/** * @Route("/settings", options={"expose" = true}) * @Template() * @Theme("admin") * * @param Request $request * * @return array|RedirectResponse */ public function settingsAction(Request $request) { if (!$this->get('cmfcmf_media_module.security_manager')->hasPermission('settings', 'admin')) { throw new AccessDeniedException(); } if ($request->query->get('update', false)) { $this->get('zikula.doctrine.schema_tool')->update(MediaModuleInstaller::getEntities()); } $collectionTemplateCollection = $this->get('cmfcmf_media_module.collection_template_collection'); $form = $this->createForm(new SettingsType($collectionTemplateCollection->getCollectionTemplateTitles())); $form->handleRequest($request); if ($form->isValid()) { $data = $form->getData(); foreach ($data as $name => $value) { \ModUtil::setVar('CmfcmfMediaModule', $name, $value); } $this->addFlash('status', $this->__('Settings saved!')); } $scribiteInstalled = \ModUtil::available('Scribite'); $descriptionEscapingStrategyForCollectionOk = true; $descriptionEscapingStrategyForMediaOk = true; if ($scribiteInstalled) { $mediaBinding = $this->get('hook_dispatcher')->getBindingBetweenAreas("subscriber.cmfcmfmediamodule.ui_hooks.media", "provider.scribite.ui_hooks.editor"); $collectionBinding = $this->get('hook_dispatcher')->getBindingBetweenAreas("subscriber.cmfcmfmediamodule.ui_hooks.collection", "provider.scribite.ui_hooks.editor"); $descriptionEscapingStrategyForCollectionOk = !is_object($collectionBinding) || \ModUtil::getVar('CmfcmfMediaModule', 'descriptionEscapingStrategyForCollection') == 'raw'; $descriptionEscapingStrategyForMediaOk = !is_object($mediaBinding) || \ModUtil::getVar('CmfcmfMediaModule', 'descriptionEscapingStrategyForMedia') == 'raw'; } return ['form' => $form->createView(), 'scribiteInstalled' => $scribiteInstalled, 'descriptionEscapingStrategyForCollectionOk' => $descriptionEscapingStrategyForCollectionOk, 'descriptionEscapingStrategyForMediaOk' => $descriptionEscapingStrategyForMediaOk]; }
public function install() { if (!SecurityUtil::checkPermission('Files::', '::', ACCESS_ADMIN)) { return LogUtil::registerPermissionError(); } // set content of the files .htaccess and .locked $htaccessContent = "# Avoid direct web access to folder files\r\nOrder deny,allow\r\nDeny from all\r\n"; $lockedContent = "# Avoid direct web access with the file file.php\r\n"; // Create module table if (!DBUtil::createTable('Files')) { return false; } //Create indexes $pntable = DBUtil::getTables(); $c = $pntable['Files_column']; DBUtil::createIndex($c['userId'], 'Files', 'userId'); // create security files FileUtil::writeFile(ModUtil::getVar('Files', 'folderPath') . '/.htaccess', $htaccessContent, true); FileUtil::writeFile(ModUtil::getVar('Files', 'folderPath') . '/.locked', $lockedContent, true); FileUtil::writeFile(ModUtil::getVar('Files', 'folderPath') . '/' . ModUtil::getVar('Files', 'usersFolder') . '/.htaccess', $htaccessContent, true); FileUtil::writeFile(ModUtil::getVar('Files', 'folderPath') . '/' . ModUtil::getVar('Files', 'usersFolder') . '/.locked', $lockedContent, true); //Create module vars ModUtil::setVar('Files', 'showHideFiles', '0'); ModUtil::setVar('Files', 'allowedExtensions', 'gif,png,jpg,odt,doc,pdf,zip'); ModUtil::setVar('Files', 'defaultQuota', 1); ModUtil::setVar('Files', 'groupsQuota', 's:0:"";'); ModUtil::setVar('Files', 'filesMaxSize', '1000000'); ModUtil::setVar('Files', 'maxWidth', '250'); ModUtil::setVar('Files', 'maxHeight', '250'); ModUtil::setVar('Files', 'editableExtensions', 'php,htm,html,htaccess,css,js,tpl'); // Set up module hook ModUtil::registerHook('item', 'display', 'GUI', 'Files', 'user', 'Files'); return true; }
/** * This function is called internally by the core whenever the module is * loaded. It adds in the information */ function Feeds_tables() { // Initialise table array $dbtable = array(); // Full table definition $dbtable['feeds'] = 'feeds'; $dbtable['feeds_column'] = array('fid' => 'fid', 'name' => 'name', 'urltitle' => 'urltitle', 'url' => 'url'); $dbtable['feeds_column_def'] = array('fid' => 'I(10) NOTNULL AUTOINCREMENT PRIMARY', 'name' => "C(255) NOTNULL DEFAULT ''", 'urltitle' => "C(255) NOTNULL DEFAULT ''", 'url' => "C(255) NOTNULL DEFAULT ''"); // Enable categorization services $dbtable['feeds_db_extra_enable_categorization'] = ModUtil::getVar('Feeds', 'enablecategorization'); $dbtable['feeds_primary_key_column'] = 'fid'; // add standard data fields ObjectUtil::addStandardFieldsToTableDefinition($dbtable['feeds_column']); ObjectUtil::addStandardFieldsToTableDataDefinition($dbtable['feeds_column_def']); // Return the table information return $dbtable; }
function initialize(Zikula_Form_View $view) { $this->id = (int) FormUtil::getPassedValue('id', -1, 'GETPOST'); $objectid = FormUtil::getPassedValue('objectid', '', 'GETPOST'); $redirect = base64_decode(FormUtil::getPassedValue('redirect', '', 'GETPOST')); $view->caching = false; $comment = ModUtil::apiFunc('EZComments', 'user', 'get', array('id' => $this->id)); if ($comment == false || !is_array($comment)) { return LogUtil::registerError($this->__('No such comment found.'), ModUtil::url('EZComments', 'user', 'main')); } // check if user is allowed to modify this content $modifyowntime = (int) ModUtil::getVar('EZComments', 'modifyowntime'); $ts = strtotime($comment['date']); if (!SecurityUtil::checkPermission('EZComments::', '::', ACCESS_ADMIN)) { // user has no admin permissions. Only commenting user should be able to modify if ($comment['uid'] != UserUtil::getVar('uid')) { // foreign content and no admin permissions $view->assign('nomodify', 1); $this->nomodify = 1; } else { if ($modifyowntime > 0 && $ts + $modifyowntime * 60 * 60 < time()) { $view->assign('nomodify', 1); $this->nomodify = 1; } } } else { $view->assign('nomodify', 0); $this->nomodify = 0; } $view->assign('redirect', isset($redirect) && !empty($redirect) ? true : false); // finally asign the comment information $view->assign($comment); return true; }
/** * Avatar_upgrade() * * Upgrade the Module * * @param integer $oldversion old version of the module * @return boolean success or not **/ public function upgrade($oldversion) { // Upgrade dependent on old version number switch ($oldversion) { case '1.1': $this->delVar('prefix_group_1'); $this->delVar('prefix_group_2'); $this->delVar('prefix_group_3'); $this->delVar('prefix_prefix_1'); $this->delVar('prefix_prefix_2'); $this->delVar('prefix_prefix_3'); $this->setVar('allow_multiple', true); // for PHP5: if jpg is allowed, also allow jpeg if needed // this is needed because image_type_to_extension() always returns 'jpeg' in case // of jpg images in PHP5 $exts = explode(';', $this->getVar('allowed_extensions')); if (is_array($exts) && in_array('jpg', $exts) && !in_array('jpeg', $exts)) { $exts[] = 'jpeg'; $this->setVar('allowed_extensions', implode(';', $exts)); } case '2.0': case '2.1': ModUtil::setVar('Users', 'avatarpath', ModUtil::getVar('Avatar', 'avatardir')); $this->delVar('avatardir'); case '2.2': } return true; }
public function initialize(Zikula_Form_View $view) { if (!SecurityUtil::checkPermission('Content::', '::', ACCESS_ADMIN)) { throw new Zikula_Exception_Forbidden(LogUtil::getErrorMsgPermission()); } $catoptions = array( array('text' => $this->__('Use 2 category levels (1st level single, 2nd level multi selection)'), 'value' => '1'), array('text' => $this->__('Use 2 category levels (both single selection)'), 'value' => '2'), array('text' => $this->__('Use 1 category level'), 'value' => '3'), array('text' => $this->__("Don't use Categories at all"), 'value' => '4') ); $this->view->assign('catoptions', $catoptions); $this->view->assign('categoryusage', 1); $activeoptions = array( array('text' => $this->__('New pages will be active and available in the menu'), 'value' => '1'), array('text' => $this->__('New pages will be inactive and available in the menu'), 'value' => '2'), array('text' => $this->__('New pages will be active and not available in the menu'), 'value' => '3'), array('text' => $this->__('New pages will be inactive and not available in the menu'), 'value' => '4') ); $this->view->assign('activeoptions', $activeoptions); $pageinfolocationoptions = array( array('text' => $this->__('Top of the page, left of the page title'), 'value' => 'top'), array('text' => $this->__('Bottom of the page'), 'value' => 'bottom') ); $this->view->assign('pageinfolocationoptions', $pageinfolocationoptions); // Assign all module vars $this->view->assign('config', ModUtil::getVar('Content')); return true; }
/** * Sets the value of the Registry Relation. * * @param Doctrine_Event $event Event. * * @return void */ public function preSave($event) { $subclasses = ModUtil::getVar('Categories', 'EntityCategorySubclasses', array()); // get the registry object $registry = Doctrine::getTable('Zikula_Doctrine_Model_Registry')->findOneByModuleAndTableAndProperty($subclasses[get_class($this)]['module'], $subclasses[get_class($this)]['table'], $this->reg_property); $this['Registry'] = $registry; }
/** * Initialize form handler. * * This method takes care of all necessary initialisation of our data and form states. * * @return boolean False in case of initialization errors, otherwise true. */ public function initialize(Zikula_Form_View $view) { // permission check if (!SecurityUtil::checkPermission('MUBoard::', '::', ACCESS_ADMIN)) { return $view->registerError(LogUtil::registerPermissionError()); } // retrieve module vars $modVars = ModUtil::getVar('MUBoard'); // initialise list entries for the 'number images' setting $modVars['numberImagesItems'] = array(array('value' => '1', 'text' => '1'), array('value' => '2', 'text' => '2'), array('value' => '3', 'text' => '3')); // initialise list entries for the 'number files' setting $modVars['numberFilesItems'] = array(array('value' => '1', 'text' => '1'), array('value' => '2', 'text' => '2'), array('value' => '3', 'text' => '3')); // initialise list entries for the 'sorting postings' setting $modVars['sortingPostingsItems'] = array(array('value' => 'descending', 'text' => 'Descending'), array('value' => 'ascending', 'text' => 'Ascending')); // initialise list entries for the 'icon set' setting $modVars['iconSetItems'] = array(array('value' => '1', 'text' => '1'), array('value' => '2', 'text' => '2'), array('value' => '3', 'text' => '3')); // initialise list entries for the 'template' setting $modVars['templateItems'] = array(array('value' => 'normal', 'text' => 'Normal'), array('value' => 'jquery', 'text' => 'JQuery')); // assign all module vars $this->view->assign('config', $modVars); // custom initialisation aspects $this->initializeAdditions(); // everything okay, no initialization errors occured return true; }
/** * AddressBook * * @copyright (c) AddressBook Development Team * @license GNU/GPL - http://www.gnu.org/copyleft/gpl.html * @package AddressBook */ function AddressBook_tables() { // Initialise table array $tables = array(); $tables['addressbook_address'] = 'addressbook_address'; $tables['addressbook_address_column'] = array('id' => 'adr_id', 'cat_id' => 'adr_catid', 'prefix' => 'adr_prefix', 'lname' => 'adr_name', 'fname' => 'adr_fname', 'sortname' => 'adr_sortname', 'title' => 'adr_title', 'company' => 'adr_company', 'sortcompany' => 'adr_sortcompany', 'img' => 'adr_img', 'zip' => 'adr_zip', 'city' => 'adr_city', 'address1' => 'adr_address1', 'address2' => 'adr_address2', 'state' => 'adr_state', 'country' => 'adr_country', 'geodata' => 'adr_geodata', 'contact_1' => 'adr_contact_1', 'contact_2' => 'adr_contact_2', 'contact_3' => 'adr_contact_3', 'contact_4' => 'adr_contact_4', 'contact_5' => 'adr_contact_5', 'c_label_1' => 'adr_c_label_1', 'c_label_2' => 'adr_c_label_2', 'c_label_3' => 'adr_c_label_3', 'c_label_4' => 'adr_c_label_4', 'c_label_5' => 'adr_c_label_5', 'c_main' => 'adr_c_main', 'custom_1' => 'adr_custom_1', 'custom_2' => 'adr_custom_2', 'custom_3' => 'adr_custom_3', 'custom_4' => 'adr_custom_4', 'note' => 'adr_note', 'user_id' => 'adr_user', 'private' => 'adr_private', 'date' => 'adr_date', 'counter' => 'adr_counter', 'language' => 'adr_language', 'status' => 'adr_status'); // Enable categorization services $tables['addressbook_address_db_extra_enable_categorization'] = ModUtil::getVar('AddressBook', 'enablecategorization'); $tables['addressbook_address_primary_key_column'] = 'id'; ObjectUtil::addStandardFieldsToTableDefinition($tables['addressbook_address_column'], 'adr_'); // add potential custom_fields addCustomFieldsToTableDefinition($tables['addressbook_address_column']); $tables['addressbook_address_column_def'] = array('id' => "I AUTO PRIMARY", 'cat_id' => "I NOTNULL DEFAULT 0", 'prefix' => "I NOTNULL DEFAULT 0", 'lname' => "C(100) DEFAULT NULL", 'fname' => "C(60) DEFAULT NULL", 'sortname' => "C(180) DEFAULT NULL", 'title' => "C(100) DEFAULT NULL", 'company' => "C(100) DEFAULT NULL", 'sortcompany' => "C(100) DEFAULT NULL", 'img' => "C(100) DEFAULT NULL", 'zip' => "C(30) DEFAULT NULL", 'city' => "C(100) DEFAULT NULL", 'address1' => "C(100) DEFAULT NULL", 'address2' => "C(100) DEFAULT NULL", 'state' => "C(60) DEFAULT NULL", 'country' => "C(60) DEFAULT NULL", 'geodata' => "C(180) DEFAULT NULL", 'contact_1' => "C(100) DEFAULT NULL", 'contact_2' => "C(100) DEFAULT NULL", 'contact_3' => "C(100) DEFAULT NULL", 'contact_4' => "C(100) DEFAULT NULL", 'contact_5' => "C(100) DEFAULT NULL", 'c_label_1' => "I2 DEFAULT NULL", 'c_label_2' => "I2 DEFAULT NULL", 'c_label_3' => "I2 DEFAULT NULL", 'c_label_4' => "I2 DEFAULT NULL", 'c_label_5' => "I2 DEFAULT NULL", 'c_main' => "I2 DEFAULT NULL", 'custom_1' => "X DEFAULT NULL", 'custom_2' => "X DEFAULT NULL", 'custom_3' => "X DEFAULT NULL", 'custom_4' => "X DEFAULT NULL", 'note' => "X DEFAULT NULL", 'user_id' => "I DEFAULT NULL", 'private' => "I2 DEFAULT NULL", 'date' => "I NOTNULL DEFAULT 0", 'counter' => "I NOTNULL DEFAULT 0", 'language' => "C(30) NOTNULL DEFAULT ''", 'status' => "I1 DEFAULT '1'"); ObjectUtil::addStandardFieldsToTableDataDefinition($tables['addressbook_address_column_def'], 'adr_'); $tables['addressbook_labels'] = 'addressbook_labels'; $tables['addressbook_labels_column'] = array('id' => 'lab_id', 'name' => 'lab_name', 'name1' => 'lab_name1'); $tables['addressbook_labels_primary_key_column'] = 'id'; ObjectUtil::addStandardFieldsToTableDefinition($tables['addressbook_labels_column'], 'lab_'); $tables['addressbook_labels_column_def'] = array('id' => "I AUTO PRIMARY", 'name' => "C(30) DEFAULT NULL", 'name1' => "C(30) DEFAULT NULL"); ObjectUtil::addStandardFieldsToTableDataDefinition($tables['addressbook_labels_column_def'], 'lab_'); $tables['addressbook_customfields'] = 'addressbook_customfields'; $tables['addressbook_customfields_column'] = array('id' => 'cus_id', 'name' => 'cus_name', 'name1' => 'cus_name1', 'type' => 'cus_type', 'position' => 'cus_pos', 'option' => 'cus_option'); $tables['addressbook_customfields_primary_key_column'] = 'id'; ObjectUtil::addStandardFieldsToTableDefinition($tables['addressbook_customfields_column'], 'cus_'); $tables['addressbook_customfields_column_def'] = array('id' => "I AUTO PRIMARY", 'name' => "C(30) DEFAULT NULL", 'name1' => "C(30) DEFAULT NULL", 'type' => "C(30) DEFAULT NULL", 'position' => "I NOTNULL DEFAULT 0", 'option' => "X DEFAULT NULL"); ObjectUtil::addStandardFieldsToTableDataDefinition($tables['addressbook_customfields_column_def'], 'cus_'); $tables['addressbook_favourites'] = 'addressbook_favourites'; $tables['addressbook_favourites_column'] = array('favadr_id' => 'fav_adr_id', 'favuser_id' => 'fav_user_id'); $tables['addressbook_favourites_column_def'] = array('favadr_id' => "I NOTNULL DEFAULT 0", 'favuser_id' => "I NOTNULL DEFAULT 0"); // Return the table information return $tables; }
/** * @param CollectionEntity|AbstractMediaEntity $entity * * @return string */ public function escapeDescription($entity) { $description = $entity->getDescription(); $strategy = null; $hookName = null; if ($entity instanceof CollectionEntity) { $strategy = \ModUtil::getVar('CmfcmfMediaModule', 'descriptionEscapingStrategyForCollection'); $hookName = 'collections'; } elseif ($entity instanceof AbstractMediaEntity) { $strategy = \ModUtil::getVar('CmfcmfMediaModule', 'descriptionEscapingStrategyForMedia'); $hookName = 'media'; } else { throw new \LogicException(); } $eventName = "cmfcmfmediamodule.filter_hooks.{$hookName}.filter"; $hook = new \Zikula_FilterHook($eventName, $description); $description = $this->hookDispatcher->dispatch($eventName, $hook)->getData(); switch ($strategy) { case 'raw': return $description; case 'text': return htmlentities($description); case 'markdown': return $this->markdownExtra->transform($description); default: throw new \LogicException(); } }
/** * Zikula_View function to get module variable * * This function obtains a module-specific variable from the Zikula system. * * Note that the results should be handled by the safetext or the safehtml * modifier before being displayed. * * * Available parameters: * - module: The well-known name of a module from which to obtain the variable * - name: The name of the module variable to obtain * - assign: If set, the results are assigned to the corresponding variable instead of printed out * - html: If true then result will be treated as html content * - default: The default value to return if the config variable is not set * * Example * {modgetvar module='Example' name='foobar' assign='foobarOfExample'} * * @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_modgetvar($params, Zikula_View $view) { $assign = isset($params['assign']) ? $params['assign'] : null; $default = isset($params['default']) ? $params['default'] : null; $module = isset($params['module']) ? $params['module'] : null; $html = isset($params['html']) ? (bool) $params['html'] : false; $name = isset($params['name']) ? $params['name'] : null; if (!$module) { $view->trigger_error(__f('Error! in %1$s: the %2$s parameter must be specified.', array('modgetvar', 'module'))); return false; } if (!$name && !$assign) { $view->trigger_error(__f('Error! in %1$s: the %2$s parameter must be specified.', array('modgetvar', 'name'))); return false; } if (!$name) { $result = ModUtil::getVar($module); } else { $result = ModUtil::getVar($module, $name, $default); } if ($assign) { $view->assign($assign, $result); } else { if ($html) { return DataUtil::formatForDisplayHTML($result); } else { return DataUtil::formatForDisplay($result); } } }
/** * Avatar_userapi_GetAvatars() * * returns all possible avatars for the current user. * * @param integer $args['uid'] the user ID (if missing, the current user is assumed) * @param integer $args['startnum'] int the number where to start (for paging) * @param integer $args['perpage'] int items per page * @return array a list of avatar file names **/ public function getAvatars($args) { $uid = isset($args['uid']) ? $args['uid'] : UserUtil::getVar('uid'); $page = isset($args['page']) ? $args['page'] : -1; $perpage = isset($args['perpage']) ? $args['perpage'] : -1; $realimages = isset($args['realimages']) ? true : false; $avatarpath = ModUtil::getVar('Users', 'avatarpath'); $allavatars = FileUtil::getFiles($avatarpath, true, true, null, false); if ($realimages == true) { $allavatars = array_diff($allavatars, array('blank.gif', 'gravatar.gif')); } $avatars = array(); foreach ($allavatars as $avatar) { // imagename is like pers_XXXX.gif (with XXXX = user id) if (ModUtil::apiFunc('Avatar', 'user', 'checkAvatar', array('avatar' => $avatar, 'uid' => $uid)) == true) { $avatars[] = $avatar; } } sort($avatars); $allcount = count($avatars); // paging if ($page != -1 && $perpage != -1) { $start = ($page - 1) * $perpage; $stop = $start + $perpage; if ($stop > $allcount) { $stop = $allcount; } $pagedavatars = array(); for ($idx = $start; $idx < $stop; $idx++) { $pagedavatars[] = $avatars[$idx]; } return array($pagedavatars, $allcount); } return array($avatars, $allcount); }
/** * called near end of loader() before template is fetched * @return array */ public static function addParameters() { // get plugins for tinymce $tinymce_listplugins = ModUtil::getVar('moduleplugin.scribite.tinymce', 'activeplugins'); $tinymce_buttonmap = array('paste' => 'pastetext,pasteword,selectall', 'insertdatetime' => 'insertdate,inserttime', 'table' => 'tablecontrols,table,row_props,cell_props,delete_col,delete_row,col_after,col_before,row_after,row_before,split_cells,merge_cells', 'directionality' => 'ltr,rtl', 'layer' => 'moveforward,movebackward,absolute,insertlayer', 'save' => 'save,cancel', 'style' => 'styleprops', 'xhtmlxtras' => 'cite,abbr,acronym,ins,del,attribs', 'searchreplace' => 'search,replace'); if (is_array($tinymce_listplugins)) { // Buttons/controls: http://www.tinymce.com/wiki.php/Buttons/controls // We have some plugins with the button name same as plugin name // and a few plugins with custom button names, so we have to check the mapping array. $tinymce_buttons = array(); foreach ($tinymce_listplugins as $tinymce_button) { if (array_key_exists($tinymce_button, $tinymce_buttonmap)) { $tinymce_buttons = array_merge($tinymce_buttons, explode(",", $tinymce_buttonmap[$tinymce_button])); } else { $tinymce_buttons[] = $tinymce_button; } } // TODO: I really would like to split this into multiple row, but I do not know how // $tinymce_buttons_splitted = array_chunk($tinymce_buttons, 20); // foreach ($tinymce_buttons_splitted as $key => $tinymce_buttonsrow) { // $tinymce_buttonsrows[] = DataUtil::formatForDisplay(implode(',', $tinymce_buttonsrow)); // } $tinymce_buttons = DataUtil::formatForDisplay(implode(',', $tinymce_buttons)); return array('buttons' => $tinymce_buttons); } return array('buttons' => ''); }
function get_geodata() { if (!SecurityUtil::checkPermission('AddressBook::', "::", ACCESS_EDIT)) { AjaxUtil::error($this->__('Error! No authorization to access this module.')); } $val_1 = FormUtil::getPassedValue('val_1', NULL, 'GETPOST'); $val_2 = FormUtil::getPassedValue('val_2', NULL, 'GETPOST'); $val_3 = FormUtil::getPassedValue('val_3', NULL, 'GETPOST'); $val_4 = FormUtil::getPassedValue('val_4', NULL, 'GETPOST'); //GMaps test include_once 'modules/AddressBook/lib/vendor/GMaps/GoogleMapV3.php'; $key = ModUtil::getVar('AddressBook', 'google_api_key'); $map = new GoogleMapAPI(); $map->setApiKey($key); $geocode = $map->getGeocode($val_1 . ', ' . $val_2 . ', ' . $val_3 . ', ' . $val_4); if (isset($geocode['lat']) && isset($geocode['lon'])) { $result = $geocode['lat'] . ',' . $geocode['lon']; } else { $result = ''; } if (FormUtil::getPassedValue('plane', NULL, 'GETPOST')) { return $result; } return new Zikula_Response_Ajax(array('lat_lon' => $result, 'result' => $result ? true : false)); }
/** * Initialise SiriusXtecAuth module. */ public function install() { // create module vars // ldap configuration $this->setVars(array('ldap_server' => 'host.domain', 'ldap_basedn' => 'cn=users,dc=host,dc=domain', 'ldap_searchattr' => 'cn')); // module configutation $defaultGroupId = ModUtil::getVar('Groups', 'defaultgroup'); $initGroups = array($defaultGroupId); $this->setVars(array('ldap_active' => false, 'users_creation' => false, 'new_users_activation' => false, 'new_users_groups' => $initGroups, 'iw_write' => false, 'iw_lastnames' => false, 'loginXtecApps' => false, 'logoutXtecApps' => false, 'gtafProtocol' => 'http', 'e13Protocol' => 'http', 'gtafURL' => 'aplitic.xtec.cat/pls/gafoas/pk_for_mod_menu.p_for_opcions_menu?p_perfil=RES', 'e13URL' => 'aplitic.xtec.cat/pls/e13_formacio_gaf/formacio_gaf.inici', 'loginTime' => 200, 'logoutTime' => 200)); // register handler EventUtil::registerPersistentModuleHandler('SiriusXtecAuth', 'module.users.ui.login.failed', array('SiriusXtecAuth_Listeners', 'trySiriusXtecAuth')); EventUtil::registerPersistentModuleHandler('SiriusXtecAuth', 'module.users.ui.logout.succeeded', array('SiriusXtecAuth_Listeners', 'logoutXtecApps')); // finish return true; }
/** * Collect available actions for this entity. */ protected function prepareItemActions() { if (!empty($this->_actions)) { return; } $currentType = FormUtil::getPassedValue('type', 'user', 'GETPOST', FILTER_SANITIZE_STRING); $currentFunc = FormUtil::getPassedValue('func', 'main', 'GETPOST', FILTER_SANITIZE_STRING); $dom = ZLanguage::getModuleDomain('Reviews'); if ($currentType == 'admin') { if (in_array($currentFunc, array('main', 'view'))) { $this->_actions[] = array('url' => array('type' => 'user', 'func' => 'display', 'arguments' => array('ot' => 'review', 'id' => $this['id'], 'slug' => $this->slug)), 'icon' => 'preview', 'linkTitle' => __('Open preview page', $dom), 'linkText' => __('Preview', $dom)); $this->_actions[] = array('url' => array('type' => 'admin', 'func' => 'display', 'arguments' => array('ot' => 'review', 'id' => $this['id'], 'slug' => $this->slug)), 'icon' => 'display', 'linkTitle' => str_replace('"', '', $this->getTitleFromDisplayPattern()), 'linkText' => __('Details', $dom)); } if (in_array($currentFunc, array('main', 'view', 'display'))) { $component = 'Reviews:Review:'; $instance = $this->id . '::'; if (SecurityUtil::checkPermission($component, $instance, ACCESS_EDIT)) { $this->_actions[] = array('url' => array('type' => 'admin', 'func' => 'edit', 'arguments' => array('ot' => 'review', 'id' => $this['id'])), 'icon' => 'edit', 'linkTitle' => __('Edit', $dom), 'linkText' => __('Edit', $dom)); $this->_actions[] = array('url' => array('type' => 'admin', 'func' => 'edit', 'arguments' => array('ot' => 'review', 'astemplate' => $this['id'])), 'icon' => 'saveas', 'linkTitle' => __('Reuse for new item', $dom), 'linkText' => __('Reuse', $dom)); } if (SecurityUtil::checkPermission($component, $instance, ACCESS_DELETE)) { $this->_actions[] = array('url' => array('type' => 'admin', 'func' => 'delete', 'arguments' => array('ot' => 'review', 'id' => $this['id'])), 'icon' => 'delete', 'linkTitle' => __('Delete', $dom), 'linkText' => __('Delete', $dom)); } } if ($currentFunc == 'display') { $this->_actions[] = array('url' => array('type' => 'admin', 'func' => 'view', 'arguments' => array('ot' => 'review')), 'icon' => 'back', 'linkTitle' => __('Back to overview', $dom), 'linkText' => __('Back to overview', $dom)); } } if ($currentType == 'user') { if (in_array($currentFunc, array('main', 'view'))) { if (ModUtil::getVar('Reviews', 'addcategorytitletopermalink') == 1 && ModUtil::getVar('Reviews', 'enablecategorization') == 1) { $this->_actions[] = array('url' => array('type' => 'user', 'func' => 'display', 'arguments' => array('ot' => 'review', 'id' => $this['id'], 'slug' => $this->slug)), 'icon' => 'display', 'linkTitle' => str_replace('"', '', $this->getTitleFromDisplayPattern()), 'linkText' => __('Details', $dom)); } else { $this->_actions[] = array('url' => array('type' => 'user', 'func' => 'display', 'arguments' => array('ot' => 'review', 'id' => $this['id'], 'slug' => $this->slug)), 'icon' => 'display', 'linkTitle' => str_replace('"', '', $this->getTitleFromDisplayPattern()), 'linkText' => __('Details', $dom)); } } /* if (in_array($currentFunc, array('main', 'view', 'display'))) { $component = 'Reviews:Review:'; $instance = $this->id . '::'; if (SecurityUtil::checkPermission($component, $instance, ACCESS_EDIT)) { $this->_actions[] = array( 'url' => array('type' => 'user', 'func' => 'edit', 'arguments' => array('ot' => 'review', 'id' => $this['id'])), 'icon' => 'edit', 'linkTitle' => __('Edit', $dom), 'linkText' => __('Edit', $dom) ); $this->_actions[] = array( 'url' => array('type' => 'user', 'func' => 'edit', 'arguments' => array('ot' => 'review', 'astemplate' => $this['id'])), 'icon' => 'saveas', 'linkTitle' => __('Reuse for new item', $dom), 'linkText' => __('Reuse', $dom) ); } } */ if ($currentFunc == 'display') { $this->_actions[] = array('url' => array('type' => 'user', 'func' => 'view', 'arguments' => array('ot' => 'review')), 'icon' => 'back', 'linkTitle' => __('Back to overview', $dom), 'linkText' => __('Back to overview', $dom)); } } }
/** * Constructor initialising the supported object types. */ public function __construct() { $this->allowedObjectTypes = array('posting', 'rank'); $this->imageFileTypes = array('gif', 'jpeg', 'jpg', 'png'); $this->forbiddenFileTypes = array('cgi', 'pl', 'asp', 'phtml', 'php', 'php3', 'php4', 'php5', 'exe', 'com', 'bat', 'jsp', 'cfm', 'shtml'); $filesize = ModUtil::getVar('MUBoard', 'allowedSizeOfImages'); $this->allowedFileSizes = array('posting' => array('firstImage' => $filesize, 'secondImage' => $filesize, 'thirdImage' => $filesize)); }
function getPluginData($filtAfterDate = null) { if (!$this->pluginAvailable()) { return array(); } if (!SecurityUtil::checkPermission('ZphpBB2::', '::', ACCESS_READ, $this->userNewsletter)) { return array(); } //ModUtil::load('ZphpBB2'); $table_prefix = ModUtil::getVar('ZphpBB2', 'table_prefix', 'phpbb_'); $TOPICS_TABLE = $table_prefix . "topics"; $POSTS_TABLE = $table_prefix . "posts"; $POSTS_TEXT_TABLE = $table_prefix . "posts_text"; $FORUMS_TABLE = $table_prefix . "forums"; $connection = Doctrine_Manager::getInstance()->getCurrentConnection(); $sql = "SELECT forum_id, forum_name FROM {$FORUMS_TABLE} WHERE auth_view <= 0 AND auth_read <= 0"; $stmt = $connection->prepare($sql); try { $stmt->execute(); } catch (Exception $e) { return LogUtil::registerError(__('Error in plugin') . ' ZphpBB2: ' . $e->getMessage()); } $userforums = $stmt->fetchAll(Doctrine_Core::FETCH_ASSOC); $allowedforums = array(); foreach (array_keys($userforums) as $k) { if (SecurityUtil::checkPermission('ZphpBB2::', ":" . $userforums[$k]['forum_id'] . ":", ACCESS_READ, $this->userNewsletter)) { $allowedforums[] = $userforums[$k]['forum_id']; } } if (count($allowedforums) == 0) { // user is not allowed to read any forum at all return array(); } $sql = "SELECT {$TOPICS_TABLE}.topic_title, {$TOPICS_TABLE}.topic_replies, {$TOPICS_TABLE}.topic_views, {$TOPICS_TABLE}.topic_id, \n {$POSTS_TABLE}.post_id, {$POSTS_TABLE}.poster_id, {$POSTS_TABLE}.post_time, \n {$POSTS_TEXT_TABLE}.post_subject, {$POSTS_TEXT_TABLE}.post_text, \n {$FORUMS_TABLE}.forum_name \n FROM {$TOPICS_TABLE} \n INNER JOIN {$POSTS_TABLE} ON {$POSTS_TABLE}.topic_id = {$TOPICS_TABLE}.topic_id \n INNER JOIN {$POSTS_TEXT_TABLE} ON {$POSTS_TEXT_TABLE}.post_id = {$POSTS_TABLE}.post_id \n INNER JOIN {$FORUMS_TABLE} ON {$FORUMS_TABLE}.forum_id = {$TOPICS_TABLE}.forum_id"; $sql .= " WHERE {$TOPICS_TABLE}.forum_id IN (" . implode(',', $allowedforums) . ")"; if ($filtAfterDate) { $sql .= " AND FROM_UNIXTIME(post_time)>='" . $filtAfterDate . "'"; } $sql .= " ORDER BY post_time DESC LIMIT " . $this->nItems; $stmt = $connection->prepare($sql); try { $stmt->execute(); } catch (Exception $e) { return LogUtil::registerError(__('Error in plugin') . ' ZphpBB2: ' . $e->getMessage()); } $items = $stmt->fetchAll(Doctrine_Core::FETCH_BOTH); foreach (array_keys($items) as $k) { $items[$k]['topicurl'] = ModUtil::url('ZphpBB2', 'user', 'viewtopic', array('t' => $items[$k]['topic_id'])); $items[$k]['posturl'] = ModUtil::url('ZphpBB2', 'user', 'viewtopic', array('p' => $items[$k]['post_id'] . '#' . $items[$k]['post_id'])); $items[$k]['postdate'] = DateUtil::getDatetime($items[$k]['post_time']); $items[$k]['username'] = UserUtil::getVar('uname', $items[$k]['poster_id']); $items[$k]['nl_title'] = $items[$k]['topic_title']; $items[$k]['nl_url_title'] = System::getBaseUrl() . $items[$k]['posturl']; $items[$k]['nl_content'] = $items[$k]['forum_name'] . ', ' . $items[$k]['username'] . "<br />\n" . $items[$k]['post_text']; $items[$k]['nl_url_readmore'] = $items[$k]['nl_url_title']; } return $items; }
/** * Gets topics information * * @author Albert Pérez Monfort (aperezm@xtec.cat) * @author Josep Ferràndiz Farré (jferran6@xtec.cat) */ public function display($row) { // Security check if (!SecurityUtil::checkPermission('IWmyrole::', "::", ACCESS_ADMIN)) { return false; } $uid = UserUtil::getVar('uid'); //Check if user belongs to change group. If not the block is not showed $sv = ModUtil::func('IWmain', 'user', 'genSecurityValue'); $isMember = ModUtil::func('IWmain', 'user', 'isMember', array('sv' => $sv, 'gid' => ModUtil::getVar('IWmyrole', 'rolegroup'), 'uid' => $uid)); if (!$isMember) { return false; } $sv = ModUtil::func('IWmain', 'user', 'genSecurityValue'); $uidGroups = ModUtil::func('IWmain', 'user', 'getAllUserGroups', array('sv' => $sv, 'uid' => $uid)); foreach ($uidGroups as $g) { $originalGroups[$g['id']] = 1; } $view = Zikula_View::getInstance('IWmyrole', false); // Gets the groups $sv = ModUtil::func('IWmain', 'user', 'genSecurityValue'); $allGroups = ModUtil::func('IWmain', 'user', 'getAllGroups', array('sv' => $sv, 'less' => ModUtil::getVar('IWmyrole', 'rolegroup'))); $groupsNotChangeable = ModUtil::getVar('IWmyrole', 'groupsNotChangeable'); foreach ($allGroups as $group) { if (strpos($groupsNotChangeable, '$' . $group['id'] . '$') == false) $groupsArray[] = $group; } $sv = ModUtil::func('IWmain', 'user', 'genSecurityValue'); $invalidChange = ModUtil::func('IWmain', 'user', 'userGetVar', array('uid' => $uid, 'name' => 'invalidChange', 'module' => 'IWmyrole', 'nult' => true, 'sv' => $sv)); $view->assign('groups', $groupsArray); $view->assign('invalidChange', $invalidChange); $view->assign('roleGroups', $originalGroups); $s = $view->fetch('IWmyrole_block_change.htm'); $row['content'] = $s; return BlockUtil::themesideblock($row); }
public static function addParameters() { $useEFM = ModUtil::getVar('moduleplugin.scribite.xinha', 'useEFM'); if ($useEFM) { return array('EFMConfig' => self::getEFMConfig()); } else { return array('EFMConfig' => ''); } }
public function editors() { $this->throwForbiddenUnless(SecurityUtil::checkPermission('Scribite::', '::', ACCESS_ADMIN), LogUtil::getErrorMsgPermission()); // check for all supported editors and generate links $editors = ModUtil::apiFunc('Scribite', 'admin', 'getEditors', array('editorname' => "list")); $this->view->assign('editors', $editors); $this->view->assign('defaulteditor', ModUtil::getVar('Scribite', 'DefaultEditor')); return $this->view->fetch('admin/editors.tpl'); }
/** * Zikula_View function to display the avatar of a user * * Available parameters: * - uid User uid * - width, height Width and heigt of the image (optional) * - assign The results are assigned to the corresponding variable instead of printed out (optional). * Gravatar parameters * - size Size of the gravtar (optional) * - rating Gravatar allows users to self-rate their images so that they can indicate if an image is appropriate for a certain audience. * [g|pg|r|x] see: http://en.gravatar.com/site/implement/images/ (optional) * * Examples: * {useravatar uid="2"} * {useravatar uid="2" width=80 height=80} * {useravatar uid="2" size=80 rating=g} * * @param array $params All attributes passed to this function from the template. * @param Zikula_View $view Reference to the Zikula_View object. * * @return string A formatted string containing the avatar image. */ function smarty_function_useravatar($params, Zikula_View $view) { if (!isset($params['uid'])) { $view->trigger_error("Error! Missing 'uid' attribute for useravatar."); return false; } $email = UserUtil::getVar('email', $params['uid']); $avatar = UserUtil::getVar('avatar', $params['uid']); $uname = UserUtil::getVar('uname', $params['uid']); $avatarpath = ModUtil::getVar(UsersConstant::MODNAME, UsersConstant::MODVAR_AVATAR_IMAGE_PATH, UsersConstant::DEFAULT_AVATAR_IMAGE_PATH); $allowgravatars = ModUtil::getVar(UsersConstant::MODNAME, UsersConstant::MODVAR_GRAVATARS_ENABLED, UsersConstant::DEFAULT_GRAVATARS_ENABLED); $gravatarimage = ModUtil::getVar(UsersConstant::MODNAME, UsersConstant::MODVAR_GRAVATAR_IMAGE, UsersConstant::DEFAULT_GRAVATAR_IMAGE); if (isset($avatar) && !empty($avatar) && $avatar != $gravatarimage && $avatar != 'blank.gif') { $avatarURL = System::getBaseUrl() . $avatarpath . '/' . $avatar; } elseif ($avatar == $gravatarimage && $allowgravatars == 1) { if (!isset($params['rating'])) { $params['rating'] = false; } if (!isset($params['size'])) { if (isset($params['width'])) { $params['size'] = $params['width']; } $params['size'] = 80; } $params['width'] = $params['size']; $params['height'] = $params['size']; $avatarURL = 'http://www.gravatar.com/avatar.php?gravatar_id=' . md5($email); if (isset($params['rating']) && !empty($params['rating'])) { $avatarURL .= "&rating=" . $params['rating']; } if (isset($params['size']) && !empty($params['size'])) { $avatarURL .= "&size=" . $params['size']; } $avatarURL .= "&default=" . urlencode(System::getBaseUrl() . $avatarpath . '/' . $gravatarimage); } else { // e.g. blank.gif or empty avatars return false; } $classString = ''; if (isset($params['class'])) { $classString = "class=\"{$params['class']}\" "; } $html = '<img ' . $classString . ' src="' . DataUtil::formatForDisplay($avatarURL) . '" title="' . DataUtil::formatForDisplay($uname) . '" alt="' . DataUtil::formatForDisplay($uname); if (isset($params['width'])) { $html .= ' width="' . $params['width'] . '"'; } if (isset($params['height'])) { $html .= ' height="' . $params['height'] . '"'; } $html .= '" />'; if (isset($params['assign'])) { $view->assign($params['assign'], $avatarURL); } else { return $html; } }
function initialize(Zikula_Form_View $view) { $view->caching = false; $view->add_core_data(); $view->assign('avatarpath', ModUtil::getVar('Users', 'avatarpath')); $view->assign('avatarpath_writable', is_writable(ModUtil::getVar('Users', 'avatarpath'))); $view->assign('pnphpbb_installed', ModUtil::available('pnphpbb')); $view->assign('forumdir_writable', is_writable(ModUtil::getVar('Avatar', 'forumdir'))); return true; }
public function initialize(Zikula_Form_View $view) { $this->pageId = (int) FormUtil::getPassedValue('pid', isset($this->args['pid']) ? $this->args['pid'] : -1); if ((bool) $this->getVar('inheritPermissions', false) === true) { if (!ModUtil::apiFunc('Content', 'page', 'checkPermissionForPageInheritance', array('pageId' => $this->pageId, 'level' => ACCESS_EDIT))) { throw new Zikula_Exception_Forbidden(LogUtil::getErrorMsgPermission()); } } else { if (!SecurityUtil::checkPermission('Content:page:', $this->pageId . '::', ACCESS_EDIT)) { throw new Zikula_Exception_Forbidden(LogUtil::getErrorMsgPermission()); } } $page = ModUtil::apiFunc('Content', 'Page', 'getPage', array('id' => $this->pageId, 'editing' => true, 'filter' => array('checkActive' => false), 'enableEscape' => false, 'translate' => false, 'includeContent' => true, 'includeCategories' => true)); if ($page === false) { return $this->view->registerError(null); } // load the category registry util $mainCategory = CategoryRegistryUtil::getRegisteredModuleCategory('Content', 'content_page', $this->getVar('categoryPropPrimary'), 30); $secondCategory = CategoryRegistryUtil::getRegisteredModuleCategory('Content', 'content_page', $this->getVar('categoryPropSecondary')); $multilingual = ModUtil::getVar(ModUtil::CONFIG_MODULE, 'multilingual'); if ($page['language'] == ZLanguage::getLanguageCode()) { $multilingual = false; } PageUtil::setVar('title', $this->__("Edit page") . ' : ' . $page['title']); $pagelayout = ModUtil::apiFunc('Content', 'Layout', 'getLayout', array('layout' => $page['layout'])); if ($pagelayout === false) { return $this->view->registerError(null); } $layouts = ModUtil::apiFunc('Content', 'Layout', 'getLayouts'); if ($layouts === false) { return $this->view->registerError(null); } $layoutTemplate = $page['layoutEditTemplate']; $this->view->assign('layoutTemplate', $layoutTemplate); $this->view->assign('mainCategory', $mainCategory); $this->view->assign('secondCategory', $secondCategory); $this->view->assign('page', $page); $this->view->assign('multilingual', $multilingual); $this->view->assign('layouts', $layouts); $this->view->assign('pagelayout', $pagelayout); $this->view->assign('enableVersioning', $this->getVar('enableVersioning')); $this->view->assign('categoryUsage', $this->getVar('categoryUsage')); Content_Util::contentAddAccess($this->view, $this->pageId); if (!$this->view->isPostBack() && FormUtil::getPassedValue('back', 0)) { $this->backref = isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : null; } if ($this->backref != null) { $returnUrl = $this->backref; } else { $returnUrl = ModUtil::url('Content', 'admin', 'main'); } ModUtil::apiFunc('PageLock', 'user', 'pageLock', array('lockName' => "contentPage{$this->pageId}", 'returnUrl' => $returnUrl)); return true; }
/** * Get the theme variables from both the DB and the .yml file. * @return array|string */ public function getThemeVars() { $dbVars = \ModUtil::getVar($this->name); $defaultVars = $this->getDefaultThemeVars(); $combinedVars = array_merge($defaultVars, $dbVars); if (array_keys($dbVars) != array_keys($combinedVars)) { // First load of file or vars have been added to the .yml file. \ModUtil::setVars($this->name, $combinedVars); } return $combinedVars; }
public function getDataFromInputPostProcess($data = null) { if (!$data) { $data =& $this->_objData; } $data['private'] = isset($data['private']) ? 1 : 0; if (!ModUtil::getVar('AddressBook', 'allowprivate')) { $data['private'] = 0; } return $data; }
/** * Return an array of items to show in the your account panel * * @return array */ public function getall() { $items = array(); $useAccountPage = ModUtil::getVar('EZComments', 'useaccountpage', '1'); if ($useAccountPage) { // Create an array of links to return $items['1'] = array('url' => ModUtil::url('EZComments', 'user', 'main'), 'title' => $this->__('Manage my comments'), 'icon' => 'mycommentsbutton.png', 'set' => null); } // return the items return $items; }
/** * Get an array with the all the max deliver possibilities * @author Sara Arjona Téllez (sarjona@xtec.cat) * @param - * @return array The array with each maxdeliver possibility (id, name) */ public function getmaxdelivers($args) { $tmp = explode(",", ModUtil::getVar('IWqv', 'maxdelivers')); for ($i = 0; $i < count($tmp); $i++) { $name = $tmp[$i]; if ($name == -1) $name = $this->__('Unlimited'); $items[$i] = array("id" => $tmp[$i], "name" => $name); } return $items; }
public function getConfig() { // Security check will be done in catalegsgest() $this->throwForbiddenUnless(SecurityUtil::checkPermission('Llicencies::', '::', ACCESS_ADMIN)); $docRoot = ModUtil::getVar($this->name, 'LlicenciesDocRoot'); $view = Zikula_View::getInstance('Llicencies', false); $view->assign('root', $docRoot); return $view->fetch('Llicencies_admin_config.tpl'); }
/** * On an module remove hook call this listener * * Listens for the 'user.account.create' event. * * @param Zikula_Event $event Event. */ public static function onCreateUser(Zikula_Event $event) { if (!ModUtil::getVar('Dashboard', 'widgetsnewuser', false)) { return; } $user = $event->getSubject(); $helper = new Dashboard_Helper_WidgetHelper(ServiceUtil::getService('doctrine.entitymanager')); $widgets = $helper->getRegisteredWidgets($user['uid']); foreach ($widgets as $widget) { Dashboard_Util::addUserWidget($user['uid'], $widget); } }