コード例 #1
0
 /**
  * Create a project, checking permissions as necessary
  * @param string $projectName
  * @param string $projectCode
  * @param string $appName
  * @param string $userId
  * @param Website $website
  * @param array $srProject send receive project data
  * @return string - projectId
  */
 public static function createProject($projectName, $projectCode, $appName, $userId, $website, $srProject = null)
 {
     // Check for unique project code
     if (ProjectCommands::projectCodeExists($projectCode)) {
         return false;
     }
     $project = new ProjectModel();
     $project->projectName = $projectName;
     $project->projectCode = $projectCode;
     $project->appName = $appName;
     $project->siteName = $website->domain;
     $project->ownerRef->id = $userId;
     $project->addUser($userId, ProjectRoles::MANAGER);
     $projectId = $project->write();
     if ($srProject) {
         SendReceiveCommands::updateSRProject($projectId, $srProject);
     }
     $user = new UserModel($userId);
     $user->addProject($projectId);
     $user->write();
     $project = ProjectModel::getById($projectId);
     $project->initializeNewProject();
     ActivityCommands::addUserToProject($project, $userId);
     return $projectId;
 }
 public function testUpdateSRProject_ProjectAndUser_SRProjectSaved()
 {
     $project = self::$environ->createProject(SF_TESTPROJECT, SF_TESTPROJECTCODE);
     $projectId = $project->id->asString();
     $sendReceiveProject = new SendReceiveProjectModel('sr_name', '', 'manager');
     $srProject = JsonEncoder::encode($sendReceiveProject);
     $srProject['identifier'] = 'sr_id';
     $newProjectId = SendReceiveCommands::updateSRProject($projectId, $srProject);
     $newProject = new LexProjectModel($newProjectId);
     $this->assertEquals($projectId, $newProjectId);
     $this->assertEquals($sendReceiveProject, $newProject->sendReceiveProject);
     $this->assertEquals($srProject['identifier'], $newProject->sendReceiveProjectIdentifier);
 }
コード例 #3
0
 public function sendReceive_updateSRProject($srProject)
 {
     return SendReceiveCommands::updateSRProject($this->projectId, $srProject);
 }