OXID eShop CE  4.8.10
 All Classes Files Functions Variables Pages
oxonlinemoduleversionnotifier.php
Go to the documentation of this file.
1 <?php
2 
13 {
14 
20  protected $_sProtocolversion = '1.0';
21 
22 
28  protected $_sWebServiceUrl = 'https://omvn.oxid-esales.com/check.php';
29 
35  protected $_sRawResponseMessage = '';
36 
42  protected $_aModules = array();
43 
49  protected $_blIsException = false;
50 
56  public function setModules($aModules)
57  {
58  $this->_aModules = $aModules;
59  }
60 
66  public function getModules()
67  {
68  return $this->_aModules;
69  }
70 
76  public function setRawResponseMessage($sRawResponseMessage)
77  {
78  $this->_sRawResponseMessage = $sRawResponseMessage;
79  }
80 
86  public function getRawResponseMessage()
87  {
89  }
90 
96  public function setWebServiceUrl($sWebServiceUrl)
97  {
98  $this->_sWebServiceUrl = $sWebServiceUrl;
99  }
100 
106  public function getWebServiceUrl()
107  {
108  return $this->_sWebServiceUrl;
109  }
110 
116  public function isException() {
117  return $this->_blIsException;
118  }
119 
125  protected function _setIsException($blIsException)
126  {
127  $this->_blIsException = $blIsException;
128  }
129 
135  protected function _prepareModulesInformation()
136  {
137  $aPreparedModules = array();
138 
139  $aModules = oxRegistry::getConfig()->getConfigParam('aModulePaths');
140  if( !is_array($aModules) ) {
141  return;
142  }
143 
144  foreach( $aModules as $sModule ) {
145  $oModule = oxNew('oxModule');
146  if (!$oModule->load($sModule)) {
147  continue;
148  }
149 
150  $oPreparedModule = new stdClass();
151  $oPreparedModule->id = $oModule->getId();
152  $oPreparedModule->version = $oModule->getInfo('version');
153 
154  $oPreparedModule->activeInShops = new stdClass();
155  $oPreparedModule->activeInShops->activeInShop = array( ($oModule->isActive() ? oxRegistry::getConfig()->getShopUrl() : null) );
156 
157  $aPreparedModules[] = $oPreparedModule;
158  }
159 
160  $this->setModules($aPreparedModules);
161  }
162 
172  protected function _doRequest($oRequestParams)
173  {
174  $sOutput = "";
175 
176  $oXml = oxNew('oxSimpleXml');
177  $sXml = $oXml->objectToXml($oRequestParams, 'omvnRequest');
178 
179  // send request to web service
180  try {
181  $oCurl = oxNew( 'oxCurl' );
182  $oCurl->setMethod( 'POST' );
183  $oCurl->setUrl( $this->getWebServiceUrl() );
184  $oCurl->setParameters( array("xmlRequest" => $sXml) );
185  $sOutput = $oCurl->execute();
186  } catch (Exception $oEx) {
187  throw new oxException('OMVN_ERROR_REQUEST_FAILED');
188  }
189  return $sOutput;
190  }
191 
197  protected function _sendRequestMessage()
198  {
200 
201  // build request parameters
202  $oRequestParams = new stdClass();
203 
204  $oRequestParams->modules = new stdClass();
205  $oRequestParams->modules->module = $this->getModules();
206 
207  $oRequestParams->edition = oxRegistry::getConfig()->getEdition();
208  $oRequestParams->version = oxRegistry::getConfig()->getVersion();
209  $oRequestParams->shopurl = oxRegistry::getConfig()->getShopUrl();
210  $oRequestParams->pversion = $this->_sProtocolversion;
211 
212 
213  if ( !$sOutput = $this->_doRequest($oRequestParams) ){
214  throw new oxException('OMVN_ERROR_REQUEST_FAILED');
215  }
216  $this->setRawResponseMessage($sOutput);
217  }
218 
224  public function versionNotify()
225  {
226  $this->_setIsException(false);
227 
228  try {
229  $this->_sendRequestMessage();
230  return true;
231 
232  } catch ( oxException $oEx ) {
233  $this->_setIsException(true);
234  return false;
235  }
236  }
237 }