Ejemplo n.º 1
0
 /**
  * author Francis
  * @param int $pid
  * desctiption: purge one property with the condition of property id
  */
 private function purge_property($pid)
 {
     /** property data **/
     $property_data = wpl_property::get_property_raw_data($pid);
     /** purge property **/
     if (wpl_users::check_access('delete', $property_data['user_id'])) {
         $res = (int) wpl_property::purge($pid, true);
         $message = __("Property purged.", WPL_TEXTDOMAIN);
     } else {
         $res = 0;
         $message = __("You don't have access to this action.", WPL_TEXTDOMAIN);
     }
     /** echo response **/
     echo json_encode(array('success' => $res, 'message' => $message, 'data' => NULL));
     exit;
 }
 private function purge_related_property()
 {
     $listing_type_id = wpl_request::getVar('listing_type_id');
     $properties_list = wpl_property::get_properties_list('listing', $listing_type_id);
     foreach ($properties_list as $property) {
         wpl_property::purge($property['id']);
     }
     $this->remove_listing_type($listing_type_id, 1);
 }
Ejemplo n.º 3
0
 /**
  * Removes WPL cached data
  * @author Howard <*****@*****.**>
  * @static
  * @param type $cache_type
  * @return boolean
  */
 public static function clear_cache($cache_type = 'all')
 {
     /** first validation **/
     $cache_type = strtolower($cache_type);
     if (trim($cache_type) == '') {
         return false;
     }
     /** import libraries **/
     _wpl_import('libraries.property');
     _wpl_import('libraries.items');
     if ($cache_type == 'unfinalized_properties' or $cache_type == 'all') {
         $properties = wpl_db::select("SELECT `id` FROM `#__wpl_properties` WHERE `finalized`='0'", 'loadAssocList');
         foreach ($properties as $property) {
             wpl_property::purge($property['id']);
         }
     }
     if ($cache_type == 'properties_cached_data' or $cache_type == 'all') {
         $q = " `location_text`='', `rendered`='', `alias`=''";
         if (wpl_global::check_multilingual_status()) {
             $q = self::get_multilingual_query(array('alias', 'location_text', 'rendered'));
         }
         $query = "UPDATE `#__wpl_properties` SET " . $q;
         wpl_db::q($query);
     }
     if ($cache_type == 'location_texts' or $cache_type == 'all') {
         $q = " `location_text`=''";
         if (wpl_global::check_multilingual_status()) {
             $q = self::get_multilingual_query(array('location_text'));
         }
         $query = "UPDATE `#__wpl_properties` SET " . $q;
         wpl_db::q($query);
     }
     if ($cache_type == 'listings_thumbnails' or $cache_type == 'all') {
         $properties = wpl_db::select("SELECT `id`, `kind` FROM `#__wpl_properties` WHERE `id`>0", 'loadAssocList');
         $ext_array = array('jpg', 'jpeg', 'gif', 'png');
         foreach ($properties as $property) {
             $path = wpl_items::get_path($property['id'], $property['kind']);
             $thumbnails = wpl_folder::files($path, 'th.*\\.(' . implode('|', $ext_array) . ')$', 3, true);
             foreach ($thumbnails as $thumbnail) {
                 wpl_file::delete($thumbnail);
             }
         }
     }
     if ($cache_type == 'users_cached_data' or $cache_type == 'all') {
         $q = " `location_text`='', `rendered`=''";
         if (wpl_global::check_multilingual_status()) {
             $q = self::get_multilingual_query(array('location_text', 'rendered'), 'wpl_users');
         }
         $query = "UPDATE `#__wpl_users` SET " . $q;
         wpl_db::q($query);
     }
     if ($cache_type == 'users_thumbnails' or $cache_type == 'all') {
         $users = wpl_db::select("SELECT `id` FROM `#__wpl_users` WHERE `id`>0", 'loadAssocList');
         $ext_array = array('jpg', 'jpeg', 'gif', 'png');
         foreach ($users as $user) {
             $path = wpl_items::get_path($user['id'], 2);
             $thumbnails = wpl_folder::files($path, 'th.*\\.(' . implode('|', $ext_array) . ')$', 3, true);
             foreach ($thumbnails as $thumbnail) {
                 wpl_file::delete($thumbnail);
             }
         }
     }
     /** trigger event **/
     wpl_global::event_handler('cache_cleared', array('cache_type' => $cache_type));
     return true;
 }
 private function purge_related_property()
 {
     $property_type_id = wpl_request::getVar('property_type_id');
     $properties_list = wpl_property::get_properties_list('property_type', $property_type_id);
     foreach ($properties_list as $property) {
         wpl_property::purge($property['id']);
     }
     self::remove_property_type($property_type_id, 1);
 }