-
Notifications
You must be signed in to change notification settings - Fork 0
/
grantapplications.php
658 lines (595 loc) · 22.3 KB
/
grantapplications.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
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
<?php
require_once 'grantapplications.civix.php';
require_once 'CRM/Grantapplications/BAO/GrantApplicationProfile.php';
/**
* Implementation of hook_civicrm_config
*/
function grantapplications_civicrm_config(&$config) {
_grantapplications_civix_civicrm_config($config);
}
/**
* Implementation of hook_civicrm_xmlMenu
*
* @param $files array(string)
*/
function grantapplications_civicrm_xmlMenu(&$files) {
_grantapplications_civix_civicrm_xmlMenu($files);
}
/**
* Implementation of hook_civicrm_install
*/
function grantapplications_civicrm_install() {
_grantapplications_civix_civicrm_install();
$optionValueNameCheck = CRM_Core_DAO::singleValueQuery("SELECT id FROM civicrm_option_value WHERE name = 'grant_online_receipt'");
if (empty($optionValueNameCheck)) {
$smarty = CRM_Core_Smarty::singleton();
$smarty->assign('currentDirectoryPath', __DIR__);
CRM_Utils_File::runSqlQuery(CIVICRM_DSN, $smarty->fetch(__DIR__ . '/sql/civicrm_msg_template.tpl'), NULL, TRUE);
}
grantapplications_addRemoveMenu(TRUE);
return TRUE;
}
/**
* Implementation of hook_civicrm_postInstall
*/
function grantapplications_civicrm_postInstall() {
return _grantapplications_civix_civicrm_postInstall();
}
/**
* Implementation of hook_civicrm_uninstall
*/
function grantapplications_civicrm_uninstall() {
grantapplications_enableDisableNavigationMenu(2);
return _grantapplications_civix_civicrm_uninstall();
}
/**
* Implementation of hook_civicrm_enable
*/
function grantapplications_civicrm_enable() {
grantapplications_enableDisableNavigationMenu(1);
return _grantapplications_civix_civicrm_enable();
}
/**
* Implementation of hook_civicrm_disable
*/
function grantapplications_civicrm_disable() {
grantapplications_enableDisableNavigationMenu(0);
return _grantapplications_civix_civicrm_disable();
}
/**
* Implementation of hook_civicrm_upgrade
*
* @param $op string, the type of operation being performed; 'check' or 'enqueue'
* @param $queue CRM_Queue_Queue, (for 'enqueue') the modifiable list of pending up upgrade tasks
*
* @return mixed based on op. for 'check', returns array(boolean) (TRUE if upgrades are pending)
* for 'enqueue', returns void
*/
function grantapplications_civicrm_upgrade($op, CRM_Queue_Queue $queue = NULL) {
return _grantapplications_civix_civicrm_upgrade($op, $queue);
}
/**
* Implementation of hook_civicrm_managed
*
* Generate a list of entities to create/deactivate/delete when this module
* is installed, disabled, uninstalled.
*/
function grantapplications_civicrm_managed(&$entities) {
$entities[] = array(
'module' => 'biz.jmaconsulting.grantapplications',
'name' => 'grant',
'update' => 'never',
'entity' => 'OptionValue',
'params' => array(
'label' => 'Grant',
'is_active' => 1,
'version' => 3,
'option_group_id' => 'activity_type',
'component_id' => CRM_Core_Component::getComponentID('CiviGrant'),
'description' => ts('Online Grant Application'),
'filter' => 1,
),
);
$entities[] = array(
'module' => 'biz.jmaconsulting.grantapplications',
'name' => 'dashboard',
'update' => 'never',
'entity' => 'OptionValue',
'params' => array(
'label' => 'Grants',
'name' => 'CiviGrant',
'is_active' => 1,
'version' => 3,
'option_group_id' => 'user_dashboard_options',
'description' => ts('Grants on dashboard'),
),
);
$entities[] = array(
'module' => 'biz.jmaconsulting.grantapplications',
'name' => 'status',
'update' => 'never',
'entity' => 'OptionValue',
'params' => array(
'label' => 'Draft',
'is_active' => 1,
'version' => 3,
'option_group_id' => 'grant_status',
),
);
$entities[] = array(
'module' => 'biz.jmaconsulting.grantapplications',
'name' => 'navigation',
'update' => 'never',
'entity' => 'Navigation',
'params' => array(
'label' => "New Grant Application Page",
'name' => "grant_application_page",
'url' => "civicrm/admin/grant/apply?reset=1&action=add",
'parent_id' => "Grants",
'permission' => "access CiviGrant,edit Grant Application Pages",
'operator' => "AND",
'has_separator' => 1,
'is_active' => 1,
'version' => 3,
),
);
return _grantapplications_civix_civicrm_managed($entities);
}
/**
* Implements hook_civicrm_navigationMenu().
*
* @link http://wiki.civicrm.org/confluence/display/CRMDOC/hook_civicrm_navigationMenu
*
*/
function grantapplications_civicrm_navigationMenu(&$menu) {
foreach (array('Grants') as $parentName) {
_grantapplications_civix_insert_navigation_menu($menu, $parentName, array(
'label' => ts('New Grant Application Page', array('domain' => 'biz.jmaconsulting.grantapplications')),
'name' => 'New Grant Application Page',
'url' => 'civicrm/admin/grant/apply?reset=1&action=add',
'permission' => 'access CiviGrant,edit Grant Application Pages',
'operator' => 'AND',
));
}
}
/**
* Implementation of hook_civicrm_xmlMenu
*
* @param $files array(string)
*/
function grantapplications_civicrm_permission(&$permissions) {
$prefix = ts('CiviGrant') . ': ';
$permissions['submit online grant application'] = array(
$prefix . ts('apply for Grant Application'),
ts('Submit Grant Applications online'),
);
$permissions['edit grant application page'] = array(
$prefix . ts('edit Grant Application Pages'),
ts('Create or edit grant application pages and their criteria'),
);
$permissions['delete grant application page'] = array(
$prefix . ts('delete Grant Application Pages'),
ts('Delete grant application pages and their criteria'),
);
}
function grantapplications_civicrm_preProcess($formName, &$form) {
if ($formName == "CRM_Core_Form_ShortCode") {
$config = CRM_Core_Config::singleton();
if (in_array('CiviGrant', $config->enableComponents)) {
$form->components['grant'] = array(
'label' => ts("Grant Application Page"),
'select' => array(
'key' => 'id',
'entity' => 'GrantApplicationPage',
'select' => array('minimumInputLength' => 0),
),
);
}
}
}
function grantapplications_civicrm_validateForm($formName, &$fields, &$files, &$form, &$errors) {
if ($formName == 'CRM_Grant_Form_Grant_Confirm') {
$form->_errors = array(); // hack to prevent file fields from throwing an error in case they are required.
}
// Keeping this in validate hook to prevent re-use of same functionality
if (($formName == 'CRM_Grant_Form_Grant_Main' || $formName == 'CRM_Grant_Form_Grant_Confirm')
&& CRM_Utils_Array::value('is_draft', $form->_values) == 1 && (CRM_Utils_Array::value('_qf_Main_save', $fields) == 'Save as Draft' || $form->_params['is_draft'] == 1)) {
foreach($form->_fields as $name => $values) {
$form->setElementError($name, NULL);
$form->_errors = array();
}
}
if ($formName == "CRM_UF_Form_Field" && CRM_Core_Permission::access('CiviGrant')
&& ($form->getVar('_action') != CRM_Core_Action::DELETE)) {
$fieldType = $fields['field_name'][0];
$errorField = FALSE;
//get the group type.
$groupType = CRM_Core_BAO_UFGroup::calculateGroupType($form->getVar('_gid'), FALSE, CRM_Utils_Array::value('field_id', $fields));
if ($fieldType == "Activity" || $fieldType == "Participant" || $fieldType == "Contribution" || $fieldType =="Membership") {
if (in_array('Grant', $groupType)) {
$errors['field_name'] = ts('The profile has a grant field already, and this field is not a contact or grant field.');
}
}
elseif ($fieldType == "Grant") {
if ( in_array('Membership', $groupType) ||
in_array('Activity', $groupType) ||
in_array('Participant', $groupType) ||
in_array('Contribution', $groupType) ) {
$errors['field_name'] = ts('A grant field can only be added to a profile that has only contact and grant fields. This profile has fields that are not contact or grant fields');
}
}
}
}
function grantapplications_civicrm_buildForm($formName, &$form) {
// Code to be done to avoid core editing
if ($formName == "CRM_UF_Form_Field" && CRM_Core_Permission::access('CiviGrant')) {
if (!$form->elementExists('field_name')) {
return NULL;
}
$elements = & $form->getElement('field_name');
if ($elements && !array_key_exists('Grant', $elements->_options[0])) {
$elements->_options[0]['Grant'] = 'Grant';
$elements->_options[1]['Grant'] = $form->_mapperFields['Grant'];
$elements->_elements[0]->_options[] = array(
'text' => 'Grant',
'attr' => array('value' => 'Grant')
);
$elements->_js .= 'hs_field_name_Grant = ' . json_encode($form->_mapperFields['Grant']) . ';';
}
// set default mapper when updating profile fields
if ($form->_defaultValues && array_key_exists('field_name', $form->_defaultValues)
&& $form->_defaultValues['field_name'][0] == 'Grant') {
$defaults['field_name'] = $form->_defaultValues['field_name'];
$form->setDefaults($defaults);
}
}
if ($formName == "CRM_Grant_Form_GrantView") {
CRM_Core_Resources::singleton()->addStyle('.crm-info-panel td {
width: 50% !important;
}');
}
}
function grantapplications_civicrm_pageRun(&$page) {
if ($page->getVar('_name') == 'CRM_Grant_Page_DashBoard') {
$params = array();
$query = "SELECT
*
FROM civicrm_grant_app_page
WHERE 1";
$grantPage = CRM_Core_DAO::executeQuery($query, $params, TRUE, 'CRM_Grant_DAO_GrantApplicationPage');
$rows = array();
$allowToDelete = CRM_Core_Permission::check('delete grant application page');
//get configure actions links.
$configureActionLinks = CRM_Grant_BAO_GrantApplicationPage::configureActionLinks();
$query = "SELECT
id
FROM civicrm_grant_app_page
WHERE 1";
$grantAppPage = CRM_Core_DAO::executeQuery($query, $params, TRUE, 'CRM_Grant_DAO_GrantApplicationPage');
$grantAppPageIds = array();
while ($grantAppPage->fetch()) {
$grantAppPageIds[$grantAppPage->id] = $grantAppPage->id;
}
//get all section info.
$grantAppPageSectionInfo = CRM_Grant_BAO_GrantApplicationPage::getSectionInfo($grantAppPageIds);
while ($grantPage->fetch()) {
$rows[$grantPage->id] = array();
CRM_Core_DAO::storeValues($grantPage, $rows[$grantPage->id]);
// form all action links
$action = array_sum(array_keys(CRM_Grant_BAO_GrantApplicationPage::actionLinks()));
//add configure actions links.
$action += array_sum(array_keys($configureActionLinks));
//add online grant links.
if ($grantPage->is_active) {
$action += array_sum(array_keys(CRM_Grant_BAO_GrantApplicationPage::onlineGrantLinks()));
}
if ($grantPage->is_active) {
$action -= CRM_Core_Action::ENABLE;
}
else {
$action -= CRM_Core_Action::DISABLE;
}
if (!$allowToDelete) {
$action -= CRM_Core_Action::DELETE;
}
$sectionsInfo = CRM_Utils_Array::value($grantPage->id, $grantAppPageSectionInfo, array());
$rows[$grantPage->id]['configureActionLinks'] = CRM_Core_Action::formLink(CRM_Grant_BAO_GrantApplicationPage::formatConfigureLinks($sectionsInfo),
$action,
array('id' => $grantPage->id),
ts('Configure'),
TRUE,
'grantapppage.configure.actions',
'GrantAppPage',
$grantPage->id
);
//build the online grant application links.
$rows[$grantPage->id]['onlineGrantLinks'] = CRM_Core_Action::formLink(CRM_Grant_BAO_GrantApplicationPage::onlineGrantLinks(),
$action,
array('id' => $grantPage->id),
ts('Grant Application (Live)'),
FALSE,
'grantapppage.online.links',
'GrantAppPage',
$grantPage->id
);
//build the normal action links.
$rows[$grantPage->id]['action'] = CRM_Core_Action::formLink(CRM_Grant_BAO_GrantApplicationPage::actionLinks(),
$action,
array('id' => $grantPage->id),
ts('more'),
TRUE,
'grantapppage.action.links',
'GrantAppPage',
$grantPage->id
);
$rows[$grantPage->id]['title'] = $grantPage->title;
$rows[$grantPage->id]['is_active'] = $grantPage->is_active;
$rows[$grantPage->id]['id'] = $grantPage->id;
}
$page->assign('fields', $rows);
CRM_Core_Region::instance('page-body')->add(array(
'template' => 'CRM/Grant/Page/GrantApplicationDashboard.tpl',
));
}
if ($page->getVar('_name') == 'CRM_Contact_Page_View_UserDashBoard') {
$cid = $page->getVar('_contactId');
// Check if grant program extension is enabled
$enabled = CRM_Grantapplications_BAO_GrantApplicationProfile::checkRelatedExtensions('biz.jmaconsulting.grantprograms');
$smarty = CRM_Core_Smarty::singleton();
$rels = CRM_Contact_BAO_Relationship::getRelationship($cid, 3, 0, 0, 0, NULL, NULL, TRUE);
$dashboardElements = $smarty->get_template_vars('dashboardElements');
$components = CRM_Core_Component::getEnabledComponents();
$userDashboard = $components['CiviGrant']->getUserDashboardObject();
$dashboardElements[] = array(
'class' => 'crm-dashboard-' . strtolower($components['CiviGrant']->name),
'sectionTitle' => ts('Your Grant(s)'),
'templatePath' => $userDashboard->getTemplateFileName(),
'weight' => 50,
);
$userDashboard->run();
usort($dashboardElements, array('CRM_Utils_Sort', 'cmpFunc'));
$page->assign('dashboardElements', $dashboardElements);
$actionLinks = $smarty->get_template_vars('grant_rows');
if (empty($actionLinks)) {
$actionLinks = array();
}
$permissions = array(CRM_Core_Permission::VIEW);
if (CRM_Core_Permission::check('edit grant application page')) {
$permissions[] = CRM_Core_Permission::EDIT;
}
if (CRM_Core_Permission::check('delete grant application page')) {
$permissions[] = CRM_Core_Permission::DELETE;
}
$mask = CRM_Core_Action::mask($permissions);
foreach ($actionLinks as $key => $fields) {
//FIXME:Replace it with option value name
if (CRM_Utils_Array::value('grant_status', $fields) != 'Draft') {
unset($actionLinks[$key]);
continue;
}
$savedSearch = civicrm_api3('SavedSearch', 'get', [
'search_custom_id' => $fields['grant_id'],
'api_entity' => 'civicrm_grant',
'sequential' => 1,
]);
if (!empty($savedSearch['values'][0]['form_values'])) {
$formValues = $savedSearch['values'][0]['form_values'];
$actionLinks[$key]['action'] = CRM_Core_Action::formLink(grantapplications_dashboardActionLinks(),
$mask,
array(
'id' => $formValues['grantApplicationPageID'],
'gid' => $fields['grant_id'],
)
);
}
}
$rows = array();
if (!empty($rels)) {
$extraSelect = '';
$relationshipType = CRM_Core_PseudoConstant::relationshipType('name');
$grantType = CRM_Core_PseudoConstant::get('CRM_Grant_DAO_Grant', 'grant_type_id');
$grantStatus = CRM_Core_PseudoConstant::get('CRM_Grant_DAO_Grant', 'status_id');
$grantStatusByName = CRM_Core_PseudoConstant::get('CRM_Grant_DAO_Grant', 'status_id', array('labelColumn' => 'name'));
if ($enabled) {
$extraSelect = ', grant_program_id ';
$grantProgram = CRM_Grant_BAO_GrantProgram::getGrantPrograms();
}
foreach($rels as $id => $values) {
if ($relationshipType[$values['relationship_type_id']]['name_a_b'] != 'Employee of') {
continue;
}
$query = "SELECT
grant_type_id,
application_received_date,
amount_total,
status_id,
id,
currency
{$extraSelect}
FROM civicrm_grant
WHERE contact_id = {$values['cid']}
AND status_id = " . array_search('Draft', $grantStatusByName);
$dao = CRM_Core_DAO::executeQuery($query);
while ($dao->fetch()) {
$row = array();
$row['contact_id'] = $values['cid'];
$row['sort_name'] = $values['display_name'];
$row['grant_type'] = CRM_Utils_Array::value($dao->grant_type_id, $grantType);
$row['grant_application_received_date'] = $dao->application_received_date;
$row['grant_amount_total'] = $dao->amount_total;
$row['grant_status'] = CRM_Utils_Array::value($dao->status_id, $grantStatus);
if ($enabled) {
$row['program_id'] = $dao->grant_program_id;
$row['program_name'] =$grantProgram[$row['program_id']];
}
// FIXME:Calling multiple times
$savedSearch = civicrm_api3('SavedSearch', 'get', [
'search_custom_id' => $dao->id,
'api_entity' => 'civicrm_grant',
'sequential' => 1,
]);
if (!empty($savedSearch['values'][0]['form_values'])) {
$formValues = $savedSearch['values'][0]['form_values'];
$row['action'] = CRM_Core_Action::formLink(grantapplications_dashboardActionLinks(),
$mask,
array(
'id' => $formValues['grantApplicationPageID'],
'gid' => $dao->id,
)
);
}
$rows[] = $row;
}
}
}
$page->assign('grant_rows', array_merge($actionLinks, $rows));
$page->assign('enabled', $enabled);
}
}
function grantapplications_addRemoveMenu($enable) {
$config = CRM_Core_Config::singleton();
$params['enableComponents'] = $config->enableComponents;
if ($enable) {
if (array_search('CiviGrant', $config->enableComponents)) {
return NULL;
}
$params['enableComponents'][] = 'CiviGrant';
}
else {
$key = array_search('CiviGrant', $params['enableComponents']);
if ($key) {
unset($params['enableComponents'][$key]);
}
}
Civi::settings()->set('enable_components', $params['enableComponents']);
}
function grantapplications_civicrm_entityTypes(&$entityTypes) {
$entityTypes['CRM_Grant_DAO_GrantApplicationPage'] = array(
'name' => 'GrantApplicationPage',
'class' => 'CRM_Grant_DAO_GrantApplicationPage',
'table' => 'civicrm_grant_app_page',
);
}
/**
* function to disable/enable/delete navigation menu
*
* @param integer $action
*
*/
function grantapplications_enableDisableNavigationMenu($action) {
$domainID = CRM_Core_Config::domainID();
$enableDisableDeleteData = NULL;
if ($action != 1) {
$enableDisableDeleteData = CRM_Grantapplications_BAO_GrantApplicationProfile::checkRelatedExtensions();
}
if ($action < 2) {
if (!$enableDisableDeleteData) {
CRM_Core_DAO::executeQuery(
"UPDATE civicrm_uf_group SET is_active = %1 WHERE group_type LIKE '%Grant%'",
array(
1 => array($action, 'Integer'),
)
);
}
CRM_Core_DAO::executeQuery(
"UPDATE civicrm_option_value
INNER JOIN civicrm_option_group ON civicrm_option_value.option_group_id = civicrm_option_group.id
INNER JOIN civicrm_msg_template ON civicrm_msg_template.workflow_id = civicrm_option_value.id
SET civicrm_option_value.is_active = %1,
civicrm_option_group.is_active = %1,
civicrm_msg_template.is_active = %1
WHERE civicrm_option_group.name LIKE 'msg_tpl_workflow_grant'",
array(
1 => array($action, 'Integer')
)
);
$optionGroup = array(
'activity_type' => 'Grant',
'grant_status' => 'Draft',
'user_dashboard_options' => 'CiviGrant',
);
foreach ($optionGroup as $ogName => $ovName) {
CRM_Core_DAO::executeQuery(
"UPDATE `civicrm_activity` ca
INNER JOIN civicrm_option_value cv ON cv.value = ca.activity_type_id
INNER JOIN civicrm_option_group cg ON cg.id = cv.option_group_id
SET cv.is_active = %1
WHERE cg.name = %2 AND cv.name = %3",
array(
1 => array($action, 'Integer'),
2 => array($ogName, 'String'),
3 => array($ovName, 'String'),
)
);
}
CRM_Core_DAO::executeQuery(
"UPDATE civicrm_navigation SET is_active = %2 WHERE name = 'New Grant Application Page' AND domain_id = %1",
array(
1 => array($domainID, 'Integer'),
2 => array($action, 'Integer')
)
);
}
else {
CRM_Core_DAO::executeQuery(
"DELETE FROM civicrm_navigation WHERE name = 'New Grant Application Page' AND domain_id = %1",
array(
1 => array($domainID, 'Integer')
)
);
if ($enableDisableDeleteData === NULL) {
CRM_Core_DAO::executeQuery(
"DELETE uj.*, uf.*, g.* FROM civicrm_uf_group g
LEFT JOIN civicrm_uf_join uj ON uj.uf_group_id = g.id
LEFT JOIN civicrm_uf_field uf ON uf.uf_group_id = g.id
WHERE g.group_type LIKE '%Grant%';"
);
}
$action = 0;
}
if ($enableDisableDeleteData) {
return FALSE;
}
grantapplications_addRemoveMenu($action);
}
function grantapplications_civicrm_alterUFFields(&$fields) {
$fields['Grant'] = CRM_Grantapplications_BAO_GrantApplicationProfile::exportableFields();
}
function grantapplications_civicrm_post($entity, $op, $id, $object) {
if ($entity === 'UFField' && in_array($op, ['edit', 'create'])) {
$fieldsType = CRM_Grantapplications_BAO_GrantApplicationProfile::calculateGroupType($object->uf_group_id, TRUE);
CRM_Grantapplications_BAO_GrantApplicationProfile::updateGroupTypes($object->uf_group_id, $fieldsType);
}
}
function grantapplications_dashboardActionLinks() {
return array(
CRM_Core_Action::UPDATE => array(
'name' => ts('Edit'),
'url' => 'civicrm/grant/transact',
'qs' => 'reset=1&id=%%id%%&gid=%%gid%%',
'title' => ts('Edit Grant Application'),
'class' => 'no-popup',
),
);
}
if (function_exists('add_filter')) {
add_filter('civicrm_shortcode_preprocess_atts', 'grantapplications_amend_args', 10, 2);
add_filter('civicrm_shortcode_get_data', 'grantapplications_amend_data', 10, 3);
}
function grantapplications_amend_args($args, $shortcode_attrs) {
extract($shortcode_attrs);
if ($component === 'grant') {
$args['q'] = 'civicrm/grant/transact';
}
return $args;
}
function grantapplications_amend_data(&$data, $atts, $args) {
if ($atts['component'] === 'grant') {
$dao = CRM_Core_DAO::executeQuery("SELECT title, intro_text FROM civicrm_grant_app_page WHERE id = %1", [1 => [$args['id'], 'Positive']]);
while ($dao->fetch()) {
$data['title'] = $dao->title;
$data['text'] = $dao->intro_text;
}
}
return $data;
}