Account Suspended
Account Suspended
This Account has been suspended.
Contact your hosting provider for more information.
 All Data Structures Functions Variables Pages
DefaultController.php
1 <?php
2  /*********************************************************************************
3  * Zurmo is a customer relationship management program developed by
4  * Zurmo, Inc. Copyright (C) 2017 Zurmo Inc.
5  *
6  * Zurmo is free software; you can redistribute it and/or modify it under
7  * the terms of the GNU Affero General Public License version 3 as published by the
8  * Free Software Foundation with the addition of the following permission added
9  * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
10  * IN WHICH THE COPYRIGHT IS OWNED BY ZURMO, ZURMO DISCLAIMS THE WARRANTY
11  * OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
12  *
13  * Zurmo is distributed in the hope that it will be useful, but WITHOUT
14  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
15  * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
16  * details.
17  *
18  * You should have received a copy of the GNU Affero General Public License along with
19  * this program; if not, see http://www.gnu.org/licenses or write to the Free
20  * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
21  * 02110-1301 USA.
22  *
23  * You can contact Zurmo, Inc. with a mailing address at 27 North Wacker Drive
24  * Suite 370 Chicago, IL 60606. or at email address contact@zurmo.com.
25  *
26  * The interactive user interfaces in original and modified versions
27  * of this program must display Appropriate Legal Notices, as required under
28  * Section 5 of the GNU Affero General Public License version 3.
29  *
30  * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
31  * these Appropriate Legal Notices must retain the display of the Zurmo
32  * logo and Zurmo copyright notice. If the display of the logo is not reasonably
33  * feasible for technical reasons, the Appropriate Legal Notices must display the words
34  * "Copyright Zurmo Inc. 2017. All rights reserved".
35  ********************************************************************************/
36 
38  {
39  const FILTER_PATH = 'application.modules.install.controllers.filters.InstallControllerFilter';
40 
41  public function filters()
42  {
43  $filters = array();
44  $filters[] = array(
45  InstallDefaultController::FILTER_PATH,
46  );
47  return $filters;
48  }
49 
50  public function actionIndex()
51  {
52  $this->actionWelcome();
53  }
54 
55  public function actionWelcome()
56  {
57  $welcomeView = new InstallWelcomeView($this->getId(), $this->getModule()->getId());
58  $view = new InstallPageView($welcomeView);
59  echo $view->render();
60  }
61 
62  public function actionCheckSystem()
63  {
64  $serviceCheckResultsDataForDisplay = CheckServicesUtil::checkServicesAndGetResultsDataForDisplay();
65  $checkServicesView = new InstallCheckServicesView($this->getId(), $this->getModule()->getId(),
66  $serviceCheckResultsDataForDisplay);
67  $view = new InstallPageView($checkServicesView);
68  echo $view->render();
69  }
70 
71  public function actionSettings()
72  {
73  $form = new InstallSettingsForm();
74  $phpVersion = explode('.', phpversion());
75  if ($phpVersion[0] >= 7)
76  {
77  $memcachedServiceHelper = new MemcachedServiceHelper();
78  if (!$memcachedServiceHelper->runCheckAndGetIfSuccessful())
79  {
80  $form->setMemcacheIsNotAvailable();
81  }
82  }
83  else
84  {
85  $memcacheServiceHelper = new MemcacheServiceHelper();
86  if (!$memcacheServiceHelper->runCheckAndGetIfSuccessful())
87  {
88  $form->setMemcacheIsNotAvailable();
89  }
90  }
91 
92  $form->hostInfo = InstallUtil::getDefaultHostInfo();
93  $form->scriptUrl = InstallUtil::getDefaultScriptUrl($this->getRoute());
94 
95  if (isset($_POST['ajax']) && $_POST['ajax'] === 'install-form')
96  {
97  $this->actionValidateSettings($form);
98  }
99  else
100  {
101  if (isset($_POST['InstallSettingsForm']))
102  {
103  $form->setAttributes($_POST['InstallSettingsForm']);
104  //in case if additionalSystemCheck it will render its own screen
105  $this->additionalSystemCheck($form);
106  Yii::app()->end(0, false);
107  }
108  }
109  $settingsView = new InstallSettingsView($this->getId(), $this->getModule()->getId(), $form);
110  $view = new InstallPageView($settingsView);
111  echo $view->render();
112  }
113 
114  protected function additionalSystemCheck($form)
115  {
116  $serviceCheckResultsDataForDisplay = CheckServicesUtil::checkServicesAndGetResultsDataForDisplay(true, $form);
117 
118  if (count($serviceCheckResultsDataForDisplay[CheckServicesUtil::CHECK_FAILED][ServiceHelper::REQUIRED_SERVICE]) &&
119  !defined('IS_TEST'))
120  {
121  $checkServicesView = new InstallAdditionalCheckServicesView($this->getId(), $this->getModule()->getId(),
122  $serviceCheckResultsDataForDisplay);
123  $view = new InstallPageView($checkServicesView);
124  echo $view->render();
125  Yii::app()->end(0, false);
126  }
127  $this->actionRunInstallation($form);
128  Yii::app()->end(0, false);
129  }
130 
131  protected function actionValidateSettings($model)
132  {
133  $model->setAttributes($_POST[get_class($model)]);
134  $model->validate();
135  $errorData = array();
136  foreach ($model->getErrors() as $attribute => $errors)
137  {
138  $errorData[ZurmoHtml::activeId($model, $attribute)] = $errors;
139  }
140  echo CJSON::encode($errorData);
141  Yii::app()->end(0, false);
142  }
143 
144  protected function actionRunInstallation($form)
145  {
146  assert('$form instanceof InstallSettingsForm');
147  $nextView = new InstallCompleteView($this->getId(), $this->getModule()->getId());
148  $view = new InstallPageView($nextView);
149  echo $view->render();
150 
151  $template = ZurmoHtml::script("$('#logging-table').prepend('{message}<br/>');");
152  $messageStreamer = new MessageStreamer($template);
153  InstallUtil::runInstallation($form, $messageStreamer);
154  if ($form->installDemoData)
155  {
156  echo ZurmoHtml::script('$("#progress-table").hide(); $("#demo-data-table").show();');
157  }
158  else
159  {
160  $messageStreamer->add(Zurmo::t('InstallModule', 'Locking Installation.'));
161  InstallUtil::writeInstallComplete(INSTANCE_ROOT);
162  ForgetAllCacheUtil::forgetAllCaches();
163  echo ZurmoHtml::script('$("#progress-table").hide(); $("#complete-table").show();');
164  }
165  }
166 
170  public function actionInstallDemoData()
171  {
172  RedBeanDatabase::setup(Yii::app()->db->connectionString,
173  Yii::app()->db->username,
174  Yii::app()->db->password);
175  ForgetAllCacheUtil::forgetAllCaches();
176  Yii::app()->user->userModel = User::getByUsername('super');
177  $nextView = new InstallCompleteView($this->getId(), $this->getModule()->getId());
178  $view = new InstallPageView($nextView);
179  echo $view->render();
180  $template = ZurmoHtml::script("$('#logging-table').prepend('{message}<br/>');");
181  $messageStreamer = new MessageStreamer($template);
182  $messageStreamer->add(Zurmo::t('InstallModule', 'Starting to load demo data.'));
183  $messageLogger = new MessageLogger($messageStreamer);
184  DemoDataUtil::load($messageLogger, 6);
185  $messageStreamer->add(Zurmo::t('InstallModule', 'Finished loading demo data.'));
186  $messageStreamer->add(Zurmo::t('InstallModule', 'Locking Installation.'));
187  InstallUtil::writeInstallComplete(INSTANCE_ROOT);
188  ForgetAllCacheUtil::forgetAllCaches();
189  echo ZurmoHtml::script('$("#progress-table").hide(); $("#complete-table").show();');
190  }
191  }
192 ?>
static getByUsername($username)
Definition: User.php:49
static checkServicesAndGetResultsDataForDisplay($checkAdditionalServices=false, $form=null)
static setup($dsn, $username, $password)
static load(&$messageLogger, $loadMagnitude=null)
static writeInstallComplete($instanceRoot)
static runInstallation($form, &$messageStreamer)
Generated on Mon Jul 6 2020 07:10:30
Account Suspended
Account Suspended
This Account has been suspended.
Contact your hosting provider for more information.