From cbae1b0c8b18de0b6643e066c89578523c5e8002 Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Sun, 8 Nov 2009 17:16:50 -0500 Subject: [PATCH 01/10] add utilities for calculating local and installation theme root dirs --- lib/theme.php | 36 ++++++++++++++++++++++++++++++------ 1 file changed, 30 insertions(+), 6 deletions(-) diff --git a/lib/theme.php b/lib/theme.php index c658058ffc..e5fad2316b 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 = Theme::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 = Theme::installRoot(); $fulldir = $instroot.'/'.$name; @@ -175,4 +171,32 @@ class Theme $theme = new Theme($name); return $theme->getPath($relative); } + + /** + * 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; + } } From f086dddf43a8e1593a615e77c2fdd605623acf49 Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Sun, 8 Nov 2009 21:18:57 -0500 Subject: [PATCH 02/10] add a method to Theme class to list available themes --- lib/theme.php | 49 +++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 47 insertions(+), 2 deletions(-) diff --git a/lib/theme.php b/lib/theme.php index e5fad2316b..020ce1ac40 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 = Theme::localRoot(); + $localroot = self::localRoot(); $fulldir = $localroot.'/'.$name; @@ -82,7 +82,7 @@ class Theme // Check to see if it's in the distribution dir - $instroot = Theme::installRoot(); + $instroot = self::installRoot(); $fulldir = $instroot.'/'.$name; @@ -172,6 +172,51 @@ class Theme 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 * From ff81384ee35347b52360ef17e3537bd741a20568 Mon Sep 17 00:00:00 2001 From: Sarven Capadisli Date: Mon, 9 Nov 2009 11:10:24 +0000 Subject: [PATCH 03/10] Fixed notice option alignment in IE --- theme/base/css/ie.css | 3 --- 1 file changed, 3 deletions(-) diff --git a/theme/base/css/ie.css b/theme/base/css/ie.css index 84bc1b1d64..4e50aadbe9 100644 --- a/theme/base/css/ie.css +++ b/theme/base/css/ie.css @@ -27,11 +27,8 @@ padding:0 4px; } .notice-options input.submit { font-size:0; -margin-top:3px; -height:16px; text-align:right; text-indent:0; -width:24px; } .notice div.entry-content .timestamp a { margin-right:4px; From 2577c85a38f94612f29183b6a0a36f14d1c1f07d Mon Sep 17 00:00:00 2001 From: Sarven Capadisli Date: Mon, 9 Nov 2009 11:11:06 +0000 Subject: [PATCH 04/10] Added flag icon for UserFlag plugin --- plugins/UserFlag/flag.gif | Bin 0 -> 80 bytes 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 plugins/UserFlag/flag.gif diff --git a/plugins/UserFlag/flag.gif b/plugins/UserFlag/flag.gif new file mode 100644 index 0000000000000000000000000000000000000000..68c8aee2598d4c470b1c60c36232fea6b52dbef6 GIT binary patch literal 80 zcmZ?wbhEHb6krfwn8?KN|NsB^DFQ%}fq_BsCkrD30~3P|kPVa-0J0TB`erVB%g@;0 g#a2CkYK(uMX`+Uoh*MBz%DnK`$BZ6xu`*Z#0Jqf`MF0Q* literal 0 HcmV?d00001 From 22310d17a4886d5382832caee43da0bcf7914419 Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Mon, 9 Nov 2009 13:45:10 -0500 Subject: [PATCH 05/10] shorten flag notification and include a class --- plugins/UserFlag/UserFlagPlugin.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/plugins/UserFlag/UserFlagPlugin.php b/plugins/UserFlag/UserFlagPlugin.php index 2376bb8594..fe4a74869e 100644 --- a/plugins/UserFlag/UserFlagPlugin.php +++ b/plugins/UserFlag/UserFlagPlugin.php @@ -102,8 +102,7 @@ class UserFlagPlugin extends Plugin $action->elementStart('li', 'entity_flag'); if (User_flag_profile::exists($profile->id, $user->id)) { - $action->element('p', array(), - _('Flagged for review')); + $action->element('p', 'flagged', _('Flagged')); } else { $form = new FlagProfileForm($action, $profile, array('action' => 'showstream', From 3be120571446880cb71a57845204b3213e6df67e Mon Sep 17 00:00:00 2001 From: Craig Andrews Date: Mon, 9 Nov 2009 17:43:37 -0500 Subject: [PATCH 06/10] Add a new event: CanUserChangeField --- EVENTS.txt | 4 ++++ actions/passwordsettings.php | 14 ++++++++++++++ lib/accountsettingsaction.php | 35 ++++++++++++++++++++--------------- plugins/Ldap/LdapPlugin.php | 11 +++++++++++ 4 files changed, 49 insertions(+), 15 deletions(-) diff --git a/EVENTS.txt b/EVENTS.txt index 25a51516b4..c3fe73134c 100644 --- a/EVENTS.txt +++ b/EVENTS.txt @@ -489,6 +489,10 @@ ChangePassword: Handle a password change request - $newpassword: the desired new password - &$errormsg: set this to an error message if the password could not be changed. If the password was changed, leave this as false +CanUserChangeField: Determines if a user is allowed to change a specific profile field +- $nickname: nickname of the user who would like to know which of their profile fields are mutable +- $field: name of the field the user wants to change (nickname, fullname, password, avatar, etc) + UserDeleteRelated: Specify additional tables to delete entries from when deleting users - $user: User object - &$related: array of DB_DataObject class names to delete entries on matching user_id. diff --git a/actions/passwordsettings.php b/actions/passwordsettings.php index 6658d279f2..15539d4a01 100644 --- a/actions/passwordsettings.php +++ b/actions/passwordsettings.php @@ -58,6 +58,19 @@ class PasswordsettingsAction extends AccountSettingsAction return _('Change password'); } + function prepare($args){ + parent::prepare($args); + + $user = common_current_user(); + + Event::handle('CanUserChangeField', array($user->nickname, 'password')); + + if(! $fields['password']){ + //user is not allowed to change his password + $this->clientError(_('You are not allowed to change your password')); + } + } + /** * Instructions for use * @@ -86,6 +99,7 @@ class PasswordsettingsAction extends AccountSettingsAction function showContent() { $user = common_current_user(); + $this->elementStart('form', array('method' => 'POST', 'id' => 'form_password', 'class' => 'form_settings', diff --git a/lib/accountsettingsaction.php b/lib/accountsettingsaction.php index a004a3ed99..9865e17489 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/plugins/Ldap/LdapPlugin.php b/plugins/Ldap/LdapPlugin.php index 755562f54b..3795ffd7f1 100644 --- a/plugins/Ldap/LdapPlugin.php +++ b/plugins/Ldap/LdapPlugin.php @@ -102,4 +102,15 @@ class LdapPlugin extends Plugin //return false, indicating that the event has been handled return false; } + + function onCanUserChangeField($nickname, $field) + { + switch($field) + { + case 'password': + case 'nickname': + case 'email': + return false; + } + } } From 223fee2ad1430e827830265c9fe97f4d025bb060 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Tue, 10 Nov 2009 15:53:07 +1300 Subject: [PATCH 07/10] just sent a http 200 for the check-fancy from install.php --- lib/common.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/common.php b/lib/common.php index 6aac468075..c473d9cdbf 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 From 2f3e414cd1226b328a63854592f0783a9088baae Mon Sep 17 00:00:00 2001 From: Sarven Capadisli Date: Tue, 10 Nov 2009 13:08:58 +0000 Subject: [PATCH 08/10] Updated group block markup --- actions/groupblock.php | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/actions/groupblock.php b/actions/groupblock.php index 133101eb7a..fe09cbc2d6 100644 --- a/actions/groupblock.php +++ b/actions/groupblock.php @@ -151,17 +151,19 @@ class GroupblockAction extends Action function areYouSureForm() { $id = $this->profile->id; + $this->elementStart('form', array('id' => 'block-' . $id, + 'method' => 'post', + 'class' => 'form_settings form_entity_block', + 'action' => common_local_url('groupblock'))); + $this->elementStart('fieldset'); + $this->hidden('token', common_session_token()); + $this->element('legend', _('Block user')); $this->element('p', null, sprintf(_('Are you sure you want to block user "%s" from the group "%s"? '. 'They will be removed from the group, unable to post, and '. 'unable to subscribe to the group in the future.'), $this->profile->getBestName(), $this->group->getBestName())); - $this->elementStart('form', array('id' => 'block-' . $id, - 'method' => 'post', - 'class' => 'block', - 'action' => common_local_url('groupblock'))); - $this->hidden('token', common_session_token()); $this->hidden('blockto-' . $this->profile->id, $this->profile->id, 'blockto'); @@ -173,8 +175,9 @@ class GroupblockAction extends Action $this->hidden($k, $v); } } - $this->submit('no', _('No')); - $this->submit('yes', _('Yes')); + $this->submit('form_action-no', _('No'), 'submit form_action-primary', 'no', _("Do not block this user from this group")); + $this->submit('form_action-yes', _('Yes'), 'submit form_action-secondary', 'yes', _('Block this user from this group')); + $this->elementEnd('fieldset'); $this->elementEnd('form'); } From 91da72ede0b834d017165ececdc340ec0a24227b Mon Sep 17 00:00:00 2001 From: Sarven Capadisli Date: Tue, 10 Nov 2009 13:09:15 +0000 Subject: [PATCH 09/10] Updated block @title text (shouldn't say from group) --- actions/block.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/actions/block.php b/actions/block.php index 408f16434b..b125d2d8b6 100644 --- a/actions/block.php +++ b/actions/block.php @@ -146,8 +146,8 @@ class BlockAction extends Action $this->hidden($k, $v); } } - $this->submit('form_action-no', _('No'), 'submit form_action-primary', 'no', _("Do not block this user from this group")); - $this->submit('form_action-yes', _('Yes'), 'submit form_action-secondary', 'yes', _('Block this user from this group')); + $this->submit('form_action-no', _('No'), 'submit form_action-primary', 'no', _("Do not block this user")); + $this->submit('form_action-yes', _('Yes'), 'submit form_action-secondary', 'yes', _('Block this user')); $this->elementEnd('fieldset'); $this->elementEnd('form'); } From 069d3f2b2f912f2e7d2289bc58270341c9b1ecc5 Mon Sep 17 00:00:00 2001 From: Sarven Capadisli Date: Tue, 10 Nov 2009 13:52:47 +0000 Subject: [PATCH 10/10] Added hook for the Group navigation items --- EVENTS.txt | 6 ++++ lib/groupnav.php | 81 +++++++++++++++++++++++++----------------------- 2 files changed, 48 insertions(+), 39 deletions(-) diff --git a/EVENTS.txt b/EVENTS.txt index c3fe73134c..af686b9cdf 100644 --- a/EVENTS.txt +++ b/EVENTS.txt @@ -191,6 +191,12 @@ StartPersonalGroupNav: beginning of personal group nav menu EndPersonalGroupNav: end of personal group nav menu (good place to add a menu item) - $action: action object being shown +StartGroupGroupNav: Showing the group nav menu +- $action: the current action + +EndGroupGroupNav: At the end of the group nav menu +- $action: the current action + StartEndHTML: just before the tag - $action: action object being shown diff --git a/lib/groupnav.php b/lib/groupnav.php index 31cf378c8a..131b38fa27 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'); - - $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' => + if (Event::handle('StartGroupGroupNav', array($this))) { + $this->out->menuItem(common_local_url('showgroup', 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'); + _('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(); + + 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'); }