1: <?php
2: declare(strict_types=1);
3: /**
4: * Copyright (C) Apis Networks, Inc - All Rights Reserved.
5: *
6: * Unauthorized copying of this file, via any medium, is
7: * strictly prohibited without consent. Any dissemination of
8: * material herein is prohibited.
9: *
10: * For licensing inquiries email <licensing@apisnetworks.com>
11: *
12: * Written by Matt Saladna <matt@apisnetworks.com>, July 2017
13: */
14:
15: /**
16: * User tracking, trouble tickets
17: *
18: * @package core
19: */
20: class Crm_Module extends Module_Skeleton
21: {
22: const FROM_ADDRESS = CRM_FROM_ADDRESS;
23:
24: // @ignore
25: const REPLY_ADDRESS = CRM_REPLY_ADDRESS;
26: const FROM_NAME = CRM_FROM_NAME;
27: const FROM_NO_REPLY_ADDRESS = CRM_FROM_NO_REPLY_ADDRESS;
28: const MAX_SMS_LENGTH = 150;
29: // lowercase list of ticket subject priorities that cannot change
30: const COPY_ADMIN = CRM_COPY_ADMIN;
31:
32: const TICKET_STCLOSE = 'close';
33: const TICKET_STAPPEND = 'append';
34: const TICKET_STOPEN = 'open';
35: const PRIORITIES = array('normal', 'high', 'outage');
36: const LOW_PRIORITY_SUBJECTS = array('billing');
37:
38: // @var string
39: // @ignore
40: const SHORT_COPY_ADMIN = CRM_SHORT_COPY_ADMIN;
41:
42: // @ignore
43: private static $CRM_SERVER_HOST = CRM_TICKET_HOST;
44: // @ignore
45: private static $CRM_SERVER_USER = CRM_TICKET_USER;
46: // @ignore
47: private static $CRM_SERVER_PASSWORD = CRM_TICKET_PASSWORD;
48: // @ignore
49: private static $CRM_SERVER_DATABASE = CRM_TICKET_DB;
50:
51: /**
52: * void __construct(void)
53: *
54: * @ignore
55: */
56: public function __construct()
57: {
58: parent::__construct();
59: $this->exportedFunctions = array(
60: '*' => PRIVILEGE_SITE | PRIVILEGE_ADMIN,
61: 'append_ticket_via_email' => PRIVILEGE_ADMIN,
62: 'get_notifications' => PRIVILEGE_ALL,
63: 'cancel_notification' => PRIVILEGE_ALL,
64: 'configured' => PRIVILEGE_ALL
65:
66: );
67: }
68:
69: /**
70: * CRM enabled for user
71: *
72: * @return bool
73: */
74: public function enabled(): bool
75: {
76: return $this->configured() &&
77: ($this->permission_level & PRIVILEGE_ADMIN || !$this->getServiceValue('billing', 'parent_invoice'));
78: }
79:
80: /**
81: * Verify CRM module is configured
82: *
83: * @return bool
84: */
85: public function configured(): bool
86: {
87: return false;
88: }
89:
90: /**
91: * Get pending notifications
92: *
93: * @return array
94: */
95: public function get_notifications(): array
96: {
97: return [];
98: }
99: }
100: