本文整理汇总了PHP中ModUtil::setVar方法的典型用法代码示例。如果您正苦于以下问题:PHP ModUtil::setVar方法的具体用法?PHP ModUtil::setVar怎么用?PHP ModUtil::setVar使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ModUtil
的用法示例。
在下文中一共展示了ModUtil::setVar方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: confupdate
/**
* Update the configuration values
* @author: Sara Arjona Téllez (sarjona@xtec.cat)
* @params The config values from the form
* @return Thue if success
*/
public function confupdate($args) {
$skins = FormUtil::getPassedValue('skins', isset($args['skins']) ? $args['skins'] : null, 'POST');
$langs = FormUtil::getPassedValue('langs', isset($args['langs']) ? $args['langs'] : null, 'POST');
$maxdelivers = FormUtil::getPassedValue('maxdelivers', isset($args['maxdelivers']) ? $args['maxdelivers'] : null, 'POST');
$basedisturl = FormUtil::getPassedValue('basedisturl', isset($args['basedisturl']) ? $args['basedisturl'] : null, 'POST');
// Security check
if (!SecurityUtil::checkPermission('IWqv::', "::", ACCESS_ADMIN)) {
throw new Zikula_Exception_Forbidden();
}
// Confirm authorisation code
$this->checkCsrfToken();
if (isset($skins))
ModUtil::setVar('IWqv', 'skins', $skins);
if (isset($langs))
ModUtil::setVar('IWqv', 'langs', $langs);
if (isset($maxdelivers))
ModUtil::setVar('IWqv', 'maxdelivers', $maxdelivers);
if (isset($basedisturl))
ModUtil::setVar('IWqv', 'basedisturl', $basedisturl);
LogUtil::registerStatus($this->__f('Done! %1$s updated.', $this->__('settings')));
return System::redirect(ModUtil::url('IWqv', 'admin', 'main'));
}
示例2: changeGroup
public function changeGroup($args) {
$gid = FormUtil::getPassedValue('gid', isset($args['gid']) ? $args['gid'] : null, 'POST');
$groups = FormUtil::getPassedValue('groups', isset($args['groups']) ? $args['groups'] : null, 'POST');
// Security check
if (!SecurityUtil::checkPermission('IWmyrole::', "::", ACCESS_ADMIN)) {
throw new Zikula_Exception_Forbidden();
}
$this->checkCsrfToken();
$groupsString = '$';
foreach ($groups as $group) {
$groupsString .= '$' . $group . '$';
}
if ($gid) {
// Modify the permissions in group_perms
$changePerms = ModUtil::apiFunc('IWmyrole', 'admin', 'changePermissions',
array('gid' => $gid));
if ($changePerms) {
//Update module var with new value
ModUtil::setVar('IWmyrole', 'rolegroup', $gid);
LogUtil::registerStatus($this->__('The group change has been made.'));
} else {
LogUtil::registerError($this->__('The group change has not been made.'));
}
}
$this->setVar('groupsNotChangeable', $groupsString);
return System::redirect(ModUtil::url('IWmyrole', 'admin', 'main'));
}
示例3: upgrade
/**
* Avatar_upgrade()
*
* Upgrade the Module
*
* @param integer $oldversion old version of the module
* @return boolean success or not
**/
public function upgrade($oldversion)
{
// Upgrade dependent on old version number
switch ($oldversion) {
case '1.1':
$this->delVar('prefix_group_1');
$this->delVar('prefix_group_2');
$this->delVar('prefix_group_3');
$this->delVar('prefix_prefix_1');
$this->delVar('prefix_prefix_2');
$this->delVar('prefix_prefix_3');
$this->setVar('allow_multiple', true);
// for PHP5: if jpg is allowed, also allow jpeg if needed
// this is needed because image_type_to_extension() always returns 'jpeg' in case
// of jpg images in PHP5
$exts = explode(';', $this->getVar('allowed_extensions'));
if (is_array($exts) && in_array('jpg', $exts) && !in_array('jpeg', $exts)) {
$exts[] = 'jpeg';
$this->setVar('allowed_extensions', implode(';', $exts));
}
case '2.0':
case '2.1':
ModUtil::setVar('Users', 'avatarpath', ModUtil::getVar('Avatar', 'avatardir'));
$this->delVar('avatardir');
case '2.2':
}
return true;
}
示例4: install
public function install()
{
if (!SecurityUtil::checkPermission('Files::', '::', ACCESS_ADMIN)) {
return LogUtil::registerPermissionError();
}
// set content of the files .htaccess and .locked
$htaccessContent = "# Avoid direct web access to folder files\r\nOrder deny,allow\r\nDeny from all\r\n";
$lockedContent = "# Avoid direct web access with the file file.php\r\n";
// Create module table
if (!DBUtil::createTable('Files')) {
return false;
}
//Create indexes
$pntable = DBUtil::getTables();
$c = $pntable['Files_column'];
DBUtil::createIndex($c['userId'], 'Files', 'userId');
// create security files
FileUtil::writeFile(ModUtil::getVar('Files', 'folderPath') . '/.htaccess', $htaccessContent, true);
FileUtil::writeFile(ModUtil::getVar('Files', 'folderPath') . '/.locked', $lockedContent, true);
FileUtil::writeFile(ModUtil::getVar('Files', 'folderPath') . '/' . ModUtil::getVar('Files', 'usersFolder') . '/.htaccess', $htaccessContent, true);
FileUtil::writeFile(ModUtil::getVar('Files', 'folderPath') . '/' . ModUtil::getVar('Files', 'usersFolder') . '/.locked', $lockedContent, true);
//Create module vars
ModUtil::setVar('Files', 'showHideFiles', '0');
ModUtil::setVar('Files', 'allowedExtensions', 'gif,png,jpg,odt,doc,pdf,zip');
ModUtil::setVar('Files', 'defaultQuota', 1);
ModUtil::setVar('Files', 'groupsQuota', 's:0:"";');
ModUtil::setVar('Files', 'filesMaxSize', '1000000');
ModUtil::setVar('Files', 'maxWidth', '250');
ModUtil::setVar('Files', 'maxHeight', '250');
ModUtil::setVar('Files', 'editableExtensions', 'php,htm,html,htaccess,css,js,tpl');
// Set up module hook
ModUtil::registerHook('item', 'display', 'GUI', 'Files', 'user', 'Files');
return true;
}
示例5: setDocRoot
public function setDocRoot($value)
{
$this->throwForbiddenUnless(SecurityUtil::checkPermission('Llicencies::', '::', ACCESS_ADMIN));
if (ModUtil::setVar($this->name, 'LlicenciesDocRoot', $value)){
LogUtil::registerStatus(__('El paràmetre s\'ha actualitzat correctament.'));
}
else
LogUtil::registerError(__('El paràmetre no s\'ha pogut actualitzar.'));
return true;
}
示例6: Install
/**
* Initialise the IWmenu module creating module tables and module vars
* @author Albert Perez Monfort (aperezm@xtec.cat)
* @return bool true if successful, false otherwise
*/
public function Install() {
// Checks if module IWmain is installed. If not returns error
$modid = ModUtil::getIdFromName('IWmain');
$modinfo = ModUtil::getInfo($modid);
if ($modinfo['state'] != 3) {
return LogUtil::registerError($this->__('Module IWmain is needed. You have to install the IWmain module previously to install it.'));
}
// Check if the version needed is correct
$versionNeeded = '3.0.0';
if (!ModUtil::func('IWmain', 'admin', 'checkVersion', array('version' => $versionNeeded))) {
return false;
}
// Create module table
if (!DBUtil::createTable('IWmenu'))
return false;
//Create indexes
$pntable = DBUtil::getTables();
$c = $pntable['IWmenu_column'];
if (!DBUtil::createIndex($c['id_parent'], 'IWmenu', 'id_parent'))
return false;
//Create module vars
ModUtil::setVar('IWmenu', 'height', 26); // Default height
ModUtil::setVar('IWmenu', 'width', 200); // Default width
ModUtil::setVar('IWmenu', 'imagedir', "menu"); // Default directori of menu images
// checks if module vhmenu exists. If it exists import module vhmenu tables
$modid = ModUtil::getIdFromName('IWmenu');
$modinfo = ModUtil::getInfo($modid);
if ($modinfo['state'] == 3) {
// get the objects from the db
ModUtil::load('IWvhmenu', 'user');
$items = DBUtil::selectObjectArray('IWvhmenu');
if ($items) {
foreach ($items as $item) {
$groups = str_replace('|0', '', $item['groups']);
$groups = substr($groups, 1, strlen($groups));
$itemArray = array('text' => $item['text'],
'url' => $item['url'],
'icon' => '',
'id_parent' => $item['id_parent'],
'groups' => $groups,
'active' => $item['active'],
'target' => $item['target'],
'descriu' => $item['descriu']);
DBUtil::insertObject($itemArray, 'IWmenu', 'mid');
}
}
}
return true;
}
示例7: Admin_Messages_init
/**
* initialise the Admin module
* This function is only ever called once during the lifetime of a particular
* module instance
* @author Mark West
* @return bool true if initialisation succcesful, false otherwise
*/
function Admin_Messages_init()
{
if (!DBUtil::createTable('message')) {
return false;
}
// Set a default value for a module variable
ModUtil::setVar('Admin_Messages', 'itemsperpage', 25);
ModUtil::setVar('Admin_Messages', 'allowsearchinactive', false);
// create the default data for the modules module
Admin_Messages_defaultdata();
// Initialisation successful
return true;
}
示例8: setVar
/**
* Set a configuration variable.
*
* @param string $name The name of the variable.
* @param mixed $value The value of the variable.
*
* @return boolean True on success, false on failure.
*/
public static function setVar($name, $value = '')
{
$name = isset($name) ? (string) $name : '';
// The database parameter are not allowed to change
if (empty($name) || $name == 'system' || $name == 'prefix' || in_array($name, ServiceUtil::getManager()->getParameter('protected.systemvars'))) {
return false;
}
// set the variable
if (ModUtil::setVar(ModUtil::CONFIG_MODULE, $name, $value)) {
// Update my vars
$GLOBALS['ZConfig']['System'][$name] = $value;
return true;
}
return false;
}
示例9: upgrade
/**
* Update the Files module
* @author Albert Pérez Monfort (aperezm@xtec.cat)
* @return bool true if successful, false otherwise
*/
public function upgrade($oldversion) {
switch ($oldversion) {
case '1.0.0':
$this->delVar('folderPath');
case '1.0.1':
ModUtil::setVar('Files', 'scribite_v4', false);
ModUtil::setVar('Files', 'scribite_v5', true);
ModUtil::setVar('Files', 'scribite_v4_name', 'Scribite');
ModUtil::setVar('Files', 'scribite_v5_name', 'Scribite');
case '1.0.2':
//void
case '1.0.3':
//Actual version
}
return true;
}
示例10: newVersionAvailable
public function newVersionAvailable()
{
$lastNewVersionCheck = \ModUtil::getVar('CmfcmfMediaModule', 'lastNewVersionCheck', 0);
if (time() - 24 * 60 * 60 > $lastNewVersionCheck && $this->versionChecker->checkRateLimit()) {
\ModUtil::setVar('CmfcmfMediaModule', 'lastNewVersionCheck', time());
$info = \ModUtil::getInfoFromName('CmfcmfMediaModule');
if (($release = $this->versionChecker->getReleaseToUpgradeTo($info['version'])) !== false) {
\ModUtil::setVar('CmfcmfMediaModule', 'newVersionAvailable', $release['tag_name']);
return $release['tag_name'];
}
}
$newVersionAvailable = \ModUtil::getVar('CmfcmfMediaModule', 'newVersionAvailable', false);
if ($newVersionAvailable != false) {
return $newVersionAvailable;
}
return false;
}
示例11: _generateSubclassForCategorisableTemplate
/**
* Generates an subclass of the Zikula_Doctrine_Model_EntityCategory class and caches the generated class in a file.
*
* @param string $module Name of the Module to that the model belongs to.
* @param string $modelClass Classname of the model.
*
* @return void
* @throws Exception Throws when the create of the cache directory fails.
*/
private static function _generateSubclassForCategorisableTemplate($module, $modelClass)
{
$table = Doctrine::getTable($modelClass);
sscanf($table->getTableName(), Doctrine_Manager::getInstance()->getAttribute(Doctrine::ATTR_TBLNAME_FORMAT), $tableName);
$dir = 'doctrinemodels/GeneratedDoctrineModel/' . str_replace('_', DIRECTORY_SEPARATOR, $modelClass);
if (CacheUtil::createLocalDir($dir, ServiceUtil::getManager()->getParameter('system.chmod_dir'))) {
$subclassName = 'GeneratedDoctrineModel_' . $modelClass . '_EntityCategory';
$fileContents = '<?php class ' . $subclassName . ' extends Zikula_Doctrine_Model_EntityCategory { }';
$fileName = 'EntityCategory.php';
// save new model
file_put_contents(CacheUtil::getLocalDir() . '/' . $dir . '/' . $fileName, $fileContents);
// save required data for later use
$modelsInfo = ModUtil::getVar('ZikulaCategoriesModule', 'EntityCategorySubclasses', array());
$modelsInfo[$subclassName] = array('module' => $module, 'table' => $tableName);
ModUtil::setVar('ZikulaCategoriesModule', 'EntityCategorySubclasses', $modelsInfo);
} else {
throw new Exception('Creation of the cache directory ' . $dir . ' failed');
}
}
示例12: install
public function install(){
if (!SecurityUtil::checkPermission('Llicencies::', '::', ACCESS_ADMIN)) {
return LogUtil::registerPermissionError();
}
// Crear les taules del mòdul
if (!DBUtil::createTable('llicencies')||
!DBUtil::createTable('llicencies_curs')||
!DBUtil::createTable('llicencies_tema')||
!DBUtil::createTable('llicencies_subtema')||
!DBUtil::createTable('llicencies_tipus')||
!DBUtil::createTable('llicencies_modalitat')||
!DBUtil::createTable('llicencies_estats')
)
return false;
ModUtil::setVar($this->name, 'LlicenciesDocRoot', "http://www.xtec.es/sgfp/llicencies/");
//Successfull
return true;
}
示例13: modifyoverrides
/**
* Create/modify/delete module or textarea overrides
* template uses ajax to create/modify/delete rows
*
* @return string (html)
*/
public function modifyoverrides()
{
$this->throwForbiddenUnless(SecurityUtil::checkPermission('Scribite::', '::', ACCESS_ADMIN), LogUtil::getErrorMsgPermission());
// get hookable modules (subscribers)
$hookSubscribers = HookUtil::getHookSubscribers();
$modulelist = array();
foreach ($hookSubscribers as $module) {
$modulelist[$module['name']] = $module['displayname'];
}
$this->view->assign('moduleList', $modulelist);
// provide default values if none exists
$overrides = ModUtil::getVar('Scribite', 'overrides');
if (empty($overrides)) {
ModUtil::setVar('Scribite', 'overrides', array());
}
// get all editors
$editorList = ModUtil::apiFunc('Scribite', 'admin', 'getEditors');
$this->view->assign('editorList', $editorList);
return $this->view->fetch('admin/modifyoverrides.tpl');
}
示例14: Install
/**
* Initialise the IWbookings module creating module tables and module vars
* @author Albert Pérez Monfort (aperezm@xtec.cat)
* @author Josep Ferràndiz Farré (jferran6@xtec.cat)
* @return bool true if successful, false otherwise
*/
public function Install() {
// Checks if module IWmain is installed. If not returns error
$modid = ModUtil::getIdFromName('IWmain');
$modinfo = ModUtil::getInfo($modid);
if ($modinfo['state'] != 3) {
return LogUtil::registerError($this->__('Module IWmain is required. You have to install the IWmain module previously to install it.'));
}
// Check if the version needed is correct
$versionNeeded = '3.0.0';
if (!ModUtil::func('IWmain', 'admin', 'checkVersion', array('version' => $versionNeeded))) {
return false;
}
// Create module tables
if (!DBUtil::createTable('IWbookings'))
return false;
if (!DBUtil::createTable('IWbookings_spaces'))
return false;
//Create indexes
$pntable = DBUtil::getTables();
$c = $pntable['IWbookings_column'];
if (!DBUtil::createIndex($c['sid'], 'IWbookings', 'sid'))
return false;
if (!DBUtil::createIndex($c['start'], 'IWbookings', 'start'))
return false;
//Create module vars
ModUtil::setVar('IWbookings', 'group', ''); //grup
ModUtil::setVar('IWbookings', 'weeks', '1'); // setmanes
ModUtil::setVar('IWbookings', 'month_panel', '0'); // taula_mes
ModUtil::setVar('IWbookings', 'weekends', '0'); // capssetmana
ModUtil::setVar('IWbookings', 'eraseold', '1'); // delantigues
ModUtil::setVar('IWbookings', 'showcolors', '0'); // mostracolors
ModUtil::setVar('IWbookings', 'NTPtime', '0');
//Initialation successfull
return true;
}
示例15: handleCommand
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'));
}
$layoutDisplay = ModUtil::getVar('Content', 'layoutDisplay');
foreach ($layoutDisplay as $k => $layout) {
$layoutDisplay[$k]['display'] = in_array($layout['name'], $data['layoutDisplaySelection']);
}
if (!ModUtil::setVar('Content', 'layoutDisplay', $layoutDisplay)) {
return $this->view->setErrorMsg($this->__('Failed to set layoutDisplay 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);
}