diff options
25 files changed, 200 insertions, 85 deletions
@@ -1228,6 +1228,30 @@ enabled: Set to true to enable. Default false. server: a string with the hostname of the sphinx server. port: an integer with the port number of the sphinx server. +emailpost +--------- + +For post-by-email. + +enabled: Whether to enable post-by-email. Defaults to true. You will + also need to set up maildaemon.php. + +sms +--- + +For SMS integration. + +enabled: Whether to enable SMS integration. Defaults to true. Queues + should also be enabled. + +twitter +------- + +For Twitter integration + +enabled: Whether to enable Twitter integration. Defaults to true. + Queues should also be enabled. + integration ----------- diff --git a/actions/emailsettings.php b/actions/emailsettings.php index 634388fdd..cdd092829 100644 --- a/actions/emailsettings.php +++ b/actions/emailsettings.php @@ -122,7 +122,7 @@ class EmailsettingsAction extends AccountSettingsAction } $this->elementEnd('fieldset'); - if ($user->email) { + if (common_config('emailpost', 'enabled') && $user->email) { $this->elementStart('fieldset', array('id' => 'settings_email_incoming')); $this->element('legend',_('Incoming email')); if ($user->incomingemail) { @@ -173,11 +173,13 @@ class EmailsettingsAction extends AccountSettingsAction _('Allow friends to nudge me and send me an email.'), $user->emailnotifynudge); $this->elementEnd('li'); - $this->elementStart('li'); - $this->checkbox('emailpost', - _('I want to post notices by email.'), - $user->emailpost); - $this->elementEnd('li'); + if (common_config('emailpost', 'enabled')) { + $this->elementStart('li'); + $this->checkbox('emailpost', + _('I want to post notices by email.'), + $user->emailpost); + $this->elementEnd('li'); + } $this->elementStart('li'); $this->checkbox('emailmicroid', _('Publish a MicroID for my email address.'), diff --git a/actions/imsettings.php b/actions/imsettings.php index e0f5ede3a..70a6f37d4 100644 --- a/actions/imsettings.php +++ b/actions/imsettings.php @@ -84,6 +84,12 @@ class ImsettingsAction extends ConnectSettingsAction function showContent() { + if (!common_config('xmpp', 'enabled')) { + $this->element('div', array('class' => 'error'), + _('IM is not available.')); + return; + } + $user = common_current_user(); $this->elementStart('form', array('method' => 'post', 'id' => 'form_settings_im', diff --git a/actions/smssettings.php b/actions/smssettings.php index 922bab9a4..33b54abf6 100644 --- a/actions/smssettings.php +++ b/actions/smssettings.php @@ -80,6 +80,12 @@ class SmssettingsAction extends ConnectSettingsAction function showContent() { + if (!common_config('sms', 'enabled')) { + $this->element('div', array('class' => 'error'), + _('SMS is not available.')); + return; + } + $user = common_current_user(); $this->elementStart('form', array('method' => 'post', diff --git a/actions/subscriptions.php b/actions/subscriptions.php index 42bdae10f..0724471ff 100644 --- a/actions/subscriptions.php +++ b/actions/subscriptions.php @@ -174,14 +174,26 @@ class SubscriptionsListItem extends SubscriptionListItem return; } + if (!common_config('xmpp', 'enabled') && !common_config('sms', 'enabled')) { + return; + } + $this->out->elementStart('form', array('id' => 'subedit-' . $this->profile->id, 'method' => 'post', 'class' => 'form_subscription_edit', 'action' => common_local_url('subedit'))); $this->out->hidden('token', common_session_token()); $this->out->hidden('profile', $this->profile->id); - $this->out->checkbox('jabber', _('Jabber'), $sub->jabber); - $this->out->checkbox('sms', _('SMS'), $sub->sms); + if (common_config('xmpp', 'enabled')) { + $this->out->checkbox('jabber', _('Jabber'), $sub->jabber); + } else { + $this->out->hidden('jabber', $sub->jabber); + } + if (common_config('sms', 'enabled')) { + $this->out->checkbox('sms', _('SMS'), $sub->sms); + } else { + $this->out->hidden('sms', $sub->sms); + } $this->out->submit('save', _('Save')); $this->out->elementEnd('form'); return; diff --git a/actions/twittersettings.php b/actions/twittersettings.php index 2b742788e..3343dba95 100644 --- a/actions/twittersettings.php +++ b/actions/twittersettings.php @@ -85,6 +85,12 @@ class TwittersettingsAction extends ConnectSettingsAction function showContent() { + if (!common_config('twitter', 'enabled')) { + $this->element('div', array('class' => 'error'), + _('Twitter is not available.')); + return; + } + $user = common_current_user(); $profile = $user->getProfile(); diff --git a/config.php.sample b/config.php.sample index c27645ff8..21b6865e1 100644 --- a/config.php.sample +++ b/config.php.sample @@ -164,6 +164,15 @@ $config['sphinx']['port'] = 3312; // $config['memcached']['server'] = 'localhost'; // $config['memcached']['port'] = 11211; +// Disable post-by-email +// $config['emailpost']['enabled'] = false; + +// Disable SMS +// $config['sms']['enabled'] = false; + +// Disable Twitter integration +// $config['twitter']['enabled'] = false; + // Twitter integration source attribute. Note: default is Laconica // $config['integration']['source'] = 'Laconica'; diff --git a/install.php b/install.php index ea2135651..f02a06663 100644 --- a/install.php +++ b/install.php @@ -180,6 +180,9 @@ function handlePost() $password = $_POST['password']; $sitename = $_POST['sitename']; $fancy = !empty($_POST['fancy']); + $server = $_SERVER['HTTP_HOST']; + $path = substr(dirname($_SERVER['PHP_SELF']), 1); + ?> <dl class="system_notice"> <dt>Page notice</dt> @@ -219,20 +222,42 @@ function handlePost() } switch($dbtype) { - case 'mysql': mysql_db_installer($host, $database, $username, $password, $sitename, $fancy); - break; - case 'pgsql': pgsql_db_installer($host, $database, $username, $password, $sitename, $fancy); - break; - default: + case 'mysql': + $db = mysql_db_installer($host, $database, $username, $password); + break; + case 'pgsql': + $db = pgsql_db_installer($host, $database, $username, $password); + break; + default: + } + + if (!$db) { + // database connection failed, do not move on to create config file. + return false; + } + + updateStatus("Writing config file..."); + $res = writeConf($sitename, $server, $path, $fancy, $db); + + if (!$res) { + updateStatus("Can't write config file.", true); + showForm(); + return; } - if ($path) $path .= '/'; - updateStatus("You can visit your <a href='/$path'>new Laconica site</a>."); + + /* + TODO https needs to be considered + */ + $link = "http://".$server.'/'.$path; + + updateStatus("Laconica has been installed at $link"); + updateStatus("You can visit your <a href='$link'>new Laconica site</a>."); ?> <?php } -function pgsql_db_installer($host, $database, $username, $password, $sitename, $fancy) { +function pgsql_db_installer($host, $database, $username, $password) { $connstring = "dbname=$database host=$host user=$username"; //No password would mean trust authentication used. @@ -265,7 +290,7 @@ function pgsql_db_installer($host, $database, $username, $password, $sitename, $ if ($res === false) { updateStatus("Can't run database script.", true); showForm(); - return; + return false; } foreach (array('sms_carrier' => 'SMS carrier', 'notice_source' => 'notice source', @@ -276,29 +301,24 @@ function pgsql_db_installer($host, $database, $username, $password, $sitename, $ if ($res === false) { updateStatus(sprintf("Can't run %d script.", $name), true); showForm(); - return; + return false; } } pg_query($conn, 'COMMIT'); - updateStatus("Writing config file..."); if (empty($password)) { $sqlUrl = "pgsql://$username@$host/$database"; } else { $sqlUrl = "pgsql://$username:$password@$host/$database"; } - $res = writeConf($sitename, $sqlUrl, $fancy, 'pgsql'); - if (!$res) { - updateStatus("Can't write config file.", true); - showForm(); - return; - } - updateStatus("Done!"); - + + $db = array('type' => 'pgsql', 'database' => $sqlUrl); + + return $db; } -function mysql_db_installer($host, $database, $username, $password, $sitename, $fancy) { +function mysql_db_installer($host, $database, $username, $password) { updateStatus("Starting installation..."); updateStatus("Checking database..."); @@ -306,21 +326,21 @@ function mysql_db_installer($host, $database, $username, $password, $sitename, $ if (!$conn) { updateStatus("Can't connect to server '$host' as '$username'.", true); showForm(); - return; + return false; } updateStatus("Changing to database..."); $res = mysql_select_db($database, $conn); if (!$res) { updateStatus("Can't change to database.", true); showForm(); - return; + return false; } updateStatus("Running database script..."); $res = runDbScript(INSTALLDIR.'/db/laconica.sql', $conn); if ($res === false) { updateStatus("Can't run database script.", true); showForm(); - return; + return false; } foreach (array('sms_carrier' => 'SMS carrier', 'notice_source' => 'notice source', @@ -331,35 +351,44 @@ function mysql_db_installer($host, $database, $username, $password, $sitename, $ if ($res === false) { updateStatus(sprintf("Can't run %d script.", $name), true); showForm(); - return; + return false; } } - updateStatus("Writing config file..."); $sqlUrl = "mysqli://$username:$password@$host/$database"; - $res = writeConf($sitename, $sqlUrl, $fancy); - if (!$res) { - updateStatus("Can't write config file.", true); - showForm(); - return; - } - updateStatus("Done!"); - } -function writeConf($sitename, $sqlUrl, $fancy, $type='mysql') + $db = array('type' => 'mysql', 'database' => $sqlUrl); + return $db; +} + +function writeConf($sitename, $server, $path, $fancy, $db) { - $res = file_put_contents(INSTALLDIR.'/config.php', - "<?php\n". - "if (!defined('LACONICA')) { exit(1); }\n\n". - "\$config['site']['name'] = \"$sitename\";\n\n". - ($fancy ? "\$config['site']['fancy'] = true;\n\n":''). - "\$config['db']['database'] = \"$sqlUrl\";\n\n". - ($type == 'pgsql' ? "\$config['db']['quote_identifiers'] = true;\n\n" . - "\$config['db']['type'] = \"$type\";\n\n" : ''). - "?>"); + // assemble configuration file in a string + $cfg = "<?php\n". + "if (!defined('LACONICA')) { exit(1); }\n\n". + + // site name + "\$config['site']['name'] = '$sitename';\n\n". + + // site location + "\$config['site']['server'] = '$server';\n". + "\$config['site']['path'] = '$path'; \n\n". + + // checks if fancy URLs are enabled + ($fancy ? "\$config['site']['fancy'] = true;\n\n":''). + + // database + "\$config['db']['database'] = '{$db['database']}';\n\n". + ($type == 'pgsql' ? "\$config['db']['quote_identifiers'] = true;\n\n":''). + "\$config['db']['type'] = '{$db['type']}';\n\n". + + "?>"; + // write configuration file out to install directory + $res = file_put_contents(INSTALLDIR.'/config.php', $cfg); + return $res; } -function runDbScript($filename, $conn, $type='mysql') +function runDbScript($filename, $conn, $type = 'mysql') { $sql = trim(file_get_contents($filename)); $stmts = explode(';', $sql); @@ -368,10 +397,15 @@ function runDbScript($filename, $conn, $type='mysql') if (!mb_strlen($stmt)) { continue; } - if ($type == 'mysql') { - $res = mysql_query($stmt, $conn); - } elseif ($type=='pgsql') { - $res = pg_query($conn, $stmt); + switch ($type) { + case 'mysql': + $res = mysql_query($stmt, $conn); + break; + case 'pgsql': + $res = pg_query($conn, $stmt); + break; + default: + updateStatus("runDbScript() error: unknown database type ". $type ." provided."); } if ($res === false) { updateStatus("FAILED SQL: $stmt"); diff --git a/lib/action.php b/lib/action.php index 1c6170693..326edf3a0 100644 --- a/lib/action.php +++ b/lib/action.php @@ -402,6 +402,14 @@ class Action extends HTMLOutputter // lawsuit function showPrimaryNav() { $user = common_current_user(); + $connect = ''; + if (common_config('xmpp', 'enabled')) { + $connect = 'imsettings'; + } else if (common_config('sms', 'enabled')) { + $connect = 'smssettings'; + } else if (common_config('twitter', 'enabled')) { + $connect = 'twittersettings'; + } $this->elementStart('dl', array('id' => 'site_nav_global_primary')); $this->element('dt', null, _('Primary site navigation')); @@ -413,12 +421,9 @@ class Action extends HTMLOutputter // lawsuit _('Home'), _('Personal profile and friends timeline'), false, 'nav_home'); $this->menuItem(common_local_url('profilesettings'), _('Account'), _('Change your email, avatar, password, profile'), false, 'nav_account'); - if (common_config('xmpp', 'enabled')) { - $this->menuItem(common_local_url('imsettings'), - _('Connect'), _('Connect to IM, SMS, Twitter'), false, 'nav_connect'); - } else { - $this->menuItem(common_local_url('smssettings'), - _('Connect'), _('Connect to SMS, Twitter'), false, 'nav_connect'); + if ($connect) { + $this->menuItem(common_local_url($connect), + _('Connect'), _('Connect to services'), false, 'nav_connect'); } if (common_config('invite', 'enabled')) { $this->menuItem(common_local_url('invite'), diff --git a/lib/common.php b/lib/common.php index b3d301862..be30519f4 100644 --- a/lib/common.php +++ b/lib/common.php @@ -183,6 +183,12 @@ $config = array('piddir' => '/var/run', 'user' => false, 'group' => false), + 'emailpost' => + array('enabled' => true), + 'sms' => + array('enabled' => true), + 'twitter' => + array('enabled' => true), 'twitterbridge' => array('enabled' => false), 'integration' => diff --git a/lib/connectsettingsaction.php b/lib/connectsettingsaction.php index 30629680e..02c468a35 100644 --- a/lib/connectsettingsaction.php +++ b/lib/connectsettingsaction.php @@ -99,25 +99,27 @@ class ConnectSettingsNav extends Widget function show() { # action => array('prompt', 'title') - $menu = - array('imsettings' => - array(_('IM'), - _('Updates by instant messenger (IM)')), - 'smssettings' => - array(_('SMS'), - _('Updates by SMS')), - 'twittersettings' => - array(_('Twitter'), - _('Twitter integration options'))); + $menu = array(); + if (common_config('xmpp', 'enabled')) { + $menu['imsettings'] = + array(_('IM'), + _('Updates by instant messenger (IM)')); + } + if (common_config('sms', 'enabled')) { + $menu['smssettings'] = + array(_('SMS'), + _('Updates by SMS')); + } + if (common_config('twitter', 'enabled')) { + $menu['twittersettings'] = + array(_('Twitter'), + _('Twitter integration options')); + } $action_name = $this->action->trimmed('action'); $this->action->elementStart('ul', array('class' => 'nav')); foreach ($menu as $menuaction => $menudesc) { - if ($menuaction == 'imsettings' && - !common_config('xmpp', 'enabled')) { - continue; - } $this->action->menuItem(common_local_url($menuaction), $menudesc[0], $menudesc[1], diff --git a/lib/htmloutputter.php b/lib/htmloutputter.php index f4445b44f..2684baca6 100644 --- a/lib/htmloutputter.php +++ b/lib/htmloutputter.php @@ -370,9 +370,6 @@ class HTMLOutputter extends XMLOutputter */ function cssLink($src,$theme=null,$media=null) { - if (!$theme) { - $theme = common_config('site', 'theme'); - } $url = parse_url($src); if(! ($url->scheme || $url->host || $url->query || $url->fragment)) { diff --git a/lib/jsonsearchresultslist.php b/lib/jsonsearchresultslist.php index 7beea9328..34a3d530e 100644 --- a/lib/jsonsearchresultslist.php +++ b/lib/jsonsearchresultslist.php @@ -207,7 +207,7 @@ class ResultItem $replier_profile = null; if ($this->notice->reply_to) { - $reply = Notice::staticGet(intval($notice->reply_to)); + $reply = Notice::staticGet(intval($this->notice->reply_to)); if ($reply) { $replier_profile = $reply->getProfile(); } @@ -224,7 +224,7 @@ class ResultItem $user = User::staticGet('id', $this->profile->id); - $this->iso_language_code = $this->user->language; + $this->iso_language_code = $user->language; $this->source = $this->getSourceLink($this->notice->source); diff --git a/scripts/getvaliddaemons.php b/scripts/getvaliddaemons.php index 1e4546dff..8b127bd20 100755 --- a/scripts/getvaliddaemons.php +++ b/scripts/getvaliddaemons.php @@ -43,7 +43,11 @@ if(common_config('twitterbridge','enabled')) { echo "twitterstatusfetcher.php "; } echo "ombqueuehandler.php "; -echo "twitterqueuehandler.php "; +if (common_config('twitter', 'enabled')) { + echo "twitterqueuehandler.php "; +} echo "facebookqueuehandler.php "; echo "pingqueuehandler.php "; -echo "smsqueuehandler.php "; +if (common_config('sms', 'enabled')) { + echo "smsqueuehandler.php "; +} diff --git a/scripts/maildaemon.php b/scripts/maildaemon.php index 3ef4d0638..91c257adb 100755 --- a/scripts/maildaemon.php +++ b/scripts/maildaemon.php @@ -385,5 +385,7 @@ class MailerDaemon } } -$md = new MailerDaemon(); -$md->handle_message('php://stdin'); +if (common_config('emailpost', 'enabled')) { + $md = new MailerDaemon(); + $md->handle_message('php://stdin'); +} diff --git a/theme/base/images/icons/icon_atom.png b/theme/base/images/icons/icon_atom.png Binary files differindex 6a001f11a..de63f1577 100644 --- a/theme/base/images/icons/icon_atom.png +++ b/theme/base/images/icons/icon_atom.png diff --git a/theme/base/images/icons/icon_rss.png b/theme/base/images/icons/icon_rss.png Binary files differindex 0ccd1ce25..e75778a9e 100644 --- a/theme/base/images/icons/icon_rss.png +++ b/theme/base/images/icons/icon_rss.png diff --git a/theme/default/default-avatar-mini.png b/theme/default/default-avatar-mini.png Binary files differindex 38b8692b4..6c7808616 100644 --- a/theme/default/default-avatar-mini.png +++ b/theme/default/default-avatar-mini.png diff --git a/theme/default/default-avatar-profile.png b/theme/default/default-avatar-profile.png Binary files differindex f8357d4fc..08ce4e48e 100644 --- a/theme/default/default-avatar-profile.png +++ b/theme/default/default-avatar-profile.png diff --git a/theme/default/default-avatar-stream.png b/theme/default/default-avatar-stream.png Binary files differindex 6b63baa70..f18994d75 100644 --- a/theme/default/default-avatar-stream.png +++ b/theme/default/default-avatar-stream.png diff --git a/theme/default/logo.png b/theme/default/logo.png Binary files differindex fdead6c4a..322cbe903 100644 --- a/theme/default/logo.png +++ b/theme/default/logo.png diff --git a/theme/identica/default-avatar-mini.png b/theme/identica/default-avatar-mini.png Binary files differindex 38b8692b4..6c7808616 100644 --- a/theme/identica/default-avatar-mini.png +++ b/theme/identica/default-avatar-mini.png diff --git a/theme/identica/default-avatar-profile.png b/theme/identica/default-avatar-profile.png Binary files differindex f8357d4fc..08ce4e48e 100644 --- a/theme/identica/default-avatar-profile.png +++ b/theme/identica/default-avatar-profile.png diff --git a/theme/identica/default-avatar-stream.png b/theme/identica/default-avatar-stream.png Binary files differindex 6b63baa70..f18994d75 100644 --- a/theme/identica/default-avatar-stream.png +++ b/theme/identica/default-avatar-stream.png diff --git a/theme/identica/logo.png b/theme/identica/logo.png Binary files differindex 7c68b34f6..b32c6f951 100644 --- a/theme/identica/logo.png +++ b/theme/identica/logo.png |