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

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

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