| 1 |
<?php |
| 2 |
/** |
| 3 |
* |
| 4 |
*/ |
| 5 |
|
| 6 |
/** |
| 7 |
* |
| 8 |
*/ |
| 9 |
class CJTStore extends CJTServicesClientModule { |
| 10 |
|
| 11 |
/** |
| 12 |
* put your comment there... |
| 13 |
* |
| 14 |
* @var mixed |
| 15 |
*/ |
| 16 |
private $baseName; |
| 17 |
|
| 18 |
/** |
| 19 |
* put your comment there... |
| 20 |
* |
| 21 |
* @var mixed |
| 22 |
*/ |
| 23 |
private $itemName; |
| 24 |
|
| 25 |
/** |
| 26 |
* put your comment there... |
| 27 |
* |
| 28 |
* @var mixed |
| 29 |
*/ |
| 30 |
private $license; |
| 31 |
|
| 32 |
/** |
| 33 |
* put your comment there... |
| 34 |
* |
| 35 |
* @var mixed |
| 36 |
*/ |
| 37 |
private $pluginFile; |
| 38 |
|
| 39 |
/** |
| 40 |
* put your comment there... |
| 41 |
* |
| 42 |
* @var mixed |
| 43 |
*/ |
| 44 |
private $slug; |
| 45 |
|
| 46 |
/** |
| 47 |
* put your comment there... |
| 48 |
* |
| 49 |
* @param mixed $itemName |
| 50 |
* @param mixed $license |
| 51 |
* @param mixed $pluginFile |
| 52 |
* @return CJTStore |
| 53 |
*/ |
| 54 |
public function __construct($itemName, $license, $pluginFile) { |
| 55 |
# Initialize module base class |
| 56 |
parent::__construct(); |
| 57 |
# Initialize |
| 58 |
$this->pluginFile = $pluginFile; |
| 59 |
$this->baseName = plugin_basename( $pluginFile ); |
| 60 |
$this->slug = basename( $this->baseName, '.php' ); |
| 61 |
$this->license = $license; |
| 62 |
$this->itemName = $itemName; |
| 63 |
} |
| 64 |
|
| 65 |
/** |
| 66 |
* put your comment there... |
| 67 |
* |
| 68 |
* @param mixed $ownerName |
| 69 |
* @return mixed |
| 70 |
*/ |
| 71 |
public function activateLicense($ownerName) { |
| 72 |
return (int) $this->makeCall( __FUNCTION__, compact( 'ownerName' ) )->getResponseData(); |
| 73 |
} |
| 74 |
|
| 75 |
/** |
| 76 |
* put your comment there... |
| 77 |
* |
| 78 |
* @param mixed $ownerName |
| 79 |
* @return mixed |
| 80 |
*/ |
| 81 |
public function checkLicense($ownerName) { |
| 82 |
return (int) $this->makeCall( __FUNCTION__, compact( 'ownerName' ) )->getResponseData(); |
| 83 |
} |
| 84 |
|
| 85 |
/** |
| 86 |
* put your comment there... |
| 87 |
* |
| 88 |
* @param mixed $ownerName |
| 89 |
* @return mixed |
| 90 |
*/ |
| 91 |
public function deactivateLicense($ownerName) { |
| 92 |
return (int) $this->makeCall( __FUNCTION__, compact( 'ownerName' ) )->getResponseData(); |
| 93 |
} |
| 94 |
|
| 95 |
/** |
| 96 |
* put your comment there... |
| 97 |
* |
| 98 |
*/ |
| 99 |
public function getBaseName() { |
| 100 |
return $this->baseName; |
| 101 |
} |
| 102 |
|
| 103 |
/** |
| 104 |
* put your comment there... |
| 105 |
* |
| 106 |
*/ |
| 107 |
public function getItemName() { |
| 108 |
return $this->itemName; |
| 109 |
} |
| 110 |
|
| 111 |
/** |
| 112 |
* put your comment there... |
| 113 |
* |
| 114 |
*/ |
| 115 |
public function getPluginInformation() { |
| 116 |
# Check if there is update available for current extension |
| 117 |
$info = $this->jsonDecode( $this->makeCall( __FUNCTION__ )->getResponseData() ); |
| 118 |
# Return result |
| 119 |
return $info; |
| 120 |
} |
| 121 |
|
| 122 |
/** |
| 123 |
* put your comment there... |
| 124 |
* |
| 125 |
*/ |
| 126 |
public function getPluginUpdate() { |
| 127 |
# Check if there is update available for current extension |
| 128 |
$pluginUpdate = $this->jsonDecode( $this->makeCall( __FUNCTION__ )->getResponseData() ); |
| 129 |
# Return result |
| 130 |
return $pluginUpdate; |
| 131 |
} |
| 132 |
|
| 133 |
/** |
| 134 |
* put your comment there... |
| 135 |
* |
| 136 |
*/ |
| 137 |
public function getLicense() { |
| 138 |
return $this->license; |
| 139 |
} |
| 140 |
|
| 141 |
/** |
| 142 |
* put your comment there... |
| 143 |
* |
| 144 |
*/ |
| 145 |
public function getPluginFile() { |
| 146 |
return $this->pluginFile; |
| 147 |
} |
| 148 |
|
| 149 |
/** |
| 150 |
* put your comment there... |
| 151 |
* |
| 152 |
*/ |
| 153 |
public function getSlug() { |
| 154 |
return $this->slug; |
| 155 |
} |
| 156 |
|
| 157 |
/** |
| 158 |
* put your comment there... |
| 159 |
* |
| 160 |
*/ |
| 161 |
public function hasUpdate() { |
| 162 |
# Get Version |
| 163 |
$pluginUpdate = $this->getPluginUpdate(); |
| 164 |
$version = $pluginUpdate[ 'currentVersion' ]; |
| 165 |
# Get Plugin version |
| 166 |
$pluginData = get_plugin_data( $this->getPluginFile() ); |
| 167 |
# Return version details if there is new version/ otherwise return false |
| 168 |
$result = ( version_compare( $version, $pluginData[ 'Version' ] ) == 1 ) ? $pluginUpdate : false; |
| 169 |
return $result; |
| 170 |
} |
| 171 |
|
| 172 |
/** |
| 173 |
* put your comment there... |
| 174 |
* |
| 175 |
* @param mixed $method |
| 176 |
* @param mixed $params |
| 177 |
* @param mixed $postData |
| 178 |
* @return CJTServicesClientModule |
| 179 |
*/ |
| 180 |
public function makeCall($method, $params = null, $postData = null) { |
| 181 |
# Always include the following parameters |
| 182 |
$params = array_merge( array( |
| 183 |
'itemName' => $this->getItemName(), |
| 184 |
'license' => $this->getLicense() ), |
| 185 |
$params ? $params : array() |
| 186 |
); |
| 187 |
# Call method |
| 188 |
return parent::makeCall( $method, $params, $postData ); |
| 189 |
} |
| 190 |
|
| 191 |
} |