public function index($userName, $projectName)
 {
     /**
      * @var \Proxy\ProjectProxy $projectProxy
      */
     $projectProxy = Loader::proxy('ProjectProxy');
     $memberCount = $projectProxy->getProjectMemberCount($this->project->id);
     $roles = $projectProxy->getProjectMemberWithRole($this->project->id);
     /**
      * @var \Proxy\NoticeProxy $noticeProxy
      */
     $noticeProxy = Loader::proxy('NoticeProxy');
     $notices = $noticeProxy->getNoticeByProject($this->project->id, 5);
     Loader::library('NoticeAdapter/NoticeAdapter', null, FALSE);
     $noticeFormats = [];
     foreach ($notices as $notice) {
         $noticeFormats[] = NoticeAdapter::newNotice($notice);
     }
     /**
      * @var Model/Repository $repo
      */
     $repo = $this->project->repository();
     $readme = $repo->readme();
     View::render('project_index', array('pageName' => 'project_index', 'account' => $this->account, 'project' => $this->project, 'memberCount' => $memberCount, 'roles' => $roles, 'notices' => $noticeFormats, 'readme' => $readme));
 }
 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.º 4
0
 public function getReadme($projectId)
 {
     $project = Project::findOne(['id' => $projectId]);
     return $project->readme();
 }