public function process()
 {
     global $sys_allow_restricted_users;
     $parameters = $this->getParametersAsArray();
     $project = null;
     if (!empty($parameters[0])) {
         $project = $this->getProject($parameters[0]);
     } else {
         $this->error('Missing argument project id');
         return false;
     }
     $repositoryName = '';
     if (!empty($parameters[1])) {
         $repositoryName = $parameters[1];
     } else {
         $this->error('Missing argument repository name');
         return false;
     }
     $userId = 0;
     if (!empty($parameters[2])) {
         $userId = $parameters[2];
     } else {
         $this->error('Missing argument user id');
         return false;
     }
     try {
         $repository = new GitRepository();
         $repository->setBackend(Backend::instance('Git', 'GitBackend'));
         $repository->setDescription('-- Default description --');
         //default access is private when restricted users are allowed
         if ($sys_allow_restricted_users == 1) {
             $repository->setAccess(GitRepository::PRIVATE_ACCESS);
         } else {
             $repository->setAccess(GitRepository::PUBLIC_ACCESS);
         }
         $user = null;
         if (!empty($userId)) {
             $user = UserManager::instance()->getUserById($userId);
         }
         if (!empty($user)) {
             $repository->setCreator($user);
         }
         $repository->setProject($project);
         $repository->setName($repositoryName);
         $repository->create();
         $this->done();
     } catch (GitDaoException $e) {
         $this->error($e->getMessage());
         return false;
     } catch (GitDriverException $e) {
         $this->error($e->getMessage());
         return false;
     } catch (GitBackendException $e) {
         $this->error($e->getMessage());
         return false;
     } catch (Exception $e) {
         $this->error($e->getMessage());
         return false;
     }
 }
 public function process()
 {
     $parameters = $this->getParametersAsArray();
     //repo id
     $repositoryId = '';
     if (!empty($parameters[0])) {
         $repositoryId = $parameters[0];
     } else {
         $this->error('Missing argument repository id');
         return false;
     }
     //repo access
     $repositoryAccess = '';
     if (!empty($parameters[1])) {
         $repositoryAccess = $parameters[1];
     } else {
         $this->error('Missing argument repository access');
         return false;
     }
     //save
     $repository = new GitRepository();
     $repository->setId($repositoryId);
     try {
         $repository->load();
         $repository->setAccess($repositoryAccess);
         $repository->changeAccess();
     } catch (GitDaoException $e) {
         $this->error($e->getMessage());
         return false;
     }
     $this->done();
 }
示例#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
 /**
  * @deprecated Should use GitRepository::getInstanceFrom row instead.
  * @param GitRepository $repository
  * @param type $result
  */
 public function hydrateRepositoryObject(GitRepository $repository, $result)
 {
     $repository->setName($result[self::REPOSITORY_NAME]);
     $repository->setPath($result[self::REPOSITORY_PATH]);
     $repository->setId($result[self::REPOSITORY_ID]);
     $repository->setDescription($result[self::REPOSITORY_DESCRIPTION]);
     $repository->setParentId($result[self::REPOSITORY_PARENT]);
     $project = ProjectManager::instance()->getProject($result[self::FK_PROJECT_ID]);
     $repository->setProject($project);
     $repository->setCreationDate($result[self::REPOSITORY_CREATION_DATE]);
     $user = UserManager::instance()->getUserById($result[self::REPOSITORY_CREATION_USER_ID]);
     $repository->setCreator($user);
     $repository->setIsInitialized($result[self::REPOSITORY_IS_INITIALIZED]);
     $repository->setDeletionDate($result[self::REPOSITORY_DELETION_DATE]);
     $repository->setAccess($result[self::REPOSITORY_ACCESS]);
     $repository->setMailPrefix($result[self::REPOSITORY_MAIL_PREFIX]);
     $repository->setBackendType($result[self::REPOSITORY_BACKEND_TYPE]);
     $repository->setNamespace($result[self::REPOSITORY_NAMESPACE]);
     $repository->setBackupPath($result[self::REPOSITORY_BACKUP_PATH]);
     $repository->setScope($result[self::REPOSITORY_SCOPE]);
     $repository->setRemoteServerId($result[self::REMOTE_SERVER_ID]);
     $repository->setRemoteServerDisconnectDate($result[self::REMOTE_SERVER_DISCONNECT_DATE]);
     $repository->setRemoteProjectDeletionDate($result[self::REMOTE_SERVER_DELETE_DATE]);
     $repository->setRemoteServerMigrationStatus($result[self::REMOTE_SERVER_MIGRATION_STATUS]);
     $repository->loadNotifiedMails();
     /* Here just for reviewer test, will be replaced by real DB data in a future changeset*/
     $result[self::ENABLE_ONLINE_EDIT] = false;
     if ($result[self::ENABLE_ONLINE_EDIT] && GitConfig::instance()->isOnlineEditEnabled()) {
         $repository->enableOnlineEdit();
     }
 }
示例#5
0
 /**
  * Clone a repository, it inherits access
  * @param String forkName
  */
 public function forkShell($forkName)
 {
     $clone = new GitRepository();
     $clone->setName($forkName);
     $clone->setProject($this->getProject());
     $clone->setParent($this);
     $clone->setCreationDate(date('Y-m-d H:i:s'));
     $clone->setCreator($this->getCreator());
     $clone->setAccess($this->getAccess());
     $clone->setIsInitialized(1);
     $clone->setDescription('-- Default description --');
     $this->getBackend()->createFork($clone);
 }
示例#6
0
 public function hydrateRepositoryObject(GitRepository $repository, $result)
 {
     $repository->setName($result[self::REPOSITORY_NAME]);
     $repository->setPath($result[self::REPOSITORY_PATH]);
     $repository->setId($result[self::REPOSITORY_ID]);
     $repository->setDescription($result[self::REPOSITORY_DESCRIPTION]);
     $repository->setParentId($result[self::REPOSITORY_PARENT]);
     $project = ProjectManager::instance()->getProject($result[self::FK_PROJECT_ID]);
     $repository->setProject($project);
     $repository->setCreationDate($result[self::REPOSITORY_CREATION_DATE]);
     $user = UserManager::instance()->getUserById($result[self::REPOSITORY_CREATION_USER_ID]);
     $repository->setCreator($user);
     $repository->setIsInitialized($result[self::REPOSITORY_IS_INITIALIZED]);
     $repository->setDeletionDate($result[self::REPOSITORY_DELETION_DATE]);
     $repository->setAccess($result[self::REPOSITORY_ACCESS]);
     $repository->setMailPrefix($result[self::REPOSITORY_MAIL_PREFIX]);
     $repository->setBackendType($result[self::REPOSITORY_BACKEND_TYPE]);
     $repository->setNamespace($result[self::REPOSITORY_NAMESPACE]);
     $repository->setScope($result[self::REPOSITORY_SCOPE]);
     $repository->loadNotifiedMails();
 }