* @copyright http://www.xoops.org/ The XOOPS Project * @copyright XOOPS_copyrights.txt * @copyright http://www.impresscms.org/ The ImpressCMS Project * @license LICENSE.txt * @package core * @since XOOPS * @author http://www.xoops.org The XOOPS Project * @author modified by UnderDog <*****@*****.**> * @version $Id: notification_select.php 10825 2010-12-03 00:01:23Z skenow $ */ if (!defined('ICMS_ROOT_PATH')) { exit; } include_once ICMS_ROOT_PATH . '/include/notification_constants.php'; $xoops_notification = array(); $xoops_notification['show'] = isset($icmsModule) && is_object(icms::$user) && icms_data_notification_Handler::isEnabled('inline') ? 1 : 0; if ($xoops_notification['show']) { icms_loadLanguageFile('core', 'notification'); $notification_handler = icms::handler('icms_data_notification'); $categories =& $notification_handler->subscribableCategoryInfo(); $event_count = 0; if (!empty($categories)) { foreach ($categories as $category) { $section['name'] = $category['name']; $section['title'] = $category['title']; $section['description'] = $category['description']; $section['itemid'] = $category['item_id']; $section['events'] = array(); $subscribed_events = $notification_handler->getSubscribedEvents($category['name'], $category['item_id'], $icmsModule->getVar('mid'), icms::$user->getVar('uid')); foreach ($notification_handler->categoryEvents($category['name'], true) as $event) { if (!empty($event['admin_only']) && !icms::$user->isAdmin($icmsModule->getVar('mid'))) {
/** * Shows The latest notifications * * @param array $options The block options * @return array $block the block array */ function b_system_notification_show() { global $icmsConfig, $icmsModule; icms_loadLanguageFile('core', 'notification'); // Notification must be enabled, and user must be logged in if (empty(icms::$user) || !icms_data_notification_Handler::isEnabled('block')) { return FALSE; // do not display block } $notification_handler = icms::handler('icms_data_notification'); // Now build the a nested associative array of info to pass // to the block template. $block = array(); $categories =& $notification_handler->subscribableCategoryInfo(); if (empty($categories)) { return FALSE; } foreach ($categories as $category) { $section['name'] = $category['name']; $section['title'] = $category['title']; $section['description'] = $category['description']; $section['itemid'] = $category['item_id']; $section['events'] = array(); $subscribed_events = $notification_handler->getSubscribedEvents($category['name'], $category['item_id'], $icmsModule->getVar('mid'), icms::$user->getVar('uid')); foreach ($notification_handler->categoryEvents($category['name'], TRUE) as $event) { if (!empty($event['admin_only']) && !icms::$user->isAdmin($icmsModule->getVar('mid'))) { continue; } $subscribed = in_array($event['name'], $subscribed_events) ? 1 : 0; $section['events'][$event['name']] = array('name'=>$event['name'], 'title'=>$event['title'], 'caption'=>$event['caption'], 'description'=>$event['description'], 'subscribed'=>$subscribed); } $block['categories'][$category['name']] = $section; } // Additional form data $block['target_page'] = "notification_update.php"; // FIXME: better or more standardized way to do this? $script_url = explode('/', $_SERVER['PHP_SELF']); $script_name = $script_url[count($script_url)-1]; $block['redirect_script'] = $script_name; $block['submit_button'] = _NOT_UPDATENOW; $block['notification_token'] = icms::$security->createToken(); return $block; }
/** * Generate module config info for a particular category, event pair. * The selectable config options are given names depending on the * category and event names, and the text depends on the category * and event titles. These are pieced together in this function in * case we wish to alter the syntax. * * @param array $category Array of category info * @param array $event Array of event info * @param string $type The particular name to generate * return string * @deprecated Use the notification class method instead - generateConfig * @todo **/ function notificationGenerateConfig(&$category, &$event, $type) { icms_core_Debug::setDeprecated('icms_data_notification_Handler::generateConfig', sprintf(_CORE_REMOVE_IN_VERSION, '1.4')); return icms_data_notification_Handler::generateConfig($category, $event, $type); }
function icms_module_update($dirname) { $dirname = trim($dirname); $db =& icms_db_Factory::instance(); $module_handler = icms::handler('icms_module'); $module =& $module_handler->getByDirname($dirname); // Save current version for use in the update function $prev_version = $module->getVar('version'); $prev_dbversion = $module->getVar('dbversion'); xoops_template_clear_module_cache($module->getVar('mid')); // we dont want to change the module name set by admin $temp_name = $module->getVar('name'); $module->loadInfoAsVar($dirname); $module->setVar('name', $temp_name); if (!$module_handler->insert($module)) { echo '<p>Could not update ' . $module->getVar('name') . '</p>'; echo "<br /><a href='admin.php?fct=modulesadmin'>" . _MD_AM_BTOMADMIN . "</a>"; } else { $newmid = $module->getVar('mid'); $msgs = array(); $msgs[] = _MD_AM_MOD_DATA_UPDATED; $tplfile_handler =& icms::handler('icms_view_template_file'); $deltpl =& $tplfile_handler->find('default', 'module', $module->getVar('mid')); $delng = array(); if (is_array($deltpl)) { $xoopsDelTpl = new icms_view_Tpl(); // clear cache files $xoopsDelTpl->clear_cache(null, 'mod_' . $dirname); // delete template file entry in db $dcount = count($deltpl); for ($i = 0; $i < $dcount; $i++) { if (!$tplfile_handler->delete($deltpl[$i])) { $delng[] = $deltpl[$i]->getVar('tpl_file'); } } } $templates = $module->getInfo('templates'); if ($templates != false) { $msgs[] = _MD_AM_MOD_UP_TEM; foreach ($templates as $tpl) { $tpl['file'] = trim($tpl['file']); if (!in_array($tpl['file'], $delng)) { $tpldata =& xoops_module_gettemplate($dirname, $tpl['file']); $tplfile =& $tplfile_handler->create(); $tplfile->setVar('tpl_refid', $newmid); $tplfile->setVar('tpl_lastimported', 0); $tplfile->setVar('tpl_lastmodified', time()); if (preg_match("/\\.css\$/i", $tpl['file'])) { $tplfile->setVar('tpl_type', 'css'); } else { $tplfile->setVar('tpl_type', 'module'); } $tplfile->setVar('tpl_source', $tpldata, true); $tplfile->setVar('tpl_module', $dirname); $tplfile->setVar('tpl_tplset', 'default'); $tplfile->setVar('tpl_file', $tpl['file'], true); $tplfile->setVar('tpl_desc', $tpl['description'], true); if (!$tplfile_handler->insert($tplfile)) { $msgs[] = sprintf(' <span style="color:#ff0000;">' . _MD_AM_TEMPLATE_INSERT_FAIL . '</span>', '<strong>' . $tpl['file'] . '</strong>'); } else { $newid = $tplfile->getVar('tpl_id'); $msgs[] = sprintf(' <span>' . _MD_AM_TEMPLATE_INSERTED . '</span>', '<strong>' . $tpl['file'] . '</strong>', '<strong>' . $newid . '</strong>'); if ($icmsConfig['template_set'] == 'default') { if (!icms_view_Tpl::template_touch($newid)) { $msgs[] = sprintf(' <span style="color:#ff0000;">' . _MD_AM_TEMPLATE_RECOMPILE_FAIL . '</span>', '<strong>' . $tpl['file'] . '</strong>'); } else { $msgs[] = sprintf(' <span>' . _MD_AM_TEMPLATE_RECOMPILED . '</span>', '<strong>' . $tpl['file'] . '</strong>'); } } } unset($tpldata); } else { $msgs[] = sprintf(' <span style="color:#ff0000;">' . _MD_AM_TEMPLATE_DELETE_FAIL . '</span>', $tpl['file']); } } } $blocks = $module->getInfo('blocks'); $msgs[] = _MD_AM_MOD_REBUILD_BLOCKS; if ($blocks != false) { $count = count($blocks); $showfuncs = array(); $funcfiles = array(); for ($i = 1; $i <= $count; $i++) { if (isset($blocks[$i]['show_func']) && $blocks[$i]['show_func'] != '' && isset($blocks[$i]['file']) && $blocks[$i]['file'] != '') { $editfunc = isset($blocks[$i]['edit_func']) ? $blocks[$i]['edit_func'] : ''; $showfuncs[] = $blocks[$i]['show_func']; $funcfiles[] = $blocks[$i]['file']; $template = ''; if (isset($blocks[$i]['template']) && trim($blocks[$i]['template']) != '') { $content =& xoops_module_gettemplate($dirname, $blocks[$i]['template'], true); } if (!$content) { $content = ''; } else { $template = $blocks[$i]['template']; } $options = ''; if (!empty($blocks[$i]['options'])) { $options = $blocks[$i]['options']; } $sql = "SELECT bid, name FROM " . $db->prefix('newblocks') . " WHERE mid='" . (int) $module->getVar('mid') . "' AND func_num='" . (int) $i . "' AND show_func='" . addslashes($blocks[$i]['show_func']) . "' AND func_file='" . addslashes($blocks[$i]['file']) . "'"; $fresult = $db->query($sql); $fcount = 0; while ($fblock = $db->fetchArray($fresult)) { $fcount++; $sql = "UPDATE " . $db->prefix("newblocks") . " SET name='" . addslashes($blocks[$i]['name']) . "', edit_func='" . addslashes($editfunc) . "', content='', template='" . $template . "', last_modified=" . time() . " WHERE bid='" . (int) $fblock['bid'] . "'"; $result = $db->query($sql); if (!$result) { $msgs[] = sprintf(' ' . _MD_AM_UPDATE_FAIL, $fblock['name']); } else { $msgs[] = sprintf(' ' . _MD_AM_BLOCK_UPDATED, '<strong>' . $fblock['name'] . '</strong>', '<strong>' . icms_conv_nr2local($fblock['bid']) . '</strong>'); if ($template != '') { $tplfile =& $tplfile_handler->find('default', 'block', $fblock['bid']); if (count($tplfile) == 0) { $tplfile_new =& $tplfile_handler->create(); $tplfile_new->setVar('tpl_module', $dirname); $tplfile_new->setVar('tpl_refid', (int) $fblock['bid']); $tplfile_new->setVar('tpl_tplset', 'default'); $tplfile_new->setVar('tpl_file', $blocks[$i]['template'], true); $tplfile_new->setVar('tpl_type', 'block'); } else { $tplfile_new = $tplfile[0]; } $tplfile_new->setVar('tpl_source', $content, true); $tplfile_new->setVar('tpl_desc', $blocks[$i]['description'], true); $tplfile_new->setVar('tpl_lastmodified', time()); $tplfile_new->setVar('tpl_lastimported', 0); if (!$tplfile_handler->insert($tplfile_new)) { $msgs[] = sprintf(' <span style="color:#ff0000;">' . _MD_AM_TEMPLATE_UPDATE_FAIL . '</span>', '<strong>' . $blocks[$i]['template'] . '</strong>'); } else { $msgs[] = ' Template <b>' . $blocks[$i]['template'] . '</b> updated.'; if ($icmsConfig['template_set'] == 'default') { if (!icms_view_Tpl::template_touch($tplfile_new->getVar('tpl_id'))) { $msgs[] = sprintf(' <span style="color:#ff0000;">' . _MD_AM_TEMPLATE_RECOMPILE_FAIL . '</span>', '<strong>' . $blocks[$i]['template'] . '</strong>'); } else { $msgs[] = sprintf(' ' . _MD_AM_TEMPLATE_RECOMPILED, '<strong>' . $blocks[$i]['template'] . '</strong>'); } } } } } } if ($fcount == 0) { $newbid = $db->genId($db->prefix('newblocks') . '_bid_seq'); $block_name = addslashes($blocks[$i]['name']); $sql = "INSERT INTO " . $db->prefix("newblocks") . " (bid, mid, func_num, options, name, title, content, side, weight, visible, block_type, c_type, isactive, dirname, func_file, show_func, edit_func, template, bcachetime, last_modified) VALUES ('" . (int) $newbid . "', '" . (int) $module->getVar('mid') . "', '" . (int) $i . "','" . addslashes($options) . "','" . $block_name . "', '" . $block_name . "', '', '1', '0', '0', 'M', 'H', '1', '" . addslashes($dirname) . "', '" . addslashes($blocks[$i]['file']) . "', '" . addslashes($blocks[$i]['show_func']) . "', '" . addslashes($editfunc) . "', '" . $template . "', '0', '" . time() . "')"; $result = $db->query($sql); if (!$result) { $msgs[] = ' ERROR: Could not create ' . $blocks[$i]['name']; echo $sql; } else { if (empty($newbid)) { $newbid = $db->getInsertId(); } $groups =& icms::$user->getGroups(); $gperm_handler = icms::handler('icms_member_groupperm'); foreach ($groups as $mygroup) { $bperm =& $gperm_handler->create(); $bperm->setVar('gperm_groupid', (int) $mygroup); $bperm->setVar('gperm_itemid', (int) $newbid); $bperm->setVar('gperm_name', 'block_read'); $bperm->setVar('gperm_modid', 1); if (!$gperm_handler->insert($bperm)) { $msgs[] = ' <span style="color:#ff0000;">ERROR: Could not add block access right. Block ID: <b>' . $newbid . '</b> Group ID: <b>' . $mygroup . '</b></span>'; } else { $msgs[] = ' Added block access right. Block ID: <b>' . $newbid . '</b> Group ID: <b>' . $mygroup . '</b>'; } } if ($template != '') { $tplfile =& $tplfile_handler->create(); $tplfile->setVar('tpl_module', $dirname); $tplfile->setVar('tpl_refid', (int) $newbid); $tplfile->setVar('tpl_source', $content, true); $tplfile->setVar('tpl_tplset', 'default'); $tplfile->setVar('tpl_file', $blocks[$i]['template'], true); $tplfile->setVar('tpl_type', 'block'); $tplfile->setVar('tpl_lastimported', 0); $tplfile->setVar('tpl_lastmodified', time()); $tplfile->setVar('tpl_desc', $blocks[$i]['description'], true); if (!$tplfile_handler->insert($tplfile)) { $msgs[] = ' <span style="color:#ff0000;">ERROR: Could not insert template <b>' . $blocks[$i]['template'] . '</b> to the database.</span>'; } else { $newid = $tplfile->getVar('tpl_id'); $msgs[] = ' Template <b>' . $blocks[$i]['template'] . '</b> added to the database.'; if ($icmsConfig['template_set'] == 'default') { if (!icms_view_Tpl::template_touch($newid)) { $msgs[] = sprintf(' <span style="color:#ff0000;">' . _MD_AM_TEMPLATE_RECOMPILE_FAIL . '</span>', '<strong>' . $blocks[$i]['template'] . '</strong>'); } else { $msgs[] = sprintf(' ' . _MD_AM_TEMPLATE_RECOMPILED, '<strong>' . $blocks[$i]['template'] . '</strong>'); } } } } $msgs[] = ' Block <b>' . $blocks[$i]['name'] . '</b> created. Block ID: <b>' . $newbid . '</b>'; $sql = "INSERT INTO " . $db->prefix('block_module_link') . " (block_id, module_id, page_id) VALUES ('" . (int) $newbid . "', '0', '1')"; $db->query($sql); } } } } $icms_block_handler = icms::handler('icms_view_block'); $block_arr = $icms_block_handler->getByModule($module->getVar('mid')); foreach ($block_arr as $block) { if (!in_array($block->getVar('show_func'), $showfuncs) || !in_array($block->getVar('func_file'), $funcfiles)) { $sql = sprintf("DELETE FROM %s WHERE bid = '%u'", $db->prefix('newblocks'), (int) $block->getVar('bid')); if (!$db->query($sql)) { $msgs[] = ' <span style="color:#ff0000;">ERROR: Could not delete block <b>' . $block->getVar('name') . '</b>. Block ID: <b>' . $block->getVar('bid') . '</b></span>'; } else { $msgs[] = ' Block <b>' . $block->getVar('name') . ' deleted. Block ID: <b>' . $block->getVar('bid') . '</b>'; if ($block->getVar('template') != '') { $tplfiles =& $tplfile_handler->find(null, 'block', $block->getVar('bid')); if (is_array($tplfiles)) { $btcount = count($tplfiles); for ($k = 0; $k < $btcount; $k++) { if (!$tplfile_handler->delete($tplfiles[$k])) { $msgs[] = ' <span style="color:#ff0000;">ERROR: Could not remove deprecated block template. (ID: <b>' . $tplfiles[$k]->getVar('tpl_id') . '</b>)</span>'; } else { $msgs[] = ' Block template <b>' . $tplfiles[$k]->getVar('tpl_file') . '</b> deprecated.'; } } } } } } } } // first delete all config entries $config_handler = icms::handler('icms_config'); $configs =& $config_handler->getConfigs(new icms_db_criteria_Item('conf_modid', $module->getVar('mid'))); $confcount = count($configs); $config_delng = array(); if ($confcount > 0) { $msgs[] = 'Deleting module config options...'; for ($i = 0; $i < $confcount; $i++) { if (!$config_handler->deleteConfig($configs[$i])) { $msgs[] = ' <span style="color:#ff0000;">ERROR: Could not delete config data from the database. Config ID: <b>' . $configs[$i]->getvar('conf_id') . '</b></span>'; // save the name of config failed to delete for later use $config_delng[] = $configs[$i]->getvar('conf_name'); } else { $config_old[$configs[$i]->getvar('conf_name')]['value'] = $configs[$i]->getvar('conf_value', 'N'); $config_old[$configs[$i]->getvar('conf_name')]['formtype'] = $configs[$i]->getvar('conf_formtype'); $config_old[$configs[$i]->getvar('conf_name')]['valuetype'] = $configs[$i]->getvar('conf_valuetype'); $msgs[] = ' Config data deleted from the database. Config ID: <b>' . $configs[$i]->getVar('conf_id') . '</b>'; } } } // now reinsert them with the new settings $configs = $module->getInfo('config'); if ($configs != false) { if ($module->getVar('hascomments') != 0) { include_once ICMS_ROOT_PATH . '/include/comment_constants.php'; array_push($configs, array('name' => 'com_rule', 'title' => '_CM_COMRULES', 'description' => '', 'formtype' => 'select', 'valuetype' => 'int', 'default' => 1, 'options' => array('_CM_COMNOCOM' => XOOPS_COMMENT_APPROVENONE, '_CM_COMAPPROVEALL' => XOOPS_COMMENT_APPROVEALL, '_CM_COMAPPROVEUSER' => XOOPS_COMMENT_APPROVEUSER, '_CM_COMAPPROVEADMIN' => XOOPS_COMMENT_APPROVEADMIN))); array_push($configs, array('name' => 'com_anonpost', 'title' => '_CM_COMANONPOST', 'description' => '', 'formtype' => 'yesno', 'valuetype' => 'int', 'default' => 0)); } } else { if ($module->getVar('hascomments') != 0) { $configs = array(); include_once ICMS_ROOT_PATH . '/include/comment_constants.php'; $configs[] = array('name' => 'com_rule', 'title' => '_CM_COMRULES', 'description' => '', 'formtype' => 'select', 'valuetype' => 'int', 'default' => 1, 'options' => array('_CM_COMNOCOM' => XOOPS_COMMENT_APPROVENONE, '_CM_COMAPPROVEALL' => XOOPS_COMMENT_APPROVEALL, '_CM_COMAPPROVEUSER' => XOOPS_COMMENT_APPROVEUSER, '_CM_COMAPPROVEADMIN' => XOOPS_COMMENT_APPROVEADMIN)); $configs[] = array('name' => 'com_anonpost', 'title' => '_CM_COMANONPOST', 'description' => '', 'formtype' => 'yesno', 'valuetype' => 'int', 'default' => 0); } } // RMV-NOTIFY if ($module->getVar('hasnotification') != 0) { if (empty($configs)) { $configs = array(); } // Main notification options include_once ICMS_ROOT_PATH . '/include/notification_constants.php'; include_once ICMS_ROOT_PATH . '/include/notification_functions.php'; $options = array(); $options['_NOT_CONFIG_DISABLE'] = XOOPS_NOTIFICATION_DISABLE; $options['_NOT_CONFIG_ENABLEBLOCK'] = XOOPS_NOTIFICATION_ENABLEBLOCK; $options['_NOT_CONFIG_ENABLEINLINE'] = XOOPS_NOTIFICATION_ENABLEINLINE; $options['_NOT_CONFIG_ENABLEBOTH'] = XOOPS_NOTIFICATION_ENABLEBOTH; //$configs[] = array ('name' => 'notification_enabled', 'title' => '_NOT_CONFIG_ENABLED', 'description' => '_NOT_CONFIG_ENABLEDDSC', 'formtype' => 'yesno', 'valuetype' => 'int', 'default' => 1); $configs[] = array('name' => 'notification_enabled', 'title' => '_NOT_CONFIG_ENABLE', 'description' => '_NOT_CONFIG_ENABLEDSC', 'formtype' => 'select', 'valuetype' => 'int', 'default' => XOOPS_NOTIFICATION_ENABLEBOTH, 'options' => $options); // Event specific notification options // FIXME: for some reason the default doesn't come up properly // initially is ok, but not when 'update' module.. $options = array(); $categories =& icms_data_notification_Handler::categoryInfo('', $module->getVar('mid')); foreach ($categories as $category) { $events =& icms_data_notification_Handler::categoryEvents($category['name'], false, $module->getVar('mid')); foreach ($events as $event) { if (!empty($event['invisible'])) { continue; } $option_name = $category['title'] . ' : ' . $event['title']; $option_value = $category['name'] . '-' . $event['name']; $options[$option_name] = $option_value; //$configs[] = array ('name' => icms_data_notification_Handler::generateConfig($category,$event,'name'), 'title' => icms_data_notification_Handler::generateConfig($category,$event,'title_constant'), 'description' => icms_data_notification_Handler::generateConfig($category,$event,'description_constant'), 'formtype' => 'yesno', 'valuetype' => 'int', 'default' => 1); } } $configs[] = array('name' => 'notification_events', 'title' => '_NOT_CONFIG_EVENTS', 'description' => '_NOT_CONFIG_EVENTSDSC', 'formtype' => 'select_multi', 'valuetype' => 'array', 'default' => array_values($options), 'options' => $options); } if ($configs != false) { $msgs[] = 'Adding module config data...'; $config_handler = icms::handler('icms_config'); $order = 0; foreach ($configs as $config) { // only insert ones that have been deleted previously with success if (!in_array($config['name'], $config_delng)) { $confobj =& $config_handler->createConfig(); $confobj->setVar('conf_modid', (int) $newmid); $confobj->setVar('conf_catid', 0); $confobj->setVar('conf_name', $config['name']); $confobj->setVar('conf_title', $config['title'], true); $confobj->setVar('conf_desc', $config['description'], true); $confobj->setVar('conf_formtype', $config['formtype']); $confobj->setVar('conf_valuetype', $config['valuetype']); if (isset($config_old[$config['name']]['value']) && $config_old[$config['name']]['formtype'] == $config['formtype'] && $config_old[$config['name']]['valuetype'] == $config['valuetype']) { // preserver the old value if any // form type and value type must be the same $confobj->setVar('conf_value', $config_old[$config['name']]['value'], true); } else { $confobj->setConfValueForInput($config['default'], true); //$confobj->setVar('conf_value', $config['default'], true); } $confobj->setVar('conf_order', $order); $confop_msgs = ''; if (isset($config['options']) && is_array($config['options'])) { foreach ($config['options'] as $key => $value) { $confop =& $config_handler->createConfigOption(); $confop->setVar('confop_name', $key, true); $confop->setVar('confop_value', $value, true); $confobj->setConfOptions($confop); $confop_msgs .= '<br /> Config option added. Name: <b>' . $key . '</b> Value: <b>' . $value . '</b>'; unset($confop); } } $order++; if (false != $config_handler->insertConfig($confobj)) { $msgs[] = ' Config <b>' . $config['name'] . '</b> added to the database.' . $confop_msgs; } else { $msgs[] = ' <span style="color:#ff0000;">ERROR: Could not insert config <b>' . $config['name'] . '</b> to the database.</span>'; } unset($confobj); } } unset($configs); } // add module specific tasks to system autotasks list $atasks = $module->getInfo('autotasks'); $atasks_handler =& icms_getModuleHandler('autotasks', 'system'); if (count($atasks) > 0) { $msgs[] = 'Updating autotasks...'; $criteria = new icms_db_criteria_Compo(); $criteria->add(new icms_db_criteria_Item('sat_type', 'addon/' . $module->getInfo('dirname'))); $items_atasks = $atasks_handler->getObjects($criteria, false); foreach ($items_atasks as $task) { $taskID = (int) $task->getVar('sat_addon_id'); $atasks[$taskID]['enabled'] = $task->getVar('sat_enabled'); $atasks[$taskID]['repeat'] = $task->getVar('sat_repeat'); $atasks[$taskID]['interval'] = $task->getVar('sat_interval'); $atasks[$taskID]['name'] = $task->getVar('sat_name'); } $atasks_handler->deleteAll($criteria); foreach ($atasks as $taskID => $taskData) { if (!isset($taskData['code']) || trim($taskData['code']) == '') { continue; } $task =& $atasks_handler->create(); if (isset($taskData['enabled'])) { $task->setVar('sat_enabled', $taskData['enabled']); } if (isset($taskData['repeat'])) { $task->setVar('sat_repeat', $taskData['repeat']); } if (isset($taskData['interval'])) { $task->setVar('sat_interval', $taskData['interval']); } if (isset($taskData['onfinish'])) { $task->setVar('sat_onfinish', $taskData['onfinish']); } $task->setVar('sat_name', $taskData['name']); $task->setVar('sat_code', sprintf("require ICMS_ROOT_PATH . \"/modules/%s/%s\";", $module->getInfo('dirname'), addslashes($taskData['code']))); $task->setVar('sat_type', 'addon/' . $module->getInfo('dirname')); $task->setVar('sat_addon_id', (int) $taskID); if (!$atasks_handler->insert($task)) { $msgs[] = ' <span style="color:#ff0000;">ERROR: Could not insert autotask to db. Name: <b>' . $taskData['name'] . '</b></span>'; } else { $msgs[] = ' Updated task from autotasks list. Task Name: <b>' . $taskData['name'] . '</b>'; } } unset($atasks, $atasks_handler, $task, $taskData, $criteria, $items, $taskID); } // execute module specific update script if any $update_script = $module->getInfo('onUpdate'); $ModName = $module->getInfo('modname') != '' ? trim($module->getInfo('modname')) : $dirname; if (false != $update_script && trim($update_script) != '') { include_once ICMS_ROOT_PATH . '/modules/' . $dirname . '/' . trim($update_script); $is_IPF = $module->getInfo('object_items'); if (!empty($is_IPF)) { $icmsDatabaseUpdater = icms_db_legacy_Factory::getDatabaseUpdater(); $icmsDatabaseUpdater->moduleUpgrade($module, true); foreach ($icmsDatabaseUpdater->_messages as $msg) { $msgs[] = $msg; } } if (function_exists('xoops_module_update_' . $ModName)) { $func = 'xoops_module_update_' . $ModName; if (!$func($module, $prev_version, $prev_dbversion)) { $msgs[] = sprintf(_MD_AM_FAIL_EXEC, '<strong>' . $func . '</strong>'); } else { $msgs[] = sprintf(_MD_AM_FUNCT_EXEC, '<strong>' . $func . '</strong>'); } } elseif (function_exists('icms_module_update_' . $ModName)) { $func = 'icms_module_update_' . $ModName; if (!$func($module, $prev_version, $prev_dbversion)) { $msgs[] = sprintf(_MD_AM_FAIL_EXEC, '<strong>' . $func . '</strong>'); } else { $msgs[] = sprintf(_MD_AM_FUNCT_EXEC, '<strong>' . $func . '</strong>'); } } } $msgs[] = '</code><p>' . sprintf(_MD_AM_OKUPD, '<b>' . $module->getVar('name') . '</b>') . '</p>'; } $ret = '<code>'; foreach ($msgs as $msg) { $ret .= $msg . '<br />'; } return $ret; }
if (!$status) { $notification_handler->unsubscribe($category, $item_id, $event, $module_id, $user_id); } else { $notification_handler->subscribe($category, $item_id, $event); } } // @TODO: something like grey box summary of actions (like multiple comment // deletion), with a button to return back... NOTE: we need some arguments // to help us get back to where we were... // @TODO: finish integration with comments... i.e. need calls to // notifyUsers at appropriate places... (need to figure out where // comment submit occurs and where comment approval occurs)... $redirect_args = array(); foreach ($update_list as $update_item) { list($category, $item_id, $event) = explode(',', $update_item['params']); $category_info =& icms_data_notification_Handler::categoryInfo($category); if (!empty($category_info['item_name'])) { $redirect_args[$category_info['item_name']] = $item_id; } } // @TODO: write a central function to put together args with '?' and '&' // symbols... $argstring = ''; $first_arg = 1; foreach (array_keys($redirect_args) as $arg) { if ($first_arg) { $argstring .= "?" . $arg . "=" . $redirect_args[$arg]; $first_arg = 0; } else { $argstring .= "&" . $arg . "=" . $redirect_args[$arg]; }