~fabiocbalbuquerque/sahana-agasti/web-services

1 by Usman Akeju
- initial commit; migrating to new branch internally
1
<?php
2
3
/**
1.1.107 by Darlene E McCullough
installer text proofed
4
 * Agasti 2.0 Installer
5
 *
6
 * PHP Version 5
7
 *
8
 * LICENSE: This source file is subject to LGPLv3.0 license
9
 * that is available through the world-wide-web at the following URI:
10
 * http://www.gnu.org/copyleft/lesser.html
11
 *
12
 * @author Charles Wisniewski, CUNY SPS
13
 *
14
 * Copyright of the Sahana Software Foundation, sahanafoundation.org
15
 */
16
/**
17
 * Sahana Agasti 2.0 install.inc.php
1 by Usman Akeju
- initial commit; migrating to new branch internally
18
 * this file houses installation specific functions, primarily called from install.php
19
 */
20
require_once (dirname(__FILE__) . '/../lib/vendor/symfony/lib/yaml/sfYaml.php');
21
require_once (dirname(__FILE__) . '/../config/ProjectConfiguration.class.php');
22
require_once(dirname(__FILE__) . '/requirements.inc.php');
1.1.630 by charles wisniewski
work to abstract the installer has begun, yml file is written in func.inc.php. Event Staff are also indexed now and searchable through the front end.
23
require_once (dirname(__FILE__) . '/../apps/frontend/lib/install/func.inc.php');
24
//OR sfProjectConfiguration::getActive()->loadHelpers(array('Install)); ^
1 by Usman Akeju
- initial commit; migrating to new branch internally
25
$configuration = ProjectConfiguration::getApplicationConfiguration('frontend', 'all', false);
1.1.1184 by Usman Akeju
- fixes installer
26
1.1.630 by charles wisniewski
work to abstract the installer has begun, yml file is written in func.inc.php. Event Staff are also indexed now and searchable through the front end.
27
//perhaps we should also autoload-regsiter...
1 by Usman Akeju
- initial commit; migrating to new branch internally
28
29
class agInstall
30
{
1.19.129 by Chad Heuschober
Updated installer and clean-project to allow switch-on / off of sample data.
31
 
1 by Usman Akeju
- initial commit; migrating to new branch internally
32
  /* protected *//*
33
    var $AG_CONFIG;
34
    var $DISABLE_NEXT;
35
    var $steps = array();
36
   */
37
38
  /* public */
39
40
  function __construct(&$AG_CONFIG)
41
  {
42
    $this->DISABLE_NEXT = FALSE;
43
    $this->RETRY_SUCCESS = FALSE;
44
    $this->ERROR_MESSAGE = '';
45
    $this->INSTALL_RESULT = '';
46
47
    $this->AG_CONFIG = &$AG_CONFIG;
48
49
    $this->steps = array(
50
      0 => array('title' => '1. Introduction', 'fun' => 'stage0'),
1.1.107 by Darlene E McCullough
installer text proofed
51
      1 => array('title' => '2. License Agreement', 'fun' => 'stage1'),
52
      2 => array('title' => '3. Prerequisite Check', 'fun' => 'stage2'),
1 by Usman Akeju
- initial commit; migrating to new branch internally
53
      3 => array('title' => '4. Configure Database', 'fun' => 'stage3'),
54
      4 => array('title' => '5. Configuration Summary', 'fun' => 'stage4'),
55
      5 => array('title' => '6. Installation Summary', 'fun' => 'stage5'),
56
//    6 => array('title' => '7. Enter Secure Mode', 'fun' => 'stage6' ),
57
    );
58
    $this->EventHandler();
59
    GLOBAL $trans;
60
    $trans = array(
1.1.81 by Usman Akeju
- fills in nav menu to match Darlene's design
61
//     requirements.inc.php
1 by Usman Akeju
- initial commit; migrating to new branch internally
62
      'S_PHP_VERSION' => 'PHP version',
63
      'S_MINIMAL_VERSION_OF_PHP_IS' => 'Minimal version of PHP is',
64
      'S_PHP_MEMORY_LIMIT' => 'PHP memory limit',
65
      'S_IS_A_MINIMAL_PHP_MEMORY_LIMITATION_SMALL' => 'is a minimal PHP memory limitation',
66
      'S_PHP_POST_MAX_SIZE' => 'PHP post max size',
67
      'S_IS_A_MINIMUM_SIZE_OF_PHP_POST_SMALL' => 'is minimum size of PHP post',
68
      'S_PHP_MAX_EXECUTION_TIME' => 'PHP max execution time',
69
      'S_PHP_MAX_INPUT_TIME' => 'PHP max input time',
70
      'S_IS_A_MINIMAL_LIMITATION_EXECTUTION_TIME_SMALL' => 'is a minimal limitation on execution time of PHP scripts',
71
      'S_IS_A_MINIMAL_LIMITATION_INPUT_PARSE_TIME_SMALL' => 'is a minimal limitation on input parse time for PHP scripts',
72
      'S_PHP_TIMEZONE' => 'PHP timezone',
73
      'S_NO_SMALL' => 'no',
74
      'S_YES_SMALL' => 'yes',
75
      'S_TIMEZONE_FOR_PHP_IS_NOT_SET' => 'Timezone for PHP is not set',
76
      'S_PLEASE_SET' => 'Please set',
77
      'S_OPTION_IN_SMALL' => 'option in',
78
      'S_PHP_DATABASES_SUPPORT' => 'PHP databases support',
79
      'S_REQUIRES_ANY_DATABASE_SUPPORT' => 'Requires any database support [MySQL or PostgreSQL or Oracle or SQLite3]',
80
      'S_REQUIRES_BCMATH_MODULE' => 'Requires bcmath module',
81
      'S_CONFIGURE_PHP_WITH_SMALL' => 'configure PHP with',
82
      'S_REQUIRES_MB_STRING_MODULE' => 'Requires mb string module',
83
      'S_PHP_SOCKETS' => 'PHP Sockets',
84
      'S_REQUIRED_SOCKETS_MODULE' => 'Required Sockets module',
85
      'S_THE_GD_EXTENSION_IS_NOT_LOADED' => 'The GD extension is not loaded.',
86
      'S_GD_PNG_SUPPORT' => 'GD PNG Support',
87
      'S_REQUIRES_IMAGES_GENERATION_SUPPORT' => 'Requires images generation support',
88
      'S_LIBXML_MODULE' => 'libxml module',
89
      'S_PHPXML_MODULE_IS_NOT_INSTALLED' => 'php-xml module is not installed',
90
      'S_CTYPE_MODULE' => 'ctype module',
91
      'S_REQUIRES_CTYPE_MODULE' => 'Requires ctype module',
92
      'S_PHP_UPLOAD_MAX_FILESIZE' => 'PHP upload max filesize',
93
      'S_IS_MINIMAL_FOR_PHP_ULOAD_FILESIZE_SMALL' => 'is minimum for PHP upload filesize',
94
      'S_SESSION_MODULE' => 'PHP Session',
95
      'S_REQUIRED_SESSION_MODULE' => 'Required Session module',
96
    );
97
    foreach ($trans as $const => $label) {
98
      if (!defined($const))
99
        define($const, $label);
100
    }
101
    unset($GLOBALS['trans']);
102
  }
103
104
  function getConfig($name, $default = null)
105
  {
1.1.81 by Usman Akeju
- fills in nav menu to match Darlene's design
106
//if entry method to this function is admin/config instead of install, set the global
1 by Usman Akeju
- initial commit; migrating to new branch internally
107
    return isset($this->AG_CONFIG[$name]) ? $this->AG_CONFIG[$name] : $default;
108
  }
109
110
  function setConfig($name, $value)
111
  {
112
    return ($this->AG_CONFIG[$name] = $value);
113
  }
114
115
  function getStep()
116
  {
117
    return $this->getConfig('step', 0);
118
  }
119
120
  function DoNext()
121
  {
122
    if (isset($this->steps[$this->getStep() + 1])) {
123
      $this->AG_CONFIG['step']++;
124
      return true;
125
    }
126
    return false;
127
  }
128
129
  function DoBack()
130
  {
131
    if (isset($this->steps[$this->getStep() - 1])) {
132
      $this->AG_CONFIG['step']--;
133
      return true;
134
    }
135
    return false;
136
  }
137
138
  function getList()
139
  {
140
    /**
141
     * this is a simple html constructor, takes our array and
142
     * generates a series of list items
143
     */
144
    $list = "<ul>";
145
    foreach ($this->steps as $id => $data) {
146
      if ($id < $this->getStep())
147
        $style = 'completed';
148
      else if ($id == $this->getStep())
149
        $style = 'current';
150
      else
151
        $style = null;
152
153
      $list = $list . '<li class="' . $style . '">' . $data['title'] . '</li>';
154
    }
155
    $list = $list . "</ul>";
156
    return $list;
157
  }
158
159
  function getState()
160
  {
161
    $fun = $this->steps[$this->getStep()]['fun'];
162
    return $this->$fun();
163
  }
164
165
  function stage0()
166
  {
1.1.107 by Darlene E McCullough
installer text proofed
167
    return '<div class=info><h2>Welcome to the Sahana Agasti 2.0 Installation Wizard</h2><br />
168
      <p>Agasti is an emergency management application with tools to manage staff, resources, 
169
      client information and facilities through an easy to use web interface. The Installation
170
      Wizard will guide you through the installation of Agasti 2.0.</p> <br />
1.1.1165 by charles wisniewski
facility json export format set, awaiting data from db. installer ui clean up and logic fixes
171
      Click the "Next" button to proceed to the Next screen. If you want to change something at 
1.1.107 by Darlene E McCullough
installer text proofed
172
      a previous step, click the "Previous" button.  You may cancel installation at any time by
173
      clicking the "Cancel" button.</p>
174
      <p><b> Click the "Next" button to continue.</p></b></div>';
1 by Usman Akeju
- initial commit; migrating to new branch internally
175
  }
176
177
  function stage1()
178
  {
1.1.236 by Usman Akeju
- removes some relative paths
179
    $LICENSE_FILE = sfConfig::get('sf_root_dir') . '/LICENSE';
1 by Usman Akeju
- initial commit; migrating to new branch internally
180
181
    $this->DISABLE_NEXT = !$this->getConfig('agree', false);
182
183
    $license = 'Missing licence file. See GPL licence.';
1.1.1196 by Usman Akeju
- installer no longer clobbers databases.yml if it already exists
184
    if (file_exists($LICENSE_FILE)) {
1.1.236 by Usman Akeju
- removes some relative paths
185
      $license = file_get_contents($LICENSE_FILE);
1.1.1196 by Usman Akeju
- installer no longer clobbers databases.yml if it already exists
186
    }
1 by Usman Akeju
- initial commit; migrating to new branch internally
187
188
    $agree = '<input class="checkbox" type="checkbox" value="yes" name="agree" id="agree" onclick="submit();"';
189
    $this->getConfig('agree', false) == 'yes' ? $agree .= ' checked=checked>' : $agree .= '>';
190
1.1.107 by Darlene E McCullough
installer text proofed
191
    return '<div class=info>' . nl2br($license) . "</div><br />" . $agree . '<label for="agree">I agree</label>';
1 by Usman Akeju
- initial commit; migrating to new branch internally
192
  }
193
194
  /**
195
   * step 2: pre-requisite check
196
   * @return block of html for UI of stage/step 2
197
   */
198
  function stage2()
199
  {
200
1.5.1 by charles wisniewski
removed backend, Agasti plugins are now considered `packages` and live in apps/frontend/lib/packages, symlinks still remain in web. new package manager, a little css cleanup on installer
201
    $table = '<table class="requirements" style="align:center; width:100%;">
202
                <th><tr style="font-weight:bold;">
203
                  <td>Option</td><td>Current Value</td><td>Required</td><td>Recommended</td><td>&nbsp;</td></tr></th>';
1 by Usman Akeju
- initial commit; migrating to new branch internally
204
    /**
205
     * @todo clean up the following code
206
     */
207
    $final_result = true;
208
209
    $reqs = check_php_requirements();
210
    foreach ($reqs as $req) {
211
212
      $result = null;
213
      if (!is_null($req['recommended']) && ($req['result'] == 1)) {
214
        $result = '<span class="orange">Ok</span>';
215
      } else if ((!is_null($req['recommended']) && ($req['result'] == 2))
216
          || (is_null($req['recommended']) && ($req['result'] == 1))) {
217
        $result = '<span class="green">Ok</span>';
218
      } else if ($req['result'] == 0) {
219
        $result = '<span class="fail">Fail</span>';
1.1.81 by Usman Akeju
- fills in nav menu to match Darlene's design
220
// this will be useful$result->setHint($req['error']);
1 by Usman Akeju
- initial commit; migrating to new branch internally
221
      }
222
1.5.1 by charles wisniewski
removed backend, Agasti plugins are now considered `packages` and live in apps/frontend/lib/packages, symlinks still remain in web. new package manager, a little css cleanup on installer
223
      $current = '<tr><td><strong>' . $req['name'] . '</strong></td>' . '<td>' . $req['current'] . '</td>';
1 by Usman Akeju
- initial commit; migrating to new branch internally
224
      $required = $req['required'] ? $req['required'] : '&nbsp;';
225
      $recommend = $req['recommended'] ? $req['recommended'] : '&nbsp;';
226
      $res = $req['result'] ? '&nbsp;' : 'fail';
227
      $row = '<td>' . $current . '</td><td>' . $required . '</td><td>' . $recommend . '</td><td>' . $result . '</td>';
228
229
      $table = $table . $row . '</tr>';
230
231
      $final_result &= (bool) $req['result'];
232
    }
233
234
    if (!$final_result) {
235
      $this->DISABLE_NEXT = true;
236
237
      $retry = '<input type="submit" class="inputGray" id="retry" name="retry" value="retry" />';
1.1.107 by Darlene E McCullough
installer text proofed
238
      $final_result = '<span class="fail">There are errors in your configuration.  
239
        Please correct all issues and press the "retry" button.  For additional assistance
240
        reference the README file.</span><br /><br />' . $retry;
1 by Usman Akeju
- initial commit; migrating to new branch internally
241
    } else {
242
      $this->DISABLE_NEXT = false;
1.1.107 by Darlene E McCullough
installer text proofed
243
      $final_result = '<span class="green">Your system is properly configured.  Please continue.</span>';
1 by Usman Akeju
- initial commit; migrating to new branch internally
244
    }
245
246
    return $table . '</table><br />' . $final_result;
247
  }
248
249
  function stage3()
250
  {
1.1.1196 by Usman Akeju
- installer no longer clobbers databases.yml if it already exists
251
    global $AG_CONFIG; //why? why not $this->AG_CONFIG? -UA
1.1.27 by charles wisniewski
install issue should be resolved, new config.inc.php file for config page
252
    $this->getCurrent();
1 by Usman Akeju
- initial commit; migrating to new branch internally
253
254
    if (isset($_REQUEST['retry']) && $this->RETRY_SUCCESS == false) {
255
      $retry_label = 'retry';
1.1.107 by Darlene E McCullough
installer text proofed
256
      $instruct = '<span class="fail">Error</span><br />
257
      <br />Error Message:' . $this->ERROR_MESSAGE . '<br /><span class="fail">Please correct the
258
        error and press retry.</span>';
1 by Usman Akeju
- initial commit; migrating to new branch internally
259
    } else if ($this->RETRY_SUCCESS == false) {
260
      $retry_label = 'test connection';
261
      $instruct = 'Press "Test connection" button when done.';
262
    } else {
1.1.1165 by charles wisniewski
facility json export format set, awaiting data from db. installer ui clean up and logic fixes
263
      $instruct = 'Database Settings are <span class="green">Ok</span> please click Next';
1 by Usman Akeju
- initial commit; migrating to new branch internally
264
    }
265
    $retry = '';
266
    if ($this->RETRY_SUCCESS == false) {
1.1.86 by Nils Stolpe
agPersonForm has been largely broken out into functions, and new functions have also been added to agStaffPerson form in the staff package.
267
      $retry = '<input type="submit" class="linkButton" id="retry" name="retry" value="' . $retry_label . '" />';
1 by Usman Akeju
- initial commit; migrating to new branch internally
268
    }
1.19.129 by Chad Heuschober
Updated installer and clean-project to allow switch-on / off of sample data.
269
    $loadSamples = '<input class="checkbox" type="checkbox" value="yes" name="load_samples" id="load_samples" ';
270
    $this->getConfig('LOAD_SAMPLES', false) == 'yes' ? $loadSamples .= ' checked=checked>' : $loadSamples .= '>';
271
1 by Usman Akeju
- initial commit; migrating to new branch internally
272
    $table = '<fieldset>
273
              <legend><img src="images/database.png" alt="database icon" />Database Configuration:</legend>
274
275
              <ul>
276
                <li>
277
                  <label>host:</label>
278
                  <input type="text" name="db_host" id="db_host" class="inputGray"
279
                         value="' . $this->getConfig('DB_SERVER', 'localhost') . '"/>
280
                </li>
281
                <li>
282
                  <label>database:</label>
283
                  <input type="text" name="db_name" id="db_name" class="inputGray"
284
                         value="' . $this->getConfig('DB_DATABASE', 'agasti') . '" />
285
                </li>
286
                <li>
287
                  <label>username:</label>
288
                  <input type="text" name="db_user" id="db_user" class="inputGray"
289
                         value="' . $this->getConfig('DB_USER', 'root') . '" />
290
                </li>
291
                <li>
292
                  <label>password:</label>
293
                  <input type="password" name="db_pass" id="db_pass" class="inputGray"
294
                         value="' . $this->getConfig('DB_PASSWORD', 'root') . '" />
295
                </li>
1.19.129 by Chad Heuschober
Updated installer and clean-project to allow switch-on / off of sample data.
296
                <li>
297
                  <label>load sample data?:</label>' . $loadSamples .
298
                '</li>
1 by Usman Akeju
- initial commit; migrating to new branch internally
299
                <input id="init_schema" type="hidden" name="init_schema" checked="checked" />
300
                <li><span class="fail">this will drop your current database.</span></li>
301
              </ul>
302
            </fieldset>
303
            <fieldset>
304
              <legend><img src="images/config.png" alt="config gear icon" />Administrator Information:</legend>
305
              <ul>
306
                <li>
1.1.1165 by charles wisniewski
facility json export format set, awaiting data from db. installer ui clean up and logic fixes
307
                  <label>Name:</label>
1 by Usman Akeju
- initial commit; migrating to new branch internally
308
                  <input type="text" name="admin_name" id="admin_name" class="inputGray"
309
                         value="' . $this->getConfig('ADMIN_NAME', 'administrator') . '" /><br />
310
                </li>
311
                <li>
1.1.1165 by charles wisniewski
facility json export format set, awaiting data from db. installer ui clean up and logic fixes
312
                  <label>Email:</label>
1 by Usman Akeju
- initial commit; migrating to new branch internally
313
                  <input type="text" name="admin_email" id="admin_email" class="inputGray"
314
                         value="' . $this->getConfig('ADMIN_EMAIL', 'b@m.an') . '" /><br />
315
                </li>
316
              </ul>
1.1.1165 by charles wisniewski
facility json export format set, awaiting data from db. installer ui clean up and logic fixes
317
              <legend><img src="images/config.png" alt="config gear icon" />Superuser Information:</legend>
318
              <ul>
319
                <li>
320
                  <label>Superuser:</label>
321
                  <input type="text" name="admin_user" id="admin_user" class="inputGray"
322
                         value="' . $this->getConfig('ADMIN_USER', 'superuser') . '" /><br />
323
                </li>
324
                <li>
325
                  <label>Password:</label>
326
                  <input type="text" name="admin_pass" id="admin_pass" class="inputGray"
327
                         value="' . $this->getConfig('ADMIN_PASS', 'sEcur3P45s!') . '" /><br />
328
                </li>
329
              </ul>              
1 by Usman Akeju
- initial commit; migrating to new branch internally
330
            </fieldset>';
1.1.107 by Darlene E McCullough
installer text proofed
331
    $results = 'The database is created manually.  First, the Agasti Installer will test your
332
      configuration settings before continuing.  Enter your database settings and click "Test Connection". <br /><br/>'
1 by Usman Akeju
- initial commit; migrating to new branch internally
333
        . $instruct . $table . $retry;
334
1.1.81 by Usman Akeju
- fills in nav menu to match Darlene's design
335
//$this->DISABLE_NEXT ? new CSpan(S_OK,'ok') :  new CSpan(S_FAIL, 'fail'),
336
//new  CButton('retry', 'Test connection')
1 by Usman Akeju
- initial commit; migrating to new branch internally
337
    return $results;
338
  }
339
340
  function stage4()
341
  {
1.1.27 by charles wisniewski
install issue should be resolved, new config.inc.php file for config page
342
    $current = $this->getCurrent();
1.19.129 by Chad Heuschober
Updated installer and clean-project to allow switch-on / off of sample data.
343
    $loadSamples = ($this->getConfig('LOAD_SAMPLES') == 'yes') ? 'Yes' : 'No';
1 by Usman Akeju
- initial commit; migrating to new branch internally
344
1.1.1165 by charles wisniewski
facility json export format set, awaiting data from db. installer ui clean up and logic fixes
345
    return 'Configuration files written. Below is your installation configuration summary:<br />
346
      <div class="info">
1 by Usman Akeju
- initial commit; migrating to new branch internally
347
        <strong>Database Host</strong>: ' . $this->getConfig('DB_SERVER') .
348
    '<br /><strong>Database Name</strong>: ' . $this->getConfig('DB_DATABASE') .
349
    '<br /><strong>Database User</strong>: ' . $this->getConfig('DB_USER') .
1.1.107 by Darlene E McCullough
installer text proofed
350
    '<br /><strong>Database Password</strong>: ' . preg_replace('/./', '*', $this->getConfig('DB_PASSWORD', 'unknown')) .
1.19.129 by Chad Heuschober
Updated installer and clean-project to allow switch-on / off of sample data.
351
    '<br /><strong>Load Sample Data:</strong>: ' . $loadSamples .
1.1.1165 by charles wisniewski
facility json export format set, awaiting data from db. installer ui clean up and logic fixes
352
    '<br /><strong>Administrator Name </strong>: ' . $this->getConfig('ADMIN_NAME') .
1.1.107 by Darlene E McCullough
installer text proofed
353
    '<br /><strong>Admin E-mail</strong>: ' . $this->getConfig('ADMIN_EMAIL') .
1.1.1165 by charles wisniewski
facility json export format set, awaiting data from db. installer ui clean up and logic fixes
354
    '<br /><strong>Super User</strong>: ' . $this->getConfig('ADMIN_USER') .
355
    '<br /><strong>Super User Password:</strong>: *******' .
356
    '</div>
357
      <br /> Please verify your settings.  By clicking Next you will install Sahana Agasti.';
1 by Usman Akeju
- initial commit; migrating to new branch internally
358
  }
359
360
  function stage5()
361
  {
362
    if ($this->INSTALL_RESULT == 'Success!') {
1.19.129 by Chad Heuschober
Updated installer and clean-project to allow switch-on / off of sample data.
363
      $loadSamples = ($this->getConfig('LOAD_SAMPLES') == 'yes') ? 'Yes' : 'No';
1.1.107 by Darlene E McCullough
installer text proofed
364
      return '<span class="okay">Congratulations!  Installation was successful:</span> <br /><div class="info">
1 by Usman Akeju
- initial commit; migrating to new branch internally
365
        <strong>Database Host</strong>: ' . $this->getConfig('DB_SERVER') .
366
      '<br /><strong>Database Name</strong>: ' . $this->getConfig('DB_DATABASE') .
367
      '<br /><strong>Database User</strong>: ' . $this->getConfig('DB_USER') .
1.1.107 by Darlene E McCullough
installer text proofed
368
      '<br /><strong>Database Password</strong>: ' . preg_replace('/./', '*', $this->getConfig('DB_PASSWORD', 'unknown')) .
1.19.129 by Chad Heuschober
Updated installer and clean-project to allow switch-on / off of sample data.
369
      '<br /><strong>Load Sample Data:</strong>: ' . $loadSamples .
1.1.107 by Darlene E McCullough
installer text proofed
370
      '<br /><strong>Administrator</strong>: ' . $this->getConfig('ADMIN_NAME') .
371
      '<br /><strong>Admin E-mail</strong>: ' . $this->getConfig('ADMIN_EMAIL') .
372
      '</div><br /> NOTE: to continue with Agasti setup you must first create the "Super User"
373
        account by editing the config file.  In .../config please edit the config.yml file with the
374
        Super User username and password.  After you have done so, click finish and you will be 
1.1.691 by charles wisniewski
fixed a requirement check in install(256 is minimum RAM). Modified agEventFacilityHelper to optionally not return facility resources which have an activation time set (for standby facility group management page)
375
        redirected to log in with the Super User username and password and then create your
1.1.107 by Darlene E McCullough
installer text proofed
376
        first user.';
1 by Usman Akeju
- initial commit; migrating to new branch internally
377
    } else {
378
      return '<span class="fail">There was an error with your installation:</span><br /><div class="info">' . $this->INSTALL_RESULT . '</div>';
379
    }
380
  }
381
382
  function stage6()
383
  {
384
    return "there is no step 6 in the installer, well, no screen for it at least: this should login the user and redirect to admin/createuser, i.e. you shouldn't even SEE this";
385
  }
386
1.1.27 by charles wisniewski
install issue should be resolved, new config.inc.php file for config page
387
  function getCurrent()
1 by Usman Akeju
- initial commit; migrating to new branch internally
388
  {
1.1.236 by Usman Akeju
- removes some relative paths
389
    $filename = sfConfig::get('sf_config_dir') . '/databases.yml';
390
    if (file_exists($filename)) {
391
      $dbArray = sfYaml::load($filename);
1 by Usman Akeju
- initial commit; migrating to new branch internally
392
    } else {
393
      $install_flag = false;
394
    }
1.1.236 by Usman Akeju
- removes some relative paths
395
    $filename = sfConfig::get('sf_config_dir') . '/config.yml';
396
    if (file_exists($filename)) {
397
      $cfgArray = sfYaml::load($filename);
1 by Usman Akeju
- initial commit; migrating to new branch internally
398
    } else {
399
      $install_flag = true;
400
      $existing_auth_method = "bypass";
401
    }
402
    try {
403
      $db_params = parseDSN($dbArray['all']['doctrine']['param']['dsn']);
404
      $this->setConfig('db_config', $dbArray);
405
      $this->setConfig('DB_SERVER', $db_params['host']);
406
      $this->setConfig('DB_DATABASE', $db_params['dbname']);
407
      $this->setConfig('DB_USER', $dbArray['all']['doctrine']['param']['username']);
408
      $this->setConfig('DB_PASSWORD', $dbArray['all']['doctrine']['param']['password']);
1.1.1165 by charles wisniewski
facility json export format set, awaiting data from db. installer ui clean up and logic fixes
409
410
      $this->setConfig('ADMIN_PASS', $cfgArray['sudo']['super_pass']);
411
      $this->setConfig('ADMIN_USER', $cfgArray['sudo']['super_user']);
1 by Usman Akeju
- initial commit; migrating to new branch internally
412
      $this->setConfig('ADMIN_NAME', $cfgArray['admin']['admin_name']);
413
      $this->setConfig('ADMIN_EMAIL', $cfgArray['admin']['admin_email']);
1.1.27 by charles wisniewski
install issue should be resolved, new config.inc.php file for config page
414
      $this->setConfig('AUTH_METHOD', $cfgArray['admin']['auth_method']['value']);
1 by Usman Akeju
- initial commit; migrating to new branch internally
415
    } catch (Exception $e) {
416
      return 'file was unreadable';
417
    }
418
    return array($dbArray, $cfgArray);
419
  }
420
1.1.1196 by Usman Akeju
- installer no longer clobbers databases.yml if it already exists
421
  function dbParams(array $db_params)
1 by Usman Akeju
- initial commit; migrating to new branch internally
422
  {
423
    $arguments = array(
424
      'task' => 'configure:database',
425
      //'dsn' => buildDsnString('mysql', $_POST['db_host'], $_POST['db_name'], $_POST['db_port']),
426
      'dsn' => $db_params['dsn'], // ilya 2010-07-21 15:16:58
1.1.81 by Usman Akeju
- fills in nav menu to match Darlene's design
427
//'dsn' => buildDsnString($_POST['db_type'], $_POST['db_host'], $_POST['db_name'], $_POST['db_port']),
1 by Usman Akeju
- initial commit; migrating to new branch internally
428
      'username' => $db_params['username'],
429
      'password' => $db_params['password'],
430
    );
431
    $options = array(
432
      'help' => null,
433
      'quiet' => null,
434
      'trace' => null,
435
      'version' => null,
436
      'color' => null,
437
      'env' => 'all',
438
      'name' => 'doctrine',
439
      'class' => 'sfDoctrineDatabase',
440
      'app' => null
441
    );
442
    $dispatcher = new sfEventDispatcher();
443
    $formatter = new sfFormatter();
444
    $dbConfig = new agDoctrineConfigureDatabaseTask($dispatcher, $formatter);
445
    $dbConfig->execute($arguments, $options);
446
    try {
447
      $configuration = ProjectConfiguration::getApplicationConfiguration('frontend', 'all', false);
448
    } catch (Exception $e) {
449
      $configuration = false;
450
    }
451
    return $configuration;
452
  }
453
1.1.1196 by Usman Akeju
- installer no longer clobbers databases.yml if it already exists
454
  function CheckConnection(array $db_config)
1 by Usman Akeju
- initial commit; migrating to new branch internally
455
  {
456
    if ($db_config['dsn'] != '') {
457
      try {
458
        $databaseManager = new sfDatabaseManager($this->dbParams($db_config));
459
        $connection = Doctrine_Manager::connection()->connect();
460
        $result = 'good';
461
      } catch (Exception $e) {
462
        $result = $e->getMessage();
463
      }
464
    } else {
465
      $result = 'Database configuration is not valid: bad DSN';
466
    }
467
    return $result;
468
  }
469
1.1.1196 by Usman Akeju
- installer no longer clobbers databases.yml if it already exists
470
  function doInstall(array $db_params)
1 by Usman Akeju
- initial commit; migrating to new branch internally
471
  {
472
    $databaseManager = new sfDatabaseManager($this->dbParams($db_params));
473
    $buildSql = new Doctrine_Task_GenerateSql();
474
    $dropDb = new Doctrine_Task_DropDb();
475
476
    $dropDb->setArguments(array('force' => true));
477
    $buildSql->setArguments(array(
478
      'models_path' => sfConfig::get('sf_lib_dir') . '/model/doctrine',
479
      'sql_path' => sfConfig::get('sf_data_dir') . '/sql',
480
    ));
481
    $createDb = new Doctrine_Task_CreateDb();
482
    try {
483
      if ($dropDb->validate()) {
484
        $dropDb->execute();
485
      } else {
486
        throw new Doctrine_Exception($dropDb->ask());
487
      }
488
    } catch (Exception $e) {
1.1.285 by charles wisniewski
cleaned up install a little bit, data models are only loaded once now, there is commented out code in an attempt to load fixtures that reside outside of data/config fixtures (i.e. lib/packages/packageName/data/fixtures
489
      $installed[] = 'Could not drop DB! : ' . "\n" . $e->getMessage();
1 by Usman Akeju
- initial commit; migrating to new branch internally
490
    }
491
    try {
492
      if ($createDb->validate()) {
493
        $createDb->execute();
494
      } else {
495
        throw new Doctrine_Exception($createDb->ask());
496
      }
1.1.285 by charles wisniewski
cleaned up install a little bit, data models are only loaded once now, there is commented out code in an attempt to load fixtures that reside outside of data/config fixtures (i.e. lib/packages/packageName/data/fixtures
497
      $installed[] = 'Successfully created database';
1 by Usman Akeju
- initial commit; migrating to new branch internally
498
    } catch (Exception $e) {
1.1.285 by charles wisniewski
cleaned up install a little bit, data models are only loaded once now, there is commented out code in an attempt to load fixtures that reside outside of data/config fixtures (i.e. lib/packages/packageName/data/fixtures
499
      $installed[] = 'Could not create DB! : ' . "\n" . $e->getMessage();
1 by Usman Akeju
- initial commit; migrating to new branch internally
500
    }
501
    try {
502
      if ($buildSql->validate()) {
503
        $buildSql->execute();
504
      }
1.1.285 by charles wisniewski
cleaned up install a little bit, data models are only loaded once now, there is commented out code in an attempt to load fixtures that reside outside of data/config fixtures (i.e. lib/packages/packageName/data/fixtures
505
      $installed[] = 'Successfully built SQL';
1 by Usman Akeju
- initial commit; migrating to new branch internally
506
    } catch (Exception $e) {
1.1.285 by charles wisniewski
cleaned up install a little bit, data models are only loaded once now, there is commented out code in an attempt to load fixtures that reside outside of data/config fixtures (i.e. lib/packages/packageName/data/fixtures
507
      $installed[] = 'Could not build SQL! : ' . "\n" . $e->getMessage();
1 by Usman Akeju
- initial commit; migrating to new branch internally
508
    }
509
510
    try {
1.1.285 by charles wisniewski
cleaned up install a little bit, data models are only loaded once now, there is commented out code in an attempt to load fixtures that reside outside of data/config fixtures (i.e. lib/packages/packageName/data/fixtures
511
      $allmodels = Doctrine_Core::loadModels(
1 by Usman Akeju
- initial commit; migrating to new branch internally
512
              sfConfig::get('sf_lib_dir') . '/model/doctrine',
513
              Doctrine_Core::MODEL_LOADING_CONSERVATIVE);
1.1.285 by charles wisniewski
cleaned up install a little bit, data models are only loaded once now, there is commented out code in an attempt to load fixtures that reside outside of data/config fixtures (i.e. lib/packages/packageName/data/fixtures
514
      $installed[] = 'Sucessefully loaded all data models';
1 by Usman Akeju
- initial commit; migrating to new branch internally
515
    } catch (Exception $e) {
1.1.285 by charles wisniewski
cleaned up install a little bit, data models are only loaded once now, there is commented out code in an attempt to load fixtures that reside outside of data/config fixtures (i.e. lib/packages/packageName/data/fixtures
516
      $installed[] = 'Could not load models! : ' . "\n" . $e->getMessage();
1 by Usman Akeju
- initial commit; migrating to new branch internally
517
    }
518
    try {
519
      Doctrine_Core::createTablesFromArray(Doctrine_Core::getLoadedModels());
1.1.285 by charles wisniewski
cleaned up install a little bit, data models are only loaded once now, there is commented out code in an attempt to load fixtures that reside outside of data/config fixtures (i.e. lib/packages/packageName/data/fixtures
520
      $installed[] = 'Successfully created database tables from models';
1 by Usman Akeju
- initial commit; migrating to new branch internally
521
    } catch (Exception $e) {
522
1.1.285 by charles wisniewski
cleaned up install a little bit, data models are only loaded once now, there is commented out code in an attempt to load fixtures that reside outside of data/config fixtures (i.e. lib/packages/packageName/data/fixtures
523
      $installed[] = 'Could not create tables! : ' . "\n" . $e->getMessage();
1 by Usman Akeju
- initial commit; migrating to new branch internally
524
    }
525
1.1.1184 by Usman Akeju
- fixes installer
526
    try {
1.1.1236 by Clayton Kramer
Facility import working again!
527
      //Doctrine_Core::loadData(sfConfig::get('sf_data_dir') . '/fixtures', false);
1.1.1184 by Usman Akeju
- fixes installer
528
      //$installed[] = 'Successfully loaded core data fixtures';
1.19.129 by Chad Heuschober
Updated installer and clean-project to allow switch-on / off of sample data.
529
      $dataDirectories = array(sfConfig::get('sf_data_dir') . '/fixtures');
530
      if ($this->getConfig('LOAD_SAMPLES') == 'yes') {
531
        $dataDirectories[] = sfConfig::get('sf_data_dir') . '/samples';
532
      }
1.1.1236 by Clayton Kramer
Facility import working again!
533
      Doctrine_Core::loadData($dataDirectories, false);
1.1.1184 by Usman Akeju
- fixes installer
534
      $installed = 'Success!';
535
    } catch (Exception $e) {
536
      $installed[] = 'Could not insert SQL! : ' . "\n" . $e->getMessage();
537
    }
1.1.285 by charles wisniewski
cleaned up install a little bit, data models are only loaded once now, there is commented out code in an attempt to load fixtures that reside outside of data/config fixtures (i.e. lib/packages/packageName/data/fixtures
538
//
539
//    $packages = agPluginManager::getPackagesByStatus(1); //get all enabled packages
540
//    foreach($packages as $package)
541
//    {
542
//      try {
543
////        if($package == 'agStaffPackage'){
544
////          Doctrine_Core::loadModels(sfConfig::get('sf_lib_dir') . '/model/doctrine', Doctrine_Core::MODEL_LOADING_AGGRESSIVE);
545
////        }
546
////        else{
547
//          Doctrine_Core::loadModels(sfConfig::get('sf_app_dir') . '/lib/packages/' . $package . '/lib/model/doctrine', Doctrine_Core::MODEL_LOADING_AGGRESSIVE);
548
////        }
549
//        Doctrine_Core::loadData(sfConfig::get('sf_app_dir') . '/lib/packages/' . $package  . '/data/fixtures', true);
550
//        $installed[] = 'Successfully loaded packaged data fixtures';
551
//      } catch (Exception $e) {
552
//        $installed[] = 'Could not insert SQL! : ' . "\n" . $e->getMessage();
553
//      }
554
//    }
1.1.350 by charles wisniewski
fixed install.inc.php (patched) to not insert agHost record as it exists as a fixture now. event shifts listing cleaned up
555
//    this entry is achieved by proxy of the agHost.yml fixture/example
556
//
557
//    try {
558
//      $ag_host = new agHost();
559
//      $ag_host->setHostname($this->getConfig('DB_SERVER'));
560
//      $ag_host->save();
561
//      //$installed[] = 'Successfully generated host record based on database server host';
562
//    } catch (Exception $e) {
563
//      $installed[] = 'Could not insert ag_host record ' . $e->getMessage();
564
//    }
1.1.1184 by Usman Akeju
- fixes installer
565
    try {
566
      $configuration = ProjectConfiguration::getApplicationConfiguration('frontend', 'all', false);
567
      $databaseManager = new sfDatabaseManager($configuration);
1.1.677 by charles wisniewski
indexing is now fully functional upon install
568
//        $connection = Doctrine_Manager::connection()->connect();
1.1.1184 by Usman Akeju
- fixes installer
569
      sfContext::createInstance($configuration)->dispatch();
1.1.677 by charles wisniewski
indexing is now fully functional upon install
570
1.22.7 by Shirley Chan
Making organization lucene searchable
571
      $luceneIndex = new agLuceneIndex(array('agStaff', 'agFacility', 'agScenario', 'agScenarioFacilityGroup', 'agOrganization'));
1.1.1184 by Usman Akeju
- fixes installer
572
      $luceneIndex->indexAll();
573
      $installed = 'Success!';
574
    } catch (Exception $e) {
575
      $installed[] = 'Could not index Data! : ' . "\n" . $e->getMessage();
576
    }
577
    if (is_array($installed)) {
1.1.285 by charles wisniewski
cleaned up install a little bit, data models are only loaded once now, there is commented out code in an attempt to load fixtures that reside outside of data/config fixtures (i.e. lib/packages/packageName/data/fixtures
578
      return implode('<br>', $installed);
1.1.1184 by Usman Akeju
- fixes installer
579
    } else {
1.1.285 by charles wisniewski
cleaned up install a little bit, data models are only loaded once now, there is commented out code in an attempt to load fixtures that reside outside of data/config fixtures (i.e. lib/packages/packageName/data/fixtures
580
      return $installed;
581
    }
1 by Usman Akeju
- initial commit; migrating to new branch internally
582
  }
583
584
  function EventHandler()
585
  {
586
    if (isset($_REQUEST['back'][$this->getStep()]))
587
      $this->DoBack();
1.1.664 by charles wisniewski
facility deletion is now possible if that facility is not in an event or scenario
588
//STEP ONE
1 by Usman Akeju
- initial commit; migrating to new branch internally
589
    if ($this->getStep() == 1) {
1.1.1165 by charles wisniewski
facility json export format set, awaiting data from db. installer ui clean up and logic fixes
590
      if (!isset($_REQUEST['Next'][0]) && !isset($_REQUEST['back'][2])) {
1 by Usman Akeju
- initial commit; migrating to new branch internally
591
        $this->setConfig('agree', isset($_REQUEST['agree']));
1.1.285 by charles wisniewski
cleaned up install a little bit, data models are only loaded once now, there is commented out code in an attempt to load fixtures that reside outside of data/config fixtures (i.e. lib/packages/packageName/data/fixtures
592
        //$this->doNext();
1 by Usman Akeju
- initial commit; migrating to new branch internally
593
      }
594
1.1.1165 by charles wisniewski
facility json export format set, awaiting data from db. installer ui clean up and logic fixes
595
      if (isset($_REQUEST['Next'][$this->getStep()]) && $this->getConfig('agree', false)) {
1 by Usman Akeju
- initial commit; migrating to new branch internally
596
        $this->DoNext();
597
      }
598
    }
599
1.1.664 by charles wisniewski
facility deletion is now possible if that facility is not in an event or scenario
600
//STEP TWO
1.1.1196 by Usman Akeju
- installer no longer clobbers databases.yml if it already exists
601
    if ($this->getStep() == 2
602
        && isset($_REQUEST['Next'][$this->getStep()])
603
        && !isset($_REQUEST['problem'])) {
604
      $filename = sfConfig::get('sf_config_dir') . '/databases.yml';
605
      if (file_exists($filename)) {
606
        $dbArray = sfYaml::load($filename);
607
      } else {
608
        $dbArray = array();
609
      }
610
      $this->dbParams($dbArray);
1 by Usman Akeju
- initial commit; migrating to new branch internally
611
      $this->DoNext();
612
    }
1.1.1165 by charles wisniewski
facility json export format set, awaiting data from db. installer ui clean up and logic fixes
613
//STEP THREE
1 by Usman Akeju
- initial commit; migrating to new branch internally
614
    if ($this->getStep() == 3) {
1.1.81 by Usman Akeju
- fills in nav menu to match Darlene's design
615
//on our first pass, these values won't exist (or if someone has returned with no POST
1.1.27 by charles wisniewski
install issue should be resolved, new config.inc.php file for config page
616
      $current = $this->getCurrent();
1.1.1184 by Usman Akeju
- fixes installer
617
      if ($_POST['db_host']) {
618
        $db_params = array(
619
          'dsn' => buildDsnString('mysql', $_POST['db_host'], $_POST['db_name']), // ilya 2010-07-21 15:16:58
620
          //'dsn' => buildDsnString($_POST['db_type'], $_POST['db_host'], $_POST['db_name'], $_POST['db_port']),
621
          'username' => $_POST['db_user'],
622
          'password' => $_POST['db_pass']);
623
        $this->setConfig('DB_SERVER', $_POST['db_host']);
624
        $this->setConfig('DB_DATABASE', $_POST['db_name']);
625
        $this->setConfig('DB_USER', $_POST['db_user']);
626
        $this->setConfig('DB_PASSWORD', $_POST['db_pass']);
627
        $this->setConfig('ADMIN_NAME', $_POST['admin_name']);
628
        $this->setConfig('ADMIN_EMAIL', $_POST['admin_email']);
1.19.129 by Chad Heuschober
Updated installer and clean-project to allow switch-on / off of sample data.
629
        $this->setConfig('LOAD_SAMPLES', (isset($_POST['load_samples']) ? 'yes' : FALSE));
1.1.1184 by Usman Akeju
- fixes installer
630
      } else {
1.1.1165 by charles wisniewski
facility json export format set, awaiting data from db. installer ui clean up and logic fixes
631
        $db_params = $current[0];
632
        $config_array = $current[1];
633
      }
1 by Usman Akeju
- initial commit; migrating to new branch internally
634
      $config_array = array(
635
        'is_installed' => array('value' => 'true'),
636
        'sudo' => array(
637
          'super_user' => $current[1]['sudo']['super_user'],
638
          'super_pass' => $current[1]['sudo']['super_pass']),
639
        'admin' => array(
640
          'admin_name' => $this->getConfig('ADMIN_NAME'),
641
          'admin_email' => $this->getConfig('ADMIN_EMAIL'),
642
          'auth_method' => array('value' => 'bypass'),
643
          'log_level' => array('value' => 'default'),
644
        //'db_type' => $_POST['db_type'],
1.1.1165 by charles wisniewski
facility json export format set, awaiting data from db. installer ui clean up and logic fixes
645
        //'db_host' => $_POST['db_host'],
646
        //'db_name' => $_POST['db_port'], //ilya 2010-07-21 15:17:13
1 by Usman Akeju
- initial commit; migrating to new branch internally
647
          ));
1.1.1165 by charles wisniewski
facility json export format set, awaiting data from db. installer ui clean up and logic fixes
648
1.1.38 by charles wisniewski
now install is REALLY fixed
649
      if (!($this->agSaveSetup($config_array))) {
1 by Usman Akeju
- initial commit; migrating to new branch internally
650
        $this->DISABLE_NEXT = true;
1.1.1165 by charles wisniewski
facility json export format set, awaiting data from db. installer ui clean up and logic fixes
651
        unset($_REQUEST['Next']);
1.1.81 by Usman Akeju
- fills in nav menu to match Darlene's design
652
//if we cannot save our configuration
1 by Usman Akeju
- initial commit; migrating to new branch internally
653
      } else {
1.1.27 by charles wisniewski
install issue should be resolved, new config.inc.php file for config page
654
        $dbcheck = $this->CheckConnection($db_params);
1 by Usman Akeju
- initial commit; migrating to new branch internally
655
        if ($dbcheck == 'good') {
656
          $this->RETRY_SUCCESS = true;
657
        } else {
1.1.81 by Usman Akeju
- fills in nav menu to match Darlene's design
658
//if we cannot establish a db connection
1 by Usman Akeju
- initial commit; migrating to new branch internally
659
          $this->RETRY_SUCCESS = false;
660
          $this->DISABLE_NEXT = true;
661
          $this->ERROR_MESSAGE = $dbcheck;
1.1.81 by Usman Akeju
- fills in nav menu to match Darlene's design
662
//set the installer's global error message to the return of our connection attempt
1.1.1165 by charles wisniewski
facility json export format set, awaiting data from db. installer ui clean up and logic fixes
663
          unset($_REQUEST['Next']);
1 by Usman Akeju
- initial commit; migrating to new branch internally
664
        }
665
      }
1.1.1165 by charles wisniewski
facility json export format set, awaiting data from db. installer ui clean up and logic fixes
666
      if (isset($_REQUEST['Next'][$this->getStep()])) {
1.1.81 by Usman Akeju
- fills in nav menu to match Darlene's design
667
//the validation comment below can be handled by:
668
//$this->getCurrent();
1 by Usman Akeju
- initial commit; migrating to new branch internally
669
        $this->setConfig('db_config', $db_params);
670
        $this->setConfig('DB_SERVER', $_POST['db_host']);
671
        $this->setConfig('DB_DATABASE', $_POST['db_name']);
672
        $this->setConfig('DB_USER', $_POST['db_user']);
673
        $this->setConfig('DB_PASSWORD', $_POST['db_pass']);
674
        $this->setConfig('ADMIN_NAME', $_POST['admin_name']);
675
        $this->setConfig('ADMIN_EMAIL', $_POST['admin_email']);
1.19.129 by Chad Heuschober
Updated installer and clean-project to allow switch-on / off of sample data.
676
        $this->setConfig('LOAD_SAMPLES', (isset($_POST['load_samples']) ? 'yes' : FALSE));
1 by Usman Akeju
- initial commit; migrating to new branch internally
677
        $this->DoNext();
1.1.81 by Usman Akeju
- fills in nav menu to match Darlene's design
678
//we should validate here in case someone changes correct information
1 by Usman Akeju
- initial commit; migrating to new branch internally
679
      }
680
    }
1.1.1165 by charles wisniewski
facility json export format set, awaiting data from db. installer ui clean up and logic fixes
681
//STEP FOUR
1 by Usman Akeju
- initial commit; migrating to new branch internally
682
    if ($this->getStep() == 4) {
1.1.81 by Usman Akeju
- fills in nav menu to match Darlene's design
683
//present user with configuration settings, show 'install button'
1.1.1165 by charles wisniewski
facility json export format set, awaiting data from db. installer ui clean up and logic fixes
684
      if (isset($_REQUEST['Next'][$this->getStep()])) {
1 by Usman Akeju
- initial commit; migrating to new branch internally
685
        $this->INSTALL_RESULT = $this->doInstall($this->getConfig('db_config'));
686
        $this->DoNext();
687
      }
688
    }
1.1.1165 by charles wisniewski
facility json export format set, awaiting data from db. installer ui clean up and logic fixes
689
//STEP FINISH
1.1.1184 by Usman Akeju
- fixes installer
690
    if (isset($_REQUEST['Finish'])) {       //isset($_REQUEST['Next'][$this->getStep()]
1.1.81 by Usman Akeju
- fills in nav menu to match Darlene's design
691
//$this->doNext();
1.1.27 by charles wisniewski
install issue should be resolved, new config.inc.php file for config page
692
      $sudo = $this->getCurrent();
1 by Usman Akeju
- initial commit; migrating to new branch internally
693
      $sudoer = $sudo[1]['sudo']['super_user']; //get username and password from config.yml, should be cleaner.
694
      $supw = $sudo[1]['sudo']['super_pass'];
1.1.81 by Usman Akeju
- fills in nav menu to match Darlene's design
695
//authenticate with this
1 by Usman Akeju
- initial commit; migrating to new branch internally
696
      try {
697
        $configuration = ProjectConfiguration::getApplicationConfiguration('frontend', 'all', false);
698
        $databaseManager = new sfDatabaseManager($configuration);
699
//        $connection = Doctrine_Manager::connection()->connect();
700
        sfContext::createInstance($configuration)->dispatch();
701
        agSudoAuth::authenticate($sudoer, $supw);
702
        redirect('admin/new');
703
      } catch (Exception $e) {
704
        $this->ERROR_MESSAGE = $e->getMessage();
705
      }
706
      return;
707
    }
708
1.1.1165 by charles wisniewski
facility json export format set, awaiting data from db. installer ui clean up and logic fixes
709
    if (isset($_REQUEST['Next'][$this->getStep()])) {
1 by Usman Akeju
- initial commit; migrating to new branch internally
710
      $this->DoNext();
711
    }
712
  }
1.1.81 by Usman Akeju
- fills in nav menu to match Darlene's design
713
714
  function agSaveSetup($config)
715
  {
716
    /** remember to set the superadmin config.yml up!!!  */
717
    sfClearCache('frontend', 'all');
718
    sfClearCache('frontend', 'dev');
719
    sfClearCache('frontend', 'prod');
1.1.236 by Usman Akeju
- removes some relative paths
720
    require_once sfConfig::get('sf_lib_dir') . '/vendor/symfony/lib/yaml/sfYaml.php';
1.1.630 by charles wisniewski
work to abstract the installer has begun, yml file is written in func.inc.php. Event Staff are also indexed now and searchable through the front end.
721
1.1.81 by Usman Akeju
- fills in nav menu to match Darlene's design
722
    $file = sfConfig::get('sf_config_dir') . '/config.yml';
1.1.630 by charles wisniewski
work to abstract the installer has begun, yml file is written in func.inc.php. Event Staff are also indexed now and searchable through the front end.
723
    touch($file);
724
// if config.yml does not exist
1.1.81 by Usman Akeju
- fills in nav menu to match Darlene's design
725
    try {
726
      file_put_contents($file, sfYaml::dump($config, 4));
727
    } catch (Exception $e) {
728
      echo "hey, something went wrong:" . $e->getMessage();
729
    }
730
1.1.236 by Usman Akeju
- removes some relative paths
731
    $file = sfConfig::get('sf_app_config_dir') . '/app.yml';
1.1.81 by Usman Akeju
- fills in nav menu to match Darlene's design
732
    touch($file);
1.1.630 by charles wisniewski
work to abstract the installer has begun, yml file is written in func.inc.php. Event Staff are also indexed now and searchable through the front end.
733
//if app.yml does not exist
734
    $appYmlResult = writeAppYml();
1.1.81 by Usman Akeju
- fills in nav menu to match Darlene's design
735
    $file = sfConfig::get('sf_config_dir') . '/databases.yml';
1.1.202 by charles wisniewski
added agReportMaker form class, bringing together the needed forms/datapoints for creating reports, little work on the frontend
736
//the below line will fail if the permissions are not correct, should be wrapped in a try/catch
1.1.81 by Usman Akeju
- fills in nav menu to match Darlene's design
737
    $dbConfiguration = sfYaml::load($file);
738
    $dbConfiguration['all']['doctrine']['param']['attributes'] = array(
739
      'default_table_type' => 'INNODB',
740
      'default_table_charset' => 'utf8',
741
      'default_table_collate' => 'utf8_general_ci'
742
    );
743
    try {
744
      file_put_contents($file, sfYaml::dump($dbConfiguration, 4));
745
    } catch (Exception $e) {
746
      echo "hey, something went wrong:" . $e->getMessage();
747
      return false;
748
    }
749
750
    return true;
1.1.83 by charles wisniewski
patches
751
    //once save setup is complete, create entry in ag_host (needed for global params
1.1.81 by Usman Akeju
- fills in nav menu to match Darlene's design
752
  }
753
754
}
1.1.37 by charles wisniewski
install issue fixed
755
756
/** these two extended classes are for configuring doctrine */
757
class agDoctrineConfigureDatabaseTask extends sfDoctrineConfigureDatabaseTask
758
{
759
760
  function execute($arguments = array(), $options = array())
761
  {
762
    parent::execute($arguments, $options);
763
  }
764
765
}
766
767
class agDoctrineBuildSqlTask extends sfDoctrineBuildSqlTask
768
{
769
770
  function execute($arguments = array(), $options = array())
771
  {
772
    try {
773
      parent::execute($arguments, $options);
774
    } catch (Exception $e) {
775
      throw new Doctrine_Exception($e->getMessage());
776
    }
777
  }
778
1.1.83 by charles wisniewski
patches
779
}