コード例 #1
0
 /**
  * Save permissions to asset
  *
  * @return void
  */
 public function saveTask()
 {
     $scope = Request::getWord('scope', false);
     $scope_id = Request::getInt('scope_id', false);
     if (!$scope || !$scope_id) {
         echo json_encode(array('success' => false));
         exit;
     }
     // Process Rules
     $data = Request::getVar(strtolower($scope));
     $rules = array();
     if ($data && count($data) > 0) {
         foreach ($data as $rule => $parts) {
             if ($parts && count($parts) > 0) {
                 foreach ($parts as $group => $perms) {
                     if ($perms == '') {
                         continue;
                     }
                     $rules[$rule][$group] = $perms;
                 }
             }
         }
     }
     $class = 'Components\\Time\\Models\\' . $scope;
     $model = $class::oneOrFail($scope_id);
     $model->assetRules = new \JAccessRules($rules);
     $model->save();
     echo json_encode(array('success' => true));
     exit;
 }
コード例 #2
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();
     }
 }
コード例 #3
0
 /**
  * Hook for after parsing route
  *
  * @return void
  */
 public function onAfterRoute()
 {
     if (User::isGuest()) {
         $current = Request::getWord('option', '');
         $current .= ($controller = Request::getWord('controller', false)) ? '.' . $controller : '';
         $current .= ($task = Request::getWord('task', false)) ? '.' . $task : '';
         $current .= ($view = Request::getWord('view', false)) ? '.' . $view : '';
         if (App::isSite()) {
             $pages = ['com_users.login'];
             $granted = Session::get('user_consent', false);
             if (in_array($current, $pages) && !$granted) {
                 Request::setVar('option', 'com_users');
                 Request::setVar('view', 'userconsent');
             }
         } else {
             if (App::isAdmin()) {
                 $exceptions = ['com_login.grantconsent'];
                 $granted = Session::get('user_consent', false);
                 if (!in_array($current, $exceptions) && !$granted) {
                     Request::setVar('option', 'com_login');
                     Request::setVar('task', 'consent');
                 }
             }
         }
     }
 }
コード例 #4
0
ファイル: password.php プロジェクト: mined-gatech/hubzero-cms
 /**
  * Hook for after parsing route
  *
  * @return void
  */
 public function onAfterRoute()
 {
     if (App::isSite() && !User::isGuest()) {
         $exceptions = ['com_users.logout', 'com_users.userlogout', 'com_support.tickets.save.index', 'com_members.changepassword', 'com_members.media.download.profiles'];
         $current = Request::getWord('option', '');
         $current .= ($controller = Request::getWord('controller', false)) ? '.' . $controller : '';
         $current .= ($task = Request::getWord('task', false)) ? '.' . $task : '';
         $current .= ($view = Request::getWord('view', false)) ? '.' . $view : '';
         $badpassword = Session::get('badpassword', false);
         $expiredpassword = Session::get('expiredpassword', false);
         // If guest, proceed as normal and they'll land on the login page
         if (!in_array($current, $exceptions) && ($badpassword || $expiredpassword)) {
             Request::setVar('option', 'com_members');
             Request::setVar('task', 'changepassword');
             Request::setVar('id', 0);
             if ($badpassword) {
                 Request::setVar('Your password does not meet current site requirements. Please change your password now.');
             }
             if ($expiredpassword) {
                 Request::setVar('Your password has expired. Please change your password now.');
             }
             $this->event->stop();
         }
     }
 }
コード例 #5
0
ファイル: watch.php プロジェクト: kevinwojo/hubzero-cms
 /**
  * Return data on a publication sub view (this will be some form of HTML)
  *
  * @param   object   $publication  Current publication
  * @param   string   $option       Name of the component
  * @param   integer  $miniview     View style
  * @return  array
  */
 public function onPublicationSub($publication, $option, $miniview = 0)
 {
     $arr = array('html' => '', 'metadata' => '', 'name' => 'watch');
     // Check if our area is in the array of areas we want to return results for
     $areas = array('watch');
     if (!array_intersect($areas, $this->onPublicationSubAreas($publication)) && !array_intersect($areas, array_keys($this->onPublicationSubAreas($publication)))) {
         return false;
     }
     // Only show for logged-in users
     if (User::isGuest()) {
         return false;
     }
     $this->publication = $publication;
     $this->action = strtolower(Request::getWord('action', ''));
     switch ($this->action) {
         case 'subscribe':
         case 'unsubscribe':
             $arr['html'] = $this->_subscribe();
             break;
         default:
             $arr['html'] = $this->_status();
             break;
     }
     return $arr;
 }
コード例 #6
0
 /**
  * Hook for after parsing route
  *
  * @return void
  */
 public function onAfterRoute()
 {
     if (in_array(App::get('client')->id, $this->params->get('clients', [1]))) {
         $exceptions = ['com_login.logout', 'com_users.logout'];
         $current = Request::getWord('option', '');
         $current .= ($task = Request::getWord('task', false)) ? '.' . $task : '';
         $current .= ($view = Request::getWord('view', false)) ? '.' . $view : '';
         // If guest, proceed as normal and they'll land on the login page
         if (!User::isGuest() && !in_array($current, $exceptions)) {
             // Get factor status
             $status = App::get('session')->get('authfactors.status', null);
             if ($status === false) {
                 // If not a guest, and auth factors checks are done and have failed,
                 // log out so we start over
                 $logout = 'logout' . ucfirst(App::get('client')->alias);
                 self::$logout();
             } else {
                 if ($status === null) {
                     // If not a guest, but no factor verification has been completed,
                     // procede with auth factor checks as applicable
                     $factors = 'factors' . ucfirst(App::get('client')->alias);
                     self::$factors();
                 }
             }
         }
     }
 }
コード例 #7
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;
 }
コード例 #8
0
ファイル: router.php プロジェクト: mined-gatech/hubzero-cms
 /**
  * Parse the segments of a URL.
  *
  * @param   array  &$segments  The segments of the URL to parse.
  * @return  array  The URL attributes to be used by the application.
  */
 public function parse(&$segments)
 {
     $vars = array();
     if (empty($segments)) {
         return $vars;
     }
     //$vars['task'] = 'view';
     $e = array_pop($segments);
     $s = implode(DS, $segments);
     if ($s) {
         $vars['scope'] = $s;
     }
     $vars['pagename'] = $e;
     if (!isset($vars['task']) || !$vars['task']) {
         $vars['task'] = \Request::getWord('task', '');
     }
     switch ($vars['task']) {
         case 'upload':
         case 'download':
         case 'deletefolder':
         case 'deletefile':
         case 'media':
         case 'list':
             $vars['controller'] = 'media';
             break;
         case 'history':
         case 'compare':
         case 'approve':
         case 'deleterevision':
             $vars['controller'] = 'history';
             break;
         case 'editcomment':
         case 'addcomment':
         case 'savecomment':
         case 'reportcomment':
         case 'removecomment':
         case 'comments':
             $vars['controller'] = 'comments';
             break;
         case 'delete':
         case 'edit':
         case 'save':
         case 'rename':
         case 'saverename':
         case 'approve':
         default:
             $vars['controller'] = 'page';
             break;
     }
     if (substr(strtolower($vars['pagename']), 0, strlen('image:')) == 'image:' || substr(strtolower($vars['pagename']), 0, strlen('file:')) == 'file:') {
         $vars['controller'] = 'media';
         $vars['task'] = 'download';
     }
     return $vars;
 }
コード例 #9
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;
 }
コード例 #10
0
ファイル: spamjail.php プロジェクト: kevinwojo/hubzero-cms
 /**
  * Hook for after parsing route
  *
  * @return void
  */
 public function onAfterRoute()
 {
     if (App::isSite() && !User::isGuest()) {
         $exceptions = ['com_users.logout', 'com_support.tickets.save.index', 'com_members.media.download.profiles'];
         $current = Request::getWord('option', '');
         $current .= ($controller = Request::getWord('controller', false)) ? '.' . $controller : '';
         $current .= ($task = Request::getWord('task', false)) ? '.' . $task : '';
         $current .= ($view = Request::getWord('view', false)) ? '.' . $view : '';
         // If guest, proceed as normal and they'll land on the login page
         if (!in_array($current, $exceptions) && User::getInstance()->reputation->isJailed()) {
             Request::setVar('option', 'com_users');
             Request::setVar('view', 'spamjail');
         }
     }
 }
コード例 #11
0
ファイル: opengraph.php プロジェクト: kevinwojo/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  void
  */
 public function onResources($model, $option, $areas, $rtrn = 'all')
 {
     if (!App::isSite()) {
         return;
     }
     if (Request::getWord('tmpl') || Request::getWord('format') || Request::getInt('no_html')) {
         return;
     }
     $view = $this->view();
     Document::addCustomTag('<meta property="og:title" content="' . $view->escape($model->resource->title) . '" />');
     Document::addCustomTag('<meta property="og:description" content="' . $view->escape($model->resource->introtext) . '" />');
     Document::addCustomTag('<meta property="og:type" content="article" />');
     $url = Route::url('index.php?option=com_resources&' . ($model->resource->alias ? 'alias=' . $model->resource->alias : 'id=' . $model->resource->id));
     $url = rtrim(Request::root(), '/') . '/' . trim($url, '/');
     Document::addCustomTag('<meta property="og:url" content="' . $url . '" />');
 }
コード例 #12
0
 /**
  * Hook for after parsing route
  *
  * @return void
  */
 public function onAfterRoute()
 {
     if (App::isSite() && !User::isGuest()) {
         $exceptions = ['com_users.logout', 'com_users.userlogout', 'com_support.tickets.save.index', 'com_support.tickets.new.index', 'com_members.media.download.profiles'];
         $current = Request::getWord('option', '');
         $current .= ($controller = Request::getWord('controller', false)) ? '.' . $controller : '';
         $current .= ($task = Request::getWord('task', false)) ? '.' . $task : '';
         $current .= ($view = Request::getWord('view', false)) ? '.' . $view : '';
         // If guest, proceed as normal and they'll land on the login page
         if (!in_array($current, $exceptions) && !User::get('approved')) {
             Request::setVar('option', 'com_users');
             Request::setVar('view', 'unapproved');
             $this->event->stop();
         }
     }
 }
コード例 #13
0
ファイル: unconfirmed.php プロジェクト: kevinwojo/hubzero-cms
 /**
  * Hook for after parsing route
  *
  * @return void
  */
 public function onAfterRoute()
 {
     if (App::isSite() && !User::isGuest()) {
         $exceptions = ['com_users.logout', 'com_users.userlogout', 'com_support.tickets.save.index', 'com_support.tickets.new.index', 'com_members.media.download.profiles', 'com_members.register.unconfirmed.profiles', 'com_members.register.change.profiles', 'com_members.register.resend.profiles', 'com_members.register.resend', 'com_members.register.confirm.profiles', 'com_members.register.confirm', 'com_members.save.profiles', 'com_members.profiles.save', 'com_members.profiles.save.profiles', 'com_members.changepassword'];
         $current = Request::getWord('option', '');
         $current .= ($controller = Request::getWord('controller', false)) ? '.' . $controller : '';
         $current .= ($task = Request::getWord('task', false)) ? '.' . $task : '';
         $current .= ($view = Request::getWord('view', false)) ? '.' . $view : '';
         if (User::get('id') && User::get('activation') != 1 && User::get('activation') != 3 && !in_array($current, $exceptions)) {
             Request::setVar('option', 'com_members');
             Request::setVar('controller', 'register');
             Request::setVar('task', 'unconfirmed');
             $this->event->stop();
         }
     }
 }
コード例 #14
0
ファイル: twitter.php プロジェクト: kevinwojo/hubzero-cms
 /**
  * Method to call when redirected back from twitter after authentication
  * Grab the return URL if set and handle denial of app privileges from twitter
  *
  * @param   object  $credentials
  * @param   object  $options
  * @return  void
  */
 public function login(&$credentials, &$options)
 {
     if ($return = Request::getVar('return', '', 'method', 'base64')) {
         $b64dreturn = base64_decode($return);
         if (!\Hubzero\Utility\Uri::isInternal($b64dreturn)) {
             $b64dreturn = '';
         }
     }
     $options['return'] = $b64dreturn;
     // Check to make sure they didn't deny our application permissions
     if (Request::getWord('denied', false)) {
         // User didn't authorize our app or clicked cancel
         App::redirect(Route::url('index.php?option=com_users&view=login&return=' . $return), Lang::txt('PLG_AUTHENTICATION_TWITTER_MUST_AUTHORIZE_TO_LOGIN', Config::get('sitename')), 'error');
         return;
     }
 }
コード例 #15
0
 function display($tpl = null)
 {
     // Assign variables to the view
     $authenticator = \Request::getWord('authenticator', false);
     \Hubzero\Document\Assets::addComponentStylesheet('com_user', 'login.css');
     // Get the site name
     $sitename = \Config::get('sitename');
     // Get the display name for the current plugin being used
     $plugin = Plugin::byType('authentication', $authenticator);
     $pparams = new \Hubzero\Config\Registry($plugin->params);
     $display_name = $pparams->get('display_name', ucfirst($plugin->name));
     $this->assign('authenticator', $authenticator);
     $this->assign('sitename', $sitename);
     $this->assign('display_name', $display_name);
     parent::display($tpl);
 }
コード例 #16
0
 /**
  * Hook for after parsing route
  *
  * @return void
  */
 public function onAfterRoute()
 {
     if (App::isSite() && !User::isGuest()) {
         $exceptions = ['com_users.logout', 'com_users.userlogout', 'com_support.tickets.save.index', 'com_support.tickets.new.index', 'com_members.media.download.profiles', 'com_members.save.profiles'];
         $current = Request::getWord('option', '');
         $current .= ($controller = Request::getWord('controller', false)) ? '.' . $controller : '';
         $current .= ($task = Request::getWord('task', false)) ? '.' . $task : '';
         $current .= ($view = Request::getWord('view', false)) ? '.' . $view : '';
         if (!in_array($current, $exceptions) && Session::get('registration.incomplete')) {
             // First check if we're heading to the registration pages, and allow that through
             if (Request::getWord('option') == 'com_members' && (Request::getWord('controller') == 'register' || Request::getWord('view') == 'register')) {
                 // Set linkaccount far to false at this point, otherwise we'd get stuck in a loop
                 Session::set('linkaccount', false);
                 $this->event->stop();
                 return;
             }
             // Joomla tmp users
             if (User::get('tmp_user')) {
                 Request::setVar('option', 'com_members');
                 Request::setVar('controller', 'register');
                 Request::setVar('task', 'create');
                 Request::setVar('act', '');
             } else {
                 if (substr(User::get('email'), -8) == '@invalid') {
                     $usersConfig = Component::params('com_users');
                     $simpleRegistration = $usersConfig->get('simple_registration', false);
                     if (Session::get('linkaccount', true) && !$simpleRegistration) {
                         Request::setVar('option', 'com_users');
                         Request::setVar('view', 'link');
                     } else {
                         Request::setVar('option', 'com_members');
                         Request::setVar('controller', 'register');
                         Request::setVar('task', 'update');
                         Request::setVar('act', '');
                     }
                 } else {
                     Request::setVar('option', 'com_members');
                     Request::setVar('task', 'view');
                     Request::setVar('id', User::get('id'));
                     Request::setVar('active', 'profile');
                 }
             }
             $this->event->stop();
         }
     }
 }
コード例 #17
0
 /**
  * Hook for after parsing route
  *
  * @return void
  */
 public function onAfterRoute()
 {
     if (App::isSite() && !User::isGuest()) {
         $exceptions = ['com_users.logout', 'com_users.userlogout', 'com_support.tickets.save.index', 'com_support.tickets.new.index', 'com_members.media.download.profiles', 'com_members.register.unconfirmed.profiles', 'com_members.register.change.profiles', 'com_members.register.resend.profiles', 'com_members.register.confirm.profiles'];
         $current = Request::getWord('option', '');
         $current .= ($controller = Request::getWord('controller', false)) ? '.' . $controller : '';
         $current .= ($task = Request::getWord('task', false)) ? '.' . $task : '';
         $current .= ($view = Request::getWord('view', false)) ? '.' . $view : '';
         $xprofile = \Hubzero\User\Profile::getInstance(User::get('id'));
         if (is_object($xprofile) && $xprofile->get('emailConfirmed') != 1 && $xprofile->get('emailConfirmed') != 3 && !in_array($current, $exceptions)) {
             Request::setVar('option', 'com_members');
             Request::setVar('controller', 'register');
             Request::setVar('task', 'unconfirmed');
             $this->event->stop();
         }
     }
 }
コード例 #18
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();
 }
コード例 #19
0
 /**
  * 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', 'f095');
     if ($describe) {
         return $response;
     }
     if (!($active = Request::getVar('active'))) {
         Request::setVar('active', $active = $this->_name);
     }
     // Get a student count
     $response->set('meta_count', $offering->announcements(array('count' => true)));
     // Check if our area is in the array of areas we want to return results for
     if ($response->get('name') == $active) {
         // Set some variables so other functions have access
         $this->option = Request::getCmd('option', 'com_courses');
         $this->course = $course;
         $this->offering = $offering;
         // Set the page title
         Document::setTitle(Document::getTitle() . ': ' . Lang::txt('PLG_COURSES_ANNOUNCEMENTS'));
         Pathway::append(Lang::txt('PLG_COURSES_' . strtoupper($this->_name)), $this->offering->link() . '&active=' . $this->_name);
         require_once Component::path('com_courses') . DS . 'models' . DS . 'announcement.php';
         $action = Request::getWord('action', '');
         switch (strtolower($action)) {
             case 'save':
                 $response->set('html', $this->_save());
                 break;
             case 'new':
                 $response->set('html', $this->_edit());
                 break;
             case 'edit':
                 $response->set('html', $this->_edit());
                 break;
             case 'delete':
                 $response->set('html', $this->_delete());
                 break;
             default:
                 $response->set('html', $this->_list());
                 break;
         }
     }
     // Return the output
     return $response;
 }
コード例 #20
0
ファイル: authy.php プロジェクト: mined-gatech/hubzero-cms
 /**
  * Renders the auth factor challenge
  *
  * @return string
  **/
 public function onRenderChallenge()
 {
     // Setup our response
     $response = new \Hubzero\Base\Object();
     // Route based on an action
     switch (Request::getWord('action', '')) {
         case 'register':
             $this->register();
             break;
         case 'verify':
             $this->verify();
             break;
         default:
             $this->display();
             break;
     }
     $response->set('html', $this->view->loadTemplate());
     // Return the response
     return $response;
 }
コード例 #21
0
ファイル: watch.php プロジェクト: kevinwojo/hubzero-cms
 /**
  * Return data on a resource sub view (this will be some form of HTML)
  *
  * @param   object   $resource  Current resource
  * @param   string   $option    Name of the component
  * @param   integer  $miniview  View style
  * @return  array
  */
 public function onResourcesSub($resource, $option, $miniview = 0)
 {
     $arr = array('area' => $this->_name, 'html' => '', 'metadata' => '');
     // Only show for logged-in users
     if (User::isGuest()) {
         return;
     }
     $this->resource = $resource;
     $this->action = strtolower(Request::getWord('action', ''));
     $this->link = 'index.php?option=com_resources&' . ($this->resource->alias ? 'alias=' . $this->resource->alias : 'id=' . $this->resource->id);
     switch ($this->action) {
         case 'subscribe':
         case 'unsubscribe':
             $arr['html'] = $this->subscribeAction();
             break;
         default:
             $arr['html'] = $this->statusAction();
             break;
     }
     return $arr;
 }
コード例 #22
0
ファイル: courses.php プロジェクト: mined-gatech/hubzero-cms
 /**
  * Event call to return data for a specific member
  *
  * @param      object  $user   User
  * @param      object  $member MembersProfile
  * @param      string  $option Component name
  * @param      string  $areas  Plugins to return data
  * @return     array   Return array of html
  */
 public function onMembers($user, $member, $option, $areas)
 {
     $returnhtml = true;
     // 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;
         }
     }
     $arr = array('html' => '', 'metadata' => array('count' => 0));
     $this->database = App::get('db');
     $this->member = $member;
     require_once PATH_CORE . DS . 'components' . DS . 'com_courses' . DS . 'models' . DS . 'offering.php';
     $model = \Components\Courses\Models\Offering::getInstance();
     $roles = $model->roles();
     $hasRoles = 0;
     if ($roles) {
         foreach ($roles as $i => $role) {
             $roles[$i]->total = $this->_getData('count', $role->alias);
             if ($roles[$i]->total > 0) {
                 $hasRoles++;
             }
             $arr['metadata']['count'] += $roles[$i]->total;
         }
     }
     // Build the HTML
     if ($returnhtml) {
         $view = $this->view('default', 'display');
         $view->option = $option;
         $view->member = $member;
         $view->roles = $roles;
         $view->hasRoles = $hasRoles;
         $view->filters = array();
         $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['task'] = strtolower(Request::getVar('action', ''));
         $view->filters['sort'] = strtolower(Request::getWord('sort', 'enrolled'));
         if (!in_array($view->filters['sort'], array('enrolled', 'title'))) {
             $view->filters['sort'] = 'enrolled';
         }
         $view->total = 0;
         $view->results = null;
         $view->active = null;
         $view->results = null;
         if ($view->hasRoles >= 1) {
             $found = false;
             if ($view->filters['task']) {
                 foreach ($roles as $i => $role) {
                     if ($view->filters['task'] == $role->alias && $role->total > 0) {
                         $found = true;
                     }
                 }
             }
             if (!$found) {
                 foreach ($roles as $i => $role) {
                     if ($role->total > 0) {
                         $view->filters['task'] = $role->alias;
                         break;
                     }
                 }
             }
         }
         foreach ($view->roles as $i => $role) {
             if ($view->filters['task'] == $role->alias) {
                 $view->active = $view->roles[$i];
                 $view->total = $view->roles[$i]->total;
             }
         }
         if (!is_null($view->active)) {
             $view->results = $this->_getData('list', $view->active->alias, $view->filters);
         }
         foreach ($this->getErrors() as $error) {
             $view->setError($error);
         }
         $arr['html'] = $view->loadTemplate();
     }
     return $arr;
 }
コード例 #23
0
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 * THE SOFTWARE.
 *
 * HUBzero is a registered trademark of Purdue University.
 *
 * @package   hubzero-cms
 * @author    Shawn Rice <*****@*****.**>
 * @copyright Copyright 2005-2015 HUBzero Foundation, LLC.
 * @license   http://opensource.org/licenses/MIT MIT
 */
namespace Components\Resources\Admin;

$option = \Request::getCmd('option', 'com_resources');
$task = \Request::getWord('task', '');
if (!\User::authorise('core.manage', $option)) {
    return \App::abort(404, \Lang::txt('JERROR_ALERTNOAUTHOR'));
}
// Include jtables
require_once dirname(__DIR__) . DS . 'tables' . DS . 'resource.php';
require_once dirname(__DIR__) . DS . 'tables' . DS . 'type.php';
require_once dirname(__DIR__) . DS . 'tables' . DS . 'assoc.php';
require_once dirname(__DIR__) . DS . 'tables' . DS . 'review.php';
require_once dirname(__DIR__) . DS . 'tables' . DS . 'doi.php';
require_once dirname(__DIR__) . DS . 'tables' . DS . 'contributor.php';
require_once dirname(__DIR__) . DS . 'tables' . DS . 'license.php';
require_once dirname(__DIR__) . DS . 'tables' . DS . 'contributor' . DS . 'role.php';
require_once dirname(__DIR__) . DS . 'tables' . DS . 'contributor' . DS . 'roletype.php';
// include helpers
require_once dirname(__DIR__) . DS . 'helpers' . DS . 'html.php';
コード例 #24
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 = 'resources';
     // The output array we're returning
     $arr = array('html' => '');
     //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';
         }
     }
     //set group members plugin access level
     $group_plugin_acl = $access[$active];
     //get the group members
     $members = $group->get('members');
     if ($return == 'html') {
         //if set to nobody make sure cant access
         if ($group_plugin_acl == 'nobody') {
             $arr['html'] = '<p class="info">' . Lang::txt('GROUPS_PLUGIN_OFF', ucfirst($active)) . '</p>';
             return $arr;
         }
         //check if guest and force login if plugin access is registered or members
         if (User::isGuest() && ($group_plugin_acl == 'registered' || $group_plugin_acl == 'members')) {
             $area = Request::getWord('area', 'resource');
             $url = Route::url('index.php?option=com_groups&cn=' . $group->get('cn') . '&active=' . $active . '&area=' . $area);
             App::redirect(Route::url('index.php?option=com_users&view=login&return=' . base64_encode($url)), Lang::txt('GROUPS_PLUGIN_REGISTERED', ucfirst($active)), 'warning');
             return;
         }
         //check to see if user is member and plugin access requires members
         if (!in_array(User::get('id'), $members) && $group_plugin_acl == 'members' && $authorized != 'admin') {
             $arr['html'] = '<p class="info">' . Lang::txt('GROUPS_PLUGIN_REQUIRES_MEMBER', ucfirst($active)) . '</p>';
             return $arr;
         }
         require_once PATH_CORE . DS . 'components' . DS . 'com_search' . DS . 'models' . DS . 'hubgraph' . DS . 'client.php';
         $hgConf = \Components\Search\Models\Hubgraph\Configuration::instance();
         if ($hgConf->isOptionEnabled('com_groups')) {
             $view = $this->view('default', 'results');
             // Pass the view some info
             $view->option = $option;
             $view->group = $group;
             ob_start();
             $_GET['group'] = $group->gidNumber;
             define('HG_INLINE', 1);
             require PATH_CORE . DS . 'components' . DS . 'com_search' . DS . 'controllers' . DS . 'hubgraph.php';
             $controller = new \Components\Search\Controllers\Hubgraph();
             $controller->execute();
             $controller->redirect();
             $view->hubgraphResponse = ob_get_clean();
             return array('html' => $view->loadTemplate('hubgraph'));
         }
     }
     $database = App::get('db');
     // Incoming paging vars
     $sort = Request::getVar('sort', 'date');
     if (!in_array($sort, array('date', 'title', 'ranking', 'rating'))) {
         $sort = 'date';
     }
     $access = Request::getVar('access', 'all');
     if (!in_array($access, array('all', 'public', 'protected', 'private'))) {
         $access = 'date';
     }
     $config = Component::params('com_resources');
     if ($return == 'metadata') {
         if ($config->get('show_ranking')) {
             $sort = 'ranking';
         } elseif ($config->get('show_rating')) {
             $sort = 'rating';
         }
     }
     // Trigger the functions that return the areas we'll be using
     $rareas = $this->getResourcesAreas();
     // Get the active category
     $area = Request::getWord('area', 'resources');
     if ($area) {
         $activeareas = array($area);
     } else {
         $limit = 5;
         $activeareas = $rareas;
     }
     if ($return == 'metadata') {
         $ls = -1;
     } else {
         $ls = $limitstart;
     }
     // Get the search result totals
     $ts = $this->getResources($group, $authorized, 0, $ls, $sort, $access, $activeareas);
     $totals = array($ts);
     // Get the total results found (sum of all categories)
     $i = 0;
     $total = 0;
     $cats = array();
     foreach ($rareas as $c => $t) {
         $cats[$i]['category'] = $c;
         // Do sub-categories exist?
         if (is_array($t) && !empty($t)) {
             // They do - do some processing
             $cats[$i]['title'] = ucfirst($c);
             $cats[$i]['total'] = 0;
             $cats[$i]['_sub'] = array();
             $z = 0;
             // Loop through each sub-category
             foreach ($t as $s => $st) {
                 // Ensure a matching array of totals exist
                 if (is_array($totals[$i]) && !empty($totals[$i]) && isset($totals[$i][$z])) {
                     // Add to the parent category's total
                     $cats[$i]['total'] = $cats[$i]['total'] + $totals[$i][$z];
                     // Get some info for each sub-category
                     $cats[$i]['_sub'][$z]['category'] = $s;
                     $cats[$i]['_sub'][$z]['title'] = $st;
                     $cats[$i]['_sub'][$z]['total'] = $totals[$i][$z];
                 }
                 $z++;
             }
         } else {
             // No sub-categories - this should be easy
             $cats[$i]['title'] = $t;
             $cats[$i]['total'] = !is_array($totals[$i]) ? $totals[$i] : 0;
         }
         // Add to the overall total
         $total = $total + intval($cats[$i]['total']);
         $i++;
     }
     // Do we have an active area?
     if (count($activeareas) == 1 && !is_array(current($activeareas))) {
         $active = $activeareas[0];
     } else {
         $active = '';
     }
     // Get the search results
     $r = $this->getResources($group, $authorized, $limit, $limitstart, $sort, $access, $activeareas);
     $results = array($r);
     // Build the output
     switch ($return) {
         case 'html':
             // Instantiate a vew
             $view = $this->view('default', 'results');
             // Pass the view some info
             $view->option = $option;
             $view->group = $group;
             $view->authorized = $authorized;
             $view->totals = $totals;
             $view->results = $results;
             $view->cats = $cats;
             $view->active = $active;
             $view->limitstart = $limitstart;
             $view->limit = $limit;
             $view->total = $total;
             $view->sort = $sort;
             $view->access = $access;
             foreach ($this->getErrors() as $error) {
                 $view->setError($error);
             }
             // Return the output
             $arr['metadata']['count'] = $total;
             $arr['html'] = $view->loadTemplate();
             break;
         case 'metadata':
             $arr['metadata']['count'] = $total;
             break;
     }
     // Return the output
     return $arr;
 }
コード例 #25
0
ファイル: courses.php プロジェクト: sumudinie/hubzero-cms
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 * THE SOFTWARE.
 *
 * HUBzero is a registered trademark of Purdue University.
 *
 * @package   hubzero-cms
 * @copyright Copyright 2005-2015 HUBzero Foundation, LLC.
 * @license   http://opensource.org/licenses/MIT MIT
 */
// No direct access.
defined('_HZEXEC_') or die;
$this->css()->js();
$txt = '';
$html = '';
$mode = strtolower(Request::getWord('mode', ''));
if ($mode != 'preview') {
    switch ($this->model->resource->published) {
        case 1:
            $txt .= '';
            break;
            // published
        // published
        case 2:
            $txt .= '<span>[' . Lang::txt('COM_RESOURCES_DRAFT_EXTERNAL') . ']</span> ';
            break;
            // external draft
        // external draft
        case 3:
            $txt .= '<span>[' . Lang::txt('COM_RESOURCES_PENDING') . ']</span> ';
            break;
コード例 #26
0
ファイル: series.php プロジェクト: kevinwojo/hubzero-cms
    }
    ?>
		</aside><!-- / .aside extracontent -->
	</section>

	<?php 
    // Show course listings under 'about' tab
    if ($this->tab == 'about' && $ccount > 0) {
        // Build the results
        $sortbys = array('date' => Lang::txt('Date'), 'title' => Lang::txt('Title'), 'author' => Lang::txt('Author'), 'ordering' => Lang::txt('Ordering'));
        if ($this->model->params->get('show_ranking')) {
            $sortbys['ranking'] = Lang::txt('Ranking');
        }
        $defaultsort = $this->model->params->get('sort_children', 'ordering');
        $defaultsort = $this->model->params->get('show_ranking') ? 'ranking' : $defaultsort;
        $filters = array('sortby' => Request::getWord('sortby', $defaultsort), 'limit' => Request::getInt('limit', 0), 'start' => Request::getInt('limitstart', 0), 'id' => $this->model->resource->id);
        if (!isset($sortbys[$filters['sortby']])) {
            $filters['sortby'] = $defaultsort;
        }
        // Get children
        $children = $this->model->children('standalone', $filters['limit'], $filters['start'], $filters['sortby']);
        ?>
		<form method="get" action="<?php 
        echo Route::url('index.php?option=' . $this->option . '&' . ($this->model->resource->alias ? 'alias=' . $this->model->resource->alias : 'id=' . $this->model->resource->id));
        ?>
">
			<section class="section">
				<div class="subject">
					<h3>
						<?php 
        echo Lang::txt('In This Series');
コード例 #27
0
ファイル: item.php プロジェクト: kevinwojo/hubzero-cms
//   * published (not deleted)
//   * publish up before now
//   * publish down after now
if ($this->announcement->get('state') == 1 && $this->announcement->inPublishWindow()) {
    $class = 'published';
}
// Is it high priority?
if ($this->announcement->get('priority')) {
    $class .= ' high';
}
// Is it sticky?
if ($this->announcement->get('sticky')) {
    $class .= ' sticky';
}
//did the user already close this
$closed = Request::getWord('group_announcement_' . $this->announcement->get('id'), '', 'cookie');
if ($closed == 'closed' && $this->showClose == true) {
    return;
}
?>

<div class="announcement-container <?php 
echo $class;
?>
">
	<?php 
if (strstr($class, 'unpublished')) {
    ?>
		<span class="unpublished-message"><?php 
    echo Lang::txt('PLG_GROUPS_ANNOUNCEMENTS_NOT_ACTIVE');
    ?>
コード例 #28
0
 /**
  * Determines task being called and attempts to execute it
  *
  * @return  void
  */
 public function execute()
 {
     // Incoming task
     $this->_task = strtolower(\Request::getCmd('task', \Request::getWord('layout', '')));
     // Check if the task is in the taskMap
     if (isset($this->_taskMap[$this->_task])) {
         $doTask = $this->_taskMap[$this->_task];
     } elseif (isset($this->_taskMap['__default'])) {
         $doTask = $this->_taskMap['__default'];
     } else {
         throw new InvalidTaskException(Lang::txt('The requested task "%s" was not found.', $this->_task), 404);
     }
     $name = $this->_controller;
     $layout = preg_replace('/[^A-Z0-9_]/i', '', $doTask);
     if (!$this->_controller) {
         $cls = get_class($this);
         // Attempt to parse the controller name from the class name
         if (ucfirst($this->_name) . 'Controller' != $cls && preg_match('/(\\w)Controller(.*)/i', $cls, $r)) {
             $this->_controller = strtolower($r[2]);
             $name = $this->_controller;
             $layout = preg_replace('/[^A-Z0-9_]/i', '', $doTask);
         } else {
             if (preg_match('/(.?)Controllers\\\\(.*)/i', $cls, $r)) {
                 $this->_controller = strtolower($r[2]);
                 $name = $this->_controller;
                 $layout = preg_replace('/[^A-Z0-9_]/i', '', $doTask);
             } else {
                 $name = $doTask;
             }
         }
     }
     // Instantiate a view with layout the same name as the task
     $this->view = new View(array('base_path' => $this->_basePath, 'name' => $name, 'layout' => $layout));
     // Set some commonly used vars
     $this->view->set('option', $this->_option)->set('task', $doTask)->set('controller', $this->_controller);
     // Record the actual task being fired
     $doTask .= 'Task';
     // On before do task hook
     $this->_onBeforeDoTask();
     // Call the task
     $this->{$doTask}();
 }
コード例 #29
0
ファイル: outline.php プロジェクト: mined-gatech/hubzero-cms
 /**
  * Show the builder interface
  *
  * @return  string
  */
 private function _build()
 {
     if (!$this->course->access('manage')) {
         App::abort(401, Lang::txt('Not Authorized'));
         return;
     }
     // If we have a scope set, we're loading a specific outline piece (ex: a unit)
     if ($scope = Request::getWord('scope', false)) {
         // Setup view
         $this->view->setLayout("edit{$scope}");
         $this->css('build.css');
         $this->css($scope . '.css');
         $this->js($scope);
         // Add file uploader JS
         $this->js('jquery.iframe-transport', 'system');
         $this->js('jquery.fileupload', 'system');
         $this->view->title = "Edit {$scope}";
         $this->view->scope = $scope;
         $this->view->scope_id = Request::getInt('scope_id');
         return;
     }
     $this->css('jquery.ui.css', 'system');
     // Add outline builder style and script
     $this->css('build.css');
     $this->js('build');
     // Add Content box plugin
     $this->js('contentbox', 'system');
     $this->css('contentbox.css', 'system');
     // Add underscore
     $this->js('underscore-min', 'system');
     $this->js('jquery.hoverIntent', 'system');
     // Add 'uniform' js and css
     $this->css('uniform.css', 'system');
     $this->js('jquery.uniform', 'system');
     // Add file uploader JS
     $this->js('jquery.iframe-transport', 'system');
     $this->js('jquery.fileupload', 'system');
     // Use datetime picker, rather than just datepicker
     $this->js('jquery.timepicker', 'system');
     // Setup view
     $this->view->setLayout('build');
     $this->view->title = 'Build Outline';
 }
コード例 #30
0
ファイル: session.php プロジェクト: mined-gatech/hubzero-cms
defined('_HZEXEC_') or die;
Html::behavior('core');
//is this a share session thats read-only
$readOnly = false;
foreach ($this->shares as $share) {
    if (User::get('username') == $share->viewuser) {
        if (strtolower($share->readonly) == 'yes') {
            $readOnly = true;
        }
    }
}
include_once PATH_CORE . DS . 'components' . DS . 'com_tools' . DS . 'tables' . DS . 'preferences.php';
$database = App::get('db');
$preferences = new \Components\Tools\Tables\Preferences($database);
$preferences->loadByUser(User::get('id'));
$declared = Request::getWord('viewer');
if ($declared) {
    if (Request::getInt('preferred', 0)) {
        $preferences->set('user_id', User::get('id'));
        $preferences->param()->set('viewer', $declared);
        $preferences->store();
    }
} else {
    if ($declared = $preferences->param('viewer')) {
        Request::setVar('viewer', $declared);
    }
}
// We actually need to do this first so we know what viewer is the active one.
$output = Event::trigger('tools.onToolSessionView', array($this->app, $this->output, $readOnly));
$plugins = Event::trigger('tools.onToolSessionIdentify');
$this->css('tools.css')->js('sessions.js');