public function handleCommand(Zikula_Form_View $view, &$args) { if ($args['commandName'] == 'save') { if (!$this->view->isValid()) { return false; } $data = $this->view->getValues(); if (!ModUtil::setVars('Content', $data['config'])) { return $this->view->setErrorMsg($this->__('Failed to set configuration variables')); } if ($data['config']['categoryUsage'] < 4) { // load the category registry util $mainCategory = CategoryRegistryUtil::getRegisteredModuleCategory('Content', 'content_page', $data['config']['categoryPropPrimary']); if (!$mainCategory) { return LogUtil::registerError($this->__('Main category property does not exist.')); } if ($data['config']['categoryUsage'] < 3) { $secondCategory = CategoryRegistryUtil::getRegisteredModuleCategory('Content', 'content_page', $data['config']['categoryPropSecondary']); if (!$secondCategory) { return LogUtil::registerError($this->__('Second category property does not exist.')); } } } LogUtil::registerStatus($this->__('Done! Saved module configuration.')); } else if ($args['commandName'] == 'cancel') { } $url = ModUtil::url('Content', 'admin', 'main'); return $this->view->redirect($url); }
function handleCommand(Zikula_Form_View $view, &$args) { if ($args['commandName'] == 'cancel') { $url = ModUtil::url('Scribite', 'admin', 'main'); return $view->redirect($url); } else { if ($args['commandName'] == 'restore') { $classname = 'ModulePlugin_Scribite_' . $this->editor . '_Plugin'; if (method_exists($classname, 'getDefaults')) { $defaults = $classname::getDefaults(); if (!empty($defaults)) { ModUtil::setVars("moduleplugin.scribite." . strtolower($this->editor), $defaults); LogUtil::registerStatus('Defaults succesfully restored.'); } } return true; } } // check for valid form if (!$view->isValid()) { return false; } $data = $view->getValues(); ModUtil::setVars("moduleplugin.scribite." . strtolower($this->editor), $data); LogUtil::registerStatus($this->__('Done! Module configuration updated.')); return true; }
public function updateConfig($args) { // Security check if (!SecurityUtil::checkPermission('SiriusXtecAuth::', '::', ACCESS_ADMIN)) { return LogUtil::registerPermissionError(); } $items = array( 'ldap_active' => FormUtil::getPassedValue('ldap_active', false, 'POST')?true:false, 'users_creation' => FormUtil::getPassedValue('users_creation', false, 'POST')?true:false, 'new_users_activation' => FormUtil::getPassedValue('new_users_activation', false, 'POST')?true:false, 'iw_write' => FormUtil::getPassedValue('iw_write', false, 'POST')?true:false, 'iw_lastnames' => FormUtil::getPassedValue('iw_lastnames', false, 'POST')?true:false, 'new_users_groups' => FormUtil::getPassedValue('new_users_groups', array(), 'POST'), 'ldap_server' => FormUtil::getPassedValue('ldap_server', false, 'POST'), 'ldap_basedn' => FormUtil::getPassedValue('ldap_basedn', false, 'POST'), 'ldap_searchattr' => FormUtil::getPassedValue('ldap_searchattr', false, 'POST'), 'loginXtecApps' => FormUtil::getPassedValue('loginXtecApps', false, 'POST'), 'logoutXtecApps' => FormUtil::getPassedValue('logoutXtecApps', false, 'POST'), 'gtafProtocol' => FormUtil::getPassedValue('gtafProtocol', false, 'POST'), 'e13Protocol' => FormUtil::getPassedValue('e13Protocol', false, 'POST'), 'gtafURL' => FormUtil::getPassedValue('gtafURL', false, 'POST'), 'e13URL' => FormUtil::getPassedValue('e13URL', false, 'POST'), 'loginTime' => FormUtil::getPassedValue('loginTime', false, 'POST'), 'logoutTime' => FormUtil::getPassedValue('logoutTime', false, 'POST')); ModUtil::setVars($this->name,$items); LogUtil::registerStatus($this->__('S\'ha actualitzat la configuració del mòdul.')); return System::redirect(ModUtil::url('SiriusXtecAuth', 'admin', 'main')); }
/** * @Route("/config") * @Theme("admin") * @param Request $request * @return \Symfony\Component\HttpFoundation\RedirectResponse|Response */ public function configAction(Request $request) { $form = $this->createFormBuilder(\ModUtil::getVar('ZikulaPagesModule'))->add('enablecategorization', 'checkbox', array('label' => __('Enable categorization'), 'required' => false))->add('itemsperpage', 'number', array('label' => __('Items per page'), 'constraints' => array(new Assert\GreaterThan(array('value' => 0)))))->add('def_displaywrapper', 'checkbox', array('label' => __('Display additional information'), 'required' => false))->add('def_displaytitle', 'checkbox', array('label' => __('Display page title'), 'required' => false))->add('def_displaycreated', 'checkbox', array('label' => __('Display page creation date'), 'required' => false))->add('def_displayupdated', 'checkbox', array('label' => __('Display page update date'), 'required' => false))->add('def_displaytextinfo', 'checkbox', array('label' => __('Display page text statistics'), 'required' => false))->add('def_displayprint', 'checkbox', array('label' => __('Display page print link'), 'required' => false))->add('addcategorytitletopermalink', 'checkbox', array('label' => __('Add category title to permalink'), 'required' => false, 'disabled' => true))->add('showpermalinkinput', 'checkbox', array('label' => __('Show permalink input field'), 'required' => false, 'disabled' => true))->add('save', 'submit', array('label' => 'Save'))->add('cancel', 'submit', array('label' => 'Cancel'))->getForm(); $form->handleRequest($request); if ($form->isValid()) { if ($form->get('save')->isClicked()) { \ModUtil::setVars('ZikulaPagesModule', $form->getData()); $this->addFlash('status', __('Done! Module configuration updated.')); } if ($form->get('cancel')->isClicked()) { $this->addFlash('status', __('Operation cancelled.')); } return $this->redirect($this->generateUrl('zikulapagesmodule_admin_index')); } $request->attributes->set('_legacy', true); // forces template to render inside old theme return $this->render('ZikulaPagesModule:Admin:config.html.twig', array('form' => $form->createView())); }
/** * Init ephemerides module * @author The Zikula Development Team * @return true if init successful, false otherwise */ public function install() { // create table if (!DBUtil::createTable('ephem')) { return false; } // set up module config variables $modvars = array('itemsperpage' => 25, 'enablecategorization' => true, 'enablefacebookshare' => false); // create our default category if (!$this->_createdefaultcategory()) { LogUtil::registerStatus($this->{$this}->__('Warning! Could not create the default Ephemerides category tree. If you want to use categorisation with Ephemerides, register at least one property for the module in the Category Registry.')); $modvars['enablecategorization'] = false; } // set up module variables ModUtil::setVars('Ephemerides', $modvars); // Register hooks HookUtil::registerSubscriberBundles($this->version->getHookSubscriberBundles()); HookUtil::registerProviderBundles($this->version->getHookProviderBundles()); // initialisation successful return true; }
/** * Configure a theme's variables based on provided .yml definitions for each field. * @Route("/admin/var/{themeName}") * @todo change route name to /admin/variable/{themeName} when similar named is removed? * @Theme("admin") * * @param Request $request * @param string $themeName * @return mixed * @throws \InvalidArgumentException if theme type is not twig-based */ public function varAction(Request $request, $themeName) { $themeBundle = \ThemeUtil::getTheme($themeName); if (!$themeBundle->isTwigBased()) { throw new NotFoundHttpException('Theme type must be twig-based in ' . __FILE__ . ' at line ' . __LINE__ . '.'); } $themeVarsPath = $themeBundle->getConfigPath() . '/variables.yml'; if (!file_exists($themeVarsPath)) { $this->addFlash('warning', $this->__f('%theme% has no configuration.', array('%theme%' => $themeName))); return $this->redirect($this->generateUrl('zikulathememodule_admin_view')); } $variableDefinitions = Yaml::parse(file_get_contents($themeVarsPath)); /** @var \Symfony\Component\Form\FormBuilder $formBuilder */ $formBuilder = $this->createFormBuilder($themeBundle->getThemeVars()); foreach ($variableDefinitions as $fieldName => $definitions) { $options = isset($definitions['options']) ? $definitions['options'] : []; if (isset($definitions['type'])) { $formBuilder->add($fieldName, $definitions['type'], $options); } } $formBuilder->add('save', 'submit', array('label' => $this->__('Save'), 'icon' => 'fa-check fa-lg', 'attr' => array('class' => "btn btn-success")))->add('toDefault', 'submit', array('label' => $this->__('Set to defaults'), 'icon' => 'fa-refresh fa-lg', 'attr' => array('class' => "btn btn-primary")))->add('cancel', 'submit', array('label' => $this->__('Cancel'), 'icon' => 'fa-times fa-lg', 'attr' => array('class' => "btn btn-danger"))); $form = $formBuilder->getForm(); $form->handleRequest($request); if ($form->isValid()) { if ($form->get('save')->isClicked()) { // pseudo-hack to save theme vars in to modvars table \ModUtil::setVars($themeName, $form->getData()); $this->addFlash('status', $this->__('Done! Theme configuration updated.')); } elseif ($form->get('toDefault')->isClicked()) { \ModUtil::setVars($themeName, $themeBundle->getDefaultThemeVars()); $this->addFlash('status', $this->__('Done! Theme configuration updated to default values.')); } elseif ($form->get('cancel')->isClicked()) { $this->addFlash('status', $this->__('Operation cancelled.')); } return $this->redirect($this->generateUrl('zikulathememodule_admin_view')); } return $this->render('ZikulaThemeModule:Admin:var.html.twig', ['themeName' => $themeName, 'form' => $form->createView()]); }
/** * initialise the module * * This function is only ever called once during the lifetime of a particular * module instance * * @return boolean */ public function install() { // create table try { $this->container->get('zikula.doctrine.schema_tool')->create($this->entities); } catch (\Exception $e) { $this->container->get('request')->getSession()->getFlashBag()->add('error', $e->getMessage()); return false; } // insert default category try { $this->createCategoryTree(); } catch (\Exception $e) { $this->container->get('request')->getSession()->getFlashBag()->add('error', $this->__f('Did not create default categories (%s).', $e->getMessage())); } // set up config variables $modvars = array('itemsperpage' => 25, 'enablecategorization' => true, 'addcategorytitletopermalink' => true, 'showpermalinkinput' => true, 'def_displaywrapper' => true, 'def_displaytitle' => true, 'def_displaycreated' => true, 'def_displayupdated' => true, 'def_displaytextinfo' => true, 'def_displayprint' => true); \ModUtil::setVars($this->bundle->getName(), $modvars); $hookHelper = new HookHelper($this->getTranslator()); HookUtil::registerSubscriberBundles($hookHelper->getHookSubscriberBundles()); $this->createIntroPage(); // initialisation successful return true; }
/** * Convenience Module SetVars. * * @param array $vars Array of key => value. * * @return object This. */ public function setVars(array $vars) { ModUtil::setVars($this->name, $vars); return $this; }
/** * Convenience Module SetVars. * * @param array $vars Array of key => value. * * @return object This. */ public function setVars(array $vars) { ModUtil::setVars($this->getServiceId(), $vars); return $this; }
/** * Update the module configuration * @author: Albert Pérez Monfort (aperezm@xtec.cat) * @return: True if success or false in other case */ public function updateconfig($args) { // Get parameters from whatever input we need. $showHideFiles = FormUtil::getPassedValue('showHideFiles', isset($args['showHideFiles']) ? $args['showHideFiles'] : 0, 'POST'); $folderPath = FormUtil::getPassedValue('folderPath', isset($args['folderPath']) ? $args['folderPath'] : null, 'POST'); $usersFolder = FormUtil::getPassedValue('usersFolder', isset($args['usersFolder']) ? $args['usersFolder'] : null, 'POST'); $allowedExtensions = FormUtil::getPassedValue('allowedExtensions', isset($args['allowedExtensions']) ? $args['allowedExtensions'] : null, 'POST'); $defaultQuota = FormUtil::getPassedValue('defaultQuota', isset($args['defaultQuota']) ? $args['defaultQuota'] : null, 'POST'); $filesMaxSize = FormUtil::getPassedValue('filesMaxSize', isset($args['filesMaxSize']) ? $args['filesMaxSize'] : null, 'POST'); $maxWidth = FormUtil::getPassedValue('maxWidth', isset($args['maxWidth']) ? $args['maxWidth'] : null, 'POST'); $maxHeight = FormUtil::getPassedValue('maxHeight', isset($args['maxHeight']) ? $args['maxHeight'] : null, 'POST'); $editableExtensions = FormUtil::getPassedValue('editableExtensions', isset($args['editableExtensions']) ? $args['editableExtensions'] : null, 'POST'); // Security check if (!SecurityUtil::checkPermission('Files::', '::', ACCESS_ADMIN)) { return LogUtil::registerPermissionError(); } // Confirm authorisation code if (!SecurityUtil::confirmAuthKey()) { return LogUtil::registerAuthidError(ModUtil::url('Files', 'admin', 'main')); } $moduleVars = array('showHideFiles' => $showHideFiles, 'allowedExtensions' => $allowedExtensions, 'defaultQuota' => $defaultQuota, 'filesMaxSize' => $filesMaxSize, 'maxWidth' => $maxWidth, 'maxHeight' => $maxHeight, 'editableExtensions' => $editableExtensions); if ($GLOBALS['PNConfig']['Multisites']['multi'] != 1) { if (!file_exists($folderPath)) { ModUtil::setVars('Files', $moduleVars); LogUtil::registerError($this->__f('The directory <strong>%s</strong> does not exist', $folderPath)); return System::redirect(ModUtil::url('Files', 'admin', 'main')); } $folderPath = substr($folderPath, -1) == '/' ? substr($folderPath, 0, strlen($folderPath) - 1) : $folderPath; $moduleVars['folderPath'] = $folderPath; } if (!file_exists($folderPath . '/' . $usersFolder) || $usersFolder == '' || $usersFolder == null) { ModUtil::setVars('Files', $moduleVars); LogUtil::registerError($this->__f('The directory <strong>%s</strong> for users does not exist', $usersFolder)); return System::redirect(ModUtil::url('Files', 'admin', 'main')); } $usersFolder = substr($usersFolder, -1) == '/' ? substr($usersFolder, 0, strlen($usersFolder) - 1) : $usersFolder; $usersFolder = substr($usersFolder, 0, 1) == '/' ? substr($usersFolder, 1, strlen($usersFolder)) : $usersFolder; $moduleVars['usersFolder'] = $usersFolder; ModUtil::setVars('Files', $moduleVars); LogUtil::registerStatus($this->__('The configuration has been updated')); // This function generated no output, and so now it is complete we redirect // the user to an appropriate page for them to carry on their work return System::redirect(ModUtil::url('Files', 'admin', 'main')); }
/** * upgrade the Feeds module from an old version * This function can be called multiple times */ public function upgrade($oldversion) { $dom = ZLanguage::getModuleDomain('Feeds'); // when upgrading let's clear the cache directory CacheUtil::clearLocalDir('feeds'); switch ($oldversion) { // version 1.0 shipped with PN .7x case '1.0': // rename table if upgrading from an earlier version if (in_array(DBUtil::getLimitedTablename('RSS'), DBUtil::MetaTables())) { DBUtil::renameTable('RSS', 'feeds'); } if (in_array(DBUtil::getLimitedTablename('rss'), DBUtil::MetaTables())) { DBUtil::renameTable('rss', 'feeds'); } // create cache directory CacheUtil::createLocalDir('feeds'); // migrate module vars $tables = DBUtil::getTables(); $sql = "UPDATE $tables[module_vars] SET pn_modname = 'Feeds' WHERE pn_modname = 'RSS'"; if (!DBUtil::executeSQL($sql)) { LogUtil::registerError(__('Error! Update attempt failed.', $dom)); return '1.0'; } // create our default category $this->setVar('enablecategorization', true); if (!$this->_feeds_createdefaultcategory()) { LogUtil::registerError(__('Error! Update attempt failed.', $dom)); return '1.0'; } // update table if (!DBUtil::changeTable('feeds')) { return '1.0'; } // update the permalinks $shorturlsep = System::getVar('shorturlsseparator'); $sql = "UPDATE $tables[feeds] SET pn_urltitle = REPLACE(pn_name, ' ', '{$shorturlsep}')"; if (!DBUtil::executeSQL($sql)) { LogUtil::registerError(__('Error! Update attempt failed.', $dom)); return '1.0'; } case '2.1': $modvars = array('multifeedlimit' => 0, 'feedsperpage' => 10, 'usingcronjob' => 0, 'key' => md5(time())); if (!ModUtil::setVars('Feeds', $modvars)) { LogUtil::registerError(__('Error! Update attempt failed.', $dom)); return '2.1'; } // 2.2 -> 2.3 is the Gettext change case '2.2': case '2.3': case '2.4': case '2.5': $prefix = $this->serviceManager['prefix']; $connection = Doctrine_Manager::getInstance()->getConnection('default'); $sqlStatements = array(); // N.B. statements generated with PHPMyAdmin $sqlStatements[] = 'RENAME TABLE ' . $prefix . '_feeds' . " TO `feeds`"; $sqlStatements[] = "ALTER TABLE `feeds` CHANGE `pn_fid` `fid` INT( 10 ) NOT NULL AUTO_INCREMENT , CHANGE `pn_name` `name` VARCHAR( 255 ) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT '', CHANGE `pn_urltitle` `urltitle` VARCHAR( 255 ) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT '', CHANGE `pn_url` `url` VARCHAR( 255 ) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT '', CHANGE `pn_obj_status` `obj_status` CHAR( 1 ) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT 'A', CHANGE `pn_cr_date` `cr_date` DATETIME NOT NULL DEFAULT '1970-01-01 00:00:00', CHANGE `pn_cr_uid` `cr_uid` INT( 11 ) NOT NULL DEFAULT '0', CHANGE `pn_lu_date` `lu_date` DATETIME NOT NULL DEFAULT '1970-01-01 00:00:00', CHANGE `pn_lu_uid` `lu_uid` INT( 11 ) NOT NULL DEFAULT '0'"; foreach ($sqlStatements as $sql) { $stmt = $connection->prepare($sql); try { $stmt->execute(); } catch (Exception $e) { } } case '2.6.0': $this->delVar('feedsperpage'); case '2.6.1': // further upgrade routine } // update successful return true; }
public function install() { ModUtil::setVars($this->serviceId, $this->getDefaults()); return true; }
/** * Get the theme variables from both the DB and the .yml file. * @return array|string */ public function getThemeVars() { $dbVars = \ModUtil::getVar($this->name); $defaultVars = $this->getDefaultThemeVars(); $combinedVars = array_merge($defaultVars, $dbVars); if (array_keys($dbVars) != array_keys($combinedVars)) { // First load of file or vars have been added to the .yml file. \ModUtil::setVars($this->name, $combinedVars); } return $combinedVars; }
/** * Update the module configuration * @author: Albert Pérez Monfort (aperezm@xtec.cat) * @return: True if success or false in other case */ public function updateconfig($args) { $check = ModUtil::func('Files', 'user', 'checkingModule'); if ($check['status'] != 'ok') { $this->view->assign('check', $check); return $this->view->fetch('Files_user_failedConf.tpl'); } $folderPath = $check['folderPath']; // Get parameters from whatever input we need. $showHideFiles = FormUtil::getPassedValue('showHideFiles', isset($args['showHideFiles']) ? $args['showHideFiles'] : 0, 'POST'); $usersFolder = FormUtil::getPassedValue('usersFolder', isset($args['usersFolder']) ? $args['usersFolder'] : null, 'POST'); $allowedExtensions = FormUtil::getPassedValue('allowedExtensions', isset($args['allowedExtensions']) ? $args['allowedExtensions'] : null, 'POST'); $defaultQuota = FormUtil::getPassedValue('defaultQuota', isset($args['defaultQuota']) ? $args['defaultQuota'] : null, 'POST'); $filesMaxSize = FormUtil::getPassedValue('filesMaxSize', isset($args['filesMaxSize']) ? $args['filesMaxSize'] : null, 'POST'); $maxWidth = FormUtil::getPassedValue('maxWidth', isset($args['maxWidth']) ? $args['maxWidth'] : null, 'POST'); $maxHeight = FormUtil::getPassedValue('maxHeight', isset($args['maxHeight']) ? $args['maxHeight'] : null, 'POST'); $editableExtensions = FormUtil::getPassedValue('editableExtensions', isset($args['editableExtensions']) ? $args['editableExtensions'] : null, 'POST'); $defaultPublic = FormUtil::getPassedValue('defaultPublic', $args['defaultPublic']==1 ? $args['defaultPublic'] : 0, 'POST'); $scribite_v4 = FormUtil::getPassedValue('scribite_v4', $args['scribite_v4']== true ? true : false, 'POST'); $scribite_v5 = FormUtil::getPassedValue('scribite_v5', $args['scribite_v5']== true ? true : false, 'POST'); $scribite_v4_name = FormUtil::getPassedValue('scribite_v4_name', isset($args['scribite_v4_name']) ? $args['scribite_v4_name'] : '', 'POST'); $scribite_v5_name = FormUtil::getPassedValue('scribite_v5_name', isset($args['scribite_v5_name']) ? $args['scribite_v5_name'] : '', 'POST'); // Security check if (!SecurityUtil::checkPermission('Files::', '::', ACCESS_ADMIN)) { return LogUtil::registerPermissionError(); } // Confirm authorisation code $this->checkCsrfToken(); $moduleVars = array('showHideFiles' => $showHideFiles, 'allowedExtensions' => $allowedExtensions, 'defaultQuota' => $defaultQuota, 'filesMaxSize' => $filesMaxSize, 'maxWidth' => $maxWidth, 'maxHeight' => $maxHeight, 'editableExtensions' => $editableExtensions, 'defaultPublic' => $defaultPublic, 'scribite_v4' => $scribite_v4, 'scribite_v5' => $scribite_v5, 'scribite_v4_name' => $scribite_v4_name, 'scribite_v5_name' => $scribite_v5_name); if ($usersFolder == '' || $usersFolder == null) { LogUtil::registerError($this->__("Users folder can't be empty")); return System::redirect(ModUtil::url('Files', 'admin', 'main')); } $usersFolder = (substr($usersFolder, -1) == '/') ? substr($usersFolder, 0, strlen($usersFolder) - 1) : $usersFolder; $usersFolder = (substr($usersFolder, 0, 1) == '/') ? substr($usersFolder, 1, strlen($usersFolder)) : $usersFolder; $moduleVars['usersFolder'] = $usersFolder; ModUtil::setVars('Files', $moduleVars); LogUtil::registerStatus($this->__('The configuration has been updated')); // This function generated no output, and so now it is complete we redirect // the user to an appropriate page for them to carry on their work return System::redirect(ModUtil::url('Files', 'admin', 'main')); }
/** * This is a standard function to update the configuration parameters of the * module given the information passed back by the modification form. * * @see Admin_admin_modifyconfig() * @param int $modulesperrow the number of modules to display per row in the admin panel * @param int $admingraphic switch for display of admin icons * @param int $modulename,... the id of the category to set for each module * @return string HTML string */ public function updateconfig() { $this->checkCsrfToken(); if (!SecurityUtil::checkPermission('Admin::', '::', ACCESS_ADMIN)) { return LogUtil::registerPermissionError(); } // get module vars $modvars = FormUtil::getPassedValue('modvars', null, 'POST'); // check module vars $modvars['modulesperrow'] = isset($modvars['modulesperrow']) ? $modvars['modulesperrow'] : 5; if (!is_numeric($modvars['modulesperrow'])) { unset($modvars['modulesperrow']); LogUtil::registerError($this->__("Error! You must enter a number for the 'Modules per row' setting.")); } $modvars['ignoreinstallercheck'] = isset($modvars['ignoreinstallercheck']) ? $modvars['ignoreinstallercheck'] : false; $modvars['itemsperpage'] = isset($modvars['itemsperpage']) ? $modvars['itemsperpage'] : 5; if (!is_numeric($modvars['itemsperpage'])) { unset($modvars['itemsperpage']); LogUtil::registerError($this->__("Error! You must enter a number for the 'Modules per page' setting.")); } $modvars['admingraphic'] = isset($modvars['admingraphic']) ? $modvars['admingraphic'] : 0; $modvars['displaynametype'] = isset($modvars['displaynametype']) ? $modvars['displaynametype'] : 1; $modvars['startcategory'] = isset($modvars['startcategory']) ? $modvars['startcategory'] : 1; $modvars['defaultcategory'] = isset($modvars['defaultcategory']) ? $modvars['defaultcategory'] : 1; $modvars['admintheme'] = isset($modvars['admintheme']) ? $modvars['admintheme'] : null; // save module vars ModUtil::setVars('Admin', $modvars); // get admin modules $adminmodules = ModUtil::getAdminMods(); $adminmods = FormUtil::getPassedValue('adminmods', null, 'POST'); foreach ($adminmodules as $adminmodule) { $category = $adminmods[$adminmodule['name']]; if ($category) { // Add the module to the category $result = ModUtil::apiFunc('Admin', 'admin', 'addmodtocategory', array('module' => $adminmodule['name'], 'category' => $category)); if ($result == false) { LogUtil::registerError($this->__('Error! Could not add module to module category.')); $this->redirect(ModUtil::url('Admin', 'admin', 'view')); } } } // the module configuration has been updated successfuly LogUtil::registerStatus($this->__('Done! Saved module configuration.')); // This function generated no output, and so now it is complete we redirect // the user to an appropriate page for them to carry on their work $this->redirect(ModUtil::url('Admin', 'admin', 'view')); }
/** * upgrade to 1.3 * */ function _addressbook_upgradeto_1_3() { $oldvars = ModUtil::getVar('Addressbook'); foreach ($oldvars as $varname => $oldvar) { ModUtil::delVar('AddressBook', $varname, $oldvar); } ModUtil::setVars('AddressBook', $oldvars); return true; }
/** * The pnModSetVars function sets multiple module variables. * * @deprecated * @see ModUtil::setVars() * * @param string $modname The name of the module. * @param array $vars An associative array of varnames/varvalues. * * @return boolean True if successful, false otherwise. */ function pnModSetVars($modname, $vars) { LogUtil::log(__f('Warning! Function %1$s is deprecated. Please use %2$s instead.', array(__FUNCTION__, 'ModUtil::setVars()')), E_USER_DEPRECATED); return ModUtil::setVars($modname, $vars); }
/** * Command event handler. * * This event handler is called when a command is issued by the user. Commands are typically something * that originates from a {@link Zikula_Form_Plugin_Button} plugin. The passed args contains different properties * depending on the command source, but you should at least find a <var>$args['commandName']</var> * value indicating the name of the command. The command name is normally specified by the plugin * that initiated the command. * @see Zikula_Form_Plugin_Button * @see Zikula_Form_Plugin_ImageButton */ public function handleCommand(Zikula_Form_View $view, &$args) { if ($args['commandName'] == 'save') { // check if all fields are valid if (!$this->view->isValid()) { return false; } // retrieve form data $data = $this->view->getValues(); // update all module vars if (!ModUtil::setVars('MUBoard', $data['config'])) { return LogUtil::registerError($this->__('Error! Failed to set configuration variables.')); } LogUtil::registerStatus($this->__('Done! Module configuration updated.')); } else { if ($args['commandName'] == 'cancel') { // nothing to do there } } // redirect back to the config page $url = ModUtil::url('MUBoard', 'admin', 'config'); return $this->view->redirect($url); }