/**
  * Build a new project
  *
  * @param ProjectCreationData $data project data
  * @return Project created
  */
 public function build(ProjectCreationData $data)
 {
     if (!$this->ruleShortName->isValid($data->getUnixName())) {
         throw new Project_InvalidShortName_Exception($this->ruleShortName->getErrorMessage());
     }
     if (!$this->ruleFullName->isValid($data->getFullName())) {
         throw new Project_InvalidFullName_Exception($this->ruleFullName->getErrorMessage());
     }
     $id = $this->createProject($data);
     if ($id) {
         return $this->projectManager->getProject($id);
     }
     throw new Project_Creation_Exception();
 }
 function validate($data)
 {
     $is_valid = true;
     if (!$data['project']['form_full_name'] || !$data['project']['form_unix_name']) {
         $GLOBALS['Response']->addFeedback('error', $GLOBALS['Language']->getText('register_projectname', 'info_missed'));
         $is_valid = false;
     } else {
         //check for valid group name
         $form_unix_name = $data['project']['form_unix_name'];
         $rule = new Rule_ProjectName();
         if (!$rule->isValid($form_unix_name)) {
             $GLOBALS['Response']->addFeedback('error', $GLOBALS['Language']->getText('register_license', 'invalid_short_name'));
             $GLOBALS['Response']->addFeedback('error', $rule->getErrorMessage());
         } else {
             $form_full_name = $data['project']['form_full_name'];
             $rule = new Rule_ProjectFullName();
             if (!$rule->isValid($form_full_name)) {
                 $GLOBALS['Response']->addFeedback('error', $GLOBALS['Language']->getText('register_license', 'invalid_full_name'));
                 $GLOBALS['Response']->addFeedback('error', $rule->getErrorMessage());
                 $is_valid = false;
             }
         }
     }
     return $is_valid;
 }
Esempio n. 3
0
 /**
  * Create a new project
  * 
  * $data['project']['form_unix_name']
  * $data['project']['form_full_name']
  * $data['project']['form_license']
  * $data['project']['form_license_other']
  * $data['project']['form_short_description']
  * $data['project']['built_from_template']
  * $data['project']['is_test']
  * $data['project']['is_public']
  * $data['project']["form_".$descfieldsinfos[$i]["group_desc_id"]]
  * foreach($data['project']['trove'] as $root => $values);
  * $data['project']['services'][$arr['service_id']]['is_used'];
  * $data['project']['services'][$arr['service_id']]['server_id'];
  * 
  * @param String $shortName
  * @param String $publicName
  * @param Array $data
  * 
  * @return Project
  */
 public function create($shortName, $publicName, $data)
 {
     if (!$this->ruleShortName->isValid($shortName)) {
         throw new Project_InvalidShortName_Exception($this->ruleShortName->getErrorMessage());
     }
     $data['project']['form_unix_name'] = $shortName;
     if (!$this->ruleFullName->isValid($publicName)) {
         throw new Project_InvalidFullName_Exception($this->ruleFullName->getErrorMessage());
     }
     $data['project']['form_full_name'] = $publicName;
     $id = $this->create_project($data);
     if ($id) {
         return $this->projectManager->getProject($id);
     }
     throw new Project_Creation_Exception();
 }
 /**
  *
  * @return \Project_OneStepCreation_OneStepCreationValidator
  */
 private function validateFullName()
 {
     if ($this->creation_request->getFullName() == null) {
         $GLOBALS['Response']->addFeedback('error', $GLOBALS['Language']->getText('register_projectname', 'info_missed'));
         $this->setIsNotValid();
         return $this;
     }
     $rule = new Rule_ProjectFullName();
     if (!$rule->isValid($this->creation_request->getFullName())) {
         $GLOBALS['Response']->addFeedback('error', $GLOBALS['Language']->getText('register_license', 'invalid_full_name'));
         $GLOBALS['Response']->addFeedback('error', $rule->getErrorMessage());
         $this->setIsNotValid();
     }
     return $this;
 }
 function testIsValid()
 {
     $rule = new Rule_ProjectFullName();
     $this->assertTrue($rule->isValid("prj"));
     $this->assertEqual($rule->getErrorMessage(), null);
     $this->assertTrue($rule->isValid("       project name long by spaces       "));
     $this->assertEqual($rule->getErrorMessage(), null);
     $this->assertFalse($rule->isValid(""));
     $this->assertEqual($rule->getErrorMessage(), 'name_too_short');
     $this->assertFalse($rule->isValid(" "));
     $this->assertEqual($rule->getErrorMessage(), 'name_too_short');
     $this->assertFalse($rule->isValid("   "));
     $this->assertEqual($rule->getErrorMessage(), 'name_too_short');
     $this->assertFalse($rule->isValid("p"));
     $this->assertEqual($rule->getErrorMessage(), 'name_too_short');
     $this->assertFalse($rule->isValid("p   "));
     $this->assertEqual($rule->getErrorMessage(), 'name_too_short');
     $this->assertFalse($rule->isValid("pr"));
     $this->assertEqual($rule->getErrorMessage(), 'name_too_short');
     $this->assertFalse($rule->isValid("This a very very long project name longer than 40 characters :)"));
     $this->assertEqual($rule->getErrorMessage(), 'name_too_long');
 }
Esempio n. 6
0
}
$row_grp = db_fetch_array($res_grp);
$form_group_name = trim($request->get('form_group_name'));
$form_shortdesc = $request->get('form_shortdesc');
$Update = $request->get('Update');
$valid_data = 0;
if ($Update) {
    //data validation
    $valid_data = 1;
    if (!$form_group_name || !$form_shortdesc) {
        $GLOBALS['Response']->addFeedback('error', $GLOBALS['Language']->getText('project_admin_editgroupinfo', 'info_missed'));
        $valid_data = 0;
    } else {
        $rule = new Rule_ProjectFullName();
        if (!$rule->isValid($form_group_name)) {
            $GLOBALS['Response']->addFeedback('error', $rule->getErrorMessage());
            $valid_data = 0;
        }
    }
    $descfieldsinfos = getProjectsDescFieldsInfos();
    for ($i = 0; $i < sizeof($descfieldsinfos); $i++) {
        $currentform = trim($request->get("form_" . $descfieldsinfos[$i]["group_desc_id"]));
        if ($descfieldsinfos[$i]['desc_required'] == 1 && !$currentform) {
            $GLOBALS['Response']->addFeedback('error', $GLOBALS['Language']->getText('project_admin_editgroupinfo', 'info_missed'));
            $valid_data = 0;
        }
    }
}
$project_manager = ProjectManager::instance();
$current_user = $request->getCurrentUser();
$user_can_choose_visibility = $current_user->isSuperUser() || ForgeConfig::get(ForgeAccess::PROJECT_ADMIN_CAN_CHOOSE_VISIBILITY);