Esempio n. 1
0
 public function testUpdate()
 {
     $this->assertEquals(true, Config::set('foo2', 'baz'));
     $this->assertEquals('baz', Config::get('foo2'));
     $this->assertEquals(true, Config::set('foo2', 'xyz'));
     $this->assertEquals('xyz', Config::get('foo2'));
 }
Esempio n. 2
0
 public function actionIndex()
 {
     try {
         $queue = [];
         foreach (Yii::$app->getModules() as $id => $module) {
             if ($module instanceof \luya\base\Module) {
                 $response = $module->import($this);
                 if (is_array($response)) {
                     // importer returns an array with class names
                     foreach ($response as $class) {
                         $obj = new $class($this);
                         $prio = $obj->queueListPosition;
                         while (true) {
                             if (!array_key_exists($prio, $queue)) {
                                 break;
                             }
                             ++$prio;
                         }
                         $queue[$prio] = $obj;
                     }
                 }
             }
         }
         ksort($queue);
         foreach ($queue as $pos => $object) {
             $object->run();
         }
         if (Yii::$app->hasModule('admin')) {
             Config::set('last_import_timestamp', time());
             Yii::$app->db->createCommand()->update('admin_user', ['force_reload' => 1])->execute();
         }
         return $this->outputSuccess(print_r($this->_log, true));
     } catch (Exception $err) {
         return $this->outputError(sprintf("Exception while importing: '%s' in file '%s' on line '%s'.", $err->getMessage(), $err->getFile(), $err->getLine()));
     }
 }
Esempio n. 3
0
 /**
  * @todo use options instead, override options()
  * @todo see if admin is availoable
  *
  * @param string $email
  * @param string $password
  */
 public function actionIndex()
 {
     if (!Config::has('last_import_timestamp')) {
         return $this->outputError("You have to run the 'import' process first. run in terminal: ./vendor/bin/luya import");
     }
     if (Config::has('setup_command_timestamp')) {
         return $this->outputError('The setup process already have been started on the ' . date('d.m.Y H:i', Config::get('setup_command_timestamp')) . '. If you want to reinstall your luya project. Drop all tables from your Database, run the migrate command, run the import command and then re-run the setup command');
     }
     $email = $this->prompt('Benutzer E-Mail:');
     $password = $this->prompt('Benutzer Passwort:');
     $firstname = $this->prompt('Vorname:');
     $lastname = $this->prompt('Nachname:');
     if (!$this->confirm("Create a new user ({$email}) with password '{$password}'?")) {
         return $this->outputError('Abort by user.');
     }
     $salt = Yii::$app->getSecurity()->generateRandomString();
     $pw = Yii::$app->getSecurity()->generatePasswordHash($password . $salt);
     $this->insert('admin_user', ['title' => 1, 'firstname' => $firstname, 'lastname' => $lastname, 'email' => $email, 'password' => $pw, 'password_salt' => $salt, 'is_deleted' => 0]);
     $this->insert('admin_group', ['name' => 'Adminstrator', 'text' => 'Administrator Accounts']);
     $this->insert('admin_user_group', ['user_id' => 1, 'group_id' => 1]);
     // get the api-admin-user and api-admin-group auth rights
     $data = Yii::$app->db->createCommand("SELECT * FROM admin_auth WHERE api='api-admin-user' OR api='api-admin-group'")->queryAll();
     foreach ($data as $item) {
         $this->insert('admin_group_auth', ['group_id' => 1, 'auth_id' => $item['id'], 'crud_create' => 1, 'crud_update' => 1, 'crud_delete' => 1]);
     }
     $this->insert('admin_lang', ['name' => 'Deutsch', 'short_code' => 'de', 'is_default' => 1]);
     Config::set('setup_command_timestamp', time());
     return $this->outputSuccess("You can now login with the Email '{$email}' and password '{$password}'.");
 }