! Make Profile section actually work
jdarwood007

jdarwood007 commited on 2015-11-02 20:55:29
Showing 4 changed files, with 39 additions and 8 deletions.

... ...
@@ -151,7 +151,7 @@ $hooks[] = array(
151 151
 );
152 152
 $hooks[] = array(
153 153
 	'hook' => 'integrate_profile_areas',
154
-	'function' => 'shd_admin_smf_perms',
154
+	'function' => 'shd_profile_areas',
155 155
 	'perm' => true,
156 156
 	'file' => '$sourcedir/sd_source/Subs-SimpleDeskProfile.php',
157 157
 );
... ...
@@ -14,7 +14,7 @@
14 14
 		<readme lang="english" parsebbc="true" type="inline">This package is for SMF 2.1, to install SimpleDesk on your version of SMF use the proper package.</readme>
15 15
 	</install>
16 16
 
17
-	<install for="2.1 alpha 1">
17
+	<install for="2.1 Beta 2">
18 18
 		<!-- readme files -->
19 19
 		<readme lang="english" parsebbc="true" type="file">language-readme/readme.english.txt</readme>
20 20
 
... ...
@@ -57,10 +57,10 @@
57 57
 		<!-- database changes -->
58 58
 		<database>install.php</database>
59 59
 
60
-		<redirect url="?action=admin;area=corefeatures#js_feature_shd" />
60
+		<redirect url="?action=admin;area=helpdesk_info" />
61 61
 	</install>
62 62
 
63
-	<uninstall for="2.1 alpha 1">
63
+	<uninstall for="2.1 Beta 2">
64 64
 		<!-- database changes, undone -->
65 65
 		<database>uninstall-optional.php</database>
66 66
 		<code type="file">uninstall-required.php</code>
... ...
@@ -590,17 +590,26 @@ function shd_admin_smf_perms(&$permissionGroups, &$permissionList, &$leftPermiss
590 590
  *	@param array &$hiddenPermissions A list of permissions to be hidden in the event of features being disabled
591 591
  *	@param array &$relabelPermissions A list of permissions to be renamed depending on features being active
592 592
 */
593
-function shd_admin_search($language_files, $include_files, $settings_search)
593
+function shd_admin_search(&$language_files, &$include_files, &$settings_search)
594 594
 {
595
+	// Add in language files.
596
+	$language_files = array_merge($language_files, array(
597
+		'SimpleDeskAdmin'
598
+	));
599
+
600
+	$include_files = array_merge($include_files, array(
601
+		'sd_source/SimpleDesk-Admin',
602
+	));
603
+
595 604
 	// Add SimpleDesk functions
596
-	$settings_search += array(
605
+	$settings_search = array_merge($settings_search, array(
597 606
 		array('shd_modify_display_options', 'area=helpdesk_options;sa=display'),
598 607
 		array('shd_modify_posting_options', 'area=helpdesk_options;sa=posting'),
599 608
 		array('shd_modify_admin_options', 'area=helpdesk_options;sa=admin'),
600 609
 		array('shd_modify_standalone_options', 'area=helpdesk_options;sa=standalone'),
601 610
 		array('shd_modify_actionlog_options', 'area=helpdesk_options;sa=actionlog'),
602 611
 		array('shd_modify_notifications_options', 'area=helpdesk_options;sa=notifications'),
603
-	);
612
+	));
604 613
 
605 614
 	// Our plugins may still use the old SHD hook.
606 615
 	call_integration_hook('shd_hook_hdadminoptssrch', array(&$settings_search));
... ...
@@ -34,8 +34,10 @@ if (!defined('SMF'))
34 34
  *
35 35
  *	@since 2.0
36 36
 */
37
-function shd_profile_areas($profile_areas)
37
+function shd_profile_areas(&$profile_areas)
38 38
 {
39
+	global $modSettings, $context, $txt;
40
+
39 41
 	// SimpleDesk sections. Added here after the initial cleaning is done, so that we can do our own permission checks without arguing with SMF's system (so much)
40 42
 	if (!empty($modSettings['helpdesk_active']))
41 43
 	{
... ...
@@ -50,30 +52,50 @@ function shd_profile_areas($profile_areas)
50 52
 					'file' => 'sd_source/SimpleDesk-Profile.php',
51 53
 					'function' => 'shd_profile_main',
52 54
 					'enabled' => shd_allowed_to('shd_view_profile_any') || ($context['user']['is_owner'] && shd_allowed_to('shd_view_profile_own')),
55
+					'permission' => array(
56
+						'own' => array('shd_view_profile_own'),
57
+						'any' => array('shd_view_profile_any'),
58
+					),
53 59
 				),
54 60
 				'hd_prefs' => array(
55 61
 					'label' => $txt['shd_profile_preferences'],
56 62
 					'file' => 'sd_source/SimpleDesk-Profile.php',
57 63
 					'function' => 'shd_profile_main',
58 64
 					'enabled' => shd_allowed_to('shd_view_preferences_any') || ($context['user']['is_owner'] && shd_allowed_to('shd_view_preferences_own')),
65
+					'permission' => array(
66
+						'own' => array('shd_view_preferences_own'),
67
+						'any' => array('shd_view_preferences_any'),
68
+					),
59 69
 				),
60 70
 				'hd_showtickets' => array(
61 71
 					'label' => $txt['shd_profile_show_tickets'],
62 72
 					'file' => 'sd_source/SimpleDesk-Profile.php',
63 73
 					'function' => 'shd_profile_main',
64 74
 					'enabled' => ($context['user']['is_owner'] && shd_allowed_to('shd_view_ticket_own')) || shd_allowed_to('shd_view_ticket_any'),
75
+					'permission' => array(
76
+						'own' => array('shd_view_ticket_own'),
77
+						'any' => array('shd_view_ticket_any'),
78
+					),
65 79
 				),
66 80
 				'hd_permissions' => array(
67 81
 					'label' => $txt['shd_profile_permissions'],
68 82
 					'file' => 'sd_source/SimpleDesk-Profile.php',
69 83
 					'function' => 'shd_profile_main',
70 84
 					'enabled' => shd_allowed_to('admin_helpdesk'),
85
+					'permission' => array(
86
+						'own' => array('admin_helpdesk'),
87
+						'any' => array('admin_helpdesk'),
88
+					),
71 89
 				),
72 90
 				'hd_actionlog' => array(
73 91
 					'label' => $txt['shd_profile_actionlog'],
74 92
 					'file' => 'sd_source/SimpleDesk-Profile.php',
75 93
 					'function' => 'shd_profile_main',
76 94
 					'enabled' => empty($modSettings['shd_disable_action_log']) && (shd_allowed_to('shd_view_profile_log_any') || ($context['user']['is_owner'] && shd_allowed_to('shd_view_profile_log_own'))),
95
+					'permission' => array(
96
+						'own' => array('shd_view_profile_log_own'),
97
+						'any' => array('shd_view_profile_log_any'),
98
+					),
77 99
 				),
78 100
 			),
79 101
 		);
80 102