コード例 #1
0
 /**
  * Method to display a view.
  *
  * @param	boolean			If true, the view output will be cached
  * @param	array			An array of safe url parameters and their variable types, for valid values see {@link JFilterInput::clean()}.
  *
  * @return	JController		This object to support chaining.
  * @since	1.5
  */
 public function display($cachable = false, $urlparams = false)
 {
     Plugin::import('content');
     $vName = Request::getCmd('view', 'images');
     switch ($vName) {
         case 'imagesList':
             $mName = 'list';
             $vLayout = Request::getCmd('layout', 'default');
             break;
         case 'images':
         default:
             $vLayout = Request::getCmd('layout', 'default');
             $mName = 'manager';
             $vName = 'images';
             break;
     }
     $vType = Document::getType();
     // Get/Create the view
     $view = $this->getView($vName, $vType);
     $view->addTemplatePath(JPATH_COMPONENT_ADMINISTRATOR . '/views/' . strtolower($vName) . '/tmpl');
     // Get/Create the model
     if ($model = $this->getModel($mName)) {
         // Push the model into the view (as default)
         $view->setModel($model, true);
     }
     // Set the layout
     $view->setLayout($vLayout);
     // Display the view
     $view->display();
     return $this;
 }
コード例 #2
0
 /**
  * Method to display a view.
  *
  * @param	boolean			If true, the view output will be cached
  * @param	array			An array of safe url parameters and their variable types, for valid values see {@link JFilterInput::clean()}.
  *
  * @return	JController		This object to support chaining.
  * @since	1.5
  */
 public function display($cachable = false, $urlparams = false)
 {
     // Get the document object.
     $document = App::get('document');
     // Set the default view name and format from the Request.
     $vName = Request::getCmd('view', 'categories');
     $vFormat = $document->getType();
     $lName = Request::getCmd('layout', 'default');
     $id = Request::getInt('id');
     // Check for edit form.
     if ($vName == 'category' && $lName == 'edit' && !$this->checkEditId('com_categories.edit.category', $id)) {
         // Somehow the person just went to the form - we don't allow that.
         $this->setError(Lang::txt('JLIB_APPLICATION_ERROR_UNHELD_ID', $id));
         $this->setMessage($this->getError(), 'error');
         $this->setRedirect(Route::url('index.php?option=com_categories&view=categories&extension=' . $this->extension, false));
         return false;
     }
     // Get and render the view.
     if ($view = $this->getView($vName, $vFormat)) {
         // Get the model for the view.
         $model = $this->getModel($vName, 'CategoriesModel', array('name' => $vName . '.' . substr($this->extension, 4)));
         // Push the model into the view (as default).
         $view->setModel($model, true);
         $view->setLayout($lName);
         // Push document object into the view.
         $view->assignRef('document', $document);
         // Load the submenu.
         require_once JPATH_COMPONENT . '/helpers/categories.php';
         CategoriesHelper::addSubmenu($model->getState('filter.extension'));
         $view->display();
     }
     return $this;
 }
コード例 #3
0
ファイル: browse.php プロジェクト: mined-gatech/hubzero-cms
 /**
  * Execute a task
  *
  * @return     void
  */
 public function execute()
 {
     $this->warehouse = new Warehouse();
     $user = User::getRoot();
     $this->warehouse->addAccessLevels($user->getAuthorisedViewLevels());
     // Get the task
     $this->_task = Request::getCmd('task', '');
     if (empty($this->_task)) {
         $this->_task = 'home';
         $this->registerTask('__default', $this->_task);
     }
     $executed = false;
     if (!method_exists($this, $this->_task . 'Task')) {
         // Try to find a corresponding collection
         $cId = $this->warehouse->collectionExists($this->_task);
         if ($cId) {
             // if match is found -- browse collection
             $executed = true;
             $this->browseCollection($cId);
         } else {
             App::abort(404, Lang::txt('Collection Not Found'));
         }
     }
     if (!$executed) {
         parent::execute();
     }
 }
コード例 #4
0
ファイル: related.php プロジェクト: mined-gatech/hubzero-cms
 /**
  * Return data on a course view (this will be some form of HTML)
  *
  * @param      object  $course Current course
  * @param      string  $active Current active area
  * @return     array
  */
 public function onCourseViewAfter($course)
 {
     $instructors = $course->instructors();
     if (count($instructors) <= 0) {
         return;
     }
     $ids = array();
     foreach ($instructors as $instructor) {
         $ids[] = (int) $instructor->get('user_id');
     }
     $database = App::get('db');
     $query = "SELECT DISTINCT c.*\n\t\t\t\t\tFROM `#__courses` AS c\n\t\t\t\t\tJOIN `#__courses_members` AS m ON m.course_id=c.id AND m.student=0\n\t\t\t\t\tLEFT JOIN `#__courses_roles` AS r ON r.id=m.role_id\n\t\t\t\t\tWHERE r.alias='instructor'\n\t\t\t\t\tAND m.user_id IN (" . implode(",", $ids) . ")\n\t\t\t\t\tAND m.student=0\n\t\t\t\t\tAND c.state=1\n\t\t\t\t\tAND c.id !=" . $database->Quote($course->get('id')) . " LIMIT " . (int) $this->params->get('display_limit', 3);
     $database->setQuery($query);
     if ($courses = $database->loadObjectList()) {
         $view = $this->view('default', 'overview');
         $view->option = Request::getCmd('option', 'com_courses');
         $view->controller = Request::getWord('controller', 'course');
         $view->course = $course;
         $view->name = $this->_name;
         $view->courses = $courses;
         $view->ids = $ids;
         // Return the output
         return $view->loadTemplate();
     }
 }
コード例 #5
0
 /**
  * Method to display a view.
  *
  * @param	boolean			If true, the view output will be cached
  * @param	array			An array of safe url parameters and their variable types, for valid values see {@link JFilterInput::clean()}.
  *
  * @return	JController		This object to support chaining.
  * @since	1.5
  */
 public function display($cachable = false, $urlparams = false)
 {
     require_once JPATH_COMPONENT . '/helpers/menus.php';
     // Load the submenu.
     MenusHelper::addSubmenu(Request::getCmd('view'));
     $view = Request::getCmd('view', 'menus');
     $layout = Request::getCmd('layout', 'default');
     $id = Request::getInt('id');
     // Check for edit form.
     if ($view == 'menu' && $layout == 'edit' && !$this->checkEditId('com_menus.edit.menu', $id)) {
         // Somehow the person just went to the form - we don't allow that.
         $this->setError(Lang::txt('JLIB_APPLICATION_ERROR_UNHELD_ID', $id));
         $this->setMessage($this->getError(), 'error');
         $this->setRedirect(Route::url('index.php?option=com_menus&view=menus', false));
         return false;
     } elseif ($view == 'item' && $layout == 'edit' && !$this->checkEditId('com_menus.edit.item', $id)) {
         // Somehow the person just went to the form - we don't allow that.
         $this->setError(Lang::txt('JLIB_APPLICATION_ERROR_UNHELD_ID', $id));
         $this->setMessage($this->getError(), 'error');
         $this->setRedirect(Route::url('index.php?option=com_menus&view=items', false));
         return false;
     }
     parent::display();
     return $this;
 }
コード例 #6
0
ファイル: articles.php プロジェクト: mined-gatech/hubzero-cms
 /**
  * Method to auto-populate the model state.
  *
  * Note. Calling getState in this method will result in recursion.
  *
  * @return	void
  * @since	1.6
  */
 protected function populateState($ordering = 'ordering', $direction = 'ASC')
 {
     $app = JFactory::getApplication();
     // List state information
     $value = Request::getUInt('limit', Config::get('list_limit', 0));
     $this->setState('list.limit', $value);
     $value = Request::getUInt('limitstart', 0);
     $this->setState('list.start', $value);
     $orderCol = Request::getCmd('filter_order', 'a.ordering');
     if (!in_array($orderCol, $this->filter_fields)) {
         $orderCol = 'a.ordering';
     }
     $this->setState('list.ordering', $orderCol);
     $listOrder = Request::getCmd('filter_order_Dir', 'ASC');
     if (!in_array(strtoupper($listOrder), array('ASC', 'DESC', ''))) {
         $listOrder = 'ASC';
     }
     $this->setState('list.direction', $listOrder);
     $params = $app->getParams();
     $this->setState('params', $params);
     if (!User::authorise('core.edit.state', 'com_content') && !User::authorise('core.edit', 'com_content')) {
         // filter on published for those who do not have edit or edit.state rights.
         $this->setState('filter.published', 1);
     }
     $this->setState('filter.language', App::get('language.filter'));
     // process show_noauth parameter
     if (!$params->get('show_noauth')) {
         $this->setState('filter.access', true);
     } else {
         $this->setState('filter.access', false);
     }
     $this->setState('layout', Request::getCmd('layout'));
 }
コード例 #7
0
ファイル: category.php プロジェクト: mined-gatech/hubzero-cms
 /**
  * Constructor.
  *
  * @param  array  $config  An optional associative array of configuration settings.
  *
  * @since  1.6
  * @see    JController
  */
 public function __construct($config = array())
 {
     parent::__construct($config);
     // Guess the Lang message prefix. Defaults to the option.
     if (empty($this->extension)) {
         $this->extension = Request::getCmd('extension', 'com_content');
     }
 }
コード例 #8
0
ファイル: help.php プロジェクト: mined-gatech/hubzero-cms
 /**
  * Method to get the page
  * @return string page
  */
 function &getPage()
 {
     if (is_null($this->page)) {
         $page = Request::getCmd('page', 'JHELP_START_HERE');
         $this->page = JHelp::createUrl($page);
     }
     return $this->page;
 }
コード例 #9
0
ファイル: reviews.php プロジェクト: mined-gatech/hubzero-cms
 /**
  * Return data on a resource view (this will be some form of HTML)
  *
  * @param      object  $resource Current resource
  * @param      string  $option    Name of the component
  * @param      array   $areas     Active area(s)
  * @param      string  $rtrn      Data to be returned
  * @return     array
  */
 public function onCourseView($course, $active = null)
 {
     // Prepare the response
     $response = with(new \Hubzero\Base\Object())->set('name', $this->_name)->set('title', Lang::txt('PLG_COURSES_' . strtoupper($this->_name)));
     $this->option = Request::getCmd('option', 'com_courses');
     $this->controller = Request::getWord('controller', 'course');
     $database = App::get('db');
     $tbl = new \Hubzero\Item\Comment($database);
     // Build the HTML meant for the tab's metadata overview
     $view = $this->view('default', 'metadata');
     $view->set('option', $this->option)->set('controller', $this->controller)->set('course', $course)->set('tbl', $tbl);
     $response->set('metadata', $view->loadTemplate());
     // Check if our area is in the array of areas we want to return results for
     if ($response->get('name') == $active) {
         $this->view = $this->view('default', 'view');
         $this->view->database = $this->database = $database;
         $this->view->option = $this->option;
         $this->view->controller = $this->controller;
         $this->view->obj = $this->obj = $course;
         $this->view->obj_type = $this->obj_type = substr($this->option, 4);
         $this->view->url = $this->url = Route::url($course->link() . '&active=' . $this->_name, false, true);
         $this->view->depth = 0;
         $this->view->tbl = $tbl;
         $this->_authorize();
         $this->view->params = $this->params;
         $this->view->task = $this->task = Request::getVar('action', '');
         switch ($this->task) {
             // Entries
             case 'save':
                 $this->_save();
                 break;
             case 'new':
                 $this->_view();
                 break;
             case 'edit':
                 $this->_view();
                 break;
             case 'delete':
                 $this->_delete();
                 break;
             case 'view':
                 $this->_view();
                 break;
             case 'vote':
                 $this->_vote();
                 break;
             default:
                 $this->_view();
                 break;
         }
         foreach ($this->getErrors() as $error) {
             $this->view->setError($error);
         }
         // Return the output
         $response->set('html', $this->view->loadTemplate());
     }
     return $response;
 }
コード例 #10
0
ファイル: article.php プロジェクト: mined-gatech/hubzero-cms
 /**
  * Class constructor.
  *
  * @param   array  $config  A named array of configuration variables.
  *
  * @since	1.6
  */
 public function __construct($config = array())
 {
     // An article edit form can come from the articles or featured view.
     // Adjust the redirect view on the value of 'return' in the request.
     if (Request::getCmd('return') == 'featured') {
         $this->view_list = 'featured';
         $this->view_item = 'article&return=featured';
     }
     parent::__construct($config);
 }
コード例 #11
0
ファイル: articles.php プロジェクト: mined-gatech/hubzero-cms
 /**
  * Constructor.
  *
  * @param	array	$config	An optional associative array of configuration settings.
  * @return	ContentControllerArticles
  * @see		JController
  * @since	1.6
  */
 public function __construct($config = array())
 {
     // Articles default form can come from the articles or featured view.
     // Adjust the redirect view on the value of 'view' in the request.
     if (Request::getCmd('view') == 'featured') {
         $this->view_list = 'featured';
     }
     parent::__construct($config);
     $this->registerTask('unfeatured', 'featured');
 }
コード例 #12
0
ファイル: notes.php プロジェクト: mined-gatech/hubzero-cms
 /**
  * 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', JText::_('PLG_COURSES_' . strtoupper($this->_name) . '_BLURB'))->set('default_access', $this->params->get('plugin_access', 'members'))->set('display_menu_tab', true)->set('icon', '270D');
     if ($describe) {
         return $response;
     }
     if (!($active = Request::getVar('active'))) {
         Request::setVar('active', $active = $this->_name);
     }
     if ($response->get('name') == $active) {
         $this->course = $course;
         $this->offering = $offering;
         $this->database = App::get('db');
         $this->view = with($this->view('default', 'notes'))->set('option', Request::getCmd('option', 'com_courses'))->set('controller', Request::getWord('controller', 'course'))->set('course', $course)->set('offering', $offering)->set('no_html', Request::getInt('no_html', 0));
         $this->view->filters = array('section_id' => $offering->section()->get('id'), 'search' => Request::getVar('search', ''));
         $this->view->model = new \Plugins\Courses\Notes\Models\Note(0);
         if ($action = strtolower(Request::getWord('action', ''))) {
             switch ($action) {
                 case 'add':
                     $result = $this->_edit();
                     break;
                 case 'edit':
                     $result = $this->_edit();
                     break;
                 case 'save':
                     $result = $this->_save();
                     break;
                 case 'delete':
                     $result = $this->_delete();
                     break;
                 case 'download':
                     $result = $this->_download();
                     break;
                 default:
                     $result = $this->_list();
                     break;
             }
         }
         if ($this->view->no_html && $result) {
             $note = new stdClass();
             $note->id = $result;
             $note->success = true;
             if ($this->getError()) {
                 $note->success = false;
                 $note->error = $this->getError();
             }
             ob_clean();
             echo json_encode($note);
             return;
         }
         $response->set('html', $this->view->loadTemplate());
     }
     // Return the output
     return $response;
 }
コード例 #13
0
ファイル: blog.php プロジェクト: kevinwojo/hubzero-cms
 /**
  * Loads the plugin language file
  *
  * @param   string   $extension  The extension for which a language file should be loaded
  * @param   string   $basePath   The basepath to use
  * @return  boolean  True, if the file has successfully loaded.
  */
 public function loadLanguage($extension = '', $basePath = PATH_APP)
 {
     if (empty($extension)) {
         $extension = 'plg_' . $this->_type . '_' . $this->_name;
     }
     $group = \Hubzero\User\Group::getInstance(Request::getCmd('cn'));
     if ($group && $group->isSuperGroup()) {
         $basePath = PATH_APP . DS . 'site' . DS . 'groups' . DS . $group->get('gidNumber');
     }
     $lang = \App::get('language');
     return $lang->load(strtolower($extension), $basePath, null, false, true) || $lang->load(strtolower($extension), PATH_APP . DS . 'plugins' . DS . $this->_type . DS . $this->_name, null, false, true) || $lang->load(strtolower($extension), PATH_APP . DS . 'plugins' . DS . $this->_type . DS . $this->_name, null, false, true) || $lang->load(strtolower($extension), PATH_CORE . DS . 'plugins' . DS . $this->_type . DS . $this->_name, null, false, true);
 }
コード例 #14
0
ファイル: overview.php プロジェクト: mined-gatech/hubzero-cms
 /**
  * Return data on a course view (this will be some form of HTML)
  * 
  * @param      object  $course Current course
  * @param      string  $active Current active area
  * @return     array
  */
 public function onCourseView($course, $active = null)
 {
     $response = with(new \Hubzero\Base\Object())->set('name', $this->_name)->set('title', Lang::txt('PLG_COURSES_' . strtoupper($this->_name)));
     // Check if our area is in the array of areas we want to return results for
     if ($response->get('name') == $active) {
         $view = $this->view('default', 'overview');
         $view->set('option', Request::getCmd('option', 'com_courses'))->set('controller', Request::getWord('controller', 'course'))->set('course', $course);
         $response->set('html', $view->loadTemplate());
     }
     // Return the output
     return $response;
 }
コード例 #15
0
 /**
  * Method to auto-populate the model state.
  *
  * Note. Calling getState in this method will result in recursion.
  *
  * @return  void
  * @since   1.6
  */
 protected function populateState()
 {
     // Set the component (option) we are dealing with.
     $component = Request::getCmd('component');
     $this->setState('component.option', $component);
     // Set an alternative path for the configuration file.
     if ($path = Request::getString('path')) {
         $path = Filesystem::cleanPath(PATH_ROOT . '/' . $path);
         \Hubzero\Filesystem\Util::checkCheck($path);
         $this->setState('component.path', $path);
     }
 }
コード例 #16
0
 /**
  * Method to show a newsfeeds view
  *
  * @param	boolean			If true, the view output will be cached
  * @param	array			An array of safe url parameters and their variable types, for valid values see {@link JFilterInput::clean()}.
  *
  * @return	JController		This object to support chaining.
  * @since	1.5
  */
 public function display($cachable = false, $urlparams = false)
 {
     $cachable = true;
     // Set the default view name and format from the Request.
     $vName = Request::getCmd('view', 'categories');
     Request::setVar('view', $vName);
     if (User::get('id') || $_SERVER['REQUEST_METHOD'] == 'POST' && ($vName = 'category')) {
         $cachable = false;
     }
     $safeurlparams = array('id' => 'INT', 'limit' => 'UINT', 'limitstart' => 'UINT', 'filter_order' => 'CMD', 'filter_order_Dir' => 'CMD', 'lang' => 'CMD');
     parent::display($cachable, $safeurlparams);
 }
コード例 #17
0
ファイル: form.php プロジェクト: mined-gatech/hubzero-cms
 /**
  * Method to auto-populate the model state.
  *
  * Note. Calling getState in this method will result in recursion.
  *
  * @since	1.6
  */
 protected function populateState()
 {
     $app = JFactory::getApplication();
     // Load state from the request.
     $pk = Request::getInt('a_id');
     $this->setState('article.id', $pk);
     $this->setState('article.catid', Request::getInt('catid'));
     $return = Request::getVar('return', null, 'default', 'base64');
     $this->setState('return_page', urldecode(base64_decode($return)));
     // Load the parameters.
     $params = $app->getParams();
     $this->setState('params', $params);
     $this->setState('layout', Request::getCmd('layout'));
 }
コード例 #18
0
ファイル: Help.php プロジェクト: mined-gatech/hubzero-cms
 /**
  * Fetches the button HTML code.
  *
  * @param   string   $type       Unused string.
  * @param   string   $ref        The name of the help screen (its key reference).
  * @param   boolean  $com        Use the help file in the component directory.
  * @param   string   $override   Use this URL instead of any other.
  * @param   string   $component  Name of component to get Help (null for current component)
  * @return  string
  */
 public function fetchButton($type = 'Help', $url = null, $width = 700, $height = 500)
 {
     $text = \Lang::txt('JTOOLBAR_HELP');
     $class = $this->fetchIconClass('help');
     if (!strstr('?', $url) && !strstr('&', $url) && substr($url, 0, 4) != 'http') {
         $url = \Route::url('index.php?option=com_help&component=' . \Request::getCmd('option') . '&page=' . $url);
         $doTask = "Joomla.popupWindow('{$url}', '" . \Lang::txt('JHELP', true) . "', {$width}, {$height}, 1)";
     } else {
         $doTask = $this->_getCommand($ref, $com, $override, $component);
     }
     $html = '<a data-title="' . $text . '" href="#" onclick="' . $doTask . '" rel="help" class="toolbar">' . "\n";
     $html .= '<span class="' . $class . '">' . "\n" . $text . "\n" . '</span>' . "\n";
     $html .= '</a>' . "\n";
     return $html;
 }
コード例 #19
0
ファイル: override.php プロジェクト: mined-gatech/hubzero-cms
 /**
  * Method to get a single record.
  *
  * @param		string	$pk	The key name.
  *
  * @return	mixed		Object on success, false otherwise.
  *
  * @since		2.5
  */
 public function getItem($pk = null)
 {
     require_once JPATH_COMPONENT . '/helpers/languages.php';
     $pk = !empty($pk) ? $pk : Request::getCmd('id');
     $filename = PATH_APP . '/bootstrap/' . $this->getState('filter.client') . '/language/overrides/' . $this->getState('filter.language', 'en-GB') . '.override.ini';
     $strings = LanguagesHelper::parseFile($filename);
     $result = new stdClass();
     $result->key = '';
     $result->override = '';
     if (isset($strings[$pk])) {
         $result->key = $pk;
         $result->override = $strings[$pk];
     }
     return $result;
 }
コード例 #20
0
ファイル: manager.php プロジェクト: mined-gatech/hubzero-cms
 function getState($property = null, $default = null)
 {
     static $set;
     if (!$set) {
         $folder = Request::getVar('folder', '', '', 'path');
         $this->setState('folder', $folder);
         $fieldid = Request::getCmd('fieldid', '');
         $this->setState('field.id', $fieldid);
         $parent = str_replace("\\", "/", dirname($folder));
         $parent = $parent == '.' ? null : $parent;
         $this->setState('parent', $parent);
         $set = true;
     }
     return parent::getState($property, $default);
 }
コード例 #21
0
ファイル: supergroup.php プロジェクト: kevinwojo/hubzero-cms
 /**
  * Method that fires after before a super group displays a super group comonent
  *
  * @return  void
  */
 public function onBeforeRenderSuperGroupComponent()
 {
     // get request options
     $option = Request::getCmd('option', '');
     // make sure we in groups
     if ($option != 'com_groups') {
         return;
     }
     $cn = Request::getVar('cn', '');
     $active = Request::getVar('active', '');
     // load group object
     $group = \Hubzero\User\Group::getInstance($cn);
     // make sure we have all the needed stuff
     if (is_object($group) && $group->isSuperGroup() && isset($cn) && isset($active)) {
         // get com_groups params to get upload path
         $uploadPath = $this->filespace($group);
         $componentPath = $uploadPath . DS . 'components';
         $componentRouter = $componentPath . DS . 'com_' . $active . DS . 'router.php';
         // if we have a router
         if (file_exists($componentRouter)) {
             // include router
             require_once $componentRouter;
             // build function name
             $parseRouteFunction = ucfirst($active) . 'ParseRoute';
             $parseRouteFunction = str_replace(array('-', '.'), '', $parseRouteFunction);
             // if we have a build route functions, run it
             if (function_exists($parseRouteFunction)) {
                 // get current route and remove prefix
                 $currentRoute = rtrim(Request::path(), '/');
                 $currentRoute = trim(str_replace('groups/' . $group->get('cn') . '/' . $active, '', $currentRoute), '/');
                 // split route into segements
                 $segments = explode('/', $currentRoute);
                 // run segments through parser
                 $vars = $parseRouteFunction($segments);
                 // set each var
                 foreach ($vars as $key => $var) {
                     Request::setVar($key, $var);
                 }
             }
         }
         // remove "sg_" prefix for super group query params
         foreach (Request::query() as $k => $v) {
             if (strpos($k, 'sg_') !== false) {
                 Request::setVar(str_replace('sg_', '', $k), $v);
             }
         }
     }
 }
コード例 #22
0
ファイル: activity.php プロジェクト: kevinwojo/hubzero-cms
 /**
  * Event call to return data for a specific member
  *
  * @param   object  $user    User
  * @param   object  $member  Members Profile
  * @param   string  $option  Component name
  * @param   string  $areas   Plugins to return data
  * @return  array
  */
 public function onMembers($user, $member, $option, $areas)
 {
     $returnhtml = true;
     $arr = array('html' => '', 'metadata' => '');
     // Check if our area is in the array of areas we want to return results for
     if (is_array($areas)) {
         if (!array_intersect($areas, $this->onMembersAreas($user, $member)) && !array_intersect($areas, array_keys($this->onMembersAreas($user, $member)))) {
             $returnhtml = false;
         }
     }
     // Are we returning HTML?
     if ($returnhtml) {
         $this->member = $member;
         $action = Request::getCmd('action', 'feed');
         if (!$this->params->get('email_digests')) {
             $action = 'feed';
         }
         switch ($action) {
             case 'settings':
                 $arr['html'] = $this->settingsAction();
                 break;
             case 'savesettings':
                 $arr['html'] = $this->savesettingsAction();
                 break;
             case 'remove':
                 $arr['html'] = $this->removeAction();
                 break;
             case 'unstar':
                 $arr['html'] = $this->starAction();
                 break;
             case 'star':
                 $arr['html'] = $this->starAction();
                 break;
             case 'feed':
             default:
                 $arr['html'] = $this->feedAction();
                 break;
         }
     }
     $arr['metadata'] = array();
     // Get the number of unread messages
     $unread = Hubzero\Activity\Recipient::all()->whereEquals('scope', 'user')->whereEquals('scope_id', $member->get('id'))->whereEquals('state', 1)->whereEquals('viewed', '0000-00-00 00:00:00')->total();
     // Return total message count
     $arr['metadata']['count'] = $unread;
     // Return data
     return $arr;
 }
コード例 #23
0
 /**
  * Rebuild the nested set tree.
  *
  * @return	bool	False on failure or error, true on success.
  * @since	1.6
  */
 public function rebuild()
 {
     Session::checkToken() or exit(Lang::txt('JINVALID_TOKEN'));
     $extension = Request::getCmd('extension');
     $this->setRedirect(Route::url('index.php?option=com_categories&view=categories&extension=' . $extension, false));
     // Initialise variables.
     $model = $this->getModel();
     if ($model->rebuild()) {
         // Rebuild succeeded.
         $this->setMessage(Lang::txt('COM_CATEGORIES_REBUILD_SUCCESS'));
         return true;
     } else {
         // Rebuild failed.
         $this->setMessage(Lang::txt('COM_CATEGORIES_REBUILD_FAILURE'));
         return false;
     }
 }
コード例 #24
0
 /**
  * Method to display a view.
  *
  * @param	boolean			If true, the view output will be cached
  * @param	array			An array of safe url parameters and their variable types, for valid values see {@link JFilterInput::clean()}.
  *
  * @return	JController		This object to support chaining.
  * @since	1.5
  */
 public function display($cachable = false, $urlparams = false)
 {
     // Load the submenu.
     TemplatesHelper::addSubmenu(Request::getCmd('view', 'styles'));
     $view = Request::getCmd('view', 'styles');
     $layout = Request::getCmd('layout', 'default');
     $id = Request::getInt('id');
     // Check for edit form.
     if ($view == 'style' && $layout == 'edit' && !$this->checkEditId('com_templates.edit.style', $id)) {
         // Somehow the person just went to the form - we don't allow that.
         $this->setError(Lang::txt('JLIB_APPLICATION_ERROR_UNHELD_ID', $id));
         $this->setMessage($this->getError(), 'error');
         $this->setRedirect(Route::url('index.php?option=com_templates&view=styles', false));
         return false;
     }
     parent::display();
 }
コード例 #25
0
 /**
  * task to set the default language
  */
 function setDefault()
 {
     // Check for request forgeries
     Session::checkToken() or exit(Lang::txt('JInvalid_Token'));
     $cid = Request::getCmd('cid', '');
     $model = $this->getModel('installed');
     if ($model->publish($cid)) {
         $msg = Lang::txt('COM_LANGUAGES_MSG_DEFAULT_LANGUAGE_SAVED');
         $type = 'message';
     } else {
         $msg = $this->getError();
         $type = 'error';
     }
     $client = $model->getClient();
     $clientId = $model->getState('filter.client_id');
     $this->setredirect('index.php?option=com_languages&view=installed&client=' . $clientId, $msg, $type);
 }
コード例 #26
0
ファイル: novnc.php プロジェクト: mined-gatech/hubzero-cms
 /**
  * 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();
 }
コード例 #27
0
ファイル: image.php プロジェクト: kevinwojo/hubzero-cms
 /**
  * Display the button
  *
  * @param   string   $name
  * @param   string   $asset
  * @param   integer  $author
  * @return  array    A two element array of (imageName, textToInsert)
  */
 public function onDisplay($name, $asset, $author)
 {
     $params = Component::params('com_media');
     $extension = Request::getCmd('option');
     if ($asset == '') {
         $asset = $extension;
     }
     if (User::authorise('core.edit', $asset) || User::authorise('core.create', $asset) || count(User::getAuthorisedCategories($asset, 'core.create')) > 0 || User::authorise('core.edit.own', $asset) && $author == User::get('id') || count(User::getAuthorisedCategories($extension, 'core.edit')) > 0 || count(User::getAuthorisedCategories($extension, 'core.edit.own')) > 0 && $author == User::get('id')) {
         $link = 'index.php?option=com_media&amp;view=images&amp;tmpl=component&amp;e_name=' . $name . '&amp;asset=' . $asset . '&amp;author=' . $author;
         Html::behavior('modal');
         $button = new \Hubzero\Base\Object();
         $button->set('modal', true);
         $button->set('link', $link);
         $button->set('text', Lang::txt('PLG_IMAGE_BUTTON_IMAGE'));
         $button->set('name', 'image');
         $button->set('options', "{handler: 'iframe', size: {x: 800, y: 500}}");
         return $button;
     }
     return false;
 }
コード例 #28
0
ファイル: overview.php プロジェクト: kevinwojo/hubzero-cms
 /**
  * Event call for displaying usage data
  *
  * @param   string  $option         Component name
  * @param   string  $task           Component task
  * @param   object  $db             Database
  * @param   array   $months         Month names (Jan -> Dec)
  * @param   array   $monthsReverse  Month names in reverse (Dec -> Jan)
  * @param   string  $enddate        Time period
  * @return  string  HTML
  */
 public function onUsageDisplay($option, $task, $db, $months, $monthsReverse, $enddate)
 {
     // Check if our task is the area we want to return results for
     if ($task) {
         if (!in_array($task, $this->onUsageAreas()) && !in_array($task, array_keys($this->onUsageAreas()))) {
             return '';
         }
     }
     if ($action = Request::getCmd('action')) {
         if (method_exists($this, $action)) {
             return $this->{$action}();
         }
     }
     $period = (int) $this->periodToInt(Request::getCmd('period', $this->params->get('period', 'prior12')));
     $cur_year = $this->params->get('currentYear', floor(date("Y")));
     $cur_month = $this->params->get('currentMonth', floor(date("n")));
     $datetime = $cur_year . '-' . $cur_month;
     $view = $this->view('default', 'usage')->set('element', $this->_name)->set('period', $period)->set('datetime', $datetime)->set('message', $this->params->get('message', ''));
     return $view->loadTemplate();
 }
コード例 #29
0
ファイル: outline.php プロジェクト: mined-gatech/hubzero-cms
 /**
  * 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', JText::_('PLG_COURSES_' . strtoupper($this->_name) . '_BLURB'))->set('default_access', $this->params->get('plugin_access', 'members'))->set('display_menu_tab', true)->set('icon', 'f0ae');
     if ($describe) {
         return $response;
     }
     if (!($active = Request::getVar('active'))) {
         Request::setVar('active', $active = $this->_name);
     }
     // Check to see if user is member and plugin access requires members
     $sparams = new \Hubzero\Config\Registry($course->offering()->section()->get('params'));
     if (!$course->offering()->section()->access('view') && !$sparams->get('preview', 0)) {
         $response->set('html', '<p class="info">' . Lang::txt('COURSES_PLUGIN_REQUIRES_MEMBER', ucfirst($active)) . '</p>');
         return $response;
     }
     // Determine if we need to return any HTML (meaning this is the active plugin)
     if ($response->get('name') == $active) {
         $this->css();
         // Course and action
         $this->course = $course;
         $action = strtolower(Request::getWord('action', ''));
         $this->view = $this->view('default', 'outline');
         $this->view->option = Request::getCmd('option', 'com_courses');
         $this->view->controller = Request::getWord('controller', 'course');
         $this->view->course = $course;
         $this->view->offering = $offering;
         $this->view->config = $course->config();
         switch ($action) {
             case 'build':
                 $this->_build();
                 break;
             default:
                 $this->js();
                 $this->_display();
                 break;
         }
         $response->set('html', $this->view->loadTemplate());
     }
     // Return the output
     return $response;
 }
コード例 #30
0
 /**
  * Method to display a view.
  *
  * @param	boolean			If true, the view output will be cached
  * @param	array			An array of safe url parameters and their variable types, for valid values see {@link JFilterInput::clean()}.
  *
  * @return	JController		This object to support chaining.
  * @since	1.5
  */
 public function display($cachable = false, $urlparams = false)
 {
     // Load the submenu.
     UsersHelper::addSubmenu(Request::getCmd('view', 'users'));
     $view = Request::getCmd('view', 'users');
     $layout = Request::getCmd('layout', 'default');
     $id = Request::getInt('id');
     if (!$this->canView($view)) {
         throw new Exception(Lang::txt('JERROR_ALERTNOAUTHOR'), 404);
         return;
     }
     // Check for edit form.
     if ($view == 'user' && $layout == 'edit' && !$this->checkEditId('com_users.edit.user', $id)) {
         // Somehow the person just went to the form - we don't allow that.
         $this->setError(Lang::txt('JLIB_APPLICATION_ERROR_UNHELD_ID', $id));
         $this->setMessage($this->getError(), 'error');
         $this->setRedirect(Route::url('index.php?option=com_users&view=users', false));
         return false;
     } elseif ($view == 'group' && $layout == 'edit' && !$this->checkEditId('com_users.edit.group', $id)) {
         // Somehow the person just went to the form - we don't allow that.
         $this->setError(Lang::txt('JLIB_APPLICATION_ERROR_UNHELD_ID', $id));
         $this->setMessage($this->getError(), 'error');
         $this->setRedirect(Route::url('index.php?option=com_users&view=groups', false));
         return false;
     } elseif ($view == 'level' && $layout == 'edit' && !$this->checkEditId('com_users.edit.level', $id)) {
         // Somehow the person just went to the form - we don't allow that.
         $this->setError(Lang::txt('JLIB_APPLICATION_ERROR_UNHELD_ID', $id));
         $this->setMessage($this->getError(), 'error');
         $this->setRedirect(Route::url('index.php?option=com_users&view=levels', false));
         return false;
     } elseif ($view == 'note' && $layout == 'edit' && !$this->checkEditId('com_users.edit.note', $id)) {
         // Somehow the person just went to the form - we don't allow that.
         $this->setError(Lang::txt('JLIB_APPLICATION_ERROR_UNHELD_ID', $id));
         $this->setMessage($this->getError(), 'error');
         $this->setRedirect(Route::url('index.php?option=com_users&view=notes', false));
         return false;
     }
     return parent::display();
 }