コード例 #1
0
ファイル: Module.php プロジェクト: noix/qsprog
 function UpdatePath($id = null)
 {
     global $_JAM;
     // Check whether we have data
     if (!$this->item) {
         // We don't; we need to fetch data
         $itemID = $_POST['master'] ? $_POST['master'] : $id;
         // FIXME: Again, f*****g kludge for translations.
         if ($_POST['language']) {
             $originalLanguage = $_JAM->language;
             $_JAM->language = $_POST['language'];
         }
         if (!$this->FetchItem($itemID)) {
             return false;
         }
         if ($originalLanguage) {
             $_JAM->language = $originalLanguage;
         }
     }
     $safeInsert = $this->config['forbidObsoletePaths'] ? false : true;
     // Update path for module item
     if ($path = $this->GetPath()) {
         $pathItemID = $_POST['master'] ? $_POST['master'] : $id;
         $language = $_POST['language'];
         if ($insertedPath = Path::Insert($path, $this->moduleID, $pathItemID, $safeInsert, $language)) {
             $this->item['path'] = $insertedPath;
         } else {
             trigger_error("Couldn't insert path in database", E_USER_ERROR);
             return false;
         }
     }
     // Update path for files
     if ($this->files) {
         foreach ($this->schema as $name => $info) {
             if ($info['type'] == 'file') {
                 if (!is_object($this->item[$name])) {
                     $this->item[$name] = $this->NestModule('files', $this->item[$name]);
                 }
                 if ($filePath = $this->item[$name]->GetPath($name)) {
                     if (!Path::Insert($filePath, $this->files->moduleID, $this->item[$name]->itemID, $safeInsert)) {
                         trigger_error("Couldn't insert path for file associated with field " . $name . " in module " . $this->name, E_USER_ERROR);
                     }
                 }
             }
         }
     }
 }
コード例 #2
0
ファイル: Jam.php プロジェクト: etienne/jam
 function FirstRun()
 {
     // Load table structure for required tables
     $tables = IniFile::Parse('engine/database/tables.ini', true);
     // Create tables
     foreach ($tables as $name => $schema) {
         if (!Database::CreateTable($name, $schema)) {
             trigger_error("Couldn't create table " . $name, E_USER_ERROR);
         }
     }
     // Manually add admin module to _modules table
     if (Query::TableIsEmpty('_modules')) {
         $adminModule = array('name' => 'admin');
         if (!Database::Insert('_modules', $adminModule)) {
             trigger_error("Couldn't install core modules", E_USER_ERROR);
         }
     }
     // Install required modules
     $requiredModules = array('users', 'files');
     foreach ($requiredModules as $moduleName) {
         $module = Module::GetNewModule($moduleName);
         $module->Install();
     }
     // Add default admin user
     if (Query::TableIsEmpty('users')) {
         $adminUserParams = array('created' => $this->databaseTime, 'login' => 'admin', 'name' => 'Admin', 'password' => 'admin', 'status' => 3);
         if (!Database::Insert('users', $adminUserParams)) {
             trigger_error("Couldn't create admin user", E_USER_ERROR);
         }
     }
     // Add admin path
     $adminModuleId = Query::SingleValue('_modules', 'id', "name = 'admin'");
     if (!Path::Insert('admin', $adminModuleId, false)) {
         trigger_error("Couldn't add admin path", E_USER_ERROR);
     }
     // Redirect to admin interface
     HTTP::RedirectLocal('admin');
 }
コード例 #3
0
ファイル: firstrun.php プロジェクト: noix/programme
    if (!Database::CreateTable($name, $schema)) {
        trigger_error("Couldn't create table " . $name, E_USER_ERROR);
    }
}
// Manually add admin module to _modules table
if (Query::TableIsEmpty('_modules')) {
    $adminModule = array('name' => 'admin');
    if (!Database::Insert('_modules', $adminModule)) {
        trigger_error("Couldn't install core modules", E_USER_ERROR);
    }
}
// Install required modules
$requiredModules = array('users', 'files');
foreach ($requiredModules as $moduleName) {
    $module = Module::GetNewModule($moduleName);
    $module->Install();
}
// Add default admin user
if (Query::TableIsEmpty('users')) {
    $adminUserParams = array('created' => $_JAM->databaseTime, 'login' => 'admin', 'name' => 'Admin', 'password' => 'admin', 'status' => 3);
    if (!Database::Insert('users', $adminUserParams)) {
        trigger_error("Couldn't create admin user", E_USER_ERROR);
    }
}
// Add admin path
$adminModuleId = Query::SingleValue('_modules', 'id', "name = 'admin'");
if (!Path::Insert('admin', $adminModuleId, false)) {
    trigger_error("Couldn't add admin path", E_USER_ERROR);
}
// Redirect to admin interface
HTTP::RedirectLocal('admin');