| 1 |
<?php |
| 2 |
if ( ! defined( 'ABSPATH' ) ) { |
| 3 |
exit; // Exit if accessed directly |
| 4 |
} |
| 5 |
global $current_user,$wppmfunction,$wpdb; |
| 6 |
if ( check_ajax_referer( 'wppm_set_change_project_status', '_ajax_nonce', false ) != 1 ) { |
| 7 |
wp_send_json_error( 'Unauthorised request!', 401 ); |
| 8 |
} |
| 9 |
$project_id = isset($_POST['project_id']) ? absint(sanitize_text_field(wp_unslash($_POST['project_id']))) : ''; |
| 10 |
$project_data = $wppmfunction->get_project($project_id); |
| 11 |
$wppm_current_user_capability = get_user_meta( $current_user->ID, 'wppm_capability', true ); |
| 12 |
if (!(($current_user->ID && $current_user->has_cap('manage_options')) || $wppmfunction->has_project_permission('change_project_status',$project_id) || ($project_data['created_by']==$current_user->ID && $wppm_current_user_capability=='wppm_manager') || $wppm_current_user_capability=='wppm_admin')) {exit;} |
| 13 |
|
| 14 |
$status_id = isset($_POST['wppm_project_status']) ? intval(sanitize_text_field(wp_unslash($_POST['wppm_project_status']))) : 0 ; |
| 15 |
if( !$status_id ){ |
| 16 |
die(); |
| 17 |
} |
| 18 |
$old_status_id = $project_data['status']; |
| 19 |
|
| 20 |
if($status_id && $status_id!=$old_status_id){ |
| 21 |
$wppmfunction->change_project_status( $project_id, $status_id); |
| 22 |
} |
| 23 |
do_action('wppm_after_set_change_project_status',$project_id, $status_id, $old_status_id); |