function executeViewSuccess(&$controller, &$xoopsUser, &$render) { require_once XOOPS_ROOT_PATH . "/class/template.php"; $xoopsTpl = new XoopsTpl(); $xoopsTpl->clear_cache('db:' . $this->mObject->get('tpl_file')); $xoopsTpl->clear_compiled_tpl('db:' . $this->mObject->get('tpl_file')); $tplset = $this->mObject->get('tpl_tplset'); $module = $this->mObject->get('tpl_module'); $controller->executeForward("./index.php?action=TplfileList&tpl_tplset={$tplset}&tpl_module={$module}"); }
function cacheClear(&$module) { $handler =& xoops_getmodulehandler('tplfile', 'legacyRender'); $criteria = new Criteria('tpl_module', $module->get('dirname')); $tplfileArr = $handler->getObjects($criteria); $xoopsTpl = new XoopsTpl(); foreach (array_keys($tplfileArr) as $key) { $xoopsTpl->clear_cache('db:' . $tplfileArr[$key]->get('tpl_file')); $xoopsTpl->clear_compiled_tpl('db:' . $tplfileArr[$key]->get('tpl_file')); } }
function update_block($bid, $bside, $bweight, $bvisible, $btitle, $bcontent, $bctype, $bcachetime, $bmodule, $options = array(), $bgroups = array()) { global $xoopsConfig; if (empty($bmodule)) { xoops_cp_header(); xoops_error(sprintf(_AM_NOTSELNG, _AM_VISIBLEIN)); xoops_cp_footer(); exit; } $myblock = new XoopsBlock($bid); $myblock->setVar('side', $bside); $myblock->setVar('weight', $bweight); $myblock->setVar('visible', $bvisible); $myblock->setVar('title', $btitle); $myblock->setVar('content', $bcontent); $myblock->setVar('bcachetime', $bcachetime); if (isset($options)) { $options_count = count($options); if ($options_count > 0) { //Convert array values to comma-separated for ($i = 0; $i < $options_count; $i++) { if (is_array($options[$i])) { $options[$i] = implode(',', $options[$i]); } } $options = implode('|', $options); $myblock->setVar('options', $options); } } if ($myblock->isCustom()) { switch ($bctype) { case 'H': $name = _AM_CUSTOMHTML; break; case 'P': $name = _AM_CUSTOMPHP; break; case 'S': $name = _AM_CUSTOMSMILE; break; default: $name = _AM_CUSTOMNOSMILE; break; } $myblock->setVar('name', $name); $myblock->setVar('c_type', $bctype); } else { $myblock->setVar('c_type', 'H'); } $msg = _AM_DBUPDATED; if ($myblock->store() != false) { $db =& Database::getInstance(); $sql = sprintf("DELETE FROM %s WHERE block_id = %u", $db->prefix('block_module_link'), $bid); $db->query($sql); foreach ($bmodule as $bmid) { $sql = sprintf("INSERT INTO %s (block_id, module_id) VALUES (%u, %d)", $db->prefix('block_module_link'), $bid, intval($bmid)); $db->query($sql); } include_once XOOPS_ROOT_PATH . '/class/template.php'; $xoopsTpl = new XoopsTpl(); $xoopsTpl->xoops_setCaching(2); if ($myblock->getVar('template') != '') { if ($xoopsTpl->is_cached('db:' . $myblock->getVar('template'), 'blk_' . $myblock->getVar('bid'))) { if (!$xoopsTpl->clear_cache('db:' . $myblock->getVar('template'), 'blk_' . $myblock->getVar('bid'))) { $msg = 'Unable to clear cache for block ID ' . $bid; } } } else { if ($xoopsTpl->is_cached('db:system_dummy.html', 'blk_' . $bid)) { if (!$xoopsTpl->clear_cache('db:system_dummy.html', 'blk_' . $bid)) { $msg = 'Unable to clear cache for block ID ' . $bid; } } } $groupperm_handler =& xoops_gethandler('groupperm'); $groups_with_access =& $groupperm_handler->getGroupIds("block_read", $bid); $removed_groups = array_diff($groups_with_access, $bgroups); if (count($removed_groups) > 0) { foreach ($removed_groups as $groupid) { $criteria = new CriteriaCompo(new Criteria('gperm_name', 'block_read')); $criteria->add(new Criteria('gperm_groupid', $groupid)); $criteria->add(new Criteria('gperm_itemid', $bid)); $criteria->add(new Criteria('gperm_modid', 1)); $perm = $groupperm_handler->getObjects($criteria); if (isset($perm[0]) && is_object($perm[0])) { $groupperm_handler->delete($perm[0]); } } } $new_groups = array_diff($bgroups, $groups_with_access); if (count($new_groups) > 0) { foreach ($new_groups as $groupid) { $groupperm_handler->addRight("block_read", $bid, $groupid); } } } else { $msg = 'Failed update of block. ID:' . $bid; } redirect_header('admin.php?fct=blocksadmin&t=' . time(), 1, $msg); exit; }
/** * Clear the module cache * * @deprecated * * @param int $mid Module ID * @return **/ function xoops_template_clear_module_cache($mid) { $block_arr =& XoopsBlock::getByModule($mid); $count = count($block_arr); if ($count > 0) { $xoopsTpl = new XoopsTpl(); $xoopsTpl->xoops_setCaching(2); for ($i = 0; $i < $count; $i++) { if ($block_arr[$i]->getVar('template') != '') { $xoopsTpl->clear_cache('db:' . $block_arr[$i]->getVar('template'), 'blk_' . $block_arr[$i]->getVar('bid')); } } } }
/** * uninstallAllOfModuleTemplates * * @param XoopsModule &$module * @param Legacy_ModuleInstallLog &$log * @param bool $defaultOnly * * @return void **/ public static function uninstallAllOfModuleTemplates(&$module, &$log, $defaultOnly = true) { $tplHandler =& Leimg_Utils::getXoopsHandler('tplfile'); $delTemplates =& $tplHandler->find($defaultOnly ? 'default' : null, 'module', $module->get('mid')); if (is_array($delTemplates) && count($delTemplates) > 0) { $xoopsTpl = new XoopsTpl(); $xoopsTpl->clear_cache(null, 'mod_' . $module->get('dirname')); foreach ($delTemplates as $tpl) { if (!$tplHandler->delete($tpl)) { $log->addError(XCube_Utils::formatString(_MI_LEIMG_INSTALL_ERROR_TPL_UNINSTALLED, $tpl->get('tpl_file'))); } } } }
/** * Uninstalls all of module templates $module specify. This function is * usefull for uninstaller and updater. In the case of update, you should * call this function before installAllOfModuleTemplates(). In the case of * uninstall, you must set 'false' to $defaultOnly. * * This function gets informations about templates from the database. * * @warning * * This function depends the specific spec of Legacy_RenderSystem, but this * static function is needed by the 2nd installer of Legacy System. * * @static * @param XoopsModule $module * @param Legacy_ModuleInstallLog $log * @param bool $defaultOnly Indicates whether this function deletes templates from all of tplsets. * @note FOR THE CUSTOM-INSTALLER * @see Legacy_ModuleInstallUtils::installAllOfModuleTemplates() */ function _uninstallAllOfModuleTemplates(&$module, $tplset, &$log) { // // The following processing depends on the structure of Legacy_RenderSystem. // $tplHandler =& xoops_gethandler('tplfile'); $delTemplates = null; $delTemplates =& $tplHandler->find($tplset, 'module', $module->get('mid')); if (is_array($delTemplates) && count($delTemplates) > 0) { // // clear cache // $xoopsTpl = new XoopsTpl(); $xoopsTpl->clear_cache(null, "mod_" . $module->get('dirname')); foreach ($delTemplates as $tpl) { if (!$tplHandler->delete($tpl)) { $log->addError(XCube_Utils::formatMessage(_AD_LEGACY_ERROR_TEMPLATE_UNINSTALLED, $tpl->get('tpl_file'))); } } } }
/** * Inserts templates into the database * * @return void */ function insertTemplates() { $tplfile_handler =& xoops_gethandler('tplfile'); // Delete existing templates from this module in the default template set $deltpl =& $tplfile_handler->find('default', 'module', $this->getVar('mid')); $delng = array(); $existing_templates = array(); if (is_array($deltpl)) { global $xoopsTpl; if (!isset($xoopsTpl) || !is_object($xoopsTpl)) { include_once XOOPS_ROOT_PATH . "/class/template.php"; $xoopsTpl = new XoopsTpl(); } // clear cache files $xoopsTpl->clear_cache(null, 'mod_' . $this->getVar('dirname')); // delete template file entry in db $dcount = count($deltpl); for ($i = 0; $i < $dcount; $i++) { $existing_templates[] = $deltpl[$i]; if (!$tplfile_handler->delete($deltpl[$i])) { $delng[] = $deltpl[$i]->getVar('tpl_file'); } } } // Insert new templates $templates = $this->getInfo('templates'); if ($templates != false) { global $xoopsConfig; $this->setMessage('Updating templates...'); foreach ($templates as $tpl) { $tpl['file'] = trim($tpl['file']); if (!in_array($tpl['file'], $delng)) { $new_templates[] = $tpl['file']; $tpldata =& $this->gettemplate($tpl['file']); $tplfile =& $tplfile_handler->create(); $tplfile->setVar('tpl_refid', $this->getVar('mid')); $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', $this->getVar('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)) { $this->setMessage(' <span style="color:#ff0000;">ERROR: Could not insert template <b>' . $tpl['file'] . '</b> to the database.</span>'); } else { $newid = $tplfile->getVar('tpl_id'); $this->setMessage(' Template <b>' . $tpl['file'] . '</b> inserted to the database.'); if (isset($xoopsConfig) && isset($xoopsConfig['template_set']) && $xoopsConfig['template_set'] == 'default') { if (!xoops_template_touch($tplfile)) { $this->setMessage(' <span style="color:#ff0000;">ERROR: Could not recompile template <b>' . $tpl['file'] . '</b>.</span>'); } else { $this->setMessage(' Template <b>' . $tpl['file'] . '</b> recompiled.</span>'); } } } unset($tpldata); } else { $this->setMessage(' <span style="color:#ff0000;">ERROR: Could not delete old template <b>' . $tpl['file'] . '</b>. Aborting update of this file.</span>'); } } //delete templates that are removed from the module foreach (array_keys($existing_templates) as $i) { if (!in_array($existing_templates[$i]->getVar('tpl_file'), $new_templates)) { if ($tplfile_handler->delete($existing_templates[$i])) { $this->setMessage(' Template <b>' . $existing_templates[$i]->getVar('tpl_file') . '</b> no longer used and removed'); } else { $this->setMessage(' <span style="color:#ff0000;">ERROR: Could not delete removed template <b>' . $existing_templates[$i]->getVar('tpl_file') . '</b></span>'); } } } } }
/** * Remove module's cache * * @package News * @author Hervé Thouzard (www.herve-thouzard.com) * @copyright (c) The Xoops Project - www.xoops.org */ function updateCache() { global $xoopsModule; $tpllist = array('news_item.html', 'news_archive.html', 'news_article.html', 'news_index.html', 'news_by_topic.html', 'news_by_this_author.html', 'news_ratenews.html', 'news_rss.html'); include_once XOOPS_ROOT_PATH . "/class/xoopsblock.php"; include_once XOOPS_ROOT_PATH . '/class/template.php'; // Clear blocks cache xoops_template_clear_module_cache($xoopsModule->getVar('mid')); // Clear pages cache $xoopsTpl = new XoopsTpl(); foreach ($tpllist as $onetemplate) { $xoopsTpl->clear_cache('db:' . $onetemplate); } }
function xoops_module_update_mpmanager(&$module) { global $xoopsConfig, $xoopsDB, $xoopsUser, $xoopsModule; if (file_exists(XOOPS_ROOT_PATH . "/modules/mpmanager/language/" . $xoopsConfig['language'] . "/admin.php")) { include XOOPS_ROOT_PATH . "/modules/mpmanager/language/" . $xoopsConfig['language'] . "/admin.php"; } else { include XOOPS_ROOT_PATH . "/modules/mpmanager/language/english/admin.php"; } $xoopsDB->queryF("UPDATE " . $xoopsDB->prefix('modules') . " SET weight = 0 WHERE mid = " . $module->getVar('mid') . ""); if (is_object($xoopsUser) && $xoopsUser->isAdmin($xoopsModule->mid())) { if (!TableExists($xoopsDB->prefix('priv_msgs'))) { $xoopsDB->queryFromFile(XOOPS_ROOT_PATH . "/modules/mpmanager/sql/mysqlmsg.sql"); } //mise ajour table message if (!FieldExists('msg_pid', $xoopsDB->prefix('priv_msgs'))) { $result = $xoopsDB->queryF("ALTER TABLE `" . $xoopsDB->prefix('priv_msgs') . "` ADD msg_pid MEDIUMINT( 8 ) UNSIGNED DEFAULT '0' NOT NULL AFTER msg_id"); } if (!FieldExists('reply_msg', $xoopsDB->prefix('priv_msgs'))) { $sq1 = $xoopsDB->queryF("ALTER TABLE `" . $xoopsDB->prefix('priv_msgs') . "` ADD reply_msg TINYINT(1) UNSIGNED DEFAULT '0' NOT NULL AFTER read_msg"); } if (!FieldExists('anim_msg', $xoopsDB->prefix('priv_msgs'))) { $sq1 = $xoopsDB->queryF("ALTER TABLE `" . $xoopsDB->prefix('priv_msgs') . "` ADD anim_msg VARCHAR(100) AFTER reply_msg"); } if (!FieldExists('cat_msg', $xoopsDB->prefix('priv_msgs'))) { $sq1 = $xoopsDB->queryF("ALTER TABLE `" . $xoopsDB->prefix('priv_msgs') . "` ADD cat_msg MEDIUMINT( 8 ) UNSIGNED DEFAULT '1' NOT NULL AFTER anim_msg"); } if (!FieldExists('file_msg', $xoopsDB->prefix('priv_msgs'))) { $sq1 = $xoopsDB->queryF("ALTER TABLE `" . $xoopsDB->prefix('priv_msgs') . "` ADD file_msg MEDIUMINT( 8 ) UNSIGNED DEFAULT '0' NOT NULL AFTER cat_msg"); } //mise a jour message if (TableExists($xoopsDB->prefix('priv_msgsave'))) { $sq2 = "SELECT * FROM " . $xoopsDB->prefix('priv_msgsave') . ""; $result2 = $xoopsDB->query($sq2); while ($row = $xoopsDB->fetchArray($result2)) { $sql = "INSERT INTO `" . $xoopsDB->prefix("priv_msgs") . "` (msg_id, msg_image,subject,from_userid,to_userid,msg_time,msg_text,read_msg,reply_msg,anim_msg,cat_msg,file_msg) VALUES('','" . $row['msg_image'] . "','" . $row['subject'] . "','" . $row['sauv_userid'] . "','" . $row['to_userid'] . "','" . $row['msg_time'] . "','" . $row['msg_text'] . "','" . $row['read_msg'] . "','" . $row['reply_msg'] . "','" . $row['anim_msg'] . "', '3','') "; $result = $xoopsDB->queryF($sql); } $result = $xoopsDB->queryF("DROP TABLE `" . $xoopsDB->prefix("priv_msgsave") . "`"); } //add table priv_msgscat if (!TableExists($xoopsDB->prefix('priv_msgscat'))) { $xoopsDB->queryFromFile(XOOPS_ROOT_PATH . "/modules/mpmanager/sql/mysqlcat.sql"); } $sq1 = $xoopsDB->queryF("INSERT INTO `" . $xoopsDB->prefix('priv_msgscat') . "` (`cid`, `pid`, `title`, `uid`, `ver`) VALUES (1, 0, '" . _MP_BOX1 . "', NULL, 1)"); $sq1 = $xoopsDB->queryF("INSERT INTO `" . $xoopsDB->prefix('priv_msgscat') . "` (`cid`, `pid`, `title`, `uid`, `ver`) VALUES (2, 0, '" . _MP_BOX2 . "', NULL, 1)"); $sq1 = $xoopsDB->queryF("INSERT INTO `" . $xoopsDB->prefix('priv_msgscat') . "` (`cid`, `pid`, `title`, `uid`, `ver`) VALUES (3, 0, '" . _MP_BOX3 . "', NULL, 1)"); //add and update priv_msgscont if (!TableExists($xoopsDB->prefix('priv_msgscont'))) { $xoopsDB->queryFromFile(XOOPS_ROOT_PATH . "/modules/mpmanager/sql/mysqlcont.sql"); } else { if (!FieldExists('ct_name', $xoopsDB->prefix('priv_msgscont'))) { $sql = "ALTER TABLE `" . $xoopsDB->prefix("priv_msgscont") . "` ADD `ct_name` varchar(60) NOT NULL default '' AFTER `ct_contact`"; $result = $xoopsDB->queryF($sql); } if (!FieldExists('ct_uname', $xoopsDB->prefix('priv_msgscont'))) { $sql = "ALTER TABLE `" . $xoopsDB->prefix("priv_msgscont") . "` ADD `ct_uname` varchar(25) NOT NULL default '' AFTER `ct_name`"; $result = $xoopsDB->queryF($sql); } if (!FieldExists('ct_regdate', $xoopsDB->prefix('priv_msgscont'))) { $sql = "ALTER TABLE `" . $xoopsDB->prefix("priv_msgscont") . "` ADD `ct_regdate` int(10) NOT NULL default '0' AFTER `ct_uname`"; $result = $xoopsDB->queryF($sql); } $sq3 = "SELECT * FROM " . $xoopsDB->prefix('priv_msgscont') . ""; $result3 = $xoopsDB->query($sq3); while ($row = $xoopsDB->fetchArray($result3)) { $poster = new XoopsUser($row['ct_contact']); $sql = "UPDATE `" . $xoopsDB->prefix('priv_msgscont') . "` SET ct_name='" . $poster->getVar('name') . "', ct_uname='" . $poster->getVar('uname') . "', ct_regdate='" . $poster->getVar('user_regdate') . "' WHERE ct_contact='" . $row['ct_contact'] . "'"; $result = $xoopsDB->queryF($sql); } } ////add and update tables priv_msgsopt if (!TableExists($xoopsDB->prefix('priv_msgsopt'))) { $xoopsDB->queryFromFile(XOOPS_ROOT_PATH . "/modules/mpmanager/sql/mysqlopt.sql"); } else { if (!FieldExists('resend', $xoopsDB->prefix('priv_msgsopt'))) { $sql = "ALTER TABLE `" . $xoopsDB->prefix("priv_msgsopt") . "` ADD `resend` tinyint(1) NOT NULL default '0'"; $result = $xoopsDB->queryF($sql); } if (!FieldExists('limite', $xoopsDB->prefix('priv_msgsopt'))) { $sq1 = "ALTER TABLE `" . $xoopsDB->prefix("priv_msgsopt") . "` ADD `limite` tinyint(2) default NULL"; $result = $xoopsDB->queryF($sql); } if (!FieldExists('home', $xoopsDB->prefix('priv_msgsopt'))) { $sql = "ALTER TABLE " . $xoopsDB->prefix("priv_msgsopt") . " ADD `home` tinyint(2) DEFAULT '1' NOT NULL AFTER `limite`"; $result = $xoopsDB->queryF($sql); } if (!FieldExists('sortname', $xoopsDB->prefix('priv_msgsopt'))) { $sql = "ALTER TABLE " . $xoopsDB->prefix("priv_msgsopt") . " ADD `sortname` varchar(15) AFTER `home`"; $result = $xoopsDB->queryF($sql); } if (!FieldExists('sortorder', $xoopsDB->prefix('priv_msgsopt'))) { $sql = "ALTER TABLE " . $xoopsDB->prefix("priv_msgsopt") . " ADD `sortorder` varchar(15) AFTER `sortname`"; $result = $xoopsDB->queryF($sql); } if (!FieldExists('vieworder', $xoopsDB->prefix('priv_msgsopt'))) { $sql = "ALTER TABLE " . $xoopsDB->prefix("priv_msgsopt") . " ADD `vieworder` varchar(15) AFTER `sortorder`"; $result = $xoopsDB->queryF($sql); } if (!FieldExists('formtype', $xoopsDB->prefix('priv_msgsopt'))) { $sql = "ALTER TABLE " . $xoopsDB->prefix("priv_msgsopt") . " ADD `formtype` tinyint(1) AFTER `vieworder`"; $result = $xoopsDB->queryF($sql); } } //add and update tables priv_msgsup if (!TableExists($xoopsDB->prefix('priv_msgsup'))) { $xoopsDB->queryFromFile(XOOPS_ROOT_PATH . "/modules/mpmanager/sql/mysqlup.sql"); //update priv_msgsup $sq5 = "SELECT * FROM " . $xoopsDB->prefix('priv_msgs') . "WHERE file_msg !='' "; $result5 = $xoopsDB->query($sq5); while ($row = $xoopsDB->fetchArray($result5)) { $result = $xoopsDB->queryF("INSERT INTO `" . $xoopsDB->prefix("priv_msgsup") . "` (`msg_id`, `u_id`, `u_name`, `u_mimetype`, `u_file`, `u_file`, `u_weight`) VALUES ('', " . $row['msg_id'] . ", " . $row['file_msg'] . ", '', " . $row['file_msg'] . ", '')"); $sql = "UPDATE " . $xoopsDB->prefix('priv_msgs') . " SET file_msg=1 WHERE msg_id='" . $row['msg_id'] . "'"; } //update file_msg $sql = "ALTER TABLE " . $xoopsDB->prefix("priv_msgs") . " CHANGE `file_msg` `file_msg` MEDIUMINT(8) NOT NULL DEFAULT '0'"; $result = $xoopsDB->queryF($sql); } } xoops_template_clear_module_cache($xoopsModule->getVar('mid')); $tpllist = array('mp_box.html', 'mp_contbox.html', 'mp_filebox.html', 'mp_index.html', 'mp_msgbox.html', 'mp_optionbox.html', 'mp_subox.html', 'mp_viewbox.html', 'mp_block_cont.html', 'mp_block_new.html'); $xoopsTpl = new XoopsTpl(); foreach ($tpllist as $onetemplate) { $xoopsTpl->clear_cache('db:' . $onetemplate); } return true; }
require_once XOOPS_ROOT_PATH . '/class/template.php'; $tpl = new XoopsTpl(); $tpl->force_compile = true; foreach ($_POST["{$tplset_from}_check"] as $tplfile_tmp => $val) { if (empty($val)) { continue; } $tplfile = $myts->stripSlashesGPC($tplfile_tmp); $result = $db->query("SELECT tpl_id FROM " . $db->prefix("tplfile") . " WHERE tpl_tplset='" . addslashes($tplset_from) . "' AND tpl_file='" . addslashes($tplfile) . "'"); while (list($tpl_id) = $db->fetchRow($result)) { $tpl_id = intval($tpl_id); $db->query("DELETE FROM " . $db->prefix("tplfile") . " WHERE tpl_id={$tpl_id}"); $db->query("DELETE FROM " . $db->prefix("tplsource") . " WHERE tpl_id={$tpl_id}"); } // remove templates_c $tpl->clear_cache('db:' . $tplfile); $tpl->clear_compiled_tpl('db:' . $tplfile); } redirect_header('?mode=admin&lib=altsys&page=mytplsadmin&dirname=' . $target_dirname, 1, _MYTPLSADMIN_DBUPDATED); exit; } } } //************// // GET stage // //************// // get tplsets $tplset_handler =& xoops_gethandler('tplset'); $tplsets = array_keys($tplset_handler->getList()); $sql = "SELECT distinct tpl_tplset FROM " . $db->prefix("tplfile") . " ORDER BY tpl_tplset='default' DESC,tpl_tplset"; $srs = $db->query($sql);
$module->setVar('name', $temp_name); xoops_cp_header(); 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[] = 'Module data updated.'; $tplfile_handler =& xoops_gethandler('tplfile'); $deltpl =& $tplfile_handler->find('default', 'module', $module->getVar('mid')); $delng = array(); if (is_array($deltpl)) { $xoopsTpl = new XoopsTpl(); // clear cache files $xoopsTpl->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[] = 'Updating templates...'; foreach ($templates as $tpl) { $tpl['file'] = trim($tpl['file']); if (!in_array($tpl['file'], $delng)) { $tpldata =& xoops_module_gettemplate($dirname, $tpl['file']);
function update_block($bid, $bside, $bweight, $bvisible, $btitle, $bcontent, $bctype, $bcachetime, $options = array()) { global $xoopsConfig; $block = new XoopsBlock($bid); if ($bside >= 0) { $block->setVar('side', $bside); } $block->setVar('weight', $bweight); $block->setVar('visible', $bvisible); $block->setVar('title', $btitle); if (isset($bcontent)) { $block->setVar('content', $bcontent); } if (isset($bctype)) { $block->setVar('c_type', $bctype); } $block->setVar('bcachetime', $bcachetime); if (is_array($options) && count($options) > 0) { $block->setVar('options', implode('|', $options)); } if ($block->getVar('block_type') == 'C') { $name = $this->get_blockname_from_ctype($block->getVar('c_type')); $block->setVar('name', $name); } $msg = _MD_A_MYBLOCKSADMIN_DBUPDATED; if ($block->store() != false) { include_once XOOPS_ROOT_PATH . '/class/template.php'; $xoopsTpl = new XoopsTpl(); $xoopsTpl->xoops_setCaching(2); if ($block->getVar('template') != '') { if ($xoopsTpl->is_cached('db:' . $block->getVar('template'))) { if (!$xoopsTpl->clear_cache('db:' . $block->getVar('template'))) { $msg = 'Unable to clear cache for block ID' . $bid; } } } else { if ($xoopsTpl->is_cached('db:system_dummy.html', 'blk_' . $bid)) { if (!$xoopsTpl->clear_cache('db:system_dummy.html', 'blk_' . $bid)) { $msg = 'Unable to clear cache for block ID' . $bid; } } } } else { $msg = 'Failed update of block. ID:' . $bid; } return $msg; }
case 'copy': rename(XOOPS_ROOT_PATH . '/' . $file, XOOPS_ROOT_PATH . '/' . $file . '.svg'); copy(XOOPS_ROOT_PATH . '/modules/mpmanager/Root/' . $file, XOOPS_ROOT_PATH . '/' . $file); break; case 'restore': unlink(XOOPS_ROOT_PATH . '/' . $file); rename(XOOPS_ROOT_PATH . '/' . $file . '.svg', XOOPS_ROOT_PATH . '/' . $file); break; case 'install_template': if (file_exists(XOOPS_ROOT_PATH . '/themes/' . $config_theme->getConfValueForOutput() . '/modules/' . $file)) { unlink(XOOPS_ROOT_PATH . '/themes/' . $config_theme->getConfValueForOutput() . '/modules/' . $file); } FS_Storage::dircopy(XOOPS_ROOT_PATH . '/modules/mpmanager/Root/themes/', XOOPS_ROOT_PATH . '/themes/' . $config_theme->getConfValueForOutput() . '/', $success, $error); include_once XOOPS_ROOT_PATH . '/class/template.php'; $xoopsTpl = new XoopsTpl(); $xoopsTpl->clear_cache('db:system_block_user.html'); $xoopsTpl->clear_cache('db:system_userinfo.html'); $xoopsTpl->clear_cache('db:profile_userinfo.html'); break; case 'remove_template': unlink(XOOPS_ROOT_PATH . '/themes/' . $config_theme->getConfValueForOutput() . '/modules/' . $file); break; } /* Display admin header */ xoops_cp_header(); /* Display the menu */ mp_adminmenu(0, _MP_INSTALL); /* Display some informations */ getServerStats(); getFilesStatus(); /* Display admin footer */
} $msg = _AM_DBUPDATED; if ($myblock->store() != false) { $db =& Database::getInstance(); $sql = sprintf("DELETE FROM %s WHERE block_id = %u", $db->prefix('block_module_link'), $bid); $db->query($sql); foreach ($_POST['bmodule'] as $bmid) { $sql = sprintf("INSERT INTO %s (block_id, module_id) VALUES (%u, %d)", $db->prefix('block_module_link'), $bid, intval($bmid)); $db->query($sql); } include_once XOOPS_ROOT_PATH . '/class/template.php'; $xoopsTpl = new XoopsTpl(); $xoopsTpl->xoops_setCaching(2); if ($myblock->getVar('template') != '') { if ($xoopsTpl->is_cached('db:' . $myblock->getVar('template'), 'blk_' . $myblock->getVar('bid'))) { if (!$xoopsTpl->clear_cache('db:' . $myblock->getVar('template'), 'blk_' . $myblock->getVar('bid'))) { $msg = 'Unable to clear cache for block ID ' . $bid; } } } else { if ($xoopsTpl->is_cached('db:system_dummy.html', 'blk_' . $bid)) { if (!$xoopsTpl->clear_cache('db:system_dummy.html', 'blk_' . $bid)) { $msg = 'Unable to clear cache for block ID ' . $bid; } } } } else { $msg = 'Failed update of block. ID:' . $bid; } redirect_header('admin.php?fct=blocksadmin&t=' . time(), 1, $msg); exit;
function myblocksadmin_update_block($bid, $bside, $bweight, $bvisible, $btitle, $bcontent, $bctype, $bcachetime, $bmodule, $options = array()) { global $xoopsConfig; if (empty($bmodule)) { xoops_cp_header(); xoops_error(sprintf(_AM_NOTSELNG, _AM_VISIBLEIN)); xoops_cp_footer(); exit; } $myblock = new XoopsBlock($bid); // $myblock->setVar('side', $bside); GIJ - if ($bside >= 0) { $myblock->setVar('side', $bside); } // GIJ + $myblock->setVar('weight', $bweight); $myblock->setVar('visible', $bvisible); $myblock->setVar('title', $btitle); $myblock->setVar('content', $bcontent); $myblock->setVar('bcachetime', $bcachetime); if (isset($options) && count($options) > 0) { $options = implode('|', $options); $myblock->setVar('options', $options); } if ($myblock->getVar('block_type') == 'C') { switch ($bctype) { case 'H': $name = _AM_CUSTOMHTML; break; case 'P': $name = _AM_CUSTOMPHP; break; case 'S': $name = _AM_CUSTOMSMILE; break; default: $name = _AM_CUSTOMNOSMILE; break; } $myblock->setVar('name', $name); $myblock->setVar('c_type', $bctype); } else { $myblock->setVar('c_type', 'H'); } $msg = _AM_DBUPDATED; if ($myblock->store() != false) { $db =& Database::getInstance(); $sql = sprintf("DELETE FROM %s WHERE block_id = %u", $db->prefix('block_module_link'), $bid); $db->query($sql); foreach ($bmodule as $bmid) { $sql = sprintf("INSERT INTO %s (block_id, module_id) VALUES (%u, %d)", $db->prefix('block_module_link'), $bid, intval($bmid)); $db->query($sql); } include_once XOOPS_ROOT_PATH . '/class/template.php'; $xoopsTpl = new XoopsTpl(); $xoopsTpl->xoops_setCaching(2); if ($myblock->getVar('template') != '') { if ($xoopsTpl->is_cached('db:' . $myblock->getVar('template'))) { if (!$xoopsTpl->clear_cache('db:' . $myblock->getVar('template'))) { $msg = 'Unable to clear cache for block ID' . $bid; } } } else { if ($xoopsTpl->is_cached('db:system_dummy.html', 'block' . $bid)) { if (!$xoopsTpl->clear_cache('db:system_dummy.html', 'block' . $bid)) { $msg = 'Unable to clear cache for block ID' . $bid; } } } } else { $msg = 'Failed update of block. ID:' . $bid; } // redirect_header('admin.php?fct=blocksadmin&t='.time(),1,$msg); // exit(); GIJ - return $msg; // GIJ + }
/** * Clear the module cache * * @param int $mid Module ID * @return **/ function xoops_template_clear_module_cache($mid) { $block_handler =& xoops_gethandler('block'); //note this uses backwards parameters for backwards compatibility - change that! $block_arr =& $block_handler->getByModule($mid, true, false); if (count($block_arr) > 0) { $instance_handler =& xoops_gethandler('blockinstance'); $instances =& $instance_handler->getObjects(new Criteria('bid', "(" . implode(',', array_keys($block_arr)) . ")", "IN")); $count = count($instances); if ($count > 0) { $xoopsTpl = new XoopsTpl(); $xoopsTpl->xoops_setCaching(2); for ($i = 0; $i < $count; $i++) { if ($block_arr[$instances[$i]->getVar('bid')]->getVar('template') != '') { $xoopsTpl->clear_cache('db:' . $block_arr[$instances[$i]->getVar('bid')]->getVar('template'), 'blk_' . $instances[$i]->getVar('instanceid')); } } } } }
$tpltpl_handler =& xoops_gethandler('tplfile'); $tplfile =& $tpltpl_handler->get($id, true); $err = array(); if (!is_object($tplfile)) { $err[] = 'Selected template (ID: $id) does not exist'; } else { if ($tplfile->getVar('tpl_tplset') != 'default') { $tplfile->setVar('tpl_source', $html); $tplfile->setVar('tpl_lastmodified', time()); if (!$tpltpl_handler->insert($tplfile)) { $err[] = 'Could not insert template file to the database.'; } else { include_once XOOPS_ROOT_PATH . '/class/template.php'; $xoopsTpl = new XoopsTpl(); if ($xoopsTpl->is_cached('db:' . $tplfile->getVar('tpl_file'))) { if (!$xoopsTpl->clear_cache('db:' . $tplfile->getVar('tpl_file'))) { } } if ($tplfile->getVar('tpl_tplset') == $xoopsConfig['template_set']) { xoops_template_touch($id); } } } else { $err[] = 'Default template files cannot be edited.'; } } if (count($err) == 0) { if (!empty($moddir)) { redirect_header('admin.php?fct=tplsets&op=edittpl&id=' . $tplfile->getVar('tpl_id'), 2, _MD_AM_DBUPDATED); } elseif (isset($redirect)) { redirect_header('admin.php?fct=tplsets&tplset=' . $tplfile->getVar('tpl_tplset') . '&op=' . trim($redirect), 2, _MD_AM_DBUPDATED);
/** * This member function processes the uploaded file. */ function execute(&$controller, &$xoopsUser) { require_once XOOPS_ROOT_PATH . "/class/template.php"; $this->mActionForm->fetch(); $this->mActionForm->validate(); if ($this->mActionForm->hasError()) { return $this->getDefaultView($controller, $xoopsUser); } $formFileArr = $this->mActionForm->get('upload'); // // Set tpl_module and tpl_tplset of the last object to the following variable for redirect. // $last_tplset = null; $last_module = null; $handler =& xoops_getmodulehandler('tplfile'); $successFlag = true; foreach (array_keys($formFileArr) as $key) { $formFile =& $formFileArr[$key]; $obj =& $handler->get($key); if ($obj == null) { continue; } // // If $obj belongs to 'default' template-set, kick! // if ($obj->get('tpl_tplset') == 'default') { continue; } $obj->loadSource(); $last_tplset = $obj->get('tpl_tplset'); $last_module = $obj->get('tpl_module'); // // [Warning] Access to a private property of XCube_FormFile. // if ($formFile != null) { $source = file_get_contents($formFile->_mTmpFileName); $obj->Source->set('tpl_source', $source); $obj->set('tpl_lastmodified', time()); $obj->set('tpl_lastimported', time()); $successFlag &= $handler->insert($obj); $xoopsTpl = new XoopsTpl(); $xoopsTpl->clear_cache('db:' . $obj->get('tpl_file')); $xoopsTpl->clear_compiled_tpl('db:' . $obj->get('tpl_file')); } unset($obj); unset($formFile); } $errorMessage = $successFlag ? _AD_LEGACYRENDER_MESSAGE_UPLOAD_TEMPLATE_SUCCESS : _AD_LEGACYRENDER_ERROR_DBUPDATE_FAILED; // // No good exmaple ;) // Because some local variables are used, jump directly without the return value of view status. // $controller->executeRedirect("index.php?action=TplfileList&tpl_tplset={$last_tplset}&tpl_module={$last_module}", 1, $errorMessage); }