/** * Install the MUBoard application. * * @return boolean True on success, or false. */ public function install() { parent::install(); $uid = UserUtil::getVar('uid'); MUBoard_Util_View::actualUser($uid, 1); // update successful return true; }
/** * The muboardGetFileSize modifier displays the size of a given file in a readable way. * * @param string $size File size in bytes. * @param string $filepath The input file path including file name (if file size is not known). * @param boolean $nodesc If set to true the description will not be appended. * @param boolean $onlydesc If set to true only the description will be returned. * * @return string File size in a readable form. */ function smarty_modifier_muboardGetFileSize($size = 0, $filepath = '', $nodesc = false, $onlydesc = false) { if (!is_numeric($size)) { $size = (int) $size; } if (!$size) { if (empty($filepath) || !file_exists($filepath)) { return ''; } $size = filesize($filepath); } if (!$size) { return ''; } $result = MUBoard_Util_View::getReadableFileSize($size, $nodesc, $onlydesc); return $result; }
/** * The muboardGetLastPosting modifier return the last posting of a forum * @param int $id forum id * * @return string the output of last posting */ function smarty_modifier_muboardGetLastPosting($id) { $out = MUBoard_Util_View::getLastPostingOfForum($id); return $out; }
/** * The muboardgetNumberOfPostingsOfUser modifier returns the number * of postings of an user * * @param int $id user id * * @return int the output of number of posting */ function smarty_modifier_muboardGetNumberOfPostingsOfUser($id) { $out = MUBoard_Util_View::getNumberOfPostingsOfUser($id); return $out; }
/** * The muboardGetStateOfForumAbo return the state of abo. * * @param int $id forum id * * @return out html */ function smarty_modifier_muboardGetStateOfForumAbo($id, $view) { $out = MUBoard_Util_View::getStateOfForumAbo($id, $view); return $out; }
/** * The muboardGetImportantOfPosting return the an icon for important issues. * * @param int $id posting id * * @return id the number of postings */ function smarty_modifier_muboardGetImportantOfPosting($id) { $out = MUBoard_Util_View::getImportantOfPosting($id); return $out; }
/** * The muboardGetLastAnswer modifier return the last answer for aposting * @param int $id parent id * * @return string the output of last posting */ function smarty_modifier_muboardGetLastAnswer($id) { $out = MUBoard_Util_View::getLastAnswer($id); return $out; }
/** * This method provides a generic item detail view. * * @param string $ot Treated object type. * @param string $tpl Name of alternative template (for alternative display options, feeds and xml output) * @param boolean $raw Optional way to display a template instead of fetching it (needed for standalone output) * @return mixed Output. */ public function display($args) { // DEBUG: permission check aspect starts $this->throwForbiddenUnless(SecurityUtil::checkPermission('MUBoard::', '::', ACCESS_READ)); // DEBUG: permission check aspect ends // parameter specifying which type of objects we are treating $objectType = isset($args['ot']) && !empty($args['ot']) ? $args['ot'] : $this->request->getGet()->filter('ot', 'category', FILTER_SANITIZE_STRING); $utilArgs = array('controller' => 'user', 'action' => 'display'); if (!in_array($objectType, MUBoard_Util_Controller::getObjectTypes('controllerAction', $utilArgs))) { $objectType = MUBoard_Util_Controller::getDefaultObjectType('controllerAction', $utilArgs); } $repository = $this->entityManager->getRepository('MUBoard_Entity_' . ucfirst($objectType)); $idFields = ModUtil::apiFunc($this->name, 'selection', 'getIdFields', array('ot' => $objectType)); // retrieve identifier of the object we wish to view $idValues = MUBoard_Util_Controller::retrieveIdentifier($this->request, $args, $objectType, $idFields); $hasIdentifier = MUBoard_Util_Controller::isValidIdentifier($idValues); // check for unique permalinks (without id) $hasSlug = false; $slugTitle = ''; if ($hasIdentifier === false) { $entityClass = 'MUBoard_Entity_' . ucfirst($objectType); $objectTemp = new $entityClass(); $hasSlug = $objectTemp->get_hasUniqueSlug(); if ($hasSlug) { $slugTitle = isset($args['title']) && !empty($args['title']) ? $args['title'] : $this->request->getGet()->filter('title', '', FILTER_SANITIZE_STRING); $hasSlug = !empty($slugTitle); } } $hasIdentifier |= $hasSlug; $this->throwNotFoundUnless($hasIdentifier, $this->__('Error! Invalid identifier received.')); $entity = ModUtil::apiFunc($this->name, 'selection', 'getEntity', array('ot' => $objectType, 'id' => $idValues, 'slug' => $slugTitle)); $this->throwNotFoundUnless($entity != null, $this->__('No such item.')); // build ModUrl instance for display hooks $currentUrlArgs = array('ot' => $objectType); foreach ($idFields as $idField) { $currentUrlArgs[$idField] = $idValues[$idField]; } $currentUrlObject = new Zikula_ModUrl($this->name, 'user', 'display', ZLanguage::getLanguageCode(), $currentUrlArgs); // assign output data to view object. $this->view->assign($objectType, $entity)->assign('currentUrlObject', $currentUrlObject)->assign($repository->getAdditionalTemplateParameters('controllerAction', $utilArgs)); // fetch and return the appropriate template return MUBoard_Util_View::processTemplate($this->view, 'user', $objectType, 'display', $args); }
/** * Listener for the `module.users.ui.login.succeeded` event. * * Occurs right after a successful attempt to log in, and just prior to redirecting the user to the desired page. * All handlers are notified. * * The event subject contains the user's user record (from `UserUtil::getVars($event['uid'])`). * The arguments of the event are as follows: * `'authentication_module'` an array containing the authenticating module name (`'modname'`) and method (`'method'`) * used to log the user in. * `'redirecturl'` will contain the value of the 'returnurl' parameter, if one was supplied, or an empty * string. This can be modified to change where the user is redirected following the login. * * __The `'redirecturl'` argument__ controls where the user will be directed at the end of the log-in process. * Initially, it will be the value of the returnurl parameter provided to the log-in process, or blank if none was provided. * * The action following login depends on whether WCAG compliant log-in is enabled in the Users module or not. If it is enabled, * then the user is redirected to the returnurl immediately. If not, then the user is first displayed a log-in landing page, * and then meta refresh is used to redirect the user to the returnurl. * * If a `'redirecturl'` is specified by any entity intercepting and processing the `module.users.ui.login.succeeded` event, then * the URL provided replaces the one provided by the returnurl parameter to the login process. If it is set to an empty * string, then the user is redirected to the site's home page. An event handler should carefully consider whether * changing the `'redirecturl'` argument is appropriate. First, the user may be expecting to return to the page where * he was when he initiated the log-in process. Being redirected to a different page might be disorienting to the user. * Second, all event handlers are being notified of this event. This is not a `notify()` event. An event handler * that was notified prior to the current handler may already have changed the `'redirecturl'`. * * Finally, this event only fires in the event of a "normal" UI-oriented log-in attempt. A module attempting to log in * programmatically by directly calling the core functions will not see this event fired. */ public static function succeeded(Zikula_Event $event) { $user = $event->getSubject(); $uid = $user['uid']; MUBoard_Util_View::actualUser($uid, 1); MUBoard_Util_View::actualPostings($uid); }
/** * The muboardPostingsSinceLastLogin return if new postings. * * @param int $id posting id no = 0, yes = 1 * * @return out int */ function smarty_modifier_muboardPostingsSinceLastLogin($itemid, $kind) { $out = MUBoard_Util_View::PostingsSinceLastLogin($itemid, $kind); return $out; }
/** * This method provides a generic item detail view. * * @param string $ot Treated object type. * @param string $tpl Name of alternative template (for alternative display options, feeds and xml output) * @param boolean $raw Optional way to display a template instead of fetching it (needed for standalone output) * @return mixed Output. */ public function display($args) { // DEBUG: permission check aspect starts $this->throwForbiddenUnless(SecurityUtil::checkPermission('MUBoard::', '::', ACCESS_READ)); // DEBUG: permission check aspect ends // parameter specifying which type of objects we are treating $objectType = isset($args['ot']) && !empty($args['ot']) ? $args['ot'] : $this->request->getGet()->filter('ot', 'category', FILTER_SANITIZE_STRING); $utilArgs = array('controller' => 'user', 'action' => 'display'); if (!in_array($objectType, MUBoard_Util_Controller::getObjectTypes('controllerAction', $utilArgs))) { $objectType = MUBoard_Util_Controller::getDefaultObjectType('controllerAction', $utilArgs); } $repository = $this->entityManager->getRepository('MUBoard_Entity_' . ucfirst($objectType)); $idFields = ModUtil::apiFunc($this->name, 'selection', 'getIdFields', array('ot' => $objectType)); // retrieve identifier of the object we wish to view $idValues = MUBoard_Util_Controller::retrieveIdentifier($this->request, $args, $objectType, $idFields); $hasIdentifier = MUBoard_Util_Controller::isValidIdentifier($idValues); // check for unique permalinks (without id) $hasSlug = false; $slugTitle = ''; if ($hasIdentifier === false) { $entityClass = 'MUBoard_Entity_' . ucfirst($objectType); $objectTemp = new $entityClass(); $hasSlug = $objectTemp->get_hasUniqueSlug(); if ($hasSlug) { $slugTitle = isset($args['title']) && !empty($args['title']) ? $args['title'] : $this->request->getGet()->filter('title', '', FILTER_SANITIZE_STRING); $hasSlug = !empty($slugTitle); } } $hasIdentifier |= $hasSlug; $this->throwNotFoundUnless($hasIdentifier, $this->__('Error! Invalid identifier received.')); $entity = ModUtil::apiFunc($this->name, 'selection', 'getEntity', array('ot' => $objectType, 'id' => $idValues, 'slug' => $slugTitle)); $this->throwNotFoundUnless($entity != null, $this->__('No such item.')); // we take the children postings of the parent issue if ($objectType == 'posting') { $postingid = $entity['id']; $postingsWhere = 'tbl.parent = \'' . DataUtil::formatForStore($postingid) . '\''; $order = ModUtil::getVar($this->name, 'sortingPostings'); if ($order == 'descending') { $sdir = 'desc'; } else { $sdir = 'asc'; } $selectionArgs = array('ot' => 'posting', 'where' => $postingsWhere, 'orderBy' => 'createdDate' . ' ' . $sdir); // the current offset which is used to calculate the pagination $currentPage = (int) (isset($args['pos']) && !empty($args['pos'])) ? $args['pos'] : $this->request->getGet()->filter('pos', 1, FILTER_VALIDATE_INT); // the number of items displayed on a page for pagination $resultsPerPage = (int) (isset($args['num']) && !empty($args['num'])) ? $args['num'] : $this->request->getGet()->filter('num', 0, FILTER_VALIDATE_INT); if ($resultsPerPage == 0) { $csv = (int) (isset($args['usecsv']) && !empty($args['usecsv'])) ? $args['usecsv'] : $this->request->getGet()->filter('usecsvext', 0, FILTER_VALIDATE_INT); $resultsPerPage = $csv == 1 ? 999999 : $this->getVar('pagesize', 10); } $selectionArgs['currentPage'] = $currentPage; $selectionArgs['resultsPerPage'] = $resultsPerPage; list($entities, $objectCount) = ModUtil::apiFunc($this->name, 'selection', 'getEntitiesPaginated', $selectionArgs); // we check if the user may see the form to answer to posting $mayEdit = MUBoard_Util_Controller::mayEdit($id); $this->view->assign('mayEdit', $mayEdit); } if ($objectType == 'forum') { $forumid = $entity['id']; $parentWhere = 'tbl.parent_id IS NULL'; $parentWhere .= ' AND '; $parentWhere .= 'tbl.forum = \'' . DataUtil::formatForStore($forumid) . '\''; $order = ModUtil::getVar($this->name, 'sortingPostings'); if ($order == 'descending') { $sdir = 'desc'; } else { $sdir = 'asc'; } $selectionArgs = array('ot' => 'posting', 'where' => $parentWhere, 'orderBy' => 'createdDate' . ' ' . $sdir); // the current offset which is used to calculate the pagination $currentPage = (int) (isset($args['pos']) && !empty($args['pos'])) ? $args['pos'] : $this->request->getGet()->filter('pos', 1, FILTER_VALIDATE_INT); // the number of items displayed on a page for pagination $resultsPerPage = (int) (isset($args['num']) && !empty($args['num'])) ? $args['num'] : $this->request->getGet()->filter('num', 0, FILTER_VALIDATE_INT); if ($resultsPerPage == 0) { $csv = (int) (isset($args['usecsv']) && !empty($args['usecsv'])) ? $args['usecsv'] : $this->request->getGet()->filter('usecsvext', 0, FILTER_VALIDATE_INT); $resultsPerPage = $csv == 1 ? 999999 : $this->getVar('pagesize', 10); } $selectionArgs['currentPage'] = $currentPage; $selectionArgs['resultsPerPage'] = $resultsPerPage; list($entities, $objectCount) = ModUtil::apiFunc($this->name, 'selection', 'getEntitiesPaginated', $selectionArgs); } // build ModUrl instance for display hooks $currentUrlArgs = array('ot' => $objectType); foreach ($idFields as $idField) { $currentUrlArgs[$idField] = $idValues[$idField]; } // add a call to the posting if ($objectType == 'posting') { MUBoard_Util_Model::addView($idValues); } // get actual time $nowtime = DateUtil::getDatetime(); // set sessionvar with calling time SessionUtil::setVar('muboardonline', $nowtime); $currentUrlObject = new Zikula_ModUrl($this->name, 'user', 'display', ZLanguage::getLanguageCode(), $currentUrlArgs); $type = $this->request->getGet()->filter('type', 'admin', FILTER_SANITIZE_STRING); $func = $this->request->getGet()->filter('func', 'view', FILTER_SANITIZE_STRING); $editPostings = ModUtil::getVar($this->name, 'editPostings'); // assign output data to view object. $this->view->assign($objectType, $entity)->assign('postings', $entities)->assign('currentUrlObject', $currentUrlObject)->assign('func', $func)->assign('editPostings', $editPostings)->assign($repository->getAdditionalTemplateParameters('controllerAction', $utilArgs)); $this->view->assign('currentPage', $currentPage)->assign('pager', array('numitems' => $objectCount, 'itemsperpage' => $resultsPerPage)); $dom = ZLanguage::getModuleDomain($this->name); // we set Pagetitle $sitename = ModUtil::getVar('ZConfig', 'sitename'); if ($objectType == 'category') { $titletobject = __('Forum - Category: ', $dom); } if ($objectType == 'forum') { $titletobject = __('Forum - Category: ', $dom) . ' ' . $entity['category']['title'] . ' - ' . __('Forum: ', $dom); } if ($objectType == 'posting') { $titletobject = 'Forum: ' . ' ' . $entity['forum']['title'] . ' - ' . __('Issue: ', $dom); } PageUtil::setVar('title', $sitename . ' - ' . $titletobject . ' ' . $entity['title']); // we set description if ($objectType == 'category' || $objectType == 'forum') { $descriptionobject = $entity['description']; } if ($objectType == 'posting') { $descriptionobject = $entity['text']; $descriptionobject = substr($descriptionobject, 0, 160) . '...'; } PageUtil::setVar('description', $descriptionobject); // fetch and return the appropriate template return MUBoard_Util_View::processTemplate($this->view, 'user', $objectType, 'display', $args); }
/** * The muboardGetForumInfo modifier return the infos of a forum * @param int $id forum id * * @return string the output of last posting */ function smarty_modifier_muboardGetForumInfo($id) { $out = MUBoard_Util_View::getForumInfo($id); return $out; }
/** * The muboardGetNumberOfPostings return the number of postings. * * * @return id the number of postings */ function smarty_function_muboardGetNumberOfPostings() { $out = MUBoard_Util_View::getPostings(); return $out; }
/** * The muboardGetUserRank return the state of abo. * * @param int $id posting id * * @return out html */ function smarty_modifier_muboardGetUserRank($id) { $out = MUBoard_Util_View::getUserRank($id); return $out; }
/** * Post-Process the data after an insert operation. * * @ORM\PostPersist * @see MUBoard_Entity_Base_Posting::performPostPersistCallback() * @return void. */ public function postPersistCallback() { $createdUserId = $this->getCreatedUserId(); MUBoard_Util_View::actualUser($createdUserId, 2); $args['id'] = $this->getId(); $parent = $this->getParent(); // does not work bug in MOST TODO if (isset($parent)) { $args['parent'] = $parent->getId(); $args['title'] = $parent->getTitle(); } else { $args['title'] = $this->getTitle(); } $args['text'] = $this->getText(); MUBoard_Util_Base_Abonnements::aboMailing($args); $args['text'] = str_replace('\\n', '<br />', $args['text']); $this->setText($args['text']); $this->performPostPersistCallback(); }
/** * The muboardGetNumberOfIssuesOfForum return the number of postings in a forum. * * @param int $id forum id * * @return id the number of postings */ function smarty_modifier_muboardGetNumberOfIssuesOfForum($id) { $out = MUBoard_Util_View::getIssuesOfForum($id); return $out; }
/** * The muboardGetNumberOfIssues return the number of issues. * * * @return id the number of issues */ function smarty_function_muboardGetNumberOfIssues() { $out = MUBoard_Util_View::getIssues(); return $out; }
/** * This method provides a generic handling of simple delete requests. * * @param string $ot Treated object type. * @param int $id Identifier of entity to be deleted. * @param boolean $confirmation Confirm the deletion, else a confirmation page is displayed. * @param string $tpl Name of alternative template (for alternative display options, feeds and xml output) * @param boolean $raw Optional way to display a template instead of fetching it (needed for standalone output) * @return mixed Output. */ public function delete($args) { // DEBUG: permission check aspect starts $this->throwForbiddenUnless(SecurityUtil::checkPermission('MUBoard::', '::', ACCESS_ADMIN)); // DEBUG: permission check aspect ends // parameter specifying which type of objects we are treating $objectType = isset($args['ot']) && !empty($args['ot']) ? $args['ot'] : $this->request->getGet()->filter('ot', 'category', FILTER_SANITIZE_STRING); $utilArgs = array('controller' => 'admin', 'action' => 'delete'); if (!in_array($objectType, MUBoard_Util_Controller::getObjectTypes('controllerAction', $utilArgs))) { $objectType = MUBoard_Util_Controller::getDefaultObjectType('controllerAction', $utilArgs); } $idFields = ModUtil::apiFunc($this->name, 'selection', 'getIdFields', array('ot' => $objectType)); // retrieve identifier of the object we wish to delete $idValues = MUBoard_Util_Controller::retrieveIdentifier($this->request, $args, $objectType, $idFields); $hasIdentifier = MUBoard_Util_Controller::isValidIdentifier($idValues); $this->throwNotFoundUnless($hasIdentifier, $this->__('Error! Invalid identifier received.')); $entity = ModUtil::apiFunc($this->name, 'selection', 'getEntity', array('ot' => $objectType, 'id' => $idValues)); $this->throwNotFoundUnless($entity != null, $this->__('No such item.')); $confirmation = (bool) (isset($args['confirmation']) && !empty($args['confirmation'])) ? $args['confirmation'] : $this->request->getPost()->filter('confirmation', false, FILTER_VALIDATE_BOOLEAN); if ($confirmation) { $this->checkCsrfToken(); // TODO call pre delete validation hooks $this->entityManager->remove($entity); $this->entityManager->flush(); $this->registerStatus($this->__('Done! Item deleted.')); // TODO call post delete process hooks // clear view cache to reflect our changes $this->view->clear_cache(); // redirect to the list of the current object type $this->redirect(ModUtil::url($this->name, 'admin', 'view', array('ot' => $objectType))); } $repository = $this->entityManager->getRepository('MUBoard_Entity_' . ucfirst($objectType)); // assign the object we loaded above $this->view->assign($objectType, $entity)->assign($repository->getAdditionalTemplateParameters('controllerAction', $utilArgs)); // fetch and return the appropriate template return MUBoard_Util_View::processTemplate($this->view, 'admin', $objectType, 'delete', $args); }
public function preview() { include_once 'lib/viewplugins/function.useravatar.php'; $dom = ZLanguage::getModuleDomain('MUBoard'); $id = $this->request->query->filter('id', 0); $parentid = $this->request->query->filter('muboardPosting_ParentItemList', 0, FILTER_SANITIZE_NUMBER_INT); $answer = $this->request->query->filter('answer', 0); $title = ''; $text = ''; $title = $this->request->query->filter('title'); $text = $this->request->query->filter('text'); $out = ""; if ($text != '' && ($id == 0 && $title == '' && $answer == 1 || $id == 0 && $answer == 0 && $title != '' || $id > 0 && ($parentid == 0 && $title != '' || $parentid > 0 && $title == ''))) { if (ModUtil::available('BBCode')) { $text = ModUtil::apiFunc('BBCode', 'user', 'transform', array('message' => $text)); } if (ModUtil::available('BBSmile')) { $text = ModUtil::apiFunc('BBSmile', 'user', 'transform', array('text' => $text)); } $text = nl2br($text); $uid = UserUtil::getVar('uid'); if ($uid > 1) { $uname = UserUtil::getVar('uname', $uid); } else { $uname = __('Guest', $dom); } $userRank = MUBoard_Util_View::getUserRank($uid, 1); $date = DateUtil::getDatetime(null, 'datetimelong'); if ($uid > 1) { $params['uid'] = $uid; if ($title != '') { $params["size"] = 80; } else { $params["size"] = 60; } $avatar = smarty_function_useravatar($params); } else { $avatar = ''; } $out .= "<div class='muboard-user-posting muboard-preview'>"; if ($title != '') { $out .= "<div class='muboard-user-posting-header'>"; $out .= "<div class='muboard-user-posting-header-title'>"; $out .= "<h2>" . __('Issue: ', $dom) . ' '; $out .= $title; $out .= "</h2></div></div>"; } $out .= "<div class='muboard-user-posting-user'>"; $out .= "<div class='muboard-user-posting-avatar'>"; $out .= $avatar . "<br />"; $out .= $uname; $out .= "</div>"; $out .= "<div class='muboard-user-posting-datas'>"; $out .= $userRank; $out .= "</div>"; $out .= "</div>"; $out .= "<div class='muboard-user-posting-content'>"; $out .= "<div class='muboard-user-posting-created'>"; $out .= $date; $out .= "</div>"; $out .= "<div class='muboard-user-posting-content-text'>"; $out .= $text; $out .= "</div>"; $out .= "</div>"; $out .= "</div>"; } else { $out .= "<div class='muboard-user-posting muboard-nopreview'>"; $out .= "<h3>"; if ($id == 0) { if ($answer == 0 && $title == '' && $text == '') { $out .= __('Sorry! If you want to create a new issue you have to enter a title and a text to get a preview!', $dom); } if ($answer == 0 && $title == '' && $text != '') { $out .= __('Sorry! If you want to create a new issue you have to enter a title to get a preview!', $dom); } if ($answer == 0 && $title != '' && $text == '') { $out .= __('Sorry! If you want to create a new issue you have to enter a text to get a preview!', $dom); } if ($answer == 1 && $text == '') { $out .= __('Sorry! If you want to answer to an issue you have to enter a text to get a preview', $dom); } } else { if ($answer == 0 && $parentid == 0 && $title == '') { $out .= __('Sorry! If you want to edit an existing issue you have to enter a title and a text to get a preview!', $dom); } if ($answer == 0 && $parentid > 0) { $out .= __('Sorry! If you want to edit an existing posting you have to enter a text to get a preview!', $dom); } } $out .= "</h3></div>"; } return $out; }
/** * The muboardGetStateOfCategoryAbo return the state of abo. * * @param int $id category id * * @return out html */ function smarty_modifier_muboardGetStateOfCategoryAbo($id) { $out = MUBoard_Util_View::getStateOfCtegoryAbo($id); return $out; }
/** * The muboardGetStateOfEditOfIssue return the state of edit -> yes or not. * * @param int $id posting id * * @return out html */ function smarty_modifier_muboardGetStateOfEditOfIssue($id) { $out = MUBoard_Util_View::getStateOfEditOfIssue($id); return $out; }