| @@ -128,9 +128,9 @@ | ||
| 128 | 128 | 'remind_at' => 'sanitize_text_field', |
| 129 | 129 | 'scope' => 'sanitize_text_field', |
| 130 | 130 | 'source' => 'sanitize_text_field', |
| 131 | 131 | 'source_id' => 'sanitize_text_field', |
| 132 | - 'description' => 'wp_kses_post', | |
| 132 | + 'description' => 'fluent_boards_sanitize_description', | |
| 133 | 133 | 'due_date' => 'sanitize_text_field', |
| 134 | 134 | 'start_at' => 'sanitize_text_field', |
| 135 | 135 | 'log_minutes' => 'sanitize_text_field', |
| 136 | 136 | 'last_completed' => 'sanitize_text_field', |
| @@ -154,9 +154,9 @@ | ||
| 154 | 154 | 'board_id' => 'intval', |
| 155 | 155 | 'title' => 'sanitize_text_field', |
| 156 | 156 | 'parent_id' => 'intval', |
| 157 | 157 | 'type' => 'sanitize_text_field', |
| 158 | - 'description' => 'wp_kses_post', | |
| 158 | + 'description' => 'fluent_boards_sanitize_description', | |
| 159 | 159 | 'currency' => 'sanitize_text_field', |
| 160 | 160 | 'image_url' => 'sanitize_url', |
| 161 | 161 | 'is_auth_require' => 'intval', |
| 162 | 162 | 'crm_contact_id' => 'intval', |
| @@ -162,8 +162,9 @@ | ||
| 162 | 162 | 'crm_contact_id' => 'intval', |
| 163 | 163 | 'id' => 'sanitize_text_field', |
| 164 | 164 | 'is_image' => 'rest_sanitize_boolean', |
| 165 | 165 | 'color' => 'sanitize_text_field', // sanitize_hex_color doesn't work when color code is greater than 6 characters |
| 166 | + 'reset' => 'rest_sanitize_boolean', | |
| 166 | 167 | 'created_by' => 'intval', |
| 167 | 168 | ]; |
| 168 | 169 | |
| 169 | 170 | return self::sanitizeData($data, $fieldMaps); |
| @@ -197,8 +198,9 @@ | ||
| 197 | 198 | { |
| 198 | 199 | $fieldMaps = [ |
| 199 | 200 | 'bg_color' => 'sanitize_text_field', |
| 200 | 201 | 'color' => 'sanitize_text_field', |
| 202 | + 'color_preset' => 'sanitize_key', | |
| 201 | 203 | 'label' => 'sanitize_text_field', |
| 202 | 204 | 'boardId' => 'intval', |
| 203 | 205 | 'task_id' => 'intval', |
| 204 | 206 | 'meta_value' => 'intval', |
| @@ -214,14 +216,31 @@ | ||
| 214 | 216 | 'stage' => 'sanitize_text_field', |
| 215 | 217 | 'newPosition' => 'intval', |
| 216 | 218 | 'priority' => 'sanitize_text_field', |
| 217 | 219 | 'type' => 'sanitize_text_field', |
| 220 | + 'description' => 'fluent_boards_sanitize_description', | |
| 221 | + 'group_id' => 'intval', | |
| 218 | 222 | 'board_id' => 'intval', |
| 219 | 223 | 'created_by' => 'intval', |
| 220 | 224 | 'due_date' => 'sanitize_text_field', |
| 225 | + 'due_at' => 'sanitize_text_field', | |
| 226 | + 'started_at' => 'sanitize_text_field', | |
| 227 | + 'reminder_type' => 'sanitize_text_field', | |
| 228 | + 'remind_at' => 'sanitize_text_field', | |
| 229 | + 'add_to_top' => 'rest_sanitize_boolean', | |
| 221 | 230 | ]; |
| 222 | 231 | |
| 223 | - return self::sanitizeData($data, $fieldMaps); | |
| 232 | + $data = self::sanitizeData($data, $fieldMaps); | |
| 233 | + | |
| 234 | + if (!empty($data['assignees']) && is_array($data['assignees'])) { | |
| 235 | + $data['assignees'] = array_slice(array_filter(array_map('intval', $data['assignees'])), 0, 1); | |
| 236 | + } | |
| 237 | + | |
| 238 | + if (!empty($data['labels']) && is_array($data['labels'])) { | |
| 239 | + $data['labels'] = array_filter(array_map('intval', $data['labels'])); | |
| 240 | + } | |
| 241 | + | |
| 242 | + return $data; | |
| 224 | 243 | } |
| 225 | 244 | |
| 226 | 245 | public static function createActivity($data) |
| 227 | 246 | { |
| @@ -416,9 +435,10 @@ | ||
| 416 | 435 | |
| 417 | 436 | return $users; |
| 418 | 437 | } |
| 419 | 438 | |
| 420 | - public static function sanitizeUsersArray($users, $boardId = null) | |
| 439 | + // Callers formatting multiple lists may supply a resolved board-manager result. | |
| 440 | + public static function sanitizeUsersArray($users, $boardId = null, $isBoardManager = null) | |
| 421 | 441 | { |
| 422 | 442 | if (current_user_can('list_users')) { |
| 423 | 443 | return $users; |
| 424 | 444 | } |
| @@ -424,9 +444,9 @@ | ||
| 424 | 444 | } |
| 425 | 445 | |
| 426 | 446 | $sanitizedUsers = []; |
| 427 | 447 | |
| 428 | - if(!PermissionManager::isBoardManager($boardId)) //Todo: may create permission security issue, will be modified later | |
| 448 | + if (!($isBoardManager ?? PermissionManager::isBoardManager($boardId))) | |
| 429 | 449 | { |
| 430 | 450 | $currentUser = wp_get_current_user(); |
| 431 | 451 | if($currentUser && isset($currentUser->user_email)){ |
| 432 | 452 | $currentUserEmail = $currentUser->user_email; |
| @@ -481,18 +501,26 @@ | ||
| 481 | 501 | public static function getPriorityOptions() |
| 482 | 502 | { |
| 483 | 503 | return [ |
| 484 | 504 | [ |
| 485 | - 'id' => 'low', | |
| 486 | - 'title' => 'Low' | |
| 505 | + 'id' => '', | |
| 506 | + 'title' => 'No priority' | |
| 487 | 507 | ], |
| 488 | 508 | [ |
| 509 | + 'id' => 'urgent', | |
| 510 | + 'title' => 'Urgent' | |
| 511 | + ], | |
| 512 | + [ | |
| 513 | + 'id' => 'high', | |
| 514 | + 'title' => 'High' | |
| 515 | + ], | |
| 516 | + [ | |
| 489 | 517 | 'id' => 'medium', |
| 490 | 518 | 'title' => 'Medium' |
| 491 | 519 | ], |
| 492 | 520 | [ |
| 493 | - 'id' => 'high', | |
| 494 | - 'title' => 'High' | |
| 521 | + 'id' => 'low', | |
| 522 | + 'title' => 'Low' | |
| 495 | 523 | ], |
| 496 | 524 | ]; |
| 497 | 525 | } |
| 498 | 526 | |
| @@ -570,8 +598,9 @@ | ||
| 570 | 598 | 'repeat_in' => 'intval', |
| 571 | 599 | 'repeat_type' => 'sanitize_text_field', |
| 572 | 600 | 'repeat_when_complete' => 'intval', |
| 573 | 601 | 'selected_month' => 'sanitize_text_field', |
| 602 | + 'selected_stage' => 'intval', | |
| 574 | 603 | 'board_id' => 'intval', |
| 575 | 604 | 'time' => 'sanitize_text_field', |
| 576 | 605 | 'time_zone' => 'sanitize_text_field', |
| 577 | 606 | 'next_repeat_date' => 'sanitize_text_field', |
| @@ -580,8 +609,27 @@ | ||
| 580 | 609 | |
| 581 | 610 | return self::sanitizeData($data, $fieldMaps); |
| 582 | 611 | } |
| 583 | 612 | |
| 613 | + /** | |
| 614 | + * Sanitize the author snapshot supplied by an external task integration. | |
| 615 | + * | |
| 616 | + * @param mixed $author | |
| 617 | + * @return array | |
| 618 | + */ | |
| 619 | + private static function sanitizeExternalTaskAuthor($author) | |
| 620 | + { | |
| 621 | + if (!is_array($author)) { | |
| 622 | + return []; | |
| 623 | + } | |
| 624 | + | |
| 625 | + return array_filter([ | |
| 626 | + 'name' => sanitize_text_field($author['name'] ?? ''), | |
| 627 | + 'email' => sanitize_email($author['email'] ?? ''), | |
| 628 | + 'photo' => esc_url_raw($author['photo'] ?? ''), | |
| 629 | + ]); | |
| 630 | + } | |
| 631 | + | |
| 584 | 632 | public static function sanitizeTaskForWebHook($data) |
| 585 | 633 | { |
| 586 | 634 | $fieldMaps = [ |
| 587 | 635 | 'title' => 'sanitize_text_field', |
| @@ -595,9 +643,10 @@ | ||
| 595 | 643 | 'lead_value' => 'doubleval', |
| 596 | 644 | 'remind_at' => 'sanitize_text_field', |
| 597 | 645 | 'scope' => 'sanitize_text_field', |
| 598 | 646 | 'source' => 'sanitize_text_field', |
| 599 | - 'description' => 'wp_kses_post', | |
| 647 | + 'source_id' => 'sanitize_text_field', | |
| 648 | + 'description' => 'fluent_boards_sanitize_description', | |
| 600 | 649 | 'due_date' => 'sanitize_text_field', |
| 601 | 650 | 'start_at' => 'sanitize_text_field', |
| 602 | 651 | 'log_minutes' => 'sanitize_text_field', |
| 603 | 652 | 'last_completed' => 'sanitize_text_field', |
| @@ -610,9 +659,19 @@ | ||
| 610 | 659 | 'position' => 'intval' |
| 611 | 660 | |
| 612 | 661 | ]; |
| 613 | 662 | |
| 614 | - return self::sanitizeData($data, $fieldMaps); | |
| 663 | + $data = self::sanitizeData($data, $fieldMaps); | |
| 664 | + | |
| 665 | + if (isset($data['settings']) && is_array($data['settings']) && isset($data['settings']['author'])) { | |
| 666 | + $data['settings'] = [ | |
| 667 | + 'author' => self::sanitizeExternalTaskAuthor($data['settings']['author']), | |
| 668 | + ]; | |
| 669 | + } else { | |
| 670 | + unset($data['settings']); | |
| 671 | + } | |
| 672 | + | |
| 673 | + return $data; | |
| 615 | 674 | } |
| 616 | 675 | |
| 617 | 676 | |
| 618 | 677 | public static function taskReminderTypes() |
| @@ -647,8 +706,9 @@ | ||
| 647 | 706 | 'deleted' => __('deleted', 'fluent-boards'), |
| 648 | 707 | 'archived' => __('archived', 'fluent-boards'), |
| 649 | 708 | 'restored' => __('restored', 'fluent-boards'), |
| 650 | 709 | 'set' => __('set', 'fluent-boards'), |
| 710 | + 'moved' => __('moved', 'fluent-boards'), | |
| 651 | 711 | ]; |
| 652 | 712 | |
| 653 | 713 | $columnTranslations = [ |
| 654 | 714 | 'task' => __('task', 'fluent-boards'), |
| @@ -668,11 +728,15 @@ | ||
| 668 | 728 | 'the associate email' => __('the associate email', 'fluent-boards'), |
| 669 | 729 | 'attachment' => __('attachment', 'fluent-boards'), |
| 670 | 730 | 'repeat task' => __('repeat task', 'fluent-boards'), |
| 671 | 731 | 'Repeat Task' => __('Repeat Task', 'fluent-boards'), |
| 732 | + 'tasks' => __('tasks', 'fluent-boards'), | |
| 672 | 733 | ]; |
| 673 | 734 | |
| 674 | 735 | foreach ($activities as $activity) { |
| 736 | + $activity->action_key = $activity->action; | |
| 737 | + $activity->column_key = $activity->column; | |
| 738 | + | |
| 675 | 739 | if (isset($actionTranslations[$activity->action])) { |
| 676 | 740 | $activity->action = $actionTranslations[$activity->action]; |
| 677 | 741 | } |
| 678 | 742 | if (isset($columnTranslations[$activity->column])) { |