PluginProbe
Taskbuilder – Project Management & Task Management Tool With Kanban Board / 6.0.7
Taskbuilder – Project Management & Task Management Tool With Kanban Board v6.0.7
6.0.7 6.0.6 6.0.5 6.0.2 6.0.3 6.0.4 6.0.1 6.0.0 5.0.8 5.0.9 4.0.9 5.0.0 5.0.1 5.0.2 5.0.3 5.0.4 5.0.5 5.0.6 5.0.7 trunk 1.0.0 1.0.1 1.0.2 1.0.3 1.0.4 All 59 releases
taskbuilder / includes / admin / projects / wppm_create_project.php

wppm_create_project.php in Taskbuilder – Project Management & Task Management Tool With Kanban Board 6.0.7, at includes/admin/projects/wppm_create_project.php

66 lines 2.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 if ( ! defined( 'ABSPATH' ) ) {
3 exit; // Exit if accessed directly
4 }
5 global $wpdb, $wppmfunction, $current_user;
6 if ( check_ajax_referer( 'wppm_create_project', '_ajax_nonce', false ) != 1 ) {
7 wp_send_json_error( 'Unauthorised request!', 401 );
8 }
9 $wppm_current_user_capability = get_user_meta( $current_user->ID, 'wppm_capability', true );
10 $wppm_can_create_project = ($current_user->has_cap('manage_options')) || $wppm_current_user_capability == 'wppm_manager'|| $wppm_current_user_capability == 'wppm_admin';
11 $wppm_can_create_project = apply_filters( 'wppm_can_create_project', $wppm_can_create_project, $current_user->ID );
12 if ($wppm_can_create_project) {
13 // project name
14 $name = isset($_POST['name']) ? sanitize_text_field(wp_unslash($_POST['name'])) : '';
15 if($name) $args['name'] = $name;
16
17 // Description
18 $project_description = '';
19
20 if ( !empty( $_POST['wppm_proj_description'] ) ) {
21 $project_description = wp_kses_post(
22 wp_unslash( $_POST['wppm_proj_description'] )
23 );
24 }
25 if($project_description) $args['wppm_proj_description'] = $project_description;
26
27 //Project start date
28 $text = isset($_POST['wppm_start_date']) ? sanitize_text_field(wp_unslash($_POST['wppm_start_date'])) : '';
29 if($text) $args['wppm_start_date'] = wp_date("Y-m-d H:i:s" ,strtotime($text));
30
31 //Project end date
32 $text2 = isset($_POST['wppm_end_date']) ? sanitize_text_field(wp_unslash($_POST['wppm_end_date'])) : '';
33 if($text2) $args['wppm_end_date'] = wp_date("Y-m-d H:i:s" ,strtotime($text2));
34
35 // Category
36 $project_category = isset($_POST['wppm_create_project_category']) ? intval(sanitize_text_field(wp_unslash($_POST['wppm_create_project_category']))) : '';
37 if($project_category) $args['wppm_create_project_category'] = $project_category;
38
39 //Assign user
40 $users = array();
41 if ( isset( $_POST['user_names'] ) && is_array( $_POST['user_names'] ) ) {
42 $users = array_map(
43 'absint',
44 wp_unslash( $_POST['user_names'] )
45 );
46 $users = array_unique( $users );
47 }
48 if($users) $args['user_names'] = $wppmfunction->sanitize_array($users);
49
50 //public project
51 $public_proj = isset($_POST['wppm_public_project']) ? 1 : 0;
52
53 $args = apply_filters( 'wppm_before_create_project_args', $args);
54
55 $project_id = WPPM_Functions::create_project($args);
56 if ( empty( $project_id ) ) {
57 wp_send_json_error( 'Permission denied', 403 );
58 }
59 $auth_code = $wppmfunction->getRandomString(10);
60 $wppmfunction->add_project_meta($project_id,'public_project',$public_proj);
61 $wppmfunction->add_project_meta($project_id,'project_auth_code',$auth_code);
62 } else {
63 wp_send_json_error( 'Permission denied', 403 );
64 }
65
66 do_action('wppm_after_project_created',$project_id);