Пример #1
0
    /**
     * 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
0
    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
0
 /**
  * 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
0
 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
0
 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
0
    /**
     * 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
0
/**
 * 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
0
 /**
  * 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
0
    /**
     * 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
0
 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
0
 /**
  * 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
0
    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
0
 /**
  * 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
0
    /**
     * 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
0
 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);
 }
Пример #16
0
 function handleCommand(Zikula_Form_View $view, &$args)
 {
     // Security check
     if (!SecurityUtil::checkPermission('Avatar::', '::', ACCESS_ADMIN)) {
         return LogUtil::registerPermissionError();
     }
     if ($args['commandName'] == 'submit') {
         if (!$view->IsValid()) {
             return false;
         }
         $data = $view->getValues();
         if (array_key_exists('forumdir', $data)) {
             ModUtil::setVar('Avatar', 'forumdir', $data['forumdir']);
         }
         ModUtil::setVar('Users', 'avatarpath', $data['avatarpath']);
         ModUtil::setVar('Avatar', 'allow_resize', $data['allow_resize']);
         ModUtil::setVar('Avatar', 'maxsize', $data['maxsize']);
         ModUtil::setVar('Avatar', 'maxheight', $data['maxheight']);
         ModUtil::setVar('Avatar', 'maxwidth', $data['maxwidth']);
         ModUtil::setVar('Avatar', 'allowed_extensions', $data['allowed_extensions']);
         ModUtil::setVar('Avatar', 'allow_multiple', $data['allow_multiple']);
     }
     return true;
 }
Пример #17
0
    /**
     * This is a standard function to update the configuration parameters of the
     * module given the information passed back by the modification form
     * @author Francesc Bassas i Bullich
     * @return bool true if update successful
     */
    public function updateconfig() {
        // security check
        if (!SecurityUtil::checkPermission('SiriusXtecMailer::', '::', ACCESS_ADMIN)) {
            return LogUtil::registerPermissionError();
        }

        // Confirm authorisation code
        $this->checkCsrfToken();

        // set our new module variable values
        $enabled = FormUtil::getPassedValue('enabled', '', 'POST');
        ModUtil::setVar('SiriusXtecMailer', 'enabled', $enabled);
        $idApp = FormUtil::getPassedValue('idApp', '', 'POST');
        ModUtil::setVar('SiriusXtecMailer', 'idApp', $idApp);
        $replyAddress = FormUtil::getPassedValue('replyAddress', '', 'POST');
        ModUtil::setVar('SiriusXtecMailer', 'replyAddress', $replyAddress);
        $sender = FormUtil::getPassedValue('sender', '', 'POST');
        ModUtil::setVar('SiriusXtecMailer', 'sender', $sender);
        $environment = FormUtil::getPassedValue('environment', '', 'POST');
        ModUtil::setVar('SiriusXtecMailer', 'environment', $environment);
        $contenttype = FormUtil::getPassedValue('contenttype', '', 'POST');
        ModUtil::setVar('SiriusXtecMailer', 'contenttype', $contenttype);
        $log = FormUtil::getPassedValue('log', '', 'POST');
        ModUtil::setVar('SiriusXtecMailer', 'log', $log);
        $debug = FormUtil::getPassedValue('debug', '', 'POST');
        ModUtil::setVar('SiriusXtecMailer', 'debug', $debug);
        $logpath = FormUtil::getPassedValue('logpath', '', 'POST');
        ModUtil::setVar('SiriusXtecMailer', 'logpath', $logpath);

        // the module configuration has been updated successfuly
        LogUtil::registerStatus(__('Done! Module configuration updated.', $dom));

        // 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('SiriusXtecMailer', 'admin', 'main'));
    }
Пример #18
0
    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->__('The modul IWmain must be installed. Install it, for install this modul.'));
        }

        // Check if the version needed is correct
        $versionNeeded = '2.0';
        if (!ModUtil::func('IWmain', 'admin', 'checkVersion', array('version' => $versionNeeded))) {
            return false;
        }

        // Create module tables
        if (!DBUtil::createTable('IWqv'))
            return false;
        if (!DBUtil::createTable('IWqv_assignments'))
            return false;
        if (!DBUtil::createTable('IWqv_sections'))
            return false;
        if (!DBUtil::createTable('IWqv_messages'))
            return false;
        if (!DBUtil::createTable('IWqv_messages_read'))
            return false;

        //Create module vars
        ModUtil::setVar('IWqv', 'skins', 'default,infantil,formal');
        ModUtil::setVar('IWqv', 'langs', 'ca,es,en');
        ModUtil::setVar('IWqv', 'maxdelivers', '-1,1,2,3,4,5,10');
        ModUtil::setVar('IWqv', 'basedisturl', 'http://clic.xtec.cat/qv_viewer/dist/html/');

        //Initialization successfull 
        return true;
    }
Пример #19
0
    /**
     * Gets user news
     *
     * @author	Albert Pérez Monfort (aperezm@xtec.cat)
     * @return	The user news block
     */
    public function display($row) {
        // Security check
        if (!SecurityUtil::checkPermission('IWmain:newsBlock:', $row['title'] . "::", ACCESS_READ) || !UserUtil::isLoggedIn()) {
            return false;
        }

        if (ModUtil::getVar('IWmain', 'URLBase') != System::getBaseUrl()) {
            ModUtil::setVar('IWmain', 'URLBase', System::getBaseUrl());
        }

        $uid = UserUtil::getVar('uid');

        //get the headlines saved in the user vars. It is renovate every 10 minutes
        $sv = ModUtil::func('IWmain', 'user', 'genSecurityValue');
        $exists = ModUtil::apiFunc('IWmain', 'user', 'userVarExists', array('name' => 'news',
                    'module' => 'IWmain_block_news',
                    'uid' => $uid,
                    'sv' => $sv));

        if ($exists) {
            $sv = ModUtil::func('IWmain', 'user', 'genSecurityValue');
            $have_news = ModUtil::func('IWmain', 'user', 'userGetVar', array('uid' => $uid,
                        'name' => 'have_news',
                        'module' => 'IWmain_block_news',
                        'sv' => $sv));
            if ($have_news != '0') {
                ModUtil::func('IWmain', 'user', 'news', array('where' => $have_news));
                $sv = ModUtil::func('IWmain', 'user', 'genSecurityValue');
                ModUtil::func('IWmain', 'user', 'userSetVar', array('uid' => $uid,
                    'name' => 'have_news',
                    'module' => 'IWmain_block_news',
                    'sv' => $sv,
                    'value' => '0'));
            }

            $sv = ModUtil::func('IWmain', 'user', 'genSecurityValue');
            $have_flags = ModUtil::func('IWmain', 'user', 'userGetVar', array('uid' => UserUtil::getVar('uid'),
                        'name' => 'have_flags',
                        'module' => 'IWmain_block_flagged',
                        'sv' => $sv));

            if ($have_flags != '0') {
                ModUtil::func('IWmain', 'user', 'flagged', array('where' => $have_flags,
                    'chars' => 15));


                $sv = ModUtil::func('IWmain', 'user', 'genSecurityValue');
                ModUtil::func('IWmain', 'user', 'userSetVar', array('uid' => UserUtil::getVar('uid'),
                    'name' => 'have_flags',
                    'module' => 'IWmain_block_flagged',
                    'sv' => $sv,
                    'value' => '0'));
            }
        } else {
            ModUtil::func('IWmain', 'user', 'news');
        }

        //get the flagged items
        $sv = ModUtil::func('IWmain', 'user', 'genSecurityValue');
        if (!$exists = ModUtil::apiFunc('IWmain', 'user', 'userVarExists', array('name' => 'flagged',
                    'module' => 'IWmain_block_flagged',
                    'uid' => $uid,
                    'sv' => $sv))) {
            ModUtil::func('IWmain', 'user', 'flagged', array('where' => '',
                'chars' => 15));
        }

        $sv = ModUtil::func('IWmain', 'user', 'genSecurityValue');
        $news = ModUtil::func('IWmain', 'user', 'userGetVar', array('uid' => $uid,
                    'name' => 'news',
                    'module' => 'IWmain_block_news',
                    'sv' => $sv,
                    'nult' => true));

        $sv = ModUtil::func('IWmain', 'user', 'genSecurityValue');
        $flags = ModUtil::func('IWmain', 'user', 'userGetVar', array('uid' => UserUtil::getVar('uid'),
                    'name' => 'flagged',
                    'module' => 'IWmain_block_flagged',
                    'sv' => $sv,
                    'nult' => true));

        $this->view->assign('news', $news)
                ->assign('flags', $flags);

        $s = $this->view->fetch('IWmain_block_IWnews.tpl');

        $row['content'] = $s;
        return BlockUtil::themesideblock($row);
    }
Пример #20
0
 /**
  * Upgrade ephemerides module
  * @author The Zikula Development Team
  * @return true if init successful, false otherwise
  */
 public function upgrade($oldversion)
 {
     // upgrade dependent on old version number
     switch ($oldversion) {
         case '1.2':
             // version 1.2 shipped with postnuke .72x/.75
             ModUtil::setVar('Ephemerides', 'itemsperpage', 25);
         case '1.6':
             $this->ephemerides_upgrade_updateEphemeridesLanguages();
         case '1.7':
             // needs update of table, added status column
         // needs update of table, added status column
         case '1.8':
             // needs update of table, added type column
         // needs update of table, added type column
         case '1.9':
             $connection = Doctrine_Manager::getInstance()->getConnection('default');
             // drop table prefix
             $prefix = $this->serviceManager['prefix'];
             $sqlQueries = array();
             $sqlQueries[] = 'RENAME TABLE ' . $prefix . '_ephem' . " TO `ephem`";
             $sqlQueries[] = "ALTER TABLE `ephem` CHANGE `pn_eid` `eid` INT(11) NOT NULL AUTO_INCREMENT";
             $sqlQueries[] = "ALTER TABLE `ephem` CHANGE `pn_did` `did` TINYINT(4) NOT NULL DEFAULT '0'";
             $sqlQueries[] = "ALTER TABLE `ephem` CHANGE `pn_mid` `mid` TINYINT(4) NOT NULL DEFAULT '0'";
             $sqlQueries[] = "ALTER TABLE `ephem` CHANGE `pn_yid` `yid` SMALLINT(6) NOT NULL DEFAULT '0'";
             $sqlQueries[] = "ALTER TABLE `ephem` CHANGE `pn_content` `content` TEXT CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL";
             $sqlQueries[] = "ALTER TABLE `ephem` CHANGE `pn_language` `language` VARCHAR(30) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT ''";
             $sqlQueries[] = "ALTER TABLE `ephem` CHANGE `pn_obj_status` `obj_status` VARCHAR(1) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT 'A'";
             $sqlQueries[] = "ALTER TABLE `ephem` CHANGE `pn_cr_date` `cr_date` DATETIME NOT NULL DEFAULT '1970-01-01 00:00:00'";
             $sqlQueries[] = "ALTER TABLE `ephem` CHANGE `pn_cr_uid` `cr_uid` INT(11) NOT NULL DEFAULT '0'";
             $sqlQueries[] = "ALTER TABLE `ephem` CHANGE `pn_lu_date` `lu_date` DATETIME NOT NULL DEFAULT '1970-01-01 00:00:00'";
             $sqlQueries[] = "ALTER TABLE `ephem` CHANGE `pn_lu_uid` `lu_uid` INT(11) NOT NULL DEFAULT '0'";
             $sqlQueries[] = "ALTER TABLE `ephem` CHANGE `pn_status` `status` TINYINT(4) NULL DEFAULT '1'";
             $sqlQueries[] = "ALTER TABLE `ephem` CHANGE `pn_type` `type` TINYINT(4) NULL DEFAULT '1'";
             foreach ($sqlQueries as $sql) {
                 $stmt = $connection->prepare($sql);
                 try {
                     $stmt->execute();
                 } catch (Exception $e) {
                 }
             }
             // update table structure according to table defenition
             if (!DBUtil::changeTable('ephem')) {
                 return "1.9";
             }
             // enable categorisation this module
             ModUtil::setVar('Ephemerides', 'enablecategorization', true);
             // 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;
             }
         case '3.0.0':
             $connection = Doctrine_Manager::getInstance()->getConnection('default');
             // Change module name from Ephemerids to Ephemerides
             $sqlQueries = array();
             $sqlQueries[] = "UPDATE `modules` SET `name`='Ephemerides', `directory`='Ephemerides', `securityschema`='a:1:{s:13:\"Ephemerides::\";s:14:\"::Ephemerid ID\";}' WHERE `directory`='Ephemerids';";
             $sqlQueries[] = "UPDATE `module_vars` SET `modname`='Ephemerides' WHERE `modname`='Ephemerids';";
             foreach ($sqlQueries as $sql) {
                 $stmt = $connection->prepare($sql);
                 try {
                     $stmt->execute();
                 } catch (Exception $e) {
                 }
             }
             // Register hooks
             $sqlQueries = array();
             $sqlQueries[] = 'DELETE FROM `hook_area` WHERE `owner`="Ephemerides"';
             $sqlQueries[] = 'DELETE FROM `hook_subscriber` WHERE `owner`="Ephemerides"';
             $sqlQueries[] = 'DELETE FROM `hook_provider` WHERE `owner`="Ephemerides"';
             foreach ($sqlQueries as $sql) {
                 $stmt = $connection->prepare($sql);
                 try {
                     $stmt->execute();
                 } catch (Exception $e) {
                 }
             }
             HookUtil::registerSubscriberBundles($this->version->getHookSubscriberBundles());
             HookUtil::registerProviderBundles($this->version->getHookProviderBundles());
         case '3.1.0':
             ModUtil::setVar('Ephemerides', 'enablefacebookshare', false);
         case '3.1.1':
             // future upgrade routines
     }
     // upgrade success
     return true;
 }
Пример #21
0
 /**
  * Set plugin state.
  *
  * @param string   $name  Plugin name.
  * @param constant $value Plugin state.
  *
  * @return boolean
  */
 public static function setState($name, $value)
 {
     return ModUtil::setVar(self::CONFIG, $name, $value);
 }
Пример #22
0
    /**
     * Purge the permalink fields in the Feeds table
     * @return bool true on success, false on failure
     */
    public function purgepermalinks($args)
    {
        // Security check
        if (!SecurityUtil::checkPermission('Feeds::', '::', ACCESS_ADMIN)) {
            return LogUtil::registerPermissionError();
        }

        // disable categorization to do this (if enabled)
        $catenabled = ModUtil::getVar('Feeds', 'enablecategorization');
        if ($catenabled) {
            ModUtil::setVar('Feeds', 'enablecategorization', false);
            ModUtil::dbInfoLoad('Feeds', 'Feeds', true);
        }

        // get all the ID and permalink of the table
        $data = DBUtil::selectObjectArray('feeds', '', '', -1, -1, 'fid', null, null, array('fid', 'urltitle'));

        // loop the data searching for non equal permalinks
        $perma = '';
        foreach (array_keys($data) as $fid) {
            $perma = strtolower(DataUtil::formatPermalink($data[$fid]['urltitle']));
            if ($data[$fid]['urltitle'] != $perma) {
                $data[$fid]['urltitle'] = $perma;
            } else {
                unset($data[$fid]);
            }
        }

        // restore the categorization if was enabled
        if ($catenabled) {
            ModUtil::setVar('Feeds', 'enablecategorization', true);
        }

        if (empty($data)) {
            return true;
            // store the modified permalinks
        } elseif (DBUtil::updateObjectArray($data, 'feeds', 'fid')) {
            // Let the calling process know that we have finished successfully
            return true;
        } else {
            return false;
        }
    }
Пример #23
0
 /**
  * Convenience Module SetVar.
  *
  * @param string $key   Key.
  * @param mixed  $value Value, default empty.
  *
  * @return object This.
  */
 public function setVar($key, $value='')
 {
     ModUtil::setVar($this->name, $key, $value);
     return $this;
 }
Пример #24
0
    /**
     * Update the module vars with the properties of the menu
     * @author:     Albert Pï¿œrez Monfort (aperezm@xtec.cat)
     * @param:	Array with the form information needed
     * @return:	True if success
     */
    public function conf_update($args) {
        // Get parameters from whatever input we need
        $width = FormUtil::getPassedValue('width', isset($args['width']) ? $args['width'] : null, 'POST');
        $imagedir = FormUtil::getPassedValue('imagedir', isset($args['imagedir']) ? $args['imagedir'] : null, 'POST');

        // Security check
        if (!SecurityUtil::checkPermission('IWmenu::', '::', ACCESS_ADMIN)) {
            throw new Zikula_Exception_Forbidden();
        }

        // Confirm authorisation code
        $this->checkCsrfToken();

        ModUtil::setVar('IWmenu', 'width', $width);
        ModUtil::setVar('IWmenu', 'imagedir', $imagedir);

        LogUtil::registerStatus($this->__('Menu configuration completed successfully'));

        // Reset the users menus for all users
        $sv = ModUtil::func('IWmain', 'user', 'genSecurityValue');
        ModUtil::func('IWmain', 'user', 'usersVarsDelModule', array('module' => 'IWmenu',
            'name' => 'userMenu',
            'sv' => $sv));

        // Redirect to admin config page
        return System::redirect(ModUtil::url('IWmenu', 'admin', 'conf'));
    }
Пример #25
0
    /**
     * Edit an agenda event
     *
     * @param array $args Information about the current event
     *
     * @return Return user to the agenda
     */
    public function editar($args) {
        // Security check
        $this->throwForbiddenUnless(SecurityUtil::checkPermission('IWagendas::', '::', ACCESS_READ));

        $aid = FormUtil::getPassedValue('aid', isset($args['aid']) ? $args['aid'] : null, 'GET');
        $daid = FormUtil::getPassedValue('daid', isset($args['daid']) ? $args['daid'] : null, 'GET');
        $mes = FormUtil::getPassedValue('mes', isset($args['mes']) ? $args['mes'] : null, 'GET');
        $any = FormUtil::getPassedValue('any', isset($args['any']) ? $args['any'] : null, 'GET');
        $dia = FormUtil::getPassedValue('dia', isset($args['dia']) ? $args['dia'] : null, 'GET');

        // Default value
        if (!isset($aid) || !is_numeric($aid)) {
            LogUtil::registerError($this->__('Error! Could not do what you wanted. Please check your input.'));
            return System::redirect(ModUtil::url('IWagendas', 'user', 'main'));
        }
        // Get the info of the annotation
        $anotacio = ModUtil::apiFunc('IWagendas', 'user', 'get', array('aid' => $aid));
        if ($anotacio == false) {
            LogUtil::registerError($this->__('Event not found'));
            return System::redirect(ModUtil::url('IWagendas', 'user', 'main'));
        }
        //Check if the user connected has made the note
        $a = ($anotacio['usuari'] == UserUtil::getVar('uid')) ? true : false;
        // Get the agenda ID
        $daid = $anotacio['daid'];
        // Get menú
        $menu = ModUtil::func('IWagendas', 'user', 'menu', array('mes' => $mes,
                    'any' => $any,
                    'dia' => $dia,
                    'daid' => $daid));
        $this->view->assign('menu', $menu);
        // Personal agenda or non-registered agenda
        if ($daid == 0) {
            if ($anotacio['tasca'] == 0) {
                $nomcamp['c1'] = $this->__('Event');
                $nomcamp['tc1'] = 2;
            } else {
                $nomcamp['c1'] = $this->__('Task');
                $nomcamp['tc1'] = 2;
            }
            $nomcamp['c2'] = $this->__('More information');
            $nomcamp['tc2'] = 2;
            // Check if the user can modify the note
            if (!$a) {
                LogUtil::registerError($this->__('You are not allowed to administrate the agendas'));
                return System::redirect(ModUtil::url('IWagendas', 'user', 'main'));
            }
            $this->view->assign('attachpermitted', ModUtil::setVar('IWagendas', 'adjuntspersonals'));
        } else { // Shared agenda
            // Get the definition of the agenda
            $nomcamp = ModUtil::apiFunc('IWagendas', 'user', 'getAgenda', array('daid' => $daid));
            //Check the access of the user in the agenda
            $te_acces = ModUtil::func('IWagendas', 'user', 'te_acces', array('daid' => $daid,
                        'grup' => $nomcamp['grup'],
                        'resp' => $nomcamp['resp'],
                        'activa' => $nomcamp['activa']));
            if (!($te_acces == 4 || ($te_acces == 3 && $a))) {
                LogUtil::registerError($this->__('You are not allowed to do that'));
                return System::redirect(ModUtil::url('IWagendas', 'user', 'main'));
            }
            $this->view->assign('attachpermitted', $nomcamp['adjunts']);
        }
        // Create a month days array
        for ($i = 1; $i < 32; $i++) {
            $dies_MS[] = array('id' => $i,
                'name' => $i);
        }
        // Create an array with the month's names
        $mesos_MS = array(array('id' => 1,
                'name' => $this->__('January')),
            array('id' => 2,
                'name' => $this->__('February')),
            array('id' => 3,
                'name' => $this->__('March')),
            array('id' => 4,
                'name' => $this->__('April')),
            array('id' => 5,
                'name' => $this->__('May')),
            array('id' => 6,
                'name' => $this->__('June')),
            array('id' => 7,
                'name' => $this->__('July')),
            array('id' => 8,
                'name' => $this->__('August')),
            array('id' => 9,
                'name' => $this->__('September')),
            array('id' => 10,
                'name' => $this->__('October')),
            array('id' => 11,
                'name' => $this->__('November')),
            array('id' => 12,
                'name' => $this->__('December')));
        //Creem un array preparat per un MultiSelect amb els nivells de prioritat d'una tasca
        $nivells_MS = array(array('id' => 0,
                'name' => '0'),
            array('id' => 1,
                'name' => '1'),
            array('id' => 2,
                'name' => '2'),
            array('id' => 3,
                'name' => '3'),
            array('id' => 4,
                'name' => '4'),
            array('id' => 5,
                'name' => '5'));
        //Omplim un multiselect amb els anys disponibles
        for ($i = date('Y', $anotacio['data']); $i < date('Y', $anotacio['data']) + 50; $i++) {
            $anys_MS[] = array('id' => $i,
                'name' => $i);
        }
        //Omplim un multiselect amb les hores del dia
        for ($i = 0; $i < 24; $i++) {
            $h = $i;
            if ($i == 0)
                $h = '00';
            if (strlen($i) == 1)
                $h = '0' . $i;
            $hores_MS[] = array('id' => $h,
                'name' => $h);
        }
        //Omplim un multiselect amb els minuts
        for ($i = 0; $i < 12; $i++) {
            $m = $i * 5;
            if ($i == 0)
                $m = '00';
            if (strlen($m) == 1)
                $m = '0' . $m;
            $minuts_MS[] = array('id' => $m,
                'name' => $m);
        }
        // Pass the data to the template
        $this->view->assign('dies_MS', $dies_MS)
                ->assign('mesos_MS', $mesos_MS)
                ->assign('anys_MS', $anys_MS)
                ->assign('nivells_MS', $nivells_MS)
                ->assign('hores_MS', $hores_MS)
                ->assign('minuts_MS', $minuts_MS)
                ->assign('aid', $aid)
                ->assign('daid', $daid)
                ->assign('oculta', $oculta);
        // The form is shared for annotations and tasks. This particularizes depending on the $tasca param
        if ($anotacio['tasca'] == 0) { // Not a task
            $acciosubmit = $this->__('Create event');
            $msg_no_nota = $this->__("You haven't written the event");
            $title = $this->__('Edit event');
            $date = $this->__('Date');
        } else { // It's a task
            $acciosubmit = $this->__('Create task');
            $msg_no_nota = $this->__("You haven't written the task");
            $title = $this->__('Edit task');
            $date = $this->__('Expiry date ');
            // Create priority array
            $nivells_MS = array(array('id' => 0,
                    'name' => '0'),
                array('id' => 1,
                    'name' => '1'),
                array('id' => 2,
                    'name' => '2'),
                array('id' => 3,
                    'name' => '3'),
                array('id' => 4,
                    'name' => '4'),
                array('id' => 5,
                    'name' => '5'));
        }
        $this->view->assign('date', $date)
                ->assign('title', $title)
                ->assign('extensions', ModUtil::getVar('IWmain', 'extensions'))
                ->assign('maxattachsize', ModUtil::getVar('IWmain', 'maxsize'))
                ->assign('selectedday', date("d", $anotacio['data']))
                ->assign('selectedmonth', date("m", $anotacio['data']))
                ->assign('selectedyear', date("Y", $anotacio['data']))
                ->assign('selectedhour', date("H", $anotacio['data']))
                ->assign('selectedminute', date("i", $anotacio['data']))
                ->assign('file', $anotacio['fitxer'])
                ->assign('task', $anotacio['tasca'])
                ->assign('protegida', $anotacio['protegida'])
                ->assign('nivell', $anotacio['nivell'])
                ->assign('totdia', $anotacio['totdia']);
        // get user info
        $sv = ModUtil::func('IWmain', 'user', 'genSecurityValue');
        $userfullname = ModUtil::func('IWmain', 'user', 'getUserInfo', array('sv' => $sv,
                    'uid' => UserUtil::getVar('uid'),
                    'info' => 'nc'));
        for ($i = 1; $i < 6; $i++) {
            if (!empty($nomcamp['c' . $i])) {
                $opts_array = array();
                if (isset($nomcamp['op' . $i])) {
                    $opts = explode('-', $nomcamp['op' . $i]);
                    foreach ($opts as $opt)
                        $opts_array[] = array('id' => $opt,
                            'value' => $opt);
                }
                if ($nomcamp['tc' . $i] == 3) {
                    $value = $userfullname;
                } else if ($nomcamp['tc' . $i] == 4) {
                    $value = $userfullname . $this->__(' on ') . date("d/m/Y", $anotacio['dataanota']) . $this->__(' at ') . date("H:i", $anotacio['dataanota']);
                } else {
                    $value = $anotacio['c' . $i];
                }
                $fields[] = array('desc' => $nomcamp['c' . $i],
                    'value' => $value,
                    'type' => $nomcamp['tc' . $i],
                    'opts' => $opts_array);
            }
        }
        $this->view->assign('fields', $fields);
        // Check if the agenda have repeats
        $repes = ModUtil::apiFunc('IWagendas', 'user', 'comptarepes', array('aid' => $aid,
                    'rid' => $anotacio['rid']));
        if ($repes > 0) {
            $quines_MS = array(array('id' => 1,
                    'name' => $this->__('Only this event')),
                array('id' => 2,
                    'name' => $this->__('This event and its repetitions')));
            $this->view->assign('quines_MS', $quines_MS);
        }
        if ($anotacio['tasca'] == 0) {
            $this->view->assign('acciosubmit', $this->__('Modify event'));
        } else {
            $this->view->assign('acciosubmit', $this->__('Modify task'));
        }
        return $this->view->fetch('IWagendas_user_edit.htm');
    }
Пример #26
0
 /**
  * On an module remove hook call this listener deletes all cached (generated) doctrine models for the module.
  *
  * Listens for the 'installer.module.uninstalled' event.
  *
  * @param Zikula_Event $event Event.
  *
  * @return void
  */
 public function deleteGeneratedCategoryModelsOnModuleRemove(Zikula_Event $event)
 {
     $moduleName = $event['name'];
     // remove generated category models for this record
     $dir = 'doctrinemodels/GeneratedDoctrineModel/' . $moduleName;
     if (file_exists(CacheUtil::getLocalDir($dir))) {
         CacheUtil::removeLocalDir($dir, true);
     }
     // remove saved data about the record
     $modelsInfo = ModUtil::getVar('ZikulaCategoriesModule', 'EntityCategorySubclasses', array());
     foreach ($modelsInfo as $class => $info) {
         if ($info['module'] == $moduleName) {
             unset($modelsInfo[$class]);
         }
     }
     ModUtil::setVar('ZikulaCategoriesModule', 'EntityCategorySubclasses', $modelsInfo);
 }
Пример #27
0
 public function upgrade($oldversion){
     switch ($oldversion) {
         case '1.0.0':
             if (!DBUtil::createTable('cataleg_gtafEntities') ||
                 !DBUtil::createTable('cataleg_gtafGroups') ){
                 return false;
             }
         case '1.1.0':
             $gZ = ModUtil::getVar('Cataleg','grupsZikula');
             $gZ['Sirius'] = $gZ['Cataleg'];
             unset($gZ['Cataleg']);
             $gZ['ExSirius'] = $gZ['ExCataleg'];
             unset($gZ['ExCataleg']);
             $gZ['Personals'] = $gZ['Usuaris'];
             unset($gZ['Usuaris']);
             $gZ['LectorsCat'] = $gZ['Lectors'];
             unset($gZ['Lectors']);
             $gZ['EditorsCat'] = $gZ['Editors'];
             unset($gZ['Editors']);
             ModUtil::setVar('Cataleg','grupsZikula',$gZ);
             $var2 = ModUtil::getVar('Cataleg', 'usuarisCataleg');
             if (isset($var2)) ModUtil::delVar('Cataleg', 'usuarisCataleg');
             
         case '1.1.1':
             HookUtil::registerSubscriberBundles($this->version->getHookSubscriberBundles());
         case '1.1.2':
         case '1.1.3':
     }
     return true;
 }
Пример #28
0
    /**
     * delete a quota assigned to a group
     * @author:     Albert Pérez Monfort (aperezm@xtec.cat)
     * @param:      group identity
     * @return:     quotas table content
     */
    public function deleteGroupQuota($args) {
        if (!SecurityUtil::checkPermission('Files::', '::', ACCESS_ADMIN)) {
            throw new Zikula_Exception_Fatal($this->__('Sorry! No authorization to access this module.'));
        }

        $gid = $this->request->getPost()->get('gid', '');
        if (!$gid) {
            throw new Zikula_Exception_Fatal($this->__('no group found'));
        }

        if (is_numeric($gid)) {
            $assignaments = unserialize(ModUtil::getVar('Files', 'groupsQuota'));
            $assignamentsArray = array();
            foreach ($assignaments as $assign) {
                if ($assign['gid'] != $gid) {
                    $assignamentsArray[] = array('gid' => $assign['gid'],
                        'quota' => $assign['quota']);
                }
            }
            $data = serialize($assignamentsArray);
            ModUtil::setVar('Files', 'groupsQuota', $data);
        }
        $content = ModUtil::func('Files', 'admin', 'getQuotasTable');
        return new Zikula_Response_Ajax(array('content' => $content,
                ));
    }
Пример #29
0
 /**
  * Make a category the initially selected one (by ajax).
  *
  * @return AjaxUtil::output Output to the calling ajax request is returned.
  *                          response is a string message on success.
  */
 public function defaultCategory()
 {
     $this->checkAjaxToken();
     //check user has permission to change the initially selected category
     $this->throwForbiddenUnless(SecurityUtil::checkPermission('Admin::', '::', ACCESS_ADMIN));
     //get passed cid
     $cid = trim($this->request->getPost()->get('cid'));
     //find the category corresponding to the cid.
     $category = ModUtil::apiFunc('Admin', 'admin', 'get', array('cid' => $cid));
     if ($category == false) {
         return AjaxUtil::error(LogUtil::registerError($this->__('Error! No such category found.')), array(), true);
     }
     $output = array();
     //make category the initially selected one
     if (ModUtil::setVar('Admin', 'startcategory', $cid)) {
         // Success
         $output['response'] = $this->__f('Category "%s" was successfully made default.', $category['catname']);
         return new Zikula_Response_Ajax($output);
     }
     //unknown error
     throw new Zikula_Exception_Fatal($this->__('Error! Could not make this category default.'));
 }
Пример #30
0
 /**
  * delete a quota assigned to a group
  * @author:     Albert Pérez Monfort (aperezm@xtec.cat)
  * @param:      group identity
  * @return:		quotas table content
  */
 public function deleteGroupQuota($args)
 {
     if (!SecurityUtil::checkPermission('Files::', '::', ACCESS_ADMIN)) {
         AjaxUtil::error(DataUtil::formatForDisplayHTML(_MODULENOAUTH));
     }
     $gid = FormUtil::getPassedValue('gid', -1, 'GET');
     if ($gid == -1) {
         AjaxUtil::error($this->__('no group found'));
     }
     if (is_numeric($gid)) {
         $assignaments = unserialize(ModUtil::getVar('Files', 'groupsQuota'));
         $assignamentsArray = array();
         foreach ($assignaments as $assign) {
             if ($assign['gid'] != $gid) {
                 $assignamentsArray[] = array('gid' => $assign['gid'], 'quota' => $assign['quota']);
             }
         }
         $data = serialize($assignamentsArray);
         ModUtil::setVar('Files', 'groupsQuota', $data);
     }
     $content = ModUtil::func('Files', 'admin', 'getQuotasTable');
     AjaxUtil::output(array('content' => $content));
 }