| @@ -96,8 +96,9 @@ | ||
| 96 | 96 | users VARCHAR( 200 ) NULL DEFAULT '0', |
| 97 | 97 | date_created datetime, |
| 98 | 98 | task_auth_code LONGTEXT NULL DEFAULT NULL, |
| 99 | 99 | active int(11) DEFAULT 1, |
| 100 | + parent_task_id integer NOT NULL DEFAULT 0, | |
| 100 | 101 | PRIMARY KEY (id) |
| 101 | 102 | );"; |
| 102 | 103 | dbDelta( $sql ); |
| 103 | 104 | |
| @@ -185,13 +186,23 @@ | ||
| 185 | 186 | comment_id integer, |
| 186 | 187 | comment_type VARCHAR(200) NOT NULL, |
| 187 | 188 | PRIMARY KEY (id) |
| 188 | 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 | + );"; | |
| 189 | 200 | dbDelta( $sql ); |
| 190 | 201 | } |
| 191 | 202 | |
| 192 | 203 | public function upgrade(){ |
| 193 | - global $wpdb; | |
| 204 | + global $wpdb,$wppmfunction; | |
| 194 | 205 | $installed_version = get_option( 'wppm_version' ); |
| 195 | 206 | $installed_version = $installed_version ? $installed_version : 0; |
| 196 | 207 | if($installed_version < '1.0.0'){ |
| 197 | 208 | //User Roles |
| @@ -311,8 +322,11 @@ | ||
| 311 | 322 | } |
| 312 | 323 | update_option( |
| 313 | 324 | 'wppm-ap-project-list', |
| 314 | 325 | array( |
| 326 | + 'list-header-button-background-color' => '#0052CC', | |
| 327 | + 'list-header-button-hover-color' => '#0065ff', | |
| 328 | + 'list-header-button-text-color' => '#fff', | |
| 315 | 329 | 'list-header-background-color' => '#304FFE', |
| 316 | 330 | 'list-header-text-color' => '#fff', |
| 317 | 331 | 'list-item-odd-background-color' => '#fff', |
| 318 | 332 | 'list-item-odd-text-color' => '#2C3E50', |
| @@ -524,8 +538,98 @@ | ||
| 524 | 538 | update_option('wppm_display_time_duration_project',0); |
| 525 | 539 | update_option('wppm_display_time_duration_task',0); |
| 526 | 540 | |
| 527 | 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 | + } | |
| 528 | 632 | // update wppm_version option to plugin version |
| 529 | 633 | update_option( 'wppm_version', WPPM_VERSION ); |
| 530 | 634 | } |
| 531 | 635 | } |
| @@ -531,5 +635,5 @@ | ||
| 531 | 635 | } |
| 532 | 636 | |
| 533 | 637 | endif; |
| 534 | 638 | |
| 535 | -new WPPM_Install(); | |
| 639 | +new WPPM_Install(); | |