From 85e76773a04995884e798a89cc285f48377bcb62 Mon Sep 17 00:00:00 2001 From: Stefan Parviainen Date: Thu, 1 Jan 2015 15:54:16 +0100 Subject: Use grouped select field for role selection --- include/permissions.php | 38 +++++++++----------------------------- mod/new_channel.php | 7 ++----- mod/settings.php | 4 +--- view/js/mod_new_channel.js | 2 +- view/js/mod_settings.js | 4 ++-- view/tpl/new_channel.tpl | 5 +---- view/tpl/select_timezone.tpl | 11 +++++++++++ view/tpl/settings.tpl | 5 +---- 8 files changed, 28 insertions(+), 48 deletions(-) create mode 100644 view/tpl/select_timezone.tpl 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 = ''; + 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; } diff --git a/mod/new_channel.php b/mod/new_channel.php index 185fc7c28..047048f0a 100644 --- a/mod/new_channel.php +++ b/mod/new_channel.php @@ -115,11 +115,8 @@ function new_channel_content(&$a) { '$nick_desc' => t('Your nickname will be used to create an easily remembered channel address (like an email address) which you can share with others.'), '$label_import' => t('Or import an existing channel from another location'), '$name' => $name, - '$label_role' => t('Channel Type'), - '$questionmark' => t('?'), - '$what_is_role' => t('What is this?'), - '$help_role' => t('Please choose a channel type (such as social networking or community forum) and privacy requirements so we can select the best permissions for you'), - '$role_select' => role_selector(($privacy_role) ? $privacy_role : 'social'), + '$help_role' => t('Please choose a channel type (such as social networking or community forum) and privacy requirements so we can select the best permissions for you'), + '$role' => array('permissions_role' , t('Channel Type'), ($privacy_role) ? $privacy_role : 'social', ''.t('Read more about roles').'',get_roles()), '$nickname' => $nickname, '$submit' => t('Create') )); diff --git a/mod/settings.php b/mod/settings.php index bce04e436..6f5c4287b 100644 --- a/mod/settings.php +++ b/mod/settings.php @@ -1042,9 +1042,7 @@ function settings_content(&$a) { '$aclselect' => populate_acl($perm_defaults,false), '$suggestme' => $suggestme, '$group_select' => $group_select, - '$role_lbl' => t('Channel permissions category:'), - - '$role_select' => role_selector($permissions_role), + '$role' => array('permissions_role' , t('Channel permissions category:'), $permissions_role, '', get_roles()), '$profile_in_dir' => $profile_in_dir, '$hide_friends' => $hide_friends, diff --git a/view/js/mod_new_channel.js b/view/js/mod_new_channel.js index 492267ff9..c4d5408f2 100644 --- a/view/js/mod_new_channel.js +++ b/view/js/mod_new_channel.js @@ -1,5 +1,5 @@ $(document).ready(function() { -// $("#privacy-role-select").sSelect(); +// $("#id_permissions_role").sSelect(); $("#newchannel-name").blur(function() { $("#name-spinner").spin('small'); var zreg_name = $("#newchannel-name").val(); diff --git a/view/js/mod_settings.js b/view/js/mod_settings.js index 87c8c3a2b..90e17afc4 100644 --- a/view/js/mod_settings.js +++ b/view/js/mod_settings.js @@ -8,8 +8,8 @@ $(document).ready(function() { 'transition' : 'elastic' }); - $("#privacy-role-select").change(function() { - var role = $("#privacy-role-select").val(); + $("#id_permissions_role").change(function() { + var role = $("#id_permissions_role").val(); if(role == 'custom') $('#advanced-perm').show(); else diff --git a/view/tpl/new_channel.tpl b/view/tpl/new_channel.tpl index 241846eb4..ff2011181 100755 --- a/view/tpl/new_channel.tpl +++ b/view/tpl/new_channel.tpl @@ -5,10 +5,7 @@
{{$desc}}
{{$help_role}}
- - - {{$role_select}} -
{{$questionmark}}
+ {{include file="field_select_grouped.tpl" field=$role}}
diff --git a/view/tpl/select_timezone.tpl b/view/tpl/select_timezone.tpl new file mode 100644 index 000000000..2820a54f4 --- /dev/null +++ b/view/tpl/select_timezone.tpl @@ -0,0 +1,11 @@ +{{* TODO: Make id configurabel *}} + + diff --git a/view/tpl/settings.tpl b/view/tpl/settings.tpl index 83da4f87e..53f08e24f 100755 --- a/view/tpl/settings.tpl +++ b/view/tpl/settings.tpl @@ -22,10 +22,7 @@

{{$h_prv}}

-
- -{{$role_select}} -
+{{include file="field_select_grouped.tpl" field=$role}}
{{include file="field_checkbox.tpl" field=$hide_presence}} -- cgit v1.2.3