Overview

Packages

  • application
    • commands
    • components
      • actions
      • filters
      • leftWidget
      • permissions
      • sortableWidget
      • util
      • webupdater
      • x2flow
        • actions
        • triggers
      • X2GridView
      • X2Settings
    • controllers
    • models
      • embedded
    • modules
      • accounts
        • controllers
        • models
      • actions
        • controllers
        • models
      • calendar
        • controllers
        • models
      • charts
        • models
      • contacts
        • controllers
        • models
      • docs
        • components
        • controllers
        • models
      • groups
        • controllers
        • models
      • marketing
        • components
        • controllers
        • models
      • media
        • controllers
        • models
      • mobile
        • components
      • opportunities
        • controllers
        • models
      • products
        • controllers
        • models
      • quotes
        • controllers
        • models
      • services
        • controllers
        • models
      • template
        • models
      • users
        • controllers
        • models
      • workflow
        • controllers
        • models
      • x2Leads
        • controllers
        • models
  • None
  • system
    • base
    • caching
    • console
    • db
      • ar
      • schema
    • validators
    • web
      • actions
      • auth
      • helpers
      • widgets
        • captcha
        • pagers
  • zii
    • widgets
      • grid

Classes

  • DatabaseBackupAction
  • UpdaterAction
  • UpdateStageAction
  • WebUpdaterAction
  • Overview
  • Package
  • Class
  • Tree
  1: <?php
  2: /*****************************************************************************************
  3:  * X2Engine Open Source Edition is a customer relationship management program developed by
  4:  * X2Engine, Inc. Copyright (C) 2011-2016 X2Engine Inc.
  5:  * 
  6:  * This program 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 X2ENGINE, X2ENGINE DISCLAIMS THE WARRANTY
 11:  * OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 12:  * 
 13:  * This program 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 X2Engine, Inc. P.O. Box 66752, Scotts Valley,
 24:  * California 95067, USA. or at email address contact@x2engine.com.
 25:  * 
 26:  * The interactive user interfaces in modified source and object code 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 "Powered by
 32:  * X2Engine" logo. If the display of the logo is not reasonably feasible for
 33:  * technical reasons, the Appropriate Legal Notices must display the words
 34:  * "Powered by X2Engine".
 35:  *****************************************************************************************/
 36: 
 37: Yii::import('application.components.webupdater.*');
 38: 
 39: /**
 40:  * Action for the updates/upgrades control page.
 41:  * @package application.components.webupdater
 42:  * @author Demitri Morgan <demitri@x2engine.com>
 43:  */
 44: class UpdaterAction extends WebUpdaterAction {
 45: 
 46:     /**
 47:      * Runs user-interface-related updater actions.
 48:      *
 49:      * @param string $scenario A keyword specifying what exactly is being done
 50:      * @param integer $redirect If true, and the scenario is "delete", redirect
 51:      *  to the previous page (referrer); if true, and the scenario is anything
 52:      *  but "delete", redirect to the package download URL. If false, it does
 53:      *  nothing unless the scenario is "delete".
 54:      */
 55:     public function run($scenario = 'update',$redirect=0){
 56:         // Get configuration variables:
 57:         $configVars = $this->configVars;
 58:         extract($configVars);
 59: 
 60:         if(!in_array($scenario,array('update','upgrade','delete')))
 61:             throw new CHttpException(400);
 62:         if($scenario == 'delete'){
 63:             // Delete the package that's on the server
 64:             $this->cleanUp();
 65:             if($redirect && !empty($_SERVER['HTTP_REFERER'])){
 66:                 $this->controller->redirect($_SERVER['HTTP_REFERER']);
 67:             }else{
 68:                 $this->respond('');
 69:             }
 70:         }
 71: 
 72:         $unique_id = $this->uniqueId;
 73:         $edition = $this->edition;
 74:         $this->scenario = $scenario;
 75:         $ready = $this->checkIf('packageExists',false);
 76:         $latestVersion = $version;
 77:         $viewParams = compact('scenario','unique_id','edition','version','ready','latestVersion');
 78: 
 79:         // Check for an existing package that has been extracted, in which case
 80:         // it isn't necessary to make any requests to the update server, but
 81:         // it is necessary to perform additional checks (which will be done
 82:         // via ajax in the updater view)
 83:         if($ready) {
 84:             $viewParams['latestVersion'] = $this->manifest['targetVersion'];
 85:             $this->controller->render('updater',$viewParams);
 86:             return;
 87:         }
 88: 
 89:         // Check to see if there's anything new available. FileUtil should be
 90:         // available by this point in time (since the old safeguard methods
 91:         // in AdminController would take care of that for much older
 92:         // versions) so it's safe to auto-download at this point.
 93:         $updaterCheck = $this->getLatestUpdaterVersion();
 94:         if($updaterCheck){
 95:             $refreshCriteria = version_compare($updaterVersion,$updaterCheck) < 0
 96:                     || $this->backCompatHooks($updaterCheck);
 97: 
 98:             if($refreshCriteria){
 99:                 $this->runUpdateUpdater($updaterCheck, array('updater', 'scenario' => $scenario));
100:             }
101: 
102:             $this->output(Yii::t('admin','The updater is up-to-date and safe to use.'));
103:         }else{
104:             // Is it the fault of the webserver?
105:             $this->controller->checkRemoteMethods();
106:             // Redirect to updater with the appropriate error message.
107:             $msg = Yii::t('admin', 'Could not connect to the updates server, or an error occurred on the updates server.');
108:             $this->output($msg,1);
109:             $this->controller->render('updater', array(
110:                 'scenario' => 'error',
111:                 'message' => Yii::t('admin', 'Could not connect to the updates server, or an error occurred on the updates server.'),
112:             ));
113:         }
114: 
115:         $latestVersion = $this->checkUpdates(true);
116:         $viewParams['latestVersion'] = $latestVersion;
117:         if(version_compare($version, $latestVersion) < 0){ // If the effective version is not the most recent version
118:             if($scenario == 'update'){
119:                 // Update.
120:                 $this->controller->render('updater',$viewParams);
121:             }else{ 
122:                 // Upgrade.
123:                 //
124:                 // Theoretically, legacy upgrade packages could be possible to
125:                 // use, but at this stage the updater utility itself has been
126:                 // updated, and so it won't be safe to use them because they
127:                 // might only be compatible with an earlier version of the
128:                 // updater.
129:                 $this->controller->render('updater', array(
130:                     'scenario' => 'error',
131:                     'message' => 'Update required',
132:                     'longMessage' => Yii::t('admin',"Before upgrading, you must update to the latest version ({latestver}).",array('{latestver}'=>$latestVersion)).' '.CHtml::link(Yii::t('app', 'Update'), array('/admin/updater','scenario'=>'update'), array('class' => 'x2-button'))
133:                 ));
134:             }
135:         }else{ // If at latest version already.
136:             if($scenario=='update'){
137:                 // Display a success message
138:                 Yii::app()->session['versionCheck'] = true;
139:                 $this->controller->render('updater', array(
140:                     'scenario' => 'message',
141:                     'version' => $version,
142:                     'message' => Yii::t('admin', 'X2Engine is at the latest version!'),
143:                     'longMessage' => $redirect ? Yii::t('admin','Download cancelled (no update package necessary)') : ''
144:                 ));
145:             }else{
146:                 // Upgrade.
147:                 //
148:                 // First, remove database backup; if it exists, the user most
149:                 // likely came here immediately after updating to the latest
150:                 // version, in which case the backup is outdated (applies to the
151:                 // old version and not the current state of the database).
152:                 $this->removeDatabaseBackup();
153:                 $this->controller->render('updater', $viewParams);
154:             }
155:         }
156:     }
157: 
158: }
159: 
160: ?>
161: 
X2CRM Documentation API documentation generated by ApiGen 2.8.0