コード例 #1
0
ファイル: TestProject.php プロジェクト: burbuja/indefero
 public function testMultipleCreate()
 {
     $project = new IDF_Project();
     $project->name = 'Test project';
     $project->shortname = 'test';
     $project->description = 'This is a test project.';
     $project->create();
     try {
         $project = new IDF_Project();
         $project->name = 'Test project';
         $project->shortname = 'test';
         $project->description = 'This is a test project.';
         $project->create();
         // if here it as failed
         $this->fail('It should not be possible to create 2 projects with same shortname');
     } catch (Exception $e) {
         $this->pass();
     }
 }
コード例 #2
0
ファイル: TestIssue.php プロジェクト: burbuja/indefero
 /**
  * Create 2 projects to work with and 2 users.
  */
 public function setUp()
 {
     $this->projects = array();
     $this->users = array();
     for ($i = 1; $i < 3; $i++) {
         $project = new IDF_Project();
         $project->name = 'Test project ' . $i;
         $project->shortname = 'test' . $i;
         $project->description = sprintf('This is a test project %d.', $i);
         $project->create();
         $this->projects[] = $project;
         $user = new Pluf_User();
         $user->last_name = 'user' . $i;
         $user->login = '******' . $i;
         $user->email = 'user' . $i . '@example.com';
         $user->create();
         $this->users[] = $user;
     }
 }
コード例 #3
0
ファイル: Middleware.php プロジェクト: burbuja/indefero
 /**
  * Process the request.
  *
  * When processing the request, check if matching a project. If
  * so, directly set $request->project to the project.
  *
  * The url to match a project is in the format /p/(\w+)/whatever
  * or /api/p/(\w+)/whatever. This means that it will not try to
  * match on /login/ or /logout/.
  *
  * @param Pluf_HTTP_Request The request
  * @return bool false or redirect.
  */
 function process_request(&$request)
 {
     $match = array();
     if (preg_match('#^/(?:api/p|p)/([\\-\\w]+)/?#', $request->query, $match)) {
         try {
             $request->project = IDF_Project::getOr404($match[1]);
         } catch (Pluf_HTTP_Error404 $e) {
             return new Pluf_HTTP_Response_NotFound($request);
         }
         $request->conf = new IDF_Conf();
         $request->conf->setProject($request->project);
         self::setRights($request);
     }
     return false;
 }
コード例 #4
0
ファイル: SyncGit.php プロジェクト: burbuja/indefero
 /**
  * Entry point for the post-update signal.
  *
  * It tries to find the name of the project, when found it runs an
  * update of the timeline.
  */
 public static function postUpdate($signal, &$params)
 {
     // Chop the ".git" and get what is left
     $pname = basename($params['git_dir'], '.git');
     try {
         $project = IDF_Project::getOr404($pname);
     } catch (Pluf_HTTP_Error404 $e) {
         Pluf_Log::event(array('IDF_Plugin_SyncGit::postUpdate', 'Project not found.', array($pname, $params)));
         return false;
         // Project not found
     }
     // Now we have the project and can update the timeline
     Pluf_Log::debug(array('IDF_Plugin_SyncGit::postUpdate', 'Project found', $pname, $project->id));
     IDF_Scm::syncTimeline($project, true);
     Pluf_Log::event(array('IDF_Plugin_SyncGit::postUpdate', 'sync', array($pname, $project->id)));
 }
コード例 #5
0
ファイル: SyncMercurial.php プロジェクト: burbuja/indefero
 /**
  * Update the timeline in post commit.
  *
  */
 public function processSyncTimeline($params)
 {
     $pname = basename($params['rel_dir']);
     try {
         $project = IDF_Project::getOr404($pname);
     } catch (Pluf_HTTP_Error404 $e) {
         Pluf_Log::event(array('IDF_Plugin_SyncMercurial::processSyncTimeline', 'Project not found.', array($pname, $params)));
         return false;
         // Project not found
     }
     // Now we have the project and can update the timeline
     Pluf_Log::debug(array('IDF_Plugin_SyncMercurial::processSyncTimeline', 'Project found', $pname, $project->id));
     IDF_Scm::syncTimeline($project, true);
     Pluf_Log::event(array('IDF_Plugin_SyncMercurial::processSyncTimeline', 'sync', array($pname, $project->id)));
 }
コード例 #6
0
ファイル: SyncMonotone.php プロジェクト: burbuja/indefero
 /**
  * Update the timeline after a push
  *
  */
 public function processSyncTimeline($project_name)
 {
     try {
         $project = IDF_Project::getOr404($project_name);
     } catch (Pluf_HTTP_Error404 $e) {
         Pluf_Log::event(array('IDF_Plugin_SyncMonotone::processSyncTimeline', 'Project not found.', array($project_name, $params)));
         return false;
         // Project not found
     }
     Pluf_Log::debug(array('IDF_Plugin_SyncMonotone::processSyncTimeline', 'Project found', $project_name, $project->id));
     IDF_Scm::syncTimeline($project, true);
     Pluf_Log::event(array('IDF_Plugin_SyncMonotone::processSyncTimeline', 'sync', array($project_name, $project->id)));
 }
コード例 #7
0
ファイル: ProjectCreate.php プロジェクト: Br3nda/indefero
 public function save($commit = true)
 {
     if (!$this->isValid()) {
         throw new Exception(__('Cannot save the model from an invalid form.'));
     }
     $project = new IDF_Project();
     $project->name = $this->cleaned_data['name'];
     $project->shortname = $this->cleaned_data['shortname'];
     $project->private = $this->cleaned_data['private_project'];
     $project->description = __('Click on the Project Management tab to set the description of your project.');
     $project->create();
     $conf = new IDF_Conf();
     $conf->setProject($project);
     $keys = array('scm', 'svn_remote_url', 'svn_username', 'svn_password');
     foreach ($keys as $key) {
         $this->cleaned_data[$key] = !empty($this->cleaned_data[$key]) ? $this->cleaned_data[$key] : '';
         $conf->setVal($key, $this->cleaned_data[$key]);
     }
     $project->created();
     IDF_Form_MembersConf::updateMemberships($project, $this->cleaned_data);
     $project->membershipsUpdated();
     return $project;
 }
コード例 #8
0
ファイル: ProjectCreate.php プロジェクト: burbuja/indefero
 public function save($commit = true)
 {
     if (!$this->isValid()) {
         throw new Exception(__('Cannot save the model from an invalid form.'));
     }
     $project = new IDF_Project();
     $project->name = $this->cleaned_data['name'];
     $project->shortname = $this->cleaned_data['shortname'];
     $project->shortdesc = $this->cleaned_data['shortdesc'];
     if ($this->cleaned_data['template'] != '--') {
         // Find the template project
         $sql = new Pluf_SQL('shortname=%s', array($this->cleaned_data['template']));
         $tmpl = Pluf::factory('IDF_Project')->getOne(array('filter' => $sql->gen()));
         $project->private = $tmpl->private;
         $project->description = $tmpl->description;
     } else {
         $project->private = $this->cleaned_data['private_project'];
         $project->description = __('Click on the Project Management tab to set the description of your project.');
     }
     $project->create();
     $conf = new IDF_Conf();
     $conf->setProject($project);
     $keys = array('scm', 'svn_remote_url', 'svn_username', 'svn_password', 'mtn_master_branch');
     foreach ($keys as $key) {
         $this->cleaned_data[$key] = !empty($this->cleaned_data[$key]) ? $this->cleaned_data[$key] : '';
         $conf->setVal($key, $this->cleaned_data[$key]);
     }
     if ($this->cleaned_data['template'] != '--') {
         $tmplconf = new IDF_Conf();
         $tmplconf->setProject($tmpl);
         // We need to get all the configuration variables we want from
         // the old project and put them into the new project.
         $props = array('labels_download_predefined' => IDF_Form_UploadConf::init_predefined, 'labels_download_one_max' => IDF_Form_UploadConf::init_one_max, 'labels_wiki_predefined' => IDF_Form_WikiConf::init_predefined, 'labels_wiki_one_max' => IDF_Form_WikiConf::init_one_max, 'labels_issue_template' => IDF_Form_IssueTrackingConf::init_template, 'labels_issue_open' => IDF_Form_IssueTrackingConf::init_open, 'labels_issue_closed' => IDF_Form_IssueTrackingConf::init_closed, 'labels_issue_predefined' => IDF_Form_IssueTrackingConf::init_predefined, 'labels_issue_one_max' => IDF_Form_IssueTrackingConf::init_one_max, 'webhook_url' => '', 'downloads_access_rights' => 'all', 'review_access_rights' => 'all', 'wiki_access_rights' => 'all', 'source_access_rights' => 'all', 'issues_access_rights' => 'all', 'downloads_notification_email' => '', 'review_notification_email' => '', 'wiki_notification_email' => '', 'source_notification_email' => '', 'issues_notification_email' => '');
         foreach ($props as $prop => $def) {
             $conf->setVal($prop, $tmplconf->getVal($prop, $def));
         }
     }
     $project->created();
     if ($this->cleaned_data['template'] == '--') {
         IDF_Form_MembersConf::updateMemberships($project, $this->cleaned_data);
     } else {
         // Get the membership of the template $tmpl
         IDF_Form_MembersConf::updateMemberships($project, $tmpl->getMembershipData('string'));
     }
     $project->membershipsUpdated();
     return $project;
 }