~fabiocbalbuquerque/sahana-agasti/web-services

« back to all changes in this revision

Viewing changes to web/install.inc.php

  • Committer: Fabio Albuquerque
  • Date: 2011-08-08 22:10:34 UTC
  • mfrom: (1.26.1 push-trunk)
  • Revision ID: fabiocbalbuquerque@gmail.com-20110808221034-vfr4ggsbxsdllq82
Merges from CUNY SPS

Show diffs side-by-side

added added

removed removed

Lines of Context:
28
28
 
29
29
class agInstall
30
30
{
 
31
 
31
32
  /* protected *//*
32
33
    var $AG_CONFIG;
33
34
    var $DISABLE_NEXT;
100
101
    unset($GLOBALS['trans']);
101
102
  }
102
103
 
 
104
  function  __destruct() {
 
105
    if (is_callable('apc_clear_cache')) {
 
106
      apc_clear_cache();
 
107
      apc_clear_cache('user');
 
108
      apc_clear_cache('opcode');
 
109
    }
 
110
  }
 
111
 
103
112
  function getConfig($name, $default = null)
104
113
  {
105
114
//if entry method to this function is admin/config instead of install, set the global
265
274
    if ($this->RETRY_SUCCESS == false) {
266
275
      $retry = '<input type="submit" class="linkButton" id="retry" name="retry" value="' . $retry_label . '" />';
267
276
    }
 
277
    $loadSamples = '<input class="checkbox" type="checkbox" value="yes" name="load_samples" id="load_samples" ';
 
278
    $this->getConfig('LOAD_SAMPLES', false) == 'yes' ? $loadSamples .= ' checked=checked>' : $loadSamples .= '>';
 
279
 
268
280
    $table = '<fieldset>
269
281
              <legend><img src="images/database.png" alt="database icon" />Database Configuration:</legend>
270
282
 
289
301
                  <input type="password" name="db_pass" id="db_pass" class="inputGray"
290
302
                         value="' . $this->getConfig('DB_PASSWORD', 'root') . '" />
291
303
                </li>
 
304
                <li>
 
305
                  <label>load sample data?:</label>' . $loadSamples .
 
306
                '</li>
292
307
                <input id="init_schema" type="hidden" name="init_schema" checked="checked" />
293
308
                <li><span class="fail">this will drop your current database.</span></li>
294
309
              </ul>
333
348
  function stage4()
334
349
  {
335
350
    $current = $this->getCurrent();
 
351
    $loadSamples = ($this->getConfig('LOAD_SAMPLES') == 'yes') ? 'Yes' : 'No';
336
352
 
337
353
    return 'Configuration files written. Below is your installation configuration summary:<br />
338
354
      <div class="info">
340
356
    '<br /><strong>Database Name</strong>: ' . $this->getConfig('DB_DATABASE') .
341
357
    '<br /><strong>Database User</strong>: ' . $this->getConfig('DB_USER') .
342
358
    '<br /><strong>Database Password</strong>: ' . preg_replace('/./', '*', $this->getConfig('DB_PASSWORD', 'unknown')) .
 
359
    '<br /><strong>Load Sample Data:</strong>: ' . $loadSamples .
343
360
    '<br /><strong>Administrator Name </strong>: ' . $this->getConfig('ADMIN_NAME') .
344
361
    '<br /><strong>Admin E-mail</strong>: ' . $this->getConfig('ADMIN_EMAIL') .
345
362
    '<br /><strong>Super User</strong>: ' . $this->getConfig('ADMIN_USER') .
351
368
  function stage5()
352
369
  {
353
370
    if ($this->INSTALL_RESULT == 'Success!') {
 
371
      $loadSamples = ($this->getConfig('LOAD_SAMPLES') == 'yes') ? 'Yes' : 'No';
354
372
      return '<span class="okay">Congratulations!  Installation was successful:</span> <br /><div class="info">
355
373
        <strong>Database Host</strong>: ' . $this->getConfig('DB_SERVER') .
356
374
      '<br /><strong>Database Name</strong>: ' . $this->getConfig('DB_DATABASE') .
357
375
      '<br /><strong>Database User</strong>: ' . $this->getConfig('DB_USER') .
358
376
      '<br /><strong>Database Password</strong>: ' . preg_replace('/./', '*', $this->getConfig('DB_PASSWORD', 'unknown')) .
 
377
      '<br /><strong>Load Sample Data:</strong>: ' . $loadSamples .
359
378
      '<br /><strong>Administrator</strong>: ' . $this->getConfig('ADMIN_NAME') .
360
379
      '<br /><strong>Admin E-mail</strong>: ' . $this->getConfig('ADMIN_EMAIL') .
361
380
      '</div><br /> NOTE: to continue with Agasti setup you must first create the "Super User"
515
534
    try {
516
535
      //Doctrine_Core::loadData(sfConfig::get('sf_data_dir') . '/fixtures', false);
517
536
      //$installed[] = 'Successfully loaded core data fixtures';
518
 
      $dataDirectories = array(sfConfig::get('sf_data_dir') . '/fixtures',
519
 
                               sfConfig::get('sf_data_dir') . '/samples');
 
537
      $dataDirectories = array(sfConfig::get('sf_data_dir') . '/fixtures');
 
538
      if ($this->getConfig('LOAD_SAMPLES') == 'yes') {
 
539
        $dataDirectories[] = sfConfig::get('sf_data_dir') . '/samples';
 
540
      }
520
541
      Doctrine_Core::loadData($dataDirectories, false);
521
542
      $installed = 'Success!';
522
543
    } catch (Exception $e) {
555
576
//        $connection = Doctrine_Manager::connection()->connect();
556
577
      sfContext::createInstance($configuration)->dispatch();
557
578
 
558
 
      $luceneIndex = new agLuceneIndex(array('agStaff', 'agFacility', 'agScenario', 'agScenarioFacilityGroup'));
 
579
      chdir(sfConfig::get('sf_root_dir'));
 
580
      $task = new sfCacheClearTask(sfContext::createInstance($configuration)->getEventDispatcher(), new sfFormatter());
 
581
      $task->run(array(), array());
 
582
 
 
583
      $luceneIndex = new agLuceneIndex(array('agStaff', 'agFacility', 'agScenario', 'agScenarioFacilityGroup', 'agOrganization'));
559
584
      $luceneIndex->indexAll();
560
585
      $installed = 'Success!';
561
586
    } catch (Exception $e) {
613
638
        $this->setConfig('DB_PASSWORD', $_POST['db_pass']);
614
639
        $this->setConfig('ADMIN_NAME', $_POST['admin_name']);
615
640
        $this->setConfig('ADMIN_EMAIL', $_POST['admin_email']);
 
641
        $this->setConfig('LOAD_SAMPLES', (isset($_POST['load_samples']) ? 'yes' : FALSE));
616
642
      } else {
617
643
        $db_params = $current[0];
618
644
        $config_array = $current[1];
659
685
        $this->setConfig('DB_PASSWORD', $_POST['db_pass']);
660
686
        $this->setConfig('ADMIN_NAME', $_POST['admin_name']);
661
687
        $this->setConfig('ADMIN_EMAIL', $_POST['admin_email']);
 
688
        $this->setConfig('LOAD_SAMPLES', (isset($_POST['load_samples']) ? 'yes' : FALSE));
662
689
        $this->DoNext();
663
690
//we should validate here in case someone changes correct information
664
691
      }