예제 #1
0
 public function createContract($userSID, $invoiceID, $reactivation, $status = 'active')
 {
     $listingNumber = !empty($this->product['qty']) ? $this->product['qty'] : null;
     if ($this->recurringID) {
         $contract = new SJB_Contract(array('product_sid' => $this->product['sid'], 'recurring_id' => $this->recurringID, 'gateway_id' => $this->gatewayID, 'invoice_id' => $invoiceID, 'numberOfListings' => $listingNumber));
         $contractSID = SJB_ContractManager::getContractSIDByRecurringId($this->recurringID);
         SJB_ContractManager::deleteAllContractsByRecurringId($this->recurringID);
     } else {
         $contract = new SJB_Contract(array('product_sid' => $this->product['sid'], 'gateway_id' => $this->gatewayID, 'invoice_id' => $invoiceID, 'numberOfListings' => $listingNumber));
         if ($invoiceID) {
             SJB_ContractManager::deletePendingContractByInvoiceID($invoiceID, $userSID, $this->product['sid']);
         }
     }
     $contract->setUserSID($userSID);
     $contract->setPrice($this->product['amount']);
     $contract->setStatus($status);
     if ($contract->saveInDB()) {
         SJB_ShoppingCart::deleteItemFromCartBySID($this->product['shoppingCartRecord'], $userSID);
         $bannerInfo = $this->product['banner_info'];
         if ($this->product['product_type'] == 'banners' && !empty($bannerInfo)) {
             $bannersObj = new SJB_Banners();
             if (isset($contractSID)) {
                 $bannerID = $bannersObj->getBannerIDByContract($contractSID);
                 if ($bannerID) {
                     $bannersObj->updateBannerContract($contract->getID(), $bannerID);
                 }
             } else {
                 $bannersObj->addBanner($bannerInfo['title'], $bannerInfo['link'], $bannerInfo['bannerFilePath'], $bannerInfo['sx'], $bannerInfo['sy'], $bannerInfo['type'], 0, $bannerInfo['banner_group_sid'], $bannerInfo, $userSID, $contract->getID());
                 $bannerGroup = $bannersObj->getBannerGroupBySID($bannerInfo['banner_group_sid']);
                 SJB_AdminNotifications::sendAdminBannerAddedLetter($userSID, $bannerGroup);
             }
         }
         if ($contract->isFeaturedProfile()) {
             SJB_UserManager::makeFeaturedBySID($userSID);
         }
         SJB_Statistics::addStatistics('payment', 'product', $this->product['sid'], false, 0, 0, $userSID, $this->product['amount']);
         if (SJB_UserNotificationsManager::isUserNotifiedOnSubscriptionActivation($userSID)) {
             SJB_Notifications::sendSubscriptionActivationLetter($userSID, $this->product, $reactivation);
         }
     }
 }
예제 #2
0
 private function extraProperties($user, $userInfo, &$usersID)
 {
     $savedProperties = array('user_group' => 1, 'pictures' => 1);
     foreach ($user->getProperties() as $property) {
         if (!in_array($property->id, array('file', 'Logo', 'video'))) {
             $savedProperties[$property->id] = 1;
         }
     }
     $queryFields = '';
     foreach (array_diff_key($userInfo, $savedProperties) as $key => $value) {
         if ($key == 'id') {
             $usersID[$value] = $user->getSID();
             continue;
         }
         if ($key == 'product') {
             $products = $value ? explode(',', $value) : array();
             $i = sizeof($products);
             while (--$i != -1) {
                 $productProperties = @unserialize($products[$i]);
                 if (!$productProperties) {
                     continue;
                 }
                 $productSid = SJB_ProductsManager::getProductSidByName($productProperties['name']);
                 if (!$productSid) {
                     continue;
                 }
                 $contract = new SJB_Contract(array('product_sid' => $productSid, 'numberOfListings' => $productProperties['number_of_listings']));
                 $contract->setPrice($productProperties['price']);
                 $contract->setCreationDate($productProperties['creation_date']);
                 $contract->setExpiredDate($productProperties['expired_date']);
                 $contract->setStatus($productProperties['status']);
                 $contract->setUserSID($user->getSID());
                 $contract->saveInDB();
                 SJB_ContractSQL::updatePostingsNumber($contract->id, $productProperties['number_of_postings']);
                 SJB_ProductsManager::incrementPostingsNumber($productSid, $productProperties['number_of_postings']);
             }
             continue;
         }
         if (in_array($key, array('file', 'Logo', 'video')) && !empty($value)) {
             $property = $user->getProperty($key);
             if (!$property) {
                 continue;
             }
             $fileProperties = @unserialize($value);
             if (!$fileProperties) {
                 continue;
             }
             $fieldInfo = SJB_UserProfileFieldManager::getFieldInfoBySID($property->sid);
             switch ($key) {
                 case 'file':
                     $value = 'Resume_' . $user->getSID();
                     $this->databaseFileRegister('file', $value, $fileProperties['name'] . '.' . $fileProperties['extension'], $fileProperties['mimeType']);
                     break;
                 case 'Logo':
                     $value = 'Logo_' . $user->getSID();
                     $this->databaseFileRegister('pictures', $value, $fileProperties['name'] . '.' . $fileProperties['extension'], $fileProperties['mimeType']);
                     $this->databaseFileRegister('pictures', 'Logo_' . $user->getSID() . '_thumb', $fileProperties['name'] . '_thumb.' . $fileProperties['extension'], $fileProperties['mimeType']);
                     break;
                 case 'video':
                     $value = 'video_' . $user->getSID();
                     $this->databaseFileRegister('video', 'video_' . $user->getSID(), $fileProperties['name'] . '.' . $fileProperties['extension'], $fileProperties['mimeType']);
                     break;
             }
         }
         if ($key == 'registration_date') {
             $isValid = SJB_UserRegistrationDateValidator::isValid($userInfo['registration_date']);
             if ($isValid !== true) {
                 if (!isset($errors['registrationDate'])) {
                     $errors['registrationDate'][] = $isValid;
                 }
                 if (isset($userInfo['username'])) {
                     $errors['registrationDate'][] = $userInfo['username'] . ', ';
                 }
                 continue;
             }
         }
         if (!empty($value)) {
             $queryFields .= $queryFields ? ", `" . SJB_DB::quote($key) . "` = '" . SJB_DB::quote($value) . "'" : "`" . SJB_DB::quote($key) . "` = '" . SJB_DB::quote($value) . "'";
         }
     }
     if (!empty($queryFields)) {
         SJB_DB::queryExec("UPDATE ?w SET " . $queryFields . " WHERE `sid` = ?n", 'users', $user->getSID());
     }
 }