diff options
Diffstat (limited to 'include')
-rw-r--r-- | include/datetime.php | 47 | ||||
-rw-r--r-- | include/permissions.php | 38 |
2 files changed, 18 insertions, 67 deletions
diff --git a/include/datetime.php b/include/datetime.php index 59dad2045..346d03bd4 100644 --- a/include/datetime.php +++ b/include/datetime.php @@ -14,25 +14,17 @@ function timezone_cmp($a, $b) { return ( t($a) < t($b)) ? -1 : 1; } -// emit a timezone selector grouped (primarily) by continent - -function select_timezone($current = 'America/Los_Angeles') { - +// Return timezones grouped (primarily) by continent +function get_timezones( ){ $timezone_identifiers = DateTimeZone::listIdentifiers(); - - $o ='<select id="timezone_select" name="timezone">'; usort($timezone_identifiers, 'timezone_cmp'); $continent = ''; + $continents = array(); foreach($timezone_identifiers as $value) { $ex = explode("/", $value); if(count($ex) > 1) { - if($ex[0] != $continent) { - if($continent != '') - $o .= '</optgroup>'; - $continent = $ex[0]; - $o .= '<optgroup label="' . t($continent) . '">'; - } + $continent = t($ex[0]); if(count($ex) > 2) $city = substr($value,strpos($value,'/')+1); else @@ -40,35 +32,14 @@ function select_timezone($current = 'America/Los_Angeles') { } else { $city = $ex[0]; - if($continent != t('Miscellaneous')) { - $o .= '</optgroup>'; - $continent = t('Miscellaneous'); - $o .= '<optgroup label="' . t($continent) . '">'; - } + $continent = t('Miscellaneous'); } $city = str_replace('_', ' ', t($city)); - $selected = (($value == $current) ? " selected=\"selected\" " : ""); - $o .= "<option value=\"$value\" $selected >$city</option>"; - } - $o .= '</optgroup></select>'; - return $o; -} - -// return a select using 'field_select_raw' template, with timezones -// groupped (primarily) by continent -// arguments follow convetion as other field_* template array: -// 'name', 'label', $value, 'help' -function field_timezone($name='timezone', $label='', $current = 'America/Los_Angeles', $help){ - $options = select_timezone($current); - $options = str_replace('<select id="timezone_select" name="timezone">','', $options); - $options = str_replace('</select>','', $options); - - $tpl = get_markup_template('field_select_raw.tpl'); - return replace_macros($tpl, array( - '$field' => array($name, $label, $current, $help, $options), - )); - + if(!x($continents,$ex[0])) $continents[$ex[0]] = array(); + $continents[$continent][$value] = $city; + } + return $continents; } // General purpose date parse/convert function. diff --git a/include/permissions.php b/include/permissions.php index 9e60223fb..ccbde1a7c 100644 --- a/include/permissions.php +++ b/include/permissions.php @@ -800,38 +800,18 @@ function get_role_perms($role) { } /** - * @brief Creates a HTML select field with all available roles. + * @brief Returns a list or roles, grouped by type * * @param string $current The current role - * @return string Returns the complete HTML code for this privacy-role-select field. + * @return string Returns an array of roles, grouped by type */ -function role_selector($current) { - - if(! $current) - $current = 'custom'; - +function get_roles() { $roles = array( - 'social' => array( t('Social Networking'), - array('social' => t('Mostly Public'), 'social_restricted' => t('Restricted'), 'social_private' => t('Private'))), - 'forum' => array( t('Community Forum'), - array('forum' => t('Mostly Public'), 'forum_restricted' => t('Restricted'), 'forum_private' => t('Private'))), - 'feed' => array( t('Feed Republish'), - array('feed' => t('Mostly Public'), 'feed_restricted' => t('Restricted'))), - 'special' => array( t('Special Purpose'), - array('soapbox' => t('Celebrity/Soapbox'), 'repository' => t('Group Repository'))), - 'other' => array( t('Other'), - array('custom' => t('Custom/Expert Mode')))); - - $o = '<select name="permissions_role" id="privacy-role-select">'; - foreach($roles as $k => $v) { - $o .= '<optgroup label="'. htmlspecialchars($v[0]) . '">'; - foreach($v[1] as $kk => $vv) { - $selected = (($kk === $current) ? ' selected="selected"' : ''); - $o .= '<option value="' . $kk . '"' . $selected . '>' . htmlspecialchars($vv) . '</option>'; - } - $o .= '</optgroup>'; - } - $o .= '</select>'; + t('Social Networking') => array('social' => t('Mostly Public'), 'social_restricted' => t('Restricted'), 'social_private' => t('Private')), + t('Community Forum') => array('forum' => t('Mostly Public'), 'forum_restricted' => t('Restricted'), 'forum_private' => t('Private')), + t('Feed Republish') => array('feed' => t('Mostly Public'), 'feed_restricted' => t('Restricted')), + t('Special Purpose') => array('soapbox' => t('Celebrity/Soapbox'), 'repository' => t('Group Repository')), + t('Other') => array('custom' => t('Custom/Expert Mode'))); - return $o; + return $roles; } |