/** * Event call to determine if this plugin should return data * * @return array Plugin name and title */ public function &onProjectAreas($alias = NULL) { $area = array('name' => $this->_name, 'title' => Lang::txt('COM_PROJECTS_TAB_FILES'), 'submenu' => 'Assets', 'show' => true, 'icon' => 'f016'); if ($this->params->get('default_action', 'browse') == 'connections') { $model = new Components\Projects\Models\Project(Request::getVar('alias', '')); $active = Request::getInt('connection', 0); $area['children'] = array(); $area['children'][] = array('name' => 'default', 'title' => sprintf($this->params->get('default_connection_name', '%s Master Repository'), $model->get('title')), 'url' => $model->link('files') . '&action=browse', 'class' => 'filesystem default' . (Request::getVar('action') == 'browse' && !$active ? ' active' : ''), 'icon' => 'f0a0'); if ($model->exists() && $model->access('member')) { $connections = Components\Projects\Models\Orm\Project::oneOrFail($model->get('id'))->connections()->thatICanView(); if ($connections->count()) { foreach ($connections as $connection) { //$imgRel = '/plugins/filesystem/' . $connection->provider->alias . '/assets/img/icon.png'; //$img = (is_file(PATH_APP . DS . $imgRel)) ? '/app' . $imgRel : '/core' . $imgRel; $area['children'][] = array('title' => $connection->name, 'name' => $connection->provider->alias, 'url' => $model->link('files') . '&action=browse&connection=' . $connection->id, 'class' => 'filesystem ' . $connection->provider->alias . (!$connection->isShared() ? ' private' : '') . ($active == $connection->id ? ' active' : ''), 'icon' => 'f0a0'); } } } } return $area; }
/** * 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; }