/** * Register error message. * * Causes a error message to be stored in the session and displayed next pageload. * * @param string $message Message. * @param integer $type Type. * @param mixed $debug Debug. * * @throws Zikula_Exception If no message is set. * * @return object This object. */ protected function registerError($message, $type=null, $debug=null) { if (!isset($message) || empty($message)) { throw new Zikula_Exception($this->__f('Empty [%s] received.', 'message')); } LogUtil::addErrorPopup($message); return $this; }
/** * Process errors. * * @return void */ private function processErrors() { if (count($this->errors) == 0) { return; } // fatal errors require 404 header('HTTP/1.1 404 Not Found'); foreach ($this->errors as $error) { LogUtil::addErrorPopup($error); } }
/** * Zikula_View plugin. * * Author: Peter Dudas <duda at bigfish dot hu> * * Examples: * code: * {pagerabc posvar='letter' class='abcpager' class_num='abclink' class_numon='abclink_on' separator=' - ' names='A,B;C,D;E,F;G,H;I,J;K,L;M,N,O;P,Q,R;S,T;U,V,W,X,Y,Z'} * * result * <span class="abcpager"> * <a class="abclink_on" href="index.php?module=Example&letter=A,B"> A,B</a> * - <a class="abclink" href="index.php?module=Example&letter=C,D"> C,D</a> * - <a class="abclink" href="index.php?module=Example&letter=E,F"> E,F</a> * - <a class="abclink" href="index.php?module=Example&letter=G,H"> G,H</a> * - <a class="abclink" href="index.php?module=Example&letter=I,J"> I,J</a> * - <a class="abclink" href="index.php?module=Example&letter=K,L"> K,L</a> * - <a class="abclink" href="index.php?module=Example&letter=M,N,O"> M,N,O</a> * - <a class="abclink" href="index.php?module=Example&letter=P,Q,R"> P,Q,R</a> * - <a class="abclink" href="index.php?module=Example&letter=S,T"> S,T</a> * - <a class="abclink" href="index.php?module=Example&letter=U,V,W,X,Y,Z"> U,V,W,X,Y,Z</a> * </span> * * * Parameters: * posvar Name of the variable that contains the position data, eg "letter" * forwardvars Comma- semicolon- or space-delimited list of POST and GET variables to forward in the pager links. If unset, all vars are forwarded. * additionalvars Comma- semicolon- or space-delimited list of additional variable and value pairs to forward in the links. eg "foo=2,bar=4" * route Name of a fixed route to use (optional, replaces modname / type / func) * modname Fixed name of the module to page (optional) * type Fixed value of the type url parameter (optional) * func Fixed value of the function url parameter (optional) * class Class for the pager * class_num Class for the pager links (<a> tags) * class_numon Class for the active page * printempty Print empty sel ('-') * lang Language * names String or array of names to select from (array or csv) * values Optional parameter for the previous names (array or cvs) * skin Use predefined values (hu - hungarian ABC) * * @param array $params All attributes passed to this function from the template. * @param Zikula_View $view Reference to the Zikula_View object. * * @return string */ function smarty_function_pagerabc($params, Zikula_View $view) { if (!isset($params['posvar'])) { $params['posvar'] = 'letter'; } if (!isset($params['separator'])) { $params['separator'] = ' | '; } if (!isset($params['skin'])) { $params['skin'] = ''; } if (!isset($params['printempty']) || !is_bool($params['printempty'])) { $params['printempty'] = false; } // set a default class if (!isset($params['class'])) { $params['class'] = 'pagination pagination-sm'; } if (!isset($params['class_num'])) { $params['class_num'] = ''; } if (!isset($params['class_numon'])) { $params['class_numon'] = ' '; } $pager = array(); if (!empty($params['names'])) { if (!is_array($params['names'])) { $pager['names'] = explode(';', $params['names']); } else { $pager['names'] = $params['names']; } if (!empty($params['values'])) { if (!is_array($params['values'])) { $pager['values'] = explode(';', $params['values']); } else { $pager['values'] = $params['values']; } if (count($pager['values']) != count($pager['names'])) { LogUtil::addErrorPopup('pagerabc: Values length must be the same of the names'); $pager['values'] = $pager['names']; } } else { $pager['values'] = $pager['names']; } } else { // predefined abc if (strtolower($params['skin']) == 'hu') { // Hungarian $pager['names'] = $pager['values'] = array('A', '?', 'B', 'C', 'D', 'E', '?', 'F', 'G', 'H', 'I', '?', 'J', 'K', 'L', 'M', 'N', 'O', '?', '?', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', '?', '?', 'U', 'V', 'W', 'X', 'Y', 'Z'); //$params['names'] = array('A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U' ,'V','W','X','Y','Z'); //$params['values'] = array('A,?','B','C','D','E,?','F','G','H','I,?','J','K','L','M','N','O,?,?,O','P','Q','R','S','T','U,?,?,U','V','W','X','Y','Z'); } else { $alphabet = defined('_ALPHABET') ? constant('_ALPHABET') : 'A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z'; $pager['names'] = $pager['values'] = explode(',', $alphabet); } } $pager['posvar'] = $params['posvar']; unset($params['posvar']); unset($params['names']); unset($params['values']); if (!isset($params['route'])) { if (isset($params['modname'])) { $pager['module'] = $params['modname']; } else { $module = FormUtil::getPassedValue('module', null, 'GETPOST', FILTER_SANITIZE_STRING); $name = FormUtil::getPassedValue('name', null, 'GETPOST', FILTER_SANITIZE_STRING); $pager['module'] = !empty($module) ? $module : $name; } $pager['func'] = isset($params['func']) ? $params['func'] : FormUtil::getPassedValue('func', 'index', 'GETPOST', FILTER_SANITIZE_STRING); $pager['type'] = isset($params['type']) ? $params['type'] : FormUtil::getPassedValue('type', 'user', 'GETPOST', FILTER_SANITIZE_STRING); } else { $pager['route'] = $params['route']; unset($params['route']); } $pagerUrl = function ($pager) use($view) { if (!isset($pager['route'])) { return ModUtil::url($pager['module'], $pager['type'], $pager['func'], $pager['args']); } return $view->getContainer()->get('router')->generate($pager['route'], $pager['args']); }; $allVars = array_merge($view->getRequest()->request->all(), $view->getRequest()->query->all(), $view->getRequest()->attributes->get('_route_params', array())); $pager['args'] = array(); if (empty($pager['module']) && empty($pager['route'])) { $pager['module'] = System::getVar('startpage'); $starttype = System::getVar('starttype'); $pager['type'] = !empty($starttype) ? $starttype : 'user'; $startfunc = System::getVar('startfunc'); $pager['func'] = !empty($startfunc) ? $startfunc : 'index'; $startargs = explode(',', System::getVar('startargs')); foreach ($startargs as $arg) { if (!empty($arg)) { $argument = explode('=', $arg); if ($argument[0] == $pager['posvar']) { $allVars[$argument[0]] = $argument[1]; } } } } // If $forwardvars set, add only listed vars to query string, else add all POST and GET vars if (isset($params['forwardvars'])) { if (!is_array($params['forwardvars'])) { $params['forwardvars'] = preg_split('/[,;\\s]/', $params['forwardvars'], -1, PREG_SPLIT_NO_EMPTY); } foreach ((array) $params['forwardvars'] as $key => $var) { if (!empty($var) && !empty($allVars[$var])) { $pager['args'][$var] = $allVars[$var]; } } } else { $pager['args'] = array_merge($pager['args'], $allVars); } if (isset($params['additionalvars'])) { if (!is_array($params['additionalvars'])) { $params['additionalvars'] = preg_split('/[,;\\s]/', $params['additionalvars'], -1, PREG_SPLIT_NO_EMPTY); } foreach ((array) $params['additionalvars'] as $var) { $additionalvar = preg_split('/=/', $var); if (!empty($var) && !empty($additionalvar[1])) { $pager['args'][$additionalvar[0]] = $additionalvar[1]; } } } unset($pager['args']['module']); unset($pager['args']['func']); unset($pager['args']['type']); unset($pager['args'][$pager['posvar']]); // begin to fill the output $output = '<ul class="' . $params['class'] . '">' . "\n"; $style = ''; if ($params['printempty']) { $active = ''; if (!empty($params['class_numon'])) { if (!isset($allVars[$pager['posvar']])) { $style = ' class="' . $params['class_numon'] . '"'; $active = 'class="active"'; } elseif (!empty($params['class_num'])) { $style = ' class="' . $params['class_num'] . '"'; } else { $style = ''; } } $vars[$pager['posvar']] = ''; $urltemp = DataUtil::formatForDisplay($pagerUrl($pager)); $output .= '<li ' . $active . '><a ' . $style . ' href="' . $urltemp . '"> -' . "\n</a></li>"; } $style = ''; foreach (array_keys($pager['names']) as $i) { $active = ''; if (!empty($params['class_numon'])) { if (isset($allVars[$pager['posvar']]) && $allVars[$pager['posvar']] == $pager['values'][$i]) { $style = ' class="' . $params['class_numon'] . '"'; $active = 'class="active"'; } elseif (!empty($params['class_num'])) { $style = ' class="' . $params['class_num'] . '"'; } else { $style = ''; } } $pager['args'][$pager['posvar']] = $pager['values'][$i]; $urltemp = DataUtil::formatForDisplay($pagerUrl($pager)); $output .= '<li ' . $active . '><a ' . $style . ' href="' . $urltemp . '">' . $pager['names'][$i] . "</a></li>\n"; } $output .= "</ul>\n"; return $output; }
/** * Execute workflow operation within action. * * @param string $operation Operation name. * @param array &$obj Data object. * @param string &$nextState Next state. * * @return mixed|false */ public function executeOperation($operation, &$obj, &$nextState) { $params = $operation['parameters']; if (isset($params['nextstate'])) { $nextState = $params['nextstate']; } $params['nextstate'] = $nextState; // test operation file exists $path = Zikula_Workflow_Util::_findpath("operations/function.{$operation['name']}.php", $this->module); if (!$path) { throw new \Exception(__f('Operation file [%s] does not exist', $operation['name'])); } // load file and test if function exists include_once $path; $function = "{$this->module}_operation_{$operation['name']}"; if (!function_exists($function)) { throw new \Exception(__f('Operation function [%s] is not defined', $function)); } // execute operation and return result $result = $function($obj, $params); $states = array_keys($this->stateMap); // checks for an invalid next state value if (!in_array($params['nextstate'], $states)) { LogUtil::addErrorPopup(__f('Invalid next-state value [%1$s] retrieved by the \'%2$s\' operation for the workflow \'%3$s\' [\'%4$s\'].', array($nextState, $operation, $this->getID(), $this->getModule()))); } else { $nextState = $params['nextstate']; } return $result; }
/** * Mostra el formulari per introduir una nova activitat * * ### Paràmetres rebuts per GET: * * integer **catId** identificador del catàleg on es crearà l'activitat * * @return void (mostra la plantilla Cataleg_user_fitxaActivitat.tpl) */ public function addnew() { // Check permission $this->throwForbiddenUnless(SecurityUtil::checkPermission('Cataleg::', '::', ACCESS_ADD)); $catId = FormUtil::getPassedValue('catId', null, 'GET'); $view = Zikula_View::getInstance('Cataleg', false); if (ModUtil::apiFunc($this->name, 'user', 'haveAccess', array('accio' => 'addnew', 'id' => $catId))) { $cataleg = ModUtil::apiFunc('Cataleg', 'user', 'get', array('catId' => $catId)); $prioritats = ModUtil::apiFunc('Cataleg', 'user', 'getAllPrioritatsCataleg', array('catId' => $catId)); $destinataris = ModUtil::apiFunc('Cataleg', 'user', 'getTipus', array('tipus' => 'dest')); $curs = ModUtil::apiFunc('Cataleg', 'user', 'getTipus', array('tipus' => 'curs')); $pres = ModUtil::apiFunc('Cataleg', 'user', 'getTipus', array('tipus' => 'pres')); $abast = ModUtil::apiFunc('Cataleg', 'user', 'getTipus', array('tipus' => 'abast')); $sstt = ModUtil::apiFunc('Cataleg', 'user', 'getTipus', array('tipus' => 'sstt')); $opsGest = ModUtil::apiFUnc('Cataleg', 'user', 'getOpcionsGestio'); $unitats = ModUtil::apiFunc('Cataleg', 'user', 'getAllUserUnits', array('catId' => $catId)); if (SecurityUtil::checkPermission('Cataleg::', '::', ACCESS_ADMIN)) $level = 'admin'; else $level = 'edit'; $view->assign('info', null); $view->assign('actId', null); $view->assign('level', $level); $view->assign('cataleg', $cataleg); $view->assign('eixinfo', null); // info de l'eix associat a l'activitat $view->assign('subprinfo', null); // info de la subprioritat associada a l'activitat $view->assign('subpr', null); // inicialment no hi ha llista de subprioritats perquè depenen de la prioritat triada $view->assign('priinfo', null); // info de la prioritat associada a l'activitat $view->assign('prioritats', $prioritats); // llista de prioritats disponibles $view->assign('unitats', $unitats); // llista de les unitats de l'usuari $view->assign('destinataris', $destinataris); $view->assign('curs', $curs); $view->assign('pres', $pres); $view->assign('ambit', $abast); $view->assign('sstt', $sstt); $view->assign('opsGest', $opsGest); $view->assign('def', ''); $view->assign('back', ''); if (!$unitats) { LogUtil::addErrorPopup($this->__('No esteu associat a cap unitat o servei d\'aquest catàleg ')); return system::redirect(ModUtil::url('Cataleg', 'user', 'view')); } return $view->fetch('user/Cataleg_user_fitxaActivitat.tpl'); } else { $view->assign('icon', 'important.png'); $view->assign('msg', $this->__('No teniu permís per crear una activitat en aquest catàleg.')); return $view->fetch('user/Cataleg_user_msg.tpl'); } }