Pārlūkot izejas kodu

Merge pull request #818 from MissAllSunday/AdditionalPermissions

Additional permissions for profile fields
Jessica González 10 gadi atpakaļ
vecāks
revīzija
1f52fdbe4e

+ 21 - 0
Sources/ManagePermissions.php

@@ -1126,7 +1126,12 @@ function setPermissionLevel($level, $group, $profile = 'null')
 		'send_email_to_members',
 		'profile_view_any',
 		'profile_extra_own',
+		'profile_signature_own',
+		'profile_forum_own',
+		'profile_other_own',
+		'profile_password_own',
 		'profile_server_avatar',
+		'profile_displayed_name',
 		'profile_upload_avatar',
 		'profile_remote_avatar',
 		'profile_remove_own',
@@ -1179,6 +1184,11 @@ function setPermissionLevel($level, $group, $profile = 'null')
 		'calendar_edit_any',
 		'profile_identity_any',
 		'profile_extra_any',
+		'profile_signature_any',
+		'profile_forum_own',
+		'profile_other_any',
+		'profile_displayed_name_any',
+		'profile_password_any',
 		'profile_title_any',
 	));
 	$groupLevels['board']['maintenance'] = array_merge($groupLevels['board']['moderator'], array(
@@ -1485,8 +1495,14 @@ function loadAllPermissions($loadType = 'classic')
 			'issue_warning' => array(false, 'member_admin', 'moderate_general'),
 			'profile_view' => array(true, 'profile', 'view_basic_info', 'view_basic_info'),
 			'profile_identity' => array(true, 'profile', 'edit_profile', 'moderate_general'),
+			'profile_forum' => array(true, 'profile', 'edit_profile', 'moderate_general'),
+			'profile_password' => array(true, 'profile', 'edit_profile', 'moderate_general'),
 			'profile_extra' => array(true, 'profile', 'edit_profile', 'moderate_general'),
+			'profile_signature' => array(true, 'profile', 'edit_profile', 'moderate_general'),
+			'profile_other' => array(true, 'profile', 'edit_profile', 'moderate_general'),
 			'profile_title' => array(true, 'profile', 'edit_profile', 'moderate_general'),
+			'profile_displayed_name' => array(true, 'profile', 'edit_profile', 'moderate_general'),
+			'profile_blurb' => array(true, 'profile', 'edit_profile', 'moderate_general'),
 			'profile_remove' => array(true, 'profile', 'delete_account', 'moderate_general'),
 			'profile_server_avatar' => array(false, 'profile', 'use_avatar'),
 			'profile_upload_avatar' => array(false, 'profile', 'use_avatar'),
@@ -2232,7 +2248,12 @@ function loadIllegalGuestPermissions()
 		'pm_send',
 		'profile_identity',
 		'profile_extra',
+		'profile_signature',
+		'profile_forum_own',
+		'profile_other',
+		'profile_password',
 		'profile_title',
+		'profile_displayed_name',
 		'profile_remove',
 		'profile_server_avatar',
 		'profile_upload_avatar',

+ 0 - 1
Sources/ManageSettings.php

@@ -148,7 +148,6 @@ function ModifyBasicSettings($return_config = false)
 			array('check', 'allow_guestAccess'),
 			array('check', 'enable_buddylist'),
 			array('check', 'enable_unwatch'),
-			array('check', 'allow_editDisplayName'),
 			array('check', 'allow_hideOnline'),
 			array('check', 'titlesEnable'),
 			array('text', 'default_personal_text', 'subtext' => $txt['default_personal_text_note'], 'disabled' => !$can_personal_text),

+ 20 - 20
Sources/Profile-Modify.php

@@ -180,7 +180,7 @@ function loadProfileFields($force_reload = false)
 			'label' => $txt['user_email_address'],
 			'subtext' => $txt['valid_email'],
 			'log_change' => true,
-			'permission' => 'profile_identity',
+			'permission' => 'profile_password',
 			'input_validate' => create_function('&$value', '
 				global $context, $old_profile, $context, $profile_vars, $sourcedir, $modSettings;
 
@@ -334,7 +334,7 @@ function loadProfileFields($force_reload = false)
 			'label' => $txt['location'],
 			'log_change' => true,
 			'size' => 50,
-			'permission' => 'profile_extra',
+			'permission' => 'profile_other',
 		),
 		// The username is not always editable - so adjust it as such.
 		'member_name' => array(
@@ -383,7 +383,7 @@ function loadProfileFields($force_reload = false)
 			'size' => 20,
 			'value' => '',
 			'enabled' => empty($cur_profile['openid_uri']),
-			'permission' => 'profile_identity',
+			'permission' => 'profile_password',
 			'save_key' => 'passwd',
 			// Note this will only work if passwrd2 also exists!
 			'input_validate' => create_function('&$value', '
@@ -416,7 +416,7 @@ function loadProfileFields($force_reload = false)
 			'enabled' => empty($cur_profile['openid_uri']),
 			'size' => 20,
 			'value' => '',
-			'permission' => 'profile_identity',
+			'permission' => 'profile_password',
 			'is_dummy' => true,
 		),
 		'personal_text' => array(
@@ -425,7 +425,7 @@ function loadProfileFields($force_reload = false)
 			'log_change' => true,
 			'input_attr' => array('maxlength="50"'),
 			'size' => 50,
-			'permission' => 'profile_extra',
+			'permission' => 'profile_blurb',
 			'input_validate' => create_function('&$value', '
 				global $smcFunc;
 
@@ -476,13 +476,13 @@ function loadProfileFields($force_reload = false)
 			'),
 		),
 		'real_name' => array(
-			'type' => !empty($modSettings['allow_editDisplayName']) || allowedTo('moderate_forum') ? 'text' : 'label',
+			'type' => allowedTo('profile_displayed_name_own') || allowedTo('profile_displayed_name_any') || allowedTo('moderate_forum') ? 'text' : 'label',
 			'label' => $txt['name'],
 			'subtext' => $txt['display_name_desc'],
 			'log_change' => true,
 			'input_attr' => array('maxlength="60"'),
-			'permission' => 'profile_identity',
-			'enabled' => !empty($modSettings['allow_editDisplayName']) || allowedTo('moderate_forum'),
+			'permission' => 'profile_displayed_name',
+			'enabled' => allowedTo('profile_displayed_name_own') || allowedTo('profile_displayed_name_any') || allowedTo('moderate_forum'),
 			'input_validate' => create_function('&$value', '
 				global $context, $smcFunc, $sourcedir, $cur_profile;
 
@@ -506,7 +506,7 @@ function loadProfileFields($force_reload = false)
 			'label' => $txt['secret_question'],
 			'subtext' => $txt['secret_desc'],
 			'size' => 50,
-			'permission' => 'profile_identity',
+			'permission' => 'profile_password',
 		),
 		'secret_answer' => array(
 			'type' => 'text',
@@ -515,7 +515,7 @@ function loadProfileFields($force_reload = false)
 			'size' => 20,
 			'postinput' => '<span class="smalltext" style="margin-left: 4ex;">[<a href="' . $scripturl . '?action=helpadmin;help=secret_why_blank" onclick="return reqOverlayDiv(this.href);">' . $txt['secret_why_blank'] . '</a>]</span>',
 			'value' => '',
-			'permission' => 'profile_identity',
+			'permission' => 'profile_password',
 			'input_validate' => create_function('&$value', '
 				$value = $value != \'\' ? md5($value) : \'\';
 				return true;
@@ -524,7 +524,7 @@ function loadProfileFields($force_reload = false)
 		'signature' => array(
 			'type' => 'callback',
 			'callback_func' => 'signature_modify',
-			'permission' => 'profile_extra',
+			'permission' => 'profile_signature',
 			'enabled' => substr($modSettings['signature_settings'], 0, 1) == 1,
 			'preload' => 'profileLoadSignatureData',
 			'input_validate' => 'profileValidateSignature',
@@ -634,7 +634,7 @@ function loadProfileFields($force_reload = false)
 			'log_change' => true,
 			'input_attr' => array('maxlength="50"'),
 			'size' => 50,
-			'permission' => 'profile_title',
+			'permission' => 'profile_other',
 			'enabled' => !empty($modSettings['titlesEnable']),
 			'input_validate' => create_function('&$value', '
 				global $smcFunc;
@@ -650,7 +650,7 @@ function loadProfileFields($force_reload = false)
 			'label' => $txt['website_title'],
 			'subtext' => $txt['include_website_url'],
 			'size' => 50,
-			'permission' => 'profile_extra',
+			'permission' => 'profile_other',
 			'link_with' => 'website',
 		),
 		'website_url' => array(
@@ -658,7 +658,7 @@ function loadProfileFields($force_reload = false)
 			'label' => $txt['website_url'],
 			'subtext' => $txt['complete_url'],
 			'size' => 50,
-			'permission' => 'profile_extra',
+			'permission' => 'profile_other',
 			// Fix the URL...
 			'input_validate' => create_function('&$value', '
 
@@ -941,13 +941,13 @@ function saveProfileChanges(&$profile_vars, &$post_errors, $memID)
 	// Permissions...
 	if ($context['user']['is_owner'])
 	{
-		$changeIdentity = allowedTo(array('profile_identity_any', 'profile_identity_own'));
-		$changeOther = allowedTo(array('profile_extra_any', 'profile_extra_own'));
+		$changeIdentity = allowedTo(array('profile_identity_any', 'profile_identity_own', 'profile_password_any', 'profile_password_own'));
+		$changeOther = allowedTo(array('profile_extra_any', 'profile_extra_own', 'profile_other_any', 'profile_other_own', 'profile_signature_any', 'profile_signature_own'));
 	}
 	else
 	{
-		$changeIdentity = allowedTo('profile_identity_any');
-		$changeOther = allowedTo('profile_extra_any');
+		$changeIdentity = allowedTo('profile_identity_any', 'profile_signature_any');
+		$changeOther = allowedTo('profile_extra_any', 'profile_other_any', 'profile_signature_any');
 	}
 
 	// Arrays of all the changes - makes things easier.
@@ -1572,7 +1572,7 @@ function account($memID)
 	global $context, $txt;
 
 	loadThemeOptions($memID);
-	if (allowedTo(array('profile_identity_own', 'profile_identity_any')))
+	if (allowedTo(array('profile_identity_own', 'profile_identity_any', 'profile_password_own', 'profile_password_any')))
 		loadCustomFields($memID, 'account');
 
 	$context['sub_template'] = 'edit_options';
@@ -1599,7 +1599,7 @@ function forumProfile($memID)
 	global $context, $txt;
 
 	loadThemeOptions($memID);
-	if (allowedTo(array('profile_extra_own', 'profile_extra_any')))
+	if (allowedTo(array('profile_forum_own', 'profile_forum_any')))
 		loadCustomFields($memID, 'forumprofile');
 
 	$context['sub_template'] = 'edit_options';

+ 6 - 6
Sources/Profile.php

@@ -179,8 +179,8 @@ function ModifyProfile($post_errors = array())
 					'token' => 'profile-ac%u',
 					'password' => true,
 					'permission' => array(
-						'own' => array('profile_identity_any', 'profile_identity_own', 'manage_membergroups'),
-						'any' => array('profile_identity_any', 'manage_membergroups'),
+						'own' => array('profile_identity_any', 'profile_identity_own', 'profile_password_any', 'profile_password_own', 'manage_membergroups'),
+						'any' => array('profile_identity_any', 'profile_password_any', 'manage_membergroups'),
 					),
 				),
 				'forumprofile' => array(
@@ -190,8 +190,8 @@ function ModifyProfile($post_errors = array())
 					'sc' => 'post',
 					'token' => 'profile-fp%u',
 					'permission' => array(
-						'own' => array('profile_extra_any', 'profile_extra_own', 'profile_title_own', 'profile_title_any'),
-						'any' => array('profile_extra_any', 'profile_title_any'),
+						'own' => array('profile_forum_any', 'profile_forum_own'),
+						'any' => array('profile_forum_any'),
 					),
 				),
 				'theme' => array(
@@ -215,8 +215,8 @@ function ModifyProfile($post_errors = array())
 					'hidden' => empty($modSettings['enableOpenID']) && empty($cur_profile['openid_uri']),
 					'password' => true,
 					'permission' => array(
-						'own' => array('profile_identity_any', 'profile_identity_own'),
-						'any' => array('profile_identity_any'),
+						'own' => array('profile_password_any', 'profile_password_own'),
+						'any' => array('profile_password_any'),
 					),
 				),
 				'notification' => array(

+ 2 - 2
Sources/Register.php

@@ -159,7 +159,7 @@ function Register($reg_errors = array())
 		$context['user']['is_owner'] = true;
 
 		// Here, and here only, emulate the permissions the user would have to do this.
-		$user_info['permissions'] = array_merge($user_info['permissions'], array('profile_account_own', 'profile_extra_own'));
+		$user_info['permissions'] = array_merge($user_info['permissions'], array('profile_account_own', 'profile_extra_own', 'profile_other_own', 'profile_password_own'));
 		$reg_fields = explode(',', $modSettings['registration_fields']);
 
 		// We might have had some submissions on this front - go check.
@@ -347,7 +347,7 @@ function Register2($verifiedOpenID = false)
 	require_once($sourcedir . '/Subs-Members.php');
 
 	// Validation... even if we're not a mall.
-	if (isset($_POST['real_name']) && (!empty($modSettings['allow_editDisplayName']) || allowedTo('moderate_forum')))
+	if (isset($_POST['real_name']) && (allowedTo('profile_displayed_name') || allowedTo('moderate_forum')))
 	{
 		$_POST['real_name'] = trim(preg_replace('~[\t\n\r \x0B\0' . ($context['utf8'] ? ($context['server']['complex_preg_chars'] ? '\x{A0}\x{AD}\x{2000}-\x{200F}\x{201F}\x{202F}\x{3000}\x{FEFF}' : "\xC2\xA0\xC2\xAD\xE2\x80\x80-\xE2\x80\x8F\xE2\x80\x9F\xE2\x80\xAF\xE2\x80\x9F\xE3\x80\x80\xEF\xBB\xBF") : '\x00-\x08\x0B\x0C\x0E-\x19\xA0') . ']+~' . ($context['utf8'] ? 'u' : ''), ' ', $_POST['real_name']));
 		if (trim($_POST['real_name']) != '' && !isReservedName($_POST['real_name']) && $smcFunc['strlen']($_POST['real_name']) < 60)

+ 1 - 0
Sources/Security.php

@@ -443,6 +443,7 @@ function banPermissions()
 			'manage_attachments', 'manage_smileys', 'manage_boards', 'admin_forum', 'manage_permissions',
 			'moderate_forum', 'manage_membergroups', 'manage_bans', 'send_mail', 'edit_news',
 			'profile_identity_any', 'profile_extra_any', 'profile_title_any',
+			'profile_forum_any', 'profile_other_any', 'profile_signature_any',
 			'post_new', 'post_reply_own', 'post_reply_any',
 			'delete_own', 'delete_any', 'delete_replies',
 			'make_sticky',

+ 2 - 2
Sources/Subs.php

@@ -3790,7 +3790,7 @@ function setupMenuContext()
 	// Set up the menu privileges.
 	$context['allow_search'] = !empty($modSettings['allow_guestAccess']) ? allowedTo('search_posts') : (!$user_info['is_guest'] && allowedTo('search_posts'));
 	$context['allow_admin'] = allowedTo(array('admin_forum', 'manage_boards', 'manage_permissions', 'moderate_forum', 'manage_membergroups', 'manage_bans', 'send_mail', 'edit_news', 'manage_attachments', 'manage_smileys'));
-	$context['allow_edit_profile'] = !$user_info['is_guest'] && allowedTo(array('profile_view_own', 'profile_view_any', 'profile_identity_own', 'profile_identity_any', 'profile_extra_own', 'profile_extra_any', 'profile_remove_own', 'profile_remove_any', 'moderate_forum', 'manage_membergroups', 'profile_title_own', 'profile_title_any'));
+	$context['allow_edit_profile'] = !$user_info['is_guest'] && allowedTo(array('profile_view_own', 'profile_view_any', 'profile_identity_own', 'profile_identity_any', 'profile_forum_own', 'profile_forum_any', 'moderate_forum', 'manage_membergroups'));
 	$context['allow_memberlist'] = allowedTo('view_mlist');
 	$context['allow_calendar'] = allowedTo('calendar_view') && !empty($modSettings['cal_enabled']);
 	$context['allow_moderation_center'] = $context['user']['can_mod'];
@@ -3893,7 +3893,7 @@ function setupMenuContext()
 					'profile' => array(
 						'title' => $txt['forumprofile'],
 						'href' => $scripturl . '?action=profile;area=forumprofile',
-						'show' => allowedTo(array('profile_extra_any', 'profile_extra_own')),
+						'show' => allowedTo(array('profile_forum_any', 'profile_forum_own')),
 						'is_last' => true,
 					),
 					'theme' => array(

+ 26 - 0
Themes/default/languages/ManagePermissions.english.php

@@ -34,6 +34,32 @@ $txt['permissions_profile_used_by_many'] = '%1$d Boards';
 $txt['permissions_profile_used_by_none'] = 'No Boards';
 $txt['permissions_profile_do_edit'] = 'Edit';
 $txt['permissions_profile_do_delete'] = 'Delete';
+
+$txt['permissionname_profile_displayed_name'] = 'Edit displayed name';
+$txt['permissionhelp_profile_displayed_name'] = 'Allow the member to edit the displayed name field in their profile';
+$txt['permissionname_profile_displayed_name_own'] = 'Own displayed name';
+$txt['permissionname_profile_displayed_name_any'] = 'Any displayed name';
+
+$txt['permissionname_profile_signature'] = 'Edit signature';
+$txt['permissionhelp_profile_signature'] = 'Allow the member to edit the signature field in their profile';
+$txt['permissionname_profile_signature_own'] = 'Own signature';
+$txt['permissionname_profile_signature_any'] = 'Any signature';
+$txt['permissionname_profile_forum'] = 'Allow Forum Profile edits';
+$txt['permissionhelp_profile_forum'] = 'This option will allow a member to edit their Forum Profile';
+$txt['permissionname_profile_forum_own'] = 'Own profile';
+$txt['permissionname_profile_forum_any'] = 'Any profile';
+$txt['permissionname_profile_other'] = 'Edit website and location';
+$txt['permissionhelp_profile_other'] = 'Allow the member to edit the website, and location fields in their profile';
+$txt['permissionname_profile_other_own'] = 'Own profile';
+$txt['permissionname_profile_other_any'] = 'Any profile';
+$txt['permissionname_profile_password'] = 'Change password';
+$txt['permissionhelp_profile_password'] = 'Allow the member to change the password or the secret question fields';
+$txt['permissionname_profile_password_own'] = 'Own profile';
+$txt['permissionname_profile_password_any'] = 'Any profile';
+$txt['permissionname_profile_blurb'] = 'Edit personal text';
+$txt['permissionhelp_profile_blurb'] = 'Allow the member to edit the personal text field in their profile';
+$txt['permissionname_profile_blurb_own'] = 'Own profile';
+$txt['permissionname_profile_blurb_any'] = 'Any profile';
 $txt['permissions_profile_copy_from'] = 'Copy Permissions From';
 
 $txt['permissions_includes_inherited'] = 'Inherited Groups';

+ 1 - 2
Themes/default/languages/ManageSettings.english.php

@@ -14,7 +14,6 @@ $txt['enable_polls'] = 'Enable polls';
 $txt['polls_as_topics'] = 'Show existing polls as topics';
 $txt['allow_guestAccess'] = 'Allow guests to browse the forum';
 $txt['userLanguage'] = 'Enable user-selectable language support';
-$txt['allow_editDisplayName'] = 'Allow users to edit their displayed name';
 $txt['allow_hideOnline'] = 'Allow non-administrators to hide their online status';
 $txt['titlesEnable'] = 'Enable custom titles';
 $txt['enable_buddylist'] = 'Enable buddy/ignore lists';
@@ -359,4 +358,4 @@ $txt['setting_frame_security_DISABLE'] = 'Disabled';
 
 $txt['select_boards_from_list'] = 'Select boards which apply';
 
-?>
+?>