/** * Erases all project information (to be used for test projects only) * * @return void */ public function eraseTask() { $id = Request::getVar('id', 0); $permanent = 1; // Initiate extended database class $obj = new Tables\Project($this->database); if (!$id or !$obj->loadProject($id)) { App::redirect(Route::url('index.php?option=' . $this->_option, false), Lang::txt('COM_PROJECTS_NOTICE_ID_NOT_FOUND'), 'error'); return; } // Get project group $group_prefix = $this->config->get('group_prefix', 'pr-'); $prGroup = $group_prefix . $obj->alias; // Store project info $alias = $obj->alias; $identifier = $alias; // Delete project $obj->delete(); // Erase all owners $objO = new Tables\Owner($this->database); $objO->removeOwners($id, '', 0, $permanent, '', $all = 1); // Erase owner group $group = new \Hubzero\User\Group(); $group->read($prGroup); if ($group) { $group->delete(); } // Erase all comments $objC = new Tables\Comment($this->database); $objC->deleteProjectComments($id, $permanent); // Erase all activities $objA = new Tables\Activity($this->database); $objA->deleteActivities($id, $permanent); // Erase all todos $objTD = new Tables\Todo($this->database); $objTD->deleteTodos($id, '', $permanent); // Erase all blog entries $objB = new Tables\Blog($this->database); $objB->deletePosts($id, $permanent); // Erase all notes if (file_exists(PATH_CORE . DS . 'components' . DS . 'com_wiki' . DS . 'models' . DS . 'page.php')) { include_once PATH_CORE . DS . 'components' . DS . 'com_wiki' . DS . 'models' . DS . 'page.php'; // Get all notes $this->database->setQuery("SELECT DISTINCT p.id FROM `#__wiki_pages` AS p\n\t\t\t\tWHERE p.scope_id=" . $this->database->quote($id) . " AND p.scope=" . $this->database->quote('project')); $notes = $this->database->loadObjectList(); if ($notes) { foreach ($notes as $note) { $page = \Components\Wiki\Models\Page::oneOrFail($note->id); // Finally, delete the page itself $page->destroy(); } } } // Erase all files, remove files repository if ($alias) { // Delete base dir for .git repos $dir = $alias; $prefix = $this->config->get('offroot', 0) ? '' : PATH_CORE; $repodir = DS . trim($this->config->get('webpath'), DS); $path = $prefix . $repodir . DS . $dir; if (is_dir($path)) { Filesystem::deleteDirectory($path); } // Delete images/preview directories $webdir = DS . trim($this->config->get('imagepath', '/site/projects'), DS); $webpath = PATH_APP . $webdir . DS . $dir; if (is_dir($webpath)) { Filesystem::deleteDirectory($webpath); } } // Redirect App::redirect(Route::url('index.php?option=' . $this->_option, false), Lang::txt('COM_PROJECTS_PROJECT') . ' #' . $id . ' (' . $alias . ') ' . Lang::txt('COM_PROJECTS_PROJECT_ERASED')); }