Ejemplo n.º 1
0
 /**
  * Perform actions when viewing a member profile
  *
  * @param   object  $user    Current user
  * @param   object  $member  Current member page
  * @param   string  $option  Start of records to pull
  * @param   array   $areas   Active area(s)
  * @return  array
  */
 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' => '');
     // Include models
     require_once PATH_CORE . DS . 'components' . DS . 'com_projects' . DS . 'models' . DS . 'project.php';
     include_once PATH_CORE . DS . 'components' . DS . 'com_projects' . DS . 'models' . DS . 'todo.php';
     // Get our models
     $this->todo = new \Components\Projects\Models\Todo();
     $this->model = new \Components\Projects\Models\Project();
     // Get member projects
     $this->projects = $this->model->table()->getUserProjectIds($member->get('id'));
     // Build filters
     $this->filters = array('projects' => $this->projects, 'limit' => $this->params->get('limit', 50), 'start' => 0, 'mine' => Request::getInt('mine', 0), 'sortby' => Request::getWord('sortby', 'due'), 'sortdir' => Request::getWord('sortdir', 'ASC'), 'assignedto' => Request::getInt('mine', 0) ? $member->get('id') : 0, 'state' => Request::getInt('state', 0));
     if ($returnhtml) {
         $this->user = $user;
         $this->member = $member;
         $this->option = $option;
         $this->database = App::get('db');
         $this->params = \Hubzero\Plugin\Params::getParams($this->member->get('id'), 'members', $this->_name);
         if ($user->get('id') == $member->get('id')) {
             $this->params->set('access-edit-comment', true);
             $this->params->set('access-delete-comment', true);
         }
         // Append to document the title
         Document::setTitle(Document::getTitle() . ': ' . Lang::txt('PLG_MEMBERS_TODO'));
         // Get and determine task
         $this->task = Request::getVar('action', '');
         switch ($this->task) {
             case 'browse':
             default:
                 $arr['html'] = $this->_browse();
                 break;
             case 'new':
                 $arr['html'] = $this->_new();
                 break;
             case 'save':
                 $arr['html'] = $this->_save();
                 break;
         }
     }
     // Get an entry count
     $arr['metadata']['count'] = $this->todo->entries('count', $this->filters);
     return $arr;
 }
Ejemplo 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;
     // The output array we're returning
     $arr = array('html' => '', 'metadata' => '');
     //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';
         }
     }
     include_once PATH_CORE . DS . 'components' . DS . 'com_blog' . DS . 'models' . DS . 'archive.php';
     $this->model = new \Components\Blog\Models\Archive('group', $group->get('gidNumber'));
     //are we returning html
     if ($return == 'html') {
         //set group members plugin access level
         $group_plugin_acl = $access[$active];
         //get the group members
         $members = $group->get('members');
         //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')) {
             $url = Route::url('index.php?option=com_groups&cn=' . $group->get('cn') . '&active=' . $active, false, true);
             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;
         }
         //user vars
         $this->authorized = $authorized;
         //group vars
         $this->group = $group;
         $this->members = $members;
         // Set some variables so other functions have access
         $this->action = $action;
         $this->option = $option;
         $this->database = App::get('db');
         //get the plugins params
         $this->params = \Hubzero\Plugin\Params::getParams($group->gidNumber, 'groups', $this->_name);
         if ($authorized == 'manager' || $authorized == 'admin') {
             $this->params->set('access-edit-comment', true);
             $this->params->set('access-delete-comment', true);
         }
         // Append to document the title
         Document::setTitle(Document::getTitle() . ': ' . Lang::txt('PLG_GROUPS_BLOG'));
         switch ($this->action) {
             // Feeds
             case 'feed.rss':
                 $this->_feed();
                 break;
             case 'feed':
                 $this->_feed();
                 break;
                 //case 'comments.rss': $this->_commentsFeed();   break;
                 //case 'comments':     $this->_commentsFeed();   break;
                 // Settings
             //case 'comments.rss': $this->_commentsFeed();   break;
             //case 'comments':     $this->_commentsFeed();   break;
             // Settings
             case 'savesettings':
                 $arr['html'] = $this->_savesettings();
                 break;
             case 'settings':
                 $arr['html'] = $this->_settings();
                 break;
                 // Comments
             // Comments
             case 'savecomment':
                 $arr['html'] = $this->_savecomment();
                 break;
             case 'newcomment':
                 $arr['html'] = $this->_newcomment();
                 break;
             case 'editcomment':
                 $arr['html'] = $this->_entry();
                 break;
             case 'deletecomment':
                 $arr['html'] = $this->_deletecomment();
                 break;
                 // Entries
             // Entries
             case 'save':
                 $arr['html'] = $this->_save();
                 break;
             case 'new':
                 $arr['html'] = $this->_new();
                 break;
             case 'edit':
                 $arr['html'] = $this->_edit();
                 break;
             case 'delete':
                 $arr['html'] = $this->_delete();
                 break;
             case 'entry':
                 $arr['html'] = $this->_entry();
                 break;
             case 'archive':
             case 'browse':
             default:
                 $arr['html'] = $this->_browse();
                 break;
         }
     }
     $filters = array('scope' => 'group', 'scope_id' => $group->get('gidNumber'), 'state' => 1, 'access' => User::getAuthorisedViewLevels());
     // Build the HTML meant for the "profile" tab's metadata overview
     $arr['metadata']['count'] = $this->model->entries($filters)->total();
     return $arr;
 }
Ejemplo n.º 3
0
 /**
  * Perform actions when viewing a member profile
  *
  * @param   object  $user    Current user
  * @param   object  $member  Current member page
  * @param   string  $option  Start of records to pull
  * @param   array   $areas   Active area(s)
  * @return  array
  */
 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' => '');
     include_once PATH_CORE . DS . 'components' . DS . 'com_blog' . DS . 'models' . DS . 'archive.php';
     // Get our model
     $this->model = new \Components\Blog\Models\Archive('member', $member->get('id'));
     if ($returnhtml) {
         $this->user = $user;
         $this->member = $member;
         $this->option = $option;
         //$this->authorized = $authorized;
         $this->database = App::get('db');
         $this->params = \Hubzero\Plugin\Params::getParams($this->member->get('id'), 'members', $this->_name);
         if ($user->get('id') == $member->get('id')) {
             $this->params->set('access-edit-comment', true);
             $this->params->set('access-delete-comment', true);
         }
         // Append to document the title
         Document::setTitle(Document::getTitle() . ': ' . Lang::txt('PLG_MEMBERS_BLOG'));
         // Get and determine task
         $this->task = Request::getVar('action', '');
         if (!($task = Request::getVar('action', '', 'post'))) {
             $bits = $this->_parseUrl();
             if ($this->task != 'deletecomment') {
                 $num = count($bits);
                 switch ($num) {
                     case 3:
                         $this->task = 'entry';
                         break;
                     case 2:
                     case 1:
                         if (is_numeric($bits[0])) {
                             $this->task = 'browse';
                         }
                         break;
                 }
             }
         } else {
             $this->task = $task;
         }
         switch ($this->task) {
             // Feeds
             case 'feed.rss':
                 $this->_feed();
                 break;
             case 'feed':
                 $this->_feed();
                 break;
                 //case 'comments.rss': $this->_commentsFeed();   break;
                 //case 'comments':     $this->_commentsFeed();   break;
                 // Settings
             //case 'comments.rss': $this->_commentsFeed();   break;
             //case 'comments':     $this->_commentsFeed();   break;
             // Settings
             case 'savesettings':
                 $arr['html'] = $this->_savesettings();
                 break;
             case 'settings':
                 $arr['html'] = $this->_settings();
                 break;
                 // Comments
             // Comments
             case 'savecomment':
                 $arr['html'] = $this->_savecomment();
                 break;
             case 'newcomment':
                 $arr['html'] = $this->_newcomment();
                 break;
             case 'editcomment':
                 $arr['html'] = $this->_entry();
                 break;
             case 'deletecomment':
                 $arr['html'] = $this->_deletecomment();
                 break;
                 // Entries
             // Entries
             case 'save':
                 $arr['html'] = $this->_save();
                 break;
             case 'new':
                 $arr['html'] = $this->_new();
                 break;
             case 'edit':
                 $arr['html'] = $this->_edit();
                 break;
             case 'delete':
                 $arr['html'] = $this->_delete();
                 break;
             case 'entry':
                 $arr['html'] = $this->_entry();
                 break;
             case 'archive':
             case 'browse':
             default:
                 $arr['html'] = $this->_browse();
                 break;
         }
     }
     // Build filters
     $filters = array('scope' => 'member', 'scope_id' => $member->get('id'), 'state' => 1, 'access' => User::getAuthorisedViewLevels());
     if (User::get('id') == $member->get('id')) {
         $filters['access'][] = 5;
         $filters['authorized'] = true;
     }
     // Get an entry count
     $arr['metadata']['count'] = $this->model->entries($filters)->count();
     return $arr;
 }