forked from coopsymbiotic/ncn-civi-zoom
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ncn_civi_zoom.php
598 lines (541 loc) · 21.4 KB
/
ncn_civi_zoom.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
<?php
require_once 'ncn_civi_zoom.civix.php';
require_once __DIR__.'/vendor/autoload.php';
define('ZOOM_SETTINGS', 'Zoom_Settings');
use CRM_NcnCiviZoom_ExtensionUtil as E;
// use Lcobucci\JWT\Configuration;
// use Lcobucci\JWT\Signer;
// use Lcobucci\JWT\Signer\Key;
// use Dotenv\Dotenv;
// Load .env file
// $dotenv = Dotenv::createImmutable(__DIR__);
// $dotenv->load();
function ncn_civi_zoom_civicrm_alterAPIPermissions($entity, $action, &$params, &$permissions)
{
$permissions['event']['generatewebinarattendance'] = array('access CiviEvent');
}
/**
* Implements hook_civicrm_config().
*
* @link https://docs.civicrm.org/dev/en/latest/hooks/hook_civicrm_config/
*/
function ncn_civi_zoom_civicrm_config(&$config) {
_ncn_civi_zoom_civix_civicrm_config($config);
}
/**
* Implements hook_civicrm_xmlMenu().
*
* @link https://docs.civicrm.org/dev/en/latest/hooks/hook_civicrm_xmlMenu
*/
function ncn_civi_zoom_civicrm_xmlMenu(&$files) {
_ncn_civi_zoom_civix_civicrm_xmlMenu($files);
}
/**
* Implements hook_civicrm_install().
*
* @link https://docs.civicrm.org/dev/en/latest/hooks/hook_civicrm_install
*/
function ncn_civi_zoom_civicrm_install() {
_ncn_civi_zoom_civix_civicrm_install();
}
/**
* Implements hook_civicrm_postInstall().
*
* @link https://docs.civicrm.org/dev/en/latest/hooks/hook_civicrm_postInstall
*/
function ncn_civi_zoom_civicrm_postInstall() {
$settings['base_url'] = "https://api.zoom.us/v2";
CRM_Core_BAO_Setting::setItem($settings, ZOOM_SETTINGS, 'zoom_settings');
CRM_NcnCiviZoom_Utils::forUpgrade1003();
CRM_NcnCiviZoom_Utils::forUpgrade1004();
CRM_NcnCiviZoom_Utils::forUpgrade1006();
CRM_NcnCiviZoom_Utils::forUpgrade1007();
CRM_NcnCiviZoom_Utils::checkAndCreateZoomDataSyncCG();
CRM_NcnCiviZoom_Utils::checkAndCreateZoomPartJoinLinkCF();
_ncn_civi_zoom_civix_civicrm_postInstall();
}
/**
* Implements hook_civicrm_uninstall().
*
* @link https://docs.civicrm.org/dev/en/latest/hooks/hook_civicrm_uninstall
*/
function ncn_civi_zoom_civicrm_uninstall() {
_ncn_civi_zoom_civix_civicrm_uninstall();
}
/**
* Implements hook_civicrm_enable().
*
* @link https://docs.civicrm.org/dev/en/latest/hooks/hook_civicrm_enable
*/
function ncn_civi_zoom_civicrm_enable() {
_ncn_civi_zoom_civix_civicrm_enable();
}
/**
* Implements hook_civicrm_disable().
*
* @link https://docs.civicrm.org/dev/en/latest/hooks/hook_civicrm_disable
*/
function ncn_civi_zoom_civicrm_disable() {
_ncn_civi_zoom_civix_civicrm_disable();
}
/**
* Implements hook_civicrm_upgrade().
*
* @link https://docs.civicrm.org/dev/en/latest/hooks/hook_civicrm_upgrade
*/
function ncn_civi_zoom_civicrm_upgrade($op, CRM_Queue_Queue $queue = NULL) {
CRM_Civirules_Utils_Upgrader::insertActionsFromJson(__DIR__ . '/civirules_actions.json');
return _ncn_civi_zoom_civix_civicrm_upgrade($op, $queue);
}
/**
* Implements hook_civicrm_managed().
*
* Generate a list of entities to create/deactivate/delete when this module
* is installed, disabled, uninstalled.
*
* @link https://docs.civicrm.org/dev/en/latest/hooks/hook_civicrm_managed
*/
function ncn_civi_zoom_civicrm_managed(&$entities) {
_ncn_civi_zoom_civix_civicrm_managed($entities);
}
/**
* Implements hook_civicrm_caseTypes().
*
* Generate a list of case-types.
*
* Note: This hook only runs in CiviCRM 4.4+.
*
* @link https://docs.civicrm.org/dev/en/latest/hooks/hook_civicrm_caseTypes
*/
function ncn_civi_zoom_civicrm_caseTypes(&$caseTypes) {
_ncn_civi_zoom_civix_civicrm_caseTypes($caseTypes);
}
/**
* Implements hook_civicrm_angularModules().
*
* Generate a list of Angular modules.
*
* Note: This hook only runs in CiviCRM 4.5+. It may
* use features only available in v4.6+.
*
* @link https://docs.civicrm.org/dev/en/latest/hooks/hook_civicrm_angularModules
*/
function ncn_civi_zoom_civicrm_angularModules(&$angularModules) {
_ncn_civi_zoom_civix_civicrm_angularModules($angularModules);
}
/**
* Implements hook_civicrm_alterSettingsFolders().
*
* @link https://docs.civicrm.org/dev/en/latest/hooks/hook_civicrm_alterSettingsFolders
*/
function ncn_civi_zoom_civicrm_alterSettingsFolders(&$metaDataFolders = NULL) {
_ncn_civi_zoom_civix_civicrm_alterSettingsFolders($metaDataFolders);
}
/**
* Implements hook_civicrm_entityTypes().
*
* Declare entity types provided by this module.
*
* @link https://docs.civicrm.org/dev/en/latest/hooks/hook_civicrm_entityTypes
*/
function ncn_civi_zoom_civicrm_entityTypes(&$entityTypes) {
_ncn_civi_zoom_civix_civicrm_entityTypes($entityTypes);
}
/**
* Implements hook_civicrm_thems().
*/
function ncn_civi_zoom_civicrm_themes(&$themes) {
_ncn_civi_zoom_civix_civicrm_themes($themes);
}
// --- Functions below this ship commented out. Uncomment as required. ---
function _ncn_civi_zoom_civicrm_getKeysMultidimensional(array $array) {
$keys = array();
foreach($array as $key => $value)
{
$keys[] = $key;
if( is_array($value) ) {
$keys = array_merge($keys, _ncn_civi_zoom_civicrm_getKeysMultidimensional($value));
}
}
return $keys;
}
function ncn_civi_zoom_civicrm_permission(&$permissions) {
$prefix = ts('NcnCiviZoom') . ': '; // name of extension or module
$permissions['administer Zoom'] = $prefix . ts('administer Zoom');
}
/**
* Implements hook_civicrm_navigationMenu().
*
* @link https://docs.civicrm.org/dev/en/latest/hooks/hook_civicrm_navigationMenu
*
*/
function ncn_civi_zoom_civicrm_navigationMenu(&$menu) {
$parentId = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_Navigation', 'Administer', 'id', 'name');
$maxId = max(_ncn_civi_zoom_civicrm_getKeysMultidimensional($menu));
$zoomSettingId = $maxId+1;
$zoomAccountsSettingId = $maxId+2;
$zoomDataSyncSettingId = $maxId+3;
$menu[$parentId]['child'][$zoomSettingId] = array(
'attributes' => array(
'label' => ts('Zoom Settings'),
'name' => 'Zoom_Settings',
'url' => null,
'permission' => 'administer Zoom',
'operator' => null,
'separator' => null,
'parentID' => $parentId,
'navID' => $zoomSettingId,
'active' => 1
),
);
$menu[$parentId]['child'][$zoomSettingId]['child'][$zoomAccountsSettingId] = array(
'attributes' => array(
'label' => ts('Zoom Accounts Settings'),
'name' => 'Zoom_Accounts_Settings',
'url' => CRM_Utils_System::url('civicrm/Zoom/zoomaccounts', 'reset=1'),
'permission' => 'administer Zoom',
'operator' => null,
'separator' => null,
'parentID' => $zoomSettingId,
'navID' => $zoomAccountsSettingId,
'active' => 1
),
);
$menu[$parentId]['child'][$zoomSettingId]['child'][$zoomDataSyncSettingId] = array(
'attributes' => array(
'label' => ts('Zoom Data Sync Settings'),
'name' => 'Zoom_Data_Sync_Settings',
'url' => CRM_Utils_System::url('civicrm/Zoom/zoomdatasync', 'reset=1'),
'permission' => 'administer Zoom',
'operator' => null,
'separator' => null,
'parentID' => $zoomSettingId,
'navID' => $zoomDataSyncSettingId,
'active' => 1
),
);
}
function ncn_civi_zoom_civicrm_validateForm($formName, &$fields, &$files, &$form, &$errors) {
// Throw error if tried to delete the created message template
if($formName == 'CRM_Admin_Form_MessageTemplates'){
$submitValues = $form->getVar('_submitValues');
if( !empty($submitValues['_qf_MessageTemplates_upload']) && ($submitValues['_qf_MessageTemplates_upload'] == 'Delete')){
$FormValues = $form->getVar('_values');
$msgTitle = CRM_NcnCiviZoom_Constants::SEND_ZOOM_REGISTRANTS_EMAIL_TEMPLATE_TITLE;
$msgId = CRM_NcnCiviZoom_Utils::getEmailTemplateIdToSendZoomRegistrants();
if(($FormValues['msg_title'] == $msgTitle) || ($FormValues['id'] == $msgId)){
$errors['_qf_default'] = ts("Sorry this template Can't be deleted. This was created by ncn_civi_zoom.");
}
}
}
if($formName == 'CRM_Event_Form_ManageEvent_EventInfo' && isset($form->_subType)){
$customIds['Webinar'] = CRM_NcnCiviZoom_Utils::getWebinarCustomField();
$customIds['Meeting'] = CRM_NcnCiviZoom_Utils::getMeetingCustomField();
$customFieldZoomAccount = CRM_NcnCiviZoom_Utils::getAccountIdCustomField();
$submitValues = array();
foreach ($customIds as $key => $value) {
foreach ($fields as $keys => $field) {
$tempStr = substr($keys, 0, strlen($value));
if($tempStr == $value){
//Retriving the submitted value of custom fields
$submitValues[$key] = $field;
}
}
}
//Checking whether more than one custom fields are entered
$count = 0;
$zoomEntity = NULL;
foreach ($submitValues as $key => $value) {
if(!empty($value)){
$count = $count + 1;
//Custom field id is being stored for validating the meeting/webinar id
$zoomEntity = $key;
if(isset($fields['zoom_account_list']) && $fields['zoom_account_list'] == 0){
// Return error if the account id is empty
$errors['_qf_default'] = ts('Please select a zoom account id');
}
}
if($count>1){
$errors['_qf_default'] = ts('Please enter either Webinar ID or Meeting ID, you cannot enter both');
}
}
//If the zoom account is selected but the custom fields(Webinar id or Meeting id) are empty
if(!empty($fields['zoom_account_list']) && $count == 0){
$errors['_qf_default'] = ts('Please enter either Webinar ID or Meeting ID');
}elseif (!empty($fields['zoom_account_list']) && $count == 1) {//Verifying the zoom event
$checkParams['account_id'] = $fields['zoom_account_list'];
$checkParams['entityID'] = $submitValues[$zoomEntity];
$checkParams['entity'] = $zoomEntity;
$result = CRM_CivirulesActions_Participant_AddToZoom::checkEventWithZoom($checkParams);
if(!$result['status']){
$errors['_qf_default'] = $result['message'];
}
//Validate the profile of the zoom event if it has online registration enabled
if(!empty($form->_id) && empty($errors)){
$isOnlineReg = CRM_Core_DAO::singleValueQuery("SELECT is_online_registration FROM civicrm_event WHERE id=".$form->_id);
if($isOnlineReg == 1){
$profileIds = $missingProfileFields = null;
try {
$apiResult = civicrm_api3('UFJoin', 'get', [
'sequential' => 1,
'return' => ["uf_group_id"],
'entity_id' => $form->_id,
]);
} catch (Exception $e) {
CRM_Core_Error::debug_var('ncn_civi_zoom_civicrm_validateForm error', $e);
}
if(!empty($apiResult['values'])){
foreach ($apiResult['values'] as $key => $value){
$profileIds[] = $value['uf_group_id'];
}
if(!empty($profileIds)){
$checkFields = ['first_name', 'last_name', 'email'];
$missingProfileFields = CRM_NcnCiviZoom_Utils::checkRequiredProfilesForAnEvent($profileIds, $checkFields);
}
}
if(empty($profileIds) || !empty($missingProfileFields)){
// Error message if no profiles are selected or if the required fields are missing in the selected profiles
$errors['_qf_default'] = ts('Please select a profile having the fields - first_name, last_name and email. As they are required for zoom registration');
}
}
}
}
}
//Validate the profile of the zoom event if it has online registration enabled
if($formName == 'CRM_Event_Form_ManageEvent_Registration'){
if($fields['is_online_registration'] == 1){
if(!empty($form->_id)){
$eventId = $form->_id;
$accountId = CRM_NcnCiviZoom_Utils::getZoomAccountIdByEventId($eventId);
if(!empty($accountId)){
$profileIds = $missingProfileFields = [];
$requiredFields = ['first_name', 'last_name', 'email'];
$formProfileFields = ['custom_pre_id','custom_post_id','additional_custom_pre_id','additional_custom_post_id'];
foreach ($formProfileFields as $formProfileField) {
if(!empty($fields[$formProfileField])){
$profileIds[] = $fields[$formProfileField];
}
}
if(!empty($profileIds)){
$missingProfileFields = CRM_NcnCiviZoom_Utils::checkRequiredProfilesForAnEvent($profileIds, $requiredFields);
}
if(empty($profileIds) || !empty($missingProfileFields)){
// Error message if no profiles are selected or if the required fields are missing in the selected profiles
if(!empty($missingProfileFields)){
$errors['_qf_default'] = ts('Please select a profile having the fields - first_name, last_name and email. As they are required for zoom registration');
}
}
}
}
}
}
}
/**
* Implements hook_civicrm_buildForm().
*
* Set a default value for an event price set field.
*
* @param string $formName
* @param CRM_Core_Form $form
*/
function ncn_civi_zoom_civicrm_buildForm($formName, &$form) {
//Add the zoom account list to the form once the custom datatype is loaded
if($formName == 'CRM_Custom_Form_CustomDataByType'){
if($form->_cdType == 'Event' && $form->_type == 'Event'){
$customAccountId = CRM_NcnCiviZoom_Utils::getAccountIdCustomField();
if(!empty($customAccountId)){
CRM_NcnCiviZoom_Utils::addZoomListToEventForm($form);
$templatePath = realpath(dirname(__FILE__)."/templates");
CRM_Core_Region::instance('page-body')->add(array(
'template' => "{$templatePath}/CRM/NcnCiviZoom/Event/Form/ManageEvent/Extra.tpl"
));
}
}
}
//Add the zoom account list to the form once the form is loaded
if ($formName == 'CRM_Event_Form_ManageEvent_EventInfo') {
if(($form->getAction() == CRM_Core_Action::ADD)
|| ($form->getAction() == CRM_Core_Action::UPDATE)) {
if(($form->getAction() == CRM_Core_Action::UPDATE) && ($form->controller->_QFResponseType != "json")){
return null;
}
$customAccountId = CRM_NcnCiviZoom_Utils::getAccountIdCustomField();
if(!empty($customAccountId)){
CRM_NcnCiviZoom_Utils::addZoomListToEventForm($form);
}
}
}
}
/**
* Implements hook_civicrm_postProcess().
*
* @param string $formName
* @param CRM_Core_Form $form
*/
function ncn_civi_zoom_civicrm_postProcess($formName, $form) {
if($formName == 'CRM_Event_Form_ManageEvent_EventInfo'){
$values = $form->exportValues();
$customFieldZoomAccount = CRM_NcnCiviZoom_Utils::getAccountIdCustomField();
if(isset($values['zoom_account_list']) && !empty($form->_id) && !empty($customFieldZoomAccount)){
// Preparing the api params to store the zoom account id
$createApiParams = array(
'entity_id' => $form->_id,
$customFieldZoomAccount => $values['zoom_account_list'],
);
// Trying to store the zoom joining link also
$cGName = CRM_NcnCiviZoom_Constants::CG_Event_Zoom_Notes;
$cFName = CRM_NcnCiviZoom_Constants::CF_ZOOM_JOIN_LINK;
$cGId = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_CustomGroup', $cGName, 'id', 'name');
try {
$cFDetails = civicrm_api3('CustomField', 'get', [
'name' => $cFName,
'custom_group_id' => $cGId,
]);
} catch (Exception $e) {
CRM_Core_Error::debug_var('ncn_civi_zoom_civicrm_postProcess error', $e);
CRM_Core_Error::debug_var('ncn_civi_zoom_civicrm_postProcess api calling error, entity', 'CustomField');
CRM_Core_Error::debug_var('ncn_civi_zoom_civicrm_postProcess api calling error, action', 'get');
}
if(!empty($cFDetails['id'])){
$object = new CRM_CivirulesActions_Participant_AddToZoom;
$object->event_id = $form->_id;
$joinUrl = CRM_CivirulesActions_Participant_AddToZoom::getJoinUrl($object);
if(!empty($joinUrl[0])){
$createApiParams['custom_'.$cFDetails['id']] = $joinUrl[0];
}
}
try {
civicrm_api3('CustomValue', 'create', $createApiParams);
} catch (Exception $e) {
CRM_Core_Error::debug_var('ncn_civi_zoom_civicrm_postProcess error', $e);
CRM_Core_Error::debug_var('ncn_civi_zoom_civicrm_postProcess api calling error, entity', 'CustomValue');
CRM_Core_Error::debug_var('ncn_civi_zoom_civicrm_postProcess api calling error, action', 'create');
CRM_Core_Error::debug_var('ncn_civi_zoom_civicrm_postProcess api params', $createApiParams);
}
}
}
}
function ncn_civi_zoom_civicrm_pageRun(&$page) {
$pageName = $page->getVar('_name');
if ($pageName == 'CRM_Event_Page_EventInfo') {
$templatePath = realpath(dirname(__FILE__)."/templates");
//Including the tpl file to hide the custom fields displayed for an event
CRM_Core_Region::instance('page-body')->add(array(
'template' => "{$templatePath}/CRM/NcnCiviZoom/Event/Page/Extra.tpl"
));
}
}
function ncn_civi_zoom_civicrm_links($op, $objectName, $objectId, &$links, &$mask, &$values){
// CRM_Core_Error::debug_var('op', $op);
if($op == 'event.manage.list' && $objectName == 'Event'){
// Add a link to view the zoom registrants
$links[] = array(
'name' => ts('View Zoom Registrants'),
'title' => ts('View Zoom Registrants'),
'url' => CRM_Utils_System::url('civicrm/zoom/zoomregistrants', "reset=1&event_id=".$objectId),
);
}
}
/**
* Implementation of hook_civicrm_check
*
* Add a check to the status page/System.
*/
function ncn_civi_zoom_civicrm_check(&$messages, $statusNames = [], $includeDisabled = false) {
if (CRM_Extension_System::singleton()->getMapper()->isActiveModule('civiruleslogger')) {
$zoomRegCheckStatusName = 'NcnCiviZoomRegistrantPushCheck';
// If performing your check is resource-intensive, consider bypassing if disabled
if (!$includeDisabled) {
$disabled = \Civi\Api4\StatusPreference::get()
->setCheckPermissions(FALSE)
->addWhere('is_active', '=', FALSE)
->addWhere('domain_id', '=', 'current_domain')
->addWhere('name', '=', $zoomRegCheckStatusName)
->execute()->count();
if ($disabled) {
return;
}
}
$logs = [];
$infoLevel = \PSR\Log\LogLevel::INFO;
$alertLevel = \PSR\Log\LogLevel::ALERT;
// Get zoom rule action name
$jsonFile = __DIR__ . '/civirules_actions.json';
$actions = json_decode(file_get_contents($jsonFile), true);
$actionName = '';
foreach($actions as $action) {
$actionName = $action['name'];
}
// Get zoom rule action Id
$rules = [];
$zoomActionId = null;
if(!empty($actionName)){
$getZoomActionIdQuery = 'SELECT id FROM civirule_action WHERE name = %1';
$qParams = array(1 => array($actionName, 'String'));
try {
$zoomActionId = CRM_Core_DAO::singleValueQuery($getZoomActionIdQuery, $qParams);
} catch (Exception $e) {
CRM_Core_Error::debug_log_message('getZoomActionIdQuery failed in ncn_civi_zoom_civicrm_check');
CRM_Core_Error::debug_var('getZoomActionIdQuery', $getZoomActionIdQuery);
CRM_Core_Error::debug_var('qParams', $qParams);
}
// Get rule Ids for the zoom action
if(!empty($zoomActionId)){
$getZoomRuleIdQuery = 'SELECT rule_id FROM civirule_rule_action WHERE action_id = %1';
$qParams = array(1 => array($zoomActionId, 'Integer'));
try {
$dao = CRM_Core_DAO::executeQuery($getZoomRuleIdQuery, $qParams);
while ($dao->fetch()) {
$rules[] = $dao->toArray();
}
} catch (Exception $e) {
CRM_Core_Error::debug_log_message('getZoomRuleIdQuery failed in ncn_civi_zoom_civicrm_check');
CRM_Core_Error::debug_var('getZoomRuleIdQuery', $getZoomRuleIdQuery);
CRM_Core_Error::debug_var('qParams', $qParams);
}
}
}
// Check if there are any alert level messages in the last 48hrs for each rule
foreach ($rules as $rule) {
$days = 2;
$currentDateTimeFull = new DateTime();
$pastDateTimeFull = $currentDateTimeFull->modify("-".$days." days");
$pastDateTime = $pastDateTimeFull->format('Y-m-d H:i:s');
$loggerQuery = "SELECT * FROM civirule_civiruleslogger_log WHERE rule_id = %1 AND level != %2 AND timestamp > %3";
$qParams = array(
1 => array($rule['rule_id'], 'Integer'),
2 => array($infoLevel, 'String'),
3 => array($pastDateTime, 'String')
);
try {
$dao = CRM_Core_DAO::executeQuery($loggerQuery, $qParams);
while ($dao->fetch()) {
$logs[] = $dao->toArray();
}
} catch (Exception $e) {
CRM_Core_Error::debug_log_message('loggerQuery failed in ncn_civi_zoom_civicrm_check');
CRM_Core_Error::debug_var('loggerQuery', $loggerQuery);
CRM_Core_Error::debug_var('qParams', $qParams);
}
}
// Add to system status if any logs available
if (!empty($logs)) {
$messages[] = new CRM_Utils_Check_Message(
$zoomRegCheckStatusName,
ts("There are some issues in pushing some participants to zoom. Please check civirules logger for more details."),
ts("Ncn Civi Zoom - Participants Couldn't be added to zoom"),
$alertLevel,
'fa-video-camera'
);
}
}
}
function ncn_civi_zoom_civicrm_searchTasks(string $objectType, array &$tasks){
if($objectType == 'event'){
$tasks[] = array(
'title' => ts('Add Participant to Zoom'),
'class' => 'CRM_NcnCiviZoom_Form_Task_AddToZoom',
'result' => null,
);
}
}