Beispiel #1
0
 public static function saveProduct($product)
 {
     $productType = $product->getProductType();
     if (!is_null($productType)) {
         $generalDetails = SJB_ProductDetails::getDetails();
         $generalDetailsIDs = array('product_type');
         foreach ($generalDetails as $generalDetail) {
             $generalDetailsIDs[] = $generalDetail['id'];
         }
         $serializedDetails = array();
         $product->setFloatNumbersIntoValidFormat();
         $properties = $product->getProperties();
         foreach ($properties as $name => $property) {
             if (!in_array($name, $generalDetailsIDs)) {
                 $serializedDetails[$name] = $product->getPropertyValue($name);
                 $product->deleteProperty($name);
             }
         }
         $product->addProperty(array('id' => 'serialized_extra_info', 'type' => 'text', 'value' => serialize($serializedDetails), 'is_system' => true));
         $productSID = $product->getSID();
         SJB_ObjectDBManager::saveObject('products', $product);
         if (!$productSID) {
             $max_order = SJB_DB::queryValue("SELECT MAX(`order`) FROM `products` WHERE `user_group_sid`=?n", $product->getPropertyValue('user_group_sid'));
             $max_order = empty($max_order) ? 1 : $max_order;
             SJB_DB::query("UPDATE `products` SET `order` = ?n WHERE `sid` = ?n", ++$max_order, $product->getSID());
         }
     }
 }
 public static function save($info)
 {
     SJB_ObjectDBManager::saveObject('screening_questionnaires', $info);
     if ($info->sid) {
         return true;
     }
 }
Beispiel #3
0
 public static function saveCountry(SJB_Country $country)
 {
     $countrySID = $country->getSID();
     SJB_ObjectDBManager::saveObject('countries', $country);
     if (!$countrySID) {
         self::setLastOrder($country);
     }
 }
Beispiel #4
0
 /**
  * @param SJB_State $state
  */
 public static function saveState(SJB_State $state)
 {
     SJB_Cache::getInstance()->clean('matchingAnyTag', array(SJB_Cache::TAG_FIELDS));
     $stateSID = $state->getSID();
     SJB_ObjectDBManager::saveObject('states', $state);
     if (!$stateSID) {
         self::setLastOrder($state);
     }
 }
Beispiel #5
0
 public static function saveAlphabet($alphabet)
 {
     SJB_ObjectDBManager::saveObject('alphabet', $alphabet);
     if ($alphabet->sid) {
         return true;
     }
     $max_order = SJB_DB::queryValue("SELECT MAX(`order`) FROM alphabet");
     $max_order = empty($max_order) ? 0 : $max_order;
     return SJB_DB::query("UPDATE alphabet SET `order` = ?n WHERE sid = ?n", ++$max_order, $alphabet->getSID());
 }
 public static function saveQuestion($question)
 {
     $result = parent::saveObject('questions', $question);
     if ($question->getOrder()) {
         return true;
     }
     $questionnaire_sid = $question->getProperty('questionnaire_sid');
     $max_order = SJB_DB::queryValue("SELECT MAX(`order`) FROM questions WHERE questionnaire_sid  = ?n", $questionnaire_sid->value);
     $max_order = empty($max_order) ? 0 : $max_order;
     SJB_DB::query("UPDATE questions SET questionnaire_sid = ?n, `order` = ?n WHERE sid = ?n", $questionnaire_sid->value, ++$max_order, $question->getSID());
     return $result;
 }
 public static function saveUserProfileField($user_profile_field, $recursive = false)
 {
     $user_group_sid = $user_profile_field->getUserGroupSID();
     if ($user_group_sid) {
         $fieldID = false;
         $sid = $user_profile_field->getSID();
         if ($sid) {
             $fieldInfo = parent::getObjectInfo('user_profile_fields', $sid);
             if (!empty($fieldInfo['id'])) {
                 $fieldID = $fieldInfo['id'];
             }
         }
         parent::saveObject("user_profile_fields", $user_profile_field);
         $userFieldType = $user_profile_field->getPropertyValue('type');
         if ($userFieldType == 'location') {
             if (!$sid) {
                 $userProfileFeld = new SJB_UserProfileField(array('id' => 'Country', 'caption' => 'Country', 'type' => 'list'));
                 $userProfileFeld->setUserGroupSID($user_group_sid);
                 $userProfileFeld->addParentSID($user_profile_field->getSID());
                 self::saveUserProfileField($userProfileFeld, true);
                 $userProfileFeld = new SJB_UserProfileField(array('id' => 'State', 'caption' => 'State', 'type' => 'list'));
                 $userProfileFeld->setUserGroupSID($user_group_sid);
                 $userProfileFeld->addParentSID($user_profile_field->getSID());
                 self::saveUserProfileField($userProfileFeld, true);
                 $userProfileFeld = new SJB_UserProfileField(array('id' => 'City', 'caption' => 'City', 'type' => 'string'));
                 $userProfileFeld->setUserGroupSID($user_group_sid);
                 $userProfileFeld->addParentSID($user_profile_field->getSID());
                 self::saveUserProfileField($userProfileFeld, true);
                 $userProfileFeld = new SJB_UserProfileField(array('id' => 'ZipCode', 'caption' => 'ZipCode', 'type' => 'geo'));
                 $userProfileFeld->setUserGroupSID($user_group_sid);
                 $userProfileFeld->addParentSID($user_profile_field->getSID());
                 self::saveUserProfileField($userProfileFeld, true);
                 $userProfileFeld = new SJB_UserProfileField(array('id' => 'Address', 'caption' => 'Address', 'type' => 'string'));
                 $userProfileFeld->setUserGroupSID($user_group_sid);
                 $userProfileFeld->addParentSID($user_profile_field->getSID());
                 self::saveUserProfileField($userProfileFeld, true);
             }
             parent::saveLocationField("users", "user_profile_fields", $user_profile_field, $fieldID);
         } else {
             if (!$recursive) {
                 parent::saveField("users", "user_profile_fields", $user_profile_field, $fieldID);
             }
         }
         if ($user_profile_field->getOrder()) {
             return true;
         }
         $max_order = SJB_DB::queryValue("SELECT MAX(`order`) FROM user_profile_fields WHERE user_group_sid = ?n", $user_group_sid);
         $next_order = $max_order + 1;
         return SJB_DB::query("UPDATE user_profile_fields SET user_group_sid = ?n, `order` = ?n WHERE sid = ?n", $user_group_sid, $next_order, $user_profile_field->getSID());
     }
     return false;
 }
Beispiel #8
0
 /**
  * @param SJB_User $user
  * @return array|bool|int
  */
 public static function saveUser($user)
 {
     $user_group_sid = $user->getuserGroupSID();
     $user_exists = !is_null($user->getSID());
     if (!is_null($user_group_sid)) {
         $user_group_info = SJB_UserGroupManager::getUserGroupInfoBySID($user_group_sid);
         $userName = $user->details->getProperty('username')->getValue();
         if (isset($user_group_info['user_email_as_username']) && $user_group_info['user_email_as_username'] == true && strpos($userName, 'jobg8') === false) {
             $useremail = $user->details->getProperty('email')->getValue();
             if (!is_array($useremail) || !array_key_exists('original', $useremail)) {
                 $user->details->getProperty('username')->setValue($useremail);
             } else {
                 $user->details->getProperty('username')->setValue($useremail['original']);
             }
         }
         parent::saveObject("users", $user);
         if (!$user_exists) {
             SJB_DB::query("UPDATE ?w\n\t\t\t\t\t\t   SET `registration_date` = NOW(), `activation_key` = ?s, `verification_key` = ?s\n\t\t\t\t\t\t   WHERE `sid` = ?n", "users", $user->getActivationKey(), $user->getVerificationKey(), $user->getSID());
         }
         return SJB_DB::query("UPDATE ?w SET `user_group_sid` = ?n WHERE `sid` = ?n", "users", $user_group_sid, $user->getSID());
     }
     return false;
 }
Beispiel #9
0
 /**
  * @param  $listing SJB_Listing
  * @return array|bool
  */
 public static function saveListing($listing, $listingSidsForCopy = array())
 {
     $listing_type_sid = $listing->getListingTypeSID();
     if (!is_null($listing_type_sid)) {
         $keywords = SJB_ListingDBManager::getListingKeywordsArray($listing);
         // Строчку в низ не переносить, так как после сохранения объекта вытащить кейворды сложнее
         parent::saveObject('listings', $listing, false, $listingSidsForCopy);
         $user_info = SJB_UserManager::getUserInfoBySID($listing->getUserSID());
         $user_keywords = SJB_ListingDBManager::getUserKeywords($user_info);
         if ($user_keywords) {
             $keywords[] = $user_keywords;
         }
         SJB_Cache::getInstance()->clean('matchingAnyTag', array(SJB_Cache::TAG_LISTINGS));
         foreach ($keywords as $keyword) {
             SJB_ListingDBManager::saveListingKeyword($keyword, $listing->getSID(), $listing->isActive());
         }
         if (!SJB_ListingManager::hasListingProduct($listing->getSID())) {
             SJB_ListingManager::insertProduct($listing->getSID(), $listing->getProductInfo());
         }
         return SJB_DB::query('UPDATE `?w` SET `listing_type_sid` = ?n, `user_sid` = ?n, `keywords` = ?s, ' . '`activation_date` = ' . ($listing->getActivationDate() == null ? 'NOW()' : "'{$listing->getActivationDate()}'") . ' WHERE `sid` = ?n', 'listings', $listing_type_sid, $listing->getUserSID(), $listing->getKeywords(), $listing->getSID());
     }
     return false;
 }
Beispiel #10
0
 public function update()
 {
     return SJB_ObjectDBManager::saveObject($this->db_table_name, $this);
 }
Beispiel #11
0
 public static function savePage($info)
 {
     parent::saveObject('posting_pages', $info);
     if ($info->getOrder()) {
         return true;
     }
     $max_order = SJB_DB::queryValue('SELECT MAX(`order`) FROM posting_pages WHERE listing_type_sid = ?n', $info->getListingTypeSID());
     $max_order = empty($max_order) ? 0 : $max_order;
     return SJB_DB::query('UPDATE posting_pages SET listing_type_sid = ?n, `order` = ?n WHERE sid = ?n', $info->getListingTypeSID(), ++$max_order, $info->getSID());
 }
Beispiel #12
0
 public static function saveCurrency($currency)
 {
     parent::saveObject("currency", $currency);
 }
Beispiel #13
0
 public static function saveComment($comment)
 {
     parent::saveObject('comments', $comment);
     SJB_DB::query("UPDATE `comments` SET `listing_id` = " . $comment->listing_id . ", `added` = NOW() WHERE `sid` = ?n", $comment->getSID());
 }
Beispiel #14
0
 /**
  * Save subadmin to database
  * @param SJB_SubAdmin $user
  * @return boolean
  */
 public static function saveSubAdmin($user)
 {
     return parent::saveObject("subadmins", $user);
 }
Beispiel #15
0
 public static function saveObject($db_table_name, &$object)
 {
     return SJB_ObjectDBManager::saveObject($db_table_name, $object);
 }
Beispiel #16
0
 public static function recordPaymentLog($status, $gateway_caption, $gateway_response)
 {
     $obj = new SJB_PaymentLog(array('date' => SJB_I18N::getInstance()->getDate(date('Y-m-d H:i:s')), 'gateway' => $gateway_caption, 'message' => print_r($gateway_response, true), 'status' => $status));
     SJB_ObjectDBManager::saveObject("payment_log", $obj);
 }
Beispiel #17
0
 public static function saveEmailTemplate($emailTemplate)
 {
     return SJB_ObjectDBManager::saveObject('email_templates', $emailTemplate);
 }
Beispiel #18
0
 public static function saveUserGroup($user_group)
 {
     parent::saveObject("user_groups", $user_group);
 }
 public static function saveAdminDetails($admin)
 {
     parent::saveObject('administrator', $admin);
 }
 public static function saveListingType($listing_type)
 {
     return parent::saveObject('listing_types', $listing_type);
 }
 public static function saveListingComplexField($listing_field)
 {
     $parentSID = $listing_field->getProperty('field_sid')->value;
     parent::saveObject('listing_complex_fields', $listing_field, time());
     if ($listing_field->getOrder()) {
         return true;
     }
     $max_order = SJB_DB::queryValue('SELECT MAX(`order`) FROM listing_complex_fields WHERE field_sid = ?n', $parentSID);
     $max_order = empty($max_order) ? 0 : $max_order;
     return SJB_DB::query('UPDATE listing_complex_fields SET `order` = ?n WHERE sid = ?n', ++$max_order, $listing_field->getSID());
 }
Beispiel #22
0
 public static function saveNewsArticle($articleObject)
 {
     parent::saveObject('news', $articleObject);
 }
Beispiel #23
0
 /**
  * @param $feed
  */
 public function saveFeed($feed)
 {
     SJB_ObjectDBManager::saveObject($this->db_table_name, $feed);
 }
Beispiel #24
0
 public static function savePoll($poll)
 {
     return SJB_ObjectDBManager::saveObject('polls', $poll);
 }