summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorEvan Prodromou <evan@status.net>2009-11-11 00:22:42 -0500
committerEvan Prodromou <evan@status.net>2009-11-11 00:22:42 -0500
commit935410e8dc4c2d4d286a942cc27bbf8bc452fbdd (patch)
tree98e3a577b432232bdddcc30afa9ad8a61a28d301 /lib
parent1f5f5474f175a8248b362f8be4ff23bb5e971305 (diff)
parent093857c582a68b39e0d65523d27f25ede7b7fed6 (diff)
Merge branch '0.9.x' into adminpanel
Diffstat (limited to 'lib')
-rw-r--r--lib/accountsettingsaction.php57
-rw-r--r--lib/api.php11
-rw-r--r--lib/default.php4
-rw-r--r--lib/router.php12
-rw-r--r--lib/search_engines.php71
5 files changed, 56 insertions, 99 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 5e66639c4..e2ea87b43 100644
--- a/lib/api.php
+++ b/lib/api.php
@@ -176,9 +176,14 @@ class ApiAction extends Action
$twitter_user['utc_offset'] = $t->format('Z');
$twitter_user['time_zone'] = $timezone;
- // To be supported some day, perhaps
- $twitter_user['profile_background_image_url'] = '';
- $twitter_user['profile_background_tile'] = false;
+ $twitter_user['profile_background_image_url']
+ = empty($design->backgroundimage)
+ ? '' : ($design->disposition & BACKGROUND_ON)
+ ? Design::url($design->backgroundimage) : '';
+
+ $twitter_user['profile_background_tile']
+ = empty($design->disposition)
+ ? '' : ($design->disposition & BACKGROUND_TILE) ? 'true' : 'false';
$twitter_user['statuses_count'] = $profile->noticeCount();
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/router.php b/lib/router.php
index 27ad54c19..321b4273e 100644
--- a/lib/router.php
+++ b/lib/router.php
@@ -428,9 +428,21 @@ class Router
$m->connect('api/account/verify_credentials.:format',
array('action' => 'ApiAccountVerifyCredentials'));
+ $m->connect('api/account/update_profile.:format',
+ array('action' => 'ApiAccountUpdateProfile'));
+
$m->connect('api/account/update_profile_image.:format',
array('action' => 'ApiAccountUpdateProfileImage'));
+ $m->connect('api/account/update_profile_background_image.:format',
+ array('action' => 'ApiAccountUpdateProfileBackgroundImage'));
+
+ $m->connect('api/account/update_profile_colors.:format',
+ array('action' => 'ApiAccountUpdateProfileColors'));
+
+ $m->connect('api/account/update_delivery_device.:format',
+ array('action' => 'ApiAccountUpdateDeliveryDevice'));
+
// special case where verify_credentials is called w/out a format
$m->connect('api/account/verify_credentials',
diff --git a/lib/search_engines.php b/lib/search_engines.php
index 69f6ff468..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,7 +58,7 @@ 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) {
// Don't show imported notices
$this->target->whereAdd('notice.is_local != ' . Notice::GATEWAY);
@@ -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