Beispiel #1
0
 /**
  * Edit project info
  *
  * @return     void
  */
 public function editTask()
 {
     // Incoming project ID
     $id = Request::getVar('id', array(0));
     if (is_array($id)) {
         $id = $id[0];
     }
     // Push some styles to the template
     \Hubzero\Document\Assets::addPluginStylesheet('projects', 'files', 'diskspace.css');
     \Hubzero\Document\Assets::addPluginScript('projects', 'files', 'diskspace.js');
     \Hubzero\Document\Assets::addPluginScript('projects', 'files');
     $this->view = $this->view;
     $this->view->config = $this->config;
     $model = new Models\Project($id);
     $objAC = $model->table('Activity');
     if ($id) {
         if (!$model->exists()) {
             App::redirect(Route::url('index.php?option=' . $this->_option, false), Lang::txt('COM_PROJECTS_NOTICE_ID_NOT_FOUND'), 'error');
             return;
         }
     }
     if (!$id) {
         App::redirect(Route::url('index.php?option=' . $this->_option, false), Lang::txt('COM_PROJECTS_NOTICE_NEW_PROJECT_FRONT_END'), 'error');
         return;
     }
     // Get project types
     $objT = $model->table('Type');
     $this->view->types = $objT->getTypes();
     // Get activity counts
     $counts = Event::trigger('projects.onProjectCount', array($model, 1));
     $counts = Helpers\Html::getCountArray($counts);
     $counts['activity'] = $objAC->getActivityCount($model->get('id'), User::get('id'));
     $this->view->counts = $counts;
     // Get team
     $objO = $model->table('Owner');
     // Sync with system group
     $objO->sysGroup($model->get('alias'), $this->config->get('group_prefix', 'pr-'));
     // Get members and managers
     $this->view->managers = $objO->getOwnerNames($id, 0, '1', 1);
     $this->view->members = $objO->getOwnerNames($id, 0, '0', 1);
     $this->view->authors = $objO->getOwnerNames($id, 0, '2', 1);
     $this->view->reviewers = $objO->getOwnerNames($id, 0, '5', 1);
     // Get last activity
     $afilters = array('limit' => 1);
     $last_activity = $objAC->getActivities($id, $afilters);
     $this->view->last_activity = count($last_activity) > 0 ? $last_activity[0] : '';
     // Was project suspended?
     $this->view->suspended = false;
     $setup_complete = $this->config->get('confirm_step', 0) ? 3 : 2;
     if ($model->isInactive()) {
         $this->view->suspended = $objAC->checkActivity($id, Lang::txt('COM_PROJECTS_ACTIVITY_PROJECT_SUSPENDED'));
     }
     // Get project params
     $this->view->params = $model->params;
     $content = Event::trigger('projects.diskspace', array($model, 'local', 'admin'));
     $this->view->diskusage = isset($content[0]) ? $content[0] : '';
     // Set any errors
     if ($this->getError()) {
         $this->view->setError($this->getError());
     }
     // Get tags on this item
     $cloud = new Models\Tags($id);
     $this->view->tags = $cloud->render('string');
     // Output the HTML
     $this->view->model = $model;
     $this->view->publishing = $this->_publishing;
     $this->view->display();
 }
Beispiel #2
0
 /**
  * Edit project info
  *
  * @return  void
  */
 public function editTask()
 {
     if (!User::authorise('core.edit', $this->_option) && !User::authorise('core.create', $this->_option)) {
         App::abort(403, Lang::txt('JERROR_ALERTNOAUTHOR'));
     }
     Request::setVar('hidemainmenu', 1);
     // Incoming project ID
     $id = Request::getVar('id', array(0));
     if (is_array($id)) {
         $id = !empty($id) ? intval($id[0]) : 0;
     }
     $model = new Models\Project($id);
     $objAC = $model->table('Activity');
     if ($id) {
         if (!$model->exists()) {
             Notify::error(Lang::txt('COM_PROJECTS_NOTICE_ID_NOT_FOUND'));
             return $this->cancelTask();
         }
     }
     if (!$id) {
         Notify::error(Lang::txt('COM_PROJECTS_NOTICE_NEW_PROJECT_FRONT_END'));
         return $this->cancelTask();
     }
     $this->view = $this->view;
     $this->view->config = $this->config;
     // Get project types
     $objT = $model->table('Type');
     $this->view->types = $objT->getTypes();
     // Get activity counts
     $counts = Event::trigger('projects.onProjectCount', array($model, 1));
     $counts = Helpers\Html::getCountArray($counts);
     $counts['activity'] = $objAC->getActivityCount($model->get('id'), User::get('id'));
     $this->view->counts = $counts;
     // Get team
     $objO = $model->table('Owner');
     // Sync with system group
     $objO->sysGroup($model->get('alias'), $this->config->get('group_prefix', 'pr-'));
     // Get members and managers
     $this->view->managers = $objO->getOwnerNames($id, 0, '1', 1);
     $this->view->members = $objO->getOwnerNames($id, 0, '0', 1);
     $this->view->authors = $objO->getOwnerNames($id, 0, '2', 1);
     $this->view->reviewers = $objO->getOwnerNames($id, 0, '5', 1);
     // Get last activity
     $afilters = array('limit' => 1);
     $last_activity = $objAC->getActivities($id, $afilters);
     $this->view->last_activity = count($last_activity) > 0 ? $last_activity[0] : '';
     // Was project suspended?
     $this->view->suspended = false;
     $setup_complete = $this->config->get('confirm_step', 0) ? 3 : 2;
     if ($model->isInactive()) {
         $this->view->suspended = $objAC->checkActivity($id, Lang::txt('COM_PROJECTS_ACTIVITY_PROJECT_SUSPENDED'));
     }
     // Get project params
     $this->view->params = $model->params;
     $content = Event::trigger('projects.diskspace', array($model, 'local', 'admin'));
     $this->view->diskusage = isset($content[0]) ? $content[0] : '';
     // Set any errors
     if ($this->getError()) {
         $this->view->setError($this->getError());
     }
     // Get tags on this item
     $cloud = new Models\Tags($id);
     $this->view->tags = $cloud->render('string');
     // Output the HTML
     $this->view->model = $model;
     $this->view->publishing = $this->_publishing;
     $this->view->display();
 }
Beispiel #3
0
 /**
  * Project view
  *
  * @return     void
  */
 public function viewTask()
 {
     // Incoming
     $preview = Request::getInt('preview', 0);
     $this->active = Request::getVar('active', 'feed');
     $ajax = Request::getInt('ajax', 0);
     $action = Request::getVar('action', '');
     $confirmcode = Request::getVar('confirm', '');
     $email = Request::getVar('email', '');
     $sync = false;
     // Stop ajax action if user got logged out
     if ($ajax && User::isGuest()) {
         // Project on hold
         $this->view = new \Hubzero\Component\View(array('name' => 'error', 'layout' => 'default'));
         $this->view->error = Lang::txt('COM_PROJECTS_PROJECT_RELOGIN');
         $this->view->title = Lang::txt('COM_PROJECTS_PROJECT_RELOGIN_REQUIRED');
         $this->view->display();
         return;
     }
     // Check that project exists
     if (!$this->model->exists()) {
         throw new Exception(Lang::txt('COM_PROJECTS_PROJECT_NOT_FOUND'), 404);
         return;
     }
     // Is this a group project?
     $this->group = $this->model->groupOwner();
     if ($this->model->get('owned_by_group') && !$this->group) {
         $this->_buildPathway();
         $this->_buildTitle();
         // Options for project creator
         if ($this->model->access('owner')) {
             $view = new \Hubzero\Component\View(array('name' => 'changeowner', 'layout' => 'default'));
             $view->project = $this->model;
             $view->task = $this->_task;
             $view->option = $this->_option;
             $view->display();
             return;
         } else {
             // Error
             $this->setError(Lang::txt('COM_PROJECTS_PROJECT_OWNER_DELETED'));
             $this->title = Lang::txt('COM_PROJECTS_PROJECT_OWNERSHIP_ERROR');
             $this->_showError();
             return;
         }
     }
     // Load acting team member
     $member = $this->model->member();
     // Reconcile members of project groups
     if (!$ajax) {
         if ($this->model->_tblOwner->reconcileGroups($this->model->get('id'), $this->model->get('owned_by_group'))) {
             $sync = true;
         }
     }
     // Is project deleted?
     if ($this->model->isDeleted()) {
         $this->setError(Lang::txt('COM_PROJECTS_PROJECT_DELETED'));
         $this->introTask();
         return;
     }
     // Check if project is in setup
     if ($this->model->inSetup() && !$ajax) {
         App::redirect(Route::url('index.php?option=' . $this->_option . '&task=setup&alias=' . $this->model->get('alias')));
         return;
     }
     // Sync with system group in case of changes
     if ($sync == true) {
         $this->model->_tblOwner->sysGroup($this->model->get('alias'), $this->config->get('group_prefix', 'pr-'));
         // Reload member
         $this->model->member(true);
     }
     // Set the pathway
     $this->_buildPathway();
     // Set the page title
     $this->_buildTitle();
     // Do we need to login?
     if (User::isGuest() && $action == 'login') {
         $this->_msg = Lang::txt('COM_PROJECTS_LOGIN_TO_VIEW_PROJECT');
         $this->_login();
         return;
     }
     // Determine layout to load
     $layout = $this->model->access('member') ? 'internal' : 'external';
     $layout = $this->model->access('member') && $preview && $this->model->isPublic() ? 'external' : $layout;
     // Is this a provisioned project?
     if ($this->model->isProvisioned()) {
         if (!$this->_publishing) {
             $this->setError(Lang::txt('COM_PROJECTS_PROJECT_CANNOT_LOAD'));
             $this->introTask();
             return;
         }
         // Redirect to publication
         $pub = $this->model->getPublication();
         if ($pub && $pub->id) {
             App::redirect(Route::url('index.php?option=com_publications&task=submit&pid=' . $pub->id));
             return;
         } else {
             throw new Exception(Lang::txt('COM_PROJECTS_PROJECT_NOT_FOUND'), 404);
             return;
         }
         $this->view->pub = $pub;
         $this->view->team = $this->model->_tblOwner->getOwnerNames($this->model->get('id'));
         $this->view->suggested = Helpers\Html::suggestAlias($pub->title);
         $this->view->verified = $this->model->check($this->view->suggested, $this->model->get('id'), 0);
         $this->view->suggested = $this->view->verified ? $this->view->suggested : '';
     }
     // Check if they are a reviewer
     $reviewer = false;
     if (!$this->model->access('member')) {
         if ($this->model->reviewerAccess('sensitive')) {
             $reviewer = 'sensitive';
         }
         if ($this->model->reviewerAccess('sponsored')) {
             $reviewer = 'sponsored';
         }
     }
     // Invitation view
     if ($confirmcode && (!$member or $member->status != 1)) {
         $match = $this->model->_tblOwner->matchInvite($this->model->get('id'), $confirmcode, $email);
         if (User::isGuest() && $match) {
             $layout = 'invited';
         } elseif ($match && $this->model->_tblOwner->load($match)) {
             if (User::get('email') == $email) {
                 // Confirm user
                 $this->model->_tblOwner->status = 1;
                 $this->model->_tblOwner->userid = User::get('id');
                 if (!$this->model->_tblOwner->store()) {
                     $this->setError($this->model->_tblOwner->getError());
                     return false;
                 } else {
                     // Sync with system group
                     $this->model->_tblOwner->sysGroup($this->model->get('alias'), $this->config->get('group_prefix', 'pr-'));
                     // Go to project page
                     App::redirect(Route::url($this->model->link()));
                     return;
                 }
             } else {
                 // Error - different email
                 $this->setError(Lang::txt('COM_PROJECTS_INVITE_DIFFERENT_EMAIL'));
                 $this->_showError();
                 return;
             }
         }
     }
     // Private project
     if (!$this->model->isPublic() && $layout != 'invited') {
         // Login required
         if (User::isGuest()) {
             $this->_msg = Lang::txt('COM_PROJECTS_LOGIN_PRIVATE_PROJECT_AREA');
             $this->_login();
             return;
         }
         if (!$this->model->access('member') && !$reviewer) {
             throw new Exception(Lang::txt('ALERTNOTAUTH'), 403);
             return;
         }
     }
     // Is project suspended?
     if ($this->model->isInactive()) {
         if (!$this->model->access('member')) {
             throw new Exception(Lang::txt('ALERTNOTAUTH'), 403);
             return;
         }
         $layout = 'suspended';
     }
     // Is project pending approval?
     if ($this->model->isPending()) {
         if ($reviewer) {
             $layout = 'external';
         } elseif (!$this->model->access('owner')) {
             throw new Exception(Lang::txt('ALERTNOTAUTH'), 403);
             return;
         } else {
             $layout = 'pending';
         }
     }
     // Set layout
     $this->view->setLayout($layout);
     // Record join activity
     if ($this->active == 'feed' && !$ajax) {
         // First-time visit, record join activity
         $this->model->recordFirstJoinActivity();
     }
     // Get available plugins
     $plugins = Event::trigger('projects.onProjectAreas', array($this->model->get('alias')));
     // Get tabbed plugins
     $this->view->tabs = Helpers\Html::getTabs($plugins);
     // Go through plugins
     $this->view->content = '';
     if ($layout == 'internal') {
         $plugin = $this->active == 'feed' ? 'blog' : $this->active;
         $plugin = $this->active == 'info' ? '' : $plugin;
         // Get active plugins (some may not be in tabs)
         $activePlugins = Helpers\Html::getPluginNames($plugins);
         // Get plugin content
         if ($this->active != 'info') {
             // Do not go further if plugin is inactive or does not exist
             if (!in_array($plugin, $activePlugins)) {
                 if ($ajax) {
                     // Plugin not active in this project
                     echo '<p class="error">' . Lang::txt('COM_PROJECTS_ERROR_CONTENT_CANNOT_LOAD') . '</p>';
                     return;
                 }
                 App::redirect(Route::url($this->model->link()));
                 return;
             }
             // Plugin params
             $plugin_params = array($this->model, $action, array($plugin));
             // Get plugin content
             $sections = Event::trigger('projects.onProject', $plugin_params);
             // Output
             if (!empty($sections)) {
                 foreach ($sections as $section) {
                     if (isset($section['html']) && $section['html']) {
                         if ($ajax) {
                             // AJAX output
                             echo $section['html'];
                             return;
                         } else {
                             // Normal output
                             $this->view->content .= $section['html'];
                         }
                     }
                 }
             } else {
                 // No html output
                 App::redirect(Route::url($this->model->link()));
                 return;
             }
         }
         // Get item counts
         $counts = Event::trigger('projects.onProjectCount', array($this->model));
         $this->model->set('counts', Helpers\Html::getCountArray($counts));
         // Record page visit
         if ($this->active == 'feed' && !$ajax) {
             $this->model->recordVisit();
         }
         // Hide suggestions
         if ($this->active == 'feed') {
             // Hide welcome screen?
             $c = Request::getInt('c', 0);
             if ($c) {
                 $this->model->member()->saveParam($this->model->get('id'), User::get('id'), $param = 'hide_welcome', 1);
                 App::redirect(Route::url($this->model->link()));
                 return;
             }
         }
     }
     // Output HTML
     $this->view->params = $this->model->params;
     $this->view->model = $this->model;
     $this->view->reviewer = $reviewer;
     $this->view->title = $this->title;
     $this->view->active = $this->active;
     $this->view->task = $this->_task;
     $this->view->option = $this->_option;
     $this->view->config = $this->config;
     $this->view->msg = $this->_getNotifications('success');
     if ($layout == 'invited') {
         $this->view->confirmcode = $confirmcode;
         $this->view->email = $email;
     }
     $error = $this->getError() ? $this->getError() : $this->_getNotifications('error');
     if ($error) {
         $this->view->setError($error);
     }
     $this->view->display();
     return;
 }