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);
     }
 }
 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;
 }
Ejemplo n.º 3
0
 public function getReadme($projectId)
 {
     $project = Project::findOne(['id' => $projectId]);
     return $project->readme();
 }