PluginProbe
Taskbuilder – Project Management & Task Management Tool With Kanban Board / 6.0.3
Taskbuilder – Project Management & Task Management Tool With Kanban Board v6.0.3
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 1.0.5 1.0.6 All 57 releases
taskbuilder / includes / wppm-install.php

wppm-install.php in Taskbuilder – Project Management & Task Management Tool With Kanban Board 6.0.3, at includes/wppm-install.php

610 lines 22.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
3
4 if ( ! class_exists( 'WPPM_Install' ) ) :
5
6 final class WPPM_Install {
7 public function __construct() {
8 $this->check_version();
9 }
10 /**
11 * Check version of Taskbuilder
12 */
13 public function check_version(){
14 $installed_version = get_option( 'wppm_version' );
15 if( $installed_version != WPPM_VERSION ){
16 $this->create_db_tables();
17 add_action( 'init', array($this,'upgrade'), 101 );
18 }
19 }
20 /**** Create mysql tables****/
21 public function create_db_tables() {
22 global $wpdb;
23 require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
24 $sql = "CREATE TABLE IF NOT EXISTS {$wpdb->prefix}wppm_project (
25 id integer NOT NULL AUTO_INCREMENT,
26 created_by integer,
27 project_name VARCHAR( 200 ) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
28 description LONGTEXT CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
29 start_date datetime,
30 end_date datetime,
31 status integer,
32 cat_id integer,
33 users VARCHAR( 200 ) NULL DEFAULT '0',
34 date_created datetime,
35 PRIMARY KEY (id)
36 );";
37 dbDelta( $sql );
38
39 $sql = "CREATE TABLE IF NOT EXISTS {$wpdb->prefix}wppm_project_meta (
40 id integer NOT NULL AUTO_INCREMENT,
41 project_id integer,
42 meta_key LONGTEXT NULL DEFAULT NULL,
43 meta_value LONGTEXT NULL DEFAULT NULL,
44 PRIMARY KEY (id)
45 );";
46 dbDelta( $sql );
47
48 $sql = "CREATE TABLE IF NOT EXISTS {$wpdb->prefix}wppm_project_categories (
49 id integer NOT NULL AUTO_INCREMENT,
50 name TINYTEXT CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
51 load_order int(11) NOT NULL DEFAULT '1',
52 PRIMARY KEY (id)
53 );";
54 dbDelta( $sql );
55
56 $sql = "CREATE TABLE IF NOT EXISTS {$wpdb->prefix}wppm_project_statuses (
57 id bigint(20) NOT NULL AUTO_INCREMENT,
58 name varchar(200) COLLATE utf8mb4_unicode_520_ci NOT NULL,
59 color varchar(50) COLLATE utf8mb4_unicode_520_ci NOT NULL,
60 bg_color varchar(50) COLLATE utf8mb4_unicode_520_ci NOT NULL,
61 load_order int(11) NOT NULL DEFAULT '1',
62 PRIMARY KEY (id)
63 );";
64 dbDelta( $sql );
65
66 $sql = "CREATE TABLE IF NOT EXISTS {$wpdb->prefix}wppm_task_statuses (
67 id bigint(20) NOT NULL AUTO_INCREMENT,
68 name varchar(200) COLLATE utf8mb4_unicode_520_ci NOT NULL,
69 color varchar(50) COLLATE utf8mb4_unicode_520_ci NOT NULL,
70 bg_color varchar(50) COLLATE utf8mb4_unicode_520_ci NOT NULL,
71 load_order int(11) NOT NULL DEFAULT '1',
72 PRIMARY KEY (id)
73 );";
74 dbDelta( $sql );
75
76 $sql = "CREATE TABLE IF NOT EXISTS {$wpdb->prefix}wppm_task_priorities (
77 id bigint(20) NOT NULL AUTO_INCREMENT,
78 name varchar(200) COLLATE utf8mb4_unicode_520_ci NOT NULL,
79 color varchar(50) COLLATE utf8mb4_unicode_520_ci NOT NULL,
80 bg_color varchar(50) COLLATE utf8mb4_unicode_520_ci NOT NULL,
81 load_order int(11) NOT NULL DEFAULT '1',
82 PRIMARY KEY (id)
83 );";
84 dbDelta( $sql );
85
86 $sql = "CREATE TABLE IF NOT EXISTS {$wpdb->prefix}wppm_task (
87 id integer NOT NULL AUTO_INCREMENT,
88 created_by integer,
89 task_name VARCHAR( 200 ) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
90 description LONGTEXT CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
91 project integer,
92 start_date datetime,
93 end_date datetime,
94 status integer,
95 priority integer,
96 users VARCHAR( 200 ) NULL DEFAULT '0',
97 date_created datetime,
98 task_auth_code LONGTEXT NULL DEFAULT NULL,
99 active int(11) DEFAULT 1,
100 PRIMARY KEY (id)
101 );";
102 dbDelta( $sql );
103
104 $sql = "CREATE TABLE IF NOT EXISTS {$wpdb->prefix}wppm_task_meta (
105 id integer NOT NULL AUTO_INCREMENT,
106 task_id integer,
107 meta_key LONGTEXT NULL DEFAULT NULL,
108 meta_value LONGTEXT NULL DEFAULT NULL,
109 PRIMARY KEY (id)
110 );";
111 dbDelta( $sql );
112
113 $sql = "CREATE TABLE IF NOT EXISTS {$wpdb->prefix}wppm_checklist (
114 id integer NOT NULL AUTO_INCREMENT,
115 task_id integer,
116 checklist_name VARCHAR( 200 ) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
117 created_by integer,
118 PRIMARY KEY (id)
119 );";
120 dbDelta( $sql );
121
122 $sql = "CREATE TABLE IF NOT EXISTS {$wpdb->prefix}wppm_checklist_items (
123 id integer NOT NULL AUTO_INCREMENT,
124 checklist_id integer,
125 item_name VARCHAR( 200 ) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
126 checked integer,
127 members VARCHAR( 200 ) NULL DEFAULT '0',
128 due_date datetime,
129 PRIMARY KEY (id)
130 );";
131 dbDelta( $sql );
132
133 $sql = "CREATE TABLE IF NOT EXISTS {$wpdb->prefix}wppm_task_comment (
134 id integer NOT NULL AUTO_INCREMENT,
135 task_id integer,
136 body LONGTEXT CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
137 attachment_ids TINYTEXT CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
138 create_time datetime,
139 created_by integer,
140 PRIMARY KEY (id)
141 );";
142 dbDelta( $sql );
143 $sql = "CREATE TABLE IF NOT EXISTS {$wpdb->prefix}wppm_project_comment (
144 id integer NOT NULL AUTO_INCREMENT,
145 proj_id integer,
146 body LONGTEXT NULL DEFAULT NULL,
147 attachment_ids TINYTEXT NULL DEFAULT NULL,
148 create_time datetime,
149 created_by integer,
150 PRIMARY KEY (id)
151 );";
152 dbDelta( $sql );
153 $sql = "CREATE TABLE IF NOT EXISTS {$wpdb->prefix}wppm_attachments (
154 id BIGINT NOT NULL AUTO_INCREMENT,
155 name VARCHAR(200) NOT NULL,
156 file_name VARCHAR(200) NOT NULL,
157 file_path VARCHAR(500) NOT NULL,
158 is_image INT(1) NOT NULL DEFAULT 0,
159 is_active INT(1) NOT NULL DEFAULT 0,
160 is_uploaded INT(1) NOT NULL DEFAULT 0,
161 date_created DATETIME NOT NULL,
162 PRIMARY KEY (id)
163 );";
164 dbDelta( $sql );
165 $sql = "CREATE TABLE IF NOT EXISTS {$wpdb->prefix}wppm_project_users (
166 id BIGINT NOT NULL AUTO_INCREMENT,
167 proj_id integer,
168 user_id integer,
169 role_id integer,
170 assigned_by integer,
171 PRIMARY KEY (id)
172 );";
173 dbDelta( $sql );
174 $sql = "CREATE TABLE IF NOT EXISTS {$wpdb->prefix}wppm_project_comment_meta (
175 id BIGINT NOT NULL AUTO_INCREMENT,
176 proj_id integer,
177 comment_id integer,
178 comment_type VARCHAR(200) NOT NULL,
179 PRIMARY KEY (id)
180 );";
181 dbDelta( $sql );
182 $sql = "CREATE TABLE IF NOT EXISTS {$wpdb->prefix}wppm_task_comment_meta (
183 id BIGINT NOT NULL AUTO_INCREMENT,
184 task_id integer,
185 comment_id integer,
186 comment_type VARCHAR(200) NOT NULL,
187 PRIMARY KEY (id)
188 );";
189 dbDelta( $sql );
190 $sql = "CREATE TABLE IF NOT EXISTS {$wpdb->prefix}wppm_notifications (
191 id BIGINT AUTO_INCREMENT PRIMARY KEY,
192 user_id INT,
193 message TEXT,
194 link TEXT,
195 is_read TINYINT DEFAULT 0,
196 notification_type VARCHAR(200) NOT NULL,
197 created_at DATETIME DEFAULT CURRENT_TIMESTAMP
198 );";
199 dbDelta( $sql );
200 }
201
202 public function upgrade(){
203 global $wpdb,$wppmfunction;
204 $installed_version = get_option( 'wppm_version' );
205 $installed_version = $installed_version ? $installed_version : 0;
206 if($installed_version < '1.0.0'){
207 //User Roles
208 $user_role = get_option('wppm_user_role');
209 if(empty($user_role)){
210 $user_role = array(
211 1 => array(
212 'label' => esc_html__('manager','taskbuilder'),
213 ),
214 2 => array(
215 'label' => esc_html__('co-worker','taskbuilder'),
216 )
217 );
218 update_option('wppm_user_role',$user_role);
219 }
220
221 $wppm_email_notificatins = get_option('wppm_email_notification');
222 if(empty($wppm_email_notificatins)){
223 $wppm_email_notificatins = array(
224 1=>array(
225 'type'=>'new_project',
226 'subject'=>esc_html__('New project has been created:{project_name}','taskbuilder'),
227 'body'=>esc_html__('<p><strong>{user_name}</strong> assigned project to you.</p> <p>Below are details of the project :</p><p><strong> Assign to:-</strong>{project_assigned_users}</p><p><strong> Start Date:-</strong>{project_start_date} </p><p> <strong> End Date:- </strong> {project_end_date} </p> <p><strong>Description:-</strong>{project_description}</p>','taskbuilder'),
228 'recipients'=>array(1,2)
229 ),
230 2=>array(
231 'type'=>'new_task',
232 'subject'=>esc_html__('New task has been created: {task_name}','taskbuilder'),
233 'body'=>esc_html__('<p><strong>{user_name}</strong> assigned task to you.</p><p>Below are details of the task :</p> <p><strong>Assign to:-</strong>{task_assigned_users} </p><p><strong> Start Date:-</strong>{task_start_date}</p><p><strong>End Date:-</strong>{task_end_date} </p><p> <strong>Description:-</strong>{task_description}</p>','taskbuilder'),
234 'recipients'=>array(1,2)
235 ),
236 3=>array(
237 'type'=>'change_project_status',
238 'subject'=>esc_html__('{project_name} Project\'s status has been changed from {old_project_status} to {new_project_status}','taskbuilder'),
239 'body'=>esc_html__('<p><strong>{user_name}</strong> changed project\'s status to <strong>{new_project_status}</strong> </p> <p>Below are details of the project:</p><p><strong>Assign to:- </strong> {project_assigned_users}</p><p><strong>Start Date:-</strong>{project_start_date} </p> <p><strong>End Date:-</strong>{project_end_date} </p> <p><strong>Description:-</strong>{project_description}</p>','taskbuilder'),
240 'recipients'=>array(1,2)
241 ),
242 4=>array(
243 'type'=>'change_task_status',
244 'subject'=>esc_html__('{task_name} Task\'s status has been changed from {old_task_status} to {new_task_status}','taskbuilder'),
245 'body'=>esc_html__('<p><strong>{user_name}</strong> changed task status to <strong>{new_task_status} </strong><p> Below are details of the task:</p> <p><strong>Assign to:-</strong>{task_assigned_users} </p> <p><strong>Start Date:-</strong>{task_start_date}</p><p><strong>End Date:-</strong>{task_end_date} </p> <p><strong>Description:-</strong>{task_description}</p>','taskbuilder'),
246 'recipients'=>array(1,2)
247 ),
248 5=>array(
249 'type'=>'change_project_assign_users',
250 'subject'=>esc_html__('{project_name} Project\'s assigned users changed from {previously_assigned_project_users} to {project_assigned_users}','taskbuilder'),
251 'body'=>esc_html__('<p><strong>{user_name}</strong> changed project\'s assign users to <strong> {project_assigned_users}</strong></p> <p>Below are details of the project :</p><p><strong> Assign to:-</strong>{project_assigned_users}</p><p><strong> Start Date:-</strong>{project_start_date} </p><p> <strong> End Date:- </strong> {project_end_date} </p> <p><strong>Description:-</strong>{project_description}</p>','taskbuilder'),
252 'recipients'=>array(1,2)
253 ),
254 6=>array(
255 'type'=>'change_task_assign_users',
256 'subject'=>esc_html__('{task_name} Task\'s assigned users change from {previously_assigned_task_users} to {task_assigned_users}','taskbuilder'),
257 'body'=>esc_html__('<p><strong>{user_name}</strong> changed task\'s assign users to <strong>{task_assigned_users}</strong></p><p>Below are details of the task :</p> <p><strong>Assign to:-</strong>{task_assigned_users} </p><p><strong> Start Date:-</strong>{task_start_date}</p><p><strong>End Date:-</strong>{task_end_date} </p><p> <strong>Description:-</strong>{task_description}</p>','taskbuilder'),
258 'recipients'=>array(1,2)
259 ),
260 7=>array(
261 'type'=>'new_discussion',
262 'subject'=>esc_html__('[{project_name}][{task_name}] {last_comment_user_name} started new discussion:','taskbuilder'),
263 'body'=>esc_html__('<p><strong>{last_comment_user_name}</strong> wrote:</p> <p>{comment_body}</p>','taskbuilder'),
264 'recipients'=>array(1,2)
265 )
266 );
267 update_option('wppm_email_notification',$wppm_email_notificatins);
268 }
269
270 update_option('wppm_default_task_list_view',1);
271
272 $default_statuses = $wpdb->get_var("select count(*) from {$wpdb->prefix}wppm_project_statuses");
273 if (empty($default_statuses)) {
274 $wpdb->insert($wpdb->prefix . "wppm_project_statuses", array('id' => 1,'name' => esc_html__('New','taskbuilder'),'color'=>'#ffffff','bg_color'=>'#306EFF','load_order'=>1));
275 $wpdb->insert($wpdb->prefix . "wppm_project_statuses", array('id' => 2,'name' => esc_html__('In Progress','taskbuilder'),'color'=>'#ffffff','bg_color'=>'#FCD12A','load_order'=>2));
276 $wpdb->insert($wpdb->prefix . "wppm_project_statuses", array('id' => 3,'name' => esc_html__('Hold','taskbuilder'),'color'=>'#ffffff','bg_color'=>'#D3D3D3','load_order'=>3));
277 $wpdb->insert($wpdb->prefix . "wppm_project_statuses", array('id' => 4,'name' => esc_html__('Completed','taskbuilder'),'color'=>'#ffffff','bg_color'=>'#5cb85c','load_order'=>4));
278 }
279 $wppm_default_project_status = get_option('wppm_default_project_status',true);
280 if($wppm_default_project_status == ''){
281 update_option('wppm_default_project_status',1);
282 }
283 $default_task_statuses = $wpdb->get_var("select count(*) from {$wpdb->prefix}wppm_task_statuses");
284 if (empty($default_task_statuses)) {
285 $wpdb->insert($wpdb->prefix . "wppm_task_statuses",array('id' => 1,'name' => esc_html__('Todo','taskbuilder'),'color'=>'#ffffff','bg_color'=>'#306EFF','load_order'=>1));
286 $wpdb->insert($wpdb->prefix . "wppm_task_statuses",array('id' => 2,'name' => esc_html__('In Progress','taskbuilder'),'color'=>'#ffffff','bg_color'=>'#FCD12A','load_order'=>2));
287 $wpdb->insert($wpdb->prefix . "wppm_task_statuses",array('id' => 3,'name' => esc_html__('Hold','taskbuilder'),'color'=>'#ffffff','bg_color'=>'#D3D3D3','load_order'=>3));
288 $wpdb->insert($wpdb->prefix . "wppm_task_statuses",array('id' => 4,'name' => esc_html__('Completed','taskbuilder'),'color'=>'#ffffff','bg_color'=>'#5cb85c','load_order'=>4));
289 }
290 $wppm_default_task_status = get_option('wppm_default_task_status',true);
291 if($wppm_default_task_status == ''){
292 update_option('wppm_default_task_status',1);
293 }
294 }
295 if($installed_version < '1.0.2'){
296 update_option('wppm_project_time', 1);
297 }
298 if($installed_version < '2.0.0'){
299 update_option('wppm_default_project_date', 1);
300 update_option('wppm_default_task_date', 1);
301 }
302 if($installed_version < '2.0.2'){
303 update_option('wppm_default_edit_tasks_permission', 0);
304 }
305 if($installed_version < '2.0.4'){
306 update_option('wppm_public_projects_permission',0);
307 }
308 if($installed_version < '2.0.8'){
309 update_option('wppm_task_time',1);
310 }
311 if($installed_version < '3.0.0'){
312 $wppm_email_notificatins = get_option('wppm_email_notification');
313 if(!empty($wppm_email_notificatins) && !isset($wppm_email_notificatins[8])){
314 $wppm_email_notificatins[8] = array(
315 'type'=>'new_proj_discussion',
316 'subject'=>esc_html__('[{project_name}] {last_proj_comment_user_name} started new discussion:','taskbuilder'),
317 'body'=>esc_html__('<p><strong>{last_proj_comment_user_name}</strong> wrote:</p> <p>{proj_comment_body}</p>','taskbuilder'),
318 'recipients'=>array(1,2)
319 );
320 update_option('wppm_email_notification',$wppm_email_notificatins);
321 }
322 update_option(
323 'wppm-ap-project-list',
324 array(
325 'list-header-background-color' => '#304FFE',
326 'list-header-text-color' => '#fff',
327 'list-item-odd-background-color' => '#fff',
328 'list-item-odd-text-color' => '#2C3E50',
329 'list-item-even-background-color' => '#F2F2F2',
330 'list-item-even-text-color' => '#2C3E50',
331 'list-item-hover-background-color' => '#F5F5F5',
332 'list-item-hover-text-color' => '#2C3E50'
333 )
334 );
335 update_option(
336 'wppm-ap-task-list',
337 array(
338 'list-header-button-background-color'=>'#0052CC',
339 'list-header-button-hover-color' =>'#0065ff',
340 'list-header-button-text-color' =>'#fff',
341 'list-header-background-color' => '#304FFE',
342 'list-header-text-color' => '#fff',
343 'list-item-odd-background-color' => '#fff',
344 'list-item-odd-text-color' => '#2C3E50',
345 'list-item-even-background-color' => '#F2F2F2',
346 'list-item-even-text-color' => '#2C3E50',
347 'list-item-hover-background-color' => '#F5F5F5',
348 'list-item-hover-text-color' => '#2C3E50',
349 )
350 );
351 update_option(
352 'wppm-ap-individual-project',
353 array(
354 'menu-button-bg-color' =>'#0052CC',
355 'menu-button-hover-color' =>'#0065ff',
356 'menu-button-text-color' =>'#fff',
357 'comment-primary-color' => '#000000',
358 'comment-secondary-color' => '#4e4e4e',
359 'comment-date-color' => '#a8aeb5',
360 'comment-date-hover-color' => '#000000',
361 'comment-send-btn-bg-color' => '#5067c5',
362 'comment-send-btn-color' => '#ffffff',
363 'widget-header-bg-color' => '#ffffff',
364 'widget-header-text-color' => '#2C3E50',
365 'widget-body-bg-color' => '#ffffff',
366 'widget-body-label-color' => '#9c9c9c',
367 'widget-body-text-color' => '#2C3E50',
368 )
369 );
370 update_option(
371 'wppm-ap-individual-task',
372 array(
373 'comment-primary-color' => '#000000',
374 'comment-secondary-color' => '#4e4e4e',
375 'comment-date-color' => '#a8aeb5',
376 'comment-date-hover-color' => '#000000',
377 'comment-send-btn-bg-color' => '#5067c5',
378 'comment-send-btn-color' => '#ffffff',
379 'widget-header-bg-color' => '#ffffff',
380 'widget-header-text-color' => '#2C3E50',
381 'widget-body-bg-color' => '#ffffff',
382 'widget-body-label-color' => '#9c9c9c',
383 'widget-body-text-color' => '#2C3E50',
384 )
385 );
386 update_option(
387 'wppm-ap-modal',
388 array(
389 'header-bg-color' => '#ffffff',
390 'header-text-color' => '#3c434a',
391 'body-bg-color' => '#fff',
392 'body-label-color' => '#3c434a',
393 'body-text-color' => '#555',
394 'footer-bg-color' => '#F6F6F6',
395 'action-btn-bg-color' =>'#306EFF',
396 'action-btn-text-color'=>'#fff',
397 'z-index' => 900000000,
398 )
399 );
400 update_option(
401 'wppm-ap-grid-view',
402 array(
403 'menu-button-bg-color' =>'#0052CC',
404 'menu-button-hover-color' =>'#0065ff',
405 'menu-button-text-color' =>'#fff',
406 'grid-background-color' => '#fff',
407 'grid-header-text-color' => '#2C3E50'
408 )
409 );
410 update_option(
411 'wppm-ap-settings',
412 array(
413 'tab-background-color' => '#0052CC',
414 'tab-text-color' => '#fff',
415 'add-new-button-bg-color' =>'#0052CC',
416 'add-new-button-text-color' =>'#fff',
417 'add-new-button-hover-color'=>'#0065ff',
418 'save-changes-button-bg-color'=>'#306EFF',
419 'save-changes-button-text-color'=>'#fff'
420 )
421 );
422 }
423 if($installed_version < '3.0.1'){
424 update_option('wppm_default_project_status', 1);
425 update_option('wppm_default_task_status', 1);
426 }
427 if($installed_version < '3.0.5'){
428 update_option('wppm_tinymce_visibility_open_task',0);
429 update_option('wppm_tinymce_visibility_open_project',0);
430 update_option('wppm_default_email_notification_to_current_user', 1);
431 }
432 if($installed_version < '3.0.6'){
433 update_option('wppm_allow_coworkers_create_task',1);
434 update_option('wppm_allow_coworkers_add_checklist',1);
435 update_option('wppm_allow_coworkers_assign_users', 0);
436 update_option('wppm_allow_coworkers_change_status', 1);
437 }
438 if($installed_version < '3.0.9'){
439 update_option('wppm_rich_text_editor',1);
440 update_option(
441 'wppm_toolbar_actions',
442 array(
443 'bold' => '1',
444 'italic' => '1',
445 'underline' =>'1',
446 'blockquote' =>'1',
447 'align'=>'1',
448 'bullist'=>'1',
449 'numlist'=>'1',
450 'rtl'=>'1',
451 'link'=>'1',
452 'wppm_insert_editor_img'=>'1',
453 'forecolor'=>'0',
454 'backcolor' => '0',
455 'strikethrough' => '0'
456 )
457 );
458 }
459
460 if($installed_version < '4.0.0'){
461 update_option(
462 'wppm-page-settings',
463 array(
464 'task-url-page' => 0,
465 'project-url-page' => 0
466 )
467 );
468 }
469
470 if($installed_version < '4.0.4'){
471 update_option('wppm_date_setting','Y-m-d h:i:sa');
472 }
473
474 if($installed_version < '4.0.5'){
475 update_option('wppm_hide_completed_status_proj','1');
476 update_option('wppm_hide_completed_status_task','1');
477 update_option('wppm_hide_proj_statuses_from_frontend','0');
478 update_option('wppm_hide_task_statuses_from_frontend','0');
479 update_option('wppm_proj_hide_comment_section','1');
480 update_option('wppm_task_hide_comment_section','1');
481 }
482
483 if($installed_version < '5.0.0'){
484 $wppm_print_settings = array(
485 'wppm_print_body_font_size' => 10);
486 update_option('wppm_print_settings',$wppm_print_settings);
487 }
488 if($installed_version < '5.0.2'){
489 $table_name = $wpdb->prefix . 'wppm_checklist_items';
490 $column_name = 'load_order';
491 $column_type = 'INT(11) NOT NULL DEFAULT 1';
492
493 $column_exists = $wpdb->get_var(
494 $wpdb->prepare(
495 "SHOW COLUMNS FROM `$table_name` LIKE %s",
496 $column_name
497 )
498 );
499
500 if ( null === $column_exists ) {
501
502 // Column name and type are hardcoded, not user input.
503 // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared
504 $wpdb->query(
505 "ALTER TABLE `$table_name`
506 ADD `$column_name` $column_type"
507 );
508 }
509 $table_name = $wpdb->prefix . 'wppm_task';
510 $cl_name = 'is_archived';
511 $cl_type = 'TINYINT(1) DEFAULT 0';
512
513 $cl_exists = $wpdb->get_var(
514 $wpdb->prepare(
515 "SHOW COLUMNS FROM `$table_name` LIKE %s",
516 $cl_name
517 )
518 );
519
520 if ( null === $cl_exists ) {
521
522 $sql = sprintf(
523 'ALTER TABLE `%s` ADD `%s` %s',
524 $table_name,
525 $cl_name,
526 $cl_type
527 );
528
529 // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared -- Safe: identifiers are hardcoded.
530 $wpdb->query( $sql );
531 }
532 }
533 if($installed_version < '5.0.3'){
534 update_option('wppm_display_time_duration_project',0);
535 update_option('wppm_display_time_duration_task',0);
536
537 }
538 if($installed_version < '5.0.6'){
539 update_option('wppm_show_update_notice', 1);
540 $user_role = get_option('wppm_user_role');
541 if (!isset($user_role[3])) {
542 $user_role[3] = array(
543 'label' => esc_html__('Client', 'taskbuilder'),
544 );
545 }
546 update_option('wppm_user_role', $user_role);
547 }
548 if($installed_version < '6.0.0'){
549 $table_name = $wpdb->prefix . 'wppm_project';
550 $column_name = 'project_auth_code';
551 $column_type = 'LONGTEXT NULL DEFAULT NULL';
552 $column_exists = $wpdb->get_var(
553 $wpdb->prepare(
554 "SHOW COLUMNS FROM `$table_name` LIKE %s",
555 $column_name
556 )
557 );
558 if ( empty( $column_exists ) ) {
559 // Column name and type are hardcoded, not user input.
560 // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared
561 $wpdb->query(
562 "ALTER TABLE `$table_name`
563 ADD `$column_name` $column_type"
564 );
565 }
566 $projects = $wpdb->get_results(
567 "SELECT id FROM {$wpdb->prefix}wppm_project
568 WHERE project_auth_code IS NULL OR project_auth_code = ''"
569 );
570 foreach ( $projects as $project ) {
571 $wpdb->update(
572 "{$wpdb->prefix}wppm_project",
573 array(
574 'project_auth_code' => $wppmfunction->getRandomString(10),
575 ),
576 array(
577 'id' => $project->id,
578 ),
579 array('%s'),
580 array('%d')
581 );
582 }
583 $table_name = $wpdb->prefix . 'wppm_project';
584 $cl_name = 'is_archived';
585 $cl_type = 'TINYINT(1) DEFAULT 0';
586 $cl_exists = $wpdb->get_var(
587 $wpdb->prepare(
588 "SHOW COLUMNS FROM `$table_name` LIKE %s",
589 $cl_name
590 )
591 );
592 if ( empty( $cl_exists ) ) {
593 $sql = sprintf(
594 'ALTER TABLE `%s` ADD `%s` %s',
595 $table_name,
596 $cl_name,
597 $cl_type
598 );
599 // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared -- Safe: identifiers are hardcoded.
600 $wpdb->query( $sql );
601 }
602 }
603 // update wppm_version option to plugin version
604 update_option( 'wppm_version', WPPM_VERSION );
605 }
606 }
607
608 endif;
609
610 new WPPM_Install();