Пример #1
0
 public static function deleteUserById($id)
 {
     $user = SJB_UserManager::getObjectBySID($id);
     if (empty($user)) {
         SJB_UserDBManager::deleteEmptyUsers();
         return true;
     }
     SJB_Event::dispatch('onBeforeUserDelete', $user);
     $listings = SJB_ListingDBManager::getListingsSIDByUserSID($id);
     SJB_ListingManager::deleteListingBySID($listings);
     $subusers = self::getSubusers($id);
     foreach ($subusers as $subuser) {
         self::deleteUserById($subuser['sid']);
     }
     // delete user logo file
     $pictProp = $user->getProperty('Logo');
     if ($pictProp) {
         SJB_UploadFileManager::deleteUploadedFileByID($pictProp->value);
     }
     $videoProp = $user->getProperty('video');
     if ($videoProp) {
         SJB_UploadFileManager::deleteUploadedFileByID($videoProp->value);
     }
     // delete social info
     $socialReference = SJB_SocialPlugin::getProfileSocialID($user->getSID());
     if ($socialReference) {
         SJB_SocialPlugin::deleteProfileSocialInfoByReference($socialReference);
     }
     $result = SJB_UserDBManager::deleteUserById($id) && SJB_ContractManager::deleteAllContractsByUserSID($id) && SJB_Rating::deleteRatingByUserSID($id);
     SJB_Cache::getInstance()->clean('matchingAnyTag', array(SJB_Cache::TAG_USERS));
     return $result && SJB_SavedSearches::deleteUserSearchesFromDB($id);
 }