| 1 |
<?php |
| 2 |
//if accessed directly exit |
| 3 |
if (!defined('ABSPATH')) exit; |
| 4 |
|
| 5 |
use FluentBoards\App\Services\Helper; |
| 6 |
|
| 7 |
/** |
| 8 |
* All registered action's handlers should be in app\Hooks\Handlers, |
| 9 |
* addAction is similar to add_action and addCustomAction is just a |
| 10 |
* wrapper over add_action which will add a prefix to the hook name |
| 11 |
* using the plugin slug to make it unique in all WordPress plugins, |
| 12 |
* ex: $app->addCustomAction('foo', ['FooHandler', 'handleFoo']) is |
| 13 |
* equivalent to add_action('slug-foo', ['FooHandler', 'handleFoo']). |
| 14 |
*/ |
| 15 |
|
| 16 |
/** |
| 17 |
* @var $app FluentBoards\Framework\Foundation\Application |
| 18 |
*/ |
| 19 |
|
| 20 |
(new \FluentBoards\App\Hooks\Handlers\AdminMenuHandler())->register(); |
| 21 |
|
| 22 |
//$app->addCustomAction('task_prop_changed', 'ActivityHandler@logActivity', 10, 3); |
| 23 |
$app->addCustomAction('task_board_changed', 'ActivityHandler@logMoveTaskToAnotherBoardActivity', 10, 2); //will call from service after board change code merged |
| 24 |
$app->addCustomAction('task_date_changed', 'ActivityHandler@logDueDateActivity', 10, 3); |
| 25 |
$app->addCustomAction('task_priority_changed', 'ActivityHandler@logPriorityChangeActivity', 10, 2); |
| 26 |
$app->addCustomAction('task_comment_added', 'ActivityHandler@logCommentCreateActivity', 10, 1); |
| 27 |
$app->addCustomAction('task_comment_updated', 'ActivityHandler@logCommentUpdateActivity', 10, 3); |
| 28 |
$app->addCustomAction('task_comment_deleted', 'ActivityHandler@logCommentDeleteActivity', 10, 2); |
| 29 |
$app->addCustomAction('subtask_added', 'ActivityHandler@logSubtaskAddedActivity', 10, 2); |
| 30 |
$app->addCustomAction('subtask_deleted_activity', 'ActivityHandler@logSubtaskDeletedActivity', 10, 2); |
| 31 |
$app->addCustomAction('task_completed_activity', 'ActivityHandler@logTaskCompletedOrReopenActivity', 10, 2); |
| 32 |
$app->addCustomAction('task_moved_to_new_stage', 'ActivityHandler@logTaskStageUpdatedActivity', 10, 2); |
| 33 |
$app->addCustomAction('task_assignee_changed', 'ActivityHandler@logAssigneeChangeActivity', 10, 3); |
| 34 |
$app->addCustomAction('task_added_from_fluent_form', 'ActivityHandler@taskAddedFromFluentForms', 10, 1); |
| 35 |
$app->addCustomAction('task_created', 'ActivityHandler@logTaskCreationActivity', 10, 1); |
| 36 |
$app->addCustomAction('task_content_updated', 'ActivityHandler@logTaskContentUpdatedActivity', 10, 3); |
| 37 |
$app->addCustomAction('task_deleted', 'TaskHandler@taskDeleted', 10, 1); |
| 38 |
|
| 39 |
$app->addCustomAction('board_created', 'BoardHandler@boardCreated', 10, 1); |
| 40 |
$app->addCustomAction('before_board_deleted', 'BoardHandler@beforeBoardDeleted', 10, 2); |
| 41 |
$app->addCustomAction('board_deleted', 'BoardHandler@boardDeleted', 10, 1); |
| 42 |
$app->addCustomAction('board_updated', 'BoardHandler@boardUpdated', 10, 2); |
| 43 |
$app->addCustomAction('board_stage_updated', 'BoardHandler@boardStageUpdated', 10, 3); |
| 44 |
$app->addCustomAction('board_stage_moved', 'BoardHandler@boardStageMoved', 10, 2); |
| 45 |
$app->addCustomAction('board_stage_dragged', 'BoardHandler@boardStageDragged', 10, 1); |
| 46 |
$app->addCustomAction('board_stage_added', 'BoardHandler@boardStageAdded', 10, 2); |
| 47 |
$app->addCustomAction('stage_deleted', 'BoardHandler@boardStageDeleted', 10, 2); |
| 48 |
$app->addCustomAction('board_stage_archived', 'BoardHandler@boardStageArchived', 10, 2); |
| 49 |
$app->addCustomAction('board_stage_restored', 'BoardHandler@boardArchivedStageRestore', 10, 2); |
| 50 |
$app->addCustomAction('task_created', 'BoardHandler@taskCreatedOnBoard', 10, 1); |
| 51 |
$app->addCustomAction('before_task_deleted', 'BoardHandler@beforeTaskDeleted', 10, 2); |
| 52 |
$app->addCustomAction('task_deleted', 'BoardHandler@taskdeleted', 10, 1); |
| 53 |
$app->addCustomAction('task_moved_from_board', 'BoardHandler@taskMovedFromBoard', 10, 3); |
| 54 |
$app->addCustomAction('board_task_archived', 'BoardHandler@taskarchivedOnBoard', 10, 1); |
| 55 |
$app->addCustomAction('board_member_added', 'BoardHandler@boardMemberAdded', 10, 2); |
| 56 |
$app->addCustomAction('board_member_removed', 'BoardHandler@boardMemberRemoved', 10, 2); |
| 57 |
$app->addCustomAction('board_admin_added', 'BoardHandler@boardAdminAdded', 10, 2); |
| 58 |
$app->addCustomAction('board_admin_removed', 'BoardHandler@boardAdminRemoved', 10, 2); |
| 59 |
$app->addCustomAction('associate_user_add_change_remove_activity', 'ActivityHandler@associateUserAddChangeRemoveActivity', 10, 3); |
| 60 |
$app->addCustomAction('task_assignee_leave', 'ActivityHandler@taskAssigneeLeave', 10, 1); |
| 61 |
$app->addCustomAction('task_assignee_join', 'ActivityHandler@taskAssigneeJoin', 10, 1); |
| 62 |
$app->addCustomAction('task_label', 'ActivityHandler@taskLabelActivity', 10, 3); |
| 63 |
$app->addCustomAction('label_manage_for_task_activity', 'ActivityHandler@labelManageForTaskActivity', 10, 2); |
| 64 |
$app->addCustomAction('board_label', 'BoardHandler@boardLabelActivity', 10, 2); |
| 65 |
$app->addCustomAction('board_stages_reordered', 'BoardHandler@boardStagesReOrdered', 10, 2); |
| 66 |
|
| 67 |
|
| 68 |
$app->addCustomAction('task_comment_added', 'NotificationHandler@addCommentNotification', 10, 1); |
| 69 |
$app->addCustomAction('mention_comment_notification', 'NotificationHandler@mentionInCommentNotification', 10, 3); |
| 70 |
$app->addCustomAction('subtask_added', 'NotificationHandler@addSubtaskNotification', 10, 2); |
| 71 |
$app->addCustomAction('task_date_changed', 'NotificationHandler@changeDateNotification', 10, 2); |
| 72 |
$app->addCustomAction('task_moved_to_new_stage', 'NotificationHandler@changeStageNotification', 10, 2); |
| 73 |
$app->addCustomAction('task_priority_changed', 'NotificationHandler@changePriorityNotification', 10, 2); |
| 74 |
$app->addCustomAction('board_task_archived', 'NotificationHandler@taskArchiveNotification', 10, 1); |
| 75 |
$app->addCustomAction('task_content_updated', 'NotificationHandler@changeTitleOrDescriptionNotification', 10, 3); |
| 76 |
//$app->addCustomAction('description_changed_notification', 'NotificationHandler@changeDescriptionNotification', 10, 1); |
| 77 |
$app->addCustomAction('board_changed_notification', 'NotificationHandler@changeBoardNotification', 10, 2); |
| 78 |
$app->addCustomAction('task_assignee_changed', 'NotificationHandler@assigneeAddedNotification', 10, 3); |
| 79 |
|
| 80 |
|
| 81 |
$app->addCustomAction('one_time_schedule_send_email_for_comment', 'ScheduleHandler@sendEmailForComment', 10, 3); |
| 82 |
$app->addCustomAction('one_time_schedule_send_email_for_add_assignee', 'ScheduleHandler@sendEmailForAddAssignee', 10, 3); |
| 83 |
$app->addCustomAction('one_time_schedule_send_email_for_remove_assignee', 'ScheduleHandler@sendEmailForRemoveAssignee', 10, 3); |
| 84 |
$app->addCustomAction('one_time_schedule_send_email_for_stage_change', 'ScheduleHandler@sendEmailForChangeStage', 10, 3); |
| 85 |
|
| 86 |
//Todo:: update handler |
| 87 |
$app->addCustomAction('one_time_schedule_send_email_for_due_date_update', 'ScheduleHandler@sendEmailForDueDateUpdate', 10, 3); |
| 88 |
$app->addCustomAction('one_time_schedule_send_email_for_task_archived', 'ScheduleHandler@sendEmailForArchivedTask', 10, 3); |
| 89 |
$app->addCustomAction('one_time_schedule_send_email_for_removed_from_task', 'ScheduleHandler@sendEmailForChangeStage', 10, 3); |
| 90 |
|
| 91 |
$app->addCustomAction('task_attachment_added', 'ActivityHandler@taskAttachmentAdded', 10, 1); |
| 92 |
$app->addCustomAction('task_attachment_deleted', 'ActivityHandler@taskAttachmentDeleted', 10, 1); |
| 93 |
$app->addCustomAction('task_attachment_deleted', 'TaskHandler@taskAttachmentDeleted', 10, 1); |
| 94 |
$app->addAction('deleted_user', 'BoardHandler@deleteUserRelatedData', 10, 3); |
| 95 |
$app->addAction('delete_attachment', 'FileHandler@mediaFileDeleted', 10, 1); |
| 96 |
|
| 97 |
$app->addCustomAction('send_invitation', 'ScheduleHandler@sendInvitationViaEmail', 10, 3); |
| 98 |
|
| 99 |
|
| 100 |
if (defined('WP_CLI') && WP_CLI) { |
| 101 |
\WP_CLI::add_command('fluent_boards', '\FluentBoards\App\Hooks\Cli\Commands'); |
| 102 |
} |
| 103 |
|
| 104 |
|
| 105 |
add_action('init', function () { |
| 106 |
if (!isset($_REQUEST['fbs'])) { |
| 107 |
return; |
| 108 |
} |
| 109 |
}); |
| 110 |
|
| 111 |
|
| 112 |
/* |
| 113 |
* IMPORTANT |
| 114 |
* External Pages Handler |
| 115 |
* Each Request must have fbs=1 as a query parameter, then the plugin will handle the request. |
| 116 |
*/ |
| 117 |
if(isset($_GET['fbs']) && $_GET['fbs'] == 1) { |
| 118 |
|
| 119 |
// For viewing attachment |
| 120 |
if(isset($_GET['route']) && ($_GET['route'] == 'task')) { |
| 121 |
add_action('init', function() { |
| 122 |
(new \FluentBoardsPro\App\Hooks\Handlers\ExternalPages())->handleTaskWebhook(); |
| 123 |
}); |
| 124 |
} |
| 125 |
|
| 126 |
} |
| 127 |
|