protected function getAvailable($ui)
 {
     $themesPath = '/usr/share/css/themes/';
     $themesDir = $this->webos->managers()->get('File')->get($themesPath);
     $themes = array();
     foreach ($themesDir->contents() as $file) {
         if (!$file->isDir()) {
             continue;
         }
         if (!$this->webos->managers()->get('File')->exists($file->path() . '/' . $ui . '/')) {
             continue;
         }
         if (!$this->webos->managers()->get('File')->exists($file->path() . '/theme.xml')) {
             continue;
         }
         $config = new \lib\models\Config($this->webos);
         $config->load($file->path() . '/theme.xml');
         $themes[$file->basename()] = array('name' => $config->get('name'), 'description' => $config->get('description'));
     }
     return $themes;
 }
 /**
  * Inscrire un nouvel utilisateur.
  * @param string $data Les informations sur l'utilisateur, encodees en JSON.
  */
 protected function register($data, $captchaData)
 {
     //Verification du captcha
     $captcha = $this->webos()->managers()->get('Captcha')->get($captchaData['id']);
     if (!$captcha->check($captchaData['value'])) {
         throw new \InvalidArgumentException('Le code de vérification est incorrect');
     }
     //Chargement de la configuration
     $config = new \lib\models\Config($this->webos);
     $config->load('/etc/register.xml');
     $canRegister = (int) $config->get('register');
     $authorizations = explode(';', $config->get('authorizations'));
     if (!$canRegister) {
         throw new \RuntimeException('L\'inscription a été désactivée. Pour obtenir un compte, veuillez contacter l\'administrateur système');
     }
     //On inscrit le membre
     $this->webos->managers()->get('User')->create($data, $authorizations);
 }
示例#3
0
        $specificData[] = array('~' => $specific['home']);
    }
}
$newConfig = array('specific' => $specificData, 'global' => array('~' => $oldConfig['global']['home']));
$newConfigFile = $fileManager->createFileRecursive($dest . '/etc/quotas.json');
$newConfigFile->setContents(json_encode($newConfig));
echo 'Exporting register config...' . "\n";
$config = new \lib\models\Config($this->webos);
$config->load('/etc/register.xml');
$registrationEnabled = (int) $config->get('register') ? true : false;
$maxUsers = (int) $config->get('maxUsers');
$defaultAuths = explode(';', $config->get('authorizations'));
$defaultAuths[] = 'user.self.edit';
//New permission
$newConfig = array('register' => $registrationEnabled, 'maxUsers' => $maxUsers, 'autoEnable' => true, 'authorizations' => $defaultAuths);
$newConfigFile = $fileManager->createFileRecursive($dest . '/etc/register.json');
$newConfigFile->setContents(json_encode($newConfig));
echo 'Exporting uploads config...' . "\n";
$config = new \lib\models\Config($this->webos);
$config->load('/etc/uploads.xml');
$newConfig = array('enabled' => (int) $config->get('enabled') ? true : false, 'maxFileSize' => (int) $config->get('maxFileSize'), 'allowedExtensions' => explode(';', $config->get('allowedExtensions')));
$newConfigFile = $fileManager->createFileRecursive($dest . '/etc/uploads.json');
$newConfigFile->setContents(json_encode($newConfig));
//CACHE
echo 'Deleting cache...' . "\n";
if ($fileManager->exists('/var/cache/diskusage.json')) {
    $fileManager->get('/var/cache/diskusage.json')->delete();
}
echo 'Done !' . "\n";
echo 'Migrated files are in "' . $destFilename . '". You can now update the webos to the latest commit. Then, copy files from "' . $destFilename . '/etc" to "/etc" and files from "' . $destFilename . '/var" to "/var".' . "\n";
echo 'IMPORTANT NOTE: You must clear sessions (by deleting cookies for example) before upgrading.' . "\n";