Example #1
0
 function saveInDB()
 {
     $result = SJB_ContractSQL::insert($this->_getHashedFields());
     if ($result) {
         if (!$this->id) {
             $this->id = $result;
         }
         SJB_ContractSQL::updateContractExtraInfoByProductSID($this);
         if ($this->status == 'active') {
             SJB_Acl::copyPermissions($this->product_sid, $this->id, $this->number_of_listings);
         } else {
             SJB_Acl::clearPermissions('contract', $this->id);
         }
         $userInfo = SJB_UserManager::getUserInfoBySID($this->user_sid);
         $user = new SJB_User($userInfo, $userInfo['user_group_sid']);
         $user->updateSubscribeOnceUsersProperties($this->product_sid, $this->user_sid);
     }
     return (bool) $result;
 }
Example #2
0
 public static function activateContract($contract_id, $user_sid = false)
 {
     $contractInfo = self::getInfo($contract_id);
     $number_of_listings = isset($contractInfo['number_of_postings']) ? $contractInfo['number_of_postings'] : 0;
     $product_sid = isset($contractInfo['product_sid']) ? $contractInfo['product_sid'] : 0;
     SJB_Acl::copyPermissions($product_sid, $contract_id, $number_of_listings);
     SJB_DB::query("UPDATE `contracts` SET `status` = 'active' WHERE `id` = ?n", $contract_id);
 }