/** * Change the category a module belongs to by ajax. * * @return AjaxUtil::output Output to the calling ajax request is returned. * response is a string moduleid on sucess. */ public function changeModuleCategory() { $this->checkAjaxToken(); $this->throwForbiddenUnless(SecurityUtil::checkPermission('Admin::', '::', ACCESS_ADMIN)); $moduleID = $this->request->getPost()->get('modid'); $newParentCat = $this->request->getPost()->get('cat'); //get info on the module $module = ModUtil::getInfo($moduleID); if (!$module) { //deal with couldnt get module info throw new Zikula_Exception_Fatal($this->__('Error! Could not get module name for id %s.')); } //get the module name $displayname = DataUtil::formatForDisplay($module['displayname']); $module = $module['name']; $oldcid = ModUtil::apiFunc('Admin', 'admin', 'getmodcategory', array('mid' => $moduleID)); //move the module $result = ModUtil::apiFunc('Admin', 'admin', 'addmodtocategory', array('category' => $newParentCat, 'module' => $module)); if (!$result) { throw new Zikula_Exception_Fatal($this->__('Error! Could not add module to module category.')); } $output = array(); $output['response'] = $moduleID; $output['newParentCat'] = $newParentCat; $output['oldcid'] = $oldcid; $output['modulename'] = $displayname; $output['url'] = ModUtil::url($module, 'admin', 'main'); return new Zikula_Response_Ajax($output); }
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; }
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'); }
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; }
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); } }
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'); }
function display() { $id = $this->blockid; $blockinfo = BlockUtil::getBlockInfo($id); $modinfo = ModUtil::getInfo($blockinfo['mid']); $text = BlockUtil::show($modinfo['name'], $blockinfo['bkey'], $blockinfo); $this->view->assign('content', $text); return $this->view->fetch($this->getTemplate()); }
/** * 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; }
/** * 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; }
/** * 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; }
/** * 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; }
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; }
/** * 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; }
/** * 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; }
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; }
/** * 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]); } } }
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; }
/** * Display all blocks in a block position. * * @param string $side Block position to render. * @param boolean $echo Whether or not to echo output directly. * @param boolean $implode Whether or not to implode lines by \n. * * @return void|string The rendered output. */ public static function displayPosition($side, $echo = true, $implode = true) { static $blockplacements = array(); static $positions = array(); static $modname; static $currentlang; static $func; static $type; static $customargs; if (!isset($side)) { return null; } // get the block position if (empty($positions)) { $positions = ModUtil::apiFunc('ZikulaBlocksModule', 'user', 'getallpositions'); } if (!isset($positions[$side])) { return; } if (!isset($modname)) { if (PageUtil::isHomepage()) { $modname = '_homepage_'; } else { $modname = ModUtil::getName(); } } // get all block placements if (empty($blockplacements)) { $blockplacements = ModUtil::apiFunc('ZikulaBlocksModule', 'user', 'getallplacements'); } // get variables from input if (!isset($func)) { $func = FormUtil::getPassedValue('func', 'main', 'GETPOST'); } if (!isset($type)) { $type = FormUtil::getPassedValue('type', 'user', 'GETPOST'); } if (!isset($customargs)) { $customargs = array(); $filtervars = array('module', 'name', 'type', 'func', 'theme', 'csrftoken'); foreach ($_GET as $var => $value) { if (is_array($value)) { $arguments = explode('&', urldecode(http_build_query(array($var => $value)))); foreach ($arguments as $argument) { $args = explode('=', $argument); if (!in_array($args[0], $filtervars)) { $customargs[] = DataUtil::formatForOS(strip_tags($args[0])) . '=' . DataUtil::formatForOS(strip_tags($args[1])); } } } else { if (!in_array($var, $filtervars)) { $customargs[] = DataUtil::formatForOS(strip_tags($var)) . '=' . DataUtil::formatForOS(strip_tags($value)); } } } } // current language if (!isset($currentlang)) { $currentlang = ZLanguage::getLanguageCode(); } // loop around the blocks and display only the ones we need $blockoutput = array(); foreach ($blockplacements as $blockplacement) { // don't display a block if it's not in this block position if ($blockplacement['pid'] != $positions[$side]['pid']) { continue; } // get the full block info $blockinfo = self::getBlockInfo($blockplacement['bid']); // dont display the block if it's not active or not in matching langauge if (!$blockinfo['active'] || !empty($blockinfo['language']) && $blockinfo['language'] != $currentlang) { continue; } // block filtering if (!empty($blockinfo['filter']) && is_array($blockinfo['filter']) && count($blockinfo['filter'])) { $showblock = false; // loop for each filter foreach ($blockinfo['filter'] as $filter) { // filter must be an array of values if (!is_array($filter)) { continue; } $rule1 = $filter['module'] == $modname; $rule2 = empty($filter['ftype']) ? true : $filter['ftype'] == $type; $rule3 = empty($filter['fname']) ? true : $filter['fname'] == $func; if (empty($filter['fargs'])) { $rule4 = true; } else { $testargs = explode('&', $filter['fargs']); foreach ($testargs as $test) { $key = array_search($test, $customargs); if ($key === false) { $rule4 = false; break; } else { $rule4 = true; } } } if ($rule1 == true && $rule2 == true && $rule3 == true && $rule4 !== false) { $showblock = true; break; } } if (!$showblock) { continue; } } $blockinfo['position'] = $positions[$side]['name']; // get the module info and display the block $modinfo = ModUtil::getInfo($blockinfo['mid']); if ($echo) { echo self::show($modinfo['name'], $blockinfo['bkey'], $blockinfo); } else { $blockoutput[$blockinfo['bid']] = self::show($modinfo['name'], $blockinfo['bkey'], $blockinfo); } } if ($echo) { return; } else { if ($implode) { return implode("\n", $blockoutput); } else { return $blockoutput; } } }
public function setForum($args){ if (!SecurityUtil::checkPermission('IWforums::', '::', ACCESS_READ)) { throw new Zikula_Exception_Fatal($this->__('Sorry! No authorization to access this module.')); } $item = array(); $item['fid'] = $this->request->getPost()->get('fid', ''); if (!$item['fid']) { throw new Zikula_Exception_Fatal($this->__('No forum id')); } $item['nom_forum'] = $this->request->getPost()->get('nom_forum', ''); $item['longDescriu'] = $this->request->getPost()->get('longDescriu', ''); $item['descriu'] = $this->request->getPost()->get('descriu', ''); $item['observacions'] = $this->request->getPost()->get('observacions', ''); $access = ModUtil::func('IWforums', 'user', 'access', array('fid' => $item['fid'])); $moderator = ($access == 4) ? true : false; // Set topic changes $result = ModUtil::apiFunc($this->name, 'user', 'setForum', $item); $forum = ModUtil::apiFunc($this->name, 'user', 'get', array('fid' => $item['fid'])); $view = Zikula_View::getInstance($this->name, false); $view->assign('name', $forum['nom_forum']) ->assign('descriu', $forum['descriu']) ->assign('observacions', $forum['observacions']) ->assign('lDesc', $forum['longDescriu']) ->assign('moderator', $moderator) ->assign('topicsPage', $this->request->getPost()->get('topicsPage', 0)) ->assign('fid', $forum['fid']); $content = $view->fetch('user/IWforums_user_forumDesc.tpl'); if(ModUtil::available('Scribite')) { $modScId = ModUtil::getIdFromName('Scribite'); $modScInfo = ModUtil::getInfo($modScId); if ($modScInfo['version'] < '5.0.0') { $moduleSc = 'old'; }else{ $moduleSc = 'new'; } }else{ $moduleSc = false; } return new Zikula_Response_Ajax(array('content' => $content, 'moduleSc' => $moduleSc)); }
/** * 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; }
/** * Display hook for view. * * Subject is the object being viewed that we're attaching to. * args[id] Is the id of the object. * args[caller] the module who notified of this event. * * @param Zikula_Hook $hook The hook. * * @return void */ public function uiView(Zikula_DisplayHook $hook) { // work out the input from the hook $mod = $hook->getCaller(); $areaId = $hook->getAreaId(); $objectid = $hook->getId(); // first check if the user is allowed to do any comments for this module/objectid if (!SecurityUtil::checkPermission('EZComments::', "{$mod}:{$objectid}:", ACCESS_OVERVIEW)) { return; } $subject = array(); //$hook->getSubject(); $owneruid = isset($subject['cr_uid']) ? (int) $subject['cr_uid'] : 0; $useurl = isset($subject['useurl']) ? $subject['useurl'] : null; $ownerUidSession = SessionUtil::delVar('commentOwner', 0); if ($ownerUidSession > 0) { $owneruid = $ownerUidSession; } // we may have a comment incoming $ezcomment = unserialize(SessionUtil::getVar('ezcomment', 'a:0:{}')); $ezcomment = isset($ezcomment[$mod][$objectid]) ? $ezcomment[$mod][$objectid] : null; // we may get some input in from the navigation bar $order = FormUtil::getPassedValue('order'); $sortorder = $order == 1 ? 'DESC' : 'ASC'; $status = 0; // check if we're using the pager $enablepager = ModUtil::getVar('EZComments', 'enablepager'); if ($enablepager) { $numitems = ModUtil::getVar('EZComments', 'commentsperpage'); $startnum = FormUtil::getPassedValue('comments_startnum'); if (!isset($startnum) && !is_numeric($startnum)) { $startnum = -1; } } else { $startnum = -1; $numitems = -1; } $params = compact('mod', 'areaId', 'objectid', 'sortorder', 'status', 'numitems', 'startnum'); $items = ModUtil::apiFunc('EZComments', 'user', 'getall', $params); if ($items === false) { return LogUtil::registerError($this->__('Internal Error.'), null, 'index.php'); } $items = ModUtil::apiFunc('EZComments', 'user', 'prepareCommentsForDisplay', $items); if ($enablepager) { $commentcount = ModUtil::apiFunc('EZComments', 'user', 'countitems', compact('mod', 'objectid', 'status')); } else { $commentcount = count($items); } // create the output object $view = Zikula_View::getInstance('EZComments', false, null, true); $view->assign('areaid', $areaId)->assign('comments', $items)->assign('commentcount', $commentcount)->assign('ezcomment', $ezcomment)->assign('ezc_info', compact('mod', 'objectid', 'sortorder', 'status'))->assign('modinfo', ModUtil::getInfo(ModUtil::getIdFromName($mod)))->assign('msgmodule', System::getVar('messagemodule', ''))->assign('prfmodule', System::getVar('profilemodule', ''))->assign('allowadd', SecurityUtil::checkPermission('EZComments::', "{$mod}:{$objectid}:", ACCESS_COMMENT))->assign('loggedin', UserUtil::isLoggedIn()); $modUrl = $hook->getUrl(); $redirect = !is_null($modUrl) ? $modUrl->getUrl() : ''; $view->assign('returnurl', $redirect); // encode the url - otherwise we can get some problems out there.... $redirect = base64_encode($redirect); $view->assign('redirect', $redirect); $view->assign('objectid', $objectid); // assign the user is of the content owner $view->assign('owneruid', $owneruid); // assign url that should be stored in db and sent in email if it // differs from the redirect url $view->assign('useurl', $useurl); // flag to recognize the main call static $mainScreen = true; $view->assign('mainscreen', $mainScreen); $mainScreen = false; // assign the values for the pager $view->assign('ezc_pager', array('numitems' => $commentcount, 'itemsperpage' => $numitems)); // find out which template and stylesheet to use $templateset = isset($args['template']) ? $args['template'] : FormUtil::getPassedValue('eztpl'); $css = isset($args['ezccss']) ? $args['ezccss'] : FormUtil::getPassedValue('ezccss'); $defaultcss = ModUtil::getVar('EZComments', 'css', 'style.css'); if (!$view->template_exists(DataUtil::formatForOS($templateset) . '/ezcomments_user_view.tpl')) { $templateset = ModUtil::getVar('EZComments', 'template', 'Standard'); } $view->assign('template', $templateset); // include stylesheet if there is a style sheet $css = $css ? "{$css}.css" : $defaultcss; if ($css = ModUtil::apiFunc('EZComments', 'user', 'getStylesheet', array('path' => "{$templateset}/{$css}"))) { PageUtil::addVar('stylesheet', $css); } $template = DataUtil::formatForOS($templateset) . '/ezcomments_user_view.tpl'; $response = new Zikula_Response_DisplayHook('provider_area.ui_hooks.ezcomments.comments', $view, $template); $hook->setResponse($response); }
/** * 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); }
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; }
public function check_module($module_name){ $result = false; // Checks if module $module_name is installed. $modid = ModUtil::getIdFromName($module_name); $modinfo = ModUtil::getInfo($modid); if ($modinfo['state'] == 3) { $result = true; } return $result; }
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; } }
/** * Display all blocks in a block position. * * @param string $side Block position to render. * @param boolean $echo Whether or not to echo output directly. * @param boolean $implode Whether or not to implode lines by \n. * * @return void|string The rendered output. */ public static function displayPosition($side, $echo = true, $implode = true) { static $blockplacements = array(); static $positions = array(); static $modname; static $currentlang; static $func; static $type; static $customargs; if (!isset($side)) { return null; } ModUtil::dbInfoLoad('Blocks', 'Blocks'); // get the block position if (empty($positions)) { $positions = DBUtil::selectObjectArray('block_positions', null, null, -1, -1, 'name'); } if (!isset($positions[$side])) { return; } if (!isset($modname)) { $modname = FormUtil::getPassedValue('module', '_homepage_', 'GETPOST', FILTER_SANITIZE_STRING); } // get the blocks in this block position if (empty($blockplacements)) { $blockplacements = DBUtil::selectObjectArray('block_placements', null, 'sortorder'); } // get variables from input if (!isset($func)) { $func = FormUtil::getPassedValue('func', 'main', 'GETPOST'); } if (!isset($type)) { $type = FormUtil::getPassedValue('type', 'user', 'GETPOST'); } if (!isset($customargs)) { $customargs = array(); $filtervars = array('module', 'name', 'type', 'func', 'theme', 'authid', 'csrftoken'); foreach ($_GET as $var => $value) { if (!in_array($var, $filtervars)) { $customargs[] = DataUtil::formatForOS(strip_tags($var)) . '=' . DataUtil::formatForOS(strip_tags($value)); } } } // current language if (!isset($currentlang)) { $currentlang = ZLanguage::getLanguageCode(); } // loop around the blocks and display only the ones we need $blockoutput = array(); foreach ($blockplacements as $blockplacement) { // don't display a block if it's not in this block position if ($blockplacement['pid'] != $positions[$side]['pid']) { continue; } // get the full block info $blockinfo = self::getBlockInfo($blockplacement['bid']); // dont display the block if it's not active or not in matching langauge if (!$blockinfo['active'] || (!empty($blockinfo['language']) && $blockinfo['language'] != $currentlang)) { continue; } // block filtering if (!empty($blockinfo['filter'])) { $showblock = false; // loop for each filter foreach ($blockinfo['filter'] as $filter) { // filter must be an array of values if (!is_array($filter)) { continue; } $rule1 = $filter['module'] == $modname; $rule2 = empty($filter['ftype']) ? true : ($filter['ftype'] == $type); $rule3 = empty($filter['fname']) ? true : ($filter['fname'] == $func); $rule4 = empty($filter['fargs']) ? true : array_search($filter['fargs'], $customargs); if ($rule1 == true && $rule2 == true && $rule3 == true && $rule4 !== false) { $showblock = true; break; } } if (!$showblock) { continue; } } $blockinfo['position'] = $positions[$side]['name']; // get the module info and display the block $modinfo = ModUtil::getInfo($blockinfo['mid']); if ($echo) { echo self::show($modinfo['name'], $blockinfo['bkey'], $blockinfo); } else { $blockoutput[] = self::show($modinfo['name'], $blockinfo['bkey'], $blockinfo); } } if ($echo) { return; } else { if ($implode) { return implode("\n", $blockoutput); } else { return $blockoutput; } } }
/** * 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); }
/** * Display an existing Zikula block. * * The block is choosen by its id. * The block state is ignored, so even deactivated blocks can be shown. * The parameters specific to the block can be overridden. * * Available parameters: * - id (numeric) ID of the block to be displayed * - name (string) Name of the block to be displayed (not used) * - title (string) Overrides the block title * - position (string) Overrides the block position * - assign (string) The name of a template variable to which the output * of the block is assigned, instead of sending the * output to the template (optional) * - Any additional parameters are passed to the block as block variables, * overriding any existing values. * * Examples: * * Insert the block with block ID (bid) 4 at the current position in the template * * <samp>{block id=4}</samp> * * Insert the block with block ID (bid) 5 at the current position in the * template, overriding the block's title. * * <samp>{block id=5 title='My Block 5'}</samp> * * Store the output generated by retrieving the block with ID 6 in the template * variable $myBlockContents. * * <samp>{block id=6 assign='myBlockContents'}</samp> * * @param array $params All attributes passed to this function from the template. * @param Zikula_View $view Reference to the {@link Zikula_View} object. * * @return string The block. * * @todo the attribute 'name' is not used. * */ function smarty_function_block($params, Zikula_View $view) { $bid = isset($params['bid']) ? (int) $params['bid'] : 0; $name = isset($params['name']) ? $params['name'] : null; $title = isset($params['title']) ? $params['title'] : null; $position = isset($params['position']) ? $params['position'] : null; $assign = isset($params['assign']) ? $params['assign'] : null; // unset the variables for the function, leaving the ones for the block unset($params['bid']); unset($params['name']); unset($params['title']); unset($params['position']); unset($params['assign']); if (!$bid) { $view->trigger_error(__f('Error! in %1$s: the %2$s parameter must be specified.', array('pnblock', 'bid'))); return false; } // render the block $blockinfo = BlockUtil::getBlockInfo($bid); // overwrite block title if ($title) { $blockinfo['title'] = $title; } if ($position) { $blockinfo['position'] = $position; } $blockinfo['bid'] = $bid; // bid is not return by BlockGetInfo. // Overwrite block specific config vars. // Only the new style is supported. if (count($params) > 0) { $_vars = BlockUtil::varsFromContent($blockinfo['content']); $_vars = array_merge($_vars, $params); $blockinfo['content'] = BlockUtil::varsToContent($_vars); } // We need the module name. $modinfo = ModUtil::getInfo($blockinfo['mid']); if (!is_array($modinfo) || !isset($modinfo['name'])) { $modinfo = array('name' => 'core'); } // show the block and capture its contents $content = BlockUtil::show($modinfo['name'], $blockinfo['bkey'], $blockinfo); if ($assign) { $view->assign($assign, $content); } else { return $content; } }
/** * 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); }
/** * Display a form to create a new block position. * * @return string HTML output string. */ public function modifyposition() { // get our input $pid = FormUtil::getPassedValue('pid'); // get the block position $position = ModUtil::apiFunc('Blocks', 'user', 'getposition', array('pid' => $pid)); // Security check if (!SecurityUtil::checkPermission("Blocks::{$position['name']}", '::', ACCESS_ADMIN)) { return LogUtil::registerPermissionError(); } // assign the item $this->view->assign($position); // get all blocks in the position $block_placements = ModUtil::apiFunc('blocks', 'user', 'getblocksinposition', array('pid' => $pid)); // get all defined blocks $allblocks = ModUtil::apiFunc('Blocks', 'user', 'getall', array('active_status' => 0)); foreach ($allblocks as $key => $allblock) { // set the module that holds the block $modinfo = ModUtil::getInfo($allblock['mid']); $allblocks[$key]['modname'] = $modinfo['name']; } // loop over arrays forming a list of blocks not in the block positon and obtaining // full details on those that are $blocks = array(); foreach ($block_placements as $blockplacement) { $block = BlockUtil::getBlockInfo($blockplacement['bid']); $block['order'] = $blockplacement['order']; foreach ($allblocks as $key => $allblock) { if ($allblock['bid'] == $blockplacement['bid']) { unset($allblocks[$key]); $block['modname'] = $allblock['modname']; } } $blocks[] = $block; } $this->view->assign('assignedblocks', $blocks)->assign('unassignedblocks', $allblocks); // Return the output that has been generated by this function return $this->view->fetch('blocks_admin_modifyposition.tpl'); }