/** * Show the results of the import * * @return void */ private function savedAction() { // Check if they're logged in if (User::isGuest()) { return $this->loginAction(); } if (!$this->params->get('access-manage')) { throw new Exception(Lang::txt('PLG_MEMBERS_CITATIONS_NOT_AUTHORIZED'), 403); } // Get the session object $session = App::get('session'); // Get the citations $citations_saved = $session->get('citations_saved'); $citations_not_saved = $session->get('citations_not_saved'); $citations_error = $session->get('citations_error'); // Check to make sure we have citations if (!$citations_saved && !$citations_not_saved) { App::redirect(Route::url($this->member->getLink() . '&active=' . $this->_name . '&action=import'), Lang::txt('PLG_MEMBERS_CITATIONS_IMPORT_MISSING_FILE_CONTINUE'), 'error'); return; } $view = $this->view('saved', 'import'); $view->member = $this->member; $view->option = $this->option; $view->isAdmin = $this->params->get('access-manage'); $view->config = Component::params('com_citations'); $view->database = $this->database; $view->filters = array('start' => 0, 'search' => ''); $view->citations = array(); foreach ($citations_saved as $cs) { $cc = new \Components\Citations\Tables\Citation($this->database); $cc->load($cs); $view->citations[] = $cc; } $view->openurl['link'] = ''; $view->openurl['text'] = ''; $view->openurl['icon'] = ''; //take care fo type $ct = new \Components\Citations\Tables\Type($this->database); $view->types = $ct->getType(); $view->messages = Notify::messages('plg_members_citations'); return $view->loadTemplate(); }
/** * View a citation entry * * @return void */ public function viewTask() { // get request vars $id = Request::getInt('id', 0); //make sure we have an id if (!$id || $id == 0) { App::abort(404, Lang::txt('COM_CITATIONS_MUST_HAVE_ID')); return; } // set vars for view $this->view->database = $this->database; //get the citation $this->view->citation = new Citation($this->view->database); $this->view->citation->load($id); //make sure we got a citation if (!isset($this->view->citation->title) || $this->view->citation->title == '') { App::abort(404, Lang::txt('COM_CITATIONS_NO_CITATION_WITH_ID')); return; } // make sure citation is published if (!$this->view->citation->published) { App::abort(404, Lang::txt('COM_CITATIONS_NOT_PUBLISHED')); return; } //load citation associations $assoc = new Association($this->database); $this->view->associations = $assoc->getRecords(array('cid' => $id)); //open url stuff $this->view->openUrl = $this->openUrl(); //make sure title isnt too long $this->view->maxTitleLength = 50; $this->view->shortenedTitle = strlen($this->view->citation->title) > $this->view->maxTitleLength ? substr($this->view->citation->title, 0, $this->view->maxTitleLength) . '…' : $this->view->citation->title; // Set the page title Document::setTitle(Lang::txt('COM_CITATIONS_CITATION') . ": " . $this->view->shortenedTitle); // Set the pathway if (Pathway::count() <= 0) { Pathway::append(Lang::txt(strtoupper($this->_name)), 'index.php?option=' . $this->_option); } Pathway::append(Lang::txt('COM_CITATIONS_BROWSE'), 'index.php?option=' . $this->_option . '&task=browse'); Pathway::append($this->view->shortenedTitle, 'index.php?option=' . $this->_option . '&task=view&id=' . $this->view->citation->id); //get this citation type to see if we have a template override for this type $citationType = new Type($this->database); $type = $citationType->getType($this->view->citation->type); $typeAlias = $type[0]['type']; // Build paths to type specific overrides $componentTypeOverride = PATH_CORE . DS . 'components' . DS . 'com_citations' . DS . 'views' . DS . 'citations' . DS . 'tmpl' . DS . $typeAlias . '.php'; $tempalteTypeOverride = PATH_CORE . DS . 'templates' . DS . App::get('template')->template . DS . 'html' . DS . 'com_citations' . DS . 'citations' . DS . $typeAlias . '.php'; //if we found an override use it if (file_exists($tempalteTypeOverride) || file_exists($componentTypeOverride)) { $this->view->setLayout($typeAlias); } //get any messages & display view $this->view->messages = \Notify::messages('citations'); $this->view->config = $this->config; $this->view->display(); }
/** * Get notifications * @param string $type * @return $messages if they exist */ public function getNotifications($type = 'success') { // Get messages in quene $messages = \Notify::messages($this->_option); // Return first message of type if ($messages && count($messages) > 0) { foreach ($messages as $message) { if ($message['type'] == $type) { return $message['message']; } } } return false; }
/** * Show a form for editing a course * * @return void */ public function editTask() { $this->view->notifications = \Notify::messages('courses'); $this->view->setLayout('edit')->display(); }
/** * Display a list of courses on the site and options for filtering/browsing them * * @return void */ public function browseTask() { // Filters $this->view->filters = array('state' => 1, 'search' => Request::getVar('search', ''), 'sortby' => strtolower(Request::getWord('sortby', 'title')), 'group' => Request::getVar('group', '')); if ($this->view->filters['group']) { $group = \Hubzero\User\Group::getInstance($this->view->filters['group']); if ($group) { $this->view->filters['group_id'] = $group->get('gidNumber'); } } if (!in_array($this->view->filters['sortby'], array('alias', 'title', 'popularity'))) { $this->view->filters['sortby'] = 'title'; } switch ($this->view->filters['sortby']) { case 'popularity': $this->view->filters['sort'] = 'students'; $this->view->filters['sort_Dir'] = 'DESC'; break; case 'title': case 'alias': default: $this->view->filters['sort'] = $this->view->filters['sortby']; $this->view->filters['sort_Dir'] = 'ASC'; break; } // Filters for returning results $this->view->filters['limit'] = Request::getInt('limit', Config::get('list_limit')); $this->view->filters['limit'] = $this->view->filters['limit'] ? $this->view->filters['limit'] : 'all'; $this->view->filters['start'] = Request::getInt('limitstart', 0); $this->view->filters['index'] = strtolower(Request::getWord('index', '')); if ($this->view->filters['index'] && !in_array($this->view->filters['index'], array('a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'))) { $this->view->filters['index'] = ''; } $this->view->filters['tag'] = Request::getVar('tag', ''); $model = Models\Courses::getInstance(); // Get a record count $this->view->filters['count'] = true; $this->view->total = $model->courses($this->view->filters); // Get records $this->view->filters['count'] = false; $this->view->courses = $model->courses($this->view->filters); //build the title $this->_buildTitle(); //build pathway $this->_buildPathway(); // Output HTML $this->view->model = $model; $this->view->title = $this->_title; $this->view->config = $this->config; $this->view->notifications = \Notify::messages('courses'); $this->view->display(); }
/** * Show a form for editing an entry * * @param mixed $post * @return void */ public function editTask($post = null) { $id = Request::getInt('thread', 0); $category = Request::getCmd('category', ''); $section = Request::getVar('section', ''); if (User::isGuest()) { $return = Route::url('index.php?option=' . $this->_option . '§ion=' . $section . '&category=' . $category . '&task=new'); if ($id) { $return = Route::url('index.php?option=' . $this->_option . '§ion=' . $section . '&category=' . $category . '&thread=' . $id . '&task=edit'); } App::redirect(Route::url('index.php?option=com_users&view=login&return=' . base64_encode($return)) . Lang::txt('COM_FORUM_LOGIN_NOTICE'), 'warning'); return; } $this->view->section = $this->model->section($section, $this->model->get('scope'), $this->model->get('scope_id')); if (!$this->view->section->exists()) { throw new Exception(Lang::txt('COM_FORUM_SECTION_NOT_FOUND'), 404); } $this->view->category = $this->view->section->category($category); if (!$this->view->category->exists()) { throw new Exception(Lang::txt('COM_FORUM_CATEGORY_NOT_FOUND'), 404); } // Incoming if (is_object($post)) { $this->view->post = $post; } else { $this->view->post = new Thread($id); } $this->_authorize('thread', $id); if (!$id) { $this->view->post->set('scope', $this->model->get('scope')); $this->view->post->set('created_by', User::get('id')); } elseif ($this->view->post->get('created_by') != User::get('id') && !$this->config->get('access-edit-thread')) { App::redirect(Route::url('index.php?option=' . $this->_option . '§ion=' . $section . '&category=' . $category), Lang::txt('COM_FORUM_NOT_AUTHORIZED'), 'warning'); return; } // Set the page title $this->_buildTitle(); // Set the pathway $this->_buildPathway(); $this->view->config = $this->config; $this->view->model = $this->model; $this->view->notifications = \Notify::messages('forum'); // Set any errors foreach ($this->getErrors() as $error) { $this->view->setError($error); } $this->view->setLayout('edit')->display(); }
/** * Get notifications * * @param string $type * @return $messages if they exist */ protected function _getNotifications($type = 'success') { // Get messages in queue if (!isset($this->_messages)) { $this->_messages = \Notify::messages('projects'); } // Return first message of type if ($this->_messages && count($this->_messages) > 0) { foreach ($this->_messages as $message) { if ($message['type'] == $type) { return $message['message']; } } } else { return false; } }
/** * Display a ticket and associated comments * * @param mixed $comment * @return void */ public function ticketTask($comment = null) { // Get the ticket ID $id = Request::getInt('id', 0); if (!$id) { App::redirect(Route::url('index.php?option=' . $this->_option . '&controller=' . $this->controller . '&task=tickets'), Lang::txt('COM_SUPPORT_ERROR_MISSING_TICKET_ID'), 'error'); return; } // Initiate database class and load info $this->view->row = Ticket::getInstance($id); if (!$this->view->row->exists()) { App::abort(404, Lang::txt('COM_SUPPORT_ERROR_TICKET_NOT_FOUND')); return; } // Check authorization if (User::isGuest()) { $return = base64_encode(Route::url($this->view->row->link(), false, true)); App::redirect(Route::url('index.php?option=com_users&view=login&return=' . $return, false)); return; } // Ensure the user is authorized to view this ticket if (!$this->view->row->access('read', 'tickets')) { App::abort(403, Lang::txt('COM_SUPPORT_ERROR_NOT_AUTH')); return; } $this->view->filters = array('limit' => Request::getState($this->_option . '.' . $this->_controller . '.limit', 'limit', Config::get('list_limit'), 'int'), 'start' => Request::getState($this->_option . '.' . $this->_controller . '.limitstart', 'limitstart', 0, 'int'), 'show' => Request::getState($this->_option . '.' . $this->_controller . '.show', 'show', 0, 'int'), 'search' => urldecode(Request::getState($this->_option . '.' . $this->_controller . '.search', 'search', ''))); if ($watch = Request::getWord('watch', '')) { // Already watching if ($this->view->row->isWatching(User::get('id'))) { // Stop watching? if ($watch == 'stop') { $this->view->row->stopWatching(User::get('id')); } } else { // Start watching? if ($watch == 'start') { $this->view->row->watch(User::get('id')); if (!$this->view->row->isWatching(User::get('id'), true)) { $this->setError(Lang::txt('COM_SUPPORT_ERROR_FAILED_TO_WATCH')); } } } } $this->view->lists = array(); $sc = new Tables\Category($this->database); $this->view->lists['categories'] = $sc->find('list'); // Get messages $sm = new Tables\Message($this->database); $this->view->lists['messages'] = $sm->getMessages(); // Get severities $this->view->lists['severities'] = Utilities::getSeverities($this->config->get('severities')); // Populate the list of assignees based on if the ticket belongs to a group or not if (trim($this->view->row->get('group'))) { $this->view->lists['owner'] = $this->_userSelectGroup('ticket[owner]', $this->view->row->get('owner'), 1, '', trim($this->view->row->get('group'))); } elseif (trim($this->config->get('group'))) { $this->view->lists['owner'] = $this->_userSelectGroup('ticket[owner]', $this->view->row->get('owner'), 1, '', trim($this->config->get('group'))); } else { $this->view->lists['owner'] = $this->_userSelect('ticket[owner]', $this->view->row->get('owner'), 1); } // Set the pathway $this->_buildPathway($this->view->row); // Set the page title $this->_buildTitle($this->view->row); $this->view->title = $this->_title; $this->view->database = $this->database; if (\Notify::any('support')) { foreach (\Notify::messages('support') as $error) { if ($error['type'] == 'error') { $this->view->setError($error['message']); } } } if (!$comment) { $comment = new Comment(); } $this->view->comment = $comment; // Output HTML foreach ($this->getErrors() as $error) { $this->view->setError($error); } $this->view->set('config', $this->config)->setLayout('ticket')->display(); }
/** * Display a list of sections and their categories * * @return void */ public function displayTask() { // Get authorization $this->_authorize('section'); $this->_authorize('category'); $this->view->config = $this->config; $this->view->title = Lang::txt('COM_FORUM'); // Incoming $this->view->filters = array('scope' => $this->model->get('scope'), 'scope_id' => $this->model->get('scope_id'), 'search' => Request::getVar('q', ''), 'state' => 1, 'access' => User::isGuest() ? 0 : array(0, 1)); // Flag to indicate if a section is being put into edit mode $this->view->edit = null; if (($section = Request::getVar('section', '')) && $this->_task == 'edit') { $this->view->edit = $section; } $this->view->sections = $this->model->sections('list', array('state' => 1)); $this->view->model = $this->model; if (!$this->view->sections->total() && $this->config->get('access-create-section') && Request::getWord('action') == 'populate') { if (!$this->model->setup()) { $this->setError($this->model->getError()); } $this->view->sections = $this->model->sections('list', array('state' => 1)); } // Set the page title $this->_buildTitle(); // Set the pathway $this->_buildPathway(); $this->view->notifications = \Notify::messages('forum'); // Set any errors foreach ($this->getErrors() as $error) { $this->view->setError($error); } $this->view->display(); }