Esempio n. 1
0
 /**
  * author Francis
  * @param int $pid
  * @param string $action
  * @param int $value
  * description: update 'confirmed' and 'deleted' fields of one property
  */
 private function update_property($pid, $action, $value)
 {
     /** property data **/
     $property_data = wpl_property::get_property_raw_data($pid);
     if ($action == 'confirm') {
         if (wpl_users::check_access('confirm', $property_data['user_id'])) {
             /** confirm property **/
             $res = wpl_property::confirm($pid, $value, true);
             $message = __("Operation was successful.", WPL_TEXTDOMAIN);
         } else {
             $res = 0;
             $message = __("You don't have access to this action.", WPL_TEXTDOMAIN);
         }
     } elseif ($action == 'trash') {
         if (wpl_users::check_access('delete', $property_data['user_id'])) {
             /** delete property **/
             $res = wpl_property::delete($pid, $value, true);
             $message = __("Operation was successful.", WPL_TEXTDOMAIN);
         } else {
             $res = 0;
             $message = __("You don't have access to this action.", WPL_TEXTDOMAIN);
         }
     }
     /** echo response **/
     $res = (int) $res;
     $data = NULL;
     echo json_encode(array('success' => $res, 'message' => $message, 'data' => $data));
     exit;
 }