| 1 |
<?php |
| 2 |
/** |
| 3 |
* |
| 4 |
*/ |
| 5 |
|
| 6 |
// Disallow direct access. |
| 7 |
defined('ABSPATH') or die("Access denied"); |
| 8 |
|
| 9 |
/** |
| 10 |
* |
| 11 |
*/ |
| 12 |
class CJTAutoUpgradeController extends CJTController { |
| 13 |
|
| 14 |
/** |
| 15 |
* put your comment there... |
| 16 |
* |
| 17 |
* @var mixed |
| 18 |
*/ |
| 19 |
protected $controllerInfo = array('model' => 'setup'); |
| 20 |
|
| 21 |
/** |
| 22 |
* put your comment there... |
| 23 |
* |
| 24 |
*/ |
| 25 |
protected function enableAction() { |
| 26 |
// Initializing! |
| 27 |
$model = $this->model; |
| 28 |
$cjtWebServer = cssJSToolbox::getCJTWebSiteURL(); |
| 29 |
$extensions =& CJTPlugin::getInstance()->extensions(); |
| 30 |
// Get all CJT-Plugins (Include CJT Plugin itself + all its extensions) that has activate |
| 31 |
// license key! |
| 32 |
$activeLicenses = $model->getStatedLicenses(); |
| 33 |
// Activate Automatic upgrade for all activated licenses/components! |
| 34 |
foreach ($activeLicenses as $name => $state) { |
| 35 |
// Get extension def doc. |
| 36 |
// Act only if extension has XMl DOC! This might happened i fthe extension |
| 37 |
// removed while its key still in the database |
| 38 |
if ($extDef = $extensions->getDefDoc(dirname($state['component']['pluginBase']))) { |
| 39 |
// Check CJT Server only if updateSrc points to Wordpress Repository |
| 40 |
$updateSrcServer = (string) $extDef->license->attributes()->updateSrc; |
| 41 |
if (!$updateSrcServer || ($updateSrcServer == 'CJT')) { |
| 42 |
// Initializingn vars for a single state/component! |
| 43 |
$pluginFile = WP_PLUGIN_DIR . '/' . $state['component']['pluginBase']; |
| 44 |
$license =& $state['license']; |
| 45 |
// Set EDD Automatic Updater! |
| 46 |
try { |
| 47 |
CJTStoreUpdate::autoUpgrade( $name, $license[ 'key' ], $pluginFile ); |
| 48 |
} |
| 49 |
catch ( CJTServicesAPICallException $exception ) { |
| 50 |
die( 'CJT AUTO-UPGRADE EXCAPTION!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!' ); |
| 51 |
} |
| 52 |
} |
| 53 |
} |
| 54 |
} |
| 55 |
} |
| 56 |
} // End class. |
| 57 |
|