/** * 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; }
public function install() { if (!SecurityUtil::checkPermission('IWdocmanager::', '::', ACCESS_ADMIN)) { return LogUtil::registerPermissionError(); } // Checks if module IWmain is installed. If not returns error if (!ModUtil::available('IWmain')) { return LogUtil::registerError(__('Module IWmain is required. You have to install the IWmain module previously to install it.')); } // Check if the version needed is correct $versionNeeded = '3.0.0'; if (!ModUtil::func('IWmain', 'admin', 'checkVersion', array('version' => $versionNeeded))) { return false; } if (!DBUtil::createTable('IWdocmanager')) return false; if (!DBUtil::createTable('IWdocmanager_categories')) return false; //Create indexes $table = DBUtil::getTables(); $c = $table['IWdocmanager_column']; DBUtil::createIndex($c['author'], 'IWdocmanager', 'author'); DBUtil::createIndex($c['categoryId'], 'IWdocmanager', 'categoryId'); //Create module vars $this->setVar('documentsFolder', 'documents') ->setVar('notifyMail', '') ->setVar('editTime', '45') ->setVar('deleteTime', '20'); return true; }
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; }
/** * 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); }
/** * Display block */ public function display($blockinfo) { if (!SecurityUtil::checkPermission('Zgoodies:marqueeblock:', "{$blockinfo['bid']}::", ACCESS_OVERVIEW)) { return; } if (!ModUtil::available('Zgoodies')) { return; } $vars = BlockUtil::varsFromContent($blockinfo['content']); $lang = ZLanguage::getLanguageCode(); // block title if (isset($vars['block_title'][$lang]) && !empty($vars['block_title'][$lang])) { $blockinfo['title'] = $vars['block_title'][$lang]; } // marquee content if (isset($vars['marquee_content'][$lang]) && !empty($vars['marquee_content'][$lang])) { $vars['marquee_content_lang'] = $vars['marquee_content'][$lang]; } if (!isset($vars['marquee_content'])) { $vars['marquee_content_lang'] = ''; } $this->view->assign('vars', $vars); $this->view->assign('bid', $blockinfo['bid']); $blockinfo['content'] = $this->view->fetch('blocks/' . $vars['block_template']); if (isset($vars['block_wrap']) && !$vars['block_wrap']) { if (empty($blockinfo['title'])) { return $blockinfo['content']; } else { return '<h4>' . DataUtil::formatForDisplayHTML($blockinfo['title']) . '</h4>' . "\n" . $blockinfo['content']; } } return BlockUtil::themeBlock($blockinfo); }
/** * 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; }
/** * @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]; }
/** * Display the block. * * @param array $blockinfo the blockinfo structure * * @return string output of the rendered block */ public function display($blockinfo) { // only show block content if the user has the required permissions if (!SecurityUtil::checkPermission('Reviews:ModerationBlock:', "{$blockinfo['title']}::", ACCESS_OVERVIEW)) { return false; } // check if the module is available at all if (!ModUtil::available('Reviews')) { return false; } if (!UserUtil::isLoggedIn()) { return false; } ModUtil::initOOModule('Reviews'); $this->view->setCaching(Zikula_View::CACHE_DISABLED); $template = $this->getDisplayTemplate($vars); $workflowHelper = new Reviews_Util_Workflow($this->serviceManager); $amounts = $workflowHelper->collectAmountOfModerationItems(); // assign block vars and fetched data $this->view->assign('moderationObjects', $amounts); // set a block title if (empty($blockinfo['title'])) { $blockinfo['title'] = $this->__('Moderation'); } $blockinfo['content'] = $this->view->fetch($template); // return the block to the theme return BlockUtil::themeBlock($blockinfo); }
/** * Content * * @copyright (C) 2007-2010, Content Development Team * @link http://github.com/zikula-modules/Content * @license See license.txt */ function smarty_function_contentcodeeditor($params, $view) { $dom = ZLanguage::getModuleDomain('Content'); $inputId = $params['inputId']; $inputType = isset($params['inputType']) ? $params['inputType'] : null; // Get reference to optional radio button that enables the editor (a hack for the HTML plugin). // It would have been easier just to read a $var in the template, but this won't work with a // Forms plugin - you would just get the initial value from when the page was loaded $htmlRadioButton = isset($params['htmlradioid']) ? $view->getPluginById($params['htmlradioid']) : null; $textRadioButton = isset($params['textradioid']) ? $view->getPluginById($params['textradioid']) : null; $html = ''; $useBBCode = $textRadioButton == null && $inputType == 'text' && !$view->isPostBack() || $textRadioButton != null && $textRadioButton->checked; if ($useBBCode && ModUtil::available('BBCode')) { $html = "<div class=\"z-formrow\"><em class=\"z-sub\">"; $html .= ModUtil::func('BBCode', 'User', 'bbcodes', array('textfieldid' => $inputId, 'images' => 0)); $html .= "</em></div>"; } else { if ($useBBCode && !ModUtil::available('BBCode')) { $html = "<div class=\"z-formrow\"><em class=\"z-sub\">"; $html .= '(' . __("Please install the BBCode module to enable BBCodes display.", $dom) . ')'; $html .= "</em></div>"; } } return $html; }
/** * 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; }
/** * display block */ public function display($blockinfo) { // Security check if (!SecurityUtil::checkPermission('Admin:adminnavblock', "$blockinfo[title]::$blockinfo[bid]", ACCESS_ADMIN)) { return; } // Get variables from content block $vars = BlockUtil::varsFromContent($blockinfo['content']); // Call the modules API to get the items if (!ModUtil::available('Admin')) { return; } $items = ModUtil::apiFunc('Admin', 'admin', 'getall'); // Check for no items returned if (empty($items)) { return; } // get admin capable modules $adminmodules = ModUtil::getAdminMods(); $adminmodulescount = count($adminmodules); // Display each item, permissions permitting $admincategories = array(); foreach ($items as $item) { if (SecurityUtil::checkPermission('Admin::', "$item[name]::$item[cid]", ACCESS_READ)) { $adminlinks = array(); foreach ($adminmodules as $adminmodule) { // Get all modules in the category $catid = ModUtil::apiFunc('Admin', 'admin', 'getmodcategory', array('mid' => ModUtil::getIdFromName($adminmodule['name']))); if (($catid == $item['cid']) || (($catid == false) && ($item['cid'] == $this->getVar('defaultcategory')))) { $modinfo = ModUtil::getInfoFromName($adminmodule['name']); $menutexturl = ModUtil::url($modinfo['name'], 'admin'); $menutexttitle = $modinfo['displayname']; $adminlinks[] = array('menutexturl' => $menutexturl, 'menutexttitle' => $menutexttitle); } } $admincategories[] = array('url' => ModUtil::url('Admin', 'admin', 'adminpanel', array('cid' => $item['cid'])), 'title' => DataUtil::formatForDisplay($item['name']), 'modules' => $adminlinks); } } $this->view->assign('admincategories', $admincategories); // Populate block info and pass to theme $blockinfo['content'] = $this->view->fetch('admin_block_adminnav.tpl'); return BlockUtil::themeBlock($blockinfo); }
function display() { if (ModUtil::available('BBCode') && $this->codeFilter == 'bbcode') { $code = '[code]' . $this->text . '[/code]'; PageUtil::addVar('stylesheet', 'modules/BBCode/style/style.css'); return ModUtil::apiFunc('BBCode', 'User', 'transform', array('message' => $code)); } else { return $this->transformCode($this->text, true); } }
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; }
/** * render plugin for fetching a particular module object * * Examples * {selectmodobject module="AutoCustomer" objecttype="customer" id=4 assign="myCustomer"} * {selectmodobject module="AutoCocktails" objecttype="recipe" id=12 assign="myRecipe"} * {selectmodobject recordClass="AutoCocktails_Model_Recipe" id=12 assign="myRecipe"} * * Parameters: * module Name of the module storing the desired object (in DBObject mode) * objecttype Name of object type (in DBObject mode) * recordClass Class name of an doctrine record. (in Doctrine mode) * id Identifier of desired object * prefix Optional prefix for class names (defaults to PN) (in DBObject mode) * assign Name of the returned object * * @param array $params All attributes passed to this function from the template. * @param Zikula_View $view Reference to the Zikula_View object. * * @return void */ function smarty_function_selectmodobject($params, Zikula_View $view) { if (isset($params['recordClass']) && !empty($params['recordClass'])) { $doctrineMode = true; } else { // DBObject checks if (!isset($params['module']) || empty($params['module'])) { $view->trigger_error(__f('Error! in %1$s: the %2$s parameter must be specified.', array('selectmodobject', 'module'))); } if (!isset($params['objecttype']) || empty($params['objecttype'])) { $view->trigger_error(__f('Error! in %1$s: the %2$s parameter must be specified.', array('selectmodobject', 'objecttype'))); } if (!isset($params['prefix'])) { $params['prefix'] = 'PN'; } $doctrineMode = false; } if (!isset($params['id']) || empty($params['id']) || !is_numeric($params['id'])) { $view->trigger_error(__f('Error! in %1$s: the %2$s parameter must be specified.', array('selectmodobject', 'id'))); } if (!isset($params['assign']) || empty($params['assign'])) { $view->trigger_error(__f('Error! in %1$s: the %2$s parameter must be specified.', array('selectmodobject', 'assign'))); } // load object depending on mode: doctrine or dbobject if (!$doctrineMode) { if (!ModUtil::available($params['module'])) { $view->trigger_error(__f('Invalid %1$s passed to %2$s.', array('module', 'selectmodobject'))); } ModUtil::dbInfoLoad($params['module']); $classname = "{$params['module']}_DBObject_" . StringUtil::camelize($params['objecttype']); if (!class_exists($classname) && System::isLegacyMode()) { // BC check for PNObject old style. // load the object class corresponding to $params['objecttype'] if (!($class = Loader::loadClassFromModule($params['module'], $params['objecttype'], false, false, $params['prefix']))) { z_exit(__f('Unable to load class [%s] for module [%s]', array(DataUtil::formatForDisplay($params['objecttype']), DataUtil::formatForDisplay($params['module'])))); } } // intantiate object model $object = new $class(); $idField = $object->getIDField(); // assign object data // this performs a new database select operation // while the result will be saved within the object, we assign it to a local variable for convenience $objectData = $object->get(intval($params['id']), $idField); if (!is_array($objectData) || !isset($objectData[$idField]) || !is_numeric($objectData[$idField])) { $view->trigger_error(__('Sorry! No such item found.')); } } else { $objectData = Doctrine_Core::getTable($params['recordClass'])->find($params['id']); if ($objectData === false) { $view->trigger_error(__('Sorry! No such item found.')); } } $view->assign($params['assign'], $objectData); }
/** * render plugin for fetching a particular module object * * Examples * {selectmodobject module="AutoCustomer" objecttype="customer" id=4 assign="myCustomer"} * {selectmodobject module="AutoCocktails" objecttype="recipe" id=12 assign="myRecipe"} * {selectmodobject recordClass="AutoCocktails_Model_Recipe" id=12 assign="myRecipe"} * * Parameters: * module Name of the module storing the desired object (in DBObject mode) * objecttype Name of object type (in DBObject mode) * recordClass Class name of an doctrine record. (in Doctrine mode) * id Identifier of desired object * prefix Optional prefix for class names (defaults to PN) (in DBObject mode) * assign Name of the returned object * * @param array $params All attributes passed to this function from the template. * @param Zikula_View $view Reference to the Zikula_View object. * * @return void */ function smarty_function_selectmodobject($params, Zikula_View $view) { if (isset($params['recordClass']) && !empty($params['recordClass'])) { $doctrineMode = true; } else { // DBObject checks if (!isset($params['module']) || empty($params['module'])) { $view->trigger_error(__f('Error! in %1$s: the %2$s parameter must be specified.', array('selectmodobject', 'module'))); } if (!isset($params['objecttype']) || empty($params['objecttype'])) { $view->trigger_error(__f('Error! in %1$s: the %2$s parameter must be specified.', array('selectmodobject', 'objecttype'))); } if (!isset($params['prefix'])) { $params['prefix'] = 'PN'; } $doctrineMode = false; } if (!isset($params['id']) || empty($params['id']) || !is_numeric($params['id'])) { $view->trigger_error(__f('Error! in %1$s: the %2$s parameter must be specified.', array('selectmodobject', 'id'))); } if (!isset($params['assign']) || empty($params['assign'])) { $view->trigger_error(__f('Error! in %1$s: the %2$s parameter must be specified.', array('selectmodobject', 'assign'))); } // load object depending on mode: doctrine or dbobject if (!$doctrineMode) { if (!ModUtil::available($params['module'])) { $view->trigger_error(__f('Invalid %1$s passed to %2$s.', array('module', 'selectmodobject'))); } ModUtil::dbInfoLoad($params['module']); $class = "{$params['module']}_DBObject_" . StringUtil::camelize($params['objecttype']); // intantiate object model $object = new $class(); $idField = $object->getIDField(); // assign object data // this performs a new database select operation // while the result will be saved within the object, we assign it to a local variable for convenience $objectData = $object->get(intval($params['id']), $idField); if (!is_array($objectData) || !isset($objectData[$idField]) || !is_numeric($objectData[$idField])) { $view->trigger_error(__('Sorry! No such item found.')); } } else { if ($params['recordClass'] instanceof \Doctrine_Record) { $objectData = Doctrine_Core::getTable($params['recordClass'])->find($params['id']); if ($objectData === false) { $view->trigger_error(__('Sorry! No such item found.')); } } else { /** @var $em Doctrine\ORM\EntityManager */ $em = \ServiceUtil::get('doctrine.entitymanager'); $result = $em->getRepository($params['recordClass'])->find($params['id']); $objectData = $result->toArray(); } } $view->assign($params['assign'], $objectData); }
/** * Show the month calendar into a bloc * * @param array $blockinfo The month and the year to show * * @return The calendar content */ public function display($blockinfo) { $mes = FormUtil::getPassedValue('mes', isset($args['mes']) ? $args['mes'] : 0, 'REQUEST'); $any = FormUtil::getPassedValue('any', isset($args['any']) ? $args['any'] : 0, 'REQUEST'); // Security check if (!SecurityUtil::checkPermission("IWagendas:calendarblock:", $blockinfo['title'] . "::", ACCESS_READ)) return; // Check if the module is available if (!ModUtil::available('IWagendas')) return; $user = (UserUtil::isLoggedIn()) ? UserUtil::getVar('uid') : '-1'; //get the calendar saved in the user vars. $sv = ModUtil::func('IWmain', 'user', 'genSecurityValue'); $exists = ModUtil::apiFunc('IWmain', 'user', 'userVarExists', array('name' => 'Calendar', 'module' => 'IWagendas', 'uid' => $user, 'sv' => $sv)); /* if ($exists) { $sv = ModUtil::func('IWmain', 'user', 'genSecurityValue'); $s = ModUtil::func('IWmain', 'user', 'userGetVar', array('uid' => $user, 'name' => 'calendar', 'module' => 'IWagendas', 'sv' => $sv, 'nult' => true)); $blockinfo['content'] = $s; return BlockUtil::themesideblock($blockinfo); } * */ $s = ModUtil::func('IWagendas', 'user', 'getCalendarContent', array('mes' => $mes, 'any' => $any)); //Copy the block information into user vars $sv = ModUtil::func('IWmain', 'user', 'genSecurityValue'); ModUtil::func('IWmain', 'user', 'userSetVar', array('uid' => $user, 'name' => 'calendar', 'module' => 'IWagendas', 'sv' => $sv, 'value' => $s, 'lifetime' => '700')); //Copy the block information into user vars $sv = ModUtil::func('IWmain', 'user', 'genSecurityValue'); ModUtil::func('IWmain', 'user', 'userSetVar', array('uid' => $user, 'name' => 'month', 'module' => 'IWagendas', 'sv' => $sv, 'value' => $mes)); // Populate block info and pass to theme $blockinfo['content'] = $s; return BlockUtil::themesideblock($blockinfo); }
/** * Show all the blocks in a position by name. * @todo at Core-2.0 remove all $legacy use and other checks. * @param string $positionName * @param bool|true $implode * @return array|string */ public function showBlockPosition($positionName, $implode = true) { if (!\ModUtil::available('ZikulaBlocksModule')) { // @TODO refactor to Core-2.0 return "Blocks not currently available."; } $blocks = $this->blockApi->getBlocksByPosition($positionName); foreach ($blocks as $key => $block) { $blocks[$key] = $this->showBlock($block, $positionName); } return $implode ? implode("\n", $blocks) : $blocks; }
/** * 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. if (!ModUtil::available('Profile')) { return false; } // Security check if (!SecurityUtil::checkPermission('Profile:MembersOnlineblock:', "$blockinfo[title]::", ACCESS_READ)) { return false; } // Get variables from content block $vars = BlockUtil::varsFromContent($blockinfo['content']); // Defaults if (empty($vars['lengthmax'])) { $vars['lengthmax'] = 30; } $uid = (int)UserUtil::getVar('uid'); $users = ModUtil::apiFunc('Profile', 'memberslist', 'getallonline'); $usersonline = array(); if ($users) { foreach ($users['unames'] as $user) { $usersonline[] = $user; } } $this->view->setCaching(false) ->setCacheId($uid); // check which messaging module is available and add the necessary info $msgmodule = ModUtil::apiFunc('Profile', 'memberslist', 'getmessagingmodule'); if (!empty($msgmodule) && UserUtil::isLoggedIn()) { $this->view->assign('messages', ModUtil::apiFunc($msgmodule, 'user', 'getmessagecount')); } $this->view->assign('msgmodule', $msgmodule); $this->view->assign('maxLength', $vars['lengthmax']); $this->view->assign('usersonline', $usersonline); $this->view->assign('membonline', $users['numusers']); $this->view->assign('anononline', $users['numguests']); $this->view->assign('uid', $uid); $blockinfo['content'] = $this->view->fetch('profile_block_membersonline.tpl'); return BlockUtil::themeBlock($blockinfo); }
/** * Returns custom plugin variables. * * @return array List of variables. */ public function getParameters() { $objectTypes = array(); if (ModUtil::available($this->modname) && ModUtil::loadApi($this->modname)) { $objectTypes['collection'] = array('name' => $this->__('Collections')); $objectTypes['movie'] = array('name' => $this->__('Movies')); } $active = $this->getPluginVar('ObjectTypes', array()); foreach ($objectTypes as $k => $v) { $objectTypes[$k]['nwactive'] = in_array($k, $active); } $args = $this->getPluginVar('Args', array()); return array('number' => 1, 'param' => array('ObjectTypes' => $objectTypes, 'Args' => $args)); }
/** * Helper method to handle the mailing for abos of postings and forums */ public static function aboMailing($args) { $id = $args['id']; $parent = $args['parent']; if ($parent == '') { $parent = 0; } $title = $args['title']; $text = $args['text']; if (ModUtil::available('BBCode')) { $text = ModUtil::apiFunc('BBCode', 'user', 'transform', array('message' => $text)); } if (ModUtil::available('BBSmile')) { $text = ModUtil::apiFunc('BBSmile', 'user', 'transform', array('text' => $text)); } // we get a repository for abos $repository = MUBoard_Util_Model::getAboRepository(); // we get a repository for forums $repository2 = MUBoard_Util_Model::getForumRepository(); // we get a repository for postings $repository3 = MUBoard_Util_Model::getPostingRepository(); // we get the just saved posting $savedPosting = $repository3->selectById($id); $createdUserId = $savedPosting->getCreatedUserId(); $forum = $savedPosting->getForum(); $forumid = $forum->getId(); // we get serviceManager and handler $serviceManager = ServiceUtil::getManager(); $handler = new Zikula_Form_View($serviceManager, 'MUBoard'); // We build the url for the email message $host = System::serverGetVar('HTTP_HOST') . '/'; // workaround because of bug in MOST or doctrine2 TODO if ($parent == 0) { $url = 'http://' . $host . ModUtil::url('MUBoard', 'user', 'display', array('ot' => 'posting', 'id' => $id)); } else { $url = 'http://' . $host . ModUtil::url('MUBoard', 'user', 'display', array('ot' => 'posting', 'id' => $parent)); } // We get the name of the site $from = ModUtil::getVar('ZConfig', 'sitename') . ' '; // We get the adminmail $fromaddress = ModUtil::getVar('ZConfig', 'adminmail'); $toaddress = self::getForumAbos($forumid, $createdUserId); foreach ($toaddress as $address) { if (filter_var($address, FILTER_VALIDATE_EMAIL)) { $messagecontent = self::getMailContent($from, $fromaddress, $address, $forum, $title, $text, $url, $kind, $parent); ModUtil::apiFunc('Mailer', 'user', 'sendmessage', $messagecontent); } } }
/** * 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) { $this->inlineUsage = UserUtil::getTheme() == 'Printer' ? true : false; $this->idPrefix = $this->request->getGet()->filter('idp', '', FILTER_SANITIZE_STRING); // initialise redirect goal $this->returnTo = $this->request->getGet()->filter('returnTo', null, FILTER_SANITIZE_STRING); // store current uri for repeated creations $this->repeatReturnUrl = System::getCurrentURI(); $this->permissionComponent = $this->name . ':' . $this->objectTypeCapital . ':'; $entityClass = $this->name . '_Entity_' . ucfirst($this->objectType); $objectTemp = new $entityClass(); $this->idFields = $objectTemp->get_idFields(); // retrieve identifier of the object we wish to view $this->idValues = MUBoard_Util_Controller::retrieveIdentifier($this->request, array(), $this->objectType, $this->idFields); $hasIdentifier = MUBoard_Util_Controller::isValidIdentifier($this->idValues); $entity = null; $this->mode = $hasIdentifier ? 'edit' : 'create'; if ($this->mode == 'edit') { if (!SecurityUtil::checkPermission($this->permissionComponent, '::', ACCESS_EDIT)) { // set an error message and return false return LogUtil::registerPermissionError(); } $entity = $this->initEntityForEdit(); if ($this->hasPageLockSupport === true && ModUtil::available('PageLock')) { // try to guarantee that only one person at a time can be editing this entity /* ModUtil::apiFunc('PageLock', 'user', 'pageLock', array('lockName' => $this->name . $this->objectTypeCapital . $this->createCompositeIdentifier(), 'returnUrl' => $this->getRedirectUrl(null, $entity))); */ } } else { if (!SecurityUtil::checkPermission($this->permissionComponent, '::', ACCESS_ADD)) { return LogUtil::registerPermissionError(); } $entity = $this->initEntityForCreation($entityClass); } $this->view->assign('mode', $this->mode)->assign('inlineUsage', $this->inlineUsage); // We set text field to empty if entity class is posting if ($this->request->query->filter('ot', 'category', FILTER_SANITIZE_STRING) == 'posting' && $this->request->query->filter('func', 'main', FILTER_SANITIZE_STRING) == 'display') { $entity['text'] = ''; } $entityData = $entity->toArray(); // assign data to template as array (makes translatable support easier) $this->view->assign($this->objectTypeLower, $entityData); // save entity reference for later reuse $this->entityRef = $entity; $this->initializeAdditions(); // everything okay, no initialization errors occured return true; }
/** * Smarty function build module header in user content page. * * {moduleheader} * * Available parameters: * modname Module name to display header for (optional, defaults to current module) * type Type for module links (defaults to 'user') * title Title to display in header (optional, defaults to module name) * titlelink Link to attach to title (optional, defaults to none) * setpagetitle If set to true, {pagesetvar} is used to set page title * insertstatusmsg If set to true, {insert name='getstatusmsg'} is put in front of template * menufirst If set to true, menu is first, then title * putimage If set to true, module image is also displayed next to title * * @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_moduleheader($params, $view) { if (!isset($params['modname']) || !ModUtil::available($params['modname'])) { $params['modname'] = ModUtil::getName(); } if (empty($params['modname'])) { return false; } $type = isset($params['type']) ? $params['type'] : 'user'; $assign = isset($params['assign']) ? $params['assign'] : null; $menufirst = isset($params['menufirst']) ? $params['menufirst'] : false; $putimage = isset($params['putimage']) ? $params['putimage'] : false; $setpagetitle = isset($params['setpagetitle']) ? $params['setpagetitle'] : false; $insertstatusmsg = isset($params['insertstatusmsg']) ? $params['insertstatusmsg'] : false; $cutlenght = isset($params['cutlenght']) ? $params['cutlenght'] : 20; if ($putimage) { $image = isset($params['image']) ? $params['image'] : ModUtil::getModuleImagePath($params['modname']); } else { $image = ''; } if (!isset($params['title'])) { $modinfo = ModUtil::getInfoFromName($params['modname']); if (isset($modinfo['displayname'])) { $params['title'] = $modinfo['displayname']; } else { $params['title'] = ModUtil::getName(); } } $titlelink = isset($params['titlelink']) ? $params['titlelink'] : false; $renderer = Zikula_View::getInstance('Theme'); $renderer->setCaching(Zikula_View::CACHE_DISABLED); $renderer->assign('userthemename', UserUtil::getTheme()); $renderer->assign('modname', $params['modname']); $renderer->assign('type', $params['type']); $renderer->assign('title', $params['title']); $renderer->assign('titlelink', $titlelink); $renderer->assign('truncated', mb_strlen($params['title']) > $cutlenght); $renderer->assign('titletruncated', mb_substr($params['title'], 0, $cutlenght) . '...'); $renderer->assign('setpagetitle', $setpagetitle); $renderer->assign('insertstatusmsg', $insertstatusmsg); $renderer->assign('menufirst', $menufirst); $renderer->assign('image', $image); if ($assign) { $view->assign($assign, $renderer->fetch('moduleheader.tpl')); } else { return $renderer->fetch('moduleheader.tpl'); } }
/** * Event handler. * * @param Zikula_Event $event Event. * * @return void */ public function handler(Zikula_Event $event) { // subject must be an instance of Theme class. $theme = $event->getSubject(); if (!$theme instanceof Theme) { return; } // register output filter to add MultiHook environment if requried if (ModUtil::available('MultiHook')) { $modinfo = ModUtil::getInfoFromName('MultiHook'); if (version_compare($modinfo['version'], '5.0', '>=') == 1) { $theme->load_filter('output', 'multihook'); ModUtil::apiFunc('MultiHook', 'theme', 'preparetheme'); } } }
/** * Zikula_View function to check for the availability of a module * * This function calls ModUtil::available to determine if a Zikula module is * is available. True is returned if the module is available, false otherwise. * The result can also be assigned to a template variable. * * Available parameters: * - modname: The well-known name of a module to execute a function from (required) * - assign: The name of a variable to which the results are assigned * * Examples * {modavailable modname="News"} * * {modavailable modname="foobar" assign="myfoo"} * {if $myfoo}.....{/if} * * @param array $params All attributes passed to this function from the template. * @param Zikula_View $view Reference to the Zikula_View object. * * @see function.ModUtil::available.php::smarty_function_modavailable() * * @return boolean True if the module is available; false otherwise. */ function smarty_function_modavailable($params, Zikula_View $view) { $assign = isset($params['assign']) ? $params['assign'] : null; $mod = isset($params['mod']) ? $params['mod'] : null; $modname = isset($params['modname']) ? $params['modname'] : null; // minor backwards compatability if ($mod) { $modname = $mod; } $result = ModUtil::available($modname); if ($assign) { $view->assign($assign, $result); } else { return $result; } }
function initialize(Zikula_Form_View $view) { $view->caching = false; $templates = array(); $rawtemplates = ModUtil::apiFunc('EZComments', 'user', 'gettemplates'); if (is_array($rawtemplates) && count($rawtemplates) != 0) { foreach ($rawtemplates as $rawtemplate) { $templates[] = array('text' => $rawtemplate, 'value' => $rawtemplate); } } $view->assign('templates', $templates); // is the akismet module available $view->assign('akismetavailable', ModUtil::available('Akismet')); $statuslevels = array(array('text' => $this->__('Approved'), 'value' => 0), array('text' => $this->__('Pending'), 'value' => 1), array('text' => $this->__('Rejected'), 'value' => 2)); $view->assign('statuslevels', $statuslevels); $feeds = array(array('text' => $this->__('Atom 0.3'), 'value' => 'atom'), array('text' => $this->__('RSS 2.0'), 'value' => 'rss')); $view->assign('feeds', $feeds); return true; }
/** * Zikula_View function to display some user links * * Example * {userlinks start="[" end="]" seperator="|"} * * Parameters: * start Start delimiter * end End delimiter * seperator Seperator * * @param array $params All attributes passed to this function from the template. * @param Zikula_View $view Reference to the Zikula_View object. * * @see function.userlinks.php::smarty_function_userlinks() * * @return string User links. */ function smarty_function_userlinks($params, Zikula_View $view) { $start = isset($params['start']) ? $params['start'] : '['; $end = isset($params['end']) ? $params['end'] : ']'; $seperator = isset($params['seperator']) ? $params['seperator'] : '|'; if (UserUtil::isLoggedIn()) { $links = "{$start} "; $profileModule = System::getVar('profilemodule', ''); if (!empty($profileModule) && ModUtil::available($profileModule)) { $links .= "<a href=\"" . DataUtil::formatForDisplay(ModUtil::url($profileModule, 'user', 'view')) . '">' . __('Your Account') . "</a> {$seperator} "; } else { $links .= "<a href=\"" . DataUtil::formatForDisplay(ModUtil::url('ZikulaUsersModule', 'user', 'index')) . '">' . __('Your Account') . "</a> {$seperator} "; } $links .= "<a href=\"" . DataUtil::formatForDisplay(ModUtil::url('ZikulaUsersModule', 'user', 'logout')) . '">' . __('Log out') . "</a> {$end}"; } else { $links = "{$start} <a href=\"" . DataUtil::formatForDisplay(ModUtil::url('ZikulaUsersModule', 'user', 'register')) . '">' . __('Register new account') . "</a> {$seperator} " . "<a href=\"" . DataUtil::formatForDisplay(ModUtil::url('ZikulaUsersModule', 'user', 'login')) . '">' . __('Login') . "</a> {$end}"; } return DataUtil::formatForDisplayHTML($links); }
/** * Do the migration * * With this function, the actual migration is done. * * @return boolean true on sucessful migration, false else */ function EZComments_migrateapi_pnComments() { if (!SecurityUtil::checkPermission('EZComments::', '::', ACCESS_ADMIN)) { return LogUtil::registerPermissionError(); } if (!ModUtil::available('pnComments')) { return LogUtil::RegisterError('pnComments not available'); } ModUtil::dbInfoLoad('pnComments'); $comments = DBUtil::SelectObjectArray('pncomments'); $counter = 0; foreach ($comments as $c) { $obj = array('modname' => $c['module'], 'objectid' => $c['objectid'], 'comment' => $c['text'], 'replyto' => -1, 'subject' => $c['subject'], 'uid' => $c['uid'], 'date' => $c['date'] . ' 00:00:00'); if (!DBUtil::insertObject($obj, 'EZComments')) { return LogUtil::registerError('error inserting comments in ezcomments table'); } $counter++; } return LogUtil::registerStatus("Migrated: {$counter} comments successfully."); }
/** * Zikula_View modifier to create a link to a users profile from the UID. * * Example * * Simple version, shows the username * {$uid|profilelinkbyuid} * Simple version, shows username, using class="classname" * {$uid|profilelinkbyuid:classname} * Using profile.gif instead of username, no class * {$uid|profilelinkbyuid:'':'images/profile.gif'} * * Using language depending image from pnimg. Note that we pass * the pnimg result array to the modifier as-is * {img src='profile.gif' assign=profile} * {$uid|profilelinkbyuid:'classname':$profile} * * @param string $uid The users uid. * @param string $class The class name for the link (optional). * @param mixed $image The image to show instead of the username (optional). * May be an array as created by pnimg. * @param integer $maxLength If set then user names are truncated to x chars. * * @return string The output. */ function smarty_modifier_profilelinkbyuid($uid, $class = '', $image = '', $maxLength = 0) { if (empty($uid) || (int) $uid < 1) { return $uid; } $uid = (double) $uid; $profileModule = System::getVar('profilemodule', ''); if ($uid && $uid > 1 && !empty($profileModule) && ModUtil::available($profileModule)) { $userDisplayName = ModUtil::apiFunc($profileModule, 'user', 'getUserDisplayName', array('uid' => $uid)); if (empty($userDisplayName)) { $userDisplayName = UserUtil::getVar('uname', $uid); } if (!empty($class)) { $class = ' class="' . DataUtil::formatForDisplay($class) . '"'; } if (!empty($image)) { $userDisplayName = DataUtil::formatForDisplay($userDisplayName); if (is_array($image)) { // if it is an array we assume that it is an pnimg array $show = '<img src="' . DataUtil::formatForDisplay($image['src']) . '" alt="' . DataUtil::formatForDisplay($image['alt']) . '" width="' . DataUtil::formatForDisplay($image['width']) . '" height="' . DataUtil::formatForDisplay($image['height']) . '" />'; } else { $show = '<img src="' . DataUtil::formatForDisplay($image) . '" alt="' . $userDisplayName . '" />'; } } elseif ($maxLength > 0) { // truncate the user name to $maxLength chars $length = strlen($userDisplayName); $truncEnd = $maxLength > $length ? $length : $maxLength; $show = DataUtil::formatForDisplay(substr($userDisplayName, 0, $truncEnd)); } else { $show = DataUtil::formatForDisplay($userDisplayName); } $profileLink = '<a' . $class . ' title="' . DataUtil::formatForDisplay(__('Profile')) . ': ' . $userDisplayName . '" href="' . DataUtil::formatForDisplay(ModUtil::url($profileModule, 'user', 'view', array('uid' => $uid), null, null, true)) . '">' . $show . '</a>'; } elseif (!empty($image)) { $profileLink = ''; // image for anonymous user should be "empty" } else { $uname = UserUtil::getVar('uname', $uid); $profileLink = DataUtil::formatForDisplay($uname); } return $profileLink; }
/** * Show the month calendar into a bloc * @autor: Albert Pérez Monfort * @autor: Toni Ginard Lladó * param: The month and the year to show * return: The calendar content */ public function display($blockinfo) { // Security check if (!SecurityUtil::checkPermission("IWusers:welcomeblock:", $blockinfo['title'] . "::", ACCESS_READ)) { return; } $baseURL = System::getBaseUrl(); $baseURL .= 'index.php'; if ('http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'] != $baseURL) { return; } // Check if the module is available if (!ModUtil::available('IWusers')) { return; } $user = (UserUtil::isLoggedIn()) ? UserUtil::getVar('uid') : '-1'; // Only for loggedin users if ($user == '-1') { return; } $sv = ModUtil::func('IWmain', 'user', 'genSecurityValue'); $userName = ModUtil::func('IWmain', 'user', 'getUserInfo', array('sv' => $sv, 'uid' => $user, 'info' => 'n')); $values = explode('---', $blockinfo['url']); $hello = (!empty($values[0])) ? $values[0] : $this->__('Hi'); $welcome = (!empty($values[0])) ? $values[1] : $this->__('welcome to the intranet'); $date = (isset($values[2])) ? $values[2] : ''; $s = $this->view->assign('userName', $userName) ->assign('hello', $hello) ->assign('welcome', $welcome) ->assign('date', $date) ->assign('dateText', date('d/m/Y', time())) ->assign('timeText', date('H.i', time())) ->fetch('IWusers_block_welcome.htm'); // Populate block info and pass to theme $blockinfo['content'] = $s; return BlockUtil::themesideblock($blockinfo); }
/** * Zikula_View modifier to create a link to a users profile * * Example * * Simple version, shows $username * {$username|userprofilelink} * Simple version, shows $username, using class="classname" * {$username|userprofilelink:classname} * Using profile.gif instead of username, no class * {$username|userprofilelink:'':'images/profile.gif'} * * Using language depending image from pnimg. Note that we pass * the pnimg result array to the modifier as-is * { pnimg src='profile.gif' assign=profile} * {$username|userprofilelink:'classname':$profile} * * @param string $string The users name. * @param string $class The class name for the link (optional). * @param mixed $image The image to show instead of the username (optional). * May be an array as created by pnimg. * @param integer $maxLength If set then user names are truncated to x chars. * * @return string The output. */ function smarty_modifier_userprofilelink($string, $class = '', $image = '', $maxLength = 0) { LogUtil::log(__f('Warning! Template modifier {$var|%1$s} is deprecated, please use {$var|%2$s} instead.', array('userprofilelink', 'profilelinkbyuname} {$var|profilelinkbyuid')), E_USER_DEPRECATED); // TODO - This does not handle cases where the uname is made up entirely of digits (e.g. $uname == "123456"). It will interpret it // as a uid. A new modifier is needed that acts on uids and only uids, and this modifier should act on unames and only unames. if (is_numeric($string)) { $uid = DataUtil::formatForStore($string); $uname = UserUtil::getVar('uname', $uid); } else { $uname = DataUtil::formatForStore($string); $uid = UserUtil::getIdFromName($uname); } $showUname = DataUtil::formatForDisplay($uname); $profileModule = System::getVar('profilemodule', ''); if (isset($uid) && $uid && isset($uname) && $uname && $uid > 1 && !empty($profileModule) && ModUtil::available($profileModule) && strtolower($uname) != strtolower(ModUtil::getVar(Users_Constant::MODNAME, Users_Constant::MODVAR_ANONYMOUS_DISPLAY_NAME))) { if (!empty($class)) { $class = ' class="' . DataUtil::formatForDisplay($class) . '"'; } if (!empty($image)) { if (is_array($image)) { // if it is an array we assume that it is an pnimg array $show = '<img src="' . DataUtil::formatForDisplay($image['src']) . '" alt="' . DataUtil::formatForDisplay($image['alt']) . '" width="' . DataUtil::formatForDisplay($image['width']) . '" height="' . DataUtil::formatForDisplay($image['height']) . '" />'; } else { $show = '<img src="' . DataUtil::formatForDisplay($image) . '" alt="' . $showUname . '" />'; } } elseif ($maxLength > 0) { // truncate the user name to $maxLength chars $showLength = strlen($showUname); $truncEnd = $maxLength > $showLength ? $showLength : $maxLength; $showUname = substr($string, 0, $truncEnd); } $profileLink = '<a' . $class . ' title="' . DataUtil::formatForDisplay(__('Personal information')) . ': ' . $showUname . '" href="' . DataUtil::formatForDisplay(ModUtil::url($profileModule, 'user', 'view', array('uid' => $uid), null, null, true)) . '">' . $showUname . '</a>'; } elseif (!empty($image)) { $profileLink = ''; //image for anonymous user should be "empty" } else { $profileLink = DataUtil::formatForDisplay($string); } return $profileLink; }