/** * Zikula_View modifier to apply transform hooks * * This modifier will run the transform hooks that are enabled for the * corresponding module (like Autolinks, bbclick and others). * * Available parameters: * - modname: The well-known name of the calling module; passed to the hook function * in the extrainfo array * Example * * {$MyVar|modcallhooks} * * @param mixed $string The contents to transform. * @param string $modname Module name. * * @return string The modified output. */ function smarty_modifier_modcallhooks($string, $modname = '') { LogUtil::log(__f('Warning! Template modifier {$var|%1$s} is deprecated.', array('modcallhooks')), E_USER_DEPRECATED); $extrainfo = array($string); if (!empty($modname)) { $extrainfo['module'] = $modname; } list($string) = ModUtil::callHooks('item', 'transform', '', $extrainfo); return $string; }
/** * Zikula_View function call hooks * * This function calls a specific module function. It returns whatever the return * value of the resultant function is if it succeeds. * Note that in contrast to the API function modcallhooks you need not to load the * module with ModUtil::load. * * * Available parameters: * - 'hookobject' the object the hook is called for - either 'item' or 'category' * - 'hookaction' the action the hook is called for - one of 'create', 'delete', 'transform', or 'display' * - 'hookid' the id of the object the hook is called for (module-specific) * - 'implode' Implode collapses all display hooks into a single string. * - 'assign' If set, the results are assigned to the corresponding variable instead of printed out * - all remaining parameters are passed to the ModUtil::callHooks API via the extrainfo array * * Example * {modcallhooks hookobject='item' hookaction='modify' hookid=$tid $modname='ThisModule' $objectid=$tid} * * @param array $params All attributes passed to this function from the template. * @param Zikula_View $view Reference to the Zikula_View object. * * @see function.modcallhooks.php::smarty_function_modcallhooks() * * @return string The results of the module function. */ function smarty_function_modcallhooks($params, $view) { LogUtil::log(__f('Warning! Template plugin {%1$s} is deprecated, please use {%2$s} instead.', array('modcallhooks', 'notifydisplayhooks')), E_USER_DEPRECATED); $assign = isset($params['assign']) ? $params['assign'] : null; $hookid = isset($params['hookid']) ? $params['hookid'] : ''; $hookaction = isset($params['hookaction']) ? $params['hookaction'] : null; $hookobject = isset($params['hookobject']) ? $params['hookobject'] : null; $implode = isset($params['implode']) ? (bool)$params['implode'] : true; // avoid sending these to ModUtil::callHooks unset($params['hookobject']); unset($params['hookaction']); unset($params['hookid']); unset($params['assign']); unset($params['implode']); if (!$hookobject) { $view->trigger_error(__f('Error! in %1$s: the %2$s parameter must be specified.', array('modcallhooks', 'hookobject'))); return false; } if (!$hookaction) { $view->trigger_error(__f('Error! in %1$s: the %2$s parameter must be specified.', array('modcallhooks', 'hookaction'))); return false; } if (!$hookid) { $hookid = ''; } // create returnurl if not supplied (= this page) if (!isset($params['returnurl']) || empty($params['returnurl'])) { $params['returnurl'] = str_replace('&', '&', 'http://' . System::getHost() . System::getCurrentUri()); } // if the implode flag is true then we must always assign the result to a template variable // outputing the erray is no use.... if (!$implode) { $assign = 'hooks'; } $result = ModUtil::callHooks($hookobject, $hookaction, $hookid, $params, $implode); if ($assign) { $view->assign($assign, $result); } else { return $result; } }
/** * Create a new event. * * @param TimeIt_Model_Event $event Event to save. * @param boolean $noRecurrenceCalculation Set to true to omit the recurrence calculation. * * @return boolean true if the event create was successfull. * @throws InvalidArgumentException If $event is null. */ public function create(TimeIt_Model_Event $event, $noRecurrenceCalculation = false) { if ($event == null) { throw new InvalidArgumentException('$event not set'); } if ($event->isValid()) { $event->save(); } else { return false; } //TODO Workflows if (!isset($obj['__META__']['TimeIt']['recurrenceOnly']) || !$obj['__META__']['TimeIt']['recurrenceOnly']) { if (!$noRecurrenceCalculation) { $prozi = new TimeIt_Recurrence_Processor(new TimeIt_Recurrence_Output_DB(), $obj); $prozi->doCalculation(); } // Let any hooks know that we have created a new item ModUtil::callHooks('item', 'create', $obj['id'], array('module' => 'TimeIt')); } return true; }
/** * Create a new forum in database * @author Albert Pï¿œrez Monfort (aperezm@xtec.cat) * @param: args Array with the forum properties * @return true if success */ public function create($args) { $item = FormUtil::getPassedValue('item', isset($args['item']) ? $args['item'] : null, 'POST'); // Security check if (!SecurityUtil::checkPermission('IWforums::', "::", ACCESS_ADMIN)) { throw new Zikula_Exception_Forbidden(); } //Needed arguments if ((!isset($item['nom_forum']))) { return LogUtil::registerError($this->__('Error! Could not do what you wanted. Please check your input.')); } if (!DBUtil::insertObject($item, 'IWforums_definition', 'fid')) { return LogUtil::registerError($this->__('Error! Creation attempt failed.')); } // Let any hooks know that we have created a new item ModUtil::callHooks('item', 'create', $item['fid'], array('module' => 'IWforums')); return $item['fid']; }
public function deleteBlock($bid) { // Ensure that $bid is 1 or higher. if (!is_numeric($bid) || $bid < 1) { $this->setError(__('Block ID Invalid')); return false; } // Ensure block exists. if (!BlockUtil::getBlockInfo($bid)) { $this->setError(__('No Such Block Exists')); return false; } // Delete block placements for this block. if (!DBUtil::deleteObjectByID('block_placements', $bid, 'bid')) { $this->setError(__('Block Placements Not Removed')); return false; } // Delete the block itself. if (!DBUtil::deleteObjectByID('blocks', $bid, 'bid')) { $this->setError(__('Block Not Deleted')); return false; } // Let other modules know we have deleted an item. ModUtil::callHooks('item', 'delete', $bid, array('module' => 'Blocks')); // Success. return true; }
/** * Call system hooks. * * Implements 'core.postinit' event. * * This is just here for legacy systeminit hooks. * * @param Zikula_Event $event The event handler. * * @return void */ public function systemHooks(Zikula_Event $event) { if (!System::isInstalling() && System::isLegacyMode()) { // call system init hooks $systeminithooks = FormUtil::getPassedValue('systeminithooks', 'yes', 'GETPOST'); if (SecurityUtil::checkPermission('::', '::', ACCESS_ADMIN) && (isset($systeminithooks) && $systeminithooks == 'no')) { // omit system hooks if requested by an administrator } else { ModUtil::callHooks('zikula', 'systeminit', 0, array('module' => 'zikula')); } } }
/** * Update a menu item * @author: Albert Pérez Monfort (aperezm@xtec.cat) * @param: args id of the item to update * @return: True if success */ public function updateIcon($args) { // Security check if (!SecurityUtil::checkPermission('IWmenu::', '::', ACCESS_ADMIN)) { return LogUtil::registerPermissionError(); } // Needed arguments. if (!isset($args['mid'])) { return LogUtil::registerError($this->__('Error! Could not do what you wanted. Please check your input.')); } //Cridem la funció get que retorna les dades $item = ModUtil::apiFunc('IWmenu', 'admin', 'get', array('mid' => $args['mid'])); if (!$item) { return LogUtil::registerError($this->__('No such item found.')); } $items = array('icon' => $args['icon']); $pntable = & DBUtil::getTables(); $c = $pntable['IWmenu_column']; $where = "$c[mid]=" . $args['mid']; if (!DBUtil::updateObject($items, 'IWmenu', $where, 'mid')) { return LogUtil::registerError($this->__('Error! Update attempt failed.')); } // Let any hooks know that we have updated an item. ModUtil::callHooks('item', 'update', $items['mid'], array('module' => 'IWmenu')); // Let the calling process know that we have finished successfully return true; }
/** * Formats an event. * * @param array $args Event. * * @return array * @throws InvalidArgumentException In case of invalid parameters. */ function getEventPreformat($args) { if (!isset($args['obj']) || empty($args['obj'])) { throw new InvalidArgumentException('$obj arg not set'); } $obj =& $args['obj']; //process text format if (substr($obj['text'], 0, 11) == "#plaintext#") { $obj['text'] = substr_replace($obj['text'], "", 0, 11); $obj['text'] = nl2br($obj['text']); } // hooks if (!isset($args['noHooks']) || $args['noHooks'] == false) { $obj['text'] = ModUtil::callHooks('item', 'transform', '', array($obj['text'])); $obj['text'] = $obj['text'][0]; } // repeats if ($obj['repeatType'] == 2) { $temp = explode(' ', $obj['repeatSpec']); $obj['repeat21'] = $temp[0]; $obj['repeat22'] = $temp[1]; } // split duration $obj['allDayDur'] = explode(',', $obj['allDayDur']); TimeIt_Util::convertAlldayStartToLocalTime($obj); // set username $obj['cr_name'] = UserUtil::getVar('uname', (int) $obj['cr_uid']); $obj['cr_datetime'] = DateUtil::getDatetime(strtotime($obj['cr_date']), "datetimebrief"); // set group name if ($obj['group'] == 'all') { $obj['group_name'] = 'all'; } else { $groupNames = array(); foreach (explode(',', $obj['group']) as $grpId) { $groupObj = UserUtil::getPNGroup((int) $grpId); $groupNames[] = $groupObj['name']; } $obj['group_name'] = $groupNames; } return $obj; }
/** * Create a new topic in database * @author: Albert Pérez Monfort (aperezm@xtec.cat) * @param: Topic information * @return: identity of the topic created if success and false otherwise */ public function crear_tema($args) { $fid = FormUtil::getPassedValue('fid', isset($args['fid']) ? $args['fid'] : null, 'POST'); $descriu = FormUtil::getPassedValue('descriu', isset($args['descriu']) ? $args['descriu'] : '', 'POST'); $titol = FormUtil::getPassedValue('titol', isset($args['titol']) ? $args['titol'] : null, 'POST'); // Security check if (!SecurityUtil::checkPermission('IWforums::', '::', ACCESS_READ)) { return LogUtil::registerPermissionError(); } // Needed argument if (!isset($fid) || !is_numeric($fid) || !isset($titol)) { return LogUtil::registerError($this->__('Error! Could not do what you wanted. Please check your input.')); } //check if user can access the forum $access = ModUtil::func('IWforums', 'user', 'access', array('fid' => $fid)); if ($access < 3) { return LogUtil::registerError($this->__('You can\'t access the forum')); } $item = array('fid' => $fid, 'titol' => $titol, 'usuari' => UserUtil::getVar('uid'), 'descriu' => $descriu, 'data' => time()); if (!DBUtil::insertObject($item, 'IWforums_temes', 'ftid')) { return LogUtil::registerError($this->__('Error! Creation attempt failed.')); } // Let any hooks know that we have created a new item ModUtil::callHooks('item', 'create', $item['ftid'], array('module' => 'IWforums')); return $item['ftid']; }
/** * update a Admin_Messages item * @author Mark West * @param int $args['mid'] the ID of the item * @param sting $args['title'] title of the admin message * @param string $args['content'] text of the admin message * @param string $args['language'] the language of the message * @param int $args['active'] activation status of the message * @param int $args['expire'] expiry date of the message * @param int $args['view'] who can view the message * @return bool true if successful, false otherwise */ function Admin_Messages_adminapi_update($args) { $dom = ZLanguage::getModuleDomain('Admin_Messages'); // Argument check if (!isset($args['mid']) || !isset($args['title']) || !isset($args['content']) || !isset($args['language']) || !isset($args['active']) || !isset($args['expire']) || !isset($args['oldtime']) || !isset($args['changestartday']) || !isset($args['view'])) { return LogUtil::registerArgsError(); } // Get the existing admin message $item = ModUtil::apiFunc('Admin_Messages', 'user', 'get', array('mid' => $args['mid'])); if ($item == false) { return LogUtil::registerError(__('Sorry! No such item found.', $dom)); } // Security check if (!SecurityUtil::checkPermission('Admin_Messages::', "{$item['title']}::{$args['mid']}", ACCESS_EDIT)) { return LogUtil::registerPermissionError(); } // check value of change start day to today and set time if ($args['changestartday'] == 1) { $time = time(); } else { $time = $args['oldtime']; } // check for an invalid expiry if ($args['expire'] < 0) { $expire = 0; } // create the item array $item = array('mid' => $args['mid'], 'title' => $args['title'], 'content' => $args['content'], 'language' => $args['language'], 'active' => $args['active'], 'view' => $args['view']); // add some additional modified values $args['expire'] = $args['expire'] * 86400; // turns days into seconds $args['date'] = $time; if (!DBUtil::updateObject($args, 'message', '', 'mid')) { return LogUtil::registerError(__('Error! Could not save your changes.')); } // New hook functions ModUtil::callHooks('item', 'update', $args['mid'], array('module' => 'Admin_Messages')); // The item has been modified, so we clear all cached pages of this item. $view = Zikula_View::getInstance('Admin_Messages'); $view->clear_cache(null, UserUtil::getVar('uid')); // Let the calling process know that we have finished successfully return true; }
/** * Carry out hook operations for module. * * @deprecated * @see ModUtil::callHooks() * * @param string $hookobject The object the hook is called for - one of 'item', 'category' or 'module'. * @param string $hookaction The action the hook is called for - one of 'new', 'create', 'modify', 'update', 'delete', 'transform', 'display', 'modifyconfig', 'updateconfig'. * @param integer $hookid The id of the object the hook is called for (module-specific). * @param array $extrainfo Extra information for the hook, dependent on hookaction. * @param boolean $implode Implode collapses all display hooks into a single string - default to true for compatability with .7x. * * @return string|array String output from GUI hooks, extrainfo array for API hooks. */ function pnModCallHooks($hookobject, $hookaction, $hookid, $extrainfo = array(), $implode = true) { LogUtil::log(__f('Warning! Function %1$s is deprecated. Please use %2$s instead.', array(__FUNCTION__, 'ModUtil::callHooks()')), E_USER_DEPRECATED); return ModUtil::callHooks($hookobject, $hookaction, $hookid, $extrainfo, $implode); }
/** * Remove a module. * * @param array $args All parameters sent to this function. * numeric $args['id'] The id of the module. * boolean $args['removedependents'] Remove any modules dependent on this module (default: false). * boolean $args['interactive_remove'] Whether to operat in interactive mode or not. * * @return boolean True on success, false on failure. */ public function remove($args) { // Argument check if (!isset($args['id']) || !is_numeric($args['id'])) { return LogUtil::registerArgsError(); } if (!isset($args['removedependents']) || !is_bool($args['removedependents'])) { $removedependents = false; } else { $removedependents = true; } // Security check if (!SecurityUtil::checkPermission('Extensions::', '::', ACCESS_ADMIN)) { return LogUtil::registerPermissionError(); } // Get module information $modinfo = ModUtil::getInfo($args['id']); if (empty($modinfo)) { return LogUtil::registerError($this->__('Error! No such module ID exists.')); } switch ($modinfo['state']) { case ModUtil::STATE_NOTALLOWED: return LogUtil::registerError($this->__f('Error! No permission to upgrade %s.', $modinfo['name'])); break; } $osdir = DataUtil::formatForOS($modinfo['directory']); $modpath = $modinfo['type'] == ModUtil::TYPE_SYSTEM ? 'system' : 'modules'; $oomod = ModUtil::isOO($modinfo['name']); if ($oomod) { ZLoader::addAutoloader($osdir, "{$modpath}/{$osdir}/lib"); } $version = Extensions_Util::getVersionMeta($osdir, $modpath); $bootstrap = "{$modpath}/{$osdir}/bootstrap.php"; if (file_exists($bootstrap)) { include_once $bootstrap; } if ($modinfo['type'] == ModUtil::TYPE_MODULE) { if (is_dir("modules/{$osdir}/locale")) { ZLanguage::bindModuleDomain($modinfo['name']); } } // call any module delete hooks if (System::isLegacyMode() && !$oomod) { ModUtil::callHooks('module', 'remove', $modinfo['name'], array('module' => $modinfo['name'])); } // Get module database info ModUtil::dbInfoLoad($modinfo['name'], $osdir); // Module deletion function. Only execute if the module is initialised. if ($modinfo['state'] != ModUtil::STATE_UNINITIALISED) { if (!$oomod && file_exists($file = "{$modpath}/{$osdir}/pninit.php")) { if (!(include_once $file)) { LogUtil::registerError($this->__f("Error! Could not load a required file: '%s'.", $file)); } } if ($oomod) { $className = ucwords($modinfo['name']) . '_Installer'; $reflectionInstaller = new ReflectionClass($className); if (!$reflectionInstaller->isSubclassOf('Zikula_AbstractInstaller')) { LogUtil::registerError($this->__f("%s must be an instance of Zikula_AbstractInstaller", $className)); } $installer = $reflectionInstaller->newInstanceArgs(array($this->serviceManager)); $interactiveClass = ucwords($modinfo['name']) . '_Controller_Interactiveinstaller'; $interactiveController = null; if (class_exists($interactiveClass)) { $reflectionInteractive = new ReflectionClass($interactiveClass); if (!$reflectionInteractive->isSubclassOf('Zikula_Controller_AbstractInteractiveInstaller')) { LogUtil::registerError($this->__f("%s must be an instance of Zikula_Controller_AbstractInteractiveInstaller", $className)); } $interactiveController = $reflectionInteractive->newInstance($this->serviceManager); } } // perform the actual deletion of the module $func = $oomod ? array($installer, 'uninstall') : $modinfo['name'] . '_delete'; $interactive_func = $oomod ? array($interactiveController, 'uninstall') : $modinfo['name'] . '_init_interactivedelete'; // allow bypass of interactive removal during a new installation only. if (System::isInstalling() && is_callable($interactive_func) && !is_callable($func)) { return; // return void here } if (isset($args['interactive_remove']) && $args['interactive_remove'] == false && is_callable($interactive_func)) { if (is_array($interactive_func)) { // This must be an OO controller since callable is an array. // Because interactive installers extend the Zikula_AbstractController, is_callable will always return true because of the __call() // so we must check if the method actually exists by reflection - drak if ($reflectionInteractive->hasMethod('upgrade')) { SessionUtil::setVar('interactive_remove', true); return call_user_func($interactive_func); } } else { // tnis is enclosed in the else so that if both conditions fail, execution will pass onto the non-interactive execution below. SessionUtil::setVar('interactive_remove', true); return call_user_func($interactive_func); } } // non-interactive if (is_callable($func)) { if (call_user_func($func) != true) { return false; } } } // Remove variables and module // Delete any module variables that the module cleanup function might // have missed DBUtil::deleteObjectByID('module_vars', $modinfo['name'], 'modname'); // clean up any hooks activated for this module if (System::isLegacyMode()) { DBUtil::deleteObjectByID('hooks', $modinfo['name'], 'tmodule'); } if ($oomod) { HookUtil::unregisterProviderBundles($version->getHookProviderBundles()); HookUtil::unregisterSubscriberBundles($version->getHookSubscriberBundles()); EventUtil::unregisterPersistentModuleHandlers($modinfo['name']); } // remove the entry from the modules table if ($this->serviceManager['multisites.enabled'] == 1) { // who can access to the mainSite can delete the modules in any other site $canDelete = $this->serviceManager['multisites.mainsiteurl'] == FormUtil::getPassedValue('sitedns', null, 'GET') && $this->serviceManager['multisites.based_on_domains'] == 0 || $this->serviceManager['multisites.mainsiteurl'] == $_SERVER['HTTP_HOST'] && $this->serviceManager['multisites.based_on_domains'] == 1 ? 1 : 0; //delete the module infomation only if it is not allowed, missign or invalid if ($canDelete == 1 || $modinfo['state'] == ModUtil::STATE_NOTALLOWED || $modinfo['state'] == ModUtil::STATE_MISSING || $modinfo['state'] == ModUtil::STATE_INVALID) { // remove the entry from the modules table DBUtil::deleteObjectByID('modules', $args['id'], 'id'); } else { //set state as uninnitialised ModUtil::apiFunc('modules', 'admin', 'setstate', array('id' => $args['id'], 'state' => ModUtil::STATE_UNINITIALISED)); } } else { DBUtil::deleteObjectByID('modules', $args['id'], 'id'); } $event = new Zikula_Event('installer.module.uninstalled', null, $modinfo); $this->eventManager->notify($event); return true; }
/** * Modify a reference from database * * @param $args['pid'] Id of the reference that has to be modified * @param $args['ref'] Reference of the item * @param $args['url'] URL website * @param $args['description'] Reference description * @param $args['scrolls'] The iframe show the scrolls 1 - Yes (auto) 0 - No * @param $args['width'] Width of the iframe * @param $args['height'] Height of the iframe * @param $args['widthunit'] Unit used in the width specified % - percentual px - pixels * @return mixed FAQ ID on success, false on failure */ public function update($args) { // Argument check if (!isset($args['ref']) || !isset($args['url'])) { return LogUtil::registerError($this->__('Error! Could not do what you wanted. Please check your input.')); } $args['scrolls'] = ($args['scrolls'] == 'on') ? '1' : '0'; // Get the current faq $item = ModUtil::apiFunc('IWwebbox', 'user', 'get', array('pid' => $args['pid'])); if (!$item) { return LogUtil::registerError($this->__('No such item found.')); } // Security check. if (!SecurityUtil::checkPermission('IWwebbox::', "$args[pid]::", ACCESS_EDIT)) { return LogUtil::registerPermissionError(); } if (!DBUtil::updateObject($args, 'IWwebbox', '', 'pid')) { return LogUtil::registerError($this->__('Error! Update attempt failed.')); } // The item has been modified, so we clear all cached pages of this item. $view = Zikula_View::getInstance('IWwebbox'); $view->clear_cache(null, $args['pid']); // Let any hooks know that we have updated an item ModUtil::callHooks('item', 'update', $args['pid'], array('module' => 'IWwebbox')); return true; }
/** * Delete an user assignment (with its sections, messages...) * @author Sara Arjona Téllez (sarjona@xtec.cat) * @param $args['qvaid'] ID of the user assignment * @return bool true on success, false on failure */ public function deleteuserassignment($args) { // Security check if (!SecurityUtil::checkPermission('IWqv::', '::', ACCESS_ADD)) { return LogUtil::registerError($this->__('Sorry! No authorization to access this module.')); } // Argument check if (!isset($args['qvaid']) || !is_numeric($args['qvaid'])) { return LogUtil::registerError($this->__('Error! Could not do what you wanted. Please check your input.')); } $item = ModUtil::apiFunc('IWqv', 'user', 'getassignment', array('qvaid' => $args['qvaid'], 'createifnotexist' => false, 'getallinformation' => false)); if ($item == false) { return LogUtil::registerError($this->__('No such item found.')); } // Delete the assignment with its sections and messages $sections = ModUtil::apiFunc('IWqv', 'user', 'getsections', array('qvaid' => $args['qvaid'])); foreach ($sections as $section) { $sections = ModUtil::apiFunc('IWqv', 'user', 'deletesection', array('qvsid' => $section[qvsid])); } if (!DBUtil::deleteObjectByID('IWqv_assignments', $args['qvaid'], 'qvaid')) { return LogUtil::registerError($this->__('Error! Sorry! Deletion attempt failed.')); } // Let any hooks know that we have deleted an item ModUtil::callHooks('item', 'delete', $args['qvaid'], array('module' => 'IWqv')); // Let the calling process know that we have finished successfully return true; }
/** * Copy a note to another agenda * * @param array $args Agenda information * * @return True if success and false otherwise */ public function meva($args) { // Security check $this->throwForbiddenUnless(SecurityUtil::checkPermission('IWagendas::', '::', ACCESS_READ)); $aid = FormUtil::getPassedValue('aid', isset($args['aid']) ? $args['aid'] : null, 'POST'); $adaid = FormUtil::getPassedValue('adaid', isset($args['adaid']) ? $args['adaid'] : null, 'POST'); // Needed argument if (!isset($aid)) { return LogUtil::registerError($this->__('Error! Could not do what you wanted. Please check your input.')); } $note = ModUtil::apiFunc('IWagendas', 'user', 'get', array('aid' => $aid)); if ($note == false) { return LogUtil::registerError($this->__('Event not found')); } if ($note['daid'] != 0) { //get the agenda $agenda = ModUtil::apiFunc('IWagendas', 'user', 'getAgenda', array('daid' => $note['daid'])); if ($agenda == false) { return LogUtil::registerError($this->__('Event not found')); } // Check whether the user can access the agenda for this action $te_acces = ModUtil::func('IWagendas', 'user', 'te_acces', array('daid' => $note['daid'], 'grup' => $agenda['grup'], 'resp' => $agenda['resp'], 'activa' => $agenda['activa'])); // If the user has no access, show an error message and stop execution if ($te_acces < 1) { return LogUtil::registerError($this->__('You are not allowed to administrate the agendas')); } } //get all users information $sv = ModUtil::func('IWmain', 'user', 'genSecurityValue'); $usersInfo = ModUtil::func('IWmain', 'user', 'getAllUsersInfo', array('sv' => $sv, 'info' => 'ncc')); //preparem el contingut de la icona amb informaciᅵ addicional $j = 2; $c2x = ''; $ha_passat = false; for ($j = 2; $j < 7; $j++) { $c = 'c' . $j; $tc = 'tc' . $j; if ($agenda[$c] != "" && ($note[$c] != '' || $agenda[$tc] == 3 || $agenda[$tc] == 4)) { $c2x .= '<fieldset><legend> '; $c2x .= $agenda[$c]; $c2x .= ' </legend>'; $c2x .= ( $agenda[$tc] != 3 && $agenda[$tc] != 4 && $note[$c] == "") ? "---" : $note[$c]; if ($agenda[$tc] == 3) { $c2x .= $usersInfo[$note['usuari']]; } if ($agenda[$tc] == 4) { $c2x .= $usersInfo[$note['usuari']] . $this->__(' on ') . date('d/m/Y', $note['dataanota']) . $this->__(' at ') . date('H:i', $note['dataanota']); } $c2x .= '</fieldset>'; } } foreach ($adaid as $daid) { //if it is a shared agenda check if user can write in it if ($daid > 0) { // Check whether the user can access the agenda for this action $te_acces = ModUtil::func('IWagendas', 'user', 'te_acces', array('daid' => $daid)); if ($te_acces < 2) { return LogUtil::registerError($this->__('You are not allowed to administrate the agendas')); } } $subscrits = ModUtil::apiFunc('IWagendas', 'user', 'getsubscrits', array('daid' => $daid)); $subscritString = '$'; foreach ($subscrits as $subscrit) { $subscritString .= '$' . $subscrit['uid'] . '$'; } $items = array('data' => $note['data'], 'totdia' => $note['totdia'], 'usuari' => UserUtil::getVar('uid'), 'tasca' => $note['tasca'], 'nivell' => $note['nivell'], 'c1' => $note['c1'], 'c2' => $c2x, 'daid' => $daid, 'dataanota' => time(), 'nova' => $subscritString, 'completa' => $note['oculta'], 'fitxer' => $note['fitxer'], 'protegida' => $note['protegida'], 'origenId' => $note['daid']); if (!DBUtil::insertObject($items, 'IWagendas', 'aid')) { return LogUtil::registerError($this->__('Error! Creation attempt failed.')); } // Let any hooks know that we have created a new item. ModUtil::callHooks('item', 'create', $items['aid'], array('module' => 'IWagendas')); } // Return true if success return true; }
/** * This is a standard function to update the configuration parameters of the * module given the information passed back by the modification form * @author Mark West * @see Admin_Messages_admin_modifyconfig() * @param int $itemsperpage the number messages per page in the admin panel * @return bool true if successful, false otherwise */ function Admin_Messages_admin_updateconfig() { // Security check if (!SecurityUtil::checkPermission('Admin_Messages::', '::', ACCESS_ADMIN)) { return LogUtil::registerPermissionError(); } // Confirm authorisation code. if (!SecurityUtil::confirmAuthKey()) { return LogUtil::registerAuthidError(ModUtil::url('Admin_Messages', 'admin', 'view')); } // Update module variables. $itemsperpage = (int) FormUtil::getPassedValue('itemsperpage', 25, 'POST'); if ($itemsperpage < 1) { $itemsperpage = 25; } ModUtil::setVar('Admin_Messages', 'itemsperpage', $itemsperpage); $allowsearchinactive = (bool) FormUtil::getPassedValue('allowsearchinactive', false, 'POST'); ModUtil::setVar('Admin_Messages', 'allowsearchinactive', $allowsearchinactive); // Let any other modules know that the modules configuration has been updated ModUtil::callHooks('module', 'updateconfig', 'Admin_Messages', array('module' => 'Admin_Messages')); // the module configuration has been updated successfuly LogUtil::registerStatus(__('Done! Saved module configuration.')); // This function generated no output, and so now it is complete we redirect // the user to an appropriate page for them to carry on their work return System::redirect(ModUtil::url('Admin_Messages', 'admin', 'view')); }