Esempio n. 1
0
 /**
  * Displays a list of courses
  *
  * @return	void
  */
 public function displayTask()
 {
     // Incoming
     $this->view->filters = array('search' => urldecode(trim(Request::getState($this->_option . '.' . $this->_controller . '.search', 'search', ''))), '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'), 'state' => trim(Request::getState($this->_option . '.' . $this->_controller . '.state', 'state', '-1')), 'sort' => trim(Request::getState($this->_option . '.' . $this->_controller . '.sort', 'filter_order', 'title')), 'sort_Dir' => trim(Request::getState($this->_option . '.' . $this->_controller . '.sortdir', 'filter_order_Dir', 'ASC')));
     // In case limit has been changed, adjust limitstart accordingly
     $this->view->filters['start'] = $this->view->filters['limit'] != 0 ? floor($this->view->filters['start'] / $this->view->filters['limit']) * $this->view->filters['limit'] : 0;
     $model = \Components\Courses\Models\Courses::getInstance();
     $this->view->filters['count'] = true;
     $this->view->total = $model->courses($this->view->filters);
     $this->view->filters['count'] = false;
     $this->view->rows = $model->courses($this->view->filters);
     // Set any errors
     foreach ($this->getErrors() as $error) {
         $this->view->setError($error);
     }
     // Output the HTML
     $this->view->display();
 }
Esempio n. 2
0
 /**
  * Return data on a group view (this will be some form of HTML)
  *
  * @param      object  $group      Current group
  * @param      string  $option     Name of the component
  * @param      string  $authorized User's authorization level
  * @param      integer $limit      Number of records to pull
  * @param      integer $limitstart Start of records to pull
  * @param      string  $action     Action to perform
  * @param      array   $access     What can be accessed
  * @param      array   $areas      Active area(s)
  * @return     array
  */
 public function onGroup($group, $option, $authorized, $limit = 0, $limitstart = 0, $action = '', $access, $areas = null)
 {
     $return = 'html';
     $active = $this->_name;
     $active_real = 'discussion';
     // The output array we're returning
     $arr = array('html' => '', 'name' => $active);
     //get this area details
     $this_area = $this->onGroupAreas();
     // Check if our area is in the array of areas we want to return results for
     if (is_array($areas) && $limit) {
         if (!in_array($this_area['name'], $areas)) {
             $return = 'metadata';
         }
     }
     $this->group = $group;
     $this->database = App::get('db');
     require_once PATH_CORE . DS . 'components' . DS . 'com_courses' . DS . 'models' . DS . 'courses.php';
     $model = \Components\Courses\Models\Courses::getInstance();
     $filters = array('group' => $group->get('cn'), 'group_id' => $group->get('gidNumber'), 'count' => true);
     $arr['metadata']['count'] = $model->courses($filters);
     // Build the HTML
     if ($return == 'html') {
         $view = $this->view('default', 'display');
         $view->option = $option;
         $view->group = $group;
         $view->filters = $filters;
         $view->filters['count'] = false;
         $view->filters['limit'] = Request::getState($option . '.plugin.courses.limit', 'limit', Config::get('list_limit'), 'int');
         $view->filters['start'] = Request::getState($option . '.plugin.courses.limitstart', 'limitstart', 0, 'int');
         $view->filters['sortby'] = Request::getState($option . '.plugin.courses.sortby', 'sortby', '');
         $view->filters['search'] = Request::getState($option . '.plugin.courses.search', 'search', '');
         $view->filters['index'] = '';
         $view->filters['tag'] = '';
         if (!in_array($view->filters['sortby'], array('alias', 'title', 'popularity'))) {
             $view->filters['sortby'] = 'title';
         }
         switch ($view->filters['sortby']) {
             case 'popularity':
                 $view->filters['sort'] = 'students';
                 $view->filters['sort_Dir'] = 'DESC';
                 break;
             case 'title':
             case 'alias':
             default:
                 $view->filters['sort'] = $view->filters['sortby'];
                 $view->filters['sort_Dir'] = 'ASC';
                 break;
         }
         $view->total = $arr['metadata']['count'];
         $view->results = $model->courses($view->filters);
         $arr['html'] = $view->loadTemplate();
     }
     return $arr;
 }
Esempio n. 3
0
">
						<input type="hidden" name="task" value="save" />

						<div class="input-wrap">
							<label for="offering_id"><?php 
echo Lang::txt('COM_COURSES_OFFERING');
?>
:</label><br />
							<select name="fields[offering_id]" id="offering_id">
								<option value="-1"><?php 
echo Lang::txt('COM_COURSES_SELECT');
?>
</option>
								<?php 
require_once PATH_CORE . DS . 'components' . DS . 'com_courses' . DS . 'models' . DS . 'courses.php';
$model = \Components\Courses\Models\Courses::getInstance();
if ($model->courses()->total() > 0) {
    foreach ($model->courses() as $course) {
        ?>
											<optgroup label="<?php 
        echo $this->escape(stripslashes($course->get('alias')));
        ?>
">
								<?php 
        $j = 0;
        foreach ($course->offerings() as $i => $offering) {
            if ($offering->get('id') == $this->row->get('offering_id')) {
                $course_id = $offering->get('course_id');
            }
            ?>
												<option value="<?php 
Esempio n. 4
0
 /**
  * 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();
 }
Esempio n. 5
0
 /**
  * Get a list of courses
  *
  * @return \Hubzero\Base\ItemList
  */
 private function _getCourses()
 {
     // Filters for courses
     $filters = array('state' => 1, 'group' => $this->_getArg('group', ''), 'tag' => $this->_getArg('tag', ''), 'limit' => $this->_getArg('limit', 5), 'sort' => 'title', 'sort_Dir' => 'ASC');
     // make sure to replace group cname with group id
     if (isset($filters['group'])) {
         $group = \Hubzero\User\Group::getInstance($filters['group']);
         if ($group) {
             $filters['group_id'] = $group->get('gidNumber');
             unset($filters['group']);
         }
     }
     // instantiate courses model
     $model = \Components\Courses\Models\Courses::getInstance();
     // get a list of courses
     // make sure to clear in case we have more then one
     $courses = $model->courses($filters, true);
     // return courses
     return $courses;
 }
Esempio n. 6
0
 /**
  * Edit a role
  *
  * @return     void
  */
 public function editTask($row = null)
 {
     Request::setVar('hidemainmenu', 1);
     if (!is_object($row)) {
         // Incoming (expecting an array)
         $id = Request::getVar('id', array(0));
         if (is_array($id)) {
             $id = !empty($id) ? $id[0] : 0;
         }
         // Load the object
         $row = new Tables\Role($this->database);
         $row->load($id);
     }
     $this->view->row = $row;
     if (!$this->view->row->id) {
         $this->view->row->created_by = User::get('id');
         $this->view->row->created = Date::toSql();
     }
     require_once dirname(dirname(__DIR__)) . DS . 'models' . DS . 'courses.php';
     $model = \Components\Courses\Models\Courses::getInstance();
     $this->view->courses = $model->courses();
     // Set any errors
     foreach ($this->getErrors() as $error) {
         \Notify::error($error);
     }
     // Output the HTML
     $this->view->setLayout('edit')->display();
 }