Beispiel #1
0
 /**
  * Contribute a publication
  *
  * @return  void
  */
 public function contributeTask()
 {
     // Incoming
     $pid = Request::getInt('pid', 0);
     $action = Request::getVar('action', '');
     $active = Request::getVar('active', 'publications');
     $action = $this->_task == 'start' ? 'start' : $action;
     $ajax = Request::getInt('ajax', 0);
     $doiErr = Request::getInt('doierr', 0);
     // Redirect if publishing is turned off
     if (!$this->_contributable) {
         App::redirect(Route::url('index.php?option=' . $this->_option));
         return;
     }
     // Load language file
     Lang::load('com_projects') || Lang::load('com_projects', PATH_CORE . DS . 'components' . DS . 'com_projects' . DS . 'site');
     // Instantiate a new view
     $this->view = new \Hubzero\Component\View(array('name' => 'submit', 'layout' => 'default'));
     $this->view->option = $this->_option;
     $this->view->config = $this->config;
     // Set page title
     $this->_task_title = Lang::txt('COM_PUBLICATIONS_SUBMIT');
     $this->_buildTitle();
     // Set the pathway
     $this->_buildPathway();
     // What plugin requested?
     $allowed = array('team', 'files', 'notes', 'databases', 'publications', 'links');
     $plugin = in_array($active, $allowed) ? $active : 'publications';
     if (User::isGuest() && ($action == 'login' || $action == 'start' || $action == 'publication')) {
         $this->_msg = $this->_task == 'start' ? Lang::txt('COM_PUBLICATIONS_LOGIN_TO_START') : Lang::txt('COM_PUBLICATIONS_LOGIN_TO_VIEW_SUBMISSIONS');
         $this->_login();
         return;
     }
     // Get project model
     $project = new \Components\Projects\Models\Project();
     // Get project information
     if ($pid) {
         $project->loadProvisioned($pid);
         if (!$project->exists()) {
             App::redirect(Route::url('index.php?option=' . $this->_option . '&task=submit'));
             return;
         }
         // Block unauthorized access
         if (!$project->access('owner') && !$project->access('content')) {
             $this->_blockAccess();
             return;
         }
         // Redirect to project if not provisioned
         if (!$project->isProvisioned()) {
             App::redirect(Route::url($project->link('publications') . '&pid=' . $pid . '&action=' . $action));
             return;
         }
     }
     // Is project registration restricted?
     if ($action == 'start' && !$project->access('create')) {
         $this->_buildPathway(null);
         $this->view = new \Hubzero\Component\View(array('name' => 'error', 'layout' => 'restricted'));
         $this->view->error = Lang::txt('COM_PUBLICATIONS_ERROR_NOT_FROM_CREATOR_GROUP');
         $this->view->title = $this->title;
         $this->view->option = $this->_option;
         $this->view->display();
         return;
     }
     // No action requested ?
     if (!$action) {
         $action = $pid ? 'publication' : 'contribute';
     }
     // Plugin params
     $plugin_params = array($project, $action, $areas = array($plugin));
     $content = Event::trigger('projects.onProject', $plugin_params);
     $this->view->content = is_array($content) && isset($content[0]['html']) ? $content[0]['html'] : '';
     if (isset($content[0]['msg']) && !empty($content[0]['msg'])) {
         $this->setNotification($content[0]['msg']['message'], $content[0]['msg']['type']);
     }
     if ($ajax) {
         echo $this->view->content;
         return;
     } elseif (!$this->view->content && isset($content[0]['referer']) && $content[0]['referer'] != '') {
         App::redirect($content[0]['referer']);
         return;
     } elseif (empty($content)) {
         // plugin disabled?
         App::redirect(Route::url('index.php?option=' . $this->_option));
         return;
     }
     // @FIXME: Handle errors appropriately. [QUBES][#732]
     if ($doiErr == 1) {
         $this->setError(Lang::txt('COM_PUBLICATIONS_ERROR_DOI_NO_SERVICE'));
     }
     // Output HTML
     $this->view->project = $project;
     $this->view->action = $action;
     $this->view->pid = $pid;
     $this->view->title = $this->_title;
     $this->view->msg = $this->getNotifications('success');
     $error = $this->getError() ? $this->getError() : $this->getNotifications('error');
     if ($error) {
         $this->view->setError($error);
     }
     $this->view->display();
     return;
 }