private static function _createEmptyProject($languageCode, $languageName, $userId)
 {
     $website = Website::get();
     $projectCode = SemDomTransProjectModel::projectCode($languageCode);
     $projectName = SemDomTransProjectModel::projectName($languageCode, $languageName);
     $projectID = ProjectCommands::createProject($projectName, $projectCode, LfProjectModel::SEMDOMTRANS_APP, $userId, $website);
     $project = new SemDomTransProjectModel($projectID);
     $project->languageIsoCode = $languageCode;
     $project->isSourceLanguage = false;
     $project->semdomVersion = SemDomTransProjectModel::SEMDOM_VERSION;
     // by default all created projects have English as their source.  A future feature would allow creating projects off of other source languages
     $englishProject = SemDomTransProjectModel::getEnglishProject();
     $project->sourceLanguageProjectId->id = $englishProject->id->asString();
     return $project->write();
 }
Пример #2
0
$changeDatabase = false;
// process xml into a php data structure, organized by language
$xml = simplexml_load_file($xmlFilePath);
$lang = $argv[2];
$version = $argv[3];
$projectCode = "semdom-{$lang}-{$semdomVersion}";
$projectName = "Semdom {$lang} Project";
$appName = LfProjectModel::SEMDOMTRANS_APP;
$website = new Website($domain, Website::LANGUAGEFORGE);
// if a previous project for that language and semantic domain version exists, DO NOT IMPORT
$previousProject = new SemDomTransProjectModel();
$previousProject->readByProperties(array("languageIsoCode" => $lang, "semdomVersion" => $semdomVersion));
if ($previousProject->id->asString() == "") {
    $sourceProject = new SemDomTransProjectModel();
    $sourceProject->readByCode("en");
    $projectID = ProjectCommands::createProject($projectName, $projectCode, $appName, $userId, $website);
    $projectModel = new SemDomTransProjectModel($projectID);
    $newXmlFilePath = $projectModel->getAssetsFolderPath() . '/' . basename($xmlFilePath);
    FileUtilities::createAllFolders($projectModel->getAssetsFolderPath());
    print "copying {$xmlFilePath} to  {$newXmlFilePath}\n";
    copy($xmlFilePath, $newXmlFilePath);
    $projectModel->xmlFilePath = $newXmlFilePath;
    $projectModel->languageIsoCode = $lang;
    $projectModel->semdomVersion = $semdomVersion;
    $projectModel->sourceLanguageProjectId = $sourceProject->id->asString();
    $projectModel->write();
    $importer = new SemDomXMLImporter($xmlFilePath, $projectModel, false, $isEnglish);
    $importer->run();
} else {
    echo "Project exists already" . "\n";
}
 /**
  * Creates a semdomtrans project and prefills it (using Google Translate data if appropriate flag is set)
  * @param string $languageCode
  * @param string $languageName
  * @param bool $useGoogleTranslateData
  * @param string $userId
  * @param Website $website
  * @param int $semdomVersion
  * @return string
  */
 public static function createProject($languageCode, $languageName, $useGoogleTranslateData, $userId, $website, $semdomVersion = SemDomTransProjectModel::SEMDOM_VERSION)
 {
     $projectCode = SemDomTransProjectModel::projectCode($languageCode, $semdomVersion);
     $projectName = SemDomTransProjectModel::projectName($languageCode, $languageName, $semdomVersion);
     $projectID = ProjectCommands::createProject($projectName, $projectCode, LfProjectModel::SEMDOMTRANS_APP, $userId, $website);
     $project = new SemDomTransProjectModel($projectID);
     $project->languageIsoCode = $languageCode;
     $project->isSourceLanguage = false;
     $project->semdomVersion = $semdomVersion;
     $project->languageName = $languageName;
     // by default all created projects have English as their source.  A future feature would allow creating projects off of other source languages
     $englishProject = SemDomTransProjectModel::getEnglishProject($semdomVersion);
     $project->sourceLanguageProjectId->id = $englishProject->id->asString();
     // prefill project with semdom items
     $project->preFillFromSourceLanguage($useGoogleTranslateData);
     return $project->write();
 }
 public function testCreateProject_newProject_projectOwnerSet()
 {
     $this->environ->clean();
     $user1Id = $this->environ->createUser("user1name", "User1 Name", "*****@*****.**");
     $user1 = new UserModel($user1Id);
     $projectID = ProjectCommands::createProject(SF_TESTPROJECT, SF_TESTPROJECTCODE, 'sfchecks', $user1->id->asString(), $this->environ->website);
     $projectModel = new ProjectModel($projectID);
     $this->assertTrue($projectModel->ownerRef->asString() == $user1->id->asString());
 }
Пример #5
0
 /**
  *
  * @param string $projectName
  * @param string $projectCode
  * @param string $appName
  * @return string | boolean - $projectId on success, false if project code is not unique
  */
 public function project_create($projectName, $projectCode, $appName)
 {
     return ProjectCommands::createProject($projectName, $projectCode, $appName, $this->_userId, $this->_website);
 }
$resetUser->resetPasswordExpirationDate = $today->add(new DateInterval('P5D'));
$resetUser->write();
$projectType = null;
if ($site == 'scriptureforge') {
    $projectType = SfProjectModel::SFCHECKS_APP;
} else {
    if ($site == 'languageforge') {
        $projectType = LfProjectModel::LEXICON_APP;
    }
}
$testProject = ProjectCommands::createProject($constants['testProjectName'], $constants['testProjectCode'], $projectType, $adminUserId, $website);
$testProjectModel = new ProjectModel($testProject);
$testProjectModel->projectCode = $constants['testProjectCode'];
$testProjectModel->allowInviteAFriend = $constants['testProjectAllowInvites'];
$testProjectModel->write();
$otherProject = ProjectCommands::createProject($constants['otherProjectName'], $constants['otherProjectCode'], $projectType, $managerUserId, $website);
$otherProjectModel = new ProjectModel($otherProject);
$otherProjectModel->projectCode = $constants['otherProjectCode'];
$otherProjectModel->allowInviteAFriend = $constants['otherProjectAllowInvites'];
$otherProjectModel->write();
ProjectCommands::updateUserRole($testProject, $managerUserId, ProjectRoles::MANAGER);
ProjectCommands::updateUserRole($testProject, $memberUserId, ProjectRoles::CONTRIBUTOR);
ProjectCommands::updateUserRole($testProject, $resetUserId, ProjectRoles::CONTRIBUTOR);
ProjectCommands::updateUserRole($otherProject, $adminUserId, ProjectRoles::MANAGER);
if ($site == 'scriptureforge') {
    $text1 = TextCommands::updateText($testProject, array('id' => '', 'title' => $constants['testText1Title'], 'content' => $constants['testText1Content']));
    $text2 = TextCommands::updateText($testProject, array('id' => '', 'title' => $constants['testText2Title'], 'content' => $constants['testText2Content']));
    $question1 = QuestionCommands::updateQuestion($testProject, array('id' => '', 'textRef' => $text1, 'title' => $constants['testText1Question1Title'], 'description' => $constants['testText1Question1Content']));
    $question2 = QuestionCommands::updateQuestion($testProject, array('id' => '', 'textRef' => $text1, 'title' => $constants['testText1Question2Title'], 'description' => $constants['testText1Question2Content']));
    $template1 = QuestionTemplateCommands::updateTemplate($testProject, array('id' => '', 'title' => 'first template', 'description' => 'not particularly interesting'));
    $template2 = QuestionTemplateCommands::updateTemplate($testProject, array('id' => '', 'title' => 'second template', 'description' => 'not entirely interesting'));
Пример #7
0
 public function testUserCRUD_CRUDOK()
 {
     $e = new ApiCrudTestEnvironment();
     // initial list
     $result = $e->json(UserCommands::listUsers());
     $count = $result['count'];
     // Create
     $userId = $e->e->createUser('someuser', 'SomeUser', '*****@*****.**');
     $someUser = new UserModel($userId);
     $this->assertNotNull($someUser);
     $this->assertEqual(24, strlen($someUser->id->asString()));
     // create project
     $projectId = ProjectCommands::createProject(SF_TESTPROJECT, SF_TESTPROJECTCODE, 'sfchecks', $someUser->id->asString(), $e->e->website);
     // list
     $result = $e->json(UserCommands::listUsers());
     $this->assertEqual($count + 1, $result['count']);
     // Read
     $result = $e->json(UserCommands::readUser($someUser->id->asString()));
     $this->assertNotNull($result['id']);
     $this->assertEqual('someuser', $result['username']);
     $this->assertEqual('*****@*****.**', $result['email']);
     // Update
     $result['username'] = '******';
     $result['email'] = '*****@*****.**';
     $id = UserCommands::updateUser($result);
     $this->assertNotNull($id);
     $this->assertEqual($result['id'], $id);
     // typeahead
     $result = $e->json(UserCommands::userTypeaheadList('ome', '', $e->e->website));
     $this->assertTrue($result['count'] > 0);
     // change password
     UserCommands::changePassword($id, 'newpassword', $id);
     // Delete
     $result = UserCommands::deleteUsers(array($id));
     $this->assertTrue($result);
 }