public function handle(array $params = null)
 {
     if (Request::hasParameter('account') && is_array($params) && isset($params[1])) {
         $currentAccount = null;
         if (Request::hasParameter('currentAccount')) {
             $currentAccount = Request::getParameter('currentAccount');
         }
         $account = Request::getParameter('account');
         $project = Project::findOne(['uid' => $account->uid, 'identifier' => $params[1]]);
         if (!empty($project)) {
             if ($project->is_public != '1') {
                 if (is_null($currentAccount)) {
                     Exception::throwException(10004);
                 } elseif ($project->uid != $currentAccount->uid) {
                     Exception::throwException(10004);
                 }
             }
             Request::addParameter('project', $project);
         } else {
             Exception::throwException(10003);
         }
     } else {
         Exception::throwException(10001);
     }
 }
 /**
  * @param $args
  *
  * @return \Models\Project
  */
 public function createProject($args)
 {
     try {
         Project::getDB()->transactionStart();
         $name = $args['name'];
         $identifier = $args['identifier'];
         $isPublic = $args['is_public'];
         $project = Project::findOne(['identifier' => $identifier]);
         if (!empty($project)) {
             Exception::throwException(10006);
         }
         $guid = Loader::library('Guid');
         $guid->getGuid();
         $account = Request::getParameter('currentAccount');
         $project = Project::create(['id' => $guid->toString(), 'name' => $name, 'is_public' => $isPublic, 'identifier' => $identifier, 'uid' => $account->uid]);
         //创建初始角色
         $projectRole = $this->createProjectRole(config('App.project_role_init_name'), config('App.project_role_init_permission'), $project->id);
         //创建初始项目成员关系
         $this->createProjectMemberRelation($project->id, $projectRole->role_id, $account->uid);
         //创建版本库
         $this->createRepository($account->identifier, $project->identifier);
         Project::getDB()->transactionComplete();
         return $project;
     } catch (\Exception $e) {
         Project::getDB()->transactionRollback();
         throw $e;
     }
 }
예제 #3
0
 function __construct()
 {
     if (self::$_allowInstance) {
         Application::getInstance()->config->load('ShellConfig');
         $this->_config = Application::getInstance()->config->get('ShellConfig');
     } else {
         Exception::throwException(101, ['FindConfig']);
     }
 }
 function __construct()
 {
     Application::getInstance()->config->load('ShellConfig');
     $config = Application::getInstance()->config->get('ShellConfig');
     if (!empty($config) && isset($config['shell_cmd']) && !empty($config['shell_cmd'])) {
         $this->_shellCmd = $config['shell_cmd'];
     } else {
         Exception::throwException(10007);
     }
 }
 public function handle(array $params = null)
 {
     if (is_array($params) && isset($params[0])) {
         $accountIdentifier = $params[0];
         $account = Account::findOne(['identifier' => $accountIdentifier]);
         if (!empty($account)) {
             Request::addParameter('account', $account);
         } else {
             Exception::throwException(10002);
         }
     } else {
         Exception::throwException(10002);
     }
 }
 public function handle(array $params = null)
 {
     $tokenName = Application::getInstance()->config->get('App.cookie_prefix') . Application::getInstance()->config->get('App.token_cookie_name');
     $token = Input::cookie($tokenName);
     if (!empty($token)) {
         $result = Account::where('ucenter_token', $token)->limit(1)->get();
         if (!empty($result)) {
             $result = $result[0];
             if (time() < $result->token_expired) {
                 Request::addParameter('currentAccount', $result);
                 return;
             }
         }
     }
     Exception::throwException(10005);
 }
 private function _pushCommandAccessCheck($repo, $keyId)
 {
     $result = false;
     if (!empty($repo)) {
         $key = Key::findOne(['id' => $keyId]);
         $project = Project::findOne(['identifier' => $repo]);
         if (empty($key)) {
             Exception::throwException(20001);
         }
         if (empty($project)) {
             Exception::throwException(20002);
         }
         if ($key->uid == $project->uid) {
             $result = true;
         }
     }
     return $result;
 }
예제 #8
0
 protected function _processCommand()
 {
     $this->repoPath = $this->reposPath . DIRECTORY_SEPARATOR . $this->repoName;
     if ($this->gitCommand == 'git-annex-shell') {
         if (!$this->config->gitAnnexEnabled()) {
             Exception::throwException(30002, [$this->gitCommand, $this->user['name']]);
         }
     } else {
         logInfo("find-shell: executing git command '{$this->gitCommand} {$this->repoPath} by " . $this->user['name'] . ".", $this->config->commonLogFile());
         $this->_runCommand($this->gitCommand, array($this->repoPath));
     }
 }