/**
 * Content
 *
 * @copyright (C) 2007-2010, Content Development Team
 * @link http://github.com/zikula-modules/Content
 * @license See license.txt
 */
function smarty_function_contentcodeeditor($params, $view)
{
    $dom = ZLanguage::getModuleDomain('Content');
    $inputId = $params['inputId'];
    $inputType = isset($params['inputType']) ? $params['inputType'] : null;
    // Get reference to optional radio button that enables the editor (a hack for the HTML plugin).
    // It would have been easier just to read a $var in the template, but this won't work with a
    // Forms plugin - you would just get the initial value from when the page was loaded
    $htmlRadioButton = isset($params['htmlradioid']) ? $view->getPluginById($params['htmlradioid']) : null;
    $textRadioButton = isset($params['textradioid']) ? $view->getPluginById($params['textradioid']) : null;
    $html = '';
    $useBBCode = $textRadioButton == null && $inputType == 'text' && !$view->isPostBack() || $textRadioButton != null && $textRadioButton->checked;
    if ($useBBCode && ModUtil::available('BBCode')) {
        $html = "<div class=\"z-formrow\"><em class=\"z-sub\">";
        $html .= ModUtil::func('BBCode', 'User', 'bbcodes', array('textfieldid' => $inputId, 'images' => 0));
        $html .= "</em></div>";
    } else {
        if ($useBBCode && !ModUtil::available('BBCode')) {
            $html = "<div class=\"z-formrow\"><em class=\"z-sub\">";
            $html .= '(' . __("Please install the BBCode module to enable BBCodes display.", $dom) . ')';
            $html .= "</em></div>";
        }
    }
    return $html;
}
Пример #2
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->$this->__('Module IWmain is needed. You have to install the IWmain module before installing 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('IWusers'))
         return false;
     if (!DBUtil::createTable('IWusers_friends'))
         return false;
     // Create the index
     if (!DBUtil::createIndex('iw_uid', 'IWusers', 'uid'))
         return false;
     if (!DBUtil::createIndex('iw_uid', 'IWusers_friends', 'uid'))
         return false;
     if (!DBUtil::createIndex('iw_fid', 'IWusers_friends', 'fid'))
         return false;
     //Create module vars
     $this->setVar('friendsSystemAvailable', 1)
             ->setVar('invisibleGroupsInList', '$')
             ->setVar('usersCanManageName', 0)
             ->setVar('allowUserChangeAvatar', '1')
             ->setVar('allowUserSetTheirSex', '0')
             ->setVar('allowUserDescribeTheirSelves', '1')
             ->setVar('avatarChangeValidationNeeded', '1')
             ->setVar('usersPictureFolder', 'photos');
     return true;
 }
Пример #3
0
 public function displayEditing()
 {
     if (!empty($this->addressid)) {
         return ModUtil::func('AddressBook', 'user', 'simpledisplay', array('id' => (int) $this->addressid));
     }
     return $this->__('No address selected');
 }
Пример #4
0
    /**
     * update the used disk for the user
     * @author:    Albert Pérez Monfort
     * @return:    True if success and false otherwise
    */
    public function updateUsedSpace()
    {
        // security check
        if (!SecurityUtil::checkPermission( 'Files::', '::', ACCESS_ADD)) {
            return LogUtil::registerPermissionError();
        }
        // get user used space
        $usedSpace = ModUtil::apiFunc('Files', 'user', 'get');
        if(!$usedSpace){
            // user row doesn't exists and it is created
            ModUtil::apiFunc('Files', 'user', 'createUserFilesInfo');
        }

        $check = ModUtil::func('Files', 'user', 'checkingModule');
        if ($check['status'] != 'ok') {
	    $this->view->assign('check', $check);
            return $this->view->fetch('Files_user_failedConf.tpl');
        }
        $initFolderPath = $check['initFolderPath'];
        $spaceUsed = ModUtil::apiFunc('Files', 'user', 'calcUsedSpace', array('folderToCalc' => $initFolderPath));
        $item = array('diskUse' => DataUtil::formatForStore($spaceUsed));
        $pntable =& DBUtil::getTables();
        $c = $pntable['Files_column'];
        $where = "$c[userId]=" . UserUtil::getVar('uid');
        if (!DBUtil::updateObject($item, 'Files', $where, 'fileId')) {
            return LogUtil::registerError ($this->__('Error! Could not update the used disk.'));
        }
        // Let the calling process know that we have finished successfully
        return true;
    }
Пример #5
0
 /**
  * Handles an error.
  *
  * @param integer $errno      Number of the error.
  * @param string  $errstr     Error message.
  * @param string  $errfile    Filename where the error occurred.
  * @param integer $errline    Line of the error.
  * @param string  $errcontext Context of the error.
  *
  * @return boolean
  */
 public function handler($errno, $errstr, $errfile = '', $errline = 0, $errcontext = null)
 {
     $this->setupHandler($errno, $errstr, $errfile, $errline, $errcontext);
     // Notify all loggers
     $this->eventManager->notify($this->event->setArgs(array('trace' => $this->trace, 'type' => $this->type, 'errno' => $this->errno, 'errstr' => $this->errstr, 'errfile' => $this->errfile, 'errline' => $this->errline, 'errcontext' => $this->errcontext)));
     if ($this->isPHPError() && System::isDevelopmentMode() && $this->showPHPErrorHandler()) {
         // allow PHP to return error
         $this->resetHandler();
         return false;
     }
     if (!$this->isDisplayErrorTemplate()) {
         // prevent PHP from handling the event after we return
         $this->resetHandler();
         return true;
     }
     // obey reporing level
     if (abs($this->getType()) > $this->serviceManager['log.display_level']) {
         return false;
     }
     // unless in development mode, exit.
     if (!$this->serviceManager['log.display_template']) {
         return false;
     }
     // if we get this far, display template
     echo ModUtil::func('Errors', 'user', 'system', array('type' => $this->errno, 'message' => $this->errstr, 'file' => $this->errfile, 'line' => $this->errline));
     Zikula_View_Theme::getInstance()->themefooter();
     System::shutDown();
 }
Пример #6
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->__('Module IWmain is needed. You have to install the IWmain module before installing it.'));
        }

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

        // create module tables
        $tables = array('IWstats', 'IWstats_summary');
        foreach ($tables as $table) {
            if (!DBUtil::createTable($table)) {
                return false;
            }
        }

        // create several indexes for IWstats table
        $table = DBUtil::getTables();
        $c = $table['IWstats_column'];
        if (!DBUtil::createIndex($c['moduleid'], 'IWstats', 'moduleid')) {
            return false;
        }
        if (!DBUtil::createIndex($c['uid'], 'IWstats', 'uid')) {
            return false;
        }
        if (!DBUtil::createIndex($c['ip'], 'IWstats', 'ip')) {
            return false;
        }
        if (!DBUtil::createIndex($c['ipForward'], 'IWstats', 'ipForward')) {
            return false;
        }
        if (!DBUtil::createIndex($c['ipClient'], 'IWstats', 'ipClient')) {
            return false;
        }
        if (!DBUtil::createIndex($c['userAgent'], 'IWstats', 'userAgent')) {
            return false;
        }
        if (!DBUtil::createIndex($c['isadmin'], 'IWstats', 'isadmin')) {
            return false;
        }

        // Set up config variables
        $this->setVar('skippedIps', '')
                ->setVar('modulesSkipped', '')
                ->setVar('deleteFromDays', 90)
                ->setVar('keepDays', 90);

        // create the system init hook
        EventUtil::registerPersistentModuleHandler('IWstats', 'core.postinit', array('IWstats_Listeners', 'coreinit'));

        // Initialisation successful
        return true;
    }
/**
 * Smarty function to display the category menu for admin links. This also adds the
 * navtabs.css to the page vars array for stylesheets.
 *
 * Admin
 * {admincategorymenu}
 *
 * @see          function.admincategorymenu.php::smarty_function_admincategoreymenu()
 * @param        array       $params      All attributes passed to this function from the template
 * @param        object      $view        Reference to the Zikula_View object
 * @return       string      the results of the module function
 */
function smarty_function_admincategorymenu($params, $view)
{
    PageUtil::addVar('stylesheet', ThemeUtil::getModuleStylesheet('Admin'));
    $modinfo = ModUtil::getInfoFromName($view->getTplVar('toplevelmodule'));
    $acid = ModUtil::apiFunc('AdminModule', 'admin', 'getmodcategory', array('mid' => $modinfo['id']));
    return ModUtil::func('AdminModule', 'admin', 'categorymenu', array('acid' => $acid));
}
Пример #8
0
 /**
  * Give access to the administrator main page
  * @author:    Albert Pérez Monfort (aperezm@xtec.cat)
  * @return:    The form for general configuration values of the Intraweb modules
  */
 public function main()
 {
     // Security check
     if (!SecurityUtil::checkPermission('Files::', '::', ACCESS_ADMIN)) {
         return LogUtil::registerPermissionError();
     }
     $multisites = isset($GLOBALS['PNConfig']['Multisites']['multi']) && $GLOBALS['PNConfig']['Multisites']['multi'] == 1 ? true : false;
     if ($multisites) {
         $siteDNS = FormUtil::getPassedValue('siteDNS', '', 'GET');
         $folderPath = $GLOBALS['PNConfig']['Multisites']['filesRealPath'] . '/' . $siteDNS . $GLOBALS['PNConfig']['Multisites']['siteFilesFolder'];
     } else {
         $folderPath = ModUtil::getVar('Files', 'folderPath');
     }
     $moduleVars = array('usersFolder' => ModUtil::getVar('Files', 'usersFolder'), 'allowedExtensions' => ModUtil::getVar('Files', 'allowedExtensions'), 'defaultQuota' => ModUtil::getVar('Files', 'defaultQuota'), 'filesMaxSize' => ModUtil::getVar('Files', 'filesMaxSize'), 'maxWidth' => ModUtil::getVar('Files', 'maxWidth'), 'maxHeight' => ModUtil::getVar('Files', 'maxHeight'), 'showHideFiles' => ModUtil::getVar('Files', 'showHideFiles'), 'editableExtensions' => ModUtil::getVar('Files', 'editableExtensions'));
     // check if file file.php exists in folder modules/Files
     $fileFileInModule = file_exists('modules/Files/file.php') ? true : false;
     // check if file file.php exists in folder modules/Files
     $fileFileNotInRoot = !file_exists('file.php') ? true : false;
     $folderPathProblem = !is_writable($folderPath) || !file_exists($folderPath) ? true : false;
     $usersFolderProblem = !is_writable($folderPath . '/' . $moduleVars['usersFolder']) || !file_exists($folderPath . '/' . $moduleVars['usersFolder']) || $moduleVars['usersFolder'] == '' ? true : false;
     $quotasTable = ModUtil::func('Files', 'admin', 'getQuotasTable');
     $this->view->assign('folderPath', $folderPath);
     $this->view->assign('multisites', $multisites);
     $this->view->assign('quotasTable', $quotasTable);
     $this->view->assign('moduleVars', $moduleVars);
     $this->view->assign('fileFileInModule', $fileFileInModule);
     $this->view->assign('fileFileNotInRoot', $fileFileNotInRoot);
     $this->view->assign('folderPathProblem', $folderPathProblem);
     $this->view->assign('usersFolderProblem', $usersFolderProblem);
     return $this->view->fetch('Files_admin_conf.htm');
 }
/**
 * Copyright Zikula Foundation 2011 - Zikula Application Framework
 *
 * This work is contributed to the Zikula Foundation under one or more
 * Contributor Agreements and licensed to You under the following license:
 *
 * @license GNU/LGPLv3 (or at your option, any later version).
 * @package Zikula_View
 * @subpackage Template_Plugins
 *
 * Please see the NOTICE file distributed with this source code for further
 * information regarding copyright and licensing.
 */
function smarty_function_login_form_fields($params, $view)
{
    if (!isset($params) || !is_array($params) || empty($params)) {
        throw new \Zikula\Framework\Exception\FatalException(__f('An invalid \'%1$s\' parameter was received by the template function \'%2$s\'.', array('$params', 'login_form_fields'), 'Zikula'));
    }
    if (isset($params['authentication_method']) && is_array($params['authentication_method']) && !empty($params['authentication_method']) && count($params['authentication_method']) == 2) {
        $authenticationMethod = $params['authentication_method'];
        if (!isset($authenticationMethod['modname']) || empty($authenticationMethod['modname']) || !is_string($authenticationMethod['modname'])) {
            throw new \Zikula\Framework\Exception\FatalException(__f('An invalid authentication module was received by the template function \'%1$s\'.', array('login_form_fields'), 'Zikula'));
        }
        if (!isset($authenticationMethod['method']) || empty($authenticationMethod['method']) || !is_string($authenticationMethod['method'])) {
            throw new \Zikula\Framework\Exception\FatalException(__f('An invalid authentication method was received by the template function \'%1$s\'.', array('login_form_fields'), 'Zikula'));
        }
    } else {
        throw new \Zikula\Framework\Exception\FatalException(__f('An invalid \'%1$s\' parameter was received by the template function \'%2$s\'.', array('authentication_method', 'login_form_fields'), 'Zikula'));
    }
    if (isset($params['form_type']) && is_string($params['form_type']) && !empty($params['form_type'])) {
        $formType = $params['form_type'];
    } else {
        throw new \Zikula\Framework\Exception\FatalException(__f('An invalid \'%1$s\' parameter was received by the template function \'%2$s\'.', array('form_type', 'login_form_fields'), 'Zikula'));
    }
    if (isset($params['assign'])) {
        if (!is_string($params['assign']) || empty($params['assign'])) {
            throw new \Zikula\Framework\Exception\FatalException(__f('An invalid \'%1$s\' parameter was received by the template function \'%2$s\'.', array('assign', 'login_form_fields'), 'Zikula'));
        }
    }
    $args = array('form_type' => $formType, 'method' => $authenticationMethod['method']);
    $content = ModUtil::func($authenticationMethod['modname'], 'Authentication', 'getLoginFormFields', $args, 'Zikula_Controller_AbstractAuthentication');
    $content = $content->getContent();
    if (isset($params['assign'])) {
        $view->assign($params['assign'], $content);
    } else {
        return $content;
    }
}
Пример #10
0
    public function install() {
        if (!SecurityUtil::checkPermission('IWdocmanager::', '::', ACCESS_ADMIN)) {
            return LogUtil::registerPermissionError();
        }
        // Checks if module IWmain is installed. If not returns error
        if (!ModUtil::available('IWmain')) {
            return LogUtil::registerError(__('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;
        }

        if (!DBUtil::createTable('IWdocmanager'))
            return false;
        if (!DBUtil::createTable('IWdocmanager_categories'))
            return false;

        //Create indexes
        $table = DBUtil::getTables();
        $c = $table['IWdocmanager_column'];
        DBUtil::createIndex($c['author'], 'IWdocmanager', 'author');
        DBUtil::createIndex($c['categoryId'], 'IWdocmanager', 'categoryId');

        //Create module vars
        $this->setVar('documentsFolder', 'documents')
                ->setVar('notifyMail', '')
                ->setVar('editTime', '45')
                ->setVar('deleteTime', '20');

        return true;
    }
Пример #11
0
    public function get_sense_grup() {

        $users = DBUtil::selectObjectArray('users', '', '', -1, -1, 'uid');
        // Check for a DB error
        if ($users === false) {
            return LogUtil::registerError($this->__('Error! Could not load items.'));
        }
        // get all users that are in any group
        $allUsersWithGroup = DBUtil::selectObjectArray('group_membership', '', '', -1, -1, 'uid');
        if ($allUsersWithGroup === false) {
            return LogUtil::registerError($this->__('Error! Could not load items.'));
        }
        $diff = array_diff_key($users, $allUsersWithGroup);
        $usersList = '$$';
        $registres = array();
        if (count($diff) > 0) {
            foreach ($diff as $user) {
                $usersList .= $user['uid'] . '$$';
            }
            //get all users information
            $sv = ModUtil::func('IWmain', 'user', 'genSecurityValue');
            $usersInfo = ModUtil::func('IWmain', 'user', 'getAllUsersInfo', array('sv' => $sv,
                        'list' => $usersList,
                        'info' => 'ccn'));
            foreach ($usersInfo as $key => $value) {
                $registres[] = array('name' => $value,
                    'id' => $key);
            }
        }
        return $registres;
    }
Пример #12
0
    public function getFile($args) {
        // File name with the path
        $fileName = FormUtil::getPassedValue('fileName', isset($args['fileName']) ? $args['fileName'] : 0, 'GET');

        $sv = ModUtil::func('IWmain', 'user', 'genSecurityValue');
        return ModUtil::func('IWmain', 'user', 'getFile', array('fileName' => $fileName,
                    'sv' => $sv));
    }
Пример #13
0
/**
 * Gets qv summary information
 *
 * @author: Sara Arjona Téllez (sarjona@xtec.cat)
 */
function IWqv_qvsummaryblock_display($row) {
    // Security check
    if (!SecurityUtil::checkPermission('IWqv:summaryBlock:', $row['title'] . "::", ACCESS_READ) || !UserUtil::isLoggedIn()) {
        return false;
    }

    $uid = UserUtil::getVar('uid');
    if (!isset($uid))
        $uid = '-1';

    // Get the qvsummary 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' => 'qvsummary',
                'module' => 'IWqv',
                'uid' => $uid,
                'sv' => $sv));
    if ($exists) {
        $sv = ModUtil::func('IWmain', 'user', 'genSecurityValue');
        $s = ModUtil::func('IWmain', 'user', 'userGetVar', array('uid' => $uid,
                    'name' => 'qvsummary',
                    'module' => 'IWqv',
                    'sv' => $sv,
                    'nult' => true));
    } else {
        $teacherassignments = ModUtil::apiFunc('IWqv', 'user', 'getall', array("teacher" => $uid));
        $studentassignments = ModUtil::apiFunc('IWqv', 'user', 'getall', array("student" => $uid));

        if (empty($teacherassignments) && empty($studentassignments)) {
            
        }

        $view = Zikula_View::getInstance('IWqv', false);
        $view->assign('teacherassignments', $teacherassignments);
        $view->assign('studentassignments', $studentassignments);
        $view->assign('isblock', true);
        $s = $view->fetch('IWqv_block_summary.htm');

        if (empty($teacherassignments) && empty($studentassignments)) {
            $s = '';
        }

        //Copy the block information into user vars
        $sv = ModUtil::func('IWmain', 'user', 'genSecurityValue');
        ModUtil::func('IWmain', 'user', 'userSetVar', array('uid' => $uid,
            'name' => 'qvsummary',
            'module' => 'IWqv',
            'sv' => $sv,
            'value' => $s,
            'lifetime' => '2000'));
    }

    if ($s == '') {
        return false;
    }

    $row['content'] = $s;
    return BlockUtil::themesideblock($row);
}
Пример #14
0
    /**
     * Gets topics information
     *
     * @author		Albert Pérez Monfort (aperezm@xtec.cat)
     * @author 		Josep Ferràndiz Farré (jferran6@xtec.cat)
     */
    public function display($row) {
        // Security check
        if (!SecurityUtil::checkPermission('IWmyrole::', "::", ACCESS_ADMIN)) {
            return false;
        }

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

        //Check if user belongs to change group. If not the block is not showed
        $sv = ModUtil::func('IWmain', 'user', 'genSecurityValue');
        $isMember = ModUtil::func('IWmain', 'user', 'isMember',
                                   array('sv' => $sv,
                                         'gid' => ModUtil::getVar('IWmyrole', 'rolegroup'),
                                         'uid' => $uid));

        if (!$isMember) {
            return false;
        }

        $sv = ModUtil::func('IWmain', 'user', 'genSecurityValue');
        $uidGroups = ModUtil::func('IWmain', 'user', 'getAllUserGroups',
                                    array('sv' => $sv,
                                          'uid' => $uid));
        foreach ($uidGroups as $g) {
            $originalGroups[$g['id']] = 1;
        }

        $view = Zikula_View::getInstance('IWmyrole', false);

        // Gets the groups
        $sv = ModUtil::func('IWmain', 'user', 'genSecurityValue');
        $allGroups = ModUtil::func('IWmain', 'user', 'getAllGroups',
                                    array('sv' => $sv,
                                          'less' => ModUtil::getVar('IWmyrole', 'rolegroup')));

        $groupsNotChangeable = ModUtil::getVar('IWmyrole', 'groupsNotChangeable');

        foreach ($allGroups as $group) {
            if (strpos($groupsNotChangeable, '$' . $group['id'] . '$') == false) $groupsArray[] = $group;
        }

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

        $view->assign('groups', $groupsArray);
        $view->assign('invalidChange', $invalidChange);
        $view->assign('roleGroups', $originalGroups);
        $s = $view->fetch('IWmyrole_block_change.htm');

        $row['content'] = $s;
        return BlockUtil::themesideblock($row);
    }
Пример #15
0
    /**
     * Initialise the IWmyrole module creating 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;
        }

        // Name of the initial group
        $name = "changingRole";

        // The API function is called.
        $check = ModUtil::apiFunc('Groups', 'admin', 'getgidbyname', array('name' => $name));

        if ($check != false) {
            // Group already exists
            // LogUtil::registerError (_GROUPS_ALREADYEXISTS);
            $gid = $check;
        } else {
            // Falta mirar si existeix
            $gid = ModUtil::apiFunc('Groups', 'admin', 'create', array('name' => $name,
                        'gtype' => 0,
                        'state' => 0,
                        'nbumax' => 0,
                        'description' => $this->__('Initial group of users that can change the role')));
            // Success
        }

        // The return value of the function is checked here
        if ($gid != false) {
            $this->setVar('rolegroup', $gid);
            // Gets the first sequence number of permissions list
            $pos = DBUtil::selectFieldMax('group_perms', 'sequence', 'MIN');
            // SET MODULE AND BLOCK PERMISSIONS
            // insert permission myrole:: :: administration in second place
            ModUtil::apiFunc('permissions', 'admin', 'create', array('realm' => 0,
                'id' => $gid,
                'component' => 'IWmyrole::',
                'instance' => '::',
                'level' => '800',
                'insseq' => $pos + 1));
        }

        $this->setVar('groupsNotChangeable', '');

        //Initialation successfull
        return true;
    }
Пример #16
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;
    }
function smarty_function_authentication_method_selector($params, $view)
{
    if (!isset($params) || !is_array($params) || empty($params)) {
        throw new Zikula_Exception_Fatal(__f('An invalid \'%1$s\' parameter was received by the template function \'%2$s\'.', array('$params', 'authentication_method_selector'), 'Zikula'));
    }
    if (isset($params['authentication_method']) && is_array($params['authentication_method']) && !empty($params['authentication_method']) && count($params['authentication_method']) == 2) {
        $authenticationMethod = $params['authentication_method'];
        if (!isset($authenticationMethod['modname']) || empty($authenticationMethod['modname']) || !is_string($authenticationMethod['modname'])) {
            throw new Zikula_Exception_Fatal(__f('An invalid authentication module was received by the template function \'%1$s\'.', array('authentication_method_selector'), 'Zikula'));
        }
        if (!isset($authenticationMethod['method']) || empty($authenticationMethod['method']) || !is_string($authenticationMethod['method'])) {
            throw new Zikula_Exception_Fatal(__f('An invalid authentication method was received by the template function \'%1$s\'.', array('authentication_method_selector'), 'Zikula'));
        }
    } else {
        throw new Zikula_Exception_Fatal(__f('An invalid \'%1$s\' parameter was received by the template function \'%2$s\'.', array('authentication_method', 'authentication_method_selector'), 'Zikula'));
    }
    if (isset($params['selected_authentication_method']) && is_array($params['selected_authentication_method']) && !empty($params['selected_authentication_method'])) {
        if (count($params['selected_authentication_method']) == 2) {
            if (!isset($params['selected_authentication_method']['modname']) || empty($params['selected_authentication_method']['modname']) || !is_string($params['selected_authentication_method']['modname'])) {
                throw new Zikula_Exception_Fatal(__f('An invalid selected authentication module was received by the template function \'%1$s\'.', array('authentication_method_selector'), 'Zikula'));
            }
            if (!isset($params['selected_authentication_method']['method']) || empty($params['selected_authentication_method']['method']) || !is_string($params['selected_authentication_method']['method'])) {
                throw new Zikula_Exception_Fatal(__f('An invalid selected authentication method was received by the template function \'%1$s\'.', array('authentication_method_selector'), 'Zikula'));
            }
            $isSelected = $authenticationMethod['modname'] == $params['selected_authentication_method']['modname'] && $authenticationMethod['method'] == $params['selected_authentication_method']['method'];
        } else {
            throw new Zikula_Exception_Fatal(__f('An invalid \'%1$s\' parameter was received by the template function \'%2$s\'.', array('selected_authentication_method', 'authentication_method_selector'), 'Zikula'));
        }
    } else {
        $isSelected = false;
    }
    if (!isset($params['form_type']) || !is_string($params['form_type']) || empty($params['form_type'])) {
        throw new Zikula_Exception_Fatal(__f('An invalid \'%1$s\' parameter was received by the template function \'%2$s\'.', array('form_type', 'authentication_method_selector')));
    }
    if (!isset($params['form_action']) || !is_string($params['form_action']) || empty($params['form_action'])) {
        throw new Zikula_Exception_Fatal(__f('An invalid \'%1$s\' parameter was received by the template function \'%2$s\'.', array('form_action', 'authentication_method_selector')));
    }
    if (isset($params['assign'])) {
        if (!is_string($params['assign']) || empty($params['assign'])) {
            throw new Zikula_Exception_Fatal(__f('An invalid \'%1$s\' parameter was received by the template function \'%2$s\'.', array('assign', 'authentication_method_selector'), 'Zikula'));
        }
    }
    $getSelectorArgs = array('form_type' => $params['form_type'], 'form_action' => $params['form_action'], 'method' => $authenticationMethod['method'], 'is_selected' => $isSelected);
    $content = ModUtil::func($authenticationMethod['modname'], 'Authentication', 'getAuthenticationMethodSelector', $getSelectorArgs, 'Zikula_Controller_AbstractAuthentication');
    if ($content instanceof Response) {
        // Forward compatability. @todo Remove check in 1.5.0
        $content = $content->getContent();
    }
    if (isset($params['assign'])) {
        $view->assign($params['assign'], $content);
    } else {
        return $content;
    }
}
Пример #18
0
    /**
     * Get the properties of the activities that a user have got assigned
     * @author:     Albert Pérez Monfort (aperezm@xtec.cat)
     * @return:	An array with the activity proporties
     */
    public function getAllActivities($args) {
        // Security check
        if (!SecurityUtil::checkPermission('IWjclic::', "::", ACCESS_READ)) {
            throw new Zikula_Exception_Forbidden();
        }

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

        //get all the groups of the user
        $sv = ModUtil::func('IWmain', 'user', 'genSecurityValue');
        $userGroups = ModUtil::func('IWmain', 'user', 'getAllUserGroups', array('uid' => $uid,
                    'sv' => $sv));

        $myJoin = array();

        $myJoin[] = array('join_table' => 'IWjclic',
            'join_field' => array(),
            'object_field_name' => array(),
            'compare_field_table' => 'jid',
            'compare_field_join' => 'jid');
        $myJoin[] = array('join_table' => 'IWjclic_groups',
            'join_field' => array(),
            'object_field_name' => array(),
            'compare_field_table' => 'jid',
            'compare_field_join' => 'jid');

        $pntables = DBUtil::getTables();

        $ocolumn = $pntables['IWjclic_column'];
        $lcolumn = $pntables['IWjclic_groups_column'];

        $where = "(";
        $orderby = "a.$ocolumn[date]";

        foreach ($userGroups as $group) {
            $where .= "b.$lcolumn[group_id]=" . $group['id'] . ' OR ';
        }

        $where = substr($where, 0, -3);

        $where .= ") AND a.$ocolumn[active] = 1";

        $items = DBUtil::selectExpandedObjectArray('IWjclic', $myJoin, $where, $orderby, '-1', '-1', 'jid');

        if ($items === false) {
            return LogUtil::registerError($this->__('Error! Could not load items.'));
        }

        // get the user activities that the user has made independently of the groups.
        // In case the activity groups changes but the user have made an activity he/she can accés to the activity information
        // marge the items in the two requests
        // Return the items
        return $items;
    }
Пример #19
0
 /**
  * Show the month calendar into a bloc
  *
  * @param array $blockinfo The month and the year to show
  *
  * @return The calendar content
  */
 public function display($blockinfo)
 {
     $mes = FormUtil::getPassedValue('mes', isset($args['mes']) ? $args['mes'] : 0, 'REQUEST');
     $any = FormUtil::getPassedValue('any', isset($args['any']) ? $args['any'] : 0, 'REQUEST');
     // Security check
     if (!SecurityUtil::checkPermission("IWagendas:calendarblock:", $blockinfo['title'] . "::", ACCESS_READ)) return;
     // Check if the module is available
     if (!ModUtil::available('IWagendas')) return;
     $user = (UserUtil::isLoggedIn()) ? UserUtil::getVar('uid') : '-1';
     //get the calendar saved in the user vars.
     $sv = ModUtil::func('IWmain', 'user', 'genSecurityValue');
     $exists = ModUtil::apiFunc('IWmain', 'user', 'userVarExists',
                                 array('name' => 'Calendar',
                                       'module' => 'IWagendas',
                                       'uid' => $user,
                                       'sv' => $sv));
     /*
     if ($exists) {
         $sv = ModUtil::func('IWmain', 'user', 'genSecurityValue');
         $s = ModUtil::func('IWmain', 'user', 'userGetVar',
                             array('uid' => $user,
                                   'name' => 'calendar',
                                   'module' => 'IWagendas',
                                   'sv' => $sv,
                                   'nult' => true));
         $blockinfo['content'] = $s;
         return BlockUtil::themesideblock($blockinfo);
     }
      * 
      */
     $s = ModUtil::func('IWagendas', 'user', 'getCalendarContent',
                         array('mes' => $mes,
                               'any' => $any));
     //Copy the block information into user vars
     $sv = ModUtil::func('IWmain', 'user', 'genSecurityValue');
     ModUtil::func('IWmain', 'user', 'userSetVar',
                    array('uid' => $user,
                          'name' => 'calendar',
                          'module' => 'IWagendas',
                          'sv' => $sv,
                          'value' => $s,
                          'lifetime' => '700'));
     //Copy the block information into user vars
     $sv = ModUtil::func('IWmain', 'user', 'genSecurityValue');
     ModUtil::func('IWmain', 'user', 'userSetVar',
                    array('uid' => $user,
                          'name' => 'month',
                          'module' => 'IWagendas',
                          'sv' => $sv,
                          'value' => $mes));
     // Populate block info and pass to theme
     $blockinfo['content'] = $s;
     return BlockUtil::themesideblock($blockinfo);
 }
Пример #20
0
    /**
     * 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'));
    }
Пример #21
0
    /**
     * Get a file from a server folder even it is out of the public html directory
     * @author:     Albert Pérez Monfort (aperezm@xtec.cat)
     * @param:	name of the file that have to be gotten
     * @return:	The file information
     */
    public function getFile($args) {
        // File name with the path
        $fileName = FormUtil::getPassedValue('fileName', isset($args['fileName']) ? $args['fileName'] : 0, 'GET');

        // Security check
        if (!SecurityUtil::checkPermission('IWmenu::', "::", ACCESS_READ)) {
            throw new Zikula_Exception_Forbidden();
        }
        $sv = ModUtil::func('IWmain', 'user', 'genSecurityValue');
        return ModUtil::func('IWmain', 'user', 'getFile',
                array('fileName' => $fileName,
                    'sv' => $sv));
    }
Пример #22
0
    /**
     * Sets the user groups membership
     * @author:     Albert Pérez Monfort (aperezm@xtec.cat)
     * @author: 	Josep Ferràndiz (jferran6@xtec.cat)
     * @param:	Array with the id's of the groups where the user will be enroled
     * @return:	True if success and false in other case
     */
    public function addUserToGroup($args) {
        $roles = FormUtil::getPassedValue('roles', isset($args['roles']) ? $args['roles'] : null, 'POST');
        $defaultRoles = FormUtil::getPassedValue('defaultRoles', isset($args['defaultRoles']) ? $args['defaultRoles'] : null, 'POST');
        // Security check
        if (!SecurityUtil::checkPermission('IWmyrole::', "::", ACCESS_ADMIN) && $defaultRoles != 1) {
            throw new Zikula_Exception_Forbidden();
        }
        if ($defaultRoles == 1) {
            $roles = array();
            //get user default roles
            $sv = ModUtil::func('IWmain', 'user', 'genSecurityValue');
            $defaultRoles = ModUtil::func('IWmain', 'user', 'userGetVar',
                                           array('uid' => $uid,
                                                 'name' => 'defaultRoles',
                                                 'module' => 'IWmyrole',
                                                 'sv' => $sv));

            //set default roles
            $userGroups = explode('$$', $defaultRoles);
            $i = 0;
            foreach ($userGroups as $group) {
                if ($group != '') {
                    $roles[$i] = $group;
                    $i++;
                }
            }
        }
        $uid = UserUtil::getVar('uid');
        $count = count($roles);
        for ($i = 0; $i < $count; $i++) {
            //Check if user belongs to change group. If not the block is not showed
            $sv = ModUtil::func('IWmain', 'user', 'genSecurityValue');
            $isMember = ModUtil::func('IWmain', 'user', 'isMember',
                                       array('sv' => $sv,
                                             'gid' => $roles[$i],
                                             'uid' => $uid));
            if (!$isMember) {
                $obj[] = array('uid' => $uid,
                               'gid' => $roles[$i]);
            }
        }

        if ($count > 0) {
            if (!DBUtil::insertObjectArray($obj, 'group_membership')) {
                return LogUtil::registerError($this->__('Error! Creation attempt failed.'));
            }
        }
        return true;
    }
function smarty_function_iwformsfileicon($params, &$smarty)
{
	$fileName = $params['fileName'];
		
	// Get file extension
	$fileExtension = strtolower(substr(strrchr($fileName,"."),1));

	// get file icon
	$ctypeArray = ModUtil::func('IWmain', 'user', 'getMimetype', array('extension' => $fileExtension));
	$fileIcon = $ctypeArray['icon'];
			
	$formsfileicon = $fileIcon;

	return $formsfileicon;
}
Пример #24
0
    /**
     * Initialise the IWnoteboard module creating module tables and module vars
     * @author Albert Pérez 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 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('IWnoteboard'))
            return false;
        if (!DBUtil::createTable('IWnoteboard_topics'))
            return false;

        //Create module vars
        $this->setVar('grups', '')
                ->setVar('permisos', '')
                ->setVar('marcat', '')
                ->setVar('verifica', '')
                ->setVar('caducitat', '30')
                ->setVar('repperdefecte', '1')
                ->setVar('colorrow1', '#FFFFFF')
                ->setVar('colorrow2', '#FFFFCC')
                ->setVar('colornewrow1', '#FFCC99')
                ->setVar('colornewrow2', '#99FFFF')
                ->setVar('attached', 'noteboard')
                ->setVar('notRegisteredSeeRedactors', '1')
                ->setVar('multiLanguage', '0')
                ->setVar('topicsSystem', '0')
                ->setVar('shipHeadersLines', '0')
                ->setVar('notifyNewEntriesByMail', '0')
                ->setVar('editPrintAfter', '-1')
                ->setVar('notifyNewCommentsByMail', '1')
                ->setVar('commentCheckedByDefault', '1')
                ->setVar('smallAvatar', '0');

		HookUtil::registerSubscriberBundles($this->version->getHookSubscriberBundles());

        //Initialation successfull
        return true;
    }
Пример #25
0
    /**
     * This is a standard function to modify the configuration parameters of the module
     * @author Francesc Bassas i Bullich
     * @return string HTML string
     */
    public function modifyconfig() {
        // security check
        if (!SecurityUtil::checkPermission('SiriusXtecMailer::', '::', ACCESS_ADMIN)) {
            return LogUtil::registerPermissionError();
        }

        // create a new output object
        $render = Zikula_View::getInstance('SiriusXtecMailer', false);

        // assign the module contenttypes
        $render->assign('contenttypes', ModUtil::func('SiriusXtecMailer', 'admin', 'getContentTypes'));

        // assign all module vars
        $render->assign(ModUtil::getVar('SiriusXtecMailer'));
        return $render->fetch('siriusxtecmailer_admin_modifyconfig.tpl');
    }
Пример #26
0
 /**
  * This method provides a handling of edit requests.
  *
  * @param string  $ot           Treated object type.
  * @param string  $tpl          Name of alternative template (to be used instead of the default template).
  * @param boolean $raw          Optional way to display a template instead of fetching it (required for standalone output).
  *
  * @return mixed Output.
  */
 public function getVideos()
 {
     $controllerHelper = new MUVideo_Util_Controller($this->serviceManager);
     // parameter specifying which type of objects we are treating
     $objectType = $this->request->query->filter('ot', 'collection', FILTER_SANITIZE_STRING);
     $utilArgs = array('controller' => 'user', 'action' => 'getVideos');
     if (!in_array($objectType, $controllerHelper->getObjectTypes('controllerAction', $utilArgs))) {
         $objectType = $controllerHelper->getDefaultObjectType('controllerAction', $utilArgs);
     }
     $permLevel = ACCESS_EDIT;
     $this->throwForbiddenUnless(SecurityUtil::checkPermission($this->name . ':' . ucfirst($objectType) . ':', '::', $permLevel), LogUtil::getErrorMsgPermission());
     // redirect to entity controller
     System::queryStringSetVar('lct', 'user');
     $this->request->query->set('lct', 'user');
     return ModUtil::func($this->name, $objectType, 'getVideos', array('lct' => 'user'));
 }
Пример #27
0
    /**
     * Initialise the IWforums module creating module tables and module vars
     * @author Albert Pérez 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 required. You have to install the IWmain module previously to install it.'));
        }

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

        // Create module tables
        if (!DBUtil::createTable('IWforums_definition'))
            return false;
        if (!DBUtil::createTable('IWforums_temes'))
            return false;
        if (!DBUtil::createTable('IWforums_msg'))
            return false;
        
        //Create indexes
        $tables = DBUtil::getTables();
        $c = $tables['IWforums_msg_column'];
        if (!DBUtil::createIndex($c['idparent'], 'IWforums_msg', 'idparent'))
            return false;
        if (!DBUtil::createIndex($c['ftid'], 'IWforums_msg', 'ftid'))
            return false;
        if (!DBUtil::createIndex($c['fid'], 'IWforums_msg', 'fid'))
            return false;

        $c = $tables['IWforums_temes_column'];
        if (!DBUtil::createIndex($c['fid'], 'IWforums_temes', 'fid'))
            return false;

        //Create module vars
        $this->setVar('urladjunts', 'forums')
                ->setVar('avatarsVisible', '1')
                ->setVar('restyledTheme', '1')
                ->setVar('smiliesActive', '1');
        
        HookUtil::registerSubscriberBundles($this->version->getHookSubscriberBundles());
        //Initialation successfull
        return true;
    }
Пример #28
0
    /**
     * Fetch and render the configuration template.
     *
     * @return string The rendered template.
     */
    public function configure()
    {
        $modVars = $this->plugin->getVars();
        $options = array(
            'mode' => array('inset', 'outset'),
            'extension' => array('jpg', 'png', 'gif'),
        );

        $this->getView()
            ->assign('header', ModUtil::func('Admin', 'admin', 'adminheader'))
            ->assign('footer', ModUtil::func('Admin', 'admin', 'adminfooter'))
            ->assign('vars', $modVars)
            ->assign('thumb_full_dir', CacheUtil::getLocalDir($modVars['thumb_dir']))
            ->assign('options', $options);

        return $this->getView()->fetch('configuration.tpl');
    }
Пример #29
0
 public function display($blockinfo)
 {
     // security check
     $this->throwForbiddenUnless(SecurityUtil::checkPermission('Content:OnePageBlock:', "{$blockinfo['title']}::", ACCESS_READ), LogUtil::getErrorMsgPermission());
     // Break out options from our content field
     $vars = BlockUtil::varsFromContent($blockinfo['content']);
     // --- Setting of the Defaults
     if (!isset($vars['page'])) {
         $vars['page'] = 0;
     }
     if ($vars['page'] > 0) {
         $blockinfo['content'] = ModUtil::func('Content', 'user', 'view', array('pid' => $vars['page']));
     } else {
         $blockinfo['content'] = $this->__('No page selected');
     }
     return BlockUtil::themeBlock($blockinfo);
 }
Пример #30
0
/**
 * Zikula_View function to to execute a module function
 *
 * This function calls a specific module function.  It returns whatever the return
 * value of the resultant function is if it succeeds.
 * Note that in contrast to the API function ModUtil::func you need not to load the
 * module with ModUtil::load.
 *
 *
 * Available parameters:
 *   - modname:  The well-known name of a module to execute a function from (required)
 *   - type:     The type of function to execute; currently one of 'user' or 'admin' (default is 'user')
 *   - func:     The name of the module function to execute (default is 'main')
 *   - assign:   If set, the results are assigned to the corresponding variable instead of printed out
 *   - all remaining parameters are passed to the module function
 *
 * Example
 * {modfunc modname='News' type='user' func='view'}
 *
 * @param array       $params All attributes passed to this function from the template.
 * @param Zikula_View $view   Reference to the Zikula_View object.
 *
 * @see    function.ModUtil::apiFunc.php::smarty_function_modapifunc()
 * 
 * @return string The results of the module function.
 */
function smarty_function_modfunc($params, Zikula_View $view)
{
    //889$saveDomain = $view->renderDomain;
    $assign  = isset($params['assign'])                  ? $params['assign']  : null;
    $func    = isset($params['func']) && $params['func'] ? $params['func']    : 'main';
    $modname = isset($params['modname'])                 ? $params['modname'] : null;
    $type    = isset($params['type']) && $params['type'] ? $params['type']    : 'user';
    $return  = isset($params['return'])                  ? $params['return']  : null;

    // avoid passing these to ModUtil::func
    unset($params['modname']);
    unset($params['type']);
    unset($params['func']);
    unset($params['assign']);

    if (!$modname) {
        $view->trigger_error(__f('Error! in %1$s: the %2$s parameter must be specified.', array('modfunc', 'modname')));
        return false;
    }

    if (isset($params['modnamefunc'])) {
        $params['modname'] = $params['modnamefunc'];
        unset($params['modnamefunc']);
    }

    $result = ModUtil::func($modname, $type, $func, $params);
    if (is_array($result)) {
        $renderer = Zikula_View::getInstance($modname);
        $renderer->assign($result);
        if (isset($return['template'])) {
            echo $renderer->fetch($return['template']);
        } else {
            $modname = strtolower($modname);
            $type = strtolower($type);
            $func = strtolower($func);
            $result = $renderer->fetch("{$modname}_{$type}_{$func}.tpl");
        }
    }

    if ($assign) {
        $view->assign($assign, $result);
    } else {
        return $result;
    }
}