/** * Render a tool session * * @param object $tool * @param object $session * @param boolean $readOnly * @return string */ public function onToolSessionView($tool, $session, $readOnly = false) { $us = App::get('session'); $declared = Request::getWord('viewer'); $viewer = $declared ? $declared : $us->get('tool_viewer'); if (isset($session->rendered) && $session->rendered || $viewer && $viewer != $this->_name) { return; } if (!$this->canRender()) { return; } $session->rendered = $this->_name; if (!$declared) { //$us->set('tool_viewer', $this->_name); } $view = new \Hubzero\Plugin\View(array('folder' => $this->_type, 'element' => $this->_name, 'name' => 'session', 'layout' => 'default')); return $view->set('option', Request::getCmd('option', 'com_tools'))->set('controller', Request::getWord('controller', 'sessions'))->set('output', $session)->set('app', $tool)->set('readOnly', $readOnly)->set('params', $this->params)->loadTemplate(); }
echo $this->escape(stripslashes($this->course->offering()->section()->get('title'))); ?> </span> </p> </header><!-- / #content-header --> <div class="innerwrap"> <div id="page_container"> <?php } ?> <?php if (!$this->course->offering()->access('view') && !$sparams->get('preview', 0)) { $view = new \Hubzero\Plugin\View(array('folder' => 'courses', 'element' => 'outline', 'name' => 'shared', 'layout' => '_not_enrolled')); $view->set('course', $this->course)->set('option', 'com_courses')->set('message', Lang::txt('COM_COURSES_ENROLLMENT_REQUIRED')); echo $view; } else { if ($this->course->offering()->section()->expired() && !$sparams->get('preview', 0)) { ?> <div id="offering-introduction"> <div class="instructions"> <p class="warning"><?php echo Lang::txt('COM_COURSES_SECTION_EXPIRED'); ?> </p> </div><!-- / .instructions --> <div class="questions"> <p><strong><?php echo Lang::txt('COM_COURSES_WHERE_TO_LEARN_MORE'); ?>
/** * Return data on a course view (this will be some form of HTML) * * @param object $course Current course * @param object $offering Name of the component * @param boolean $describe Return plugin description only? * @return object */ public function onCourse($course, $offering, $describe = false) { $response = with(new \Hubzero\Base\Object())->set('name', $this->_name)->set('title', Lang::txt('PLG_COURSES_' . strtoupper($this->_name)))->set('description', Lang::txt('PLG_COURSES_' . strtoupper($this->_name) . '_BLURB'))->set('default_access', $this->params->get('plugin_access', 'members'))->set('display_menu_tab', true)->set('icon', 'f012'); if ($describe) { return $response; } if (!($active = Request::getVar('active'))) { Request::setVar('active', $active = $this->_name); } if ($response->get('name') != $active) { return $response; } // Check to see if user is member and plugin access requires members if (!$course->offering()->section()->access('view')) { $view = new \Hubzero\Plugin\View(array('folder' => 'courses', 'element' => 'outline', 'name' => 'shared', 'layout' => '_not_enrolled')); $view->set('course', $course)->set('option', 'com_courses')->set('message', 'You must be enrolled to utilize the progress feature.'); $response->set('html', $view->__toString()); return $response; } $this->member = $course->offering()->section()->member(User::get('id')); $this->course = $course; $this->base = $course->offering()->link(); $this->db = App::get('db'); // Instantiate a vew $this->view = $this->view('student', 'report'); $this->view->course = $course; $this->view->member = $this->member; $this->view->option = 'com_courses'; $this->view->base = $this->base; switch (Request::getWord('action')) { case 'assessmentdetails': $this->assessmentdetails(); break; case 'getprogressrows': $this->getprogressrows(); break; case 'getprogressdata': $this->getprogressdata(); break; case 'getgradebookdata': $this->getgradebookdata(); break; case 'getreportsdata': $this->getreportsdata(); break; case 'exportcsv': $this->exportcsv(); break; case 'downloadresponses': $this->downloadresponses(); break; case 'savegradebookitem': $this->savegradebookitem(); break; case 'deletegradebookitem': $this->deletegradebookitem(); break; case 'savegradebookentry': $this->savegradebookentry(); break; case 'resetgradebookentry': $this->resetgradebookentry(); break; case 'policysave': $this->policysave(); break; case 'restoredefaults': $this->restoredefaults(); break; default: $this->progress(); break; } $response->set('html', $this->view->loadTemplate()); // Return the output return $response; }
</div><!-- / .instructions --> <div class="questions"> <p><strong><?php echo Lang::txt('PLG_COURSES_NOTES_WHERE_IS_SAVE_BUTTON'); ?> </strong></p> <p><?php echo Lang::txt('PLG_COURSES_NOTES_WHERE_IS_SAVE_BUTTON_EXPLANATION'); ?> </p> <p><strong><?php echo Lang::txt('PLG_COURSES_NOTES_WHO_CAN_SEE_MY_NOTES'); ?> </strong></p> <p><?php echo Lang::txt('PLG_COURSES_NOTES_WHO_CAN_SEE_MY_NOTES_EXPLANATION'); ?> </p> </div><!-- / .post-type --> </div><!-- / #collection-introduction --> <?php } ?> </div> <?php } else { ?> <?php $view = new \Hubzero\Plugin\View(array('folder' => 'courses', 'element' => 'outline', 'name' => 'shared', 'layout' => '_not_enrolled')); $view->set('course', $this->course)->set('option', $this->option)->set('message', Lang::txt('PLG_COURSES_NOTES_ENROLLMENT_REQUIRED'))->display(); }
*/ defined('_HZEXEC_') or die; $this->js(); $base = $this->offering->link() . '&active=discussions'; $instructors = array(); $inst = $this->course->instructors(); if (count($inst) > 0) { foreach ($inst as $i) { $instructors[] = $i->get('user_id'); } } if (!$this->course->offering()->section()->access('view')) { ?> <?php $view = new \Hubzero\Plugin\View(array('folder' => 'courses', 'element' => 'outline', 'name' => 'shared', 'layout' => '_not_enrolled')); $view->set('course', $this->course)->set('option', $this->option)->set('message', 'You must be enrolled to utilize the discussion feature.')->display(); return; } if ($this->course->access('manage', 'offering')) { ?> <div id="manager-options"> <p><a class="btn" href="<?php echo Route::url($base . '&unit=manage'); ?> "><?php echo Lang::txt('Manage'); ?> </a></p> </div> <?php }
/** * Set redirect and message * * @param object $url URL to redirect to * @param object $msg Message to send * @return void */ public function onCourseAfterLecture($course, $unit, $lecture) { if (!$course->offering()->section()->access('view')) { $view = new \Hubzero\Plugin\View(array('folder' => 'courses', 'element' => 'outline', 'name' => 'shared', 'layout' => '_not_enrolled')); $view->set('course', $course)->set('option', 'com_courses')->set('message', 'You must be enrolled to utilize the discussion feature.'); return $view->loadTemplate(); } // Are discussions turned on? if (!$lecture->params('discussions_category')) { return ''; } $this->params->merge(new \Hubzero\Config\Registry($course->offering()->section()->get('params'))); $this->_active = 'outline'; $this->database = App::get('db'); $this->offering = $course->offering(); $this->base = $this->offering->link() . '&active=' . $this->_active; $this->_authorize('category'); $this->_authorize('thread'); $view = $this->view('lecture', 'threads'); $view->course = $this->course = $course; $view->unit = $this->unit = $unit; $view->lecture = $this->lecture = $lecture; $view->option = $this->option = 'com_courses'; $view->config = $this->params; // Incoming $view->filters = array(); $view->filters['limit'] = Request::getInt('limit', 500); $view->filters['start'] = Request::getInt('limitstart', 0); $view->filters['section'] = Request::getVar('section', ''); $view->filters['category'] = Request::getVar('category', ''); $view->filters['state'] = 1; $view->filters['scope'] = 'course'; $view->filters['scope_id'] = $course->offering()->get('id'); if ($this->params->get('discussions_threads', 'all') != 'all') { $view->filters['scope_sub_id'] = $course->offering()->section()->get('id'); } $view->filters['sticky'] = false; //$view->filters['start_id'] = Request::getInt('start_id', 0); $view->filters['search'] = Request::getVar('search', ''); $view->no_html = Request::getInt('no_html', 0); $view->filters['sort_Dir'] = 'DESC'; $view->filters['sort'] = 'c.created'; $view->filters['object_id'] = $lecture->get('id'); $view->post = new \Components\Forum\Tables\Post($this->database); $view->total = 0; $view->rows = null; // Load the section $section = new \Components\Forum\Tables\Section($this->database); if (!$section->loadByAlias($unit->get('alias'), $view->filters['scope_id'], $view->filters['scope'])) { // Create a default section $section->title = $unit->get('title'); $section->alias = $unit->get('alias'); $section->scope = $view->filters['scope']; $section->scope_id = $view->filters['scope_id']; $section->object_id = $unit->get('id'); $section->state = 1; if ($section->check()) { $section->store(); } } $category = new \Components\Forum\Tables\Category($this->database); $category->loadByObject($lecture->get('id'), $section->get('id'), $view->filters['scope_id'], $view->filters['scope']); if (!$category->get('id')) { $category->section_id = $section->get('id'); if ($lecture->get('title') == '--') { $category->title = $lecture->assets()->fetch('first')->get('title'); } else { $category->title = $lecture->get('title'); } $category->alias = $lecture->get('alias'); $category->description = Lang::txt('Discussions for %s', $unit->get('alias')); $category->state = 1; $category->scope = $view->filters['scope']; $category->scope_id = $view->filters['scope_id']; $category->object_id = $lecture->get('id'); $category->ordering = $lecture->get('ordering'); if ($category->check()) { $category->store(); } } $view->post->scope = $view->filters['scope']; $view->post->scope_id = $view->filters['scope_id']; $view->post->scope_sub_id = $course->offering()->section()->get('id'); $view->post->category_id = $category->get('id'); $view->post->object_id = $lecture->get('id'); $view->post->parent = 0; // Get attachments $view->attach = new \Components\Forum\Tables\Attachment($this->database); $view->attachments = $view->attach->getAttachments($view->post->id); $view->filters['state'] = array(1, 3); $view->thread = Request::getInt('thread', 0); // No thread? if (!$view->thread) { // Try being more specific $view->thread = Request::getInt('thread', 0, 'get'); } $action = strtolower(Request::getWord('action', '')); if ($view->no_html == 1) { $data = new stdClass(); $data->success = true; $data->threads = new stdClass(); $data->threads->lastchange = '0000-00-00 00:00:00'; $data->threads->lastid = 0; $data->threads->total = 0; $data->threads->posts = null; $data->threads->html = null; $data->thread = new stdClass(); $data->thread->lastchange = '0000-00-00 00:00:00'; $data->thread->lastid = 0; $data->thread->posts = null; $data->thread->total = 0; $data->thread->html = null; if ($view->thread) { $view->post->load($view->thread); } if (!$action && $view->thread) { $action = 'both'; } switch ($action) { case 'posts': $view->filters['parent'] = $view->post->id; $view->filters['start_at'] = Request::getVar('start_at', ''); $data->thread = $this->_posts($view->post, $view->filters); break; case 'delete': if ($pid = Request::getInt('post', 0)) { $this->deletethread($pid, false); } $data->thread = $this->_thread($view->post, $view->filters); break; case 'thread': $data->thread = $this->_thread($view->post, $view->filters); break; case 'search': $view->filters['search'] = Request::getVar('search', ''); $data->threads = $this->_threadsSearch($view->post, $view->filters); break; case 'sticky': $view->post->sticky = Request::getInt('sticky', 0); $view->post->store(); break; case 'both': default: $view->filters['start_at'] = Request::getVar('start_at', ''); $data->thread = $this->_thread($view->post, $view->filters); $view->filters['start_at'] = Request::getVar('threads_start', ''); $data->threads = $this->_threads($view->post, $view->filters); break; case 'threads': default: $view->filters['parent'] = $view->post->id; $view->filters['start_at'] = Request::getVar('threads_start', ''); $data->threads = $this->_threads($view->post, $view->filters); break; } if ($this->getError()) { $data->success = false; $data->errors = $this->getErrors(); } ob_clean(); header('Content-type: text/plain'); echo json_encode($data); exit; } switch ($action) { case 'search': $view->filters['search'] = Request::getVar('search', ''); $data = $this->_threadsSearch($view->post, $view->filters); $view->threads = $data->posts; break; default: if ($action == 'delete') { if ($pid = Request::getInt('post', 0)) { $this->deletethread($pid, false); } } $view->filters['parent'] = 0; $view->threads = $view->post->find($view->filters); break; } $view->data = null; if ($view->thread) { $view->post->load($view->thread); $view->data = $this->_thread($view->post, $view->filters); } $view->notifications = $this->getPluginMessage(); // Set any errors foreach ($this->getErrors() as $error) { $this->view->setError($error); } return $view->loadTemplate(); }
/** * Set redirect and message * * @param object $url URL to redirect to * @param object $msg Message to send * @return void */ public function onCourseAfterLecture($course, $unit, $lecture) { if (!$course->offering()->section()->access('view')) { $view = new \Hubzero\Plugin\View(array('folder' => 'courses', 'element' => 'outline', 'name' => 'shared', 'layout' => '_not_enrolled')); $view->set('course', $course)->set('option', 'com_courses')->set('message', Lang::txt('You must be enrolled to utilize the discussion feature.')); return $view->loadTemplate(); } // Are discussions turned on? if (!$lecture->params('discussions_category')) { return ''; } $this->params->merge(new \Hubzero\Config\Registry($course->offering()->section()->get('params'))); $this->_active = 'outline'; $this->database = App::get('db'); $this->course = $course; $this->offering = $course->offering(); $this->unit = $unit; $this->base = $this->offering->link() . '&active=' . $this->_active; $this->_authorize('category'); $this->_authorize('thread'); // Incoming $filters = array('limit' => Request::getInt('limit', 500), 'start' => Request::getInt('limitstart', 0), 'section' => Request::getVar('section', ''), 'category' => Request::getVar('category', ''), 'state' => array(1, 3), 'scope' => 'course', 'scope_id' => $course->offering()->get('id'), 'sticky' => false, 'search' => Request::getVar('search', ''), 'sort_Dir' => 'DESC', 'sort' => 'c.created', 'object_id' => $lecture->get('id')); if ($this->params->get('discussions_threads', 'all') != 'all') { $filters['scope_sub_id'] = $course->offering()->section()->get('id'); } // Load the section // This should map to course Unit $section = Section::all()->whereEquals('alias', $unit->get('alias'))->whereEquals('scope', $filters['scope'])->whereEquals('scope_id', $filters['scope_id'])->whereEquals('state', Section::STATE_PUBLISHED)->row(); if (!$section->get('id')) { // Create a default section $section->set('title', $unit->get('title')); $section->set('alias', $unit->get('alias')); $section->set('scope', $filters['scope']); $section->set('scope_id', $filters['scope_id']); $section->set('object_id', $unit->get('id')); $section->set('state', Section::STATE_PUBLISHED); $section->save(); } // Load category // This should map to course asset group (lecture) $category = Category::all()->whereEquals('object_id', $lecture->get('id'))->whereEquals('section_id', $section->get('id'))->whereEquals('scope', $filters['scope'])->whereEquals('scope_id', $filters['scope_id'])->whereEquals('state', Category::STATE_PUBLISHED)->row(); if (!$category->get('id')) { // Category doesn't exist yet, so create it $category->set('section_id', $section->get('id')); if ($lecture->get('title') == '--') { $category->set('title', $lecture->assets()->fetch('first')->get('title')); } else { $category->set('title', $lecture->get('title')); } $category->set('alias', $lecture->get('alias')); $category->set('description', Lang::txt('Discussions for %s', $unit->get('alias'))); $category->set('state', Category::STATE_PUBLISHED); $category->set('scope', $filters['scope']); $category->set('scope_id', $filters['scope_id']); $category->set('object_id', $lecture->get('id')); $category->set('ordering', $lecture->get('ordering')); $category->save(); } // Instantiate a blank Post $post = Post::blank(); $post->set('scope', $filters['scope']); $post->set('scope_id', $filters['scope_id']); $post->set('scope_sub_id', $course->offering()->section()->get('id')); $post->set('category_id', $category->get('id')); $post->set('object_id', $lecture->get('id')); $post->set('parent', 0); // Get attachments //$view->attach = Attachment::blank(); //$view->attachments = $view->attach->getAttachments($view->post->id); $thread = Request::getInt('thread', 0); $thread = $thread ?: Request::getInt('thread', 0, 'get'); // No thread? Try being more specific $action = strtolower(Request::getWord('action', '')); // Called via AJAX? $no_html = Request::getInt('no_html', 0); if ($no_html) { $data = new stdClass(); $data->success = true; $data->threads = new stdClass(); $data->threads->lastchange = '0000-00-00 00:00:00'; $data->threads->lastid = 0; $data->threads->total = 0; $data->threads->posts = null; $data->threads->html = null; $data->thread = new stdClass(); $data->thread->lastchange = '0000-00-00 00:00:00'; $data->thread->lastid = 0; $data->thread->posts = null; $data->thread->total = 0; $data->thread->html = null; if ($thread) { $post = Post::oneOrNew($thread); } if (!$action && $thread) { $action = 'both'; } switch ($action) { case 'posts': $filters['parent'] = $post->get('id'); $filters['start_at'] = Request::getVar('start_at', ''); $data->thread = $this->_posts($post, $filters); break; case 'delete': if ($pid = Request::getInt('post', 0)) { $this->deletethread($pid, false); } $data->thread = $this->_thread($post, $filters); break; case 'thread': $data->thread = $this->_thread($post, $filters); break; case 'search': $filters['search'] = Request::getVar('search', ''); $data->threads = $this->_threadsSearch($post, $filters); break; case 'sticky': $post->set('sticky', Request::getInt('sticky', 0)); $post->save(); break; case 'both': default: $filters['start_at'] = Request::getVar('start_at', ''); $data->thread = $this->_thread($post, $filters); $filters['start_at'] = Request::getVar('threads_start', ''); $data->threads = $this->_threads($post, $filters); break; case 'threads': default: $filters['parent'] = $post->get('id'); $filters['start_at'] = Request::getVar('threads_start', ''); $data->threads = $this->_threads($post, $filters); break; } if ($this->getError()) { $data->success = false; $data->errors = $this->getErrors(); } ob_clean(); header('Content-type: text/plain'); echo json_encode($data); exit; } switch ($action) { case 'search': $filters['search'] = Request::getVar('search', ''); $data = $this->_threadsSearch($post, $filters); $threads = $data->posts; break; default: if ($action == 'delete') { if ($pid = Request::getInt('post', 0)) { $this->deletethread($pid, false); } } $filters['parent'] = 0; $data = $this->_threadsSearch($post, $filters); $threads = $data->posts; break; } $data = null; if ($thread) { $post = Post::oneOrNew($thread); $data = $this->_thread($post, $filters); } $view = $this->view('lecture', 'threads')->set('course', $course)->set('unit', $unit)->set('lecture', $lecture)->set('option', 'com_courses')->set('config', $this->params)->set('filters', $filters)->set('post', $post)->set('data', $data)->set('thread', $thread)->set('threads', $threads)->setErrors($this->getErrors()); return $view->loadTemplate(); }
/** * Get public link and list/unlist * * * @return string */ protected function _share() { // Incoming $id = trim(Request::getInt('p', 0)); // Load requested page $page = $this->note->page($id); if (!$page->get('id')) { App::redirect(Route::url($this->model->link('notes'))); } // Output HTML $view = new \Hubzero\Plugin\View(array('folder' => 'projects', 'element' => 'notes', 'name' => 'pubsettings')); // Get/update public stamp for page $view->set('publicStamp', $this->note->getPublicStamp($page->get('id'), true)); $view->set('option', $this->_option); if (!$view->publicStamp) { $this->setError(Lang::txt('PLG_PROJECTS_NOTES_ERROR_SHARE')); // Output error $view = new \Hubzero\Plugin\View(array('folder' => 'projects', 'element' => 'files', 'name' => 'error')); $view->set('title', ''); $view->setErrors($this->getErrors()); return $view->loadTemplate(); } $view->set('project', $this->model); $view->set('url', $url); $view->set('config', $this->model->config()); $view->set('page', $page); $view->set('revision', $page->revision('current')); $view->set('masterscope', 'projects' . DS . $this->model->get('alias') . DS . 'notes'); $view->set('params', $this->params); $view->set('ajax', Request::getInt('ajax', 0)); $view->setErrors($this->getErrors()); return $view->loadTemplate(); }