private function getView() { if (empty($_REQUEST['a'])) { $_REQUEST['a'] = 'summary'; } else { if ($_REQUEST['a'] === 'blobdiff' && isset($_REQUEST['jenkins']) && $_REQUEST['jenkins'] === 'true') { $this->inverseURLArgumentsForGitPhpDiff(); } } set_time_limit(300); $_GET['a'] = $_REQUEST['a']; $_REQUEST['group_id'] = $this->repository->getProjectId(); $_REQUEST['repo_id'] = $this->repository->getId(); $_REQUEST['repo_name'] = $this->repository->getFullName(); $_GET['p'] = $_REQUEST['repo_name'] . '.git'; $_REQUEST['repo_path'] = $this->repository->getPath(); $_REQUEST['project_dir'] = $this->repository->getProject()->getUnixName(); $_REQUEST['git_root_path'] = $this->repository->getGitRootPath(); $_REQUEST['action'] = 'view'; $this->preSanitizeRequestForGitphp(); if (empty($_REQUEST['noheader'])) { echo '<div id="gitphp" class="plugin_git_gitphp">'; } include $this->getGitPhpIndexPath(); if (empty($_REQUEST['noheader'])) { echo '</div>'; } }
public function queueRepositoryDeletion(GitRepository $repository) { if ($repository->getBackend() instanceof Git_Backend_Gitolite) { $this->system_event_manager->createEvent(SystemEvent_GIT_REPO_DELETE::NAME, $repository->getProjectId() . SystemEvent::PARAMETER_SEPARATOR . $repository->getId(), SystemEvent::PRIORITY_MEDIUM, SystemEvent::OWNER_APP); } else { $this->system_event_manager->createEvent(SystemEvent_GIT_LEGACY_REPO_DELETE::NAME, $repository->getProjectId() . SystemEvent::PARAMETER_SEPARATOR . $repository->getId(), SystemEvent::PRIORITY_MEDIUM, SystemEvent::OWNER_ROOT); } }
private function getRemoteRepositoryInfoError() { $date = DateHelper::timeAgoInWords($this->project_creator_status->getEventDate($this->repository), false, true); $url = GIT_BASE_URL . '/?action=repo_management&group_id=' . $this->repository->getProjectId() . '&repo_id=' . $this->repository->getId() . '&pane=gerrit'; $html = ''; $html .= '<div class="alert alert-error gerrit_url">'; $html .= $GLOBALS['Language']->getText('plugin_git', 'delegated_to_gerrit_error', array($date, $url), CODENDI_PURIFIER_DISABLED); $html .= '</div>'; return $html; }
public function updateRepositoryMirrors(GitRepository $repository, array $mirror_ids) { if ($this->mirror_data_mapper->doesAllSelectedMirrorIdsExist($mirror_ids) && $this->mirror_data_mapper->unmirrorRepository($repository->getId()) && $this->mirror_data_mapper->mirrorRepositoryTo($repository->getId(), $mirror_ids)) { $this->history_dao->groupAddHistory("git_repo_mirroring_update", $repository->getName(), $repository->getProjectId()); return true; } return false; }
/** * @param GitRepository $repository * @return string the base url to access the git repository regarding plugin configuration */ public function getRepositoryBaseUrl(GitRepository $repository) { if ($this->git_plugin->areFriendlyUrlsActivated()) { return GIT_BASE_URL . '/' . $repository->getProject()->getUnixName() . '/' . $repository->getFullName(); } else { return GIT_BASE_URL . '/index.php/' . $repository->getProjectId() . '/view/' . $repository->getId() . '/'; } }
private function sendErrorNotification(GitRepository $repository) { $user = $this->getRequester(); if (!$user->isAnonymous()) { $factory = new BaseLanguageFactory(); $language = $factory->getBaseLanguage($user->getLocale()); $url = get_server_url() . GIT_BASE_URL . '/?action=repo_management&group_id=' . $repository->getProjectId() . '&repo_id=' . $repository->getId() . '&pane=gerrit'; $notification = new Notification(array($user->getEmail()), $language->getText('plugin_git', 'delegated_to_gerrit_error_mail_subject', array($repository->getFullName())), $language->getText('plugin_git', 'delegated_to_gerrit_error_mail_body', array($repository->getFullName(), $url)), $language->getText('plugin_git', 'delegated_to_gerrit_error_mail_body', array($repository->getFullName(), $url)), $url, 'git'); $this->mail_builder->buildAndSendEmail($repository->getProject(), $notification, new MailEnhancer()); } }
public function project_id() { return $this->repository->getProjectId(); }
function permission_user_allowed_to_change($params) { if (!$params['allowed']) { if (!$this->_cached_permission_user_allowed_to_change) { if (in_array($params['permission_type'], array('PLUGIN_GIT_READ', 'PLUGIN_GIT_WRITE', 'PLUGIN_GIT_WPLUS'))) { require_once 'GitRepository.class.php'; $repository = new GitRepository(); $repository->setId($params['object_id']); try { $repository->load(); //Only project admin can update perms of project repositories //Only repo owner can update perms of personal repositories $user = UserManager::instance()->getCurrentUser(); $this->_cached_permission_user_allowed_to_change = $repository->belongsTo($user) || $user->isMember($repository->getProjectId(), 'A'); } catch (Exception $e) { // do nothing } } } $params['allowed'] = $this->_cached_permission_user_allowed_to_change; } }
private function displayTab($pane) { echo '<li class="' . ($this->current_pane == $pane->getIdentifier() ? 'active' : '') . '">'; $url = GIT_BASE_URL . '/?' . http_build_query(array('action' => 'repo_management', 'group_id' => $this->repository->getProjectId(), 'repo_id' => $this->repository->getId(), 'pane' => $pane->getIdentifier())); echo '<a href="' . $url . '">' . $pane->getTitle() . '</a></li>'; }
/** * Test is user can read the content of this repository and metadata * * @param PFUser $user The user to test * @param GitRepository $repository The repository to test * * @return Boolean */ public function userCanRead($user, $repository) { if ($repository->isPrivate() && $user->isMember($repository->getProjectId())) { return true; } if ($repository->isPublic()) { if ($user->isRestricted() && $user->isMember($repository->getProjectId())) { return true; } if (!$user->isAnonymous()) { return true; } } return false; }
public function getRepoAdminUrl() { return '/plugins/git/?action=repo_management&group_id=' . $this->repository->getProjectId() . '&repo_id=' . $this->repository->getId(); }
private function markAsDeleted(GitRepository $repository) { $repository->markAsDeleted(); $this->systemEventManager->createEvent('GIT_REPO_DELETE', $repository->getProjectId() . SystemEvent::PARAMETER_SEPARATOR . $repository->getId(), SystemEvent::PRIORITY_MEDIUM); }
/** * This function initialize a GitRepository object with its database value * @param GitRepository $repository * @return <type> */ public function getProjectRepository($repository) { $projectId = $repository->getProjectId(); $repositoryPath = $repository->getPathWithoutLazyLoading(); if (empty($projectId) || empty($repositoryPath)) { throw new GitDaoException($GLOBALS['Language']->getText('plugin_git', 'dao_search_params')); } $rs = $this->searchProjectRepositoryByPath($projectId, $repositoryPath); if (empty($rs)) { throw new GitDaoException($GLOBALS['Language']->getText('plugin_git', 'dao_search_error')); return false; } $result = $rs->getRow(); if (empty($result)) { throw new GitDaoException($GLOBALS['Language']->getText('plugin_git', 'dao_search_error')); return false; } $this->hydrateRepositoryObject($repository, $result); return true; }
/** * @param GitRepository $repository * @param array $repositor_ids * @return array */ public function searchOtherRepositoriesInSameProjectFromRepositoryList(GitRepository $repository, $repositor_ids) { $project_repositories = array(); $result = $this->getDao()->searchRepositoriesInSameProjectFromRepositoryList($repositor_ids, $repository->getProjectId()); if (!$result) { return $project_repositories; } foreach ($result as $repo) { if ($repo['repository_id'] == $repository->getId()) { continue; } $project_repositories[] = $repo['repository_id']; } return $project_repositories; }
/** * Test is user can read the content of this repository and metadata * * @param User $user The user to test * @param GitRepository $repository The repository to test * * @return Boolean */ public function userCanRead($user, $repository) { return $user->isMember($repository->getProjectId(), 'A') || $user->hasPermission(Git::PERM_READ, $repository->getId(), $repository->getProjectId()) || $user->hasPermission(Git::PERM_WRITE, $repository->getId(), $repository->getProjectId()) || $user->hasPermission(Git::PERM_WPLUS, $repository->getId(), $repository->getProjectId()); }