public function updateConfig($args) { // Security check if (!SecurityUtil::checkPermission('SiriusXtecAuth::', '::', ACCESS_ADMIN)) { return LogUtil::registerPermissionError(); } $items = array( 'ldap_active' => FormUtil::getPassedValue('ldap_active', false, 'POST')?true:false, 'users_creation' => FormUtil::getPassedValue('users_creation', false, 'POST')?true:false, 'new_users_activation' => FormUtil::getPassedValue('new_users_activation', false, 'POST')?true:false, 'iw_write' => FormUtil::getPassedValue('iw_write', false, 'POST')?true:false, 'iw_lastnames' => FormUtil::getPassedValue('iw_lastnames', false, 'POST')?true:false, 'new_users_groups' => FormUtil::getPassedValue('new_users_groups', array(), 'POST'), 'ldap_server' => FormUtil::getPassedValue('ldap_server', false, 'POST'), 'ldap_basedn' => FormUtil::getPassedValue('ldap_basedn', false, 'POST'), 'ldap_searchattr' => FormUtil::getPassedValue('ldap_searchattr', false, 'POST'), 'loginXtecApps' => FormUtil::getPassedValue('loginXtecApps', false, 'POST'), 'logoutXtecApps' => FormUtil::getPassedValue('logoutXtecApps', false, 'POST'), 'gtafProtocol' => FormUtil::getPassedValue('gtafProtocol', false, 'POST'), 'e13Protocol' => FormUtil::getPassedValue('e13Protocol', false, 'POST'), 'gtafURL' => FormUtil::getPassedValue('gtafURL', false, 'POST'), 'e13URL' => FormUtil::getPassedValue('e13URL', false, 'POST'), 'loginTime' => FormUtil::getPassedValue('loginTime', false, 'POST'), 'logoutTime' => FormUtil::getPassedValue('logoutTime', false, 'POST')); ModUtil::setVars($this->name,$items); LogUtil::registerStatus($this->__('S\'ha actualitzat la configuració del mòdul.')); return System::redirect(ModUtil::url('SiriusXtecAuth', 'admin', 'main')); }
/** * Function to delete an ids log entry */ public function deleteidsentry() { // verify auth-key $this->checkCsrfToken(); // Security check if (!SecurityUtil::checkPermission('SecurityCenter::', '::', ACCESS_DELETE)) { return LogUtil::registerPermissionError(); } // get paramters $id = (int)FormUtil::getPassedValue('id', 0, 'GETPOST'); // sanity check if (!is_numeric($id)) { return LogUtil::registerError($this->__f("Error! Received a non-numeric object ID '%s'.", $id)); } $class = 'SecurityCenter_DBObject_Intrusion'; $object = new $class(); $data = $object->get($id); // check for valid object if (!$data) { return LogUtil::registerError($this->__f('Error! Invalid %s received.', "object ID [$id]")); } else { // delete object $object->delete(); } // redirect back to view function $this->redirect(ModUtil::url('SecurityCenter', 'admin', 'viewidslog')); }
/** * get available admin panel links * @return array array of admin links */ public function getlinks() { $links = array(); if (SecurityUtil::checkPermission('SecurityCenter::', '::', ACCESS_ADMIN)) { $links[] = array('url' => ModUtil::url('SecurityCenter', 'admin', 'modifyconfig'), 'text' => $this->__('Settings'), 'class' => 'z-icon-es-config'); $links[] = array('url' => ModUtil::url('SecurityCenter', 'admin', 'allowedhtml'), 'text' => $this->__('Allowed HTML settings'), 'class' => 'z-icon-es-options'); $links[] = array('url' => ModUtil::url('SecurityCenter', 'admin', 'viewidslog'), 'text' => $this->__('View IDS Log'), 'class' => 'z-icon-es-log', 'links' => array( array('url' => ModUtil::url('SecurityCenter', 'admin', 'viewidslog'), 'text' => $this->__('View IDS Log')), array('url' => ModUtil::url('SecurityCenter', 'admin', 'exportidslog'), 'text' => $this->__('Export IDS Log')), array('url' => ModUtil::url('SecurityCenter', 'admin', 'purgeidslog'), 'text' => $this->__('Purge IDS Log')) )); $outputfilter = System::getVar('outputfilter'); if ($outputfilter == 1) { $links[] = array('url' => ModUtil::url('SecurityCenter', 'admin', 'purifierconfig'), 'text' => $this->__('HTMLPurifier settings'), 'class' => 'z-icon-es-options'); } } return $links; }
/** * Smarty function to display a link to the next post * * Example * <!--[nextpostlink sid=$info.sid layout='%link% <span class="news_metanav">»</span>']--> * * @author Mark West * @since 20/10/03 * @see function.nextpostlink.php::smarty_function_nextpostlink() * @param array $params All attributes passed to this function from the template * @param object &$smarty Reference to the Smarty object * @param integer $sid article id * @param string $layout HTML string in which to insert link * @return string the results of the module function */ function smarty_function_nextpostlink($params, &$smarty) { if (!isset($params['sid'])) { // get the info template var $info = $smarty->get_template_vars('info'); $params['sid'] = $info['sid']; } if (!isset($params['layout'])) { $params['layout'] = '%link% <span class="news_metanav">»</span>'; } $article = ModUtil::apiFunc('News', 'user', 'getall', array('query' => array(array('sid', '>', $params[sid])), 'orderdir' => 'ASC', 'numitems' => 1)); if (!$article) { return; } $articlelink = '<a href="'.DataUtil::formatForDisplay(ModUtil::url('News', 'user', 'display', array('sid' => $article[0]['sid']))).'">'.DataUtil::formatForDisplay($article[0]['title']).'</a>'; $articlelink = str_replace('%link%', $articlelink, $params['layout']); if (isset($params['assign'])) { $smarty->assign($params['assign'], $articlelink); } else { return $articlelink; } }
function handleCommand(Zikula_Form_View $view, &$args) { if ($args['commandName'] == 'cancel') { $url = ModUtil::url('Scribite', 'admin', 'main'); return $view->redirect($url); } else { if ($args['commandName'] == 'restore') { $classname = 'ModulePlugin_Scribite_' . $this->editor . '_Plugin'; if (method_exists($classname, 'getDefaults')) { $defaults = $classname::getDefaults(); if (!empty($defaults)) { ModUtil::setVars("moduleplugin.scribite." . strtolower($this->editor), $defaults); LogUtil::registerStatus('Defaults succesfully restored.'); } } return true; } } // check for valid form if (!$view->isValid()) { return false; } $data = $view->getValues(); ModUtil::setVars("moduleplugin.scribite." . strtolower($this->editor), $data); LogUtil::registerStatus($this->__('Done! Module configuration updated.')); return true; }
/** * Update the configuration values * @author: Sara Arjona Téllez (sarjona@xtec.cat) * @params The config values from the form * @return Thue if success */ public function confupdate($args) { $skins = FormUtil::getPassedValue('skins', isset($args['skins']) ? $args['skins'] : null, 'POST'); $langs = FormUtil::getPassedValue('langs', isset($args['langs']) ? $args['langs'] : null, 'POST'); $maxdelivers = FormUtil::getPassedValue('maxdelivers', isset($args['maxdelivers']) ? $args['maxdelivers'] : null, 'POST'); $basedisturl = FormUtil::getPassedValue('basedisturl', isset($args['basedisturl']) ? $args['basedisturl'] : null, 'POST'); // Security check if (!SecurityUtil::checkPermission('IWqv::', "::", ACCESS_ADMIN)) { throw new Zikula_Exception_Forbidden(); } // Confirm authorisation code $this->checkCsrfToken(); if (isset($skins)) ModUtil::setVar('IWqv', 'skins', $skins); if (isset($langs)) ModUtil::setVar('IWqv', 'langs', $langs); if (isset($maxdelivers)) ModUtil::setVar('IWqv', 'maxdelivers', $maxdelivers); if (isset($basedisturl)) ModUtil::setVar('IWqv', 'basedisturl', $basedisturl); LogUtil::registerStatus($this->__f('Done! %1$s updated.', $this->__('settings'))); return System::redirect(ModUtil::url('IWqv', 'admin', 'main')); }
public function getlinks($args) { $links = array(); $sublinks = array(); $links[] = array('url' => ModUtil::url('Scribite', 'admin', 'modules'), 'text' => $this->__('Module list'), 'class' => 'z-icon-es-view'); $links[] = array('url' => ModUtil::url('Scribite', 'admin', 'newmodule'), 'text' => $this->__('Add module'), 'class' => 'z-icon-es-new'); $links[] = array('url' => ModUtil::url('Scribite', 'admin', 'modifyconfig'), 'text' => $this->__('Settings'), 'class' => 'z-icon-es-config'); // check for all supported editors and generate links if (ModUtil::apiFunc('scribite', 'user', 'getEditors', array('editorname' => 'xinha'))) { $sublinks[] = array('url' => ModUtil::url('scribite', 'admin', 'modifyxinha'), 'text' => $this->__('Xinha')); } if (ModUtil::apiFunc('scribite', 'user', 'getEditors', array('editorname' => 'ckeditor'))) { $sublinks[] = array('url' => ModUtil::url('scribite', 'admin', 'modifyckeditor'), 'text' => $this->__('CKEditor')); } // openwysiwyg deprecated @4.3.0 // if (ModUtil::apiFunc('scribite', 'user', 'getEditors', array('editorname' => 'openwysiwyg'))) { // $sublinks[] = array( // 'url' => ModUtil::url('scribite', 'admin', 'modifyopenwysiwyg'), // 'text' => $this->__('openWYSIWYG')); // } if (ModUtil::apiFunc('scribite', 'user', 'getEditors', array('editorname' => 'nicedit'))) { $sublinks[] = array('url' => ModUtil::url('scribite', 'admin', 'modifynicedit'), 'text' => $this->__('NicEdit')); } if (ModUtil::apiFunc('scribite', 'user', 'getEditors', array('editorname' => 'markitup'))) { $sublinks[] = array('url' => ModUtil::url('scribite', 'admin', 'modifymarkitup'), 'text' => $this->__('markitup')); } if (ModUtil::apiFunc('scribite', 'user', 'getEditors', array('editorname' => 'tinymce'))) { $sublinks[] = array('url' => ModUtil::url('scribite', 'admin', 'modifytinymce'), 'text' => $this->__('TinyMCE')); } // add YUI page $sublinks[] = array('url' => ModUtil::url('scribite', 'admin', 'modifyyui'), 'text' => $this->__('YUI Editor')); $links[] = array('url' => ModUtil::url('Scribite', 'admin', 'modules'), 'text' => $this->__('Editor Config'), 'class' => 'z-icon-es-editor', 'links' => $sublinks); // return output return $links; }
/** * Do the migration * * With this function, the actual migration is done. * * @return boolean true on sucessful migration, false else * @since 0.2 */ function EZComments_migrateapi_pnFlashGames() { // Security check if (!SecurityUtil::checkPermission('EZComments::', '::', ACCESS_ADMIN)) { return LogUtil::registerError('pnFlashGames comments migration: Not Admin'); } // Get datbase setup $tables = DBUtil::getTables(); $Commentstable = $tables['pnFlashGames_comments']; $Commentscolumn = $tables['pnFlashGames_comments_column']; $Usertable = $tables['users']; $Usercolumn = $tables['users_column']; $sql = "SELECT {$Commentscolumn['gid']},\n {$Commentscolumn['uname']},\n {$Commentscolumn['date']},\n {$Commentscolumn['comment']},\n {$Usercolumn['uid']}\n FROM {$Commentstable}\n LEFT JOIN {$Usertable}\n ON {$Commentscolumn['uname']} = {$Usercolumn['uname']}"; $result = DBUtil::executeSQL($sql); if ($result == false) { return LogUtil::registerError('pnFlashGames migration: DB Error: ' . $sql . ' -- ' . mysql_error()); } // loop through the old comments and insert them one by one into the DB $items = DBUtil::marshalObjects($result, array('gid', 'uname', 'date', 'comment', 'uid')); foreach ($items as $item) { // set the correct user id for anonymous users if (empty($item['uid'])) { $item['uid'] = 1; } $id = ModUtil::apiFunc('EZComments', 'user', 'create', array('mod' => 'pnFlashGames', 'objectid' => DataUtil::formatForStore($item['gid']), 'url' => ModUtil::url('pnFlashGames', 'user', 'display', array('id' => $item['gid'])), 'comment' => $item['comment'], 'subject' => '', 'uid' => $item['uid'], 'date' => $item['date'])); if (!$id) { return LogUtil::registerError('pnFlashGames migration: Error creating comment'); } } return LogUtil::registerStatus('pnFlashGames migration successful'); }
/** * Content needle * @param $args['nid'] needle id * @return array() */ function content_needleapi_content($args) { $dom = ZLanguage::getModuleDomain('Content'); // Get arguments from argument array $nid = $args['nid']; unset($args); // cache the results static $cache; if (!isset($cache)) { $cache = array(); } if (!empty($nid)) { if (!isset($cache[$nid])) { // not in cache array if (ModUtil::available('Content')) { $contentpage = ModUtil::apiFunc('Content', 'Page', 'getPage', array('id' => $nid, 'includeContent' => false)); if ($contentpage != false) { $cache[$nid] = '<a href="' . DataUtil::formatForDisplay(ModUtil::url('Content', 'user', 'view', array('pid' => $nid))) . '" title="' . DataUtil::formatForDisplay($contentpage['title']) . '">' . DataUtil::formatForDisplay($contentpage['title']) . '</a>'; } else { $cache[$nid] = '<em>' . DataUtil::formatForDisplay(__('Unknown id', $dom)) . '</em>'; } } else { $cache[$nid] = '<em>' . DataUtil::formatForDisplay(__('Content not available', $dom)) . '</em>'; } } $result = $cache[$nid]; } else { $result = '<em>' . DataUtil::formatForDisplay(__('No needle id', $dom)) . '</em>'; } return $result; }
/** * This method provides a generic handling of all edit requests. * * @param string $ot Treated object type. * @param string $tpl Name of alternative template (for alternative display options, feeds and xml output) * @param boolean $raw Optional way to display a template instead of fetching it (needed for standalone output) * * @return mixed Output. */ public function edit() { $id = $this->request->query->filter('id', 0); if ($id > 0) { $url = ModUtil::url($this->name, 'user', 'view'); return System::redirect($url); } $controllerHelper = new Reviews_Util_Controller($this->serviceManager); // parameter specifying which type of objects we are treating $objectType = $this->request->query->filter('ot', 'review', FILTER_SANITIZE_STRING); $utilArgs = array('controller' => 'user', 'action' => 'edit'); if (!in_array($objectType, $controllerHelper->getObjectTypes('controllerAction', $utilArgs))) { $objectType = $controllerHelper->getDefaultObjectType('controllerAction', $utilArgs); } $this->throwForbiddenUnless(SecurityUtil::checkPermission($this->name . ':' . ucwords($objectType) . ':', '::', ACCESS_EDIT), LogUtil::getErrorMsgPermission()); // create new Form reference $view = FormUtil::newForm($this->name, $this); // build form handler class name $handlerClass = $this->name . '_Form_Handler_User_' . ucfirst($objectType) . '_Edit'; // determine the output template $viewHelper = new Reviews_Util_View($this->serviceManager); $template = $viewHelper->getViewTemplate($this->view, 'user', $objectType, 'edit', array()); // execute form using supplied template and page event handler return $view->execute($template, new $handlerClass()); }
/** * User category selector. * * Available parameters: * - btnText: If set, the results are assigned to the corresponding variable instead of printed out * - cid: category ID * * Example * {selector_user_category cid="1" assign="category"} * * @param array $params All attributes passed to this function from the template. * @param Zikula_View $view Reference to the Zikula_View object. * * @return string HTML code of the selector. */ function smarty_function_selector_user_category($params, Zikula_View $view) { $field = isset($params['field']) ? $params['field'] : 'id'; $selectedValue = isset($params['selectedValue']) ? $params['selectedValue'] : 0; $defaultValue = isset($params['defaultValue']) ? $params['defaultValue'] : 0; $defaultText = isset($params['defaultText']) ? $params['defaultText'] : ''; $lang = isset($params['lang']) ? $params['lang'] : ZLanguage::getLanguageCode(); $name = isset($params['name']) ? $params['name'] : 'defautlselectorname'; $recurse = isset($params['recurse']) ? $params['recurse'] : true; $relative = isset($params['relative']) ? $params['relative'] : true; $includeRoot = isset($params['includeRoot']) ? $params['includeRoot'] : false; $includeLeaf = isset($params['includeLeaf']) ? $params['includeLeaf'] : true; $all = isset($params['all']) ? $params['all'] : false; $displayPath = isset($params['displayPath']) ? $params['displayPath'] : false; $attributes = isset($params['attributes']) ? $params['attributes'] : null; $assign = isset($params['assign']) ? $params['assign'] : null; $editLink = isset($params['editLink']) ? $params['editLink'] : true; $submit = isset($params['submit']) ? $params['submit'] : false; $multipleSize = isset($params['multipleSize']) ? $params['multipleSize'] : 1; $doReplaceRootCat = false; $userCats = ModUtil::apiFunc('ZikulaCategoriesModule', 'user', 'getusercategories', array('returnCategory' => 1, 'relative' => $relative)); $html = CategoryUtil::getSelector_Categories($userCats, $field, $selectedValue, $name, $defaultValue, $defaultText, $submit, $displayPath, $doReplaceRootCat, $multipleSize); if ($editLink && $allowUserEdit && UserUtil::isLoggedIn() && SecurityUtil::checkPermission('ZikulaCategoriesModule::', "{$category['id']}::", ACCESS_EDIT)) { $url = ModUtil::url('ZikulaCategoriesModule', 'user', 'edituser'); $html .= " <a href=\"{$url}\">" . __('Edit sub-categories') . '</a>'; } if ($assign) { $view->assign($assign, $html); } else { return $html; } }
/** * Display block. * * @param array $blockinfo Blockinfo structure. * * @return output Rendered block. */ public function display($blockinfo) { if (!SecurityUtil::checkPermission('PendingContent::', "{$blockinfo['title']}::", ACCESS_OVERVIEW)) { return; } // trigger event $event = new Zikula_Event('get.pending_content', new Zikula_Collection_Container('pending_content')); $pendingCollection = EventUtil::getManager()->notify($event)->getSubject(); $content = array(); // process results foreach ($pendingCollection as $collection) { $module = $collection->getName(); foreach ($collection as $item) { $link = ModUtil::url($module, $item->getController(), $item->getMethod(), $item->getArgs()); $content[] = array('description' => $item->getDescription(), 'link' => $link, 'number' => $item->getNumber()); } } if (!empty($content)) { $this->view->assign('content', $content); $blockinfo['content'] = $this->view->fetch('blocks_block_pendingcontent.tpl'); } else { $blockinfo['content'] = ''; } return BlockUtil::themeBlock($blockinfo); }
public function getlinks($args) { if (SecurityUtil::checkPermission('IWmessages::', '::', ACCESS_ADMIN)) { $links[] = array('url' => ModUtil::url($this->name, 'admin', 'main'), 'text' => $this->__('Module configuration'),'class' => 'z-icon-es-config'); } return $links; }
/** * get available User panel links * * @return array Array of admin links */ public function getlinks() { $func = $this->request->query->filter('func', 'main', FILTER_SANITIZE_STRING); $ot = $this->request->query->filter('ot', 'category', FILTER_SANITIZE_STRING); $forum = $this->request->query->filter('id', 0, FILTER_SANITIZE_NUMBER_INT); $links = array(); if (SecurityUtil::checkPermission($this->name . '::', '::', ACCESS_ADMIN)) { $links[] = array('url' => ModUtil::url($this->name, 'admin', 'main'), 'text' => $this->__('Backend'), 'title' => $this->__('Switch to administration area.'), 'class' => 'z-icon-es-options'); } if (SecurityUtil::checkPermission($this->name . '::', '::', ACCESS_READ)) { $links[] = array('url' => ModUtil::url($this->name, 'user', 'view', array('ot' => 'category')), 'text' => $this->__('Categories'), 'title' => $this->__('Category list')); } if (SecurityUtil::checkPermission($this->name . ':Forum:', $forum . '::', ACCESS_ADD) && $func == 'display' && $ot == 'forum') { $links[] = array('url' => ModUtil::url($this->name, 'user', 'edit', array('ot' => 'posting', 'forum' => $forum)), 'text' => $this->__('New issue'), 'title' => $this->__('Create a new issue')); } if (SecurityUtil::checkPermission($this->name . '::', '::', ACCESS_OVERVIEW)) { $links[] = array('url' => ModUtil::url($this->name, 'search', 'moduleSearch', array('kind' => 'latestPostings')), 'text' => $this->__('Latest issues'), 'title' => $this->__('Look for latest issues')); } if (SecurityUtil::checkPermission($this->name . '::', '::', ACCESS_OVERVIEW)) { $links[] = array('url' => ModUtil::url($this->name, 'search', 'moduleSearch'), 'text' => $this->__('Search issues'), 'title' => $this->__('Look for relevant issues')); } /*if (SecurityUtil::checkPermission($this->name . '::', '::', ACCESS_READ)) { $links[] = array('url' => ModUtil::url($this->name, 'user', 'view', array('ot' => 'forum')), 'text' => $this->__('Forums'), 'title' => $this->__('Forum list')); } if (SecurityUtil::checkPermission($this->name . '::', '::', ACCESS_READ)) { $links[] = array('url' => ModUtil::url($this->name, 'user', 'view', array('ot' => 'posting')), 'text' => $this->__('Postings'), 'title' => $this->__('Posting list')); }*/ return $links; }
/** * Create or edit record. * * @return string|boolean Output. */ public function edit() { if (!SecurityUtil::checkPermission('ExampleDoctrine::', '::', ACCESS_ADD)) { return LogUtil::registerPermissionError(ModUtil::url('ExampleDoctrine', 'user', 'index')); } $id = $this->request->query->getInt('id'); if ($id) { // load user with id $user = $this->entityManager->find('ExampleDoctrine_Entity_User', $id); if (!$user) { return LogUtil::registerError($this->__f('User with id %s not found', $id)); } } else { $user = new ExampleDoctrine_Entity_User(); } /* @var $form Symfony\Component\Form\Form */ $form = $this->serviceManager->getService('symfony.formfactory')->create(new ExampleDoctrine_Form_UserType(), $user); if ($this->request->getMethod() == 'POST') { $form->bindRequest($this->request); if ($form->isValid()) { $data = $form->getData(); $this->entityManager->persist($data); $this->entityManager->flush(); return $this->redirect(ModUtil::url('ExampleDoctrine', 'user', 'view')); } } return $this->view->assign('form', $form->createView())->fetch('exampledoctrine_user_edit.tpl'); }
function delete() { // security check if (!SecurityUtil::checkPermission('AddressBook::', '::', ACCESS_ADMIN)) { return LogUtil::registerPermissionError(); } $ot = FormUtil::getPassedValue('ot', 'categories', 'GETPOST'); $id = (int) FormUtil::getPassedValue('id', 0, 'GETPOST'); $url = ModUtil::url('AddressBook', 'admin', 'view', array('ot' => $ot)); $class = 'AddressBook_DBObject_' . ucfirst($ot); if (!class_exists($class)) { return z_exit(__f('Error! Unable to load class [%s]', $ot)); } $object = new $class(); $data = $object->get($id); if (!$data) { LogUtil::registerError(__f('%1$s with ID of %2$s doesn\'\\t seem to exist', array($ot, $id))); return System::redirect($url); } $object->delete(); if ($ot == "customfield") { $sql = "ALTER TABLE addressbook_address DROP adr_custom_" . $id; try { DBUtil::executeSQL($sql, -1, -1, true, true); } catch (Exception $e) { } } LogUtil::registerStatus($this->__('Done! Item deleted.')); return System::redirect($url); }
public function handleCommand(Zikula_Form_View $view, &$args) { if (!SecurityUtil::checkPermission('Content:page:', '::', ACCESS_ADD)) { throw new Zikula_Exception_Forbidden($this->__('Error! You have not been granted access to create pages.')); } if ($args['commandName'] == 'create') { $pageData = $this->view->getValues(); $validators = $this->notifyHooks(new Zikula_ValidationHook('content.ui_hooks.pages.validate_edit', new Zikula_Hook_ValidationProviders()))->getValidators(); if (!$validators->hasErrors() && $this->view->isValid()) { $id = ModUtil::apiFunc('Content', 'Page', 'newPage', array('page' => $pageData, 'pageId' => $this->pageId, 'location' => $this->location)); if ($id === false) { return false; } // notify any hooks they may now commit the as the original form has been committed. $objectUrl = new Zikula_ModUrl('Content', 'user', 'view', ZLanguage::getLanguageCode(), array('pid' => $this->pageId)); $this->notifyHooks(new Zikula_ProcessHook('content.ui_hooks.pages.process_edit', $this->pageId, $objectUrl)); } else { return false; } $url = ModUtil::url('Content', 'admin', 'editPage', array('pid' => $id)); } else { if ($args['commandName'] == 'cancel') { $id = null; $url = ModUtil::url('Content', 'admin', 'main'); } } return $this->view->redirect($url); }
public function handleCommand(Zikula_Form_View $view, &$args) { if ($args['commandName'] == 'save') { if (!$this->view->isValid()) { return false; } $data = $this->view->getValues(); if (!ModUtil::setVars('Content', $data['config'])) { return $this->view->setErrorMsg($this->__('Failed to set configuration variables')); } if ($data['config']['categoryUsage'] < 4) { // load the category registry util $mainCategory = CategoryRegistryUtil::getRegisteredModuleCategory('Content', 'content_page', $data['config']['categoryPropPrimary']); if (!$mainCategory) { return LogUtil::registerError($this->__('Main category property does not exist.')); } if ($data['config']['categoryUsage'] < 3) { $secondCategory = CategoryRegistryUtil::getRegisteredModuleCategory('Content', 'content_page', $data['config']['categoryPropSecondary']); if (!$secondCategory) { return LogUtil::registerError($this->__('Second category property does not exist.')); } } } LogUtil::registerStatus($this->__('Done! Saved module configuration.')); } else if ($args['commandName'] == 'cancel') { } $url = ModUtil::url('Content', 'admin', 'main'); return $this->view->redirect($url); }
/** * */ public function moduleSearch($args) { $dom = ZLanguage::getModuleDomain('MUBoard'); $searchsubmit = $this->request->getPost()->filter('searchsubmit', 'none', FILTER_SANITIZE_STRING); $searchoptions = $this->request->getPost()->filter('searchoptions', 'all', FILTER_SANITIZE_STRING); $searchplace = $this->request->getPost()->filter('searchplace', 'title', FILTER_SANITIZE_STRING); $resultorder = $this->request->getPost()->filter('resultorder', 'none', FILTER_SANITIZE_STRING); $kind = $this->request->query->filter('kind', 'none', FILTER_SANITIZE_STRING); // user has not entered a string and there is 'none' as kind of search if ($searchsubmit == 'none' && $kind == 'none') { // return search form template return $this->searchRedirect(); } else { if ($searchsubmit != 'none' && $kind == 'none') { $searchstring = $this->request->getPost()->filter('searchstring', '', FILTER_SANITIZE_STRING); if ($searchstring == '') { $url = ModUtil::url($this->name, 'search', 'modulesearch'); return LogUtil::registerError(__('You have to enter a string!', $dom), null, $url); } else { $args['searchstring'] = $searchstring; $args['searchoptions'] = $searchoptions; $args['searchplace'] = $searchplace; $args['resultorder'] = $resultorder; $args['kind'] = $kind; } } if ($searchsubmit == 'none' && $kind != 'none') { $args['kind'] = $kind; } } return ModUtil::apiFunc($this->name, 'search', 'moduleSearch', $args); }
/** * get available Admin panel links * * @return array Array of admin links */ public function getlinks() { $links = array(); if (SecurityUtil::checkPermission($this->name . '::', '::', ACCESS_READ)) { $links[] = array('url' => ModUtil::url($this->name, 'user', 'main'), 'text' => $this->__('Frontend'), 'title' => $this->__('Switch to user area.'), 'class' => 'z-icon-es-home'); } if (SecurityUtil::checkPermission($this->name . '::', '::', ACCESS_ADMIN)) { $links[] = array('url' => ModUtil::url($this->name, 'admin', 'view', array('ot' => 'category')), 'text' => $this->__('Categories'), 'title' => $this->__('Category list')); } if (SecurityUtil::checkPermission($this->name . '::', '::', ACCESS_ADMIN)) { $links[] = array('url' => ModUtil::url($this->name, 'admin', 'view', array('ot' => 'forum')), 'text' => $this->__('Forums'), 'title' => $this->__('Forum list')); } if (SecurityUtil::checkPermission($this->name . '::', '::', ACCESS_ADMIN)) { $links[] = array('url' => ModUtil::url($this->name, 'admin', 'view', array('ot' => 'posting')), 'text' => $this->__('Postings'), 'title' => $this->__('Posting list')); } if (SecurityUtil::checkPermission($this->name . '::', '::', ACCESS_ADMIN)) { $links[] = array('url' => ModUtil::url($this->name, 'admin', 'view', array('ot' => 'abo')), 'text' => $this->__('Abos'), 'title' => $this->__('Abo list')); } if (SecurityUtil::checkPermission($this->name . '::', '::', ACCESS_ADMIN)) { $links[] = array('url' => ModUtil::url($this->name, 'admin', 'view', array('ot' => 'user')), 'text' => $this->__('Users'), 'title' => $this->__('User list')); } if (SecurityUtil::checkPermission($this->name . '::', '::', ACCESS_ADMIN)) { $links[] = array('url' => ModUtil::url($this->name, 'admin', 'view', array('ot' => 'rank')), 'text' => $this->__('Ranks'), 'title' => $this->__('Rank list')); } if (SecurityUtil::checkPermission($this->name . '::', '::', ACCESS_ADMIN)) { $links[] = array('url' => ModUtil::url($this->name, 'admin', 'config'), 'text' => $this->__('Configuration'), 'title' => $this->__('Manage settings for this application')); } return $links; }
/** * Add a new admin category by ajax. * * @return AjaxUtil::output Output to the calling ajax request is returned. * response is a string the new cid on sucess. * url is a formatted url to the new category on success. */ public function addCategory() { $this->checkAjaxToken(); $this->throwForbiddenUnless(SecurityUtil::checkPermission('Admin::', '::', ACCESS_ADMIN)); //get form information $catName = trim($this->request->getPost()->get('catname')); //TODO make sure catName is set. //check if there exists a cat with this name. $cats = ModUtil::apiFunc('Admin', 'admin', 'getall'); foreach ($cats as $cat) { if (in_array($catName, $cat)) { throw new Zikula_Exception_Fatal($this->__('Error! A category by this name already exists.')); } } //create the category $result = ModUtil::apiFunc('Admin', 'admin', 'create', array('catname' => $catName, 'description' => '')); if (!$result) { throw new Zikula_Exception_Fatal($this->__('The category could not be created.')); } $output = array(); $output['response'] = $result; $url = ModUtil::url('Admin', 'admin', 'adminpanel', array('acid' => $result)); $output['url'] = $url; return new Zikula_Response_Ajax($output); }
/** * This method provides a generic item list overview. * * @param string $ot Treated object type. * @param string $sort Sorting field. * @param string $sortdir Sorting direction. * @param int $pos Current pager position. * @param int $num Amount of entries to display. * @param string $tpl Name of alternative template (for alternative display options, feeds and xml output) * @param boolean $raw Optional way to display a template instead of fetching it (needed for standalone output) * @return mixed Output. */ public function view($args) { $ot = $this->request->getGet()->filter('ot', 'category', FILTER_SANITIZE_STRING); $type = $this->request->getGet()->filter('type', 'user', FILTER_SANITIZE_STRING); $func = $this->request->getGet()->filter('func', 'view', FILTER_SANITIZE_STRING); if ($ot == 'category') { $sortdir = ModUtil::getVar('MUBoard', 'sortingCategories'); } if ($ot == 'posting') { $sortdir = ModUtil::getVar('MUBoard', 'sortingPostings'); } //view of postings is blocked if ($ot == 'posting') { return System::redirect(ModUtil::url($this->name, 'user', 'view')); } if (($ot == 'category' || $ot == 'forum') && $type == 'user') { $args['sort'] = 'pos'; if ($sortdir == 'descending') { $args['sortdir'] = 'desc'; } else { $args['sortdir'] = 'asc'; } } // get actual time $nowtime = DateUtil::getDatetime(); // set sessionvar with calling time SessionUtil::setVar('muboardonline', $nowtime); $lastlogin = SessionUtil::getVar('muboardonline'); $this->view->assign('func', $func)->assign('lastlogin', $lastlogin); $dom = ZLanguage::getModuleDomain($this->name); $sitename = ModUtil::getVar('ZConfig', 'sitename'); PageUtil::setVar('title', $sitename . ' - ' . __('Forum - Category Overview', $dom)); return parent::view($args); }
/** * Return an array of items to show in the your account panel * * @return array */ public function getall($args) { $items = array(); $uname = (isset($args['uname'])) ? $args['uname'] : UserUtil::getVar('uname'); // does this user exist? if(UserUtil::getIdFromName($uname)==false) { // user does not exist return $items; } // Create an array of links to return if (SecurityUtil::checkPermission('News::', '::', ACCESS_COMMENT)) { $items[] = array('url' => ModUtil::url('News', 'user', 'newitem'), 'module' => 'News', 'title' => $this->__('Submit an article'), 'icon' => 'news_add.gif'); /* If users can save draft articles and the viewdraft function is implemented, this can be enabled $items[] = array('url' => ModUtil::url('News', 'user', 'viewdraft'), 'module' => 'News', 'title' => __('View personal draft articles', $dom), 'icon' => 'news_draft.gif'); */ } // Return the items return $items; }
/** * Get available admin panel links. * * @return array array of admin links */ function getlinks() { $links = array(); if (SecurityUtil::checkPermission('Search::', '::', ACCESS_ADMIN)) { $links[] = array('url' => ModUtil::url('Search', 'admin', 'modifyconfig'), 'text' => $this->__('Settings'), 'class' => 'z-icon-es-config'); } return $links; }
public function getlinks($args) { $links = array(); if (SecurityUtil::checkPermission('IWtimeframes::', "::", ACCESS_ADMIN)) { $links[] = array('url' => ModUtil::url('IWtimeframes', 'admin', 'newItem', array('m' => 'n')), 'text' => $this->__('Add new timeFrame'), 'id' => 'iwtimeframes_newItem', 'class' => 'z-icon-es-new'); $links[] = array('url' => ModUtil::url('IWtimeframes', 'admin', 'main'), 'text' => $this->__('Show the timeFrames'), 'id' => 'iwtimeframes_main', 'class' => 'z-icon-es-view'); } return $links; }
public function getlinks($args) { if (SecurityUtil::checkPermission('Llicencies::', '::', ACCESS_ADMIN)) { $links[] = array('url' => ModUtil::url('Llicencies', 'admin', 'main', array()), 'text' => $this->__('Treballs'), 'class' => 'z-icon-es-view'); $links[] = array('url' => ModUtil::url('Llicencies', 'admin', 'getConfig', array()), 'text' => $this->__('Configuració'), 'class' => 'z-icon-es-config'); $links[] = array('url' => ModUtil::url('Llicencies', 'admin', 'ieTables', array()), 'text' => $this->__('Importa/Exporta'), 'class' => 'z-icon-es-import'); } return $links; }
public function getlinks() { $links = array(); $links[] = array('url' => ModUtil::url('Files', 'user', 'main'), 'text' => $this->__('Manage Files'), 'class' => 'z-icon-es-list'); $links[] = array('url' => ModUtil::url('Files', 'admin', 'main'), 'text' => $this->__('Module configuration'), 'class' => 'z-icon-es-config'); // return output return $links; }
/** * Create or edit record. * * @return string|boolean Output. */ public function edit() { if (!SecurityUtil::checkPermission('ExampleDoctrine::', '::', ACCESS_ADD)) { return LogUtil::registerPermissionError(ModUtil::url('ExampleDoctrine', 'user', 'main')); } $form = FormUtil::newForm('ExampleDoctrine', $this); return $form->execute('exampledoctrine_user_edit.tpl', new ExampleDoctrine_Handler_Edit()); }
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; }
/** * This method is the default function handling the user area called without defining arguments. * * * @return mixed Output. */ public function main() { // parameter specifying which type of objects we are treating $objectType = $this->request->query->filter('ot', 'collection', FILTER_SANITIZE_STRING); $permLevel = ACCESS_OVERVIEW; $this->throwForbiddenUnless(SecurityUtil::checkPermission($this->name . '::', '::', $permLevel), LogUtil::getErrorMsgPermission()); $redirectUrl = ModUtil::url($this->name, 'user', 'view', array('lct' => 'admin')); return $this->redirect($redirectUrl); }