Beispiel #1
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 #2
0
 /**
  * @param SJB_User $user
  * @return boolean
  */
 public static function notifyOnUserDeleted(SJB_User $user)
 {
     if (SJB_UserNotificationsManager::isUserNotifiedOnProfileDeletion($user->getSID())) {
         $userGroupSID = $user->getUserGroupSID();
         $emailTplSID = SJB_UserGroupManager::getEmailTemplateSIDByUserGroupAndField($userGroupSID, 'notify_user_on_deletion');
         $user = SJB_UserManager::createTemplateStructureForUser($user);
         $data = array('user' => $user);
         $email = SJB_EmailTemplateEditor::getEmail($user['email'], $emailTplSID, $data);
         return $email->send('User Deleted');
     }
     return false;
 }
 /**
  * @return array
  */
 public function getUserNotificationsInfo()
 {
     $result = SJB_DB::query('SELECT * FROM `users_notifications` WHERE `user_sid` = ?n', $this->user->getSID());
     $result = array_pop($result);
     return !empty($result) ? $result : array();
 }
Beispiel #4
0
 /**
  * @param array $productInfoToCheck
  * @param SJB_User $currentUser
  * @return bool
  */
 public static function isProductTrialAndAlreadyInCart($productInfoToCheck, SJB_User $currentUser = null)
 {
     if (SJB_Array::get($productInfoToCheck, 'trial') < 1) {
         return false;
     }
     if ($currentUser instanceof SJB_User) {
         $checkedProducts = SJB_ShoppingCart::getProductsInfoAlreadyCheckedByUserSID($currentUser->getSID());
     } else {
         $checkedProducts = SJB_ShoppingCart::getProductsInfoAlreadyCheckedForGuest();
     }
     foreach ($checkedProducts as $checkedProductInfo) {
         if (SJB_Array::get($productInfoToCheck, 'sid') === SJB_Array::get($checkedProductInfo, 'sid')) {
             return true;
         }
     }
     return false;
 }
Beispiel #5
0
 private function executeApplicationsForEmployer($appsPerPage, $appJobId, SJB_User $currentUser, $score, $orderInfo, $listingTitle)
 {
     $limit['countRows'] = $appsPerPage;
     $limit['startRow'] = $this->currentPage * $appsPerPage - $appsPerPage;
     $subuser = false;
     if ($appJobId) {
         $isUserOwnerApps = SJB_Applications::isUserOwnsAppsByAppJobId($currentUser->getID(), $appJobId);
         if (!$isUserOwnerApps) {
             SJB_FlashMessages::getInstance()->addWarning('NOT_OWNER_OF_APPLICATIONS', array('listingTitle' => $listingTitle));
         }
         $allAppsCountByJobID = SJB_Applications::getCountAppsByJob($appJobId, $score);
         $this->setPaginationInfo($appsPerPage, $allAppsCountByJobID);
         $apps = SJB_Applications::getByJob($appJobId, $orderInfo, $score, $limit);
     } else {
         if ($currentUser->isSubuser()) {
             $subuserInfo = $currentUser->getSubuserInfo();
             if (!SJB_Acl::getInstance()->isAllowed('subuser_manage_listings', $subuserInfo['sid'])) {
                 $subuser = $subuserInfo['sid'];
             }
         }
         $allAppsCount = SJB_Applications::getCountApplicationsByEmployer($currentUser->getSID(), $score, $subuser);
         $this->setPaginationInfo($appsPerPage, $allAppsCount);
         $apps = SJB_Applications::getByEmployer($currentUser->getSID(), $orderInfo, $score, $subuser, $limit);
     }
     return $apps;
 }