/** * Zikula_View function to check for the availability of a module * * This function calls ModUtil::isHooked to determine if two Zikula modules are * hooked together. True is returned if the modules are hooked, false otherwise. * The result can also be assigned to a template variable. * * Available parameters: * - tmodname: The well-known name of the hook module * - smodname: The well-known name of the calling module * - assign: The name of a variable to which the results are assigned * * Examples * {modishooked tmodname='Ratings' smodname='News'} * * {modishooked tmodname='bar' smodname='foo' assign='barishookedtofoo'} * {if $barishookedtofoo}.....{/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.modishooked.php::smarty_function_modishooked() * * @return boolean True if the module is available; false otherwise. */ function smarty_function_modishooked($params, $view) { LogUtil::log(__f('Warning! Template plugin {%1$s} is deprecated.', array('modishooked')), E_USER_DEPRECATED); $assign = isset($params['assign']) ? $params['assign'] : null; $smodname = isset($params['smodname']) ? $params['smodname'] : null; $tmodname = isset($params['tmodname']) ? $params['tmodname'] : null; if (!$tmodname) { $view->trigger_error(__f('Error! in %1$s: the %2$s parameter must be specified.', array('modishooked', 'tmodname'))); return false; } if (!$smodname) { $view->trigger_error(__f('Error! in %1$s: the %2$s parameter must be specified.', array('modishooked', 'smodname'))); return false; } $result = ModUtil::isHooked($tmodname, $smodname); if ($assign) { $view->assign($params['assign'], $result); } else { return $result; } }
/** * Display a comment form * * This function displays a comment form, if you do not want users to * comment on the same page as the item is. * * @param $comment the comment (taken from HTTP put) * @param $mod the name of the module the comment is for (taken from HTTP put) * @param $objectid ID of the item the comment is for (taken from HTTP put) * @param $redirect URL to return to (taken from HTTP put) * @param $subject The subject of the comment (if any) (taken from HTTP put) * @param $replyto The ID of the comment for which this an anser to (taken from HTTP put) * @param $template The name of the template file to use (with extension) * @todo Check out it this function can be merged with _view! * @since 0.2 */ public function comment($args) { $mod = isset($args['mod']) ? $args['mod'] : FormUtil::getPassedValue('mod', null, 'POST'); $objectid = isset($args['objectid']) ? $args['objectid'] : FormUtil::getPassedValue('objectid', null, 'POST'); $areaid = isset($args['areaid']) ? $args['areaid'] : FormUtil::getPassedValue('areaid', null, 'POST'); $redirect = isset($args['redirect']) ? $args['redirect'] : FormUtil::getPassedValue('redirect', null, 'POST'); $useurl = isset($args['useurl']) ? $args['useurl'] : FormUtil::getPassedValue('useurl', null, 'POST'); $comment = isset($args['comment']) ? $args['comment'] : FormUtil::getPassedValue('comment', null, 'POST'); $subject = isset($args['subject']) ? $args['subject'] : FormUtil::getPassedValue('subject', null, 'POST'); $replyto = isset($args['replyto']) ? $args['replyto'] : FormUtil::getPassedValue('replyto', null, 'POST'); $order = isset($args['order']) ? $args['order'] : FormUtil::getPassedValue('order', null, 'POST'); $owneruid = isset($args['owneruid']) ? $args['owneruid'] : FormUtil::getPassedValue('owneruid', null, 'POST'); $template = isset($args['template']) ? $args['template'] : FormUtil::getPassedValue('template', null, 'POST'); $stylesheet = isset($args['ezccss']) ? $args['ezccss'] : FormUtil::getPassedValue('ezccss', null, 'POST'); if ($order == 1) { $sortorder = 'DESC'; } else { $sortorder = 'ASC'; } $status = 0; // check if commenting is setup for the input module if (!ModUtil::available($mod) || !ModUtil::isHooked('EZComments', $mod)) { return LogUtil::registerPermissionError(); } // check if we're using the pager $enablepager = $this->getVar('enablepager'); if ($enablepager) { $numitems = $this->getVar('commentsperpage'); $startnum = FormUtil::getPassedValue('comments_startnum'); if (!isset($startnum) && !is_numeric($startnum)) { $startnum = -1; } } else { $startnum = -1; $numitems = -1; } $items = ModUtil::apiFunc('EZComments', 'user', 'getall', compact('mod', 'objectid', 'sortorder', 'status', 'numitems', 'startnum')); if ($items === false) { return LogUtil::registerError($this->__('Internal Error.'), null, 'index.php'); } $items = ModUtil::apiFunc('EZComments', 'user', 'prepareCommentsForDisplay', $items); if ($enablepager) { $commentcount = ModUtil::apiFunc('EZComments', 'user', 'countitems', compact('mod', 'objectid')); } else { $commentcount = count($items); } // don't use caching (for now...) $this->view->setCaching(false); $this->view->assign('comments', $items)->assign('commentcount', $commentcount)->assign('order', $sortorder)->assign('redirect', $redirect)->assign('allowadd', SecurityUtil::checkPermission('EZComments::', "{$mod}:{$objectid}: ", ACCESS_COMMENT))->assign('mod', DataUtil::formatForDisplay($mod))->assign('objectid', DataUtil::formatForDisplay($objectid))->assign('subject', DataUtil::formatForDisplay($subject))->assign('replyto', DataUtil::formatForDisplay($replyto))->assign('owneruid', $owneruid)->assign('useurl', $useurl)->assign(ModUtil::getVar('EZComments'))->assign('ezc_pager', array('numitems' => $commentcount, 'itemsperpage' => $numitems)); // find out which template to use $templateset = isset($args['template']) ? $args['template'] : $template; $defaultcss = $this->getVar('css', 'style.css'); if (!$this->view->template_exists(DataUtil::formatForOS($templateset) . '/ezcomments_user_comment.tpl')) { $templateset = $this->getVar('template', 'Standard'); } $this->view->assign('template', $templateset); // include stylesheet if there is a style sheet $css = $stylesheet ? "{$stylesheet}.css" : $defaultcss; if ($css = ModUtil::apiFunc('EZComments', 'user', 'getStylesheet', array('path' => "{$templateset}/{$css}"))) { PageUtil::addVar('stylesheet', $css); } // FIXME comment template missing return $this->view->fetch(DataUtil::formatForOS($templateset) . '/ezcomments_user_view.tpl'); }
/** * Determine if a module is hooked by another module. * * @deprecated * @see ModUtil::isHooked() * * @param string $tmodule The target module. * @param string $smodule The source module - default the current top most module. * * @return boolean True if the current module is hooked by the target module, false otherwise. */ function pnModIsHooked($tmodule, $smodule) { LogUtil::log(__f('Warning! Function %1$s is deprecated. Please use %2$s instead.', array(__FUNCTION__, 'ModUtil::isHooked()')), E_USER_DEPRECATED); return ModUtil::isHooked($tmodule, $smodule); }
/** * Show the list of notes that an user can read * @author: Albert Pérez Monfort (aperezm@xtec.cat) * @param: args Array with the topic that is viewing the user, the id of the note and if the user is in the saved mode * @return: The list of notes that the user can read */ public function main($args) { // Get the parameters $nid = FormUtil::getPassedValue('nid', isset($args['nid']) ? $args['nid'] : null, 'GET'); $tema = FormUtil::getPassedValue('tema', isset($args['tema']) ? $args['tema'] : 0, 'GETPOST'); $saved = FormUtil::getPassedValue('saved', isset($args['saved']) ? $args['saved'] : null, 'GETPOST'); $marked = FormUtil::getPassedValue('marked', isset($args['marked']) ? $args['marked'] : 0, 'GETPOST'); // Security check if (!SecurityUtil::checkPermission('IWnoteboard::', "::", ACCESS_READ)) { throw new Zikula_Exception_Forbidden(); } // get user identity $uid = UserUtil::getVar('uid'); if ($uid == '') { $uid = '-1'; } $usersList = ''; $anotacions = array(); $n = 0; $informa = ''; $temes_MS = array(); $tema_anotacio = array('grup' => '', 'nomtema' => ''); $havist = 0; // Get the user permissions in noteboard $permissions = ModUtil::apiFunc('IWnoteboard', 'user', 'permisos', array('uid' => $uid)); // Get all current groups $sv = ModUtil::func('IWmain', 'user', 'genSecurityValue'); $allgroups = ModUtil::func('IWmain', 'user', 'getAllGroups', array('sv' => $sv, 'plus' => $this->__('Unregistered'))); // Get all the notes that have been sended if (isset($saved) && $saved == 1 && $permissions['potverificar']) { $registres = ModUtil::apiFunc('IWnoteboard', 'user', 'getallcaducated', array('tema' => $tema, 'nid' => $nid)); } else { $registres = ModUtil::apiFunc('IWnoteboard', 'user', 'getall', array('tema' => $tema, 'nid' => $nid, 'marked' => $marked)); $saved = 0; } if (UserUtil::isLoggedIn()) { // Get the list of topics $temes = ModUtil::apiFunc('IWnoteboard', 'user', 'getalltemes'); $temes_MS[] = array('id' => '0', 'name' => $this->__('All the topics')); $temes_MS[] = array('id' => '-1', 'name' => $this->__('Not classified')); foreach ($temes as $untema) { //Check if user can see the thopic $isInArray = in_array($untema['grup'], $permissions['grups']); if ($isInArray || $permissions['potverificar']) { $temes_MS[] = array('id' => $untema['tid'], 'name' => $untema['nomtema']); } } $sv = ModUtil::func('IWmain', 'user', 'genSecurityValue'); $havist = ModUtil::func('IWmain', 'user', 'userGetVar', array('module' => 'IWnoteboard', 'name' => 'viewed', 'sv' => $sv)); } $vistes = '$'; foreach ($registres as $registre) { // insert the list of groups that have access to the note into an array $grups_acces = explode('$', $registre['destinataris']); $esta_en_grups_acces = array_intersect($grups_acces, $permissions['grups']); $pos = strpos($registre['no_mostrar'], '$' . $uid . '$'); if (isset($saved) && $saved == 1 && $permissions['potverificar']) { $pos = 0; } $marca = (strpos($registre['marca'], '$' . $uid . '$') != 0) ? 1 : 0; if (UserUtil::isLoggedIn()) { $tema_anotacio = ModUtil::apiFunc('IWnoteboard', 'user', 'gettema', array('tid' => $registre['tid'])); } if ((($registre['verifica'] == 1 && (count($esta_en_grups_acces) >= 1 || $uid == $registre['informa'])) || $permissions['potverificar']) && $pos == 0) { // Calc the colour for the list row if ($registre['verifica'] == 0) { $bgcolor = 'lightgrey'; } else { $n++; $pos = 0; if ($n % 2 == 0) { $pos = strpos($havist, '$' . $registre['nid'] . '$'); $bgcolor = ($pos == 0 && UserUtil::isLoggedIn() && $saved == 0) ? ModUtil::getVar('IWnoteboard', 'colornewrow1') : ModUtil::getVar('IWnoteboard', 'colorrow1'); } else { $pos = strpos($havist, '$' . $registre['nid'] . '$'); $bgcolor = ($pos == 0 && UserUtil::isLoggedIn() && $saved == 0) ? ModUtil::getVar('IWnoteboard', 'colornewrow2') : ModUtil::getVar('IWnoteboard', 'colorrow2'); } } $acces_tema = false; //Check if user can see the thopic $isInArray = in_array($tema_anotacio['grup'], $permissions['grups']); if ($isInArray || $permissions['potverificar'] || $tema_anotacio['grup'] == 0) { $acces_tema = true; } $comentaris_array = array(); // Get the comments associated to a note $comentaris = ModUtil::apiFunc('IWnoteboard', 'user', 'getallcomentaris', array('ncid' => $registre['nid'])); foreach ($comentaris as $comentari) { if ($comentari['verifica'] == 0) { $bgcolorcomentari = 'lightgrey'; } else { $bgcolorcomentari = $bgcolor; } $usersList .= $comentari['informa'] . '$$'; $comentaris_array[] = array('nid' => $comentari['nid'], 'noticia' => DataUtil::formatForDisplayHTML($comentari['noticia']), 'verifica' => $comentari['verifica'], 'bgcolorcomentari' => $bgcolorcomentari, 'data' => date('d/m/y', $comentari['data']), 'hora' => date('H:i', $comentari['data']), 'id_user_informa' => $comentari['informa'], 'id_user' => $uid); } $sv = ModUtil::func('IWmain', 'user', 'genSecurityValue'); $photo = ModUtil::func('IWmain', 'user', 'getUserPicture', array('uname' => UserUtil::getVar('uname', $registre['informa']), 'sv' => $sv, 'small' => $this->getVar('smallAvatars'))); // The user can edit their notes $pot_editar = false; if (($permissions['nivell'] > 4 && $registre['informa'] == $uid && $registre['verifica'] == 1) || ($permissions['nivell'] == 7 && $registre['verifica'] == 1)) { $pot_editar = true; } // The user can delete his/her notes $pot_esborrar = false; if (($permissions['nivell'] > 5 && $registre['informa'] == $uid) || $permissions['nivell'] == 7) { $pot_esborrar = true; } // Get file extension $fileExtension = strtolower(substr(strrchr($registre['fitxer'], "."), 1)); // get file icon $ctypeArray = ModUtil::func('IWmain', 'user', 'getMimetype', array('extension' => $fileExtension)); $fileIcon = $ctypeArray['icon']; $edited = ''; if ($registre['edited'] != '' && ModUtil::getVar('IWnoteboard', 'editPrintAfter') != '-1' && $registre['data'] + ModUtil::getVar('IWnoteboard', 'editPrintAfter') * 60 < $registre['edited']) { $edited = date('d/m/y H:i', $registre['edited']); } $usersList .= $registre['informa'] . '$$'; $anotacions[] = array('nid' => $registre['nid'], 'bgcolor' => $bgcolor, 'data' => date('d/m/y H:i', $registre['data']), 'acces_tema' => $acces_tema, 'tema_anotacio' => $tema_anotacio['nomtema'], 'noticia' => DataUtil::formatForDisplayHTML($registre['noticia']), 'mes_info' => $registre['mes_info'], 'text' => $registre['text'], 'textfitxer' => $registre['textfitxer'], 'fitxer' => $registre['fitxer'], 'fileIcon' => $fileIcon, 'informa' => $informa, 'photo' => $photo, 'verifica' => $registre['verifica'], 'pot_editar' => $pot_editar, 'pot_esborrar' => $pot_esborrar, 'admet_comentaris' => $registre['admet_comentaris'], 'n_comentaris' => count($comentaris), 'comentaris' => $comentaris_array, 'marca' => $marca, 'edited' => $edited, 'created_by' => $registre['informa'], 'edited_by' => UserUtil::getVar('uname', $registre['edited_by']), ); $vistes .= '$' . $registre['nid'] . '$'; } } if ($saved != 1 && UserUtil::isLoggedIn()) { $sv = ModUtil::func('IWmain', 'user', 'genSecurityValue'); if ($tema == 0 && $nid == 0 && $marked == 0 && ModUtil::getVar('IWnoteboard', 'multiLanguage') == 0) { ModUtil::func('IWmain', 'user', 'userSetVar', array('module' => 'IWnoteboard', 'name' => 'viewed', 'value' => $vistes, 'sv' => $sv)); } else { ModUtil::func('IWmain', 'user', 'userSetVar', array('module' => 'IWnoteboard', 'name' => 'viewed', 'value' => $havist . $vistes, 'sv' => $sv)); } $sv = ModUtil::func('IWmain', 'user', 'genSecurityValue'); ModUtil::func('IWmain', 'user', 'userDelVar', array('module' => 'IWmain_block_news', 'name' => 'news', 'sv' => $sv)); } // Count the use of the module if (ModUtil::available('iw_visits') && ModUtil::isHooked('iw_visits', 'IWnoteboard')) { // Insert the record ModUtil::apiFunc('iw_visits', 'user', 'visita'); } $sv = ModUtil::func('IWmain', 'user', 'genSecurityValue'); $users = ModUtil::func('IWmain', 'user', 'getAllUsersInfo', array('info' => 'ccn', 'sv' => $sv, 'list' => $usersList)); return $this->view->assign('temes_MS', $temes_MS) ->assign('users', $users) ->assign('tema', $tema) ->assign('saved', $saved) ->assign('permisos', $permissions) ->assign('saved', $saved) ->assign('anotacions', $anotacions) ->assign('loggedIn', UserUtil::isLoggedIn()) ->assign('notRegisteredSeeRedactors', ModUtil::getVar('IWnoteboard', 'notRegisteredSeeRedactors')) ->fetch('IWnoteboard_user_main.tpl'); }