示例#1
0
	function Header()
	{
	    $modid = ModUtil::getIdFromName('IWmain');
        $modinfo = ModUtil::getInfo($modid);
	
	    // Si variable 'encap' no té contingut o el mòdul IWmain no està actiu no apareixerà encapçalament
        if(($modinfo['state'] != 3) ||(!is_null(ModUtil::getVar('IWbooks', 'encap')))){
			$imatge = ModUtil::getVar('IWmain', 'documentRoot').'/'.ModUtil::getVar('IWbooks', 'encap');
			if (file_exists($imatge) && (ModUtil::getVar('IWbooks', 'encap') != '')){
			    $this->Image($imatge,8,6,180);
			}		    
	    }		
		
		//$this->Image(ModUtil::getVar('IWbooks', 'encap'),8,6,180);
		//$dir = ModUtil::getVar('IWmain', 'documentRoot')."/public/encap.jpg";
		//$dir = ModUtil::getVar('IWmain', 'documentRoot').$imatge;
		
		
		//Arial bold 15
		$this->SetFont('Arial','B',15);
		//Ens movem a la dreta
		$this->Cell(80);
		//Títol
		//Salt de línia
		$this->Ln(30);

		if (ModUtil::getVar('IWbooks', 'marca_aigua') == 1)
		{
			// Fer marca d'aigua
			$this->SetFont('Arial','B',50);
			$this->SetTextColor(140,140,140);
			$this->RotatedText(50,190,'P r o v i s i o n a l',45);
		}
	}
示例#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 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;
    }
示例#4
0
    public function main() {

        // Security check
        if (!SecurityUtil::checkPermission('IWvhmenu::', '::', ACCESS_ADMIN)) {
            return LogUtil::registerPermissionError();
        }

        // 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. If not return error
        $versionNeeded = '2.0';
        if (!ModUtil::func('IWmain', 'admin', 'checkVersion', array('version' => $versionNeeded))) {
            return false;
        }

        // Gets the groups information
        $sv = ModUtil::func('IWmain', 'user', 'genSecurityValue');
        $grupsInfo = ModUtil::func('IWmain', 'user', 'getAllGroupsInfo', array('sv' => $sv));

        // Get the menu
        $menu = ModUtil::func('IWvhmenu', 'admin', 'getsubmenu', array('id_parent' => 0,
                    'grups_info' => $grupsInfo,
                    'level' => 0));

        // Pass the data to the template
        return $this->view->assign('menuarray', $menu)
                        ->assign('image_folder', ModUtil::getVar('IWvhmenu', 'imagedir'))
                        ->fetch('IWvhmenu_admin_main.htm');
    }
示例#5
0
    public function profile() {
        // Security check
        if (!SecurityUtil::checkPermission('IWusers::', "::", ACCESS_READ) || !UserUtil::isLoggedIn()) {
            throw new Zikula_Exception_Forbidden();
        }
        $uid = UserUtil::getVar('uid');

        $sv = ModUtil::func('IWmain', 'user', 'genSecurityValue');
        $photo = ModUtil::func('IWmain', 'user', 'getUserPicture', array('uname' => UserUtil::getVar('uname'),
                    'sv' => $sv));
        $sv = ModUtil::func('IWmain', 'user', 'genSecurityValue');
        $photo_s = ModUtil::func('IWmain', 'user', 'getUserPicture', array('uname' => '_' . UserUtil::getVar('uname'),
                    'sv' => $sv));
        //Check if gd library is available
        if (extension_loaded('gd') && ModUtil::getVar('IWusers', 'allowUserChangeAvatar') == 1)
            $canChangeAvatar = true;
        //Check if the users picture folder exists
        if (!file_exists(ModUtil::getVar('IWmain', 'documentRoot') . '/' . ModUtil::getVar('IWusers', 'usersPictureFolder')) || ModUtil::getVar('IWusers', 'usersPictureFolder') == '') {
            $canChangeAvatar = false;
        } else {
            if (!is_writeable(ModUtil::getVar('IWmain', 'documentRoot') . '/' . ModUtil::getVar('IWusers', 'usersPictureFolder')))
                $canChangeAvatar = false;
        }
        // checks if user can change their real names
        $modid = ModUtil::getIdFromName('IWusers');
        $modinfo = ModUtil::getInfo($modid);
        $usersCanManageName = (ModUtil::getVar('IWusers', 'usersCanManageName') == 1) ? true : false;
        $allowUserSetTheirSex = (ModUtil::getVar('IWusers', 'allowUserSetTheirSex') == 1) ? true : false;
        $allowUserDescribeTheirSelves = (ModUtil::getVar('IWusers', 'allowUserDescribeTheirSelves') == 1) ? true : false;


        $userSurname1 = '';
        $userSurname2 = '';
        if ($modinfo['state'] == 3) {
            $sv = ModUtil::func('IWmain', 'user', 'genSecurityValue');
            $userInfo = ModUtil::func('IWmain', 'user', 'getUserInfo', array('uid' => UserUtil::getVar('uid'),
                        'info' => array('n', 'c1', 'c2', 'd', 's'),
                        'sv' => $sv));
            $userName = $userInfo['n'];
            $userSurname1 = $userInfo['c1'];
            $userSurname2 = $userInfo['c2'];
            $description = $userInfo['d'];
            $sex = $userInfo['s'];
        }

        return $this->view->assign('avatarChangeValidationNeeded', ModUtil::getVar('IWusers', 'avatarChangeValidationNeeded'))
                        ->assign('photo', $photo)
                        ->assign('photo_s', $photo_s)
                        ->assign('canChangeAvatar', $canChangeAvatar)
                        ->assign('usersCanManageName', $usersCanManageName)
                        ->assign('allowUserSetTheirSex', $allowUserSetTheirSex)
                        ->assign('allowUserDescribeTheirSelves', $allowUserDescribeTheirSelves)
                        ->assign('userName', $userName)
                        ->assign('userSurname1', $userSurname1)
                        ->assign('userSurname2', $userSurname2)
                        ->assign('description', $description)
                        ->assign('sex', $sex)
                        ->fetch('IWusers_user_profile.htm');
    }
示例#6
0
 public function upgrade()
 {
     $filemodules = \ModUtil::apiFunc('ZikulaExtensionsModule', 'admin', 'getfilemodules');
     \ModUtil::apiFunc('ZikulaExtensionsModule', 'admin', 'regenerate', ['filemodules' => $filemodules]);
     $worked = \ModUtil::apiFunc('ZikulaExtensionsModule', 'admin', 'upgrade', ['id' => \ModUtil::getIdFromName('CmfcmfMediaModule')]);
     if ($worked == true) {
         return $worked;
     }
     return $this->translator->trans('Something went wrong with the upgrade code. This should not have happened!', [], $this->domain);
 }
示例#7
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;
    }
示例#8
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;
    }
示例#9
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;
    }
示例#10
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;
    }
示例#11
0
    public function install(){
        if (!SecurityUtil::checkPermission('Cataleg::', '::', ACCESS_ADMIN)) {
            return LogUtil::registerPermissionError();
        }
        // Verificar si el mòdul IWusers està instal·lat. Si no ho està, retorna error
        $modid = ModUtil::getIdFromName('IWusers');
        $modinfo = ModUtil::getInfo($modid);
        if ($modinfo['state'] != 3) {
            return LogUtil::registerError($this->__('El mòdul IWusers és imprescindible. Cal tenir-lo instal·lat abans d\'instal·lar el mòdul del catàleg.'));
        }

        // Verificar versió del mòdul IWusers
        $versionNeeded = '3.1.0';
        if ($modinfo['version'] < $versionNeeded) {
            throw new Zikula_Exception_Forbidden($this->__('Versió del mòdul IWusers incorrecta. Versió mínima 3.1.0'));
        }
        // Crear les taules del mòdul
        if (!DBUtil::createTable('cataleg')||
            !DBUtil::createTable('cataleg_eixos')||
            !DBUtil::createTable('cataleg_prioritats')||
            !DBUtil::createTable('cataleg_unitatsImplicades')||
            !DBUtil::createTable('cataleg_subprioritats')|| 
            !DBUtil::createTable('cataleg_activitats')||               
            !DBUtil::createTable('cataleg_activitatsZona')||   
            !DBUtil::createTable('cataleg_unitats')||
            !DBUtil::createTable('cataleg_responsables')||
            !DBUtil::createTable('cataleg_contactes')||
            !DBUtil::createTable('cataleg_auxiliar')||
            !DBUtil::createTable('cataleg_centresActivitat')||
	    !DBUtil::createTable('cataleg_centres')||
            !DBUtil::createTable('cataleg_gestioActivitatDefaults')||
            !DBUtil::createTable('cataleg_importTaules')||
            !DBUtil::createTable('cataleg_importAssign') ||
            !DBUtil::createTable('cataleg_gtafEntities') ||
            !DBUtil::createTable('cataleg_gtafGroups')
            )
            return false;

        ModUtil::setVar($this->name, 'novetats', array('dataPublicacio'=>'','diesNovetats'=> 15, 'showNew' => true, 'showMod' => true));
        
        HookUtil::registerSubscriberBundles($this->version->getHookSubscriberBundles());
        //Successfull
        return true;
    }
示例#12
0
 /**
  * display block
  */
 public function display($blockinfo)
 {
     // Security check
     if (!SecurityUtil::checkPermission('Admin:adminnavblock', "{$blockinfo['title']}::{$blockinfo['bid']}", ACCESS_ADMIN)) {
         return;
     }
     // Get variables from content block
     $vars = BlockUtil::varsFromContent($blockinfo['content']);
     // Call the modules API to get the items
     if (!ModUtil::available('Admin')) {
         return;
     }
     $items = ModUtil::apiFunc('Admin', 'admin', 'getall');
     // Check for no items returned
     if (empty($items)) {
         return;
     }
     // get admin capable modules
     $adminmodules = ModUtil::getAdminMods();
     $adminmodulescount = count($adminmodules);
     // Display each item, permissions permitting
     $admincategories = array();
     foreach ($items as $item) {
         if (SecurityUtil::checkPermission('Admin::', "{$item['catname']}::{$item['cid']}", ACCESS_READ)) {
             $adminlinks = array();
             foreach ($adminmodules as $adminmodule) {
                 // Get all modules in the category
                 $catid = ModUtil::apiFunc('Admin', 'admin', 'getmodcategory', array('mid' => ModUtil::getIdFromName($adminmodule['name'])));
                 if ($catid == $item['cid'] || $catid == false && $item['cid'] == $this->getVar('defaultcategory')) {
                     $modinfo = ModUtil::getInfoFromName($adminmodule['name']);
                     $menutexturl = ModUtil::url($modinfo['name'], 'admin');
                     $menutexttitle = $modinfo['displayname'];
                     $adminlinks[] = array('menutexturl' => $menutexturl, 'menutexttitle' => $menutexttitle);
                 }
             }
             $admincategories[] = array('url' => ModUtil::url('Admin', 'admin', 'adminpanel', array('cid' => $item['cid'])), 'title' => DataUtil::formatForDisplay($item['catname']), 'modules' => $adminlinks);
         }
     }
     $this->view->assign('admincategories', $admincategories);
     // Populate block info and pass to theme
     $blockinfo['content'] = $this->view->fetch('admin_block_adminnav.tpl');
     return BlockUtil::themeBlock($blockinfo);
 }
示例#13
0
    /**
     * Delete the IWTimeFrames module & update existing bookings references
     * @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 uninstall() {
        // Delete module table
        DBUtil::dropTable('IWtimeframes');
        DBUtil::dropTable('IWtimeframes_definition');

        // Totes les referències als marcs s'han d'esborrar a IWbookings_spaces
        // 1r. mirar si existeix el mòdul i després actualitzar els registres

        $modid = ModUtil::getIdFromName('IWbookings');
        $modinfo = ModUtil::getInfo($modid);

        if ($modinfo['state'] > 1) {
            $obj = array('mdid' => 0);
            DBUtil::updateObject($obj, 'IWbookings_spaces', 'mdid != 0');
        }

        //Delete module vars
        $this->delVar('frames');

        //Deletion successfull
        return true;
    }
示例#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 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 = '3.0.0';
        if (!ModUtil::func('IWmain', 'admin', 'checkVersion', array('version' => $versionNeeded))) {
            return false;
        }

        // Create module tables
        if (!DBUtil::createTable('IWmessages'))
            return false;

        //Create indexes
        $pntable = DBUtil::getTables();
        $c = $pntable['IWmessages_column'];
        if (!DBUtil::createIndex($c['from_userid'], 'IWmessages', 'from_userid'))
            return false;
        if (!DBUtil::createIndex($c['to_userid'], 'IWmessages', 'to_userid'))
            return false;

        //Set module vars
        $this->setVar('groupsCanUpdate', '$')
                ->setVar('uploadFolder', 'messages')
                ->setVar('multiMail', '$')
                ->setVar('limitInBox', '50')
                ->setVar('limitOutBox', '50')
                ->setVar('dissableSuggest', '0')
                ->setVar('smiliesActive', '1');
		HookUtil::registerSubscriberBundles($this->version->getHookSubscriberBundles());
        return true;
    }
示例#16
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;
    }
示例#17
0
/**
 * Zikula_View function to retrieve module information
 *
 * This function retrieves module information from the database and returns them
 * or assigns them to a variable for later use
 *
 *
 * Available parameters:
 *   - info        the information you want to retrieve from the modules info,
 *                 "all" results in assigning all information, see $assign
 *   - assign      (optional or mandatory :-)) if set, assign the result instead of returning it
 *                 if $info is "all", a $assign is mandatory and the default is modinfo
 *   - modname     (optional) module name, if not set, the recent module is used
 *   - modid       (optional) module id, if not set, the recent module is used
 *
 * Example
 *   {modgetinfo info='displayname'}
 *   {modgetinfo info='all' assign='gimmeeverything'}
 *   {modgetinfo modname='anyymodname' info='all' assign='gimmeeverything'}
 *
 * @param array       $params All attributes passed to this function from the template.
 * @param Zikula_View $view   Reference to the Zikula_View object.
 *
 * @return string The module variable.
 */
function smarty_function_modgetinfo($params, Zikula_View $view)
{
    $assign = isset($params['assign']) ? $params['assign'] : null;
    $info = isset($params['info']) ? $params['info'] : null;
    $modid = isset($params['modid']) ? (int) $params['modid'] : 0;
    $modname = isset($params['modname']) ? $params['modname'] : null;
    $default = isset($params['default']) ? $params['default'] : false;
    if (!$modid) {
        $modname = $modname ? $modname : ModUtil::getName();
        if (!ModUtil::available($modname)) {
            if ($assign) {
                $view->assign($assign, $default);
                return false;
            }
            $view->assign($assign, $default);
            return;
        }
        $modid = ModUtil::getIdFromName($modname);
    }
    $modinfo = ModUtil::getInfo($modid);
    $info = strtolower($info);
    if ($info != 'all' && !isset($modinfo[$info])) {
        $view->trigger_error(__f('Invalid %1$s [%2$s] passed to %3$s.', array('info', $info, 'modgetinfo')));
        return false;
    }
    if ($info == 'all') {
        $assign = $assign ? $assign : 'modinfo';
        $view->assign($assign, $modinfo);
    } else {
        if ($assign) {
            $view->assign($assign, $modinfo[$info]);
        } else {
            return DataUtil::formatForDisplay($modinfo[$info]);
        }
    }
}
示例#18
0
 /**
  * Main category menu.
  *
  * @return string HTML string
  */
 public function categorymenuAction(array $args = array())
 {
     // get the current category
     $acid = $this->request->query->get('acid', isset($args['acid']) ? $args['acid'] : $this->getVar('startcategory'));
     // Get all categories
     $categories = array();
     $items = \ModUtil::apiFunc('AdminModule', 'admin', 'getall');
     foreach ($items as $item) {
         if (\SecurityUtil::checkPermission('Admin::', "{$item['name']}::{$item['cid']}", ACCESS_READ)) {
             $categories[] = $item;
         }
     }
     // get admin capable modules
     $adminmodules = \ModUtil::getModulesCapableOf('admin');
     $adminlinks = array();
     foreach ($adminmodules as $adminmodule) {
         if (\SecurityUtil::checkPermission("{$adminmodule['name']}::", '::', ACCESS_EDIT)) {
             $catid = \ModUtil::apiFunc('AdminModule', 'admin', 'getmodcategory', array('mid' => $adminmodule['id']));
             $order = \ModUtil::apiFunc('AdminModule', 'admin', 'getSortOrder', array('mid' => \ModUtil::getIdFromName($adminmodule['name'])));
             $menutexturl = \ModUtil::url($adminmodule['name'], 'admin', 'index');
             $menutext = $adminmodule['displayname'];
             $menutexttitle = $adminmodule['description'];
             $adminlinks[$catid][] = array('menutexturl' => $menutexturl, 'menutext' => $menutext, 'menutexttitle' => $menutexttitle, 'modname' => $adminmodule['name'], 'order' => $order);
         }
     }
     foreach ($adminlinks as &$item) {
         usort($item, 'AdminModule\\Controller\\_sortAdminModsByOrder');
     }
     $menuoptions = array();
     $possible_cids = array();
     $permission = false;
     if (isset($categories) && is_array($categories)) {
         foreach ($categories as $category) {
             // only categories containing modules where the current user has permissions will
             // be shown, all others will be hidden
             // admin will see all categories
             if (isset($adminlinks[$category['cid']]) && count($adminlinks[$category['cid']]) || \SecurityUtil::checkPermission('.*', '.*', ACCESS_ADMIN)) {
                 $menuoption = array('url' => \ModUtil::url('Admin', 'admin', 'adminpanel', array('acid' => $category['cid'])), 'title' => $category['name'], 'description' => $category['description'], 'cid' => $category['cid']);
                 if (isset($adminlinks[$category['cid']])) {
                     $menuoption['items'] = $adminlinks[$category['cid']];
                 } else {
                     $menuoption['items'] = array();
                 }
                 $menuoptions[$category['cid']] = $menuoption;
                 $possible_cids[] = $category['cid'];
                 if ($acid == $category['cid']) {
                     $permission = true;
                 }
             }
         }
     }
     // if permission is false we are not allowed to see this category because its
     // empty and we are not admin
     if ($permission == false) {
         // show the first category
         $acid = !empty($possible_cids) ? (int) $possible_cids[0] : null;
     }
     $this->view->assign('currentcat', $acid);
     $this->view->assign('menuoptions', $menuoptions);
     // security analyzer and update checker warnings
     $notices = array();
     $notices['security'] = $this->_securityanalyzer();
     $notices['update'] = $this->_updatecheck();
     $notices['developer'] = $this->_developernotices();
     $this->view->assign('notices', $notices);
     // this should not return a response since it's being used as an API call for some odd reason... drak
     return $this->view->fetch('Admin/categorymenu.tpl');
 }
示例#19
0
    /**
     * upgrade the theme module from an old version
     *
     * This function must consider all the released versions of the module!
     * If the upgrade fails at some point, it returns the last upgraded version.
     *
     * @param  string $oldVersion version number string to upgrade from
     * @return mixed  true on success, last valid version string or false if fails
     */
    public function upgrade($oldversion)
    {
        // update the table
        if (!DBUtil::changeTable('themes')) {
            return false;
        }

        switch ($oldversion) {
            case '3.1':
                $this->setVar('cssjscombine', false);
                $this->setVar('cssjscompress', false);
                $this->setVar('cssjsminify', false);
                $this->setVar('cssjscombine_lifetime', 3600);

            case '3.3':
            // convert pnRender modvars
                $pnrendervars = ModUtil::getVar('pnRender');
                foreach ($pnrendervars as $k => $v) {
                    $this->setVar('render_' . $k, $v);
                }
                // delete pnRender modvars
                ModUtil::delVar('pnRender');

                $modid = ModUtil::getIdFromName('pnRender');

                // check and update blocks
                $blocks = ModUtil::apiFunc('Blocks', 'user', 'getall', array('modid' => $modid));
                if (!empty($blocks)) {
                    $thememodid = ModUtil::getIdFromName('Theme');
                    foreach ($blocks as $block) {
                        $block->setBkey('render');
                        $block->setMid($thememodid);
                        $this->entityManager->flush();
                    }
                }

                // check and fix permissions
                $dbtable = DBUtil::getTables();
                $permscolumn = $dbtable['group_perms_column'];
                $permswhere = "WHERE $permscolumn[component] = 'pnRender:pnRenderblock:'";
                $perms = DBUtil::selectObjectArray('group_perms', $permswhere);
                if (!empty($perms)) {
                    foreach ($perms as $perm) {
                        $perm['component'] = 'Theme:Renderblock:';
                        DBUtil::updateObject($perm, 'group_perms', '', 'pid');
                    }
                }

                // Set Module pnRender 'Inactive'
                if (!ModUtil::apiFunc('Extensions', 'admin', 'setstate', array(
                'id' => $modid,
                'state' => ModUtil::STATE_INACTIVE))) {
                    return '3.3';
                }
                // Remove Module pnRender from Modulelist
                if (!ModUtil::apiFunc('Extensions', 'admin', 'remove', array(
                'id' => $modid))) {
                    return '3.3';
                }

            case '3.4':
                if (!DBUtil::changeTable('themes')) {
                    return '3.4';
                }
            case '3.4.1':
                if (!DBUtil::changeTable('themes')) {
                    return '3.4.1';
                }
                $this->setVar('enable_mobile_theme', false);
            case '3.4.2':
                // future upgrade
        }

        // Update successful
        return true;
    }
示例#20
0
    /**
     * Define a message as marked
     * @author:     Albert Pérez Monfort (aperezm@xtec.cat)
     * @param:	args   Array with the id of the message
     * @return:	Redirect to the user main page
     */
    public function mark($args) {
        
        if (!SecurityUtil::checkPermission('IWforums::', '::', ACCESS_READ)) {
            throw new Zikula_Exception_Fatal($this->__('Sorry! No authorization to access this module.'));
        }

        if (!UserUtil::isLoggedIn()) {
            throw new Zikula_Exception_Fatal();
        }

        $fid = $this->request->getPost()->get('fid', '');
        if (!$fid) {
            throw new Zikula_Exception_Fatal($this->__('no forum id'));
        }

        $fmid = $this->request->getPost()->get('fmid', '');
        if (!$fmid) {
            throw new Zikula_Exception_Fatal($this->__('no message id'));
        }

        //get forum information
        $forum = ModUtil::apiFunc('IWforums', 'user', 'get',
                                   array('fid' => $fid));
        if ($forum == false) {
            AjaxUtil::error($this->__('The forum upon which the action had to be carried out hasn\'t been found'));
        }

        //check if user can access the forum
        $access = ModUtil::func('IWforums', 'user', 'access',
                                 array('fid' => $fid));
        if ($access < 1) {
            AjaxUtil::error($this->__('You can\'t access the forum'));
        }

        //get message information
        $registre = ModUtil::apiFunc('IWforums', 'user', 'get_msg',
                                      array('fmid' => $fmid));
        if ($registre == false) {
            AjaxUtil::error($this->__('No messages have been found'));
        }

        $marcat = (strpos($registre['marcat'], '$' . UserUtil::getVar('uid') . '$') === false) ? $registre['marcat'] . '$' . UserUtil::getVar('uid') . '$' : str_replace('$' . UserUtil::getVar('uid') . '$', '', $registre['marcat']);

        $m = (strpos($registre['marcat'], '$' . UserUtil::getVar('uid') . '$') === false) ? 1 : 0;

        $ha_marcat = ModUtil::apiFunc('IWforums', 'user', 'marcat',
                                       array('marcat' => $marcat,
                                             'fmid' => $fmid));
        ;
        $sv = ModUtil::func('IWmain', 'user', 'genSecurityValue');
        ModUtil::func('IWmain', 'user', 'userSetVar',
                       array('module' => 'IWmain_block_flagged',
                             'name' => 'have_flags',
                             'value' => 'fo',
                             'sv' => $sv));

        $markText = ($m == 0) ? $this->__("Check the message") : $this->__('Uncheck the message');
        
        $ofMarkText = $markText;
        $markText = "<span style=\"cursor: pointer;\" id=\"markText\"><a onclick=\"javascript:mark(" . $fid . "," . $fmid . ")\">" . $markText . "</a></span>";
        $modid = ModUtil::getIdFromName('IWmain');
        $blocks = ModUtil::apiFunc('Blocks', 'user', 'getall',
                                    array('modid' => $modid));
        if (!empty($blocks)) {
            $reloadFlags = ($blocks[0]['active'] == 1) ? true : false;
        } else {
            $reloadFlags = false;
        }

        return new Zikula_Response_Ajax(array('fmid' => $fmid,
                'm' => $m,
                'markText' => $markText,
                'ofMarkText' => $ofMarkText,
                'reloadFlags' => $reloadFlags,
                ));
    }
示例#21
0
    protected function newBlockPositions()
    {
        $positions = ModUtil::apiFunc('Blocks', 'user', 'getallpositions');

        // create the search block position if doesn't exists
        if (!isset($positions['search'])) {
            $searchpid = ModUtil::apiFunc('Blocks', 'admin', 'createposition', array('name' => 'search', 'description' => $this->__('Search block')));
        } else {
            $searchpid = $positions['search']['pid'];
        }

        // restores the search block if not present
        $dbtable      = DBUtil::getTables();
        $blockscolumn = $dbtable['blocks_column'];
        $searchblocks = DBUtil::selectObjectArray('blocks', "$blockscolumn[bkey] = 'Search'");

        if (empty($searchblocks)) {
            $block = array('bkey' => 'Search', 'collapsable' => 1, 'defaultstate' => 1, 'language' => '', 'mid' => ModUtil::getIdFromName('Search'), 'title' => $this->__('Search box'), 'description' => '', 'positions' => array($searchpid));
            $block['bid'] = ModUtil::apiFunc('Blocks', 'admin', 'create', $block);
            ModUtil::apiFunc('Blocks', 'admin', 'update', $block);
        } else {
            // assign the block to the search position
            $blockplacement = array('bid' => $searchblocks[0]['bid'], 'pid' => $searchpid);
            DBUtil::insertObject($blockplacement, 'block_placements');
        }

        // create new block positions if they don't exist
        if (!isset($positions['header'])) {
            $header = ModUtil::apiFunc('Blocks', 'admin', 'createposition', array('name' => 'header', 'description' => $this->__('Header block')));
        }
        if (!isset($positions['footer'])) {
            $footer = ModUtil::apiFunc('Blocks', 'admin', 'createposition', array('name' => 'footer', 'description' => $this->__('Footer block')));
        }
        if (!isset($positions['bottomnav'])) {
            $bottomnav = ModUtil::apiFunc('Blocks', 'admin', 'createposition', array('name' => 'bottomnav', 'description' => $this->__('Bottom navigation block')));
        }
        if (!isset($positions['topnav'])) {
            $topnav = ModUtil::apiFunc('Blocks', 'admin', 'createposition', array('name' => 'topnav', 'description' => $this->__('Top navigation block')));

            // Build content for the top navigation menu
            $languages = ZLanguage::getInstalledLanguages();
            $saveLanguage = ZLanguage::getLanguageCode();
            foreach ($languages as $lang) {
                ZLanguage::setLocale($lang);
                ZLanguage::bindCoreDomain();
                $topnavcontent = array();
                $topnavcontent['displaymodules'] = '0';
                $topnavcontent['stylesheet'] = 'extmenu.css';
                $topnavcontent['template'] = 'blocks_block_extmenu_topnav.tpl';
                $topnavcontent['blocktitles'][$lang] = $this->__('Top navigation');
                $topnavcontent['links'][$lang][] = array('name' => $this->__('Home'), 'url' => '{homepage}', 'title' => $this->__("Go to the site's home page"), 'level' => 0, 'parentid' => null, 'image' => '', 'active' => '1');
                $topnavcontent['links'][$lang][] = array('name' => $this->__('My Account'), 'url' => '{Users}', 'title' => $this->__('Go to your account panel'), 'level' => 0, 'parentid' => null, 'image' => '', 'active' => '1');
                $topnavcontent['links'][$lang][] = array('name' => $this->__('Site search'), 'url' => '{Search}', 'title' => $this->__('Search this site'), 'level' => 0, 'parentid' => null, 'image' => '', 'active' => '1');
            }

            ZLanguage::setLocale($saveLanguage);
            $topnavcontent = serialize($topnavcontent);
            $topnavblock = array('bkey' => 'Extmenu', 'collapsable' => 1, 'defaultstate' => 1, 'language' => '', 'mid' => ModUtil::getIdFromName('Blocks'), 'title' => $this->__('Top navigation'), 'description' => '', 'content' => $topnavcontent, 'positions' => array($topnav));
            $topnavblock['bid'] = ModUtil::apiFunc('Blocks', 'admin', 'create', $topnavblock);
            ModUtil::apiFunc('Blocks', 'admin', 'update', $topnavblock);
        }
    }
示例#22
0
    /**
     * Initialise the IWforms 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 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 tables
        if (!DBUtil::createTable('IWforms_definition'))
            return false;
        if (!DBUtil::createTable('IWforms_cat'))
            return false;
        if (!DBUtil::createTable('IWforms'))
            return false;
        if (!DBUtil::createTable('IWforms_note'))
            return false;
        if (!DBUtil::createTable('IWforms_note_definition'))
            return false;
        if (!DBUtil::createTable('IWforms_validator'))
            return false;
        if (!DBUtil::createTable('IWforms_group'))
            return false;

        //Create indexes
        $pntable = DBUtil::getTables();
        $c = $pntable['IWforms_definition_column'];
        if (!DBUtil::createIndex($c['active'], 'IWforms_definition', 'active'))
            return false;

        $c = $pntable['IWforms_column'];
        if (!DBUtil::createIndex($c['fid'], 'IWforms', 'fid'))
            return false;

        $c = $pntable['IWforms_group_column'];
        if (!DBUtil::createIndex($c['fid'], 'IWforms_group', 'fid'))
            return false;

        $c = $pntable['IWforms_note_column'];
        if (!DBUtil::createIndex($c['fmid'], 'IWforms_note', 'fmid'))
            return false;
        if (!DBUtil::createIndex($c['fndid'], 'IWforms_note', 'fndid'))
            return false;

        $c = $pntable['IWforms_note_definition_column'];
        if (!DBUtil::createIndex($c['fid'], 'IWforms_note_definition', 'fid'))
            return false;

        $c = $pntable['IWforms_validator_column'];
        if (!DBUtil::createIndex($c['fid'], 'IWforms_validator', 'fid'))
            return false;

        //Set module vars
        $this->setVar('characters', '15')
                ->setVar('resumeview', '0')
                ->setVar('newsColor', '#90EE90')
                ->setVar('viewedColor', '#FFFFFF')
                ->setVar('completedColor', '#D3D3D3')
                ->setVar('validatedColor', '#CC9999')
                ->setVar('fieldsColor', '#ADD8E6')
                ->setVar('contentColor', '#FFFFE0')
                ->setVar('attached', 'forms')
                ->setVar('publicFolder', 'forms/public');
		HookUtil::registerSubscriberBundles($this->version->getHookSubscriberBundles());
        //Successfull
        return true;
    }
示例#23
0
 /**
  * Selector for a module's tables.
  *
  * @param string  $modname       Module name.
  * @param string  $name          Select field name.
  * @param string  $selectedValue Selected value.
  * @param string  $defaultValue  Value for "default" option.
  * @param string  $defaultText   Text for "default" option.
  * @param boolean $submit        Submit on choose.
  * @param string  $remove        Remove string from table name.
  * @param boolean $disabled      Add Disabled attribute to select.
  * @param integer $nStripChars   Strip the first n characters.
  * @param integer $multipleSize  Size for multiple selects.
  *
  * @return string The rendered output.
  */
 public static function getSelector_ModuleTables($modname, $name, $selectedValue = '', $defaultValue = 0, $defaultText = '', $submit = false, $remove = '', $disabled = false, $nStripChars = 0, $multipleSize = 1)
 {
     if (!$modname) {
         return z_exit(__f('Invalid %1$s passed to %2$s.', array('modname', 'HtmlUtil::getSelector_ModuleTables')));
     }
     $modinfo = ModUtil::getInfo(ModUtil::getIdFromName($modname));
     $modpath = $modinfo['type'] == ModUtil::TYPE_SYSTEM ? 'system' : 'modules';
     $osdir = DataUtil::formatForOS($modinfo['directory']);
     $entityDir = "{$modpath}/{$osdir}/Entity/";
     $entities = array();
     if (file_exists($entityDir)) {
         $files = scandir($entityDir);
         foreach ($files as $file) {
             if ($file != '.' && $file != '..' && substr($file, -4) === '.php') {
                 $entities[] = $file;
             }
         }
     }
     $data = array();
     foreach ($entities as $entity) {
         $class = $modname . '\\Entity\\' . substr($entity, 0, strlen($entity) - 4);
         if (class_exists($class)) {
             $entityName = substr($entity, 0, strlen($entity) - 4);
             if ($remove) {
                 $entityName = str_replace($remove, '', $entityName);
             }
             if ($nStripChars) {
                 $entityName = ucfirst(substr($entityName, $nStripChars));
             }
             $data[$entityName] = $entityName;
         }
     }
     return self::getSelector_Generic($name, $data, $selectedValue, $defaultValue, $defaultText, null, null, $submit, $disabled, $multipleSize);
 }
示例#24
0
    public function viewStats($args) {
        $statsSaved = unserialize(SessionUtil::getVar('statsSaved'));

        $moduleName = (isset($statsSaved['moduleName'])) ? $statsSaved['moduleName'] : '';
        $fromDate = (isset($statsSaved['fromDate'])) ? $statsSaved['fromDate'] : null;
        $toDate = (isset($statsSaved['toDate'])) ? $statsSaved['toDate'] : '';

        $moduleName = FormUtil::getPassedValue('moduleName', isset($args['moduleName']) ? $args['moduleName'] : $moduleName, 'GETPOST');
        $uname = FormUtil::getPassedValue('uname', isset($args['uname']) ? $args['uname'] : $statsSaved['uname'], 'GETPOST');
        $fromDate = FormUtil::getPassedValue('fromDate', isset($args['fromDate']) ? $args['fromDate'] : $fromDate, 'GETPOST');
        $toDate = FormUtil::getPassedValue('toDate', isset($args['toDate']) ? $args['toDate'] : $toDate, 'GETPOST');
        $uid = FormUtil::getPassedValue('uid', isset($args['uid']) ? $args['uid'] : 0, 'GETPOST');

        if ($uid > 0) {
            $uname = UserUtil::getVar('uname', $uid);
        }

        SessionUtil::setVar('statsSaved', serialize(array('uname' => $uname,
                    'moduleName' => $moduleName,
                    'fromDate' => $fromDate,
                    'toDate' => $toDate,
                )));


        if (!SecurityUtil::checkPermission('IWstats::', '::', ACCESS_ADMIN)) {
            throw new Zikula_Exception_Forbidden();
        }

        $uid = 0;
        $rpp = 50;
        $lastDays = 10;
        $nusers = 0;

        if ($uname != null && $uname != '') {
            // get user id from uname
            $uid = UserUtil::getIdFromName($uname);
            if (!$uid) {
                LogUtil::registerError(__f('User \'%s\' not found', array($uname)));
                $uname = '';
            }
        }

        $time = time();

        if ($fromDate != null) {
            $fromDate = mktime(0, 0, 0, substr($fromDate, 3, 2), substr($fromDate, 0, 2), substr($fromDate, 6, 4));
            $fromDate = date('Y-m-d 00:00:00', $fromDate);
            $fromDate = DateUtil::makeTimestamp($fromDate);
            $fromDate = date('d-m-Y', $fromDate);
        } else {
            $fromDate = date('d-m-Y', $time - $lastDays * 24 * 60 * 60);
        }

        if ($toDate != null) {
            $toDate = mktime(0, 0, 0, substr($toDate, 3, 2), substr($toDate, 0, 2), substr($toDate, 6, 4));
            $toDate = date('Y-m-d 00:00:00', $toDate);
            $toDate = DateUtil::makeTimestamp($toDate);
            $toDate = date('d-m-Y', $toDate);
        } else {
            $toDate = date('d-m-Y', $time);
        }

        // get last records
        $records = ModUtil::apiFunc('IWstats', 'user', 'getAllSummary', array('rpp' => -1,
                    'init' => -1,
                    'fromDate' => $fromDate,
                    'toDate' => $toDate,
                ));

        // get all modules
        $modules = ModUtil::apiFunc('Extensions', 'admin', 'listmodules', array('state' => 0));

        foreach ($modules as $module) {
            $modulesNames[$module['id']] = $module['name'];
            $modulesArray[] = array('id' => $module['id'],
                'name' => $module['name']);
        }

        $modulesNames[0] = $this->__('unknown');

        $usersListArray = array();
        $moduleStatsArray = array();
        $userModulesArray = array();
        $userArray = array();
        $moduleArray = array();
        $usersForModule = array();
        $users = array();
        $usersIpCounter = 0;
        $nRecords = 0;
        $userNRecords = 0;
        $usersList = '';
        $userName = '';
        foreach ($records as $record) {
            $nRecords = $nRecords + $record['nrecords'];
            $usersIpCounter = $usersIpCounter + $record['nips'];
            $users = explode('$$', substr($record['users'], 1, -1)); // substr to remove $ in the begining and the end of the string
            foreach ($users as $user) {
                $oneUser = explode('|', $user);

                if (!in_array($oneUser[0], $usersListArray)) {
                    $nusers++;
                    $usersListArray[] = $oneUser[0];
                }
                if ($oneUser[0] == $uid && $uid > 0) {
                    $userInit = '$' . $uid . '|';
                    $userDataPos = strpos($record['users'], $userInit);
                    $subDataPre = substr($record['users'], $userDataPos + strlen($userInit));
                    $userDataPos = strpos($subDataPre, '$');
                    $subDataPre = substr($subDataPre, 0, $userDataPos);
                    $userModules = explode('#', $subDataPre);
                    foreach ($userModules as $module) {
                        $oneModule = explode('=', $module);
                        if (array_key_exists($modulesNames[$oneModule[0]], $userModulesArray)) {
                            $userModulesArray[$modulesNames[$oneModule[0]]] = $oneModule[1];
                        } else {
                            $userModulesArray[$modulesNames[$oneModule[0]]] = $userModulesArray[$modulesNames[$oneModule[0]]] + $oneModule[1];
                        }

                        $userNRecords = $userNRecords + $oneModule[1];
                    }
                }
                if ($moduleName != '') {
                    $moduleId = ModUtil::getIdFromName($moduleName);
                    if ((strpos($oneUser[1], $moduleId . '=') !== false && strpos($oneUser[1], $moduleId . '=') == 0) || strpos($oneUser[1], '#' . $moduleId . '=') !== false) {
                        // get the number of views
                        $pos = strpos($oneUser[1], $moduleId . '=');
                        if ($pos != 0) {
                            $pos = strpos($oneUser[1], '#' . $moduleId . '=');
                        }
                        $preString = substr($oneUser[1], $pos);
                        //print $preString . '<br />';
                        if ($pos != 0) {
                            $preString = substr($preString, 1);
                        }
                        $pos = strpos($preString, '#');
                        $preString = ($pos == 0) ? $preString : substr($preString, 0, $pos);
                        $num = explode('=', $preString);
                        if (!array_key_exists($oneUser[0], $usersForModule)) {
                            $usersForModule[$oneUser[0]] = $num[1];
                            $usersList .= $oneUser[0] . '$$';
                        } else {
                            $usersForModule[$oneUser[0]] = $usersForModule[$oneUser[0]] + $num[1];
                        }
                    }
                }
            }

            $modules = explode('$$', substr($record['modules'], 1, -1)); // substr to remove $ in the begining and the end of the string
            foreach ($modules as $module) {
                $oneModule = explode('|', $module);
                if (isset($modulesNames[$oneModule[0]])) {
                    if (!array_key_exists($modulesNames[$oneModule[0]], $moduleStatsArray)) {
                        $moduleStatsArray[$modulesNames[$oneModule[0]]] = $oneModule[1];
                    } else {
                        $moduleStatsArray[$modulesNames[$oneModule[0]]] = $moduleStatsArray[$modulesNames[$oneModule[0]]] + $oneModule[1];
                    }
                }
            }
        }

        ksort($userModulesArray);

        if ($uid > 0) {
            $userArray = array('nRecords' => $userNRecords,
                'userModulesArray' => $userModulesArray,
            );
        }

        ksort($moduleStatsArray);

        if ($uid > 0) {
            $sv = ModUtil::func('IWmain', 'user', 'genSecurityValue');
            $userName = ModUtil::func('IWmain', 'user', 'getUserInfo', array('info' => 'ncc',
                        'sv' => $sv,
                        'uid' => $uid));
        }

        if ($moduleName != '') {
            $sv = ModUtil::func('IWmain', 'user', 'genSecurityValue');
            $users = ModUtil::func('IWmain', 'user', 'getAllUsersInfo', array('info' => 'ncc',
                        'sv' => $sv,
                        'list' => $usersList,
                    ));
            $users[0] = $this->__('Unregistered');
        }

        return $this->view->assign('users', $users)
                        ->assign('nRecords', $nRecords)
                        ->assign('nusers', $nusers)
                        ->assign('userName', $userName)
                        ->assign('usersIpCounter', $usersIpCounter)
                        ->assign('modulesNames', $modulesNames)
                        ->assign('modulesArray', $modulesArray)
                        ->assign('moduleName', $moduleName)
                        ->assign('uname', $uname)
                        ->assign('fromDate', $fromDate)
                        ->assign('toDate', $toDate)
                        ->assign('userArray', $userArray)
                        ->assign('maxDate', date('Ymd', time()))
                        ->assign('usersForModule', $usersForModule)
                        ->assign('moduleStatsArray', $moduleStatsArray)
                        ->fetch('IWstats_admin_stats.htm');
    }
示例#25
0
public function getMessagesNews($args) {
    $result = array();
    $dateTimeFrom = $args['dateTimeFrom'];
    $dateTimeTo = $args['dateTimeTo'];
    //Checking IWmessages module
    $modinfo = ModUtil::getInfo(ModUtil::getIdFromName('IWmessages'));
    if ($modinfo['state'] != 3) return $result;
    
    if (!is_null($dateTimeFrom)) {
            $sql  = "SELECT iw_msg_id AS msg_id, iw_subject AS subject, UNIX_TIMESTAMP(iw_msg_time) AS msg_time, iw_to_userid AS to_userid, iw_from_userid AS from_userid, iw_read_msg AS read_msg";
            $sql .= " FROM IWmessages";
            $sql .= " WHERE iw_read_msg = 0 AND UNIX_TIMESTAMP(iw_msg_time) >=".$dateTimeFrom." AND UNIX_TIMESTAMP(iw_msg_time) <".$dateTimeTo;
            $query = DBUtil::executeSQL($sql);
            $messages = DBUtil::marshallObjects($query);
            $mes2 = array();
            foreach ($messages as $message) {
                $sv = ModUtil::func('IWmain', 'user', 'genSecurityValue');
                $fromUserInfo = ModUtil::func($this->name, 'user', 'getUserInfo', array('sv' => $sv, 'uid' => $message['from_userid'],'info'=> array('l','n','c1')));
                $message['from_userName'] = ($fromUserInfo['n'] != '') ? $fromUserInfo['n']." ".$fromUserInfo['c1'] : $fromUserInfo['l'];
                $message['msg_time_tx'] = date("d-m-Y / H:i",$message['msg_time']);
                $mes2[$message['to_userid']][] = $message;
            }
            foreach ($mes2 as $key => $me2) {
                $view = Zikula_View::getInstance($this->name, false);  
                $view->assign('messages', $me2);
                $result[$key]['IWmessages'] = $view->fetch('reports/IWmessages_user_report.tpl');
            } 
    }
    
    return $result;
}
示例#26
0
    public function hasbookings($args) {
        $mdid = FormUtil::getPassedValue('mdid', isset($args['mdid']) ? $args['mdid'] : null); //, 'GET');

        if (empty($mdid)) {
            return LogUtil::registerError($this->__('Error! Could not do what you wanted. Please check your input.'));
        }
        // Security check
        if (!SecurityUtil::checkPermission('IWtimeframes::', "::", ACCESS_ADMIN)) {
            return LogUtil::registerError($this->__('Not authorized to manage timeFrames.'), 403);
        }

        $modid = ModUtil::getIdFromName('IWbookings');
        $modinfo = ModUtil::getInfo($modid);

        // chek if IWbookings module is installed -> state 2 or 3
        if ($modinfo['state'] > 1) {
            $pntables = DBUtil::getTables();
            $t1 = $pntables['IWbookings'];
            $t2 = $pntables['IWbookings_spaces'];
            $c1 = $pntables['IWbookings_column'];
            $c2 = $pntables['IWbookings_spaces_column'];

            $sql = "SELECT * "
                    . " FROM $t1 INNER JOIN $t2 ON $t1.$c1[sid] = $t2.$c2[sid] "
                    . " WHERE $t2.$c2[mdid]= " . $mdid;
            //$where = ""
            $result = DBUtil::executeSQL($sql);
            for ($nitems = -1; !$result->EOF; $result->MoveNext()) $nitems ++;             
            return ($nitems);
        } else {
            return false;
        }
    }
示例#27
0
    /**
     * Load a block.
     *
     * @param string $modname Module name.
     * @param string $block   Name of the block.
     *
     * @throws LogicException Uf OO-Block is not a Zikula_Controller_AbstractBlock object.
     * @return bool True on successful load, false otherwise.
     */
    public static function load($modname, $block)
    {
        $sm = ServiceUtil::getManager();
        $modinfo = ModUtil::getInfoFromName($modname);

        $serviceId = strtolower('block.' . $modinfo['name'] . '_' . 'Block_' . $block);
        if ($sm->hasService($serviceId)) {
            return $sm->getService($serviceId);
        }

        if ($modinfo['type'] == ModUtil::TYPE_MODULE) {
            ZLanguage::bindModuleDomain($modinfo['name']);
        }

        $basedir = ($modinfo['type'] == ModUtil::TYPE_SYSTEM) ? 'system' : 'modules';
        $moddir = DataUtil::formatForOS($modinfo['directory']);
        $blockdir = "$basedir/$moddir/lib/$moddir/Block";
        $ooblock = "$blockdir/" . ucwords($block) . '.php';
        ModUtil::load($modname);
        $isOO = ModUtil::isOO($modname);

        if (!$isOO) {
            $blockdirOld = $moddir . '/pnblocks';
            $incfile = DataUtil::formatForOS($block . '.php');

            if (file_exists("$basedir/$blockdirOld/$incfile")) {
                include_once "$basedir/$blockdirOld/$incfile";
            } else {
                return false;
            }
        }

        // get the block info
        if ($isOO) {
            $className = ucwords($modinfo['name']) . '_' . 'Block_' . ucwords($block);
            $r = new ReflectionClass($className);
            $blockInstance = $r->newInstanceArgs(array($sm));
            try {
                if (!$blockInstance instanceof Zikula_Controller_AbstractBlock) {
                    throw new LogicException(sprintf('Block %s must inherit from Zikula_Controller_AbstractBlock', $className));
                }
            } catch (LogicException $e) {
                if (System::isDevelopmentMode()) {
                    throw $e;
                } else {
                    LogUtil::registerError('A fatal error has occured which can be viewed only in development mode.', 500);
                    return false;
                }
            }

            $sm->attachService($serviceId, $blockInstance);
        }

        $result = ($isOO ? $blockInstance : true);

        if ($isOO) {
            $blocks_modules[$block] = call_user_func(array($blockInstance, 'info'));
        } else {
            $infofunc = "{$modname}_{$block}block_info";
            $blocks_modules[$block] = $infofunc();
        }

        // set the module and keys for the new block
        $blocks_modules[$block]['bkey'] = $block;
        $blocks_modules[$block]['module'] = $modname;
        $blocks_modules[$block]['mid'] = ModUtil::getIdFromName($modname);

        // merge the blockinfo in the global list of blocks
        if (!isset($GLOBALS['blocks_modules'])) {
            $GLOBALS['blocks_modules'] = array();
        }
        $GLOBALS['blocks_modules'][$blocks_modules[$block]['mid']][$block] = $blocks_modules[$block];

        // Initialise block if required (new-style)
        if ($isOO) {
            call_user_func(array($blockInstance, 'init'));
        } else {
            $initfunc = "{$modname}_{$block}block_init";
            $initfunc();
        }

        // add stylesheet to the page vars, this makes manual loading obsolete
        PageUtil::addVar('stylesheet', ThemeUtil::getModuleStylesheet($modname));

        return $result;
    }
示例#28
0
 /**
  * Selector for a module's tables or entities.
  *
  * This method is Backward Compatible with all Core versions back to 1.2.x
  * It scans for tables in `tables.php` as well as locating Doctrine 1 tables
  * or Doctrine 2 entities in either the 1.3.0 type directories or 1.4.0++ type
  *
  * @param string  $modname       Module name.
  * @param string  $name          Select field name.
  * @param string  $selectedValue Selected value.
  * @param string  $defaultValue  Value for "default" option.
  * @param string  $defaultText   Text for "default" option.
  * @param boolean $submit        Submit on choose.
  * @param string  $remove        Remove string from table name.
  * @param boolean $disabled      Add Disabled attribute to select.
  * @param integer $nStripChars   Strip the first n characters.
  * @param integer $multipleSize  Size for multiple selects.
  *
  * @return string The rendered output.
  */
 public static function getSelector_ModuleTables($modname, $name, $selectedValue = '', $defaultValue = 0, $defaultText = '', $submit = false, $remove = '', $disabled = false, $nStripChars = 0, $multipleSize = 1)
 {
     if (!$modname) {
         throw new \Exception(__f('Invalid %1$s passed to %2$s.', array('modname', 'HtmlUtil::getSelector_ModuleTables')));
     }
     // old style 'tables.php' modules (Core 1.2.x--)
     $tables = ModUtil::dbInfoLoad($modname, '', true);
     $data = array();
     if (is_array($tables) && $tables) {
         foreach ($tables as $k => $v) {
             if (strpos($k, '_column') === false && strpos($k, '_db_extra_enable') === false && strpos($k, '_primary_key_column') === false) {
                 $checkColumns = $k . '_column';
                 if (!isset($tables[$checkColumns])) {
                     continue;
                 }
             }
             if (strpos($k, '_column') === false && strpos($k, '_db_extra_enable') === false && strpos($k, '_primary_key_column') === false) {
                 if (strpos($k, 'z_') === 0) {
                     $k = substr($k, 4);
                 }
                 if ($remove) {
                     $k2 = str_replace($remove, '', $k);
                 } else {
                     $k2 = $k;
                 }
                 if ($nStripChars) {
                     $k2 = ucfirst(substr($k2, $nStripChars));
                 }
                 // Use $k2 for display also (instead of showing the internal table name)
                 $data[$k2] = $k2;
             }
         }
     }
     if (!empty($data)) {
         return self::getSelector_Generic($name, $data, $selectedValue, $defaultValue, $defaultText, null, null, $submit, $disabled, $multipleSize);
     }
     // Doctrine 1 models (Core 1.3.0 - 1.3.5)
     DoctrineUtil::loadModels($modname);
     $records = Doctrine::getLoadedModels();
     $data = array();
     foreach ($records as $recordClass) {
         // remove records from other modules
         if (substr($recordClass, 0, strlen($modname)) != $modname) {
             continue;
         }
         // get table name of remove table prefix
         $tableNameRaw = Doctrine::getTable($recordClass)->getTableName();
         sscanf($tableNameRaw, Doctrine_Manager::getInstance()->getAttribute(Doctrine::ATTR_TBLNAME_FORMAT), $tableName);
         if ($remove) {
             $tableName = str_replace($remove, '', $tableName);
         }
         if ($nStripChars) {
             $tableName = ucfirst(substr($tableName, $nStripChars));
         }
         $data[$tableName] = $tableName;
     }
     if (!empty($data)) {
         return self::getSelector_Generic($name, $data, $selectedValue, $defaultValue, $defaultText, null, null, $submit, $disabled, $multipleSize);
     }
     // Doctrine 2 entities (Core 1.3.0++)
     // Core-2.0 spec
     $module = ModUtil::getModule($modname);
     if (null !== $module && !class_exists($module->getVersionClass())) {
         // this check just confirming a Core-2.0 spec bundle - remove in 2.0.0
         $capabilities = $module->getMetaData()->getCapabilities();
         if (isset($capabilities['categorizable'])) {
             $data = array();
             foreach ($capabilities['categorizable'] as $fullyQualifiedEntityName) {
                 $nameParts = explode('\\', $fullyQualifiedEntityName);
                 $entityName = array_pop($nameParts);
                 $data[$entityName] = $entityName;
             }
             $selectedValue = count($data) == 1 ? $entityName : $defaultValue;
             return self::getSelector_Generic($name, $data, $selectedValue, $defaultValue, $defaultText, null, null, $submit, $disabled, $multipleSize);
         }
     }
     // (Core-1.3 spec)
     $modinfo = ModUtil::getInfo(ModUtil::getIdFromName($modname));
     $modpath = $modinfo['type'] == ModUtil::TYPE_SYSTEM ? 'system' : 'modules';
     $osdir = DataUtil::formatForOS($modinfo['directory']);
     $entityDirs = array("{$modpath}/{$osdir}/Entity/", "{$modpath}/{$osdir}/lib/{$osdir}/Entity/");
     $entities = array();
     foreach ($entityDirs as $entityDir) {
         if (file_exists($entityDir)) {
             $files = scandir($entityDir);
             foreach ($files as $file) {
                 if ($file != '.' && $file != '..' && substr($file, -4) === '.php') {
                     $entities[] = $file;
                 }
             }
         }
     }
     $data = array();
     foreach ($entities as $entity) {
         $possibleClassNames = array($modname . '_Entity_' . substr($entity, 0, strlen($entity) - 4));
         if ($module) {
             $possibleClassNames[] = $module->getNamespace() . '\\Entity\\' . substr($entity, 0, strlen($entity) - 4);
             // Core 1.4.0++
         }
         foreach ($possibleClassNames as $class) {
             if (class_exists($class)) {
                 $entityName = substr($entity, 0, strlen($entity) - 4);
                 if ($remove) {
                     $entityName = str_replace($remove, '', $entityName);
                 }
                 if ($nStripChars) {
                     $entityName = ucfirst(substr($entityName, $nStripChars));
                 }
                 $data[$entityName] = $entityName;
             }
         }
     }
     return self::getSelector_Generic($name, $data, $selectedValue, $defaultValue, $defaultText, null, null, $submit, $disabled, $multipleSize);
 }
示例#29
0
 /**
  * Load a block.
  *
  * @param string $modname Module name.
  * @param string $block   Name of the block.
  *
  * @throws LogicException Uf OO-Block is not a Zikula_Controller_AbstractBlock object.
  * @return bool           True on successful load, false otherwise.
  */
 public static function load($modname, $block)
 {
     $sm = ServiceUtil::getManager();
     $modinfo = ModUtil::getInfoFromName($modname);
     if ($modinfo['state'] != \ModUtil::STATE_ACTIVE) {
         return false;
     }
     $serviceId = strtolower('block.' . $modinfo['name'] . '_' . 'Block_' . $block);
     if ($sm->has($serviceId)) {
         return $sm->get($serviceId);
     }
     if ($modinfo['type'] == ModUtil::TYPE_MODULE) {
         ZLanguage::bindModuleDomain($modinfo['name']);
     }
     $basedir = $modinfo['type'] == ModUtil::TYPE_SYSTEM ? 'system' : 'modules';
     $moddir = DataUtil::formatForOS($modinfo['directory']);
     $blockdir = "{$basedir}/{$moddir}/lib/{$moddir}/Block";
     $ooblock = "{$blockdir}/" . ucwords($block) . '.php';
     ModUtil::load($modname);
     // get the block info
     $kernel = $sm->get('kernel');
     $module = null;
     try {
         /** @var $module \Zikula\Core\AbstractModule */
         $module = $kernel->getModule($modinfo['name']);
         $className = $module->getNamespace() . '\\Block\\' . ucwords($block);
         $className = preg_match('/.*Block$/', $className) ? $className : $className . 'Block';
     } catch (\InvalidArgumentException $e) {
     }
     if (!isset($className)) {
         $className = ucwords($modinfo['name']) . '\\' . 'Block\\' . ucwords($block);
         $className = preg_match('/.*Block$/', $className) ? $className : $className . 'Block';
         $classNameOld = ucwords($modinfo['name']) . '_' . 'Block_' . ucwords($block);
         $className = class_exists($className) ? $className : $classNameOld;
     }
     $r = new ReflectionClass($className);
     $instanceArgs = array();
     if (is_subclass_of($className, 'Zikula_Controller_AbstractBlock')) {
         $instanceArgs = array($sm, $module);
     } elseif (is_subclass_of($className, 'Zikula\\Core\\Controller\\AbstractBlockController')) {
         $instanceArgs = array($module);
     }
     $blockInstance = $r->newInstanceArgs($instanceArgs);
     if (!$blockInstance instanceof Zikula_Controller_AbstractBlock && !$blockInstance instanceof AbstractBlockController) {
         throw new LogicException(sprintf('Block %s must inherit from Zikula_Controller_AbstractBlock or Zikula\\Core\\Controller\\AbstractBlockController', $className));
     }
     $sm->set($serviceId, $blockInstance);
     if ($blockInstance instanceof \Symfony\Component\DependencyInjection\ContainerAwareInterface) {
         $blockInstance->setContainer($sm);
     }
     $result = $blockInstance;
     $blocks_modules[$block] = call_user_func(array($blockInstance, 'info'));
     // set the module and keys for the new block
     $blocks_modules[$block]['bkey'] = $block;
     $blocks_modules[$block]['module'] = $modname;
     $blocks_modules[$block]['mid'] = ModUtil::getIdFromName($modname);
     // merge the blockinfo in the global list of blocks
     if (!isset($GLOBALS['blocks_modules'])) {
         $GLOBALS['blocks_modules'] = array();
     }
     $GLOBALS['blocks_modules'][$blocks_modules[$block]['mid']][$block] = $blocks_modules[$block];
     // Initialise block if required (new-style)
     call_user_func(array($blockInstance, 'init'));
     // add stylesheet to the page vars, this makes manual loading obsolete
     PageUtil::addVar('stylesheet', ThemeUtil::getModuleStylesheet($modname));
     return $result;
 }
示例#30
0
    /**
     * Utility function to return a list of template sets for
     * displaying the comments input/output
     *
     * @return array array of template set names (directories)
     */
    public function gettemplates()
    {
        if (!SecurityUtil::checkPermission('EZComments::', '::', ACCESS_READ)) {
            return false;
        }

        $modinfo  = ModUtil::getInfo(ModUtil::getIdFromName('EZComments'));
        $osmoddir = DataUtil::formatForOS($modinfo['directory']);
        $ostheme  = DataUtil::formatForOS(UserUtil::getTheme());
        $rootdirs = array("modules/$osmoddir/templates/",
                          "config/templates/$osmoddir/",
                          "themes/$ostheme/templates/$osmoddir/");

        $templates = array();

        // read each directory for template sets
        foreach ($rootdirs as $rootdir) {
            $folders = FileUtil::getFiles($rootdir, false, true, null, 'd');
            foreach ($folders as $folder) {
                if (!in_array($folder, array('plugins'))) {
                    $templates[] = $folder;
                }
            }
        }

        // return a list with no duplicates
        return array_unique($templates);
    }