From: <be...@us...> - 2015-09-29 10:22:39
|
Revision: 13154 http://sourceforge.net/p/xoops/svn/13154 Author: beckmi Date: 2015-09-29 10:22:37 +0000 (Tue, 29 Sep 2015) Log Message: ----------- Invalid argument supplied for foreach Modified Paths: -------------- XoopsCore/branches/2.5.x/2.5.8/docs/changelog.250.txt XoopsCore/branches/2.5.x/2.5.8/htdocs/include/notification_functions.php Modified: XoopsCore/branches/2.5.x/2.5.8/docs/changelog.250.txt =================================================================== --- XoopsCore/branches/2.5.x/2.5.8/docs/changelog.250.txt 2015-09-25 10:12:26 UTC (rev 13153) +++ XoopsCore/branches/2.5.x/2.5.8/docs/changelog.250.txt 2015-09-29 10:22:37 UTC (rev 13154) @@ -24,7 +24,8 @@ - added strong { font-weight: bold; } to reset.css (mamba) - added .tpl option for module Help files (mamba) - fix moved "count($tagsArray)" and "count($attrArray)" outside of FOR loop in xoopsfilterinput.php (mamba) -- add option to set height of Themes block (mamba) +- add option to set height of Themes block (mamba) +- fix: Invalid argument supplied for foreach() (cesagonchu/mamba) Security fixes Modified: XoopsCore/branches/2.5.x/2.5.8/htdocs/include/notification_functions.php =================================================================== --- XoopsCore/branches/2.5.x/2.5.8/htdocs/include/notification_functions.php 2015-09-25 10:12:26 UTC (rev 13153) +++ XoopsCore/branches/2.5.x/2.5.8/htdocs/include/notification_functions.php 2015-09-29 10:22:37 UTC (rev 13154) @@ -10,14 +10,14 @@ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * * @copyright (c) 2000-2015 XOOPS Project (www.xoops.org) - * @license GNU GPL 2 (http://www.gnu.org/licenses/old-licenses/gpl-2.0.html) - * @package kernel - * @subpackage Xoop Notifications Functions - * @since 2.0.0 - * @author Kazumi Ono (AKA onokazu) http://www.myweb.ne.jp/, http://jp.xoops.org/ - * @version $Id$ + * @license GNU GPL 2 (http://www.gnu.org/licenses/old-licenses/gpl-2.0.html) + * @package kernel + * @subpackage Xoop Notifications Functions + * @since 2.0.0 + * @author Kazumi Ono (AKA onokazu) http://www.myweb.ne.jp/, http://jp.xoops.org/ + * @version $Id$ */ -defined('XOOPS_ROOT_PATH') || die('Restricted access'); +defined('XOOPS_ROOT_PATH') || exit('Restricted access'); // RMV-NOTIFY @@ -27,8 +27,8 @@ /** * Determine if notification is enabled for the selected module. * - * @param string $style Subscription style: 'block' or 'inline' - * @param int $module_id ID of the module (default current module) + * @param string $style Subscription style: 'block' or 'inline' + * @param int $module_id ID of the module (default current module) * @return bool */ function notificationEnabled($style, $module_id = null) @@ -36,28 +36,28 @@ if (isset($GLOBALS['xoopsModuleConfig']['notification_enabled'])) { $status = $GLOBALS['xoopsModuleConfig']['notification_enabled']; } else { - if (! isset($module_id)) { + if (!isset($module_id)) { return false; } - $module_handler =& xoops_gethandler('module'); - $module =& $module_handler->get($module_id); + $module_handler =& xoops_getHandler('module'); + $module =& $module_handler->get($module_id); if (!empty($module) && $module->getVar('hasnotification') == 1) { - $config_handler =& xoops_gethandler('config'); - $config = $config_handler->getConfigsByCat(0, $module_id); - $status = $config['notification_enabled']; + $config_handler =& xoops_getHandler('config'); + $config = $config_handler->getConfigsByCat(0, $module_id); + $status = $config['notification_enabled']; } else { return false; } } include_once $GLOBALS['xoops']->path('include/notification_constants.php'); - if (($style == 'block') && ($status == XOOPS_NOTIFICATION_ENABLEBLOCK || $status == XOOPS_NOTIFICATION_ENABLEBOTH)) { + if (($style === 'block') && ($status === XOOPS_NOTIFICATION_ENABLEBLOCK || $status === XOOPS_NOTIFICATION_ENABLEBOTH)) { return true; } - if (($style == 'inline') && ($status == XOOPS_NOTIFICATION_ENABLEINLINE || $status == XOOPS_NOTIFICATION_ENABLEBOTH)) { + if (($style === 'inline') && ($status === XOOPS_NOTIFICATION_ENABLEINLINE || $status === XOOPS_NOTIFICATION_ENABLEBOTH)) { return true; } // if ($status != XOOPS_NOTIFICATION_DISABLE) { - // return true; + // return true; // } return false; } @@ -78,12 +78,12 @@ if (!isset($module_id)) { global $xoopsModule; $module_id = !empty($xoopsModule) ? $xoopsModule->getVar('mid') : 0; - $module =& $xoopsModule; + $module =& $xoopsModule; } else { - $module_handler =& xoops_gethandler('module'); - $module = &$module_handler->get($module_id); + $module_handler =& xoops_getHandler('module'); + $module = &$module_handler->get($module_id); } - $not_config = & $module->getInfo('notification'); + $not_config = &$module->getInfo('notification'); if (empty($category_name)) { return $not_config['category']; } @@ -107,12 +107,12 @@ * of comments, and also remove the restriction that * all notification categories must have unique item_name. (TODO) * - * @param int $module_id ID of the module (default current module) + * @param int $module_id ID of the module (default current module) * @return mixed Associative array of category info */ function ¬ificationCommentCategoryInfo($module_id = null) { - $ret = false; + $ret = false; $all_categories =& notificationCategoryInfo('', $module_id); if (empty($all_categories)) { return $ret; @@ -123,7 +123,7 @@ continue; } foreach ($all_events as $event) { - if ($event['name'] == 'comment') { + if ($event['name'] === 'comment') { return $category; } } @@ -138,9 +138,9 @@ * Get an array of info for all events (each event has associative array) * in the selected category of the selected module. * - * @param string $category_name Category name - * @param bool $enabled_only If true, return only enabled events - * @param int $module_id ID of the module (default current module) + * @param string $category_name Category name + * @param bool $enabled_only If true, return only enabled events + * @param int $module_id ID of the module (default current module) * @return mixed */ function ¬ificationEvents($category_name, $enabled_only, $module_id = null) @@ -148,23 +148,23 @@ if (!isset($module_id)) { global $xoopsModule; $module_id = !empty($xoopsModule) ? $xoopsModule->getVar('mid') : 0; - $module =& $xoopsModule; + $module =& $xoopsModule; } else { - $module_handler =& xoops_gethandler('module'); - $module = $module_handler->get($module_id); + $module_handler =& xoops_getHandler('module'); + $module = $module_handler->get($module_id); } - $not_config = $module->getInfo('notification'); - $config_handler = & xoops_gethandler('config'); - $mod_config = $config_handler->getConfigsByCat(0, $module_id); + $not_config = $module->getInfo('notification'); + $config_handler = &xoops_getHandler('config'); + $mod_config = $config_handler->getConfigsByCat(0, $module_id); $category = notificationCategoryInfo($category_name, $module_id); global $xoopsConfig; $event_array = array(); - $override_comment = false; + $override_comment = false; $override_commentsubmit = false; - $override_bookmark = false; + $override_bookmark = false; foreach ($not_config['event'] as $event) { if ($event['category'] == $category_name) { @@ -175,13 +175,13 @@ if (!$enabled_only || notificationEventEnabled($category, $event, $module)) { $event_array[] = $event; } - if ($event['name'] == 'comment') { + if ($event['name'] === 'comment') { $override_comment = true; } - if ($event['name'] == 'comment_submit') { + if ($event['name'] === 'comment_submit') { $override_commentsubmit = true; } - if ($event['name'] == 'bookmark') { + if ($event['name'] === 'bookmark') { $override_bookmark = true; } } @@ -199,14 +199,14 @@ $mail_template_dir = $dir; include_once $GLOBALS['xoops']->path('include/comment_constants.php'); - $config_handler =& xoops_gethandler('config'); - $com_config = $config_handler->getConfigsByCat(0, $module_id); + $config_handler =& xoops_getHandler('config'); + $com_config = $config_handler->getConfigsByCat(0, $module_id); if (!$enabled_only) { $insert_comment = true; - $insert_submit = true; + $insert_submit = true; } else { $insert_comment = false; - $insert_submit = false; + $insert_submit = false; switch ($com_config['com_rule']) { case XOOPS_COMMENT_APPROVENONE: // comments disabled, no comment events @@ -231,47 +231,45 @@ } if ($insert_comment) { $event = array( - 'name' => 'comment' , - 'category' => $category['name'] , - 'title' => _NOT_COMMENT_NOTIFY , - 'caption' => _NOT_COMMENT_NOTIFYCAP , - 'description' => _NOT_COMMENT_NOTIFYDSC , - 'mail_template_dir' => $mail_template_dir , - 'mail_template' => 'comment_notify' , - 'mail_subject' => _NOT_COMMENT_NOTIFYSBJ); + 'name' => 'comment', + 'category' => $category['name'], + 'title' => _NOT_COMMENT_NOTIFY, + 'caption' => _NOT_COMMENT_NOTIFYCAP, + 'description' => _NOT_COMMENT_NOTIFYDSC, + 'mail_template_dir' => $mail_template_dir, + 'mail_template' => 'comment_notify', + 'mail_subject' => _NOT_COMMENT_NOTIFYSBJ); if (!$enabled_only || notificationEventEnabled($category, $event, $module)) { $event_array[] = $event; } } if ($insert_submit) { $event = array( - 'name' => 'comment_submit' , - 'category' => $category['name'] , - 'title' => _NOT_COMMENTSUBMIT_NOTIFY , - 'caption' => _NOT_COMMENTSUBMIT_NOTIFYCAP , - 'description' => _NOT_COMMENTSUBMIT_NOTIFYDSC , - 'mail_template_dir' => $mail_template_dir , - 'mail_template' => 'commentsubmit_notify' , - 'mail_subject' => _NOT_COMMENTSUBMIT_NOTIFYSBJ , - 'admin_only' => 1); + 'name' => 'comment_submit', + 'category' => $category['name'], + 'title' => _NOT_COMMENTSUBMIT_NOTIFY, + 'caption' => _NOT_COMMENTSUBMIT_NOTIFYCAP, + 'description' => _NOT_COMMENTSUBMIT_NOTIFYDSC, + 'mail_template_dir' => $mail_template_dir, + 'mail_template' => 'commentsubmit_notify', + 'mail_subject' => _NOT_COMMENTSUBMIT_NOTIFYSBJ, + 'admin_only' => 1); if (!$enabled_only || notificationEventEnabled($category, $event, $module)) { $event_array[] = $event; } } - } } // Insert bookmark info if appropriate - if (!empty($category['allow_bookmark'])) { if (!$override_bookmark) { $event = array( - 'name' => 'bookmark' , - 'category' => $category['name'] , - 'title' => _NOT_BOOKMARK_NOTIFY , - 'caption' => _NOT_BOOKMARK_NOTIFYCAP , + 'name' => 'bookmark', + 'category' => $category['name'], + 'title' => _NOT_BOOKMARK_NOTIFY, + 'caption' => _NOT_BOOKMARK_NOTIFYCAP, 'description' => _NOT_BOOKMARK_NOTIFYDSC); if (!$enabled_only || notificationEventEnabled($category, $event, $module)) { $event_array[] = $event; @@ -280,7 +278,6 @@ } return $event_array; - } /** @@ -290,22 +287,22 @@ * @todo Check that this works correctly for comment and other * events which depend on additional config options... * - * @param array $category Category info array - * @param array $event Event info array - * @param object $module Module + * @param array $category Category info array + * @param array $event Event info array + * @param object $module Module * @return bool **/ function notificationEventEnabled(&$category, &$event, &$module) { - $config_handler =& xoops_gethandler('config'); - $mod_config = $config_handler->getConfigsByCat(0, $module->getVar('mid')); + $config_handler =& xoops_getHandler('config'); + $mod_config = $config_handler->getConfigsByCat(0, $module->getVar('mid')); if (is_array($mod_config['notification_events']) && $mod_config['notification_events'] != array()) { $option_name = notificationGenerateConfig($category, $event, 'option_name'); if (in_array($option_name, $mod_config['notification_events'])) { return true; } - $notification_handler = & xoops_gethandler('notification'); + $notification_handler = &xoops_getHandler('notification'); } return false; @@ -315,9 +312,9 @@ * Get associative array of info for the selected event in the selected * category (for the selected module). * - * @param string $category_name Notification category - * @param string $event_name Notification event - * @param int $module_id ID of the module (default current module) + * @param string $category_name Notification category + * @param string $event_name Notification event + * @param int $module_id ID of the module (default current module) * @return mixed */ function ¬ificationEventInfo($category_name, $event_name, $module_id = null) @@ -337,7 +334,7 @@ * Get an array of associative info arrays for subscribable categories * for the selected module. * - * @param int $module_id ID of the module + * @param int $module_id ID of the module * @return mixed */ @@ -346,15 +343,16 @@ $all_categories = notificationCategoryInfo('', $module_id); // FIXME: better or more standardized way to do this? - $script_url = explode('/', $_SERVER['PHP_SELF']); + $script_url = explode('/', $_SERVER['PHP_SELF']); $script_name = $script_url[count($script_url) - 1]; $sub_categories = array(); + if (null != $all_categories) { foreach ($all_categories as $category) { // Check the script name $subscribe_from = $category['subscribe_from']; if (!is_array($subscribe_from)) { - if ($subscribe_from == '*') { + if ($subscribe_from === '*') { $subscribe_from = array( $script_name); // FIXME: this is just a hack: force a match @@ -370,20 +368,19 @@ // check if that argument exists... if (empty($category['item_name'])) { $category['item_name'] = ''; - $category['item_id'] = 0; - $sub_categories[] = $category; + $category['item_id'] = 0; + $sub_categories[] = $category; } else { $item_name = $category['item_name']; - $id = ($item_name != '' && isset($_GET[$item_name])) ? (int)($_GET[$item_name]) : 0; + $id = ($item_name != '' && isset($_GET[$item_name])) ? (int)($_GET[$item_name]) : 0; if ($id > 0) { $category['item_id'] = $id; - $sub_categories[] = $category; + $sub_categories[] = $category; } } } - + } return $sub_categories; - } /** |