/** * Execute a request * * @return void */ public function execute() { $this->registerTask('files', 'list'); $this->registerTask('update', 'save'); $this->registerTask('insert', 'save'); $this->_task = Request::getWord('task', 'list'); // Load component language file Lang::load('com_projects') || Lang::load('com_projects', PATH_CORE . DS . 'components' . DS . 'com_projects' . DS . 'site'); // Incoming $id = Request::getVar('id', ''); $this->model = new Project($id); // Project did not load? if (!$this->model->exists()) { throw new Exception(Lang::txt('COM_PROJECTS_PROJECT_CANNOT_LOAD'), 404); } $contentTasks = array('insert', 'update', 'delete', 'move', 'rename', 'makedirectory'); //tasks specific to adapters $connectionTasks = array('upload', 'download', 'getmetadata', 'setmetadata'); // Check authorization if (in_array($this->_task, $contentTasks) && !$this->model->access('content') || in_array($this->_task, $connectionTasks) && !$this->model->access('content') || !$this->model->access('member')) { throw new Exception(Lang::txt('ALERTNOTAUTH'), 401); } //connection ID $this->cid = Request::getVar('cid', ''); if (in_array($this->_task, $connectionTasks) && !$this->cid) { throw new Exception("This action is only supported by connection adapters", 401); } //if task involves connections, get the ORM Project object //if there is a connection id, get an ORM Connection object as well if ($this->cid || $this->_task == 'connections') { $this->ormproj = \Components\Projects\Models\Orm\Project::oneOrFail($id); if ($this->cid) { $this->ormconn = \Components\Projects\Models\Orm\Connection::oneOrFail($this->cid); } } // Check for local repo if no connection has been specified if (!$this->cid && !$this->model->repo()->exists()) { throw new Exception(Lang::txt('COM_PROJECTS_FILES_ERROR_NO_LOCAL_REPO'), 404); } parent::execute(); }
/** * Renders project files connections view * * @return string */ public function connections() { // Set up view $view = new \Hubzero\Plugin\View(['folder' => 'projects', 'element' => 'files', 'name' => 'connections', 'layout' => 'display']); // Assign vars $view->model = $this->model; $view->connections = Project::oneOrFail($this->model->get('id'))->connections; // Load and return view content return $view->loadTemplate(); }
?> <p class="info connection-message"><?php echo Lang::txt('PLG_PROJECTS_FILES_CONNECTION_NOTE'); ?> </p> <?php } ?> <div id="content-selector" class="content-selector"> <?php if ($this->showCons && empty($this->directory) && !Request::getInt('cid')) { // Show files $view = new \Hubzero\Plugin\View(array('folder' => 'projects', 'element' => 'files', 'name' => 'selector', 'layout' => 'connections')); $view->model = $this->model; $view->connections = Project::oneOrFail($this->model->get('id'))->connections()->thatICanView(); echo $view->loadTemplate(); } else { // Show files $view = new \Hubzero\Plugin\View(array('folder' => 'projects', 'element' => 'files', 'name' => 'selector', 'layout' => 'selector')); $view->option = $this->option; $view->model = $this->model; $view->items = $this->items; $view->requirements = $params; $view->publication = $this->publication; $view->selected = $selected; $view->allowed = $allowed; $view->used = $used; echo $view->loadTemplate(); } ?>