/** * display block * * @param array $blockinfo a blockinfo structure * @return output the rendered bock */ public function display($blockinfo) { // Security check if (!SecurityUtil::checkPermission('EZComments:MostCommentsBlock:', "{$blockinfo['bid']}::", ACCESS_READ)) { return false; } if (!ModUtil::load('EZComments')) { return false; } // Get variables from content block $vars = BlockUtil::varsFromContent($blockinfo['content']); // Defaults if (!isset($vars['numentries'])) { $vars['numentries'] = 5; } if (!isset($vars['showcount'])) { $vars['showcount'] = false; } $options = array('numitems' => $vars['numentries']); if (isset($vars['mod']) && $vars['mod'] != '*') { $options['mod'] = $vars['mod']; } // get the comments $items = $this->MostCommentsBlock_getall($options); // augment the info $comments = ModUtil::apiFunc('EZComments', 'user', 'prepareCommentsForDisplay', $items); $this->view->assign($vars); $this->view->assign('comments', $comments); // Populate block info and pass to theme $blockinfo['content'] = $this->view->fetch('ezcomments_block_mostcomments.tpl'); return BlockUtil::themesideblock($blockinfo); }
/** * display block * * @param array $blockinfo a blockinfo structure * @return output the rendered bock */ public function display($blockinfo) { // Security check if (!SecurityUtil::checkPermission('EZComments:EZCommentsblock:', "{$blockinfo['bid']}::", ACCESS_READ)) { return false; } if (!ModUtil::load('EZComments')) { return false; } // Get variables from content block $vars = BlockUtil::varsFromContent($blockinfo['content']); // Defaults if (!isset($vars['numentries'])) { $vars['numentries'] = 5; } if (!isset($vars['numdays'])) { $vars['numdays'] = 0; } if (!isset($vars['showdate'])) { $vars['showdate'] = 0; } if (!isset($vars['showusername'])) { $vars['showusername'] = 0; } if (!isset($vars['linkusername'])) { $vars['linkusername'] = 0; } $options = array('numitems' => $vars['numentries']); if (isset($vars['mod']) && $vars['mod'] != '*') { $options['mod'] = $vars['mod']; } if (!isset($vars['showpending']) || $vars['showpending'] == 0) { // don't show pending comments $options['status'] = 0; } // filter comments posted in last number of days if ($vars['numdays'] > 0) { // date for filtering in format: yyyy-mm-dd hh:mm:ss $options['addwhere'] = "date>='" . DateUtil::getDatetime_NextDay(-$vars['numdays']) . "'"; } // get the comments $items = ModUtil::apiFunc('EZComments', 'user', 'getall', $options); // augment the info $comments = ModUtil::apiFunc('EZComments', 'user', 'prepareCommentsForDisplay', $items); $this->view->assign($vars); $this->view->assign('comments', $comments); // Populate block info and pass to theme $blockinfo['content'] = $this->view->fetch('ezcomments_block_ezcomments.tpl'); return BlockUtil::themesideblock($blockinfo); }
/** * 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); }
/** * Gets user news * * @return el bloc de novetats */ public function display($blockinfo) { // Security check if (!SecurityUtil::checkPermission('Cataleg::', '::', ACCESS_READ)) return; // Check if the module is available if (!ModUtil::available('Cataleg')) return; $renderedOutput = ''; // Get the view object $view = Zikula_View::getInstance('Cataleg', false); $novetats = ModUtil::apiFunc($this->name, 'user', 'getNovetats'); if ($novetats['novetats'] || $novetats['canvis']) { $view->assign('novetats', $novetats); $s = $view->fetch('block/Cataleg_block_Novetats.tpl'); $blockinfo['content'] = $s; $renderedOutput = BlockUtil::themesideblock($blockinfo); } return $renderedOutput; }
public function display($blockinfo) { // Security check if (!SecurityUtil::checkPermission('IWagendas:nextblock:', $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 headlines saved in the user vars. It is renovate every 10 minutes $sv = ModUtil::func('IWmain', 'user', 'genSecurityValue'); $exists = ModUtil::apiFunc('IWmain', 'user', 'userVarExists', array('name' => 'next', 'module' => 'IWagendas', 'uid' => $user, 'sv' => $sv)); //$exists = false; if ($exists) { $sv = ModUtil::func('IWmain', 'user', 'genSecurityValue'); $s = ModUtil::func('IWmain', 'user', 'userGetVar', array('uid' => $user, 'name' => 'next', 'module' => 'IWagendas', 'sv' => $sv, 'nult' => true)); $blockinfo['content'] = $s; return BlockUtil::themesideblock($blockinfo); } // Get the view object $view = Zikula_View::getInstance('IWagendas', false); // Get the number of days in which the future events will be shown $days = $blockinfo['url']; // Get the annotations in the following days $texts = ModUtil::apiFunc('IWagendas', 'user', 'getEvents', array('inici' => time(), 'final' => time() + $days * 24 * 60 * 60)); foreach ($texts as $text) { $datafield = str_replace("\r", '', str_replace('\'', '´', $text['c1'])); // replace any newlines that aren't preceded by a > with a <br /> $datafield = preg_replace('/(?<!>)\n/', "<br />", $datafield); $title = ($text['tasca']) ? $this->__('Task') . ' - ' . $text['nivell'] : ($text['totdia'] == 1) ? $this->__('All day') : date('H:i', $text['data']); $date = date('d/m', $text['data']); $events[] = array('date' => $date, 'title' => $title, 'deleted' => $text['deleted'], 'modified' => $text['modified'], 'datafield' => $datafield); } if (count($texts) == 0) { $events[] = array('date' => '', 'title' => '', 'deleted' => 0, 'modified' => 0, 'datafield' => $this->__('There are no events in the agenda for the next ') . ' ' . $days . ' ' . $this->__(' days'), ); } $view->assign('events', $events); $view->assign('days', $days); $s = $view->fetch('IWagendas_block_next.htm'); //Copy the block information into user vars $sv = ModUtil::func('IWmain', 'user', 'genSecurityValue'); ModUtil::func('IWmain', 'user', 'userSetVar', array('uid' => $user, 'name' => 'next', 'module' => 'IWagendas', 'sv' => $sv, 'value' => $s, 'lifetime' => '700')); $blockinfo['content'] = $s; return BlockUtil::themesideblock($blockinfo); }
/** * Show the list of forms for choosed categories * @autor: Albert Pérez Monfort * return: The list of forms */ public function display($blockinfo) { // Security check if (!SecurityUtil::checkPermission("IWstats:usersonlineblock:", "::", ACCESS_READ)) { return; } // Check if the module is available if (!ModUtil::available('IWstats')) { return; } $uid = (UserUtil::isLoggedIn()) ? UserUtil::getVar('uid') : '-1'; $sv = ModUtil::func('IWmain', 'user', 'genSecurityValue'); $exists = ModUtil::apiFunc('IWmain', 'user', 'userVarExists', array('name' => 'usersonlineblock', 'module' => 'IWstats', 'uid' => $uid, 'sv' => $sv)); //$exists = false; if ($exists) { $sv = ModUtil::func('IWmain', 'user', 'genSecurityValue'); $s = ModUtil::func('IWmain', 'user', 'userGetVar', array('uid' => $uid, 'name' => 'usersonlineblock', 'module' => 'IWstats', 'sv' => $sv, 'nult' => true)); // Create output object $view = Zikula_View::getInstance('IWstats', false); $blockinfo['content'] = $s; return BlockUtil::themesideblock($blockinfo); } // get block parameters $content = unserialize($blockinfo['content']); $sessiontime = $content['sessiontime']; $refreshtime = $content['refreshtime']; $unsee = $content['unsee']; $time = time(); $time0 = $time - $sessiontime * 60; $fromDate = date('d-m-Y H:i:s', $time0); $toDate = date('d-m-Y H:i:s', $time); $records = ModUtil::apiFunc('IWstats', 'user', 'getAllRecords', array('rpp' => -1, 'init' => -1, 'fromDate' => $fromDate, 'toDate' => $toDate, 'all' => 1, 'timeIncluded' => 1, )); $users = array(); $ipArray = array(); $usersArray = array(); $usersList = ''; // get the number of validated users and the number of different Ips detected foreach ($records as $record) { if (!in_array($record['ip'], $ipArray)) { $ipArray[] = $record['ip']; } if (!in_array($record['uid'], $usersArray) && $record['uid'] > 0) { $usersArray[] = $record['uid']; $usersList .= $record['uid'] . '$$'; } } $online = count($ipArray) - count($usersArray); $seeunames = ($unsee == 1 || $uid > 0) ? 1 : 0; if ($seeunames && count($usersArray) > 0) { $sv = ModUtil::func('IWmain', 'user', 'genSecurityValue'); $users = ModUtil::func('IWmain', 'user', 'getAllUsersInfo', array('info' => 'ncc', 'sv' => $sv, 'list' => $usersList)); } // create output object $view = Zikula_View::getInstance('IWstats', false); $view->assign('seeunames', $seeunames); $view->assign('users', $users); $view->assign('online', $online); $view->assign('validated', count($usersArray)); $s = $view->fetch('IWstats_block_usersonline.htm'); // copy the block information into user vars $sv = ModUtil::func('IWmain', 'user', 'genSecurityValue'); ModUtil::func('IWmain', 'user', 'userSetVar', array('uid' => $uid, 'name' => 'usersonlineblock', 'module' => 'IWstats', 'sv' => $sv, 'value' => $s, 'lifetime' => $refreshtime)); // Populate block info and pass to theme $blockinfo['content'] = $s; return BlockUtil::themesideblock($blockinfo); }
/** * Show the list of forms for choosed categories * @autor: Albert Pérez Monfort * return: The list of forms */ public function display($blockinfo) { // Security check if (!SecurityUtil::checkPermission("IWforms:formslistblock:", $blockinfo['title'] . "::", ACCESS_READ)) { return; } // Check if the module is available if (!ModUtil::available('IWforms')) { return; } $uid = (UserUtil::isLoggedIn()) ? UserUtil::getVar('uid') : '-1'; //get the headlines saved in the user vars. It is renovate every 10 minutes $sv = ModUtil::func('IWmain', 'user', 'genSecurityValue'); $exists = ModUtil::apiFunc('IWmain', 'user', 'userVarExists', array('name' => 'formsListBlock' . $blockinfo['bid'], 'module' => 'IWforms', 'uid' => $uid, 'sv' => $sv)); $sv = ModUtil::func('IWmain', 'user', 'genSecurityValue'); $have_flags = ModUtil::func('IWmain', 'user', 'userGetVar', array('uid' => $uid, 'name' => 'have_flags', 'module' => 'IWmain_block_flagged', 'sv' => $sv)); // $exists = false; if ($exists && $have_flags != 'fr') { $sv = ModUtil::func('IWmain', 'user', 'genSecurityValue'); $s = ModUtil::func('IWmain', 'user', 'userGetVar', array('uid' => $uid, 'name' => 'formsListBlock' . $blockinfo['bid'], 'module' => 'IWforms', 'sv' => $sv, 'nult' => true)); $blockinfo['content'] = $s; return BlockUtil::themesideblock($blockinfo); } $userGroupsArray = array(); //get all the active forms $forms = ModUtil::apiFunc('IWforms', 'user', 'getAllForms', array('user' => 1)); //get all the groups of the user $sv = ModUtil::func('IWmain', 'user', 'genSecurityValue'); $userGroups = ModUtil::func('IWmain', 'user', 'getAllUserGroups', array('uid' => $uid, 'sv' => $sv)); foreach ($userGroups as $group) { $userGroupsArray[] = $group['id']; } $flagged = ModUtil::apiFunc('IWforms', 'user', 'getWhereFlagged'); $validation = ModUtil::apiFunc('IWforms', 'user', 'getWhereNeedValidation'); $values = unserialize($blockinfo['content']); //get categories $cats = explode('|', $values['categories']); $catsString = '$'; foreach ($cats as $cat) { if ($cat != '') { $catsString .= '$' . $cat . '$'; } } //Filter the forms where the user can access $forms_array = array(); foreach ($forms as $form) { if ($catsString == '$' || strpos($catsString, '$' . $form['cid'] . '$') != false) { $access = ModUtil::func('IWforms', 'user', 'access', array('fid' => $form['fid'], 'userGroups' => $userGroupsArray)); if ($access['level'] != 0) { $isFlagged = (array_key_exists($form['fid'], $flagged)) ? 1 : 0; $needValidation = (array_key_exists($form['fid'], $validation)) ? 1 : 0; $new = ModUtil::func('IWforms', 'user', 'makeTimeForm', $form['new']); $new = mktime(23, 59, 00, substr($new, 3, 2), substr($new, 0, 2), substr($new, 6, 2)); $newLabel = ($new > time()) ? true : false; $formShortName = (strlen($form['formName']) > 17) ? $formShortName = mb_strimwidth($form['formName'], 0, 18, '...') : $formShortName = $form['formName']; $formName = ($values['listBox'] == 1) ? $formShortName : $form['formName']; //Whit all the information create the array to output $forms_array[] = array('formName' => $formName, 'title' => $form['title'], 'accessLevel' => $access['level'], 'closeableInsert' => $form['closeableInsert'], 'isFlagged' => $isFlagged, 'needValidation' => $needValidation, 'closeInsert' => $form['closeInsert'], 'newLabel' => $newLabel, 'defaultValidation' => $access['defaultValidation'], 'fid' => $form['fid']); } } } // Create output object $view = Zikula_View::getInstance('IWforms', false); $view->assign('forms', $forms_array); $view->assign('listBox', $values['listBox']); $s = $view->fetch('IWforms_block_formsList.tpl'); //Copy the block information into user vars $sv = ModUtil::func('IWmain', 'user', 'genSecurityValue'); ModUtil::func('IWmain', 'user', 'userSetVar', array('uid' => $uid, 'name' => 'formsListBlock' . $blockinfo['bid'], 'module' => 'IWforms', 'sv' => $sv, 'value' => $s, 'lifetime' => '750')); // Populate block info and pass to theme $blockinfo['content'] = $s; return BlockUtil::themesideblock($blockinfo); }
/** * 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); }
/** * Gets topics information * * @author Albert Pï¿œrez Monfort (aperezm@xtec.cat) */ public function display($row) { // Security check if (!SecurityUtil::checkPermission('IWnoteboard:nbtopicsBlock:', $row['title'] . "::", ACCESS_READ)) { return false; } if (!UserUtil::isLoggedIn()) { return false; } $uid = UserUtil::getVar('uid'); //get the headlines saved in the user vars. It is renovate every 10 minutes $sv = ModUtil::func('IWmain', 'user', 'genSecurityValue'); $exists = ModUtil::apiFunc('IWmain', 'user', 'userVarExists', array('name' => 'nbtopics', 'module' => 'IWnoteboard', 'uid' => $uid, 'sv' => $sv)); if ($exists) { $sv = ModUtil::func('IWmain', 'user', 'genSecurityValue'); $s = ModUtil::func('IWmain', 'user', 'userGetVar', array('uid' => $uid, 'name' => 'nbtopics', 'module' => 'IWnoteboard', 'sv' => $sv, 'nult' => true)); $row['content'] = $s; return BlockUtil::themesideblock($row); } $view = Zikula_View::getInstance('IWnoteboard', false); $temes = ModUtil::apiFunc('IWnoteboard', 'user', 'getalltemes'); $en_te = false; foreach ($temes as $untema) { $sv = ModUtil::func('IWmain', 'user', 'genSecurityValue'); if (ModUtil::func('IWmain', 'user', 'isMember', array('uid' => UserUtil::getVar('uid'), 'gid' => $untema['grup'], 'sv' => $sv))) { $temes0[] = array('tid' => $untema['tid'], 'nomtema' => $untema['nomtema']); $en_te = true; } } if (!$en_te) { return false; } $view->assign('temes', $temes0); $s = $view->fetch('IWnoteboard_block_topics.tpl'); //Copy the block information into user vars $sv = ModUtil::func('IWmain', 'user', 'genSecurityValue'); ModUtil::func('IWmain', 'user', 'userSetVar', array('uid' => $uid, 'name' => 'nbtopics', 'module' => 'IWnoteboard', 'sv' => $sv, 'value' => $s, 'lifetime' => '2000')); $row['content'] = $s; return BlockUtil::themesideblock($row); }
/** * alias to BlockUtil::themesideblock() * * @deprecated * @see BlockUtil::themesideblock() */ function themesideblock($row) { LogUtil::log(__f('Warning! Function %1$s is deprecated. Please use %2$s instead.', array(__FUNCTION__, 'BlockUtil::themesideblock()')), E_USER_DEPRECATED); return BlockUtil::themesideblock($row); }
/** * Gets headlines information * * @author Albert Pᅵrez Monfort (aperezm@xtec.cat) */ public function display($row) { // Security check if (!SecurityUtil::checkPermission('IWnoteboard:nbheadlinesBlock:', $row['title'] . "::", ACCESS_READ)) { return false; } $uid = UserUtil::getVar('uid'); if (!isset($uid)) { $uid = '-1'; } //get the headlines saved in the user vars. It is renovate every 10 minutes $sv = ModUtil::func('IWmain', 'user', 'genSecurityValue'); $exists = ModUtil::apiFunc('IWmain', 'user', 'userVarExists', array('name' => 'nbheadlines', 'module' => 'IWnoteboard', 'uid' => $uid, 'sv' => $sv)); if ($exists) { $sv = ModUtil::func('IWmain', 'user', 'genSecurityValue'); $s = ModUtil::func('IWmain', 'user', 'userGetVar', array('uid' => $uid, 'name' => 'nbheadlines', 'module' => 'IWnoteboard', 'sv' => $sv, 'nult' => true)); $row['content'] = $s; return BlockUtil::themesideblock($row); } $view = Zikula_View::getInstance('IWnoteboard', false); //Cridem la funciᅵ API que retornarᅵ la informaciᅵ dels tᅵtulars de les notᅵcies $registres = ModUtil::apiFunc('IWnoteboard', 'user', 'getalltitulars'); // Get all users information needed $sv = ModUtil::func('IWmain', 'user', 'genSecurityValue'); $usersFullname = ModUtil::func('IWmain', 'user', 'getAllUsersInfo', array('info' => 'nc', 'sv' => $sv)); $en_te = false; $n = 0; foreach ($registres as $registre) { $permisos = ModUtil::apiFunc('IWnoteboard', 'user', 'permisos', array('uid' => $uid)); //separem la llista de grups que tenen accᅵs a la notᅵcia i ho posem en una matriu $grups_acces = explode('$', $registre['destinataris']); $esta_en_grups_acces = array_intersect($grups_acces, $permisos['grups']); $pos = strpos($registre['no_mostrar'], '$' . $uid . '$'); if (($registre['verifica'] == 1 && count($esta_en_grups_acces) >= 1 && $pos == 0)) { if ($registre['tid'] == 0) { $tema = $this->__('Not classified'); $registre['tid'] = -1; } else { //Recollim el nom del tema $temes = ModUtil::apiFunc('IWnoteboard', 'user', 'gettema', array('tid' => $registre['tid'])); $sv = ModUtil::func('IWmain', 'user', 'genSecurityValue'); if (ModUtil::func('IWmain', 'user', 'isMember', array('uid' => UserUtil::getVar('uid'), 'gid' => $temes['grup'], 'sv' => $sv))) { $tema = $temes['nomtema']; } else { $tema = $this->__('Not classified'); } } if ($tema == "") { $tema = $this->__('Topic not found'); } $n++; $bgcolor = ($n % 2 == 0) ? ModUtil::getVar('IWnoteboard', 'colorrow1') : ModUtil::getVar('IWnoteboard', 'colorrow2'); $titulars[] = array('tid' => $registre['tid'], 'nid' => $registre['nid'], 'titular' => DataUtil::formatForDisplayHTML($registre['titular']), 'tema' => $tema, 'bgcolor' => $bgcolor, 'informa' => $usersFullname[$registre['informa']]); $en_te = true; } } if (!$en_te) { return false; } $view->assign('titulars', $titulars); $view->assign('notRegisteredSeeRedactors', ModUtil::getVar('IWnoteboard', 'notRegisteredSeeRedactors')); $view->assign('loggedIn', UserUtil::isLoggedIn()); $s = $view->fetch('IWnoteboard_block_headlines.tpl'); //Copy the block information into user vars $sv = ModUtil::func('IWmain', 'user', 'genSecurityValue'); ModUtil::func('IWmain', 'user', 'userSetVar', array('uid' => $uid, 'name' => 'nbheadlines', 'module' => 'IWnoteboard', 'sv' => $sv, 'value' => $s, 'lifetime' => '500')); $row['content'] = $s; return BlockUtil::themesideblock($row); }
/** * Show the list of activies where the user can access * @autor: Albert Pérez Monfort * return: The list of activities */ public function display($blockinfo) { // Security check if (!SecurityUtil::checkPermission("IWjclic:jclicblock:", $blockinfo['title'] . "::", ACCESS_READ)) { return; } // Check if the module is available and user is lock in if (!ModUtil::available('IWjclic') || !UserUtil::isLoggedIn()) { return; } $uid = (UserUtil::isLoggedIn()) ? UserUtil::getVar('uid') : '-1'; //get the headlines saved in the user vars. It is renovate every 10 minutes $sv = ModUtil::func('IWmain', 'user', 'genSecurityValue'); $exists = ModUtil::apiFunc('IWmain', 'user', 'userVarExists', array('name' => 'jclicBlock', 'module' => 'IWjclic', 'uid' => $uid, 'sv' => $sv)); //$exists = false; if ($exists) { $sv = ModUtil::func('IWmain', 'user', 'genSecurityValue'); $s = ModUtil::func('IWmain', 'user', 'userGetVar', array('uid' => $uid, 'name' => 'jclicBlock', 'module' => 'IWjclic', 'sv' => $sv, 'nult' => true)); $blockinfo['content'] = $s; return BlockUtil::themesideblock($blockinfo); } $jclicStudent_array = array(); $jclicTeacher_array = array(); //get the activities that the user has assigned to other users $activitiesAssigned = ModUtil::apiFunc('IWjclic', 'user', 'getAllActivitiesAssigned'); $sv = ModUtil::func('IWmain', 'user', 'genSecurityValue'); $allGroups = ModUtil::func('IWmain', 'user', 'getAllGroups', array('sv' => $sv)); foreach ($allGroups as $group) { $allGroupsArray[$group['id']] = $group['name']; } foreach ($activitiesAssigned as $activity) { //get assigned groups $groups = ModUtil::apiFunc('IWjclic', 'user', 'getGroups', array('jid' => $activity['jid'])); $groupsString = ''; if (count($groups) > 0) { foreach ($groups as $group) { $groupsString .= $allGroupsArray[$group['group_id']] . '<br />'; } } $jclicTeacher_array[] = array('name' => $activity['name'], 'jid' => $activity['jid']); } //get the activities that the user have got assigned $activities = ModUtil::apiFunc('IWjclic', 'user', 'getAllActivities'); foreach ($activities as $activity) { $content = ModUtil::func('IWjclic', 'user', 'getActivityContent', array('jid' => $activity['jid'])); if ($content['state'] == 1) { $jclicStudent_array[] = $content; } } // Create output object $view = Zikula_View::getInstance('IWjclic', false); $view->assign('jclicTeacher', $jclicTeacher_array); $view->assign('jclicStudent', $jclicStudent_array); $s = $view->fetch('IWjclic_block_jclic.htm'); //Copy the block information into user vars $sv = ModUtil::func('IWmain', 'user', 'genSecurityValue'); ModUtil::func('IWmain', 'user', 'userSetVar', array('uid' => $uid, 'name' => 'jclicBlock', 'module' => 'IWjclic', 'sv' => $sv, 'value' => $s, 'lifetime' => '950')); // Populate block info and pass to theme $blockinfo['content'] = $s; return BlockUtil::themesideblock($blockinfo); }
/** * Gets topics information * * @author Albert Pérez Monfort (aperezm@xtec.cat) * @author Josep Ferràndiz Farré (jferran6@xtec.cat) */ public function display($row) { // Security check if (!SecurityUtil::checkPermission('IWmyrole::', "::", ACCESS_ADMIN)) { return false; } $uid = UserUtil::getVar('uid'); //Check if user belongs to change group. If not the block is not showed $sv = ModUtil::func('IWmain', 'user', 'genSecurityValue'); $isMember = ModUtil::func('IWmain', 'user', 'isMember', array('sv' => $sv, 'gid' => ModUtil::getVar('IWmyrole', 'rolegroup'), 'uid' => $uid)); if (!$isMember) { return false; } $sv = ModUtil::func('IWmain', 'user', 'genSecurityValue'); $uidGroups = ModUtil::func('IWmain', 'user', 'getAllUserGroups', array('sv' => $sv, 'uid' => $uid)); foreach ($uidGroups as $g) { $originalGroups[$g['id']] = 1; } $view = Zikula_View::getInstance('IWmyrole', false); // Gets the groups $sv = ModUtil::func('IWmain', 'user', 'genSecurityValue'); $allGroups = ModUtil::func('IWmain', 'user', 'getAllGroups', array('sv' => $sv, 'less' => ModUtil::getVar('IWmyrole', 'rolegroup'))); $groupsNotChangeable = ModUtil::getVar('IWmyrole', 'groupsNotChangeable'); foreach ($allGroups as $group) { if (strpos($groupsNotChangeable, '$' . $group['id'] . '$') == false) $groupsArray[] = $group; } $sv = ModUtil::func('IWmain', 'user', 'genSecurityValue'); $invalidChange = ModUtil::func('IWmain', 'user', 'userGetVar', array('uid' => $uid, 'name' => 'invalidChange', 'module' => 'IWmyrole', 'nult' => true, 'sv' => $sv)); $view->assign('groups', $groupsArray); $view->assign('invalidChange', $invalidChange); $view->assign('roleGroups', $originalGroups); $s = $view->fetch('IWmyrole_block_change.htm'); $row['content'] = $s; return BlockUtil::themesideblock($row); }
/** * Gets user news * * @author Albert Pérez Monfort (aperezm@xtec.cat) * @return The user news block */ public function display($row) { // Security check if (!SecurityUtil::checkPermission('IWmain:newsBlock:', $row['title'] . "::", ACCESS_READ) || !UserUtil::isLoggedIn()) { return false; } if (ModUtil::getVar('IWmain', 'URLBase') != System::getBaseUrl()) { ModUtil::setVar('IWmain', 'URLBase', System::getBaseUrl()); } $uid = UserUtil::getVar('uid'); //get the headlines saved in the user vars. It is renovate every 10 minutes $sv = ModUtil::func('IWmain', 'user', 'genSecurityValue'); $exists = ModUtil::apiFunc('IWmain', 'user', 'userVarExists', array('name' => 'news', 'module' => 'IWmain_block_news', 'uid' => $uid, 'sv' => $sv)); if ($exists) { $sv = ModUtil::func('IWmain', 'user', 'genSecurityValue'); $have_news = ModUtil::func('IWmain', 'user', 'userGetVar', array('uid' => $uid, 'name' => 'have_news', 'module' => 'IWmain_block_news', 'sv' => $sv)); if ($have_news != '0') { ModUtil::func('IWmain', 'user', 'news', array('where' => $have_news)); $sv = ModUtil::func('IWmain', 'user', 'genSecurityValue'); ModUtil::func('IWmain', 'user', 'userSetVar', array('uid' => $uid, 'name' => 'have_news', 'module' => 'IWmain_block_news', 'sv' => $sv, 'value' => '0')); } $sv = ModUtil::func('IWmain', 'user', 'genSecurityValue'); $have_flags = ModUtil::func('IWmain', 'user', 'userGetVar', array('uid' => UserUtil::getVar('uid'), 'name' => 'have_flags', 'module' => 'IWmain_block_flagged', 'sv' => $sv)); if ($have_flags != '0') { ModUtil::func('IWmain', 'user', 'flagged', array('where' => $have_flags, 'chars' => 15)); $sv = ModUtil::func('IWmain', 'user', 'genSecurityValue'); ModUtil::func('IWmain', 'user', 'userSetVar', array('uid' => UserUtil::getVar('uid'), 'name' => 'have_flags', 'module' => 'IWmain_block_flagged', 'sv' => $sv, 'value' => '0')); } } else { ModUtil::func('IWmain', 'user', 'news'); } //get the flagged items $sv = ModUtil::func('IWmain', 'user', 'genSecurityValue'); if (!$exists = ModUtil::apiFunc('IWmain', 'user', 'userVarExists', array('name' => 'flagged', 'module' => 'IWmain_block_flagged', 'uid' => $uid, 'sv' => $sv))) { ModUtil::func('IWmain', 'user', 'flagged', array('where' => '', 'chars' => 15)); } $sv = ModUtil::func('IWmain', 'user', 'genSecurityValue'); $news = ModUtil::func('IWmain', 'user', 'userGetVar', array('uid' => $uid, 'name' => 'news', 'module' => 'IWmain_block_news', 'sv' => $sv, 'nult' => true)); $sv = ModUtil::func('IWmain', 'user', 'genSecurityValue'); $flags = ModUtil::func('IWmain', 'user', 'userGetVar', array('uid' => UserUtil::getVar('uid'), 'name' => 'flagged', 'module' => 'IWmain_block_flagged', 'sv' => $sv, 'nult' => true)); $this->view->assign('news', $news) ->assign('flags', $flags); $s = $this->view->fetch('IWmain_block_IWnews.tpl'); $row['content'] = $s; return BlockUtil::themesideblock($row); }
public function display($row) { // Security check if (!SecurityUtil::checkPermission('IWnoteboard:nbentriesBlock:', $row['title'] . "::", ACCESS_READ)) { return false; } $uid = UserUtil::getVar('uid'); if (!isset($uid)) $uid = '-1'; //get the headlines saved in the user vars. It is renovate every 10 minutes $sv = ModUtil::func('IWmain', 'user', 'genSecurityValue'); $exists = ModUtil::apiFunc('IWmain', 'user', 'userVarExists', array('name' => 'nbentries', 'module' => 'IWnoteboard', 'uid' => $uid, 'sv' => $sv)); //$exists = false; if ($exists) { $sv = ModUtil::func('IWmain', 'user', 'genSecurityValue'); $s = ModUtil::func('IWmain', 'user', 'userGetVar', array('uid' => $uid, 'name' => 'nbentries', 'module' => 'IWnoteboard', 'sv' => $sv, 'nult' => true)); $row['content'] = $s; return BlockUtil::themesideblock($row); } $notesArray = array(); $view = Zikula_View::getInstance('IWnoteboard', false); $notes = ModUtil::apiFunc('IWnoteboard', 'user', 'getall', array('numitems' => 7)); foreach ($notes as $note) { $notesArray[] = array('content' => $note['noticia'], 'mes_info' => $note['mes_info'], 'text' => $note['text']); } if (count($notesArray) == 0) return false; $view->assign('notesArray', $notesArray); $s = $view->fetch('IWnoteboard_block_entries.tpl'); //Copy the block information into user vars $sv = ModUtil::func('IWmain', 'user', 'genSecurityValue'); ModUtil::func('IWmain', 'user', 'userSetVar', array('uid' => $uid, 'name' => 'nbentries', 'module' => 'IWnoteboard', 'sv' => $sv, 'value' => $s, 'lifetime' => '500')); $row['content'] = $s; return BlockUtil::themesideblock($row); }
/** * Gets qv summary information * * @author: Sara Arjona Téllez (sarjona@xtec.cat) */ function IWqv_qvsummaryblock_display($row) { // Security check if (!SecurityUtil::checkPermission('IWqv:summaryBlock:', $row['title'] . "::", ACCESS_READ) || !UserUtil::isLoggedIn()) { return false; } $uid = UserUtil::getVar('uid'); if (!isset($uid)) $uid = '-1'; // Get the qvsummary saved in the user vars. It is renovate every 10 minutes $sv = ModUtil::func('IWmain', 'user', 'genSecurityValue'); $exists = ModUtil::apiFunc('IWmain', 'user', 'userVarExists', array('name' => 'qvsummary', 'module' => 'IWqv', 'uid' => $uid, 'sv' => $sv)); if ($exists) { $sv = ModUtil::func('IWmain', 'user', 'genSecurityValue'); $s = ModUtil::func('IWmain', 'user', 'userGetVar', array('uid' => $uid, 'name' => 'qvsummary', 'module' => 'IWqv', 'sv' => $sv, 'nult' => true)); } else { $teacherassignments = ModUtil::apiFunc('IWqv', 'user', 'getall', array("teacher" => $uid)); $studentassignments = ModUtil::apiFunc('IWqv', 'user', 'getall', array("student" => $uid)); if (empty($teacherassignments) && empty($studentassignments)) { } $view = Zikula_View::getInstance('IWqv', false); $view->assign('teacherassignments', $teacherassignments); $view->assign('studentassignments', $studentassignments); $view->assign('isblock', true); $s = $view->fetch('IWqv_block_summary.htm'); if (empty($teacherassignments) && empty($studentassignments)) { $s = ''; } //Copy the block information into user vars $sv = ModUtil::func('IWmain', 'user', 'genSecurityValue'); ModUtil::func('IWmain', 'user', 'userSetVar', array('uid' => $uid, 'name' => 'qvsummary', 'module' => 'IWqv', 'sv' => $sv, 'value' => $s, 'lifetime' => '2000')); } if ($s == '') { return false; } $row['content'] = $s; return BlockUtil::themesideblock($row); }
/** * Display block */ public function display($blockinfo) { if (!SecurityUtil::checkPermission('ZphpBB2_Lastposts::', $blockinfo[bid] . "::", ACCESS_READ)) { return; } if (!ModUtil::available('ZphpBB2')) { return; } // Get variables from content block $vars = BlockUtil::varsFromContent($blockinfo['content']); // Implementation cached content $enable_cache = true; $write_to_cache = false; # flag $cache_time = 180; # seconds if (isset($vars['cache_time'])) { $cache_time = $vars['cache_time']; } $content = ""; if ($enable_cache and $cache_time > 0) { $cachefilestem = 'ZphpBB2_' . $blockinfo['bid']; $cachedir = System::getVar('temp'); if (StringUtil::right($cachedir, 1) != '/') { $cachedir .= '/'; } if (isset($vars['cache_dir']) and !empty($vars['cache_dir'])) { $cachedir .= $vars['cache_dir']; } else { $cachedir .= 'any_cache'; } $cachefile = $cachedir . '/' . $cachefilestem; // attempt to load from cache if (file_exists($cachefile)) { $file_time = filectime($cachefile); $now = time(); $diff = $now - $file_time; if ($diff <= $cache_time) { $content = file_get_contents($cachefile); } } if (empty($content)) { $write_to_cache = true; } # not loaded, flag to write to cache later } if (empty($content)) { // Create output object $connection = Doctrine_Manager::getInstance()->getCurrentConnection(); $table_prefix = ModUtil::getVar('ZphpBB2', 'table_prefix', 'phpbb_'); // include some files define('IN_PHPBB', true); $phpbb_root_path = 'modules/ZphpBB2/vendor/phpBB2/'; include_once $phpbb_root_path . "includes/constants.php"; $blockinfo['content'] = ""; // Defaults some things if they are empty! $vars['last_X_posts'] = $vars['last_X_posts'] ? $vars['last_X_posts'] : "5"; //do we want every topic to appear just once? $connkeys = $vars['group_topics'] ? "" . TOPICS_TABLE . ".topic_last_post_id = " . POSTS_TABLE . ".post_id" : "" . TOPICS_TABLE . ".topic_id = " . POSTS_TABLE . ".topic_id"; //limit to certain forums? if (!is_null($vars['excluded_forums']) && is_array($vars['excluded_forums'])) { $excluded_forums = in_array("", $vars['excluded_forums']) ? "" : "AND " . FORUMS_TABLE . ".forum_id NOT IN (" . implode(", ", $vars['excluded_forums']) . ")"; } $lastvisit = 0; //list of forums user can see if private $viewforums = ""; //list of forums user can look into if private $readforums = ""; //list of forums where user is moderator $modforums = ""; //just for guests $userstate = 0; if (UserUtil::isLoggedIn()) { $uid = UserUtil::getVar('uid'); //permission level for registered users $userstate = AUTH_REG; //are you an board admin? $query = "SELECT user_level, user_lastvisit FROM " . USERS_TABLE . " WHERE user_id = {$uid}"; $stmt = $connection->prepare($query); $stmt->execute(); $result = $stmt->fetchAll(Doctrine_Core::FETCH_ASSOC); list($level, $lastvisit) = $result[0]; if ($level == ADMIN) { //user have complete access $userstate = AUTH_ADMIN; } else { $query = "SELECT " . AUTH_ACCESS_TABLE . ".forum_id,\n max(" . AUTH_ACCESS_TABLE . ".auth_view), \n max(" . AUTH_ACCESS_TABLE . ".auth_read), \n max(" . AUTH_ACCESS_TABLE . ".auth_mod)\n FROM " . USER_GROUP_TABLE . " INNER JOIN " . AUTH_ACCESS_TABLE . " ON " . USER_GROUP_TABLE . ".group_id = " . AUTH_ACCESS_TABLE . ".group_id\n WHERE " . USER_GROUP_TABLE . ".user_id = {$uid}\n GROUP BY " . AUTH_ACCESS_TABLE . ".forum_id"; $stmt = $connection->prepare($query); $stmt->execute(); $result = $stmt->fetchAll(Doctrine_Core::FETCH_ASSOC); foreach ($result as $r) { list($forum_id, $auth_view, $auth_read, $auth_mod) = $r; //let's make a nice list of forums the user is allowed to view, read and moderate if ($auth_read | $auth_mod) { $readforums .= empty($readforums) ? $forum_id : ", " . $forum_id; } if ($auth_view | $auth_mod) { $viewforums .= empty($viewforums) ? $forum_id : ", " . $forum_id; } ", " . $forum_id; if ($auth_mod) { $modforums .= empty($modforums) ? $forum_id : ", " . $forum_id; } ", " . $forum_id; } } } //let's see if we can optimize the query $view_private = !empty($viewforums) ? " OR (" . FORUMS_TABLE . ".auth_view = " . AUTH_ACL . " AND " . TOPICS_TABLE . ".forum_id IN ({$viewforums})) " : ""; $read_private = !empty($readforums) ? " OR (" . FORUMS_TABLE . ".auth_read = " . AUTH_ACL . " AND " . TOPICS_TABLE . ".forum_id IN ({$readforums})) " : ""; if (!empty($modforums)) { $view_mod = " OR (" . FORUMS_TABLE . ".auth_view = " . AUTH_MOD . " AND " . TOPICS_TABLE . ".forum_id IN ({$modforums})) "; $read_mod = " OR (" . FORUMS_TABLE . ".auth_read = " . AUTH_MOD . " AND " . TOPICS_TABLE . ".forum_id IN ({$modforums})) "; } else { $view_mod = $read_mod = ""; } //now for the main query $query = "SELECT " . TOPICS_TABLE . ".topic_title, \n " . TOPICS_TABLE . ".topic_replies, \n " . TOPICS_TABLE . ".topic_views, \n " . TOPICS_TABLE . ".topic_id, \n " . USERS_TABLE . ".username, \n " . POSTS_TABLE . ".post_id, \n " . POSTS_TABLE . ".poster_id, \n " . POSTS_TABLE . ".post_time, \n " . FORUMS_TABLE . ".forum_id, \n " . FORUMS_TABLE . ".forum_name,\n " . CATEGORIES_TABLE . ".cat_title \n FROM ((" . TOPICS_TABLE . " \n INNER JOIN " . POSTS_TABLE . " ON {$connkeys}) \n INNER JOIN " . USERS_TABLE . " ON " . USERS_TABLE . ".user_id = " . POSTS_TABLE . ".poster_id) \n INNER JOIN " . FORUMS_TABLE . " ON " . FORUMS_TABLE . ".forum_id = " . TOPICS_TABLE . ".forum_id \n INNER JOIN " . CATEGORIES_TABLE . " ON " . CATEGORIES_TABLE . ".cat_id = " . FORUMS_TABLE . ".cat_id \n WHERE (" . FORUMS_TABLE . ".auth_view <= {$userstate} {$view_private} {$view_mod})\n AND (" . FORUMS_TABLE . ".auth_read <= {$userstate} {$read_private} {$read_mod}) {$excluded_forums} \n AND " . TOPICS_TABLE . ".topic_status <> " . TOPIC_MOVED . "\n ORDER BY post_time DESC LIMIT " . $vars['last_X_posts']; $stmt = $connection->prepare($query); $stmt->execute(); $items = $stmt->fetchAll(Doctrine_Core::FETCH_ASSOC); if (!$items) { $blockinfo['content'] = ''; return BlockUtil::themesideblock($blockinfo); } // get module information $modinfo = ModUtil::getInfoFromName("ZphpBB2"); //foreach ($items as $r) { foreach (array_keys($items) as $k) { $items[$k]['replyicon'] = 'modules/' . $modinfo['directory'] . '/images/' . ($lastvisit > 0 && $items[$k]['post_time'] > $lastvisit ? "icon_newest_reply.gif" : "icon_latest_reply.gif"); $items[$k]['post_username'] = $items[$k]['poster_id'] != ANONYMOUS ? $items[$k]['username'] : $this->__('Guest'); $items[$k]['profile_url'] = $items[$k]['poster_id'] != ANONYMOUS ? ModUtil::url('ZphpBB2', 'user', 'profile', array('mode' => 'viewprofile', 'u' => $items[$k]['poster_id'])) : ""; } } $render_template = 'blocks/lastposts.tpl'; if ($this->view->is_cached($render_template)) { $blockinfo['content'] = $this->view->fetch($render_template); } else { $this->view->assign($vars); $this->view->assign('items', $items); $this->view->assign('phpbb_root_path', $phpbb_root_path); $blockinfo['content'] = $this->view->fetch($render_template); } $content = BlockUtil::themesideblock($blockinfo); if ($write_to_cache and !empty($content)) { // attempt to write to cache if not loaded before if (!file_exists($cachedir)) { mkdir($cachedir, 0777); # attempt to make the dir } if (!file_put_contents($cachefile, $content)) { //echo "<br />Could not save data to cache. Please make sure your cache directory exists and is writable.<br />"; } } return $content; }