! Various miscellaneous fixes for front page plugin. Be sure to disable it then re-enable it at least once.
gruffen

gruffen commited on 2011-05-19 07:42:13
Showing 11 changed files, with 26 additions and 7 deletions.

... ...
@@ -117,7 +117,7 @@ $txt['shd_log_editticket'] = '&quot;<a href="{scripturl}?action=helpdesk;sa=tick
117 117
 $txt['shd_log_newreply'] = '<a href="{scripturl}?action=helpdesk;sa=ticket;ticket={ticket}.msg{msg}#msg{msg}">New reply</a> to &quot;<a href="{scripturl}?action=helpdesk;sa=ticket;ticket={ticket}.0">{subject}</a>&quot;.';
118 118
 $txt['shd_log_editreply'] = 'A <a href="{scripturl}?action=helpdesk;sa=ticket;ticket={ticket}.msg{msg}#msg{msg}">reply</a> was edited in &quot;<a href="{scripturl}?action=helpdesk;sa=ticket;ticket={ticket}.0">{subject}</a>&quot;.';
119 119
 $txt['shd_log_newticketproxy'] = '&quot;<a href="{scripturl}?action=helpdesk;sa=ticket;ticket={ticket}">{subject}</a>&quot; opened on behalf of {profile_link}.';
120
-$txt['shd_log_move_dept'] = '&quot;<a href="{scripturl}?action=helpdesk;sa=ticket;ticket={ticket}">{subject}</a>&quot; was moved from <a href="{scripturl}?action=helpdesk;sa=main;dept={old_dept_id}">{old_dept_name}</a> to <a href="{scripturl}?action=helpdesk;sa=main;dept={new_dept_id}">{new_dept_name}</a>.';
120
+$txt['shd_log_move_dept'] = '&quot;<a href="{scripturl}?action=helpdesk;sa=ticket;ticket={ticket}">{subject}</a>&quot; was moved from <a href="{scripturl}?{shd_home};dept={old_dept_id}">{old_dept_name}</a> to <a href="{scripturl}?{shd_home};dept={new_dept_id}">{new_dept_name}</a>.';
121 121
 
122 122
 $txt['shd_logpart_att_added'] = 'Files added';
123 123
 $txt['shd_logpart_att_removed'] = 'Files removed';
... ...
@@ -179,6 +179,9 @@ function shd_frontpage_source()
179 179
 {
180 180
 	global $context, $txt, $modSettings;
181 181
 
182
+	if (!in_array('front_page', $context['shd_plugins']))
183
+		return;
184
+
182 185
 	loadTemplate('sd_plugins_template/SDPluginFrontPage');
183 186
 	$context['sub_template'] = 'shd_frontpage';
184 187
 	$context['page_title'] = $txt['shd_helpdesk'];
... ...
@@ -250,4 +253,10 @@ function shd_frontpage_mainmenu(&$menu_buttons)
250 253
 	}
251 254
 }
252 255
 
256
+function shd_frontpage_boardindex()
257
+{
258
+	global $context;
259
+	$context['shd_home'] = 'action=helpdesk;sa=tickets';
260
+}
261
+
253 262
 ?>
254 263
\ No newline at end of file
... ...
@@ -76,6 +76,7 @@ function shdplugin_front_page()
76 76
 			'helpdesk' => 'shd_frontpage_helpdesk',
77 77
 			'after_main' => 'shd_frontpage_aftermain',
78 78
 			'mainmenu' => 'shd_frontpage_mainmenu',
79
+			'boardindex_before' => 'shd_frontpage_boardindex',
79 80
 		),
80 81
 	);
81 82
 }
... ...
@@ -324,6 +324,8 @@ function shd_list_hooks()
324 324
 		'shd_hook_assign', // functions to call when a ticket is assigned to someone
325 325
 		'shd_hook_buffer', // functions to call prior to the final page generation
326 326
 		'shd_hook_after_main', // functions to call after action=helpdesk has been evaluated but before template calls are made
327
+		'shd_hook_boardindex_before', // functions to call before setting up the injected boardindex
328
+		'shd_hook_boardindex_after', // functions to call after setting up the injected boardindex
327 329
 
328 330
 		// Menu hooks - called after the rest of menu configuration is done (meaning menu items may or may not exist depending on permissions)
329 331
 		'shd_hook_mainmenu', // functions to call when looking at the main menu
... ...
@@ -959,7 +959,7 @@ function shd_topictoticket()
959 959
 
960 960
 	// Build the linktree
961 961
 	$context['linktree'][] = array(
962
-		'url' => $scripturl . '?action=helpdesk;sa=main',
962
+		'url' => $scripturl . '?' . $context['shd_home'],
963 963
 		'name' => $txt['shd_linktree_move_topic'],
964 964
 	);
965 965
 	$context['linktree'][] = array(
... ...
@@ -48,6 +48,7 @@ function shd_init()
48 48
 		return;
49 49
 
50 50
 	$called = true;
51
+	$context['shd_home'] = 'action=helpdesk;sa=main';
51 52
 
52 53
 	// What SD version are we on? It's now here!
53 54
 	define('SHD_VERSION', 'SimpleDesk 2.0 Anatidae');
... ...
@@ -184,6 +184,7 @@ function shd_load_action_log_entries($start = 0, $items_per_page = 10, $sort = '
184 184
 			$actions[$k]['action_text'] = isset($txt['shd_log_' . $action['action']]) ? $txt['shd_log_' . $action['action']] : $action['action'];
185 185
 
186 186
 		$actions[$k]['action_text'] = str_replace('{scripturl}', $scripturl, $actions[$k]['action_text']);
187
+		$actions[$k]['action_text'] = str_replace('{shd_home}', $context['shd_home'], $actions[$k]['action_text']);
187 188
 
188 189
 		if (isset($action['extra']['subject']))
189 190
 		{
... ...
@@ -36,6 +36,8 @@ function shd_add_to_boardindex(&$boardIndexOptions, &$categories)
36 36
 	if (!empty($board))
37 37
 		return;
38 38
 
39
+	call_integration_hook('shd_hook_boardindex_before');
40
+
39 41
 	// OK, so what helpdesks are we displaying?
40 42
 	$depts = shd_allowed_to('access_helpdesk', false);
41 43
 	if (empty($depts))
... ...
@@ -180,11 +182,12 @@ function shd_add_to_boardindex(&$boardIndexOptions, &$categories)
180 182
 
181 183
 	// Call the relevant function via hook.
182 184
 	add_integration_function('shd_hook_buffer', 'shd_buffer_boardindex', false);
185
+	call_integration_hook('shd_hook_boardindex_after', array(&$categories));
183 186
 }
184 187
 
185 188
 function shd_dept_board($dept)
186 189
 {
187
-	global $txt, $scripturl;
190
+	global $txt, $scripturl, $context;
188 191
 
189 192
 	return array(
190 193
 		'id' => 'shd' . $dept['id_dept'],
... ...
@@ -199,8 +202,8 @@ function shd_dept_board($dept)
199 202
 		'unapproved_topics' => 0,
200 203
 		'unapproved_posts' => 0,
201 204
 		'can_approve_posts' => false,
202
-		'href' => $scripturl . '?action=helpdesk;sa=main' . $dept['link'],
203
-		'link' => '<a href="' . $scripturl . '?action=helpdesk;sa=main' . $dept['link'] . '">' . $dept['dept_name'] . '</a>',
205
+		'href' => $scripturl . '?' . $context['shd_home'] . $dept['link'],
206
+		'link' => '<a href="' . $scripturl . '?' . $context['shd_home'] . $dept['link'] . '">' . $dept['dept_name'] . '</a>',
204 207
 		'last_post' => array(
205 208
 			'id' => 0,
206 209
 			'time' => $txt['not_applicable'],
... ...
@@ -44,7 +44,7 @@ function template_movedept()
44 44
 						<strong>', $txt['shd_current_dept'], ':</strong>
45 45
 					</dt>
46 46
 					<dd>
47
-						<a href="', $scripturl, '?action=helpdesk;sa=main;dept=', $context['current_dept'], '">', $context['current_dept_name'], '</a>
47
+						<a href="', $scripturl, '?', $context['shd_home'], ';dept=', $context['current_dept'], '">', $context['current_dept_name'], '</a>
48 48
 					</dd>
49 49
 					<dt>
50 50
 						<strong>', $txt['shd_ticket_move_to'], ':</strong>
... ...
@@ -143,7 +143,7 @@ function template_shd_depts()
143 143
 		echo '
144 144
 								<tr class="windowbg2">
145 145
 									<td class="icon windowbg"><img src="', $icon, '" alt="*" /></td>
146
-									<td class="info"><a href="', $scripturl, '?action=helpdesk;sa=main;dept=', $dept['id_dept'], '">', $dept['dept_name'], '</a></td>
146
+									<td class="info"><a href="', $scripturl, '?', $context['shd_home'], ';dept=', $dept['id_dept'], '">', $dept['dept_name'], '</a></td>
147 147
 									<td class="stats windowbg">', $dept['tickets']['open'], ' open<br />', $dept['tickets']['closed'], ' closed</td>
148 148
 									<td class="lastpost"></td>
149 149
 								</tr>';
... ...
@@ -133,6 +134,8 @@ $shd_hooks = array(
133 134
 	'shd_hook_assign',
134 135
 	'shd_hook_buffer',
135 136
 	'shd_hook_after_main',
137
+	'shd_hook_boardindex_before',
138
+	'shd_hook_boardindex_after',
136 139
 	// Plugin: menu hooks
137 140
 	'shd_hook_mainmenu',
138 141
 	'shd_hook_profilemenu',
139 142