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();
 }
Beispiel #2
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);
     }
 }