/** * Delete selected repository, if repository is gitolite repository or remote repository delete that too. */ function delete_git() { if (($this->request->isAsyncCall() || $this->request->isApiCall()) && $this->request->isSubmitted()) { if ($this->active_repository->isLoaded()) { if ($this->active_repository->canDelete($this->logged_user)) { try { $repo_table_name = TABLE_PREFIX . "rt_gitolite_repomaster"; /* echo "DELETE from $repo_table_name where repo_fk = '".$this->active_repository->getId()."'"; die(); */ $this->active_repository->delete(); $repo_table_name = TABLE_PREFIX . "rt_gitolite_repomaster"; $repo_access_table_name = TABLE_PREFIX . "rt_gitolite_access_master"; $remote_repo_table_name = TABLE_PREFIX . "rt_remote_repos"; $repo_fk = $this->active_repository->getId(); $chk_gitolite = ProjectGitolite::is_gitolite_repo($repo_fk); //print_r($chk_gitolite); if (is_array($chk_gitolite) && sizeof($chk_gitolite) > 0 && $chk_gitolite['chk_gitolite'] > 0) { DB::execute("DELETE repo_acc,repo_tb FROM {$repo_table_name} repo_tb\n JOIN {$repo_access_table_name} repo_acc ON repo_acc.repo_id = repo_tb.repo_id\n WHERE repo_tb.repo_fk = '" . $repo_fk . "'"); $repo_path = GIT_FILES_PATH . "/" . $chk_gitolite["repo_name"]; @ProjectGitolite::remove_directory($repo_path); } else { $remote_name_arr = DB::executeFirstRow("SELECT remote_repo_name,actual_repo_name from {$remote_repo_table_name} where repo_fk = '" . $repo_fk . "'"); if ($remote_name_arr) { $remote_name = $remote_name_arr["actual_repo_name"]; } DB::execute("DELETE from {$remote_repo_table_name} where repo_fk = '" . $repo_fk . "'"); $repo_path = GIT_FILES_PATH . "/" . $remote_name; if ($remote_name != "") { @ProjectGitolite::remove_directory($repo_path); } } $this->response->respondWithData($this->active_repository, array('as' => 'repository')); } catch (Exception $e) { $this->response->exception($e); } // if } else { $this->response->forbidden(); } // if } else { $this->response->notFound(); } // if } else { $this->response->badRequest(); } // if }
/** * Check repository access and add repository help on history page * @return void */ function history() { //ProjectGitolite::delete_commits($this->active_repository->getId()); /* * $this->wireframe->actions->add('branches', lang('Branches'), '#', array( 'subitems' => self::ac_gitolite_get_branches(), 'icon' => AngieApplication::getPreferedInterface() == AngieApplication::INTERFACE_DEFAULT ? AngieApplication::getImageUrl('icons/16X16-git.png', AC_GITOLITE_MODULE) : AngieApplication::getImageUrl('icons/16X16-git.png', AC_GITOLITE_MODULE, AngieApplication::INTERFACE_PHONE), 'id'=> 'branches_list' )); $this->wireframe->actions->add('tags', lang('Tags'), '#', array( 'subitems' => self::ac_gitolite_get_tags(), 'icon' => AngieApplication::getPreferedInterface() == AngieApplication::INTERFACE_DEFAULT ? AngieApplication::getImageUrl('icons/16X16-git.png', AC_GITOLITE_MODULE) : AngieApplication::getImageUrl('icons/16X16-git.png', AC_GITOLITE_MODULE, AngieApplication::INTERFACE_PHONE), 'id'=> 'tags_list' )); */ $repo_id = array_var($_GET, 'project_source_repository_id'); //project objects id $project = $this->active_project; $repository = $this->active_repository; $repo_details = ProjectGitolite::get_repo_details($repo_id); if (is_array($repo_details) && count($repo_details) > 0) { //if ( $this->logged_user->isAdministrator () || $this->logged_user->isProjectManager () || $project->isLeader ( $this->logged_user ) ) { $this->wireframe->actions->add('manage_access', lang('Manage Access'), Router::assemble('edit_git_repository', array('project_slug' => $project->getSlug(), 'project_source_repository_id' => $repo_id)), array('id' => 'update_access_levels', 'onclick' => new FlyoutFormCallback("access_updated", array('width' => 'narrow')), 'icon' => AngieApplication::getPreferedInterface() == AngieApplication::INTERFACE_DEFAULT ? AngieApplication::getImageUrl('icons/16X16-git.png', AC_GITOLITE_MODULE) : AngieApplication::getImageUrl('icons/16X16-git.png', AC_GITOLITE_MODULE, AngieApplication::INTERFACE_PHONE))); //} //if } /* Commented FTP section $this->wireframe->actions->add('add_ftp', 'FTP Connectiions', Router::assemble('add_ftp_conn',array('project_slug' => $this->active_project->getSlug(), 'project_source_repository_id' => $repo_id)), array( 'onclick' => new FlyoutFormCallback('ftps_updated', array('width' => '1100')), 'icon' => AngieApplication::getPreferedInterface() == AngieApplication::INTERFACE_DEFAULT ? AngieApplication::getImageUrl('icons/16X16-git.png', AC_GITOLITE_MODULE) : AngieApplication::getImageUrl('icons/16X16-git.png', AC_GITOLITE_MODULE, AngieApplication::INTERFACE_PHONE)) ); */ $this->wireframe->actions->add('add_hooks', 'Hooks', Router::assemble('add_hooks_git', array('project_slug' => $this->active_project->getSlug(), 'project_source_repository_id' => $repo_id)), array('onclick' => new FlyoutFormCallback('urls_updated', array('width' => '900')), 'icon' => AngieApplication::getPreferedInterface() == AngieApplication::INTERFACE_DEFAULT ? AngieApplication::getImageUrl('icons/16X16-git.png', AC_GITOLITE_MODULE) : AngieApplication::getImageUrl('icons/16X16-git.png', AC_GITOLITE_MODULE, AngieApplication::INTERFACE_PHONE))); $repo_path = $repository->getRepositoryPathUrl(); $repo_fk = $repository->getId(); $chk_gitolite = ProjectGitolite::is_gitolite_repo($repo_fk); if (is_array($chk_gitolite) && sizeof($chk_gitolite) > 0 && $chk_gitolite['chk_gitolite'] > 0) { $settings = GitoliteAdmin::get_admin_settings(); $clone_url = $settings['git_clone_url'] . $this->active_repository->getName() . ".git"; $permissions = @unserialize($chk_gitolite['permissions']); if ($permissions !== false || $permissions === 'b:0;') { $permissions_array = $permissions; } else { $permissions_array = array(); } if (array_key_exists($this->logged_user->getId(), $permissions_array) && $permissions_array[$this->logged_user->getId()] > 1 || $this->logged_user->isAdministrator() || $this->logged_user->isProjectManager() || $this->active_project->isLeader($this->logged_user)) { $body = "<h2>Git Global Setup</h2>"; $body .= "<code>"; $body .= "git config --global user.name '" . $this->logged_user->getDisplayName() . "'" . "<br>"; $body .= "git config --global user.email '" . $this->logged_user->getEmail() . "'" . "<br>"; $body .= "</code>"; $body .= "<h2>Create Repository:</h2>"; $body .= "<code>"; $body .= "mkdir " . $this->active_repository->getName() . "<br>"; $body .= "cd " . $this->active_repository->getName() . "<br>"; $body .= "git init" . "<br>"; $body .= "touch README" . "<br>"; $body .= "git add README" . "<br>"; $body .= "git commit -m 'first commit'" . "<br>"; $body .= "git remote add origin " . $clone_url . "<br>"; $body .= "git push -u origin master" . "<br>"; $body .= "</code>"; $body .= "<h2>Existing Git Repo?</h2>"; $body .= "<code>"; $body .= "cd existing_git_repo" . "<br>"; $body .= "git remote add origin " . $clone_url . "<br>"; $body .= "git push -u origin master"; $body .= "</code>"; $body_text = $body; } else { $this->response->forbidden(); } } else { $body_text = $repository->getFieldValue("repository_path_url"); } parent::history(); $this->response->assign(array('body_text' => $body_text, 'repo_path' => $repo_path, 'clone_url' => $clone_url)); }