public function __invoke($params)
 {
     // recreate languages
     $modelCreator = new \tao_install_utils_ModelCreator(LOCAL_NAMESPACE);
     $models = $modelCreator->getLanguageModels();
     foreach ($models as $ns => $modelFiles) {
         foreach ($modelFiles as $file) {
             $modelCreator->insertLocalModel($file);
         }
     }
     OntologyUpdater::syncModels();
     // reapply access rights
     $exts = \common_ext_ExtensionsManager::singleton()->getInstalledExtensions();
     foreach ($exts as $ext) {
         $installer = new \tao_install_ExtensionInstaller($ext);
         $installer->installManagementRole();
         $installer->applyAccessRules();
     }
     // recreate admin
     if (count($params) >= 2) {
         $login = array_shift($params);
         $password = array_shift($params);
         $sysAdmin = $this->getResource(INSTANCE_ROLE_SYSADMIN);
         $userClass = $this->getClass(CLASS_TAO_USER);
         \core_kernel_users_Service::singleton()->addUser($login, $password, $sysAdmin, $userClass);
     }
     // empty cache
     \common_cache_FileCache::singleton()->purge();
     return \common_report_Report::createSuccess('All done');
 }
示例#2
0
 /**
  * Extends the users explizit roles with the implizit rules
  * of the local system
  * 
  * @return array the identifiers of the roles:
  */
 public function getRoles()
 {
     $returnValue = array();
     // We use a Depth First Search approach to flatten the Roles Graph.
     foreach ($this->getPropertyValues(PROPERTY_USER_ROLES) as $roleUri) {
         $returnValue[] = $roleUri;
         foreach (core_kernel_users_Service::singleton()->getIncludedRoles(new core_kernel_classes_Resource($roleUri)) as $role) {
             $returnValue[] = $role->getUri();
         }
     }
     return array_unique($returnValue);
 }
 public function run()
 {
     $dbWrapper = core_kernel_classes_DbWrapper::singleton();
     $sth = $dbWrapper->prepare('SELECT DISTINCT "author" FROM statements');
     $result = $sth->execute();
     $updateQuery = $dbWrapper->prepare('UPDATE statements SET "author" = ? WHERE "author" = ?;');
     foreach ($sth->fetchAll() as $data) {
         if (!empty($data['author'])) {
             $login = $data['author'];
             $user = core_kernel_users_Service::singleton()->getOneUser($login);
             if (is_null($user)) {
                 $this->out('User with login ' . $login . ' not found, skipping');
             } else {
                 if (!$updateQuery->execute(array($user->getUri(), $login))) {
                     $this->err('Unable to replace ' . $login . ' with ' . $user->getUri());
                 }
             }
         }
     }
 }
 /**
  * constructor
  *
  * @access protected
  * @author Jerome Bogaerts, <*****@*****.**>
  * @return mixed
  */
 protected function __construct()
 {
     $this->generisUserService = core_kernel_users_Service::singleton();
 }
示例#5
0
 public function setUp()
 {
     GenerisPhpUnitTestRunner::initTest();
     $this->service = core_kernel_users_Service::singleton();
     $this->sampleUser = $this->service->addUser(self::TESTCASE_USER_LOGIN, 'pwd' . rand());
 }
示例#6
0
 /**
  * Constructor, calls the initRole method.
  *
  * @access protected
  * @author Joel Bout, <*****@*****.**>
  */
 protected function __construct()
 {
     parent::__construct();
     $this->generisUserService = core_kernel_users_Service::singleton();
     $this->initRole();
 }
示例#7
0
 /**
  * Short description of method logOut
  *
  * @access public
  * @author Bertrand Chevrier, <*****@*****.**>
  * @return boolean
  */
 public function logOut()
 {
     $returnValue = (bool) false;
     core_kernel_users_Service::singleton()->logout();
     return (bool) $returnValue;
 }
 private function determinTaoRoles()
 {
     $roles = array();
     if ($this->getLaunchData()->hasVariable(taoLti_models_classes_LtiLaunchData::ROLES)) {
         foreach ($this->getLaunchData()->getUserRoles() as $role) {
             $taoRole = taoLti_models_classes_LtiUtils::mapLTIRole2TaoRole($role);
             if (!is_null($taoRole)) {
                 $roles[] = $taoRole;
                 foreach (core_kernel_users_Service::singleton()->getIncludedRoles(new core_kernel_classes_Resource($taoRole)) as $includedRole) {
                     $roles[] = $includedRole->getUri();
                 }
             }
         }
         $roles = array_unique($roles);
     } else {
         return array(INSTANCE_ROLE_LTI_BASE);
     }
     return $roles;
 }