示例#1
0
 /**
  * Get the group's custom params
  *
  * @param      integer  $group_id
  * @return     object
  */
 protected function _params($group_id)
 {
     if (!$this->_params) {
         $database = App::get('db');
         $p = new \Hubzero\Plugin\Params($database);
         $this->_params = $p->getCustomParams($group_id, 'groups', $this->_name);
     }
     return $this->_params;
 }
示例#2
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_FORUM_NOT_AUTHORIZED'));
         return $this->sections();
     }
     // Check for request forgeries
     Request::checkToken();
     $settings = Request::getVar('settings', array(), 'post');
     $row = new \Hubzero\Plugin\Params($this->database);
     if (!$row->bind($settings)) {
         $this->setError($row->getError());
         return $this->settings();
     }
     // Get parameters
     $p = new \Hubzero\Config\Registry(Request::getVar('params', '', 'post'));
     $row->params = $p->toString();
     // Check content
     if (!$row->check()) {
         $this->setError($row->getError());
         return $this->_settings();
     }
     // Store new content
     if (!$row->store()) {
         $this->setError($row->getError());
         return $this->_settings();
     }
     App::redirect(Route::url('index.php?option=com_groups&cn=' . $this->group->get('cn') . '&active=' . $this->_name . '&action=settings'), Lang::txt('PLG_GROUPS_FORUM_SETTINGS_SAVED'));
 }
示例#3
0
 /**
  * Save blog settings
  *
  * @return  void
  */
 private function _savesettings()
 {
     if (User::isGuest()) {
         $this->setError(Lang::txt('MEMBERS_LOGIN_NOTICE'));
         return;
     }
     if (User::get('id') != $this->member->get("uidNumber")) {
         $this->setError(Lang::txt('PLG_MEMBERS_BLOG_NOT_AUTHORIZED'));
         return $this->_browse();
     }
     // Check for request forgeries
     Request::checkToken();
     $settings = Request::getVar('settings', array(), 'post');
     $row = new \Hubzero\Plugin\Params($this->database);
     if (!$row->bind($settings)) {
         $this->setError($row->getError());
         return $this->_entry();
     }
     $p = new \Hubzero\Config\Registry(Request::getVar('params', array(), 'post'));
     $row->params = $p->toString();
     // Check content
     if (!$row->check()) {
         $this->setError($row->getError());
         return $this->_settings();
     }
     // Store new content
     if (!$row->store()) {
         $this->setError($row->getError());
         return $this->_settings();
     }
     App::redirect(Route::url($this->member->getLink() . '&active=' . $this->_name . '&task=settings'), Lang::txt('PLG_MEMBERS_BLOG_SETTINGS_SAVED'));
 }
示例#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('uidNumber'));
     // 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('uidNumber') : 0, 'state' => Request::getInt('state', 0));
     if ($returnhtml) {
         $this->user = $user;
         $this->member = $member;
         $this->option = $option;
         $this->database = App::get('db');
         $p = new \Hubzero\Plugin\Params($this->database);
         $this->params = $p->getParams($this->member->get('uidNumber'), 'members', $this->_name);
         if ($user->get('id') == $member->get('uidNumber')) {
             $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;
 }
示例#5
0
 /**
  * Return data on a group view (this will be some form of HTML)
  *
  * @param   object   $group       Current group
  * @param   string   $option      Name of the component
  * @param   string   $authorized  User's authorization level
  * @param   integer  $limit       Number of records to pull
  * @param   integer  $limitstart  Start of records to pull
  * @param   string   $action      Action to perform
  * @param   array    $access      What can be accessed
  * @param   array    $areas       Active area(s)
  * @return  array
  */
 public function onGroup($group, $option, $authorized, $limit = 0, $limitstart = 0, $action = '', $access, $areas = null)
 {
     $return = 'html';
     $active = $this->_name;
     $active_real = 'discussion';
     // The output array we're returning
     $arr = array('html' => '', 'name' => $active);
     //get this area details
     $this_area = $this->onGroupAreas();
     // Check if our area is in the array of areas we want to return results for
     if (is_array($areas) && $limit) {
         if (!in_array($this_area['name'], $areas)) {
             $return = 'metadata';
         }
     }
     $this->group = $group;
     $this->database = App::get('db');
     require_once PATH_CORE . DS . 'components' . DS . 'com_forum' . DS . 'models' . DS . 'manager.php';
     $this->forum = new Manager('group', $group->get('gidNumber'));
     // Determine if we need to return any HTML (meaning this is the active plugin)
     if ($return == 'html') {
         //set group members plugin access level
         $group_plugin_acl = $access[$active];
         //get the group members
         $this->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_real)) . '</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')) {
             $return = base64_encode(Request::getVar('REQUEST_URI', Route::url('index.php?option=com_groups&cn=' . $group->get('cn') . '&active=' . $active, false, true), 'server'));
             App::redirect(Route::url('index.php?option=com_users&view=login&return=' . $return, false), Lang::txt('GROUPS_PLUGIN_REGISTERED', ucfirst($active_real)), 'warning');
             return;
         }
         //check to see if user is member and plugin access requires members
         if (!in_array(User::get('id'), $this->members) && $group_plugin_acl == 'members' && $authorized != 'admin') {
             $arr['html'] = '<p class="warning">' . Lang::txt('GROUPS_PLUGIN_REQUIRES_MEMBER', ucfirst($active_real)) . '</p>';
             return $arr;
         }
         //user vars
         $this->group_plugin_acl = $group_plugin_acl;
         $this->authorized = $authorized;
         //group vars
         //$this->members = $members;
         //get the plugins params
         $p = new \Hubzero\Plugin\Params($this->database);
         $this->params = $p->getParams($this->group->get('gidNumber'), 'groups', $this->_name);
         $this->params->set('access-plugin', $group_plugin_acl);
         //option and paging vars
         $this->option = $option;
         //$this->name = substr($option, 4, strlen($option));
         $this->limitstart = $limitstart;
         $this->limit = $limit;
         $this->base = 'index.php?option=' . $this->option . '&cn=' . $this->group->get('cn') . '&active=' . $this->_name;
         $path = Request::path();
         if (strstr($path, '/')) {
             $bits = $this->_parseUrl();
             // Section name
             if (isset($bits[0]) && trim($bits[0])) {
                 if ($bits[0] == 'new') {
                     $action = 'newsection';
                 } else {
                     if ($bits[0] == 'settings' || $bits[0] == 'savesettings') {
                         $action = $bits[0];
                     } else {
                         if ($bits[0] == 'unsubscribe') {
                             $action = 'unsubscribe';
                         } else {
                             Request::setVar('section', $bits[0]);
                         }
                     }
                 }
             }
             // Categry name
             if (isset($bits[1]) && trim($bits[1])) {
                 if ($bits[1] == 'edit') {
                     $action = 'editsection';
                 } else {
                     if ($bits[1] == 'delete') {
                         $action = 'deletesection';
                     } else {
                         if ($bits[1] == 'new') {
                             $action = 'editcategory';
                         } else {
                             Request::setVar('category', $bits[1]);
                             $action = 'categories';
                         }
                     }
                 }
             }
             // Thread name
             if (isset($bits[2]) && trim($bits[2])) {
                 if ($bits[2] == 'edit') {
                     $action = 'editcategory';
                 } else {
                     if ($bits[2] == 'delete') {
                         $action = 'deletecategory';
                     } else {
                         if ($bits[2] == 'new') {
                             $action = 'editthread';
                         } else {
                             Request::setVar('thread', $bits[2]);
                             $action = 'threads';
                         }
                     }
                 }
             }
             // Thread action
             if (isset($bits[3]) && trim($bits[3])) {
                 if ($bits[3] == 'edit') {
                     $action = 'editthread';
                 } else {
                     if ($bits[3] == 'delete') {
                         $action = 'deletethread';
                     } else {
                         Request::setVar('post', $bits[3]);
                     }
                 }
             }
             // Thread attachment download
             if (isset($bits[4]) && trim($bits[4])) {
                 Request::setVar('file', $bits[4]);
                 $action = 'download';
             }
         }
         $action = Request::getVar('action', $action, 'post');
         switch ($action) {
             // Settings
             case 'savesettings':
                 $arr['html'] .= $this->savesettings();
                 break;
             case 'settings':
                 $arr['html'] .= $this->settings();
                 break;
             case 'sections':
                 $arr['html'] .= $this->sections();
                 break;
             case 'savesection':
                 $arr['html'] .= $this->savesection();
                 break;
             case 'deletesection':
                 $arr['html'] .= $this->deletesection();
                 break;
             case 'categories':
                 $arr['html'] .= $this->categories();
                 break;
             case 'savecategory':
                 $arr['html'] .= $this->savecategory();
                 break;
             case 'newcategory':
                 $arr['html'] .= $this->editcategory();
                 break;
             case 'editcategory':
                 $arr['html'] .= $this->editcategory();
                 break;
             case 'deletecategory':
                 $arr['html'] .= $this->deletecategory();
                 break;
             case 'threads':
                 $arr['html'] .= $this->threads();
                 break;
             case 'savethread':
                 $arr['html'] .= $this->savethread();
                 break;
             case 'editthread':
                 $arr['html'] .= $this->editthread();
                 break;
             case 'deletethread':
                 $arr['html'] .= $this->deletethread();
                 break;
             case 'orderup':
                 $arr['html'] .= $this->orderup();
                 break;
             case 'orderdown':
                 $arr['html'] .= $this->orderdown();
                 break;
             case 'download':
                 $arr['html'] .= $this->download();
                 break;
             case 'search':
                 $arr['html'] .= $this->search();
                 break;
             case 'unsubscribe':
                 $arr['html'] .= $this->unsubscribe();
                 break;
             default:
                 $arr['html'] .= $this->sections();
                 break;
         }
     }
     $arr['metadata']['count'] = $this->forum->count('threads', array('state' => 1));
     // Return the output
     return $arr;
 }