static function get_instance() { if (self::$instance == null) { self::$instance = new Fre_Mailing(); } return self::$instance; }
public function __construct() { $this->mail = Fre_Mailing::get_instance(); //$this->add_action('preprocess_comment', 'process_review'); // $this->add_action( 'comment_post' , 'update_rating'); $this->init_ajax(); /* * display review form for freelancer when project completed. */ $this->add_action('wp_footer', 'fre_freelancer_review_form', 99); }
public function __construct($post_type = BID) { // init mail instance to send mail $this->mail = Fre_Mailing::get_instance(); $this->post_type = $post_type; /* add more data when convert a bid */ $this->add_filter('ae_convert_bid', 'ae_convert_bid'); // sync to update bid $this->add_ajax('ae-sync-bid', 'bid_sync'); $this->add_ajax('ae-bid-sync', 'bid_sync'); /* accept a bid */ $this->add_ajax('ae-accept-bid', 'bid_accept'); $this->add_ajax('ae-skip-bid', 'bid_skip'); // request list bid $this->add_ajax('ae-fetch-bid', 'fetch_post'); /* * check permission before insert bid. */ $this->add_filter('ae_pre_insert_bid', 'fre_check_before_insert_bid', 12, 1); /* * update project and bid after bid success. */ $this->add_action('ae_insert_bid', 'fre_update_after_bidding', 12, 1); /* * aftion after delete a bid * use this action insteated the action trashed_post */ $this->add_action('et_delete_bid', 'fre_delete_bid', 12, 1); //$this->add_action('trashed_post','fre_delete_bid'); /* * Filter for post title in back-end */ $this->add_filter('the_title', 'the_title_bid', 10, 2); /* * Add column project tile in wrodpress */ $this->add_filter('manage_bid_posts_columns', 'manage_bid_column_project', 1); $this->add_action('manage_bid_posts_custom_column', 'project_title_column_render', 2, 10); self::$instance = $this; }
/** * finish project, send money when freelancer review project * @param int $project_id * @since 1.3 * @author Dakachi */ function fre_finish_escrow($project_id) { if (ae_get_option('use_escrow')) { $bid_id_accepted = get_post_meta($project_id, 'accepted', true); if (!ae_get_option('manual_transfer')) { // cho nay co the dung action // execute payment and send money to freelancer $pay_key = get_post_meta($bid_id_accepted, 'fre_paykey', true); if ($pay_key) { $ppadaptive = AE_PPAdaptive::get_instance(); $response = $ppadaptive->executePayment($pay_key); if (strtoupper($response->responseEnvelope->ack) == 'SUCCESS') { // success update order data $order = get_post_meta($bid_id_accepted, 'fre_bid_order', true); if ($order) { wp_update_post(array('ID' => $order, 'post_status' => 'finish')); $mail = Fre_Mailing::get_instance(); $mail->alert_transfer_money($project_id, $bid_id_accepted); } } } } else { $mail = Fre_Mailing::get_instance(); $mail->alert_transfer_money($project_id, $bid_id_accepted); } } }
function ae_open_dispute() { $this->mail = Fre_Mailing::get_instance(); $post = get_post($_POST['project_id']); $project_info_output = array(); $project_info_output['current_user_id'] = $_POST['user_id']; $project_info_output['current_display_name'] = $_POST['current_display_name']; $project_info_output['ID'] = $post->ID; $project_info_output['e_mail'] = $_POST['e_mail']; $project_info_output['subject'] = $_POST['subject']; $project_info_output['amount'] = $_POST['amount']; $project_info_output['message'] = $_POST['message']; $project_info_output['post_status'] = $post->post_status; $project_info_output['post_author'] = $post->post_author; $project_info_output['display_name'] = get_userdata($post->post_author)->display_name; $project_info_output['post_date_gmt'] = $post->post_date_gmt; $project_info_output['post_title'] = $post->post_title; $project_info_output['guid'] = $post->guid; $project_meta = get_post_meta($post->ID); $project_info_output['et_budget'] = $project_meta['et_budget'][0]; $project_info_output['et_featured'] = $project_meta['et_featured'][0]; $project_info_output['hours_limit'] = $project_meta['hours_limit'][0]; $project_info_output['type_budget'] = $project_meta['type_budget'][0]; $project_info_output['accepted'] = $project_meta['accepted'][0]; $bid_post_id = get_post_meta($post->ID)['accepted'][0]; if ($bid_post_id) { $bid_post = get_post($bid_post_id); $project_info_output['bid_post_date_gmt'] = $bid_post->post_date_gmt; $project_info_output['bid_post_author'] = $bid_post->post_author; $project_info_output['bid_display_name'] = get_userdata($bid_post->post_author)->display_name; $project_bid_meta = get_post_meta($bid_post_id); $project_info_output['bid_budget'] = $project_bid_meta['bid_budget'][0]; $project_info_output['bid_time'] = $project_bid_meta['bid_time'][0]; $project_info_output['bid_type_time'] = $project_bid_meta['type_time'][0]; } if ($project_info_output['post_status'] != 'opened_disput') { add_post_meta($project_info_output['ID'], 'post_status_before_disput', $project_info_output['post_status'], true); $my_post = array('ID' => $_POST['project_id'], 'post_status' => 'opened_disput'); wp_update_post($my_post); } $mail_employer = $this->mail->disput_opened($project_info_output['post_author'], $project_info_output); $mail_freelancer = $this->mail->disput_opened($project_info_output['bid_post_author'], $project_info_output); $mail_success = $this->mail->disput_opened_for_admin($project_info_output); $response = array(); $response['msg'] = __('The dispute is open', 'user-actions-backend'); $response['success'] = true; wp_send_json($response); }
function ae_send_invite() { global $user_ID; try { if ($_POST['data']) { $this->mail = Fre_Mailing::get_instance(); $mail_success = $this->mail->invite_mail($_POST['user_id'], $_POST['data']['project_invites']); if ($mail_success || true) { $invited = $_POST['user_id']; $send_invite = $user_ID; $invite_project = $_POST['data']['project_invites']; /** * do action when user have a new invite * @param int $invited invited user id * @param int $send_invite user send invite * @param Array $invite_project list of projects * @since 1.3 * @author Dakachi */ do_action('fre_new_invite', $invited, $send_invite, $invite_project); $resp = array('success' => true, 'msg' => __('Your invite has been sent!', ET_DOMAIN)); } else { $resp = array('success' => false, 'msg' => __('Currently, you do not have any project available to invite this user.', ET_DOMAIN)); } } } catch (Exception $e) { $resp = array('success' => false, 'msg' => $e->getMessage()); } wp_send_json($resp); }
/** * ajax callback user send report to a project * request param contain $comment_content, $comment_post_ID * @since 1.3 * @author Dakachi */ function report() { global $user_ID; $request = $_REQUEST; $report = $this->insert_report($request); // update project if (is_wp_error($report)) { wp_send_json(array('success' => false, 'msg' => $report->get_error_message())); } $project_id = $request['comment_post_ID']; $report = get_comment($report); if (isset($_REQUEST['fileID'])) { $file_arr = array(); foreach ((array) $_REQUEST['fileID'] as $key => $file) { $file_arr[] = $file['attach_id']; } update_comment_meta($report->comment_ID, 'fre_comment_file', $file_arr); } do_action('fre_report_dispute_project', $project_id, $report); $mailing = Fre_Mailing::get_instance(); $mailing->new_report($project_id, $report); wp_send_json(array('success' => true, 'data' => $this->report->convert($report))); }
/** * notify when a project working on have new message * @param object $message * @param object $project * @param object $bid * @since 1.2 * @author Dakachi */ function newMessage($message, $project, $bid) { global $user_ID; $content = 'type=new_message&project=' . $project->ID . '&sender=' . $user_ID; $notification = array('post_content' => $content, 'post_excerpt' => $content, 'post_status' => 'publish', 'post_type' => $this->post_type, 'post_title' => sprintf(__("New message on project %s", 'notification-backend'), get_the_title($project->ID)), 'post_parent' => $project->ID); // update notify for freelancer if current user is project owner if ($user_ID == $project->post_author) { $notification['post_author'] = $bid->post_author; } // update notify to employer if freelancer send message if ($user_ID == $bid->post_author) { $notification['post_author'] = $project->post_author; } $have_new = get_post_meta($project->ID, $user_ID . '_new_message', true); if ($have_new) { return; } update_post_meta($project->ID, $user_ID . '_new_message', true); $mail = Fre_Mailing::get_instance(); $mail->new_message($notification['post_author'], $project, $message); return $this->insert($notification); }