/** * Construct. * * @param int $objectId Object ID. * @param int $areaId A blockinfo structure. * @param string $module Module. * @param string $urlString Url. * @param Zikula_ModUrl $urlObject Url object. */ function __construct($objectId, $areaId, $module, $urlString = null, Zikula_ModUrl $urlObject = null) { parent::__construct($objectId, $areaId, $module, $urlString, $urlObject); $args = $urlObject->getArgs(); $ot = $args['ot']; if ($ot == 'posting') { $posting = ModUtil::apiFunc('MUBoard', 'selection', 'getEntity', array('ot' => 'posting', 'id' => $this->getObjectId())); // the Api checks for perms and there is nothing else to check if ($posting) { $userid = $posting->getCreatedUserId(); $date = $posting->getCreatedDate(); $title = $posting->getTitle(); $this->setObjectAuthor(UserUtil::getVar('uname', $userid)); $this->setObjectDate($date); $this->setObjectTitle($title); } } if ($ot == 'picture') { $picture = ModUtil::apiFunc('MUImage', 'selection', 'getEntity', array('ot' => 'picture', 'id' => $this->getObjectId())); // the Api checks for perms and there is nothing else to check if ($picture) { $userid = $picture->getCreatedUserId(); $date = $picture->getCreatedDate(); $title = $picture->getTitle(); $this->setObjectAuthor(UserUtil::getVar('uname', $userid)); $this->setObjectDate($date); $this->setObjectTitle($title); } } }
/** * 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; } }
/** * 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'); }
/** * Zikula_View function to display a drop down list of module stylesheets. * * Available parameters: * - modname The module name to show the styles for * - assign: If set, the results are assigned to the corresponding variable instead of printed out * - id: ID for the control * - name: Name for the control * - exclude Comma seperated list of files to exclude (optional) * - selected: Selected value * * @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 value of the last status message posted, or void if no status message exists. */ function smarty_function_html_select_modulestylesheets($params, Zikula_View $view) { if (!isset($params['modname'])) { $view->trigger_error(__f('Error! in %1$s: the %2$s parameter must be specified.', array('html_select_modulestylesheets', 'modname'))); return false; } if (isset($params['exclude'])) { $exclude = explode(',', trim($params['exclude'])); unset($params['exclude']); } else { $exclude = array(); } $params['values'] = ModUtil::apiFunc('ZikulaAdminModule', 'admin', 'getmodstyles', array('modname' => $params['modname'], 'exclude' => $exclude)); unset($params['modname']); $params['output'] = $params['values']; $assign = isset($params['assign']) ? $params['assign'] : null; unset($params['assign']); require_once $view->_get_plugin_filepath('function', 'html_options'); $output = smarty_function_html_options($params, $view); if (!empty($assign)) { $view->assign($assign, $output); } else { return $output; } }
/** * 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; }
/** * Zikula_View function to to execute a module API function * * This function calls a calls a specific module API function. It returns whatever the return * value of the resultant function is if it succeeds. * Note that in contrast to the API function ModUtil::apiFunc you need not to load the * module API with ModUtil::loadApi. * * * Available parameters: * - modname: The well-known name of a module to execute a function from (required) * - type: The type of function to execute; currently one of 'user' or 'admin' (default is 'user') * - func: The name of the module function to execute (default is 'main') * - assign: The name of a variable to which the results are assigned * - all remaining parameters are passed to the module API function * * Examples * {modapifunc modname='News' type='user' func='get' sid='3'} * * {modapifunc modname='foobar' type='user' func='getfoo' id='1' assign='myfoo'} * {$myfoo.title} * * @param array $params All attributes passed to this function from the template. * @param Zikula_View $view Reference to the Zikula_View object. * * @see function.modfunc.php::smarty_function_modfunc() * * @return string The results of the module API function. */ function smarty_function_modapifunc($params, Zikula_View $view) { $assign = isset($params['assign']) ? $params['assign'] : null; $func = isset($params['func']) && $params['func'] ? $params['func'] : 'main'; $modname = isset($params['modname']) ? $params['modname'] : null; $type = isset($params['type']) && $params['type'] ? $params['type'] : 'user'; // avoid passing these to ModUtil::apiFunc unset($params['modname']); unset($params['type']); unset($params['func']); unset($params['assign']); if (!$modname) { $view->trigger_error(__f('Error! in %1$s: the %2$s parameter must be specified.', array('modapifunc', 'modname'))); return false; } if (isset($params['modnamefunc'])) { $params['modname'] = $params['modnamefunc']; unset($params['modnamefunc']); } $result = ModUtil::apiFunc($modname, $type, $func, $params); if ($assign) { $view->assign($assign, $result); } else { return $result; } }
/** * Display the block. * * @param array $blockinfo A blockinfo structure. * * @return string The rendered block. */ public function display($blockinfo) { // Check if the Profile module is available or saving of login dates are disabled if (!ModUtil::available('Profile')) { return false; } // Security check if (!SecurityUtil::checkPermission('Profile:LastSeenblock:', "$blockinfo[title]::", ACCESS_READ)) { return false; } // Get variables from content block $vars = BlockUtil::varsFromContent($blockinfo['content']); $this->view->setCaching(false); // get last x logged in user id's $users = ModUtil::apiFunc('Profile', 'memberslist', 'getall', array( 'sortby' => 'lastlogin', 'numitems' => $vars['amount'], 'sortorder' => 'DESC', )); $this->view->assign('users', $users); $blockinfo['content'] = $this->view->fetch('profile_block_lastseen.tpl'); return BlockUtil::themeBlock($blockinfo); }
/** * Event listener for 'core.postinit' event. * * @param Zikula_Event $event * * @return void */ public static function coreinit(Zikula_Event $event) { // get the module name $args = array(); $args['modulename'] = ModUtil::getName(); $module = $args['modulename']; // exit if Content module active - to avoid double loadings if user has given ids and functions if ($args['modulename'] == 'content') { return; } // Security check if user has COMMENT permission for scribite if (!SecurityUtil::checkPermission('Scribite::', "{$module}::", ACCESS_COMMENT)) { return; } // get passed func $func = FormUtil::getPassedValue('func', isset($args['func']) ? $args['func'] : null, 'GET'); // get config for current module $modconfig = array(); $modconfig = ModUtil::apiFunc('Scribite', 'user', 'getModuleConfig', array('modulename' => $args['modulename'])); // return if module is not supported or editor is not set if (!$modconfig['mid'] || $modconfig['modeditor'] == '-') { return; } // check if current func is fine for editors or funcs is empty (or all funcs) if (is_array($modconfig['modfuncs']) && (in_array($func, $modconfig['modfuncs']) || $modconfig['modfuncs'][0] == 'all')) { $args['areas'] = $modconfig['modareas']; $args['editor'] = $modconfig['modeditor']; $scribite = ModUtil::apiFunc('Scribite', 'user', 'loader', array('modulename' => $args['modulename'], 'editor' => $args['editor'], 'areas' => $args['areas'])); // add the scripts to page header if ($scribite) { PageUtil::AddVar('header', $scribite); } } }
/** * */ 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); }
function display() { $prevpage = null; $nextpage = null; $page = ModUtil::apiFunc('Content', 'Page', 'getPage', array('id' => $this->pageId)); $tables = DBUtil::getTables(); $pageTable = $tables['content_page']; $pageColumn = $tables['content_page_column']; $options = array('makeTree' => true); $options['orderBy'] = 'position'; $options['orderDir'] = 'desc'; $options['pageSize'] = 1; $options['filter']['superParentId'] = $page['parentPageId']; if ($page['position'] > 0) { $options['filter']['where'] = "{$pageColumn['level']} = {$page['level']} and {$pageColumn['position']} < {$page['position']}"; $pages = ModUtil::apiFunc('Content', 'Page', 'getPages', $options); if (count($pages) > 0) { $prevpage = $pages[0]; } } if (isset($page['position']) && $page['position'] >= 0) { $options['orderDir'] = 'asc'; $options['filter']['where'] = "{$pageColumn['level']} = {$page['level']} and {$pageColumn['position']} > {$page['position']}"; $pages = ModUtil::apiFunc('Content', 'Page', 'getPages', $options); if (count($pages) > 0) { $nextpage = $pages[0]; } } $this->view->assign('loggedin', UserUtil::isLoggedIn()); $this->view->assign('prevpage', $prevpage); $this->view->assign('nextpage', $nextpage); return $this->view->fetch($this->getTemplate()); }
/** * Display block. * * @param array $blockInfo A blockinfo structure. * * @return string The rendered block. */ public function display($blockInfo) { $renderedOutput = ''; if (SecurityUtil::checkPermission('Accountlinks::', $blockInfo['title']."::", ACCESS_READ)) { // Get variables from content block $vars = BlockUtil::varsFromContent($blockInfo['content']); // Call the modules API to get the items if (ModUtil::available($this->name)) { $accountlinks = ModUtil::apiFunc($this->name, 'user', 'accountLinks'); // Check for no items returned if (!empty($accountlinks)) { $this->view->setCaching(Zikula_View::CACHE_DISABLED) ->assign('accountlinks', $accountlinks); // Populate block info and pass to theme $blockInfo['content'] = $this->view->fetch('users_block_accountlinks.tpl'); $renderedOutput = BlockUtil::themeBlock($blockInfo); } } } return $renderedOutput; }
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; }
public function getContent($args) { switch ($args['pluginid']) { case 1: //$uid = $args['uid']; // Get matching news stories published since last newsletter // No selection on categories made !! $items = ModUtil::apiFunc('News', 'user', 'getall', array('numitems' => $this->getVar('itemsperpage'), 'status' => 0, 'from' => DateUtil::getDatetime($args['last']), 'filterbydate' => true)); if ($items != false) { if ($args['contenttype'] == 't') { $counter = 0; $output.="\n"; foreach ($items as $item) { $counter++; $output .= $counter . '. ' . $item['title'] . " (" . $this->__f('by %1$s on %2$s', array($item['contributor'], DateUtil::formatDatetime($item['from'], 'datebrief'))) . ")\n"; } } else { $render = Zikula_View::getInstance('News'); $render->assign('readperm', SecurityUtil::checkPermission('News::', "::", ACCESS_READ)); $render->assign('articles', $items); $output = $render->fetch('mailz/listarticles.tpl'); } } else { $output = $this->__f('No News publisher articles since last newsletter on %s.', DateUtil::formatDatetime($args['last'], 'datebrief')) . "\n"; } return $output; } return ''; }
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 search(){ // Check permission $this->throwForbiddenUnless(SecurityUtil::checkPermission('Llicencies::', '::', ACCESS_READ)); //path to zk jquery lib $js = new JCSSUtil; $scripts = $js->scriptsMap(); $jquery = $scripts['jquery']['path']; // Omplim les llistes desplegables del fromulari $cursos = ModUtil::apiFunc('Llicencies', 'user', 'getYears'); $temes = ModUtil::apiFunc('Llicencies', 'user', 'getTopicList'); $subtemes = ModUtil::apiFunc('Llicencies', 'user', 'getSubtopicList'); $tipus = ModUtil::apiFunc('Llicencies', 'user', 'getTypeList'); $view = Zikula_View::getInstance($this->name); $view->assign('jquery' , $jquery); $view->assign('cursos' , $cursos); $view->assign('temes' , $temes); $view->assign('subtemes', $subtemes); $view->assign('tipus' , $tipus); $view->assign('admin' , false); // Carreagr el formulari per a fer la cerca de llicències d'estudi return $this->view->display('Llicencies_main.tpl'); }
public function display($blockinfo) { // Security check (1) if (!SecurityUtil::checkPermission('IWmenu:topblock:', "$blockinfo[title]::", ACCESS_READ)) { return false; } // Check if the module is available. (2) if (!ModUtil::available('IWmenu')) { return false; } // Get variables from content block (3) //Get cached user menu $uid = is_null(UserUtil::getVar('uid')) ? '-1' : UserUtil::getVar('uid'); //Generate menu $menu_estructure = ModUtil::apiFunc('IWmenu', 'user', 'getMenuStructure'); // Defaults (4) if (empty($menu_estructure)) { return false; } // Create output object (6) $view = Zikula_View::getInstance('IWmenu'); // assign your data to to the template (7) $view->assign('menu', $menu_estructure); // Populate block info and pass to theme (8) $menu = $view->fetch('IWmenu_block_top.htm'); //$blockinfo['content'] = $menu; //return BlockUtil::themesideblock($blockinfo); return $menu; }
public function handleCommand(Zikula_Form_View $view, &$args) { if ($args['commandName'] == 'create') { if (!$this->view->isValid()) { return false; } $contentData = $this->view->getValues(); list($module, $type) = explode(':', $contentData['contentType']); $contentData['module'] = $module; $contentData['type'] = $type; unset($contentData['contentType']); $contentData['language'] = null; /** * It should be noted here that the content item is created with default data * immediately and then sent to the editcontent function for processing. * If the user the clicks 'cancel' the contentitem is left in existence and * not deleted which seems counter-intuitive. */ $id = ModUtil::apiFunc('Content', 'Content', 'newContent', array('content' => $contentData, 'pageId' => $this->pageId, 'contentAreaIndex' => $this->contentAreaIndex, 'position' => $this->position)); if ($id === false) { return $this->view->registerError(null); } $url = ModUtil::url('Content', 'admin', 'editcontent', array('cid' => $id)); } else { if ($args['commandName'] == 'cancel') { $id = null; $url = ModUtil::url('Content', 'admin', 'editpage', array('pid' => $this->pageId)); } } return $this->view->redirect($url); }
/** * Section to show the latest articles of a user. * * Parameters passed in the $args array: * ------------------------------------- * numeric uid The user account id of the user for whom to return comments. * numeric numitems Number of comments to show. * * @param array $args All parameters passed to this function. * * @return array An array of articles. */ function Profile_sectionapi_news($args) { // validates an the uid parameter if (!isset($args['uid']) || empty($args['uid'])) { return false; } // assures the number of items to retrieve if (!isset($args['numitems']) || empty($args['numitems'])) { $args['numitems'] = 5; } // only published articles $args['status'] = 0; // exclude future articles $args['filterbydate'] = true; // removes unallowed parameters if (isset($args['from'])) unset($args['from']); if (isset($args['to'])) unset($args['to']); if (isset($args['query'])) unset($args['query']); return ModUtil::apiFunc('News', 'user', 'getall', $args); }
/** * display items for a day * * @param $args array Arguments array. * * @return string html string */ public function display($args) { $eid = FormUtil::getPassedValue('eid', isset($args['eid']) ? $args['eid'] : null, 'REQUEST'); $objectid = FormUtil::getPassedValue('objectid', isset($args['objectid']) ? $args['objectid'] : null, 'REQUEST'); if (!empty($objectid)) { $eid = $objectid; } if (!isset($args['eid']) and !empty($eid)) { $args['eid'] = $eid; } // Chek permissions $this->throwForbiddenUnless(SecurityUtil::checkPermission('Ephemerides::', '::', ACCESS_READ), LogUtil::getErrorMsgPermission()); // check if the contents are cached. $template = 'ephemerides_user_display.tpl'; if ($this->view->is_cached($template)) { return $this->view->fetch($template); } // get items if (isset($args['eid']) and $args['eid'] > 0) { $items = ModUtil::apiFunc($this->name, 'user', 'getall', $args); } else { $items = ModUtil::apiFunc($this->name, 'user', 'gettoday', $args); } $this->view->assign('items', $items); return $this->view->fetch($template); }
/** * Smarty function to display the category menu for admin links. This also adds the * navtabs.css to the page vars array for stylesheets. * * Admin * {admincategorymenu} * * @see function.admincategorymenu.php::smarty_function_admincategoreymenu() * @param array $params All attributes passed to this function from the template * @param object $view Reference to the Zikula_View object * @return string the results of the module function */ function smarty_function_admincategorymenu($params, $view) { PageUtil::addVar('stylesheet', ThemeUtil::getModuleStylesheet('Admin')); $modinfo = ModUtil::getInfoFromName($view->getTplVar('toplevelmodule')); $acid = ModUtil::apiFunc('AdminModule', 'admin', 'getmodcategory', array('mid' => $modinfo['id'])); return ModUtil::func('AdminModule', 'admin', 'categorymenu', array('acid' => $acid)); }
/** * Toggleblock. * * This function toggles active/inactive. * * @param bid int id of block to toggle. * * @return mixed true or Ajax error */ public function toggleblock() { $this->checkAjaxToken(); $this->throwForbiddenUnless(SecurityUtil::checkPermission('Blocks::', '::', ACCESS_ADMIN)); $bid = $this->request->request->get('bid', -1); if ($bid == -1) { throw new Zikula_Exception_Fatal($this->__('No block ID passed.')); } // read the block information $blockinfo = BlockUtil::getBlockInfo($bid); if ($blockinfo == false) { throw new Zikula_Exception_Fatal($this->__f('Error! Could not retrieve block information for block ID %s.', DataUtil::formatForDisplay($bid))); } if ($blockinfo['active'] == 1) { ModUtil::apiFunc('Blocks', 'admin', 'deactivate', array('bid' => $bid)); } else { ModUtil::apiFunc('Blocks', 'admin', 'activate', array('bid' => $bid)); } return new Zikula_Response_Ajax(array('bid' => $bid)); }
/** * This function sets active/inactive status. * * @param eid * * @return mixed true or Ajax error */ public function setstatus() { $this->checkAjaxToken(); $this->throwForbiddenUnless(SecurityUtil::checkPermission('Ephemerides::', '::', ACCESS_ADMIN)); $eid = $this->request->request->get('eid', 0); $status = $this->request->request->get('status', 0); $alert = ''; if ($eid == 0) { $alert .= $this->__('No ID passed.'); } else { $item = array('eid' => $eid, 'status' => $status); $res = DBUtil::updateObject($item, 'ephem', '', 'eid'); if (!$res) { $alert .= $item['eid'] . ', ' . $this->__f('Could not change item, ID %s.', DataUtil::formatForDisplay($eid)); if ($item['status']) { $item['status'] = 0; } else { $item['status'] = 1; } } } // get current status to return $item = ModUtil::apiFunc($this->name, 'user', 'get', array('eid' => $eid)); if (!$item) { $alert .= $this->__f('Could not get data, ID %s.', DataUtil::formatForDisplay($eid)); } return new Zikula_Response_Ajax(array('eid' => $eid, 'status' => $item['status'], 'alert' => $alert)); }
function smarty_function_contentpagepath($params, $view) { if (!isset($params['pageId'])) { return $smarty->trigger_error('contentpagepath: pageId parameter required'); } $pageId = (int) $params['pageId']; $language = isset($params['language']) ? $params['language'] : null; $path = ModUtil::apiFunc('Content', 'Page', 'getPagePath', array('pageId' => $params['pageId'])); if ($path === false) { return $smarty->trigger_error(LogUtil::getErrorMessagesText()); } $result = "<span class=\"content-path\">"; $first = true; foreach ($path as $page) { $result .= ($first ? '' : ' / ') . $page['title']; $first = false; } $result .= " [{$pageId}]"; $info = ''; if (!empty($language)) { $info .= $language; } if (!empty($info)) { $result .= " ({$info})"; } $result .= " </span>"; if (array_key_exists('assign', $params)) { $view->assign($params['assign'], $result); } else { return $result; } }
/** * 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; } }
/** * Handle module install event "installer.module.installed". * Receives $modinfo as $args * * @param Zikula_Event $event * * @return void */ public static function moduleInstall(Zikula_Event $event) { $mod = $event['name']; // determine search capability if (ModUtil::apiFunc($mod, 'search', 'info')) { // get all search blocks $blocks = BlockUtil::getBlocksInfo(); foreach ($blocks as $block) { $block = $block->toArray(); if ($block['bkey'] != 'Search') { continue; } $content = BlockUtil::varsFromContent($block['content']); if (!isset($content['active'])) { $content['active'] = array(); } $content['active'][$mod] = 1; $block['content'] = BlockUtil::varsToContent($content); ModUtil::apiFunc('Blocks', 'admin', 'update', $block); } } }
/** * Zikula_View function to display admin links for a module. * * Example: * {moduleadminlinks modname=Example start="[" end="]" seperator="|" class="z-menuitem-title"} * * Available parameters: * - modname Module name to display links for. * - start Start string (optional). * - end End string (optional). * - seperator Link seperator (optional). * - class CSS class (optional). * * @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 navigation for the module admin panel. */ function smarty_function_moduleadminlinks($params, $view) { LogUtil::log(__f('Warning! Template plugin {%1$s} is deprecated, please use {%2$s} instead.', array('moduleadminlinks', 'modulelinks')), E_USER_DEPRECATED); // set some defaults $start = isset($params['start']) ? $params['start'] : '['; $end = isset($params['end']) ? $params['end'] : ']'; $seperator = isset($params['seperator'])? $params['seperator']: '|'; $class = isset($params['class']) ? $params['class'] : 'z-menuitem-title'; $modname = $params['modname']; unset ($params['modname']); if (!isset($modname) || !ModUtil::available($modname)) { $modname = ModUtil::getName(); } // check our module name if (!ModUtil::available($modname)) { $view->trigger_error('moduleadminlinks: '.__f("Error! The '%s' module is not available.", DataUtil::formatForDisplay($modname))); return false; } // get the links from the module API $links = ModUtil::apiFunc($modname, 'admin', 'getlinks', $params); // establish some useful count vars $linkcount = count($links); $adminlinks = "<span class=\"$class\">$start "; foreach ($links as $key => $link) { $id = ''; if (isset($link['id'])) { $id = 'id="' . $link['id'] . '"'; } if (!isset($link['title'])) { $link['title'] = $link['text']; } if (isset($link['disabled']) && $link['disabled'] == true) { $adminlinks .= "<span $id>" . '<a class="z-disabledadminlink" title="' . DataUtil::formatForDisplay($link['title']) . '">' . DataUtil::formatForDisplay($link['text']) . '</a> '; } else { $adminlinks .= "<span $id><a href=\"" . DataUtil::formatForDisplay($link['url']) . '" title="' . DataUtil::formatForDisplay($link['title']) . '">' . DataUtil::formatForDisplay($link['text']) . '</a> '; } if ($key == $linkcount-1) { $adminlinks .= '</span>'; continue; } // linebreak if (isset($link['linebreak']) && $link['linebreak'] == true) { $adminlinks .= "</span>\n "; $adminlinks .= "$end</span><br /><span class=\"$class\">$start "; } else { $adminlinks .= "$seperator</span>\n "; } } $adminlinks .= "$end</span>\n"; return $adminlinks; }
public function onKernelRequestSessionExpire(GetResponseEvent $event) { if (\SessionUtil::hasExpired()) { // Session has expired, display warning $response = new Response(\ModUtil::apiFunc('ZikulaUsersModule', 'user', 'expiredsession'), 403); $this->setResponse($event, $response); } }
public static function contentMainEditGetPagesList($belowPageId = null) { $filter = array('checkActive' => false); if ($belowPageId != null) { $filter['superParentId'] = $belowPageId; } return ModUtil::apiFunc('Content', 'Page', 'getPages', array('editing' => true, 'filter' => $filter, 'translate' => false)); }
/** * Gets qv summary information * * @author: Sara Arjona Téllez (sarjona@xtec.cat) */ function IWqv_qvsummaryblock_display($row) { // Security check if (!SecurityUtil::checkPermission('IWqv:summaryBlock:', $row['title'] . "::", ACCESS_READ) || !UserUtil::isLoggedIn()) { return false; } $uid = UserUtil::getVar('uid'); if (!isset($uid)) $uid = '-1'; // Get the qvsummary saved in the user vars. It is renovate every 10 minutes $sv = ModUtil::func('IWmain', 'user', 'genSecurityValue'); $exists = ModUtil::apiFunc('IWmain', 'user', 'userVarExists', array('name' => 'qvsummary', 'module' => 'IWqv', 'uid' => $uid, 'sv' => $sv)); if ($exists) { $sv = ModUtil::func('IWmain', 'user', 'genSecurityValue'); $s = ModUtil::func('IWmain', 'user', 'userGetVar', array('uid' => $uid, 'name' => 'qvsummary', 'module' => 'IWqv', 'sv' => $sv, 'nult' => true)); } else { $teacherassignments = ModUtil::apiFunc('IWqv', 'user', 'getall', array("teacher" => $uid)); $studentassignments = ModUtil::apiFunc('IWqv', 'user', 'getall', array("student" => $uid)); if (empty($teacherassignments) && empty($studentassignments)) { } $view = Zikula_View::getInstance('IWqv', false); $view->assign('teacherassignments', $teacherassignments); $view->assign('studentassignments', $studentassignments); $view->assign('isblock', true); $s = $view->fetch('IWqv_block_summary.htm'); if (empty($teacherassignments) && empty($studentassignments)) { $s = ''; } //Copy the block information into user vars $sv = ModUtil::func('IWmain', 'user', 'genSecurityValue'); ModUtil::func('IWmain', 'user', 'userSetVar', array('uid' => $uid, 'name' => 'qvsummary', 'module' => 'IWqv', 'sv' => $sv, 'value' => $s, 'lifetime' => '2000')); } if ($s == '') { return false; } $row['content'] = $s; return BlockUtil::themesideblock($row); }
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'); }