Esempio n. 1
0
 /**
  * Save blog settings
  *
  * @return     void
  */
 private function _savesettings()
 {
     if (User::isGuest()) {
         $this->setError(Lang::txt('GROUPS_LOGIN_NOTICE'));
         return;
     }
     if ($this->authorized != 'manager' && $this->authorized != 'admin') {
         $this->setError(Lang::txt('PLG_GROUPS_BLOG_NOT_AUTHORIZED'));
         return $this->_browse();
     }
     // Check for request forgeries
     Request::checkToken();
     $settings = Request::getVar('settings', array(), 'post');
     $row = \Hubzero\Plugin\Params::blank()->set($settings);
     // Get parameters
     $p = new \Hubzero\Config\Registry(Request::getVar('params', array(), 'post'));
     $row->set('params', $p->toString());
     // Store new content
     if (!$row->save()) {
         $this->setError($row->getError());
         return $this->_settings();
     }
     // Record the activity
     $recipients = array(['group', $this->group->get('gidNumber')]);
     foreach ($this->group->get('managers') as $recipient) {
         $recipients[] = ['user', $recipient];
     }
     Event::trigger('system.logActivity', ['activity' => ['action' => 'updated', 'scope' => 'blog.settings', 'scope_id' => $row->get('id'), 'description' => Lang::txt('PLG_GROUPS_BLOG_ACTIVITY_SETTINGS_UPDATED')], 'recipients' => $recipients]);
     App::redirect(Route::url('index.php?option=com_groups&cn=' . $this->group->get('cn') . '&active=' . $this->_name . '&action=settings'), Lang::txt('PLG_GROUPS_BLOG_SETTINGS_SAVED'), 'passed');
 }
Esempio n. 2
0
 /**
  * Get the group's custom params
  *
  * @param   integer  $group_id
  * @return  object
  */
 protected function _params($group_id)
 {
     if (!$this->_params) {
         $this->_params = \Hubzero\Plugin\Params::getCustomParams($group_id, 'groups', $this->_name);
     }
     return $this->_params;
 }
Esempio n. 3
0
 /**
  * Get a list of collections for a user
  *
  * - If no type or type='member', returns an array of collections
  *   that user created.
  * - If type='group', returns an array of collections in the groups
  *   the user is a member of.
  *
  * @param   string $type What type ot get collections for [group, member]
  * @return  array
  */
 public function mine($type = '')
 {
     $user = User::getInstance();
     $tbl = new Tables\Collection($this->_db);
     switch (strtolower(trim($type))) {
         case 'group':
         case 'groups':
             $collections = array();
             $usergroups = $user->groups('members');
             $usergroups_manager = $user->groups('managers');
             if ($usergroups) {
                 if ($usergroups_manager) {
                     foreach ($usergroups_manager as $manager_group) {
                         foreach ($usergroups as $user_group) {
                             if ($user_group->gidNumber == $manager_group->gidNumber) {
                                 $user_group->manager = $manager_group->manager;
                             }
                         }
                     }
                 }
                 foreach ($usergroups as $usergroup) {
                     $groups = $tbl->getRecords(array('object_type' => 'group', 'object_id' => $usergroup->gidNumber, 'state' => 1));
                     if ($groups) {
                         if (!isset($usergroup->params) || !is_object($usergroup->params)) {
                             $usergroup->params = Params::getCustomParams($usergroup->gidNumber, 'groups', 'collections');
                         }
                         foreach ($groups as $s) {
                             if (!isset($collections[$s->group_alias])) {
                                 $collections[$s->group_alias] = array();
                             }
                             if ($usergroup->params->get('create_post', 0) == 1 && !$usergroup->manager) {
                                 continue;
                             }
                             /*if ($s->access == 4 && !$usergroup->manager)
                             		{
                             			continue;
                             		}*/
                             $collections[$s->group_alias][] = $s;
                             asort($collections[$s->group_alias]);
                         }
                     }
                 }
             }
             asort($collections);
             break;
         case 'member':
         default:
             $collections = $tbl->getRecords(array('object_type' => 'member', 'object_id' => $user->get('id'), 'state' => 1));
             break;
     }
     return $collections;
 }
Esempio n. 4
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;
 }
Esempio n. 5
0
 /**
  * Save blog settings
  *
  * @return  void
  */
 private function _savesettings()
 {
     if (User::isGuest()) {
         return $this->_login();
     }
     if (User::get('id') != $this->member->get('id')) {
         $this->setError(Lang::txt('PLG_MEMBERS_BLOG_NOT_AUTHORIZED'));
         return $this->_browse();
     }
     // Check for request forgeries
     Request::checkToken();
     // Incoming
     $settings = Request::getVar('settings', array(), 'post');
     $row = \Hubzero\Plugin\Params::blank()->set($settings);
     $p = new \Hubzero\Config\Registry(Request::getVar('params', array(), 'post'));
     $row->set('params', $p->toString());
     // Store new content
     if (!$row->save()) {
         $this->setError($row->getError());
         return $this->_settings();
     }
     // Log the activity
     Event::trigger('system.logActivity', ['activity' => ['action' => 'updated', 'scope' => 'blog.settings', 'scope_id' => $row->get('id'), 'description' => Lang::txt('PLG_MEMBERS_BLOG_ACTIVITY_SETTINGS_UPDATED')], 'recipients' => [$this->member->get('id')]]);
     App::redirect(Route::url($this->member->link() . '&active=' . $this->_name . '&task=settings'), Lang::txt('PLG_MEMBERS_BLOG_SETTINGS_SAVED'));
 }