Преглед на файлове

! Small patch for 4841
! More doc changes
! Few hook names and position changed [bug: 4845]

Spuds преди 13 години
родител
ревизия
b37e796548

+ 1 - 0
Sources/Logging.php

@@ -355,6 +355,7 @@ function displayDebug()
  * It depends on the trackStats setting.
  *
  * @param array $stats = array()
+ * @return bool|array
  */
 function trackStats($stats = array())
 {

+ 1 - 1
Sources/ManageBoards.php

@@ -788,7 +788,7 @@ function EditBoardSettings($return_config = false)
 			array('check', 'allow_ignore_boards'),
 	);
 
-	call_integration_hook('integrate_board_settings', array(&$config_vars));
+	call_integration_hook('integrate_modify_board_settings', array(&$config_vars));
 
 	if ($return_config)
 		return $config_vars;

+ 5 - 1
Sources/ManageMail.php

@@ -217,6 +217,7 @@ function BrowseMailQueue()
  * @param int $start
  * @param int $items_per_page
  * @param string $sort
+ * @return array
  */
 function list_getMailQueue($start, $items_per_page, $sort)
 {
@@ -250,6 +251,7 @@ function list_getMailQueue($start, $items_per_page, $sort)
 
 /**
  * Returns the total count of items in the mail queue.
+ * @return int
  */
 function list_getMailQueueSize()
 {
@@ -271,7 +273,8 @@ function list_getMailQueueSize()
 /**
  * Allows to view and modify the mail settings.
  *
- * @param bool $return_config
+ * @param bool $return_config = false
+ * @return array
  */
 function ModifyMailSettings($return_config = false)
 {
@@ -437,6 +440,7 @@ function pauseMailQueueClear()
  * Little utility function to calculate how long ago a time was.
  *
  * @param long $time_diff
+ * @return string
  */
 function time_since($time_diff)
 {

+ 4 - 0
Sources/ManageSearch.php

@@ -162,12 +162,16 @@ function EditWeights()
 		'search_weight_sticky',
 	);
 
+	call_integration_hook('integrate_modify_search_weights', array(&$factors));
+
 	// A form was submitted.
 	if (isset($_POST['save']))
 	{
 		checkSession();
 		validateToken('admin-msw');
 
+		call_integration_hook('integrate_save_search_weights');
+
 		$changes = array();
 		foreach ($factors as $factor)
 			$changes[$factor] = (int) $_POST[$factor];

+ 1 - 1
Sources/ManageSearchEngines.php

@@ -88,7 +88,7 @@ function ManageSearchEngineSettings($return_config = false)
 		}
 		disableFields();';
 
-	call_integration_hook('integrate_search_engine_settings', array(&$config_vars));
+	call_integration_hook('integrate_modify_search_engine_settings', array(&$config_vars));
 
 	if ($return_config)
 		return $config_vars;

+ 1 - 1
Sources/ManageServer.php

@@ -328,7 +328,7 @@ function ModifyCacheSettings($return_config = false)
 		array('text', 'cache_memcached'),
 	);
 
-	call_integration_hook('integrate_cache_settings', array(&$config_vars));
+	call_integration_hook('integrate_modify_cache_settings', array(&$config_vars));
 
 	if ($return_config)
 		return $config_vars;

+ 1 - 1
Sources/ManageSettings.php

@@ -473,7 +473,7 @@ function ModifyBasicSettings($return_config = false)
 	else
 		unset($config_vars['default_timezone']);
 
-	call_integration_hook('integrate_basic_settings', array(&$config_vars));
+	call_integration_hook('integrate_modify_basic_settings', array(&$config_vars));
 
 	if ($return_config)
 		return $config_vars;

+ 80 - 95
Sources/Security.php

@@ -1,6 +1,9 @@
 <?php
 
 /**
+ * This file has the very important job of ensuring forum security.
+ * This task includes banning and permissions, namely.
+ *
  * Simple Machines Forum (SMF)
  *
  * @package SMF
@@ -14,93 +17,13 @@
 if (!defined('SMF'))
 	die('Hacking attempt...');
 
-/*	This file has the very important job of insuring forum security.  This
-	task includes banning and permissions, namely.  It does this by providing
-	the following functions:
-
-	void validateSession()
-		- makes sure the user is who they claim to be by requiring a
-		  password to be typed in every hour.
-		- is turned on and off by the securityDisable setting.
-		- uses the adminLogin() function of Subs-Auth.php if they need to
-		  login, which saves all request (post and get) data.
-
-	void is_not_guest(string message = '')
-		- checks if the user is currently a guest, and if so asks them to
-		  login with a message telling them why.
-		- message is what to tell them when asking them to login.
-
-	void is_not_banned(bool force_check = false)
-		- checks if the user is banned, and if so dies with an error.
-		- caches this information for optimization purposes.
-		- forces a recheck if force_check is true.
-
-	void banPermissions()
-		- applies any states of banning by removing permissions the user
-		  cannot have.
-
-	void log_ban(array ban_ids = array(), string email = null)
-		- log the current user in the ban logs.
-		- increment the hit counters for the specified ban ID's (if any.)
-
-	void isBannedEmail(string email, string restriction, string error)
-		- check if a given email is banned.
-		- performs an immediate ban if the turns turns out positive.
-
-	string checkSession(string type = 'post', string from_action = none,
-			is_fatal = true)
-		- checks the current session, verifying that the person is who he or
-		  she should be.
-		- also checks the referrer to make sure they didn't get sent here.
-		- depends on the disableCheckUA setting, which is usually missing.
-		- will check GET, POST, or REQUEST depending on the passed type.
-		- also optionally checks the referring action if passed. (note that
-		  the referring action must be by GET.)
-		- returns the error message if is_fatal is false.
-
-	bool checkSubmitOnce(string action, bool is_fatal = true)
-		- registers a sequence number for a form.
-		- checks whether a submitted sequence number is registered in the
-		  current session.
-		- depending on the value of is_fatal shows an error or returns true or
-		  false.
-		- frees a sequence number from the stack after it's been checked.
-		- frees a sequence number without checking if action == 'free'.
-
-	bool allowedTo(string permission, array boards = current)
-		- checks whether the user is allowed to do permission. (ie. post_new.)
-		- if boards is specified, checks those boards instead of the current
-		  one.
-		- always returns true if the user is an administrator.
-		- returns true if he or she can do it, false otherwise.
-
-	void isAllowedTo(string permission, array boards = current)
-		- uses allowedTo() to check if the user is allowed to do permission.
-		- checks the passed boards or current board for the permission.
-		- if they are not, it loads the Errors language file and shows an
-		  error using $txt['cannot_' . $permission].
-		- if they are a guest and cannot do it, this calls is_not_guest().
-
-	array boardsAllowedTo(string permission, bool check_access = false)
-		- returns a list of boards on which the user is allowed to do the
-		  specified permission.
-		- returns an array with only a 0 in it if the user has permission
-		  to do this on every board.
-		- returns an empty array if he or she cannot do this on any board.
-		- if check_access is true will also make sure the group has proper access to that board.
-
-	string showEmailAddress(string userProfile_hideEmail, int userProfile_id)
-		- returns whether an email address should be shown and how.
-		- possible outcomes are
-			'yes': show the full email address
-			'yes_permission_override': show the full email address, either you
-			  are a moderator or it's your own email address.
-			'no_through_forum': don't show the email address, but do allow
-			  things to be mailed using the built-in forum mailer.
-			'no': keep the email address hidden.
-*/
-
-// Check if the user is who he/she says he is
+/**
+ * Check if the user is who he/she says he is
+ * Makes sure the user is who they claim to be by requiring a password to be typed in every hour.
+ * Is turned on and off by the securityDisable setting.
+ * Uses the adminLogin() function of Subs-Auth.php if they need to login, which saves all request (post and get) data.
+ * @param string $type = admin
+ */
 function validateSession($type = 'admin')
 {
 	global $modSettings, $sourcedir, $user_info, $sc, $user_settings;
@@ -163,7 +86,12 @@ function validateSession($type = 'admin')
 	adminLogin($type);
 }
 
-// Require a user who is logged in. (not a guest.)
+/**
+ * Require a user who is logged in. (not a guest.)
+ * Checks if the user is currently a guest, and if so asks them to login with a message telling them why.
+ * Message is what to tell them when asking them to login.
+ * @param string $message = ''
+ */
 function is_not_guest($message = '')
 {
 	global $user_info, $txt, $context, $scripturl;
@@ -222,7 +150,13 @@ function is_not_guest($message = '')
 	trigger_error('Hacking attempt...', E_USER_ERROR);
 }
 
-// Do banning related stuff.  (ie. disallow access....)
+/**
+ * Do banning related stuff.  (ie. disallow access....)
+ * Checks if the user is banned, and if so dies with an error.
+ * Caches this information for optimization purposes.
+ * Forces a recheck if force_check is true.
+ * @param bool $forceCheck = false
+ */
 function is_not_banned($forceCheck = false)
 {
 	global $txt, $modSettings, $context, $user_info;
@@ -506,6 +440,7 @@ function is_not_banned($forceCheck = false)
 
 /**
  * Fix permissions according to ban status.
+ * Applies any states of banning by removing permissions the user cannot have.
  */
 function banPermissions()
 {
@@ -585,6 +520,8 @@ function banPermissions()
 
 /**
  * Log a ban in the database.
+ * Log the current user in the ban logs.
+ * Increment the hit counters for the specified ban ID's (if any.)
  * @param array $ban_ids = array()
  * @param string $email = null
  */
@@ -617,6 +554,8 @@ function log_ban($ban_ids = array(), $email = null)
 
 /**
  * Checks if a given email address might be banned.
+ * Check if a given email is banned.
+ * Performs an immediate ban if the turns turns out positive.
  * @param string $email
  * @param string $restriction
  * @param string $error
@@ -680,11 +619,16 @@ function isBannedEmail($email, $restriction, $error)
 }
 
 /**
- * Make sure the user's correct session was passed, and they came from here. (type can be post, get, or request.)
- * @param string $type = 'post'
+ * Make sure the user's correct session was passed, and they came from here.
+ * Checks the current session, verifying that the person is who he or she should be.
+ * Also checks the referrer to make sure they didn't get sent here.
+ * Depends on the disableCheckUA setting, which is usually missing.
+ * Will check GET, POST, or REQUEST depending on the passed type.
+ * Also optionally checks the referring action if passed. (note that the referring action must be by GET.)
+ * @param string $type = 'post' (post, get, request)
  * @param string $from_action = ''
  * @param bool $is_fatal = true
- * @return string
+ * @return string the error message if is_fatal is false.
  */
 function checkSession($type = 'post', $from_action = '', $is_fatal = true)
 {
@@ -816,6 +760,7 @@ function checkConfirm($action)
  * Lets give you a token of our appreciation.
  * @param string $action
  * @param string $type = 'post'
+ * @return array
  */
 function createToken($action, $type = 'post')
 {
@@ -837,6 +782,7 @@ function createToken($action, $type = 'post')
  * @param string $action
  * @param string $type = 'post' (get, request, or post)
  * @param bool $reset = true
+ * @return bool
  */
 function validateToken($action, $type = 'post', $reset = true)
 {
@@ -900,8 +846,14 @@ function cleanTokens($complete = false)
 
 /**
  * Check whether a form has been submitted twice.
+ * Registers a sequence number for a form.
+ * Checks whether a submitted sequence number is registered in the current session.
+ * Depending on the value of is_fatal shows an error or returns true or false.
+ * Frees a sequence number from the stack after it's been checked.
+ * Frees a sequence number without checking if action == 'free'.
  * @param string $action
  * @param bool $is_fatal = true
+ * @return bool
  */
 function checkSubmitOnce($action, $is_fatal = true)
 {
@@ -941,9 +893,12 @@ function checkSubmitOnce($action, $is_fatal = true)
 
 /**
  * Check the user's permissions.
+ * checks whether the user is allowed to do permission. (ie. post_new.)
+ * If boards is specified, checks those boards instead of the current one.
+ * Always returns true if the user is an administrator.
  * @param string $permission
  * @param array $boards = null
- * @return bool
+ * @return bool if the user can do the permission
  */
 function allowedTo($permission, $boards = null)
 {
@@ -1009,7 +964,15 @@ function allowedTo($permission, $boards = null)
 	return $result;
 }
 
-// Fatal error if they cannot...
+/**
+ * Fatal error if they cannot.
+ * Uses allowedTo() to check if the user is allowed to do permission.
+ * Checks the passed boards or current board for the permission.
+ * If they are not, it loads the Errors language file and shows an error using $txt['cannot_' . $permission].
+ * If they are a guest and cannot do it, this calls is_not_guest().
+ * @param string $permission
+ * @param array $boards = null
+ */
 function isAllowedTo($permission, $boards = null)
 {
 	global $user_info, $txt;
@@ -1060,7 +1023,15 @@ function isAllowedTo($permission, $boards = null)
 		validateSession();
 }
 
-// Return the boards a user has a certain (board) permission on. (array(0) if all.)
+/**
+ * Return the boards a user has a certain (board) permission on. (array(0) if all.)
+ * returns a list of boards on which the user is allowed to do the specified permission.
+ * Returns an array with only a 0 in it if the user has permission to do this on every board.
+ * Returns an empty array if he or she cannot do this on any board.
+ * If check_access is true will also make sure the group has proper access to that board.
+ * @param array $permissions
+ * @param bool $check_access = true
+ */
 function boardsAllowedTo($permissions, $check_access = true)
 {
 	global $user_info, $modSettings, $smcFunc;
@@ -1108,6 +1079,19 @@ function boardsAllowedTo($permissions, $check_access = true)
 	return $boards;
 }
 
+/**
+ * Returns whether an email address should be shown and how.
+ * Possible outcomes are
+ *  'yes': show the full email address
+ *  'yes_permission_override': show the full email address, either you
+ *   are a moderator or it's your own email address.
+ *  'no_through_forum': don't show the email address, but do allow
+ *    things to be mailed using the built-in forum mailer.
+ *  'no': keep the email address hidden.
+ * @param bool $userProfile_hideEmail
+ * @param int $userProfile_id
+ * @return string (yes, yes_permission_override, no_through_forum, no)
+ */
 function showEmailAddress($userProfile_hideEmail, $userProfile_id)
 {
 	global $modSettings, $user_info;
@@ -1121,6 +1105,7 @@ function showEmailAddress($userProfile_hideEmail, $userProfile_id)
 	// If the forum is set to show full email addresses: yes.
 	// Otherwise: no_through_forum.
 
+	// @todo this is really hard to understand using the ternary operator. Change to regular if/switch syntax.
 	return (!empty($modSettings['guest_hideContacts']) && $user_info['is_guest']) || isset($_SESSION['ban']['cannot_post']) ? 'no' : ((!$user_info['is_guest'] && $user_info['id'] == $userProfile_id && !$userProfile_hideEmail) || allowedTo('moderate_forum') ? 'yes_permission_override' : ($userProfile_hideEmail ? 'no' : (!empty($modSettings['make_email_viewable']) ? 'yes' : 'no_through_forum')));
 }
 

+ 32 - 36
Sources/SendTopic.php

@@ -1,6 +1,7 @@
 <?php
 
 /**
+ * The functions in this file deal with sending topics to a friend or moderator
  * Simple Machines Forum (SMF)
  *
  * @package SMF
@@ -14,38 +15,9 @@
 if (!defined('SMF'))
 	die('Hacking attempt...');
 
-/*	The functions in this file deal with sending topics to a friend or
-	moderator, and those functions are:
-
-	void SendTopic()
-		- sends information about a topic to a friend.
-		- uses the SendTopic template, with the main sub template.
-		- requires the send_topic permission.
-		- redirects back to the first page of the topic when done.
-		- is accessed via ?action=emailuser;sa=sendtopic.
-
-	void CustomEmail()
-		- send an email to the user - allow the sender to write the message.
-		- can either be passed a user ID as uid or a message id as msg.
-		- does not check permissions for a message ID as there is no information disclosed.
-
-	void ReportToModerator()
-		- gathers data from the user to report abuse to the moderator(s).
-		- uses the ReportToModerator template, main sub template.
-		- requires the report_any permission.
-		- uses ReportToModerator2() if post data was sent.
-		- accessed through ?action=reporttm.
-
-	void ReportToModerator2()
-		- sends off emails to all the moderators.
-		- sends to administrators and global moderators. (1 and 2)
-		- called by ReportToModerator(), and thus has the same permission
-		  and setting requirements as it does.
-		- accessed through ?action=reporttm when posting.
-
-*/
-
-// The main handling function for sending specialist (Or otherwise) emails to a user.
+/**
+ * The main handling function for sending specialist (Or otherwise) emails to a user.
+ */
 function EmailUser()
 {
 	global $topic, $txt, $context, $scripturl, $sourcedir, $smcFunc;
@@ -67,7 +39,13 @@ function EmailUser()
 	$sub_actions[$_GET['sa']]();
 }
 
-// Send a topic to a friend.
+/**
+ * Send a topic to a friend.
+ * Uses the SendTopic template, with the main sub template.
+ * Requires the send_topic permission.
+ * Redirects back to the first page of the topic when done.
+ * Is accessed via ?action=emailuser;sa=sendtopic.
+ */
 function SendTopic()
 {
 	global $topic, $txt, $context, $scripturl, $sourcedir, $smcFunc, $modSettings;
@@ -164,7 +142,12 @@ function SendTopic()
 	redirectexit('topic=' . $topic . '.0');
 }
 
-// Allow a user to send an email.
+/**
+ * Allow a user to send an email.
+ * Send an email to the user - allow the sender to write the message.
+ * Can either be passed a user ID as uid or a message id as msg.
+ * Does not check permissions for a message ID as there is no information disclosed.
+ */
 function CustomEmail()
 {
 	global $context, $modSettings, $user_info, $smcFunc, $txt, $scripturl, $sourcedir;
@@ -288,7 +271,14 @@ function CustomEmail()
 	$context['page_title'] = $txt['send_email'];
 }
 
-// Report a post to the moderator... ask for a comment.
+/**
+ * Report a post to the moderator... ask for a comment.
+ * Gathers data from the user to report abuse to the moderator(s).
+ * Uses the ReportToModerator template, main sub template.
+ * Requires the report_any permission.
+ * Uses ReportToModerator2() if post data was sent.
+ * Accessed through ?action=reporttm.
+ */
 function ReportToModerator()
 {
 	global $txt, $topic, $sourcedir, $modSettings, $user_info, $context, $smcFunc;
@@ -354,7 +344,13 @@ function ReportToModerator()
 	$context['sub_template'] = 'report';
 }
 
-// Send the emails.
+/**
+ * Send the emails.
+ * Sends off emails to all the moderators.
+ * Sends to administrators and global moderators. (1 and 2)
+ * Called by ReportToModerator(), and thus has the same permission and setting requirements as it does.
+ * Accessed through ?action=reporttm when posting.
+ */
 function ReportToModerator2()
 {
 	global $txt, $scripturl, $topic, $board, $user_info, $modSettings, $sourcedir, $language, $context, $smcFunc;

+ 1 - 0
Sources/Session.php

@@ -125,6 +125,7 @@ function sessionClose()
  * Implementation of sessionRead() replacing the standard read handler.
  *
  * @param string $session_id
+ * @return string
  */
 function sessionRead($session_id)
 {

+ 14 - 0
Sources/Subs-Db-mysql.php

@@ -19,6 +19,11 @@ if (!defined('SMF'))
 /**
  *  Maps the implementations in this file (smf_db_function_name)
  *  to the $smcFunc['db_function_name'] variable.
+ *  @param string $db_server
+ *  @param string $db_name
+ *  @param string $db_user
+ *  @param string $db_passwd
+ *  @param array $db_options = array()
  */
 function smf_db_initiate($db_server, $db_name, $db_user, $db_passwd, $db_prefix, $db_options = array())
 {
@@ -96,6 +101,8 @@ function db_extend($type = 'extra')
 
 /**
  * Fix up the prefix so it doesn't require the database to be selected.
+ * @param string &db_prefix
+ * @param string $db_name
  */
 function db_fix_prefix(&$db_prefix, $db_name)
 {
@@ -215,6 +222,9 @@ function smf_db_replacement__callback($matches)
 /**
  * Just like the db_query, escape and quote a string,
  * but not executing the query.
+ * @param string $db_string
+ * @param array $db_values
+ * @param resource $connection = null
  */
 function smf_db_quote($db_string, $db_values, $connection = null)
 {
@@ -238,6 +248,10 @@ function smf_db_quote($db_string, $db_values, $connection = null)
 
 /**
  * Do a query.  Takes care of errors too.
+ * @param string $identifier
+ * @param string $db_string
+ * @param array $db_values = array()
+ * @param resource $connection = null
  */
 function smf_db_query($identifier, $db_string, $db_values = array(), $connection = null)
 {

+ 52 - 50
Sources/Subs-Membergroups.php

@@ -1,6 +1,8 @@
 <?php
 
 /**
+ * This file contains functions regarding manipulation of and information about membergroups.
+ * 
  * Simple Machines Forum (SMF)
  *
  * @package SMF
@@ -14,44 +16,16 @@
 if (!defined('SMF'))
 	die('Hacking attempt...');
 
-/*	This file contains functions regarding manipulation of and information
-	about membergroups.
-
-	bool deleteMembergroups(array groups)
-		- delete one of more membergroups.
-		- requires the manage_membergroups permission.
-		- returns true on success or false on failure.
-		- has protection against deletion of protected membergroups.
-		- deletes the permissions linked to the membergroup.
-		- takes members out of the deleted membergroups.
-
-	bool removeMembersFromGroups(array members, array groups = null)
-		- remove one or more members from one or more membergroups.
-		- requires the manage_membergroups permission.
-		- returns true on success or false on failure.
-		- if groups is null, the specified members are stripped from all their
-		  membergroups.
-		- function includes a protection against removing from implicit groups.
-		- non-admins are not able to remove members from the admin group.
-
-	bool addMembersToGroup(array members, group, type = 'auto')
-		- add one or more members to a specified group.
-		- requires the manage_membergroups permission.
-		- returns true on success or false on failure.
-		- the type parameter specifies whether the group is added as primary or
-		  as additional group.
-		- function has protection against adding members to implicit groups.
-		- non-admins are not able to add members to the admin group.
-
-	bool listMembergroupMembers_Href(&array members, int membergroup, int limit = null)
-		- get a list of all members that are part of a membergroup.
-		- if limit is set to null, all members are returned.
-		- returns a list of href-links in $members.
-		- returns true if there are more than limit members.
-
-*/
-
-// Delete one or more membergroups.
+/**
+ * Delete one of more membergroups.
+ * Requires the manage_membergroups permission.
+ * Returns true on success or false on failure.
+ * Has protection against deletion of protected membergroups.
+ * Deletes the permissions linked to the membergroup.
+ * Takes members out of the deleted membergroups.
+ * @param array $groups
+ * @return bool
+ */
 function deleteMembergroups($groups)
 {
 	global $sourcedir, $smcFunc, $modSettings;
@@ -227,7 +201,16 @@ function deleteMembergroups($groups)
 	return true;
 }
 
-// Remove one or more members from one or more membergroups.
+/**
+ * Remove one or more members from one or more membergroups.
+ * Requires the manage_membergroups permission.
+ * Function includes a protection against removing from implicit groups.
+ * Non-admins are not able to remove members from the admin group.
+ * @param array $members
+ * @param array $groups = null if groups is null, the specified members are stripped from all their membergroups.
+ * @param bool $permissionCheckDone = false
+ * @return bool
+ */
 function removeMembersFromGroups($members, $groups = null, $permissionCheckDone = false)
 {
 	global $smcFunc, $user_info, $modSettings;
@@ -440,17 +423,29 @@ function removeMembersFromGroups($members, $groups = null, $permissionCheckDone
 	return true;
 }
 
-// Add one or more members to a membergroup.
-/* Supported types:
-	- only_primary      - Assigns a membergroup as primary membergroup, but only
-						  if a member has not yet a primary membergroup assigned,
-						  unless the member is already part of the membergroup.
-	- only_additional   - Assigns a membergroup to the additional membergroups,
-						  unless the member is already part of the membergroup.
-	- force_primary     - Assigns a membergroup as primary membergroup no matter
-						  what the previous primary membergroup was.
-	- auto              - Assigns a membergroup to the primary group if it's still
-						  available. If not, assign it to the additional group. */
+/**
+ * Add one or more members to a membergroup
+ * 
+ * Requires the manage_membergroups permission.
+ * Function has protection against adding members to implicit groups.
+ * Non-admins are not able to add members to the admin group.
+ * 
+ * @param string|array $members
+ * @param int $group
+ * @param string $type = 'auto' specifies whether the group is added as primary or as additional group.
+ * Supported types:
+ * 	- only_primary      - Assigns a membergroup as primary membergroup, but only
+ * 						  if a member has not yet a primary membergroup assigned,
+ * 						  unless the member is already part of the membergroup.
+ * 	- only_additional   - Assigns a membergroup to the additional membergroups,
+ * 						  unless the member is already part of the membergroup.
+ * 	- force_primary     - Assigns a membergroup as primary membergroup no matter
+ * 						  what the previous primary membergroup was.
+ * 	- auto              - Assigns a membergroup to the primary group if it's still
+ * 						  available. If not, assign it to the additional group.
+ * @param bool $permissionCheckDone
+ * @return bool success or failure
+ */
 function addMembersToGroup($members, $group, $type = 'auto', $permissionCheckDone = false)
 {
 	global $smcFunc, $user_info, $modSettings;
@@ -602,6 +597,13 @@ function addMembersToGroup($members, $group, $type = 'auto', $permissionCheckDon
 	return true;
 }
 
+/**
+ * 
+ * @param array &$members
+ * @param int $membergroup
+ * @param int $limit = null
+ * @return bool
+ */
 function listMembergroupMembers_Href(&$members, $membergroup, $limit = null)
 {
 	global $scripturl, $txt, $smcFunc;

+ 15 - 2
Sources/Subs-MembersOnline.php

@@ -26,7 +26,17 @@ if (!defined('SMF'))
 		- (optionally) hides members that chose to hide their online presense.
 */
 
-// Retrieve a list and several other statistics of the users currently online.
+// 
+/**
+ * Retrieve a list and several other statistics of the users currently online.
+ * - retrieve a list and several other statistics of the users currently
+ *   online on the forum.
+ * - used by the board index and SSI.
+ * - also returns the membergroups of the users that are currently online.
+ * - (optionally) hides members that chose to hide their online presense.
+ * @param array $membersOnlineOptions
+ * @return array
+ */
 function getMembersOnlineStats($membersOnlineOptions)
 {
 	global $smcFunc, $context, $scripturl, $user_info, $modSettings, $txt;
@@ -196,7 +206,10 @@ function getMembersOnlineStats($membersOnlineOptions)
 	return $membersOnlineStats;
 }
 
-// Check if the number of users online is a record and store it.
+/**
+ * Check if the number of users online is a record and store it.
+ * @param int $total_users_online
+ */
 function trackStatsUsersOnline($total_users_online)
 {
 	global $modSettings, $smcFunc;

+ 14 - 5
Sources/Subs-Menu.php

@@ -1,6 +1,8 @@
 <?php
 
 /**
+ * This file contains a standard way of displaying side/drop down menus for SMF.
+ * 
  * Simple Machines Forum (SMF)
  *
  * @package SMF
@@ -14,10 +16,13 @@
 if (!defined('SMF'))
 	die('Hacking attempt...');
 
-/*	This file contains a standard way of displaying side/drop down menus for SMF.
-*/
-
-// Create a menu...
+// ..
+/**
+ * Create a menu.
+ * @param array $menuData
+ * @param array $menuOptions = array()
+ * @return bool|array
+ */
 function createMenu($menuData, $menuOptions = array())
 {
 	global $context, $settings, $options, $txt, $modSettings, $scripturl, $smcFunc, $user_info, $sourcedir, $options;
@@ -281,7 +286,11 @@ function createMenu($menuData, $menuOptions = array())
 	return $include_data;
 }
 
-// Delete a menu.
+/**
+ * Delete a menu.
+ * @param string $menu_id = 'last'
+ * @return bool
+ */
 function destroyMenu($menu_id = 'last')
 {
 	global $context;

+ 40 - 10
Sources/Subs-OpenID.php

@@ -15,15 +15,6 @@
 if (!defined('SMF'))
 	die('Hacking attempt...');
 
-/*	This file handles all of the OpenID interfacing and communications.
-	void smf_openID_validate(string openid_url, bool allow_immediate_validation = true)
-		- openid_uri is the URI given by the user
-		- Validates the URI and changes it to a fully canonicalize URL
-		- Determines the IDP server and delegation
-		- optional array of fields to restore when validation complete.
-		- Redirects the user to the IDP for validation
-*/
-
 /**
  * Openid_uri is the URI given by the user
  * Validates the URI and changes it to a fully canonicalize URL
@@ -152,6 +143,10 @@ function smf_openID_getAssociation($server, $handle = null, $no_delete = false)
 	return $return;
 }
 
+/**
+ * @todo Enter description here ...
+ * @param string $server
+ */
 function smf_openID_makeAssociation($server)
 {
 	global $smcFunc, $modSettings, $p;
@@ -385,6 +380,10 @@ function smf_openID_return()
 	}
 }
 
+/**
+ * @todo Enter description here ...
+ * @param string $uri
+ */
 function smf_openID_canonize($uri)
 {
 	// @todo Add in discovery.
@@ -398,6 +397,10 @@ function smf_openID_canonize($uri)
 	return $uri;
 }
 
+/**
+ * @todo Enter description here ...
+ * @param string $uri
+ */
 function smf_openid_member_exists($url)
 {
 	global $smcFunc;
@@ -419,6 +422,7 @@ function smf_openid_member_exists($url)
 /**
  * Prepare for a Diffie-Hellman key exchange.
  * @param bool $regenerate = false
+ * @return array|false return false on failure or an array() on success
  */
 function smf_openID_setup_DH($regenerate = false)
 {
@@ -438,6 +442,10 @@ function smf_openID_setup_DH($regenerate = false)
 	return smf_openID_get_keys($regenerate);
 }
 
+/**
+ * @todo Enter description here ...
+ * @param bool $regenerate
+ */
 function smf_openID_get_keys($regenerate)
 {
 	global $modSettings, $p, $g;
@@ -467,6 +475,10 @@ function smf_openID_get_keys($regenerate)
 	);
 }
 
+/**
+ * @todo Enter description here ...
+ * @return float
+ */
 function smf_openid_generate_private_key()
 {
 	global $p;
@@ -501,6 +513,12 @@ function smf_openid_generate_private_key()
 	return bcadd(bcmod($num, $p), 1);
 }
 
+/**
+ * 
+ * Enter description here ...
+ * @param string $openid_url
+ * @return bool|array
+ */
 function smf_openID_getServerInfo($openid_url)
 {
 	global $sourcedir;
@@ -539,6 +557,11 @@ function smf_openID_getServerInfo($openid_url)
 	return $response_data;
 }
 
+/**
+ * @param string $data
+ * @param string $key
+ * @return string
+ */
 function sha1_hmac($data, $key)
 {
 
@@ -554,9 +577,12 @@ function sha1_hmac($data, $key)
 	return $hmac;
 }
 
+/**
+ * @todo move to Subs-Compat.php
+ */
 function sha1_raw($text)
 {
-	if (version_compare(PHP_VERSION, '5.0.0', '<='))
+	if (version_compare(PHP_VERSION, '5.0.0', '>='))
 		return sha1($text, true);
 
 	$hex = sha1($text);
@@ -613,6 +639,10 @@ function long_to_binary($value)
 	return $return;
 }
 
+/**
+ * @param int $num1
+ * @param int $num2
+ */
 function binary_xor($num1, $num2)
 {
 	$return = '';

+ 87 - 17
Sources/Subs.php

@@ -683,7 +683,6 @@ function constructPageIndex($base_url, &$start, $max_value, $num_per_page, $flex
 	return $pageindex;
 }
 
-// Formats a number to display in the style of the admin's choosing.
 /**
  * formats a number to display in the style of the admins' choosing.
  * uses the format of number_format to decide how to format the number.
@@ -857,7 +856,11 @@ function shorten_subject($subject, $len)
 	return $smcFunc['substr']($subject, 0, $len) . '...';
 }
 
-// The current time with offset.
+/**
+ * The current time with offset.
+ * @param bool $use_user_offset = true
+ * @param int $timestamp = null
+ */
 function forum_time($use_user_offset = true, $timestamp = null)
 {
 	global $user_info, $modSettings;
@@ -2479,7 +2482,10 @@ function parse_bbc($message, $smileys = true, $cache_id = '', $parse_tags = arra
 	return $message;
 }
 
-// Parse smileys in the passed message.
+/**
+ * Parse smileys in the passed message.
+ * @param string &$message
+ */
 function parsesmileys(&$message)
 {
 	global $modSettings, $txt, $user_info, $context, $smcFunc;
@@ -2554,7 +2560,10 @@ function parsesmileys(&$message)
 	$message = preg_replace($smileyPregSearch, '$smileyPregReplacements[\'$1\']', $message);
 }
 
-// Highlight any code...
+/**
+ * Highlight any code.
+ * @param string $code
+ */
 function highlight_php_code($code)
 {
 	global $context;
@@ -2586,6 +2595,8 @@ function highlight_php_code($code)
 /**
  * Make sure the browser doesn't come back and repost the form data.
  * Should be used whenever anything is posted.
+ * @param string $setLocation = ''
+ * @param bool $refresh = false
  */
 function redirectexit($setLocation = '', $refresh = false)
 {
@@ -2645,7 +2656,13 @@ function redirectexit($setLocation = '', $refresh = false)
 	obExit(false);
 }
 
-// Ends execution.  Takes care of template loading and remembering the previous URL.
+/**
+ * Ends execution.  Takes care of template loading and remembering the previous URL.
+ * @param bool $header = null
+ * @param bool $do_footer = null
+ * @param bool $from_index = false
+ * @param bool $from_fatal_error = false
+ */
 function obExit($header = null, $do_footer = null, $from_index = false, $from_fatal_error = false)
 {
 	global $context, $settings, $modSettings, $txt, $smcFunc;
@@ -2761,6 +2778,10 @@ function obExit($header = null, $do_footer = null, $from_index = false, $from_fa
 		exit;
 }
 
+/**
+ * 
+ * @param array &$topic_context
+ */
 function determineTopicClass(&$topic_context)
 {
 	// Set topic class depending on locked status and number of replies.
@@ -2948,7 +2969,9 @@ function setupThemeContext($forceload = false)
 	$context['meta_keywords'] = !empty($modSettings['meta_keywords']) ? $smcFunc['htmlspecialchars']($modSettings['meta_keywords']) : '';
 }
 
-// This is the only template included in the sources...
+/**
+ * This is the only template included in the sources.
+ */
 function template_rawdata()
 {
 	global $context;
@@ -2956,6 +2979,9 @@ function template_rawdata()
 	echo $context['raw_data'];
 }
 
+/**
+ * 
+ */
 function template_header()
 {
 	global $txt, $modSettings, $context, $settings, $user_info, $boarddir, $cachedir;
@@ -3053,7 +3079,10 @@ function template_header()
 	}
 }
 
-// Show the copyright...
+/**
+ * Show the copyright.
+ * @param bool $get_it = false
+ */
 function theme_copyright($get_it = false)
 {
 	global $forum_copyright, $context, $boardurl, $forum_version, $txt, $modSettings;
@@ -3070,6 +3099,9 @@ function theme_copyright($get_it = false)
 			</span>';
 }
 
+/**
+ * 
+ */
 function template_footer()
 {
 	global $context, $settings, $modSettings, $time_start, $db_count;
@@ -3181,7 +3213,9 @@ function getLegacyAttachmentFilename($filename, $attachment_id, $dir = null, $ne
 	return $filename;
 }
 
-// Convert a single IP to a ranged IP.
+/**
+ * Convert a single IP to a ranged IP.
+ */
 function ip2range($fullip)
 {
 	// If its IPv6, validate it first.
@@ -3235,7 +3269,9 @@ function ip2range($fullip)
 	return $ip_array;
 }
 
-// Lookup an IP; try shell_exec first because we can do a timeout on it.
+/**
+ * Lookup an IP; try shell_exec first because we can do a timeout on it.
+ */
 function host_from_ip($ip)
 {
 	global $modSettings;
@@ -3288,7 +3324,9 @@ function host_from_ip($ip)
 	return $host;
 }
 
-// Chops a string into words and prepares them to be inserted into (or searched from) the database.
+/**
+ * Chops a string into words and prepares them to be inserted into (or searched from) the database.
+ */
 function text2words($text, $max_chars = 20, $encrypt = false)
 {
 	global $smcFunc, $context;
@@ -3332,7 +3370,16 @@ function text2words($text, $max_chars = 20, $encrypt = false)
 	}
 }
 
-// Creates an image/text button
+/**
+ * Creates an image/text button
+ * 
+ * @param string $filename
+ * @param string $alt
+ * @param string $label = ''
+ * @param bool $custom = ''
+ * @param bool $force_use = false
+ * @return string
+ */
 function create_button($name, $alt, $label = '', $custom = '', $force_use = false)
 {
 	global $settings, $txt, $context;
@@ -3349,7 +3396,9 @@ function create_button($name, $alt, $label = '', $custom = '', $force_use = fals
 		return '<img src="' . $settings['lang_images_url'] . '/' . $name . '" alt="' . $txt[$alt] . '" ' . $custom . ' />';
 }
 
-// Empty out the cache folder.
+/**
+ * Empty out the cache folder.
+ */
 function clean_cache($type = '')
 {
 	global $cachedir, $sourcedir;
@@ -3373,7 +3422,9 @@ function clean_cache($type = '')
 	clearstatcache();
 }
 
-// Load classes that are both (E_STRICT) PHP 4 and PHP 5 compatible.
+/**
+ * Load classes that are both (E_STRICT) PHP 4 and PHP 5 compatible.
+ */
 function loadClassFile($filename)
 {
 	global $sourcedir;
@@ -3415,6 +3466,9 @@ function loadClassFile($filename)
 		require_once($sourcedir . '/' . $filename);
 }
 
+/**
+ * 
+ */
 function setupMenuContext()
 {
 	global $context, $modSettings, $user_info, $txt, $scripturl;
@@ -3697,7 +3751,9 @@ function setupMenuContext()
 	}
 }
 
-// Generate a random seed and ensure it's stored in settings.
+/**
+ * Generate a random seed and ensure it's stored in settings.
+ */
 function smf_seed_generator()
 {
 	global $modSettings;
@@ -3719,7 +3775,12 @@ function smf_seed_generator()
 	updateSettings(array('rand_seed' => mt_rand()));
 }
 
-// Process functions of an integration hook.
+/**
+ * Process functions of an integration hook.
+ * @param string $hook
+ * @param array $paramaters = array()
+ * @return array
+ */
 function call_integration_hook($hook, $parameters = array())
 {
 	global $modSettings;
@@ -3744,7 +3805,12 @@ function call_integration_hook($hook, $parameters = array())
 	return $results;
 }
 
-// Add a function for integration hook.
+/**
+ * Add a function for integration hook.
+ * @param string $hook
+ * @param string $function
+ * @param bool $permanent = true
+ */
 function add_integration_function($hook, $function, $permanent = true)
 {
 	global $smcFunc, $modSettings;
@@ -3788,7 +3854,11 @@ function add_integration_function($hook, $function, $permanent = true)
 	$modSettings[$hook] = implode(',', $functions);
 }
 
-// Remove an integration hook function.
+/**
+ * Remove an integration hook function.
+ * @param string $hook
+ * @param string $function
+ */
 function remove_integration_function($hook, $function)
 {
 	global $smcFunc, $modSettings;