summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/accountsettingsaction.php57
-rw-r--r--lib/api.php59
-rw-r--r--lib/apiauth.php2
-rw-r--r--lib/common.php2
-rw-r--r--lib/dberroraction.php6
-rw-r--r--lib/default.php4
-rw-r--r--lib/error.php4
-rw-r--r--lib/groupnav.php79
-rw-r--r--lib/htmloutputter.php2
-rw-r--r--lib/imagefile.php2
-rw-r--r--lib/jabber.php2
-rw-r--r--lib/language.php1
-rw-r--r--lib/mail.php6
-rw-r--r--lib/noticelist.php4
-rw-r--r--lib/queuehandler.php12
-rw-r--r--lib/rssaction.php2
-rw-r--r--lib/search_engines.php73
-rw-r--r--lib/util.php64
-rw-r--r--lib/xmloutputter.php2
-rw-r--r--lib/xmppqueuehandler.php2
20 files changed, 168 insertions, 217 deletions
diff --git a/lib/accountsettingsaction.php b/lib/accountsettingsaction.php
index 9865e1748..c79a1f5d7 100644
--- a/lib/accountsettingsaction.php
+++ b/lib/accountsettingsaction.php
@@ -104,35 +104,29 @@ class AccountSettingsNav extends Widget
if (Event::handle('StartAccountSettingsNav', array(&$this->action))) {
$user = common_current_user();
- $menu = array();
- $menu['profilesettings'] =
- array(_('Profile'),
- _('Change your profile settings'));
- if(Event::handle('CanUserChangeField', array($user->nickname, 'avatar'))){
- $menu['avatarsettings'] =
- array(_('Avatar'),
- _('Upload an avatar'));
+ if(Event::handle('StartAccountSettingsProfileMenuItem', array($this, &$menu))){
+ $this->showMenuItem('profilesettings',_('Profile'),_('Change your profile settings'));
+ Event::handle('EndAccountSettingsProfileMenuItem', array($this, &$menu));
}
- if(Event::handle('CanUserChangeField', array($user->nickname, 'password'))){
- $menu['passwordsettings'] =
- array(_('Password'),
- _('Change your password'));
+ if(Event::handle('StartAccountSettingsAvatarMenuItem', array($this, &$menu))){
+ $this->showMenuItem('avatarsettings',_('Avatar'),_('Upload an avatar'));
+ Event::handle('EndAccountSettingsAvatarMenuItem', array($this, &$menu));
}
- $menu['emailsettings'] =
- array(_('Email'),
- _('Change email handling'));
- $menu['userdesignsettings'] =
- array(_('Design'),
- _('Design your profile'));
- $menu['othersettings'] =
- array(_('Other'),
- _('Other options'));
-
- foreach ($menu as $menuaction => $menudesc) {
- $this->action->menuItem(common_local_url($menuaction),
- $menudesc[0],
- $menudesc[1],
- $action_name === $menuaction);
+ if(Event::handle('StartAccountSettingsPasswordMenuItem', array($this, &$menu))){
+ $this->showMenuItem('passwordsettings',_('Password'),_('Change your password'));
+ Event::handle('EndAccountSettingsPasswordMenuItem', array($this, &$menu));
+ }
+ if(Event::handle('StartAccountSettingsEmailMenuItem', array($this, &$menu))){
+ $this->showMenuItem('emailsettings',_('Email'),_('Change email handling'));
+ Event::handle('EndAccountSettingsEmailMenuItem', array($this, &$menu));
+ }
+ if(Event::handle('StartAccountSettingsDesignMenuItem', array($this, &$menu))){
+ $this->showMenuItem('userdesignsettings',_('Design'),_('Design your profile'));
+ Event::handle('EndAccountSettingsDesignMenuItem', array($this, &$menu));
+ }
+ if(Event::handle('StartAccountSettingsOtherMenuItem', array($this, &$menu))){
+ $this->showMenuItem('othersettings',_('Other'),_('Other options'));
+ Event::handle('EndAccountSettingsOtherMenuItem', array($this, &$menu));
}
Event::handle('EndAccountSettingsNav', array(&$this->action));
@@ -140,4 +134,13 @@ class AccountSettingsNav extends Widget
$this->action->elementEnd('ul');
}
+
+ function showMenuItem($menuaction, $desc1, $desc2)
+ {
+ $action_name = $this->action->trimmed('action');
+ $this->action->menuItem(common_local_url($menuaction),
+ $desc1,
+ $desc2,
+ $action_name === $menuaction);
+ }
}
diff --git a/lib/api.php b/lib/api.php
index 5da9d4982..e2ea87b43 100644
--- a/lib/api.php
+++ b/lib/api.php
@@ -60,26 +60,26 @@ class ApiAction extends Action
var $max_id = null;
var $since_id = null;
var $since = null;
-
+
/**
* Initialization.
*
* @param array $args Web and URL arguments
*
- * @return boolean false if user does not exist
+ * @return boolean false if user doesn't exist
*/
function prepare($args)
{
parent::prepare($args);
-
+
$this->format = $this->arg('format');
$this->page = (int)$this->arg('page', 1);
$this->count = (int)$this->arg('count', 20);
$this->max_id = (int)$this->arg('max_id', 0);
$this->since_id = (int)$this->arg('since_id', 0);
$this->since = $this->arg('since');
-
+
return true;
}
@@ -138,7 +138,7 @@ class ApiAction extends Action
$design = null;
$user = $profile->getUser();
- // Note: some profiles do not have an associated user
+ // Note: some profiles don't have an associated user
if (!empty($user)) {
$design = $user->getDesign();
@@ -164,7 +164,6 @@ class ApiAction extends Action
$twitter_user['favourites_count'] = $profile->faveCount(); // British spelling!
-
$timezone = 'UTC';
if ($user->timezone) {
@@ -208,7 +207,7 @@ class ApiAction extends Action
if ($get_notice) {
$notice = $profile->getCurrentNotice();
if ($notice) {
- # do not get user!
+ # don't get user!
$twitter_user['status'] = $this->twitterStatusArray($notice, false);
}
}
@@ -243,6 +242,15 @@ class ApiAction extends Action
$twitter_status['in_reply_to_screen_name'] =
($replier_profile) ? $replier_profile->nickname : null;
+ if (isset($notice->lat) && isset($notice->lon)) {
+ // This is the format that GeoJSON expects stuff to be in
+ $twitter_status['geo'] = array('type' => 'Point',
+ 'coordinates' => array((float) $notice->lat,
+ (float) $notice->lon));
+ } else {
+ $twitter_status['geo'] = null;
+ }
+
if (isset($this->auth_user)) {
$twitter_status['favorited'] = $this->auth_user->hasFave($notice);
} else {
@@ -268,7 +276,7 @@ class ApiAction extends Action
}
if ($include_user) {
- # Do not get notice (recursive!)
+ # Don't get notice (recursive!)
$twitter_user = $this->twitterUserArray($profile, false);
$twitter_status['user'] = $twitter_user;
}
@@ -367,10 +375,19 @@ class ApiAction extends Action
$entry['pubDate'] = common_date_rfc2822($notice->created);
$entry['guid'] = $entry['link'];
+ if (isset($notice->lat) && isset($notice->lon)) {
+ // This is the format that GeoJSON expects stuff to be in.
+ // showGeoRSS() below uses it for XML output, so we reuse it
+ $entry['geo'] = array('type' => 'Point',
+ 'coordinates' => array((float) $notice->lat,
+ (float) $notice->lon));
+ } else {
+ $entry['geo'] = null;
+ }
+
return $entry;
}
-
function twitterRelationshipArray($source, $target)
{
$relationship = array();
@@ -446,6 +463,9 @@ class ApiAction extends Action
case 'attachments':
$this->showXmlAttachments($twitter_status['attachments']);
break;
+ case 'geo':
+ $this->showGeoRSS($value);
+ break;
default:
$this->element($element, null, $value);
}
@@ -489,6 +509,18 @@ class ApiAction extends Action
}
}
+ function showGeoRSS($geo)
+ {
+ if (empty($geo)) {
+ // empty geo element
+ $this->element('geo');
+ } else {
+ $this->elementStart('geo', array('xmlns:georss' => 'http://www.georss.org/georss'));
+ $this->element('georss:point', null, $geo['coordinates'][0] . ' ' . $geo['coordinates'][1]);
+ $this->elementEnd('geo');
+ }
+ }
+
function showTwitterRssItem($entry)
{
$this->elementStart('item');
@@ -510,6 +542,7 @@ class ApiAction extends Action
}
}
+ $this->showGeoRSS($entry['geo']);
$this->elementEnd('item');
}
@@ -534,7 +567,6 @@ class ApiAction extends Action
$this->endDocument('json');
}
-
function showXmlTimeline($notice)
{
@@ -654,7 +686,6 @@ class ApiAction extends Action
$this->endTwitterRss();
}
-
function showTwitterAtomEntry($entry)
{
$this->elementStart('entry');
@@ -1079,7 +1110,7 @@ class ApiAction extends Action
function initTwitterAtom()
{
$this->startXML();
- // FIXME: do not hardcode the language here!
+ // FIXME: don't hardcode the language here!
$this->elementStart('feed', array('xmlns' => 'http://www.w3.org/2005/Atom',
'xml:lang' => 'en-US',
'xmlns:thr' => 'http://purl.org/syndication/thread/1.0'));
@@ -1121,7 +1152,7 @@ class ApiAction extends Action
return User::staticGet('nickname', $nickname);
} else if ($this->arg('user_id')) {
// This is to ensure that a non-numeric user_id still
- // overrides screen_name even if it does not get used
+ // overrides screen_name even if it doesn't get used
if (is_numeric($this->arg('user_id'))) {
return User::staticGet('id', $this->arg('user_id'));
}
@@ -1151,7 +1182,7 @@ class ApiAction extends Action
return User_group::staticGet('nickname', $nickname);
} else if ($this->arg('group_id')) {
// This is to ensure that a non-numeric user_id still
- // overrides screen_name even if it does not get used
+ // overrides screen_name even if it doesn't get used
if (is_numeric($this->arg('group_id'))) {
return User_group::staticGet('id', $this->arg('group_id'));
}
diff --git a/lib/apiauth.php b/lib/apiauth.php
index b8189f15d..2f2e44a26 100644
--- a/lib/apiauth.php
+++ b/lib/apiauth.php
@@ -87,7 +87,7 @@ class ApiAuthAction extends ApiAction
}
/**
- * Check for a user specified via HTTP basic auth. If there is not
+ * Check for a user specified via HTTP basic auth. If there isn't
* one, try to get one by outputting the basic auth header.
*
* @return boolean true or false
diff --git a/lib/common.php b/lib/common.php
index c473d9cdb..6aac46807 100644
--- a/lib/common.php
+++ b/lib/common.php
@@ -38,8 +38,6 @@ define('FOREIGN_NOTICE_SEND_REPLY', 4);
define('FOREIGN_FRIEND_SEND', 1);
define('FOREIGN_FRIEND_RECV', 2);
-if ( $_REQUEST['p'] == 'check-fancy') { exit; } //exit with 200 response, if this is checking fancy from the installer
-
define_syslog_variables();
# append our extlib dir as the last-resort place to find libs
diff --git a/lib/dberroraction.php b/lib/dberroraction.php
index 893797b70..2cb66a022 100644
--- a/lib/dberroraction.php
+++ b/lib/dberroraction.php
@@ -39,7 +39,7 @@ require_once INSTALLDIR.'/lib/servererroraction.php';
*
* This only occurs if there's been a DB_DataObject_Error that's
* reported through PEAR, so we try to avoid doing anything that connects
- * to the DB, so we do not trigger it again.
+ * to the DB, so we don't trigger it again.
*
* @category Action
* @package StatusNet
@@ -62,12 +62,12 @@ class DBErrorAction extends ServerErrorAction
function getLanguage()
{
- // Do not try to figure out user's language; just show the page
+ // Don't try to figure out user's language; just show the page
return common_config('site', 'language');
}
function showPrimaryNav()
{
- // do not show primary nav
+ // don't show primary nav
}
}
diff --git a/lib/default.php b/lib/default.php
index f6cc4b725..95366e0b3 100644
--- a/lib/default.php
+++ b/lib/default.php
@@ -125,10 +125,6 @@ $default =
'public' => array()), # JIDs of users who want to receive the public stream
'invite' =>
array('enabled' => true),
- 'sphinx' =>
- array('enabled' => false,
- 'server' => 'localhost',
- 'port' => 3312),
'tag' =>
array('dropoff' => 864000.0),
'popular' =>
diff --git a/lib/error.php b/lib/error.php
index 5ed5dec1b..3162cfe65 100644
--- a/lib/error.php
+++ b/lib/error.php
@@ -104,11 +104,11 @@ class ErrorAction extends Action
{
parent::showPage();
- // We do not want to have any more output after this
+ // We don't want to have any more output after this
exit();
}
- // Overload a bunch of stuff so the page is not too bloated
+ // Overload a bunch of stuff so the page isn't too bloated
function showBody()
{
diff --git a/lib/groupnav.php b/lib/groupnav.php
index 31cf378c8..131b38fa2 100644
--- a/lib/groupnav.php
+++ b/lib/groupnav.php
@@ -79,46 +79,49 @@ class GroupNav extends Widget
$nickname = $this->group->nickname;
$this->out->elementStart('ul', array('class' => 'nav'));
- $this->out->menuItem(common_local_url('showgroup', array('nickname' =>
- $nickname)),
- _('Group'),
- sprintf(_('%s group'), $nickname),
- $action_name == 'showgroup',
- 'nav_group_group');
- $this->out->menuItem(common_local_url('groupmembers', array('nickname' =>
- $nickname)),
- _('Members'),
- sprintf(_('%s group members'), $nickname),
- $action_name == 'groupmembers',
- 'nav_group_members');
+ if (Event::handle('StartGroupGroupNav', array($this))) {
+ $this->out->menuItem(common_local_url('showgroup', array('nickname' =>
+ $nickname)),
+ _('Group'),
+ sprintf(_('%s group'), $nickname),
+ $action_name == 'showgroup',
+ 'nav_group_group');
+ $this->out->menuItem(common_local_url('groupmembers', array('nickname' =>
+ $nickname)),
+ _('Members'),
+ sprintf(_('%s group members'), $nickname),
+ $action_name == 'groupmembers',
+ 'nav_group_members');
- $cur = common_current_user();
+ $cur = common_current_user();
- if ($cur && $cur->isAdmin($this->group)) {
- $this->out->menuItem(common_local_url('blockedfromgroup', array('nickname' =>
- $nickname)),
- _('Blocked'),
- sprintf(_('%s blocked users'), $nickname),
- $action_name == 'blockedfromgroup',
- 'nav_group_blocked');
- $this->out->menuItem(common_local_url('editgroup', array('nickname' =>
- $nickname)),
- _('Admin'),
- sprintf(_('Edit %s group properties'), $nickname),
- $action_name == 'editgroup',
- 'nav_group_admin');
- $this->out->menuItem(common_local_url('grouplogo', array('nickname' =>
- $nickname)),
- _('Logo'),
- sprintf(_('Add or edit %s logo'), $nickname),
- $action_name == 'grouplogo',
- 'nav_group_logo');
- $this->out->menuItem(common_local_url('groupdesignsettings', array('nickname' =>
- $nickname)),
- _('Design'),
- sprintf(_('Add or edit %s design'), $nickname),
- $action_name == 'groupdesignsettings',
- 'nav_group_design');
+ if ($cur && $cur->isAdmin($this->group)) {
+ $this->out->menuItem(common_local_url('blockedfromgroup', array('nickname' =>
+ $nickname)),
+ _('Blocked'),
+ sprintf(_('%s blocked users'), $nickname),
+ $action_name == 'blockedfromgroup',
+ 'nav_group_blocked');
+ $this->out->menuItem(common_local_url('editgroup', array('nickname' =>
+ $nickname)),
+ _('Admin'),
+ sprintf(_('Edit %s group properties'), $nickname),
+ $action_name == 'editgroup',
+ 'nav_group_admin');
+ $this->out->menuItem(common_local_url('grouplogo', array('nickname' =>
+ $nickname)),
+ _('Logo'),
+ sprintf(_('Add or edit %s logo'), $nickname),
+ $action_name == 'grouplogo',
+ 'nav_group_logo');
+ $this->out->menuItem(common_local_url('groupdesignsettings', array('nickname' =>
+ $nickname)),
+ _('Design'),
+ sprintf(_('Add or edit %s design'), $nickname),
+ $action_name == 'groupdesignsettings',
+ 'nav_group_design');
+ }
+ Event::handle('EndGroupGroupNav', array($this));
}
$this->out->elementEnd('ul');
}
diff --git a/lib/htmloutputter.php b/lib/htmloutputter.php
index 73bd9ce81..c2ec83c28 100644
--- a/lib/htmloutputter.php
+++ b/lib/htmloutputter.php
@@ -76,7 +76,7 @@ class HTMLOutputter extends XMLOutputter
/**
* Start an HTML document
*
- * If $type is not specified, will attempt to do content negotiation.
+ * If $type isn't specified, will attempt to do content negotiation.
*
* Attempts to do content negotiation for language, also.
*
diff --git a/lib/imagefile.php b/lib/imagefile.php
index edc7218d0..cf1668f20 100644
--- a/lib/imagefile.php
+++ b/lib/imagefile.php
@@ -119,7 +119,7 @@ class ImageFile
return;
}
- // Do not crop/scale if it is not necessary
+ // Don't crop/scale if it isn't necessary
if ($size === $this->width
&& $size === $this->height
&& $x === 0
diff --git a/lib/jabber.php b/lib/jabber.php
index d666fcbb3..73f2ec660 100644
--- a/lib/jabber.php
+++ b/lib/jabber.php
@@ -437,7 +437,7 @@ function jabber_public_notice($notice)
$public = common_config('xmpp', 'public');
- // FIXME PRIV do not send out private messages here
+ // FIXME PRIV don't send out private messages here
// XXX: should we send out non-local messages if public,localonly
// = false? I think not
diff --git a/lib/language.php b/lib/language.php
index bec5620fd..2570907b7 100644
--- a/lib/language.php
+++ b/lib/language.php
@@ -101,6 +101,7 @@ function get_nice_language_list()
*/
function get_all_languages() {
return array(
+ 'ar' => array('q' => 0.8, 'lang' => 'ar', 'name' => 'Arabic', 'direction' => 'rtl'),
'bg' => array('q' => 0.8, 'lang' => 'bg', 'name' => 'Bulgarian', 'direction' => 'ltr'),
'ca' => array('q' => 0.5, 'lang' => 'ca', 'name' => 'Catalan', 'direction' => 'ltr'),
'cs' => array('q' => 0.5, 'lang' => 'cs', 'name' => 'Czech', 'direction' => 'ltr'),
diff --git a/lib/mail.php b/lib/mail.php
index 79630b721..5218059e9 100644
--- a/lib/mail.php
+++ b/lib/mail.php
@@ -467,7 +467,7 @@ function mail_notify_nudge($from, $to)
"these days and is inviting you to post some news.\n\n".
"So let's hear from you :)\n\n".
"%3\$s\n\n".
- "Do not reply to this email. It will not get to them.\n\n".
+ "Don't reply to this email; it won't get to them.\n\n".
"With kind regards,\n".
"%4\$s\n"),
$from_profile->getBestName(),
@@ -516,7 +516,7 @@ function mail_notify_message($message, $from=null, $to=null)
"------------------------------------------------------\n\n".
"You can reply to their message here:\n\n".
"%4\$s\n\n".
- "Do not reply to this email. It will not get to them.\n\n".
+ "Don't reply to this email; it won't get to them.\n\n".
"With kind regards,\n".
"%5\$s\n"),
$from_profile->getBestName(),
@@ -532,7 +532,7 @@ function mail_notify_message($message, $from=null, $to=null)
/**
* notify a user that one of their notices has been chosen as a 'fave'
*
- * Does not check that the user has an email address nor if they
+ * Doesn't check that the user has an email address nor if they
* want to receive notification of faves. Maybe this happens higher
* up the stack...?
*
diff --git a/lib/noticelist.php b/lib/noticelist.php
index 4e5623ded..bf12bb73c 100644
--- a/lib/noticelist.php
+++ b/lib/noticelist.php
@@ -347,7 +347,7 @@ class NoticeListItem extends Widget
* show the link to the main page for the notice
*
* Displays a link to the page for a notice, with "relative" time. Tries to
- * get remote notice URLs correct, but does not always succeed.
+ * get remote notice URLs correct, but doesn't always succeed.
*
* @return void
*/
@@ -483,7 +483,7 @@ class NoticeListItem extends Widget
* show a link to reply to the current notice
*
* Should either do the reply in the current notice form (if available), or
- * link out to the notice-posting form. A little flakey, does not always work.
+ * link out to the notice-posting form. A little flakey, doesn't always work.
*
* @return void
*/
diff --git a/lib/queuehandler.php b/lib/queuehandler.php
index 7c07ca4f9..cd43b1e09 100644
--- a/lib/queuehandler.php
+++ b/lib/queuehandler.php
@@ -96,8 +96,8 @@ class QueueHandler extends Daemon
* Initialization, run when the queue handler starts.
* If this function indicates failure, the handler run will be aborted.
*
- * @fixme run() will abort if this does not return true,
- * but some subclasses do not bother.
+ * @fixme run() will abort if this doesn't return true,
+ * but some subclasses don't bother.
* @return boolean true on success, false on failure
*/
function start()
@@ -108,8 +108,8 @@ class QueueHandler extends Daemon
* Cleanup, run when the queue handler ends.
* If this function indicates failure, a warning will be logged.
*
- * @fixme run() will throw warnings if this does not return true,
- * but many subclasses do not bother.
+ * @fixme run() will throw warnings if this doesn't return true,
+ * but many subclasses don't bother.
* @return boolean true on success, false on failure
*/
function finish()
@@ -137,7 +137,7 @@ class QueueHandler extends Daemon
* method, which passes control back to our handle_notice() method for
* each notice that comes in on the queue.
*
- * Most of the time this will not need to be overridden in a subclass.
+ * Most of the time this won't need to be overridden in a subclass.
*
* @return boolean true on success, false on failure
*/
@@ -173,7 +173,7 @@ class QueueHandler extends Daemon
* Called by QueueHandler after each handled item or empty polling cycle.
* This is a good time to e.g. service your XMPP connection.
*
- * Does not need to be overridden if there's no maintenance to do.
+ * Doesn't need to be overridden if there's no maintenance to do.
*
* @param int $timeout seconds to sleep if there's nothing to do
*/
diff --git a/lib/rssaction.php b/lib/rssaction.php
index 0e84a65e9..faf6bec7d 100644
--- a/lib/rssaction.php
+++ b/lib/rssaction.php
@@ -386,7 +386,7 @@ class Rss10Action extends Action
return null;
}
- // FIXME: does not handle modified profiles, avatars, deleted notices
+ // FIXME: doesn't handle modified profiles, avatars, deleted notices
return strtotime($this->notices[0]->created);
}
diff --git a/lib/search_engines.php b/lib/search_engines.php
index 82713235c..332db3f89 100644
--- a/lib/search_engines.php
+++ b/lib/search_engines.php
@@ -46,70 +46,11 @@ class SearchEngine
}
}
-class SphinxSearch extends SearchEngine
-{
- private $sphinx;
- private $connected;
-
- function __construct($target, $table)
- {
- $fp = @fsockopen(common_config('sphinx', 'server'), common_config('sphinx', 'port'));
- if (!$fp) {
- $this->connected = false;
- return;
- }
- fclose($fp);
- parent::__construct($target, $table);
- $this->sphinx = new SphinxClient;
- $this->sphinx->setServer(common_config('sphinx', 'server'), common_config('sphinx', 'port'));
- $this->connected = true;
- }
-
- function is_connected()
- {
- return $this->connected;
- }
-
- function limit($offset, $count, $rss = false)
- {
- //FIXME without LARGEST_POSSIBLE, the most recent results aren't returned
- // this probably has a large impact on performance
- $LARGEST_POSSIBLE = 1e6;
-
- if ($rss) {
- $this->sphinx->setLimits($offset, $count, $count, $LARGEST_POSSIBLE);
- }
- else {
- // return at most 50 pages of results
- $this->sphinx->setLimits($offset, $count, 50 * ($count - 1), $LARGEST_POSSIBLE);
- }
-
- return $this->target->limit(0, $count);
- }
-
- function query($q)
- {
- $result = $this->sphinx->query($q, $this->table);
- if (!isset($result['matches'])) return false;
- $id_set = join(', ', array_keys($result['matches']));
- $this->target->whereAdd("id in ($id_set)");
- return true;
- }
-
- function set_sort_mode($mode)
- {
- if ('chron' === $mode) {
- $this->sphinx->SetSortMode(SPH_SORT_ATTR_DESC, 'created_ts');
- return $this->target->orderBy('created desc');
- }
- }
-}
-
class MySQLSearch extends SearchEngine
{
function query($q)
{
- if ('identica_people' === $this->table) {
+ if ('profile' === $this->table) {
$this->target->whereAdd('MATCH(nickname, fullname, location, bio, homepage) ' .
'AGAINST (\''.addslashes($q).'\' IN BOOLEAN MODE)');
if (strtolower($q) != $q) {
@@ -117,9 +58,9 @@ class MySQLSearch extends SearchEngine
'AGAINST (\''.addslashes(strtolower($q)).'\' IN BOOLEAN MODE)', 'OR');
}
return true;
- } else if ('identica_notices' === $this->table) {
+ } else if ('notice' === $this->table) {
- // Do not show imported notices
+ // Don't show imported notices
$this->target->whereAdd('notice.is_local != ' . Notice::GATEWAY);
if (strtolower($q) != $q) {
@@ -143,13 +84,13 @@ class MySQLLikeSearch extends SearchEngine
{
function query($q)
{
- if ('identica_people' === $this->table) {
+ if ('profile' === $this->table) {
$qry = sprintf('(nickname LIKE "%%%1$s%%" OR '.
' fullname LIKE "%%%1$s%%" OR '.
' location LIKE "%%%1$s%%" OR '.
' bio LIKE "%%%1$s%%" OR '.
' homepage LIKE "%%%1$s%%")', addslashes($q));
- } else if ('identica_notices' === $this->table) {
+ } else if ('notice' === $this->table) {
$qry = sprintf('content LIKE "%%%1$s%%"', addslashes($q));
} else {
throw new ServerException('Unknown table: ' . $this->table);
@@ -165,9 +106,9 @@ class PGSearch extends SearchEngine
{
function query($q)
{
- if ('identica_people' === $this->table) {
+ if ('profile' === $this->table) {
return $this->target->whereAdd('textsearch @@ plainto_tsquery(\''.addslashes($q).'\')');
- } else if ('identica_notices' === $this->table) {
+ } else if ('notice' === $this->table) {
// XXX: We need to filter out gateway notices (notice.is_local = -2) --Zach
diff --git a/lib/util.php b/lib/util.php
index b4f5af1af..81160d052 100644
--- a/lib/util.php
+++ b/lib/util.php
@@ -57,11 +57,10 @@ function common_init_language()
// we can set in another locale that may not be set up
// (say, ga_ES for Galego/Galician) it seems to take it.
common_init_locale("en_US");
-
+
$language = common_language();
$locale_set = common_init_locale($language);
setlocale(LC_CTYPE, 'C');
-
// So we do not have to make people install the gettext locales
$path = common_config('site','locale_path');
bindtextdomain("statusnet", $path);
@@ -117,51 +116,26 @@ function common_munge_password($password, $id)
}
// check if a username exists and has matching password
+
function common_check_user($nickname, $password)
{
- $authenticated = false;
- $eventResult = Event::handle('CheckPassword', array($nickname, $password, &$authenticated));
- $user = User::staticGet('nickname', $nickname);
- if (is_null($user) || $user === false) {
- //user does not exist
- if($authenticated){
- //a handler said these are valid credentials, so see if a plugin wants to auto register the user
- if(Event::handle('AutoRegister', array($nickname))){
- //no handler registered the user
- return false;
- }else{
- $user = User::staticGet('nickname', $nickname);
- if (is_null($user) || $user === false) {
- common_log(LOG_WARNING, "A plugin handled the AutoRegister event, but did not actually register the user, nickname: $nickname");
- return false;
- }else{
- return $user;
- }
- }
- }else{
- //no handler indicated the credentials were valid, and we know their not valid because the user is not in the database
- return false;
- }
- } else {
- if($eventResult && ! $authenticated){
- //no handler was authoritative
- if (mb_strlen($password) == 0) {
- // NEVER allow blank passwords, even if they match the DB
- return false;
- }else{
+ $authenticatedUser = false;
+
+ if (Event::handle('StartCheckPassword', array($nickname, $password, &$authenticatedUser))) {
+ $user = User::staticGet('nickname', $nickname);
+ if (!empty($user)) {
+ if (!empty($password)) { // never allow login with blank password
if (0 == strcmp(common_munge_password($password, $user->id),
$user->password)) {
//internal checking passed
- $authenticated = true;
+ $authenticatedUser =& $user;
}
}
}
- if($authenticated){
- return $user;
- } else {
- return false;
- }
+ Event::handle('EndCheckPassword', array($nickname, $password, $authenticatedUser));
}
+
+ return $authenticatedUser;
}
// is the current user logged in?
@@ -396,7 +370,7 @@ function common_current_user()
}
// Logins that are 'remembered' aren't 'real' -- they're subject to
-// cookie-stealing. So, we do not let them do certain things. New reg,
+// cookie-stealing. So, we don't let them do certain things. New reg,
// OpenID, and password logins _are_ real.
function common_real_login($real=true)
@@ -1112,7 +1086,11 @@ function common_log_objstring(&$object)
$arr = $object->toArray();
$fields = array();
foreach ($arr as $k => $v) {
- $fields[] = "$k='$v'";
+ if (is_object($v)) {
+ $fields[] = "$k='".get_class($v)."'";
+ } else {
+ $fields[] = "$k='$v'";
+ }
}
$objstring = $object->tableName() . '[' . implode(',', $fields) . ']';
return $objstring;
@@ -1147,7 +1125,7 @@ function common_accept_to_prefs($accept, $def = '*/*')
$parts = explode(',', $accept);
foreach($parts as $part) {
- // FIXME: does not deal with params like 'text/html; level=1'
+ // FIXME: doesn't deal with params like 'text/html; level=1'
@list($value, $qpart) = explode(';', trim($part));
$match = array();
if(!isset($qpart)) {
@@ -1346,7 +1324,7 @@ function common_error_handler($errno, $errstr, $errfile, $errline, $errcontext)
}
// FIXME: show error page if we're on the Web
- /* Do not execute PHP internal error handler */
+ /* Don't execute PHP internal error handler */
return true;
}
@@ -1448,7 +1426,7 @@ function common_shorten_url($long_url)
}
global $_shorteners;
if (!isset($_shorteners[$svc])) {
- //the user selected service does not exist, so default to ur1.ca
+ //the user selected service doesn't exist, so default to ur1.ca
$svc = 'ur1.ca';
}
if (!isset($_shorteners[$svc])) {
diff --git a/lib/xmloutputter.php b/lib/xmloutputter.php
index 9d862b2d0..5f06e491d 100644
--- a/lib/xmloutputter.php
+++ b/lib/xmloutputter.php
@@ -112,7 +112,7 @@ class XMLOutputter
*
* Utility for outputting an XML element. A convenient wrapper
* for a bunch of longer XMLWriter calls. This is best for
- * when an element does not have any sub-elements; if that's the
+ * when an element doesn't have any sub-elements; if that's the
* case, use elementStart() and elementEnd() instead.
*
* The $content element will be escaped for XML. If you need
diff --git a/lib/xmppqueuehandler.php b/lib/xmppqueuehandler.php
index 7caa078ae..f28fc9088 100644
--- a/lib/xmppqueuehandler.php
+++ b/lib/xmppqueuehandler.php
@@ -37,7 +37,7 @@ class XmppQueueHandler extends QueueHandler
function start()
{
- # Low priority; we do not want to receive messages
+ # Low priority; we don't want to receive messages
$this->log(LOG_INFO, "INITIALIZE");
$this->conn = jabber_connect($this->_id.$this->transport());