diff options
author | Brion Vibber <brion@pobox.com> | 2009-11-10 06:44:53 -0800 |
---|---|---|
committer | Brion Vibber <brion@pobox.com> | 2009-11-10 06:44:53 -0800 |
commit | 333c376c955fd2513ea168d712223f033db73356 (patch) | |
tree | 371f4e8399aa0ea44f2d30ae11d7d777ed812ee9 /lib | |
parent | 088081675fb7d5250a9b9dfe5015de0822cb5ac2 (diff) | |
parent | 069d3f2b2f912f2e7d2289bc58270341c9b1ecc5 (diff) |
Merge remote branch 'statusnet/0.9.x' into 0.9.x
Diffstat (limited to 'lib')
-rw-r--r-- | lib/accountsettingsaction.php | 35 | ||||
-rw-r--r-- | lib/common.php | 2 | ||||
-rw-r--r-- | lib/groupnav.php | 79 | ||||
-rw-r--r-- | lib/theme.php | 81 |
4 files changed, 138 insertions, 59 deletions
diff --git a/lib/accountsettingsaction.php b/lib/accountsettingsaction.php index a004a3ed9..9865e1748 100644 --- a/lib/accountsettingsaction.php +++ b/lib/accountsettingsaction.php @@ -102,26 +102,31 @@ class AccountSettingsNav extends Widget $this->action->elementStart('ul', array('class' => 'nav')); if (Event::handle('StartAccountSettingsNav', array(&$this->action))) { + $user = common_current_user(); - $menu = - array('profilesettings' => + $menu = array(); + $menu['profilesettings'] = array(_('Profile'), - _('Change your profile settings')), - 'avatarsettings' => - array(_('Avatar'), - _('Upload an avatar')), - 'passwordsettings' => - array(_('Password'), - _('Change your password')), - 'emailsettings' => + _('Change your profile settings')); + if(Event::handle('CanUserChangeField', array($user->nickname, 'avatar'))){ + $menu['avatarsettings'] = + array(_('Avatar'), + _('Upload an avatar')); + } + if(Event::handle('CanUserChangeField', array($user->nickname, 'password'))){ + $menu['passwordsettings'] = + array(_('Password'), + _('Change your password')); + } + $menu['emailsettings'] = array(_('Email'), - _('Change email handling')), - 'userdesignsettings' => + _('Change email handling')); + $menu['userdesignsettings'] = array(_('Design'), - _('Design your profile')), - 'othersettings' => + _('Design your profile')); + $menu['othersettings'] = array(_('Other'), - _('Other options'))); + _('Other options')); foreach ($menu as $menuaction => $menudesc) { $this->action->menuItem(common_local_url($menuaction), diff --git a/lib/common.php b/lib/common.php index 6aac46807..c473d9cdb 100644 --- a/lib/common.php +++ b/lib/common.php @@ -38,6 +38,8 @@ 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/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/theme.php b/lib/theme.php index c658058ff..020ce1ac4 100644 --- a/lib/theme.php +++ b/lib/theme.php @@ -70,7 +70,7 @@ class Theme // Check to see if it's in the local dir - $localroot = INSTALLDIR.'/local/theme'; + $localroot = self::localRoot(); $fulldir = $localroot.'/'.$name; @@ -82,11 +82,7 @@ class Theme // Check to see if it's in the distribution dir - $instroot = common_config('theme', 'dir'); - - if (empty($instroot)) { - $instroot = INSTALLDIR.'/theme'; - } + $instroot = self::installRoot(); $fulldir = $instroot.'/'.$name; @@ -175,4 +171,77 @@ class Theme $theme = new Theme($name); return $theme->getPath($relative); } + + /** + * list available theme names + * + * @return array list of available theme names + */ + + static function listAvailable() + { + $local = self::subdirsOf(self::localRoot()); + $install = self::subdirsOf(self::installRoot()); + + $i = array_search('base', $install); + + unset($install[$i]); + + return array_merge($local, $install); + } + + /** + * Utility for getting subdirs of a directory + * + * @param string $dir full path to directory to check + * + * @return array relative filenames of subdirs, or empty array + */ + + protected static function subdirsOf($dir) + { + $subdirs = array(); + + if (is_dir($dir)) { + if ($dh = opendir($dir)) { + while (($filename = readdir($dh)) !== false) { + if ($filename != '..' && $filename !== '.' && + is_dir($dir.'/'.$filename)) { + $subdirs[] = $filename; + } + } + closedir($dh); + } + } + + return $subdirs; + } + + /** + * Local root dir for themes + * + * @return string local root dir for themes + */ + + protected static function localRoot() + { + return INSTALLDIR.'/local/theme'; + } + + /** + * Root dir for themes that are shipped with StatusNet + * + * @return string root dir for StatusNet themes + */ + + protected static function installRoot() + { + $instroot = common_config('theme', 'dir'); + + if (empty($instroot)) { + $instroot = INSTALLDIR.'/theme'; + } + + return $instroot; + } } |