Beispiel #1
0
 public function saveConfiguration($values)
 {
     // Restore database from backup?
     if ($values['template'] == 'backup') {
         if (!Curry_Backend_DatabaseHelper::restoreFromFile('db.txt')) {
             $this->addMessage('Unable to restore database content from db.txt', self::MSG_WARNING);
         }
     }
     // Create admin user
     if ($values['admin']['username']) {
         $access = array('*', 'Curry_Backend_Content/*');
         $adminRole = self::createRole('Super', $access);
         $adminUser = self::createUser($values['admin']['username'], $values['admin']['password'], $adminRole);
         if ($adminUser->isNew()) {
             self::createFilebrowserAccess($adminRole, 'Root', '');
         }
         $adminUser->save();
     }
     // Create light user
     if ($values['user']['username']) {
         $access = array('Curry_Backend_FileBrowser', 'Curry_Backend_Page', 'Curry_Backend_Profile', 'Curry_Backend_Translations', 'Curry_Backend_Content/*');
         $userRole = self::createRole('User', $access);
         $user = self::createUser($values['user']['username'], $values['user']['password'], $userRole);
         if ($user->isNew()) {
             $user->save();
             self::createFilebrowserAccess($user, 'Home', 'user-content/' . $user->getUserId() . '/');
             self::createFilebrowserAccess($userRole, 'Shared', 'content/');
         }
         $user->save();
     }
     if ($values['template'] != 'backup') {
         // Create default meta-data items
         $metadatas = array('Title' => 'text', 'Keywords' => 'textarea', 'Description' => 'textarea', 'Image' => 'previewImage');
         foreach ($metadatas as $name => $type) {
             $metadata = new Metadata();
             $metadata->setName($name);
             $metadata->setDisplayName($name);
             $metadata->setType($type);
             $metadata->save();
         }
         $page = new Page();
         $page->setName("Home");
         $page->setURL("/");
         $page->setVisible(true);
         $page->setEnabled(true);
         $page->makeRoot();
         $page->save();
         $page->createDefaultRevisions();
         $page->save();
         $pageRev = $page->getWorkingPageRevision();
         $pageRev->setTemplate('Root.html');
         $pageRev->save();
         $pa = new PageAccess();
         $pa->setPage($page);
         $pa->setPermSubpages(true);
         $pa->setPermVisible(true);
         $pa->setPermCreatePage(true);
         $pa->setPermCreateModule(true);
         $pa->setPermPublish(true);
         $pa->setPermProperties(true);
         $pa->setPermContent(true);
         $pa->setPermMeta(true);
         $pa->setPermModules(true);
         $pa->setPermRevisions(true);
         $pa->setPermPermissions(true);
         $pa->save();
     }
     // Create template root
     $templateRoot = Curry_Core::$config->curry->template->root;
     if (!file_exists($templateRoot)) {
         @mkdir($templateRoot, 0777, true);
     }
     switch ($values['template']) {
         case 'empty':
         case 'curry':
             $source = Curry_Util::path(Curry_Core::$config->curry->wwwPath, 'shared', 'backend', 'common', 'templates', 'project-empty.html');
             $templateFile = Curry_Util::path($templateRoot, 'Root.html');
             if (!file_exists($templateFile)) {
                 @copy($source, $templateFile);
             }
             break;
         case 'twitter-bootstrap':
         case 'html5boilerplate':
     }
     if (file_exists(Curry_Core::$config->curry->configPath)) {
         $config = new Zend_Config(require Curry_Core::$config->curry->configPath, true);
         $config->curry->name = $values['name'];
         $config->curry->adminEmail = $values['email'];
         if ($values['base_url']) {
             $config->curry->baseUrl = $values['base_url'];
         } else {
             unset($config->curry->baseUrl);
         }
         $config->curry->developmentMode = (bool) $values['development_mode'];
         $config->curry->secret = sha1(uniqid(mt_rand(), true) . microtime());
         $writer = new Zend_Config_Writer_Array();
         $writer->write(Curry_Core::$config->curry->configPath, $config);
     }
     return true;
 }
Beispiel #2
0
 /**
  * Restore from file, using _GET request. 
  * 
  * @todo Verify this is working and that it's secure. Can we do this using session variables instead? 
  */
 public function showContinueRestore()
 {
     if (!Curry_URL::validate()) {
         throw new Exception('Invalid hash');
     }
     Curry_Backend_DatabaseHelper::restoreFromFile($_GET['file'], $_GET['tables'], $_GET['max_execution_time'], $_GET['line'], $this);
 }