/** * Delete member(s) * * @return mixed */ protected function delete() { // Incoming $checked = Request::getVar('owner', array()); $groups = Request::getVar('group', array()); // Are we setting up project? $setup = $this->model->inSetup() ? 1 : 0; // Instantiate project owner $objO = $this->model->table('Owner'); if (!empty($checked)) { // Get owners info from owner id(s) $selected = $objO->getInfo($this->model->get('id'), $checked, $groups); } else { $selected = array(); $this->setError(Lang::txt('PLG_PROJECTS_TEAM_ERROR_NOONE_TO_DELETE')); } if ($this->_task == 'delete') { // Output HTML $view = new \Hubzero\Plugin\View(array('folder' => 'projects', 'element' => 'team', 'name' => 'delete')); $view->selected = $selected; $view->checked = $checked; $view->option = $this->_option; $view->model = $this->model; $view->uid = $this->_uid; $view->setup = $setup; $view->aid = $objO->getOwnerID($this->model->get('id'), $this->_uid); $view->msg = isset($this->_msg) ? $this->_msg : ''; $view->setErrors($this->getErrors()); return $view->loadTemplate(); } else { // Get all managers $all = $objO->getIds($this->model->get('id'), $role = 1); $remaining = array_diff($all, $checked); $deleted = 0; // Cannot delete if no managers remain if ($remaining) { // Perform delete $deleted = $objO->removeOwners($this->model->get('id'), $checked, 1); if ($deleted) { $this->_msg = Lang::txt('PLG_PROJECTS_TEAM_OWNERS_DELETED'); } } else { if (count($all) > 0) { $left = array_diff($checked, array($all[0])); // leave one manager $deleted = $objO->removeOwners($this->model->get('id'), $left, 1); } $this->setError(Lang::txt('PLG_PROJECTS_TEAM_OWNERS_DELETE_NOMANAGERS')); } if ($deleted) { // Sync with system group $objO->sysGroup($this->model->get('alias'), $this->_config->get('group_prefix', 'pr-')); } // Pass error or success message if ($this->getError()) { Notify::message($this->getError(), 'error', 'projects'); } elseif (!empty($this->_msg)) { Notify::message($this->_msg, 'success', 'projects'); } $url = 'index.php?option=' . $this->_option . '&alias=' . $this->model->get('alias') . '&task='; $url .= $setup ? 'setup' : 'edit'; $url .= '&active=team'; App::redirect(Route::url($url)); } }
/** * Display updates * * @return string */ protected function _updates() { // Build the final HTML $view = new \Hubzero\Plugin\View(array('folder' => 'groups', 'element' => 'projects', 'name' => 'updates')); $view->filters = array('limit' => Request::getVar('limit', 25, 'request')); // Get shared updates feed from blog plugin $results = Event::trigger('projects.onShared', array('feed', $this->model, $this->_projects, User::get('id'), $view->filters)); $view->content = !empty($results) && isset($results[0]) ? $results[0] : NULL; $view->newcount = $this->model->table()->getUpdateCount($this->_projects, User::get('id')); $view->projectcount = count($this->_projects); $view->uid = User::get('id'); $view->config = $this->_config; $view->group = $this->group; $view->setErrors($this->getErrors()); return $view->loadTemplate(); }
/** * Get public link and list/unlist * * * @return string */ protected function _share() { // Incoming $id = trim(Request::getInt('p', 0)); // Load requested page $page = $this->note->page($id); if (!$page->get('id')) { App::redirect(Route::url($this->model->link('notes'))); } // Output HTML $view = new \Hubzero\Plugin\View(array('folder' => 'projects', 'element' => 'notes', 'name' => 'pubsettings')); // Get/update public stamp for page $view->set('publicStamp', $this->note->getPublicStamp($page->get('id'), true)); $view->set('option', $this->_option); if (!$view->publicStamp) { $this->setError(Lang::txt('PLG_PROJECTS_NOTES_ERROR_SHARE')); // Output error $view = new \Hubzero\Plugin\View(array('folder' => 'projects', 'element' => 'files', 'name' => 'error')); $view->set('title', ''); $view->setErrors($this->getErrors()); return $view->loadTemplate(); } $view->set('project', $this->model); $view->set('url', $url); $view->set('config', $this->model->config()); $view->set('page', $page); $view->set('revision', $page->revision('current')); $view->set('masterscope', 'projects' . DS . $this->model->get('alias') . DS . 'notes'); $view->set('params', $this->params); $view->set('ajax', Request::getInt('ajax', 0)); $view->setErrors($this->getErrors()); return $view->loadTemplate(); }