예제 #1
0
 /**
  * Searches for purchased items in the WoltLab Plugin-Store.
  * 
  * @return	array<string>
  */
 public function searchForPurchasedItems()
 {
     if (!RemoteFile::supportsSSL()) {
         return array('noSSL' => WCF::getLanguage()->get('wcf.acp.pluginStore.api.noSSL'));
     }
     if (empty($this->parameters['username']) || empty($this->parameters['password'])) {
         return array('template' => $this->renderAuthorizationDialog(false));
     }
     $request = new HTTPRequest('https://api.woltlab.com/1.0/customer/purchases/list.json', array('method' => 'POST'), array('username' => $this->parameters['username'], 'password' => $this->parameters['password'], 'wcfVersion' => WCF_VERSION));
     $request->execute();
     $reply = $request->getReply();
     $response = JSON::decode($reply['body']);
     $code = isset($response['status']) ? $response['status'] : 500;
     switch ($code) {
         case 200:
             if (empty($response['products'])) {
                 return array('noResults' => WCF::getLanguage()->get('wcf.acp.pluginStore.purchasedItems.noResults'));
             } else {
                 WCF::getSession()->register('__pluginStoreProducts', $response['products']);
                 WCF::getSession()->register('__pluginStoreWcfMajorReleases', $response['wcfMajorReleases']);
                 return array('redirectURL' => LinkHandler::getInstance()->getLink('PluginStorePurchasedItems'));
             }
             break;
             // authentication error
         // authentication error
         case 401:
             return array('template' => $this->renderAuthorizationDialog(true));
             break;
             // any other kind of errors
         // any other kind of errors
         default:
             throw new SystemException(WCF::getLanguage()->getDynamicVariable('wcf.acp.pluginStore.api.error', array('status' => $code)));
             break;
     }
 }
예제 #2
0
 /**
  * Returns true if a request to this server would make use of a secure connection.
  * 
  * @return	boolean
  */
 public function attemptSecureConnection()
 {
     if ($this->apiVersion == '2.0') {
         return false;
     }
     $metaData = $this->getMetaData();
     if (RemoteFile::supportsSSL() && $metaData['ssl']) {
         return true;
     }
     return false;
 }