Ver Fonte

+ Add a bunch of hooks that I want in 2.1

+ integrate_view_poll
+ integrate_pre_message_load
+ integrate_display_context
+ integrate_helpadmin
+ integrate_xmlfeeds
+ integrate_profile_fields
+ integrate_remove_buddy
+ integrate_add_buddies
+ integrate_view_buddies
+ integrate_profile_stats
+ integrate_unread_list
+ integrate_remove_topics
+ integrate_remove_message
+ integrate_forum_stats
+ integrate_insert_event
+ integrate_modify_event
+ integrate_remove_event
+integrate_reattribute_posts
+ integrate_xmlhttp
+ integrate_poll_vote
+ integrate_poll_add_edit
+ integrate_poll_remove
marcusforsberg há 12 anos atrás
pai
commit
e4165924f0

+ 9 - 0
Sources/Display.php

@@ -756,6 +756,9 @@ function Display()
 			);
 		}
 	}
+	
+	// Editing poll output, eh?
+	call_integration_hook('integrate_view_poll', array(&$context['poll']));
 
 	// Calculate the fastest way to get the messages!
 	$ascending = empty($options['view_newest_first']);
@@ -946,6 +949,9 @@ function Display()
 			foreach ($temp as $row)
 				$attachments[$row['id_msg']][] = $row;
 		}
+		
+		// Any custom stuff that might need to be loaded if there are messages to show
+		call_integration_hook('integrate_pre_message_load', array(&$messages));
 
 		// What?  It's not like it *couldn't* be only guests in this topic...
 		if (!empty($posters))
@@ -1225,6 +1231,9 @@ function prepareDisplayContext($reset = false)
 		$counter++;
 	else
 		$counter--;
+		
+	// Add new data to messages?
+	call_integration_hook('integrate_display_context', array(&$output));
 
 	return $output;
 }

+ 3 - 0
Sources/Help.php

@@ -84,6 +84,9 @@ function ShowAdminHelp()
 		loadLanguage('ManagePermissions');
 
 	loadTemplate('Help');
+	
+	// Allow mods to load their own language file here
+ 	call_integration_hook('integrate_helpadmin');
 
 	// Set the page title to something relevant.
 	$context['page_title'] = $context['forum_name'] . ' - ' . $txt['help'];

+ 4 - 0
Sources/News.php

@@ -179,6 +179,10 @@ function ShowXmlFeed()
 		'members' => array('getXmlMembers', 'member'),
 		'profile' => array('getXmlProfile', null),
 	);
+	
+	// Easy adding of sub actions
+ 	call_integration_hook('integrate_xmlfeeds', array(&$subActions));
+	
 	if (empty($_GET['sa']) || !isset($subActions[$_GET['sa']]))
 		$_GET['sa'] = 'recent';
 

+ 8 - 0
Sources/Poll.php

@@ -213,6 +213,9 @@ function Vote()
 		$cookie_url = url_parts(!empty($modSettings['localCookies']), !empty($modSettings['globalCookies']));
 		smf_setcookie('guest_poll_vote', $_COOKIE['guest_poll_vote'], time() + 2500000, $cookie_url[1], $cookie_url[0], false, false);
 	}
+	
+	// Maybe let a social networking mod log this, or something?
+	call_integration_hook('integrate_poll_vote', array(&$row['id_poll'], &$pollOptions));
 
 	// Return to the post...
 	redirectexit('topic=' . $topic . '.' . $_REQUEST['start']);
@@ -879,6 +882,8 @@ function EditPoll2()
 			)
 		);
 	}
+	
+	call_integration_hook('integrate_poll_add_edit', array($bcinfo['id_poll'], $isEdit));
 
 	// Off we go.
 	redirectexit('topic=' . $topic . '.' . $_REQUEST['start']);
@@ -971,6 +976,9 @@ function RemovePoll()
 			'no_poll' => 0,
 		)
 	);
+	
+	// A mod might have logged this (social network?), so let them remove, it too
+	call_integration_hook('integrate_poll_remove', array(&$pollID));
 
 	// Take the moderator back to the topic.
 	redirectexit('topic=' . $topic . '.' . $_REQUEST['start']);

+ 2 - 0
Sources/Post.php

@@ -2001,6 +2001,8 @@ function Post2()
 			$pollOptions,
 			array('id_poll', 'id_choice')
 		);
+		
+		call_integration_hook('integrate_poll_add_edit', array($id_poll, false));
 	}
 	else
 		$id_poll = 0;

+ 8 - 0
Sources/Profile-Modify.php

@@ -670,6 +670,8 @@ function loadProfileFields($force_reload = false)
 			'permission' => 'profile_extra',
 		),
 	);
+	
+	call_integration_hook('integrate_profile_fields', array(&$profile_fields));
 
 	$disabled_fields = !empty($modSettings['disabled_profile_fields']) ? explode(',', $modSettings['disabled_profile_fields']) : array();
 	// For each of the above let's take out the bits which don't apply - to save memory and security!
@@ -1339,6 +1341,8 @@ function editBuddies($memID)
 	if (isset($_GET['remove']))
 	{
 		checkSession('get');
+		
+		call_integration_hook('integrate_remove_buddy', array($memID));
 
 		// Heh, I'm lazy, do it the easy way...
 		foreach ($buddiesArray as $key => $buddy)
@@ -1368,6 +1372,8 @@ function editBuddies($memID)
 			if (strlen($new_buddies[$k]) == 0 || in_array($new_buddies[$k], array($user_profile[$memID]['member_name'], $user_profile[$memID]['real_name'])))
 				unset($new_buddies[$k]);
 		}
+		
+		call_integration_hook('integrate_add_buddies', array($memID, &$new_buddies));
 
 		if (!empty($new_buddies))
 		{
@@ -1430,6 +1436,8 @@ function editBuddies($memID)
 		loadMemberContext($buddy);
 		$context['buddies'][$buddy] = $memberContext[$buddy];
 	}
+	
+	call_integration_hook('integrate_view_buddies', array($memID));
 }
 
 /**

+ 3 - 0
Sources/Profile-View.php

@@ -801,6 +801,9 @@ function statPanel($memID)
 
 	// Put it in the right order.
 	ksort($context['posts_by_time']);
+	
+	// Custom stats (just add a template_layer to add it to the template!)
+ 	call_integration_hook('integrate_profile_stats', array($memID));
 }
 
 /**

+ 3 - 0
Sources/Recent.php

@@ -1316,6 +1316,9 @@ function UnreadTopics()
 
 	$context['querystring_board_limits'] = sprintf($context['querystring_board_limits'], $_REQUEST['start']);
 	$context['topics_to_mark'] = implode('-', $topic_ids);
+	
+	// Allow helpdesks and bug trackers and what not to add their own unread data (just add a template_layer to show custom stuff in the template!)
+ 	call_integration_hook('integrate_unread_list');
 }
 
 ?>

+ 6 - 0
Sources/RemoveTopic.php

@@ -533,6 +533,9 @@ function removeTopics($topics, $decreasePostCount = true, $ignoreRecycling = fal
 			'topics' => $topics,
 		)
 	);
+	
+	// Maybe there's a mod that wants to delete topic related data of its own
+ 	call_integration_hook('integrate_remove_topics', array($topics));
 
 	// Update the totals...
 	updateStats('message');
@@ -959,6 +962,9 @@ function removeMessage($message, $decreasePostCount = true)
 			'id_msg' => $message,
 		);
 		removeAttachments($attachmentQuery);
+		
+		// Allow mods to remove message related data of their own (likes, maybe?)
+		call_integration_hook('integrate_remove_message', array($message));
 	}
 
 	// Update the pesky statistics.

+ 3 - 0
Sources/Stats.php

@@ -627,6 +627,9 @@ function DisplayStats()
 		return;
 
 	getDailyStats(implode(' OR ', $condition_text), $condition_params);
+	
+	// Custom stats (just add a template_layer to add it to the template!)
+ 	call_integration_hook('integrate_forum_stats');
 }
 
 /**

+ 7 - 0
Sources/Subs-Calendar.php

@@ -885,6 +885,8 @@ function insertEvent(&$eventOptions)
 
 	// Store the just inserted id_event for future reference.
 	$eventOptions['id'] = $smcFunc['db_insert_id']('{db_prefix}calendar', 'id_event');
+	
+	call_integration_hook('integrate_insert_event', array($eventOptions));
 
 	// Update the settings to show something calendarish was updated.
 	updateSettings(array(
@@ -914,6 +916,9 @@ function modifyEvent($event_id, &$eventOptions)
 	if (!isset($eventOptions['end_date']))
 		$eventOptions['end_date'] = strftime('%Y-%m-%d', mktime(0, 0, 0, $month, $day, $year) + $eventOptions['span'] * 86400);
 
+	
+	call_integration_hook('integrate_modify_event', array($event_id, &$eventOptions));		
+		
 	$smcFunc['db_query']('', '
 		UPDATE {db_prefix}calendar
 		SET
@@ -953,6 +958,8 @@ function removeEvent($event_id)
 			'id_event' => $event_id,
 		)
 	);
+	
+	call_integration_hook('integrate_remove_event', array($event_id));
 
 	updateSettings(array(
 		'calendar_updated' => time(),

+ 3 - 0
Sources/Subs-Members.php

@@ -1177,6 +1177,9 @@ function reattributePosts($memID, $email = false, $membername = false, $post_cou
 			'memID' => $memID,
 		)
 	);
+	
+	// Allow mods with their own post tables to reattribute posts as well :)
+ 	call_integration_hook('integrate_reattribute_posts', array(&$memID, &$email, &$membername, &$post_count));
 }
 
 /**

+ 4 - 0
Sources/Xml.php

@@ -35,6 +35,10 @@ function XMLhttpMain()
 			'function' => 'RetrievePreview',
 		),
 	);
+	
+	// Easy adding of sub actions
+ 	call_integration_hook('integrate_xmlhttp', array(&$sub_actions));
+	
 	if (!isset($_REQUEST['sa'], $sub_actions[$_REQUEST['sa']]))
 		fatal_lang_error('no_access', false);