69 lines
2.2 KiB
PHP
69 lines
2.2 KiB
PHP
<?php
|
|
defined('BASEPATH') or exit('No direct script access allowed');
|
|
|
|
/*
|
|
Module Name: Project Notifications
|
|
Description: This module will allow you to create automated notifications for projects that have had activity.
|
|
Version: 1.0.0
|
|
*/
|
|
|
|
define('PROJECT_NOTIFICATIONS_MODULE_NAME', 'project_notifications');
|
|
|
|
hooks()->add_action('after_cron_run', 'execute_project_notification');
|
|
hooks()->add_action('admin_init', 'project_notifications_module_init_menu_items');
|
|
hooks()->add_action('admin_init', 'project_notifications_permissions');
|
|
|
|
function execute_project_notification($id = "")
|
|
{
|
|
$CI = &get_instance();
|
|
$CI->load->library(PROJECT_NOTIFICATIONS_MODULE_NAME . '/' . 'project_notifications_module');
|
|
$CI->project_notifications_module->executeNotification($id);
|
|
}
|
|
|
|
|
|
function project_notifications_permissions()
|
|
{
|
|
$capabilities = [];
|
|
|
|
$capabilities['capabilities'] = [
|
|
'view' => _l('permission_view') . '(' . _l('permission_global') . ')',
|
|
'create' => _l('permission_create'),
|
|
'create_template' => _l('permission_create'),
|
|
'edit' => _l('permission_edit'),
|
|
'delete' => _l('permission_delete'),
|
|
];
|
|
|
|
register_staff_capabilities('project_notifications', $capabilities, _l('pn_title'));
|
|
}
|
|
|
|
register_activation_hook(PROJECT_NOTIFICATIONS_MODULE_NAME, 'project_notifications_module_activation_hook');
|
|
|
|
function project_notifications_module_activation_hook()
|
|
{
|
|
$CI = &get_instance();
|
|
|
|
require_once(__DIR__ . '/install.php');
|
|
}
|
|
|
|
register_language_files(PROJECT_NOTIFICATIONS_MODULE_NAME, [PROJECT_NOTIFICATIONS_MODULE_NAME]);
|
|
|
|
function project_notifications_module_init_menu_items()
|
|
{
|
|
$CI = &get_instance();
|
|
|
|
$CI->app->add_quick_actions_link([
|
|
'name' => _l('pn_title'),
|
|
'url' => 'project_notifications/notify',
|
|
'permission' => 'project_notifications',
|
|
'position' => 56,
|
|
]);
|
|
|
|
if (has_permission('pa_notify', '', 'view')) {
|
|
$CI->app_menu->add_sidebar_children_item('utilities', [
|
|
'slug' => 'project-notifications',
|
|
'name' => _l('pn_title'),
|
|
'href' => admin_url('project_notifications'),
|
|
'position' => 24,
|
|
]);
|
|
}
|
|
} |