示例#1
0
 private function getHeader()
 {
     $html = '';
     $repoId = $this->repository->getId();
     $creator = $this->repository->getCreator();
     $parent = $this->repository->getParent();
     $access = $this->repository->getAccess();
     $creatorName = '';
     if (!empty($creator)) {
         $creatorName = UserHelper::instance()->getLinkOnUserFromUserId($creator->getId());
     }
     // Access type
     $accessType = $this->getAccessType($access, $this->repository->getBackend() instanceof Git_Backend_Gitolite);
     $html .= '<h1>' . $accessType . $this->repository->getFullName() . '</h1>';
     if (!empty($parent)) {
         $html .= '<div id="plugin_git_repo_parent">';
         $html .= $GLOBALS['Language']->getText('plugin_git', 'view_repo_parent_' . $this->repository->getBackendType(), $parent->getHTMLLink($this->url_manager));
         $html .= '</div>';
     }
     return $html;
 }
示例#2
0
 /**
  * Display access control management for gitshell backend
  *
  * @param GitRepository $repository The repository
  * 
  * @return void
  */
 protected function _accessControl($repository)
 {
     $public = '';
     $private = '';
     $checked = 'checked="checked"';
     if ($repository->getAccess() == GitRepository::PRIVATE_ACCESS) {
         $private = $checked;
         echo '<input type="hidden" id="action" name="action" value="edit" />';
     } else {
         if ($repository->getAccess() == GitRepository::PUBLIC_ACCESS) {
             $public = $checked;
             echo '<input type="hidden" id="action" name="action" value="confirm_private" />';
         }
     }
     echo '<p id="plugin_git_access">';
     echo $this->getText('view_repo_access');
     echo ': <span><input type="radio" name="repo_access" value="private" ' . $private . '/> ';
     echo $this->getText('view_repo_access_private');
     echo '<input type="radio" name="repo_access" value="public" ' . $public . '/> Public';
     echo '</span>';
     echo '</p>';
 }
示例#3
0
 /**
  * Internal method called by SystemEvent_PROJECT_IS_PRIVATE
  * @param <type> $projectId
  * @param <type> $isPublic
  * @return <type>
  */
 public static function changeProjectRepositoriesAccess($projectId, $isPrivate)
 {
     //if the project is private, then no changes may be applied to repositories,
     //in other words only if project is set to private, its repositories have to be set to private
     if (empty($isPrivate)) {
         return;
     }
     $dao = new GitDao();
     $repositories = $dao->getProjectRepositoryList($projectId);
     if (empty($repositories)) {
         return false;
     }
     foreach ($repositories as $repoId => $repoData) {
         $r = new GitRepository();
         $r->setId($repoId);
         if (!$r->exists()) {
             continue;
         }
         $newAccess = !empty($isPrivate) ? GitRepository::PRIVATE_ACCESS : GitRepository::PUBLIC_ACCESS;
         if ($r->getAccess() == $newAccess) {
             continue;
         }
         $r->setAccess($newAccess);
         $r->changeAccess();
         unset($r);
     }
 }
示例#4
0
 public function save(GitRepository $repository)
 {
     $id = (int) $repository->getId();
     $name = $repository->getName();
     $mailPrefix = $repository->getMailPrefix();
     $parentId = 0;
     $scope = $repository->getScope();
     $namespace = $repository->getNamespace();
     try {
         $parent = $repository->getParent();
         if (!empty($parent)) {
             $parentId = $parent->getId();
         }
     } catch (GitDaoException $e) {
     }
     $projectId = $repository->getProjectId();
     $description = $repository->getDescription();
     $path = $repository->getPath();
     $isInitialized = $repository->getIsInitialized();
     $creationUserId = $repository->getCreatorId();
     $access = $repository->getAccess();
     //protect parameters
     $id = $this->da->escapeInt($id);
     $name = $this->da->quoteSmart($name);
     $description = $this->da->quoteSmart($description);
     $path = $this->da->quoteSmart($path);
     $projectId = $this->da->escapeInt($projectId);
     $isInitialized = $this->da->escapeInt($isInitialized);
     $creationUserId = $this->da->escapeInt($creationUserId);
     $access = $this->da->quoteSmart($access);
     $mailPrefix = $this->da->quoteSmart($mailPrefix);
     $scope = $this->da->quoteSmart($scope);
     $namespace = $this->da->quoteSmart($namespace);
     $backup_path = $this->da->quoteSmart($repository->getBackupPath());
     $insert = false;
     if ($this->exists($id)) {
         $query = 'UPDATE ' . $this->getTable() . ' SET ' . self::REPOSITORY_DESCRIPTION . '=' . $description . ',' . self::REPOSITORY_IS_INITIALIZED . '=' . $isInitialized . ',' . self::REPOSITORY_ACCESS . '=' . $access . ',' . self::REPOSITORY_MAIL_PREFIX . '=' . $mailPrefix . ',' . self::REPOSITORY_BACKUP_PATH . '=' . $backup_path . 'WHERE ' . self::REPOSITORY_ID . '=' . $id;
     } else {
         if ($repository->getBackend() instanceof Git_Backend_Gitolite) {
             $backendType = self::BACKEND_GITOLITE;
         } else {
             $backendType = self::BACKEND_GITSHELL;
         }
         $insert = true;
         $creationDate = date('Y-m-d H:i:s');
         $query = 'INSERT INTO ' . $this->getTable() . '(' . self::REPOSITORY_NAME . ',' . self::REPOSITORY_PATH . ',' . self::REPOSITORY_PARENT . ',' . self::REPOSITORY_DESCRIPTION . ',' . self::FK_PROJECT_ID . ',' . self::REPOSITORY_CREATION_DATE . ',' . self::REPOSITORY_CREATION_USER_ID . ',' . self::REPOSITORY_IS_INITIALIZED . ',' . self::REPOSITORY_ACCESS . ',' . self::REPOSITORY_BACKEND_TYPE . ',' . self::REPOSITORY_SCOPE . ',' . self::REPOSITORY_NAMESPACE . ') values (' . "" . $name . "," . "" . $path . "," . "" . $parentId . "," . "" . $description . "," . $projectId . "," . "'" . $creationDate . "'," . $creationUserId . "," . $isInitialized . ',' . $access . ',' . $this->da->quoteSmart($backendType) . ',' . $scope . ',' . $namespace . ')';
     }
     if ($this->update($query) === false) {
         throw new GitDaoException($GLOBALS['Language']->getText('plugin_git', 'dao_update_error') . ' : ' . $this->da->isError());
     }
     if ($insert) {
         return $this->da->lastInsertId();
     }
     return true;
 }