public static function eventSystemPreferencesForm(XoopsModule $module) { $helper = \Xoops::getModuleHelper('comments'); if ($plugin = Plugin::getPlugin($module->getVar('dirname'), 'comments')) { $helper->loadLanguage('main'); } }
/** * XXX * * @copyright XOOPS Project (http://xoops.org) * @license GNU GPL 2 or later (http://www.gnu.org/licenses/gpl-2.0.html) * @since 2.6.0 * @author Mage Grégory (AKA Mage) * @version $Id: $ */ function xoops_module_update_search(XoopsModule $module) { $xoops = Xoops::getInstance(); // Copy old configs in new configs and delete old configs $config_handler = $xoops->getHandlerConfig(); $criteria = new CriteriaCompo(); $criteria->add(new Criteria('conf_modid', 0)); $criteria->add(new Criteria('conf_catid', 5)); $configs = $config_handler->getConfigs($criteria); $confcount = count($configs); if ($confcount > 0) { for ($i = 0; $i < $confcount; ++$i) { $criteria = new CriteriaCompo(); $criteria->add(new Criteria('conf_modid', $module->getVar('mid'))); $criteria->add(new Criteria('conf_name', $configs[$i]->getVar('conf_name'))); $new_configs = $config_handler->getConfigs($criteria); $new_confcount = count($new_configs); if ($new_confcount > 0) { for ($j = 0; $j < $new_confcount; ++$j) { $obj = $config_handler->getConfig($new_configs[$j]->getVar('conf_id')); } $obj->setVar("conf_value", $configs[$i]->getVar('conf_value')); $config_handler->insertConfig($obj); $config_handler->deleteConfig($configs[$i]); } } } return true; }
public function test_insertModule() { $instance = new $this->myclass($this->conn); $module = new XoopsModule(); $module->setDirty(true); $module->setNew(true); $module->setVar('name', 'MODULE_DUMMY_FOR_TESTS', true); $value = $instance->insertModule($module); $this->assertTrue($value); $value = $instance->deleteModule($module); $this->assertTrue($value); }
/** * xoops_module_update_system * * @param XoopsModule $module * * @return bool */ function xoops_module_update_system(XoopsModule $module) { $xoops = Xoops::getInstance(); if ($module->getVar('version') == 100) { $qb = $xoops->db()->createXoopsQueryBuilder(); $eb = $qb->expr(); $sql = $qb->select('t1.tpl_id')->fromPrefix('system_tplfile', 't1')->fromPrefix('system_tplfile', 't2')->where($eb->eq('t1.tpl_module', 't2.tpl_module '))->andWhere($eb->eq('t1.tpl_tplset', 't2.tpl_tplset'))->andWhere($eb->eq('t1.tpl_file', 't2.tpl_file'))->andWhere($eb->eq('t1.tpl_id', 't2.tpl_id')); $result = $sql->execute(); $tplids = array(); while (list($tplid) = $result->fetch(PDO::FETCH_NUM)) { $tplids[] = $tplid; } if (count($tplids) > 0) { $tplfile_handler = $xoops->getHandlerTplFile(); $duplicate_files = $tplfile_handler->getTplObjects(new Criteria('tpl_id', "(" . implode(',', $tplids) . ")", "IN")); if (count($duplicate_files) > 0) { foreach (array_keys($duplicate_files) as $i) { $tplfile_handler->deleteTpl($duplicate_files[$i]); } } } } // Copy old configs in new configs and delete old configs // Not for conf_catid =5 (Update in search extension) // Not for conf_catid =6 (Update in mail user extension) $config_handler = $xoops->getHandlerConfig(); $criteria = new CriteriaCompo(); $criteria->add(new Criteria('conf_modid', 0)); $criteria->add(new Criteria('conf_catid', 5, '!=')); $criteria->add(new Criteria('conf_catid', 6, '!=')); $configs = $config_handler->getConfigs($criteria); $confcount = count($configs); if ($confcount > 0) { for ($i = 0; $i < $confcount; ++$i) { $criteria = new CriteriaCompo(); $criteria->add(new Criteria('conf_modid', 1)); $criteria->add(new Criteria('conf_name', $configs[$i]->getVar('conf_name'))); $new_configs = $config_handler->getConfigs($criteria); $new_confcount = count($new_configs); if ($new_confcount > 0) { for ($j = 0; $j < $new_confcount; ++$j) { $obj = $config_handler->getConfig($new_configs[$j]->getVar('conf_id')); } $obj->setVar("conf_value", $configs[$i]->getVar('conf_value')); $config_handler->insertConfig($obj); $config_handler->deleteConfig($configs[$i]); } } } return true; }
function _checkAdmin() { if ($this->isadmin) { return true; } if (!is_object($this->user)) { return false; } if (!$this->user->isAdmin($this->module->getVar('mid'))) { return false; } $this->isadmin = true; return true; }
/** * @param XoopsModule|null $mod */ public function getModulesForm($mod = null) { $xoops = Xoops::getInstance(); $mid = 0; if ($mod instanceof XoopsModule) { $mid = $mod->getVar('mid'); } /* @var $plugin UserconfigsPluginInterface */ if ($plugins = \Xoops\Module\Plugin::getPlugins('userconfigs')) { parent::__construct('', 'pref_form', 'index.php', 'post', true, 'inline'); $ele = new Xoops\Form\Select(_MD_USERCONFIGS_CHOOSE_MODULE, 'mid', $mid); foreach (array_keys($plugins) as $dirname) { $mHelper = $xoops->getModuleHelper($dirname); $ele->addOption($mHelper->getModule()->getVar('mid'), $mHelper->getModule()->getVar('name')); } $this->addElement($ele); $this->addElement(new Xoops\Form\Hidden('op', 'showmod')); $this->addElement(new Xoops\Form\Button('', 'button', XoopsLocale::A_SUBMIT, 'submit')); } }
/** * Render about page * * @param bool $logo_xoops show logo * * @return bool|mixed|string */ public function renderAbout($logo_xoops = true) { $xoops = \Xoops::getInstance(); $date = explode('/', $this->module->getInfo('release_date')); $author = explode(',', $this->module->getInfo('author')); $nickname = explode(',', $this->module->getInfo('nickname')); $release_date = \XoopsLocale::formatTimestamp(mktime(0, 0, 0, $date[1], $date[2], $date[0]), 's'); $author_list = ''; foreach (array_keys($author) as $i) { $author_list .= $author[$i]; if (isset($nickname[$i]) && $nickname[$i] != '') { $author_list .= " (" . $nickname[$i] . "), "; } else { $author_list .= ", "; } } $changelog = ''; $language = $xoops->getConfig('locale'); if (!is_file(\XoopsBaseConfig::get('root-path') . "/modules/" . $this->module->getVar("dirname") . "/locale/" . $language . "/changelog.txt")) { $language = 'en_US'; } $file = \XoopsBaseConfig::get('root-path') . "/modules/" . $this->module->getVar("dirname") . "/locale/" . $language . "/changelog.txt"; if (is_readable($file)) { $changelog = utf8_encode(implode("<br />", file($file))) . "\n"; } else { $file = \XoopsBaseConfig::get('root-path') . "/modules/" . $this->module->getVar("dirname") . "/docs/changelog.txt"; if (is_readable($file)) { $changelog = utf8_encode(implode("<br />", file($file))) . "\n"; } } $author_list = substr($author_list, 0, -2); $this->module->setInfo('release_date', $release_date); $this->module->setInfo('author_list', $author_list); if (is_array($this->module->getInfo('paypal'))) { $this->module->setInfo('paypal', $this->module->getInfo('paypal')); } $this->module->setInfo('changelog', $changelog); $xoops->tpl()->assign('module', $this->module); $this->addInfoBox(\XoopsLocale::MODULE_INFORMATION, 'info', 'id="xo-about"'); $this->addInfoBoxLine(\XoopsLocale::C_DESCRIPTION . ' ' . $this->module->getInfo("description"), 'info'); $this->addInfoBoxLine(\XoopsLocale::C_UPDATE_DATE . ' <span class="bold">' . \XoopsLocale::formatTimestamp($this->module->getVar("last_update"), "m") . '</span>', 'info'); $this->addInfoBoxLine(\XoopsLocale::C_WEBSITE . ' <a class="xo-tooltip" href="http://' . $this->module->getInfo("module_website_url") . '" rel="external" title="' . $this->module->getInfo("module_website_name") . ' - ' . $this->module->getInfo("module_website_url") . '">' . $this->module->getInfo("module_website_name") . '</a>', 'info'); $xoops->tpl()->assign('xoops_logo', $logo_xoops); $xoops->tpl()->assign('xo_admin_box', $this->itemInfoBox); return $xoops->tpl()->fetch($this->getTplPath('about')); }
/** * @param array $obj * @param XoopsModule $mod */ public function getForm(&$obj, XoopsModule $mod) { $xoops = Xoops::getInstance(); $helper = Userconfigs::getInstance(); $config_handler = $helper->getHandlerConfig(); /* @var $plugin UserconfigsPluginInterface */ if ($plugin = \Xoops\Module\Plugin::getPlugin($mod->getVar('dirname'), 'userconfigs')) { parent::__construct('', 'pref_form', 'index.php', 'post', true); if ($mod->getVar('dirname') != 'system') { $xoops->loadLanguage('modinfo', $mod->getVar('dirname')); $xoops->loadLocale($mod->getVar('dirname')); } $configs = $plugin->configs(); $configNames = array(); foreach (array_keys($configs) as $i) { $configNames[$configs[$i]['name']] =& $configs[$i]; } $configCats = $plugin->categories(); if (!$configCats) { $configCats = array('default' => array('name' => _MD_USERCONFIGS_CONFIGS, 'description' => '')); } if (!in_array('default', array_keys($configCats))) { $configCats['default'] = array('name' => _MD_USERCONFIGS_CONFIGS, 'description' => ''); } foreach (array_keys($configNames) as $name) { if (!isset($configNames[$name]['category'])) { $configNames[$name]['category'] = 'default'; } } $tabtray = new Xoops\Form\TabTray('', 'pref_tabtay', $xoops->getModuleConfig('jquery_theme', 'system')); $tabs = array(); foreach ($configCats as $name => $info) { $tabs[$name] = new Xoops\Form\Tab($info['name'], 'pref_tab_' . $name); if (isset($info['description']) && $info['description'] != '') { $tabs[$name]->addElement(new Xoops\Form\Label('', $info['description'])); } } $count = count($obj); for ($i = 0; $i < $count; ++$i) { $title = Xoops_Locale::translate($obj[$i]->getVar('conf_title'), $mod->getVar('dirname')); $desc = $obj[$i]->getVar('conf_desc') != '' ? Xoops_Locale::translate($obj[$i]->getVar('conf_desc'), $mod->getVar('dirname')) : ''; switch ($obj[$i]->getVar('conf_formtype')) { case 'textarea': $myts = MyTextSanitizer::getInstance(); if ($obj[$i]->getVar('conf_valuetype') == 'array') { // this is exceptional.. only when value type is arrayneed a smarter way for this $ele = $obj[$i]->getVar('conf_value') != '' ? new Xoops\Form\TextArea($title, $obj[$i]->getVar('conf_name'), $myts->htmlSpecialChars(implode('|', $obj[$i]->getConfValueForOutput())), 5, 5) : new Xoops\Form\TextArea($title, $obj[$i]->getVar('conf_name'), '', 5, 5); } else { $ele = new Xoops\Form\TextArea($title, $obj[$i]->getVar('conf_name'), $myts->htmlSpecialChars($obj[$i]->getConfValueForOutput()), 5, 5); } break; case 'select': $ele = new Xoops\Form\Select($title, $obj[$i]->getVar('conf_name'), $obj[$i]->getConfValueForOutput()); $options = $config_handler->getConfigOptions(new Criteria('conf_id', $obj[$i]->getVar('conf_id'))); $opcount = count($options); for ($j = 0; $j < $opcount; ++$j) { $optval = Xoops_Locale::translate($options[$j]->getVar('confop_value'), $mod->getVar('dirname')); $optkey = Xoops_Locale::translate($options[$j]->getVar('confop_name'), $mod->getVar('dirname')); $ele->addOption($optval, $optkey); } break; case 'select_multi': $ele = new Xoops\Form\Select($title, $obj[$i]->getVar('conf_name'), $obj[$i]->getConfValueForOutput(), 5, true); $options = $config_handler->getConfigOptions(new Criteria('conf_id', $obj[$i]->getVar('conf_id'))); $opcount = count($options); for ($j = 0; $j < $opcount; ++$j) { $optval = Xoops_Locale::translate($options[$j]->getVar('confop_value'), $mod->getVar('dirname')); $optkey = Xoops_Locale::translate($options[$j]->getVar('confop_name'), $mod->getVar('dirname')); $ele->addOption($optval, $optkey); } break; case 'yesno': $ele = new Xoops\Form\RadioYesNo($title, $obj[$i]->getVar('conf_name'), $obj[$i]->getConfValueForOutput()); break; case 'theme': case 'theme_multi': $ele = $obj[$i]->getVar('conf_formtype') != 'theme_multi' ? new Xoops\Form\Select($title, $obj[$i]->getVar('conf_name'), $obj[$i]->getConfValueForOutput()) : new Xoops\Form\Select($title, $obj[$i]->getVar('conf_name'), $obj[$i]->getConfValueForOutput(), 5, true); $dirlist = XoopsLists::getThemesList(); if (!empty($dirlist)) { asort($dirlist); $ele->addOptionArray($dirlist); } break; case 'tplset': $ele = new Xoops\Form\Select($title, $obj[$i]->getVar('conf_name'), $obj[$i]->getConfValueForOutput()); $tplset_handler = $xoops->getHandlerTplSet(); $tplsetlist = $tplset_handler->getNameList(); asort($tplsetlist); foreach ($tplsetlist as $key => $name) { $ele->addOption($key, $name); } break; case 'cpanel': $ele = new Xoops\Form\Hidden($obj[$i]->getVar('conf_name'), $obj[$i]->getConfValueForOutput()); /* $ele = new Xoops\Form\Select($title, $config[$i]->getVar('conf_name'), $config[$i]->getConfValueForOutput()); XoopsLoad::load("cpanel", "system"); $list = XoopsSystemCpanel::getGuis(); $ele->addOptionArray($list); */ break; case 'timezone': $ele = new Xoops\Form\SelectTimeZone($title, $obj[$i]->getVar('conf_name'), $obj[$i]->getConfValueForOutput()); break; case 'language': $ele = new Xoops\Form\SelectLanguage($title, $obj[$i]->getVar('conf_name'), $obj[$i]->getConfValueForOutput()); break; case 'locale': $ele = new Xoops\Form\SelectLocale($title, $obj[$i]->getVar('conf_name'), $obj[$i]->getConfValueForOutput()); break; case 'startpage': $ele = new Xoops\Form\Select($title, $obj[$i]->getVar('conf_name'), $obj[$i]->getConfValueForOutput()); $module_handler = $xoops->getHandlerModule(); $criteria = new CriteriaCompo(new Criteria('hasmain', 1)); $criteria->add(new Criteria('isactive', 1)); $moduleslist = $module_handler->getNameList($criteria, true); $moduleslist['--'] = XoopsLocale::NONE; $ele->addOptionArray($moduleslist); break; case 'group': $ele = new Xoops\Form\SelectGroup($title, $obj[$i]->getVar('conf_name'), false, $obj[$i]->getConfValueForOutput(), 1, false); break; case 'group_multi': $ele = new Xoops\Form\SelectGroup($title, $obj[$i]->getVar('conf_name'), false, $obj[$i]->getConfValueForOutput(), 5, true); break; // RMV-NOTIFY: added 'user' and 'user_multi' // RMV-NOTIFY: added 'user' and 'user_multi' case 'user': $ele = new Xoops\Form\SelectUser($title, $obj[$i]->getVar('conf_name'), false, $obj[$i]->getConfValueForOutput(), 1, false); break; case 'user_multi': $ele = new Xoops\Form\SelectUser($title, $obj[$i]->getVar('conf_name'), false, $obj[$i]->getConfValueForOutput(), 5, true); break; case 'module_cache': $module_handler = $xoops->getHandlerModule(); $modules = $module_handler->getObjectsArray(new Criteria('hasmain', 1), true); $currrent_val = $obj[$i]->getConfValueForOutput(); $cache_options = array('0' => XoopsLocale::NO_CACHE, '30' => sprintf(XoopsLocale::F_SECONDS, 30), '60' => XoopsLocale::ONE_MINUTE, '300' => sprintf(XoopsLocale::F_MINUTES, 5), '1800' => sprintf(XoopsLocale::F_MINUTES, 30), '3600' => XoopsLocale::ONE_HOUR, '18000' => sprintf(XoopsLocale::F_HOURS, 5), '86400' => XoopsLocale::ONE_DAY, '259200' => sprintf(XoopsLocale::F_DAYS, 3), '604800' => XoopsLocale::ONE_WEEK, '2592000' => XoopsLocale::ONE_MONTH); if (count($modules) > 0) { $ele = new Xoops\Form\ElementTray($title, '<br />'); foreach (array_keys($modules) as $mid) { $c_val = isset($currrent_val[$mid]) ? (int) $currrent_val[$mid] : null; $selform = new Xoops\Form\Select($modules[$mid]->getVar('name'), $obj[$i]->getVar('conf_name') . "[{$mid}]", $c_val); $selform->addOptionArray($cache_options); $ele->addElement($selform); unset($selform); } } else { $ele = new Xoops\Form\Label($title, SystemLocale::NO_MODULE_TO_CACHE); } break; case 'site_cache': $ele = new Xoops\Form\Select($title, $obj[$i]->getVar('conf_name'), $obj[$i]->getConfValueForOutput()); $ele->addOptionArray(array('0' => XoopsLocale::NO_CACHE, '30' => sprintf(XoopsLocale::F_SECONDS, 30), '60' => XoopsLocale::ONE_MINUTE, '300' => sprintf(XoopsLocale::F_MINUTES, 5), '1800' => sprintf(XoopsLocale::F_MINUTES, 30), '3600' => XoopsLocale::ONE_HOUR, '18000' => sprintf(XoopsLocale::F_HOURS, 5), '86400' => XoopsLocale::ONE_DAY, '259200' => sprintf(XoopsLocale::F_DAYS, 3), '604800' => XoopsLocale::ONE_WEEK, '2592000' => XoopsLocale::ONE_MONTH)); break; case 'password': $myts = MyTextSanitizer::getInstance(); $ele = new Xoops\Form\Password($title, $obj[$i]->getVar('conf_name'), 5, 255, $myts->htmlSpecialChars($obj[$i]->getConfValueForOutput())); break; case 'color': $myts = MyTextSanitizer::getInstance(); $ele = new Xoops\Form\ColorPicker($title, $obj[$i]->getVar('conf_name'), $myts->htmlSpecialChars($obj[$i]->getConfValueForOutput())); break; case 'hidden': $myts = MyTextSanitizer::getInstance(); $ele = new Xoops\Form\Hidden($obj[$i]->getVar('conf_name'), $myts->htmlSpecialChars($obj[$i]->getConfValueForOutput())); break; case 'textbox': default: $myts = MyTextSanitizer::getInstance(); $ele = new Xoops\Form\Text($title, $obj[$i]->getVar('conf_name'), 5, 255, $myts->htmlSpecialChars($obj[$i]->getConfValueForOutput())); break; } $hidden = new Xoops\Form\Hidden('conf_ids[]', $obj[$i]->getVar('conf_id')); if (isset($ele)) { $ele->setDescription($desc); if ($obj[$i]->getVar('conf_formtype') != 'hidden') { $name = 'default'; if (isset($configNames[$obj[$i]->getVar('conf_name')]['category'])) { $name = $configNames[$obj[$i]->getVar('conf_name')]['category']; } $tabs[$name]->addElement($ele); } else { $this->addElement($ele); } $this->addElement($hidden); unset($ele); unset($hidden); } } foreach (array_keys($tabs) as $name) { if ($tabs[$name]->getElements()) { $tabtray->addElement($tabs[$name]); } } $this->addElement($tabtray); $this->addElement(new Xoops\Form\Hidden('op', 'save')); $this->addElement(new Xoops\Form\Hidden('mid', $mod->getVar('mid'))); $this->addElement(new Xoops\Form\Button('', 'button', XoopsLocale::A_SUBMIT, 'submit')); } }
/** * Load some modules * * @param CriteriaElement|null $criteria criteria to match * @param boolean $id_as_key Use the ID as key into the array * * @return array */ public function getObjectsArray(CriteriaElement $criteria = null, $id_as_key = false) { $ret = array(); $qb = $this->db2->createXoopsQueryBuilder(); $qb->select('*')->fromPrefix('system_module', null); if (isset($criteria) && $criteria instanceof CriteriaElement) { $criteria->setSort('weight'); $criteria->renderQb($qb); $qb->addOrderBy('mid', 'ASC'); } // During install, we start with no tables and no installed modules. We need to // handle the resulting exceptions and return an empty array. try { if (!($result = $qb->execute())) { return $ret; } } catch (\Doctrine\DBAL\Driver\PDOException $e) { return $ret; } catch (\Doctrine\DBAL\Exception\TableNotFoundException $e) { return $ret; } catch (\PDOException $e) { return $ret; } while ($myrow = $result->fetch(\PDO::FETCH_ASSOC)) { $module = new XoopsModule(); $module->assignVars($myrow); if (!$id_as_key) { $ret[] = $module; } else { $ret[$myrow['mid']] = $module; } unset($module); } return $ret; }
/** * Disables page cache by overriding module cache settings * * @return void */ public function disableModuleCache() { if ($this->isModule()) { $this->appendConfig('module_cache', array($this->module->getVar('mid') => 0), true); } }
/** * @param XoopsModule $module */ public function deleteModuleRelations(XoopsModule $module) { $xoops = Xoops::getInstance(); $this->getHandlerComment()->deleteByModule($module->getVar('mid')); $configNames = array('com_rule', 'com_anonpost'); $config_handler = $xoops->getHandlerConfig(); //Delete all configs $criteria = new CriteriaCompo(); $criteria->add(new Criteria('conf_modid', $module->getVar('mid'))); $criteria->add(new Criteria('conf_name', "('" . implode("','", $configNames) . "')", 'IN')); $configs = $config_handler->getConfigs($criteria); /* @var $config XoopsConfigItem */ foreach ($configs as $config) { $config_handler->deleteConfig($config); } }
/** * @param XoopsModule $module * * @return array */ public function getPluginableConfigs(XoopsModule $module) { $configs = array(); $options['_MD_NOTIFICATIONS_CONFIG_DISABLE'] = NOTIFICATIONS_DISABLE; $options['_MD_NOTIFICATIONS_CONFIG_ENABLEBLOCK'] = NOTIFICATIONS_ENABLEBLOCK; $options['_MD_NOTIFICATIONS_CONFIG_ENABLEINLINE'] = NOTIFICATIONS_ENABLEINLINE; $options['_MD_NOTIFICATIONS_CONFIG_ENABLEBOTH'] = NOTIFICATIONS_ENABLEBOTH; $configs[] = array('name' => 'notifications_enabled', 'title' => '_MD_NOTIFICATIONS_CONFIG_ENABLE', 'description' => '_MD_NOTIFICATIONS_CONFIG_ENABLEDSC', 'formtype' => 'select', 'valuetype' => 'int', 'default' => NOTIFICATIONS_ENABLEBOTH, 'options' => $options); // Event-specific notification options // FIXME: doesn't work when update module... can't read back the array of options properly... " changing to " $options = array(); $categories = $this->getCategory('', $module->getVar('dirname')); foreach ($categories as $category) { $events = $this->getEvents($category['name'], false, $module->getVar('dirname')); 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; } unset($events); } unset($categories); $configs[] = array('name' => 'notification_events', 'title' => '_MD_NOTIFICATIONS_CONFIG_EVENTS', 'description' => '_MD_NOTIFICATIONS_CONFIG_EVENTSDSC', 'formtype' => 'select_multi', 'valuetype' => 'array', 'default' => array_values($options), 'options' => $options); return $configs; }
/** * installconfigs * * @param XoopsModule $module module being installed * * @return void */ public function installConfigs(XoopsModule $module) { $xoops = Xoops::getInstance(); // now reinsert them with the new settings $configs = $module->getInfo('config'); if (!is_array($configs)) { $configs = array(); } XoopsPreload::getInstance()->triggerEvent('onModuleUpdateConfigs', array($module, &$configs)); if (is_array($configs) && count($configs) > 0) { $this->trace[] = SystemLocale::MANAGING_PREFERENCES; $config_handler = $xoops->getHandlerConfig(); $order = 0; foreach ($configs as $config) { // only insert ones that have been deleted previously with success if (!in_array($config['name'], $this->config_delng)) { $confobj = $config_handler->createConfig(); $confobj->setVar('conf_modid', $module->getVar('mid')); $confobj->setVar('conf_catid', 0); $confobj->setVar('conf_name', $config['name']); $confobj->setVar('conf_title', $config['title']); $confobj->setVar('conf_desc', $config['description']); $confobj->setVar('conf_formtype', $config['formtype']); $confobj->setVar('conf_valuetype', $config['valuetype']); if (isset($this->config_old[$config['name']]['value']) && $this->config_old[$config['name']]['formtype'] == $config['formtype'] && $this->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', $this->config_old[$config['name']]['value']); } else { $confobj->setConfValueForInput($config['default']); //$confobj->setVar('conf_value', $config['default']); } $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); $confop->setVar('confop_value', $value); $confobj->setConfOptions($confop); $confop_msgs .= '<br /> '; $confop_msgs .= SystemLocale::S_CONFIG_OPTION_ADDED; $confop_msgs .= ' '; $confop_msgs .= XoopsLocale::C_NAME; $confop_msgs .= ' <strong>' . Xoops_Locale::translate($key, $module->getVar('dirname')) . '</strong> '; $confop_msgs .= XoopsLocale::C_VALUE . ' <strong>' . $value . '</strong> '; unset($confop); } } ++$order; if (false != $config_handler->insertConfig($confobj)) { $this->trace[]['sub'] = sprintf(SystemLocale::SF_CONFIG_ADDED, "<strong>" . $config['name'] . "</strong>") . $confop_msgs; } else { $this->trace[]['sub'] = '<span class="red">' . sprintf(SystemLocale::EF_CONFIG_NOT_ADDED, "<strong>" . $config['name'] . "</strong>") . '</span>'; } unset($confobj); } } unset($configs); } }
/** * @copyright XOOPS Project (http://xoops.org) * @license GNU GPL V2 or later (http://www.gnu.org/licenses/gpl-2.0.html) * @author trabis <*****@*****.**> * @version $Id$ */ function xoops_module_update_publisher(XoopsModule $module, $version) { $gperm_handler = Xoops::getInstance()->getHandlerGroupPermission(); return $gperm_handler->deleteByModule($module->getVar('mid'), "item_read"); }
public function createDefaultUserConfigs($uid, XoopsModule $module) { /* @var $plugin UserconfigsPluginInterface */ if ($plugin = \Xoops\Module\Plugin::getPlugin($module->getVar('dirname'), 'userconfigs')) { // now reinsert them with the new settings $configs = $plugin->configs(); if (!is_array($configs)) { $configs = array(); } if (is_array($configs) && count($configs) > 0) { $order = 0; foreach ($configs as $config) { $confobj = $this->createConfig(); $confobj->setVar('conf_modid', $module->getVar('mid')); $confobj->setVar('conf_uid', $uid); $confobj->setVar('conf_name', $config['name']); $confobj->setVar('conf_title', $config['title']); $confobj->setVar('conf_desc', $config['description']); $confobj->setVar('conf_formtype', $config['formtype']); $confobj->setVar('conf_valuetype', $config['valuetype']); $confobj->setConfValueForInput($config['default']); $confobj->setVar('conf_order', $order); if (isset($config['options']) && is_array($config['options'])) { foreach ($config['options'] as $key => $value) { $confop = $this->createConfigOption(); $confop->setVar('confop_name', $key); $confop->setVar('confop_value', $value); $confobj->setConfOptions($confop); unset($confop); } } ++$order; $this->insertConfig($confobj); unset($confobj); } unset($configs); } } }
/** * remove any userconfigs for module being uninstalled * * @param XoopsModule $module module object * * @return void */ public static function eventSystemModuleUninstall(XoopsModule $module) { if ($plugin = \Xoops\Module\Plugin::getPlugin($module->getVar('dirname'), 'userconfigs')) { Userconfigs::getInstance()->getHandlerConfig()->deleteConfigsByModule($module->getVar('mid')); } }
public static function eventSystemPreferencesForm(XoopsModule $module) { if ($plugin = Plugin::getPlugin($module->getVar('dirname'), 'notifications')) { Notifications::getInstance()->loadLanguage('main'); } }