コード例 #1
0
ファイル: property.php プロジェクト: amankatoch/wp-plugin
 /**
  * Finalize a property and render needed data
  * @author Howard <*****@*****.**>
  * @static
  * @param int $property_id
  * @param string $mode
  * @param int $user_id
  * @return boolean
  */
 public static function finalize($property_id, $mode = 'edit', $user_id = '')
 {
     $property = self::get_property_raw_data($property_id);
     $update_query = self::generate_finalize_query($property, $property_id);
     $update_query .= "`finalized`='1',";
     if (wpl_global::check_access('confirm', $user_id)) {
         $update_query .= "`confirmed`='1',";
     }
     $update_query = trim($update_query, ', ');
     $query = "UPDATE `#__wpl_properties` SET " . $update_query . " WHERE `id`='{$property_id}'";
     wpl_db::q($query, 'update');
     /** Remove Property Cache **/
     wpl_property::clear_property_cache($property_id);
     /** Multilingual **/
     if (wpl_global::check_multilingual_status()) {
         $languages = wpl_addon_pro::get_wpl_languages();
         $current_language = wpl_global::get_current_language();
         foreach ($languages as $language) {
             wpl_global::switch_language($language);
             wpl_property::update_text_search_field($property_id);
             wpl_property::update_alias($property);
             wpl_property::update_property_page_title($property);
             wpl_property::update_property_title($property);
             /** generate rendered data **/
             wpl_property::generate_rendered_data($property_id);
         }
         /** Switch to current language again **/
         wpl_global::switch_language($current_language);
     } else {
         wpl_property::update_text_search_field($property_id);
         wpl_property::update_alias($property);
         wpl_property::update_property_page_title($property);
         wpl_property::update_property_title($property);
         /** generate rendered data **/
         wpl_property::generate_rendered_data($property_id);
     }
     /** Fixes **/
     wpl_property::fix_aliases($property, $property_id);
     wpl_property::update_numbs($property_id, $property);
     /** throwing events **/
     if ($mode == 'add') {
         wpl_events::trigger('add_property', $property_id);
     } elseif ($mode == 'edit') {
         wpl_events::trigger('edit_property', $property_id);
     }
     if (wpl_global::check_access('confirm', $user_id)) {
         wpl_events::trigger('property_confirm', $property_id);
     }
     return true;
 }