forked from alanski66/joomlaK2notify
-
Notifications
You must be signed in to change notification settings - Fork 0
/
k2notifyadmin.php
681 lines (555 loc) · 22 KB
/
k2notifyadmin.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
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
<?php
/*
// "Notify of K2 submission" Plugin by Joomkit Ltd for K2 v2.5 - Version 1.0
// Copyright (c) 2010 Joomkit Ltd. All rights reserved.
// Released under the GNU/GPL license: http://www.gnu.org/copyleft/gpl.html
// More info at http://www.joomkit.com/extensions
// *** Last update: Sunday 22 April ***
*/
// no direct access
defined('_JEXEC') or die('Restricted access');
//jimport('joomla.plugin.plugin');
JLoader::register('K2Plugin', JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_k2' . DS . 'lib' . DS . 'k2plugin.php');
/**
* K2 Plugin to render notifyadmin URLs entered in backend.
*/
class plgK2K2Notifyadmin extends K2Plugin {
// Some params
var $pluginName = 'k2notifyadmin';
var $pluginNameHumanReadable = 'Email Notification Settings';
function plgK2K2Notifyadmin(& $subject, $params) {
parent::__construct($subject, $params);
$this->loadLanguage();
}
/**
* Below we list all available FRONTEND events, to trigger K2 plugins.
* Watch the different prefix "onK2" instead of just "on" as used in Joomla! already.
* Most functions are empty to showcase what is available to trigger and output. A few are used to actually output some code for example reasons.
*/
function onK2PrepareContent(&$item, &$params, $limitstart) {
return;
}
function onK2AfterDisplay(&$item, &$params, $limitstart) {
return;
}
function onK2BeforeDisplay(&$item, &$params, $limitstart) {
return;
}
function onK2AfterDisplayTitle(&$item, &$params, $limitstart) {
return;
}
function onK2BeforeDisplayContent(&$item, &$params, $limitstart) {
return;
}
// Event to display in the frontend the notifyadmin URL as entered in the item form
function onK2AfterDisplayContent(& $item, & $params, $limitstart) {
return;
}
// Event to display in the frontend the YouTube URL as entered in the category form
function PPmonK2CategoryDisplay(& $category, & $params, $limitstart) {
// global $mainframe;
// $plugin = & JPluginHelper::getPlugin('k2', 'notifyadmin');
// $pluginParams = new JParameter($plugin->params);
// $plugins = new K2Parameter($category->plugins, '', $this->pluginName);
//
// $output = $plugins->get('notifyemail_cat');
// //echo 'catdisplay';
// return $output;
}
// Event to display in the frontend the notifyadmin URL as entered in the category form
// Event to display in the frontend the notifyadmin URL as entered in the user form
function onK2UserDisplay(&$user, &$params, $limitstart) {
return;
}
// Function to render plugin parameters in the backend - no need to change anything
// function onRenderAdminForm( & $item, $type, $tab='') {
// global $mainframe;
// $form = new K2Parameter($item->plugins, JPATH_SITE.DS.'plugins'.DS.'k2'.DS.$this->pluginName.'.xml', $this->pluginName);
//
//
// if ( !empty ($tab)) {
// $path = $type.'-'.$tab;
// }
// else {
// $path = $type;
// }
// $fields = $form->render('plugins', $path);
// if ($fields){
// $plugin = new JObject;
// $plugin->set('name', $this->pluginNameHumanReadable);
// $plugin->set('fields', $fields);
// $output = $plugin;
// }
// return $output;var_dump($fields);
//
// }
// This function ONLY for compatibility with K2 Usert system plugin - it use this function instead onRenderAdminForm
function onRenderUserForm(& $user) {
/*
* global $mainframe;
$form = new K2Parameter($user->plugins, JPATH_SITE.DS.'plugins'.DS.'k2'.DS.$this->pluginName.'.xml', $this->pluginName);
$fields = $form->render('plugins', 'user');
$plugin = new JObject;
$plugin->set('name', $this->pluginNameHumanReadable);
$plugin->set('fields', $fields);
return $plugin;
*/
}
//uber mail function!
//function onK2CategoryDisplay( & $category, & $params, $limitstart) {
function onAfterK2Save(&$item, $isNew) {
//jimport( 'joomla.application.application' );
$mainframe = JFactory::getApplication();
if ($mainframe->isAdmin()) {
return; // Dont run in admin
}
$body = null;
// check & load category email params for this submission
JTable::addIncludePath(JPATH_COMPONENT_ADMINISTRATOR . DS . 'tables');
$category = JTable::getInstance('K2Category', 'Table');
$category->load($item->catid);
$catName = $category->name;
// Get the K2 plugin params (the stuff you see when you edit the plugin in the plugin manager)
$plugin = JPluginHelper::getPlugin('k2', $this->pluginName);
$pluginParams = $this->params;
// Get the output of the K2 plugin fields (the data entered by your site maintainers)
$catPluginParams = new K2Parameter($category->plugins, '', $this->pluginName);
//check if we are supposed to run for edited items globally
if ($isNew == false):
//check specific category settings for on edit cat_EmailSendEdit
if ((!$catPluginParams->get('cat_EmailSendEdit')) && (!$pluginParams->get('notifyglobalEdit')))
return;
endif;
//SET RECIPIENTS from global plugin settings or category specific
if ($pluginParams->get('notifyGlobal') && (!$catPluginParams->get('cat_EmailSendStatus'))) {
$globalEmailList = trim($pluginParams->get('notifyglobalEmailList'));
//var_dump($globalEmailList);
$recipient = explode(",", $globalEmailList);
//$recipient = "[email protected]";
} elseif ($catPluginParams->get('cat_EmailSendStatus')) { //check if category set to yes
//set recipients just from this category
$categoryNotifyItemSubmittedList = trim($catPluginParams->get('cat_NotifyEmailList'));
$recipient = explode(",", $categoryNotifyItemSubmittedList);
//$recipient = "[email protected]";
}
//setup recipients for CC - BCC is to restricted on mail setps and seems flaky with jmailer /phpmailer
// if recipients more than 1
if (count($recipient) > 1):
$i = 1;
foreach ($recipient as $email):
echo $i;
if ($i == 1):
$to = "{$email}";
elseif ($i > 1):
$CC[] = "{$email}";
endif;
$i++;
endforeach;
//remove last comma
// $CC = substr($CC, 0, -1);
else:
$to = "{$recipient[0]}";
$CC = "";
endif;
//var_dump($recipient); die();
//add title via submission type check eg edited or new
$title = ($isNew == true) ? JText::_('JK_K2NOTIFY_NEW_SUBMISSION'). $item->title : Jtext::_('JK_K2NOTIFY_EDITED_SUBMISSION') . " ".$item->title;
//stuff data into output for passing to mail body
$body .= '<table cellpadding="10" style="border-collapse:collapse;border:1px solid #CCC;text-align:left;width:100%;font-family:helvetica,arial;">';
$body .= '<tr style="background:#D5E7FA;border-bottom: 2px solid #96B0CB;margin:14px"><th colspan="2"> ' . $title . '</th></tr>';
//user data
$user = JFactory::getUser();
$body.='<tr><td width="25%" style="padding:10px">'.JText::_('JK_K2NOTIFY_EDIT_FROM_LABEL').'</td><td>' . $user->username . ', ' . $user->email . '</td></tr>';
$approveurl = JURI::base() . 'administrator/index.php?option=com_k2&view=item&cid=' . $item->id;
$body.='<tr><td width="25%" style="padding:10px">'.JText::_('JK_K2NOTIFY_EDIT_APPROVE').'</td><td><a href="' . $approveurl . '">'.JText::_('JK_K2NOTIFY_EDIT_APPROVE_LINK_LABEL').'</a></td></tr>';
//notifyglobalIncludeK2ItemInBody
// $notifyglobalIncludeK2ItemInBody = $pluginParams->get(notifyglobalIncludeK2ItemInBody);
if ($pluginParams->get('notifyglobalIncludeK2ItemInBody')):
$body.='<tr><td valign"top" style="padding:10px">Article</td><td>' . $item->introtext . $item->fulltext . '</td></tr>';
$body.='<tr><td valign"top" style="padding:10px">'.JText::_('JK_K2NOTIFY_EDIT_APPROVE').'</td><td><a href="' . $approveurl . '">'.JText::_('JK_K2NOTIFY_EDIT_APPROVE_LINK_LABEL').'</a></td></tr>';
endif;
//get extrafield data for email body
$itemID = JRequest::getInt('cid', NULL);
if(count($item->extra_fields)) {
// $extra_fields=K2ModelItem::getItemExtraFields($this->item->extra_fields);
$extra_fields = $this->getExtraFields($item->extra_fields, $item);
if (count($extra_fields)) {
$body.='<tr style="background:#D5E7FA;border-bottom: 2px solid #96B0CB;"><td width="15%">'.JText::_('JK_K2EXFNAME').'</td><td>'.JText::_('JK_K2EXFVALUE').'</td>';
foreach ($extra_fields as $key=>$extraField) {
$body.='<tr><td align="left" class="key">' . $extraField->name . '</td>';
$body.='<td>' . $extraField->value . '</td></tr>';
}
}
}
$body.='</table>';
$subject = ($isNew == true) ? $pluginParams->get('notifyglobalEmailSubject') . ":" . $item->title : "Submission edited:" . $item->title;
if ($pluginParams->get('notifyglobalEmailFromName')):
$fromname = $pluginParams->get('notifyglobalEmailFromName');
else:
$fromname = $mainframe->getCfg('fromname');
endif;
$fromemail = $mainframe->getCfg('mailfrom');
$mail = JFactory::getMailer();
$config = JFactory::getConfig();
$mail->addRecipient($to);
$mail->addCC($CC);
$mail->setSender($fromemail, $fromname);
$mail->setSubject($subject);
$mail->IsHTML(true);
$mail->setBody($body);
if ($mail->Send()) {
// echo "Mail sent successfully.";
} else {
// echo "An error occurred. Mail was not sent.";
}
return;
}
//$userName,$commentEmail,$commentText,$commentURL,$row,$response->message,$item->itemID));
function onK2CommentSave($userName, $commentEmail, $commentText, $commentURL, $row, $message, $itemid, $catid) {
global $mainframe;
// Get the K2 plugin params (the stuff you see when you edit the plugin in the plugin manager)
$plugin = JPluginHelper::getPlugin('k2', $this->pluginName);
$pluginCommParams = $this->params;
$commrecipient ='';
// check & load category email params for this submission
JTable::addIncludePath(JPATH_COMPONENT_ADMINISTRATOR . DS . 'tables');
$category = &JTable::getInstance('K2Category', 'Table');
$category->load($catid);
$catPluginParams = new K2Parameter($category->plugins, '', $this->pluginName);
//set recipients from global plugin settings or category specific
// if ($pluginCommParams->get('notifyglobalComm') ) {
if ($pluginCommParams->get('notifyglobalComm') && (!$catPluginParams->get('cat_EmailCommSendStatus'))) {
$globalCommEmailList = trim($pluginCommParams->get('notifyglobalCommEmailList'));
$commrecipient = explode(",", $globalCommEmailList);
} elseif ($catPluginParams->get('cat_EmailCommSendStatus')) { //check if category set on
//set recipients just from this category
$categoryNotifyItemCommList = trim($catPluginParams->get('cat_NotifyEmailCommList'));
$commrecipient = explode(",", $categoryNotifyItemCommList);
}
//setup mailer object
$mailer = JFactory::getMailer();
// if recipients more than 1
if (count($commrecipient) > 1):
$i = 1;
foreach ($commrecipient as $email):
if ($i == 1):
$to = $email;
elseif ($i > 1):
//build as string not array otherwisemailer fails
$CC .= $email.",";
endif;
$i++;
endforeach;
$CC = substr($CC, 0, -1);
//add the cc to mailer
$mailer->addCC($CC);
else:
$to = $commrecipient[0];
endif;
//output
$body .= '<table rules="all" style="border-color: #666;" cellpadding="10">';
$body .= '<tr style="background: #eee;"><th valign="top" width="15%">'.JText::_('JK_K2NOTIFY_COMMENT_NOTIFICATION').'</th><th> ' . JText::_('JK_K2NOTIFY_EDIT_COMMENT_HEADING') . '</th></tr>';
$body .='<tr><td valign="top" width="15%">'.JText::_('JK_K2NOTIFY_EDIT_FROM_LABEL').'</td><td valign="top">' . $userName . '</td></tr>';
$body .='<tr><td valign="top" width="15%">'.JText::_('JK_K2NOTIFY_EDIT_EMAIL_LABEL').'</td><td valign="top">' . $commentEmail . '</td></tr>';
$body .='<tr><td valign="top" width="15%">'.JText::_('JK_K2NOTIFY_EDIT_COMMENT_LABEL').'</td><td valign="top">' . $commentText . '<p></td></tr>';
if($commentURL):
$body .='<tr><td valign="top" width="15%">'.JText::_('JK_K2NOTIFY_EDIT_COMMENT_URL_LABEL').'</td><td valign="top"><a href="' . $commentURL . '">' . $commentURL . '</a></td></tr>';
endif;
$body .='<tr><td valign="top" width="15%">'.JText::_('JK_K2NOTIFY_EDIT_COMMENT_EDIT_APPROVE_LABEL').'</td><td><a href="' . JURI::base() . 'administrator/index.php?option=com_k2&view=comments">Admin Link</a></td></tr>';
$body .= "</td></tr></table>";
//GET / Set from name
//joomkit reverts to get confogi call for new 3.3.3 api
$setfromname = $pluginCommParams->get('notifyglobalCommEmailFromName');
$config = JFactory::getConfig();
if (isset($setfromname)):
$fromname = $setfromname;
else:
// $fromname = $config->get('fromname');
endif;
//pass to sender array
$sender = array($config->get('mailfrom'), $fromname);
//set subject
$CommEmailsubject = $pluginCommParams->get('notifyglobalCommEmailSubject');
$mailer->setSender($sender);
$mailer->setSubject($CommEmailsubject);
$mailer->addRecipient($to);
$mailer->IsHTML(true);
$mailer->setBody($body);
$send = $mailer->Send();
//return $message;
return;
}
function getXFVal($id, $currentValue) {
global $mainframe;
$db = JFactory::getDBO();
$db->setQuery('SELECT * FROM #__k2_extra_fields WHERE id = ' . $id);
$row = $db->loadObject();
//var_dump($row);
require_once(JPATH_ROOT . '/administrator/components/com_k2/lib/JSON.php');
$json = new Services_JSON;
$jsonObject = $json->decode($row->value);
$xfvalue = '';
$currentValue = '';
if ($row->type == 'textfield' || $row->type == 'textarea' || $row->type == 'labels') {
$xfvalue = $currentValue;
} else if ($row->type == 'multipleSelect') {
foreach ($jsonObject as $option) {
if (in_array($option->value, $currentValue))
$xfvalue.=$option->name . ' ';
}
}
else if ($row->type == 'link') {
$xfvalue.=$currentValue[0] . ' ';
$xfvalue.=$currentValue[1] . ' ';
} else {
if (!is_array($jsonObject))
return '';
foreach ($jsonObject as $option) {
if ($option->value == $currentValue)
$xfvalue.=$option->name;
}
}
var_dump($xfvalue); //die();
return $xfvalue;
}
function getExtraFields($itemExtraFields, &$item = null)
{
static $K2ItemExtraFieldsInstances = array();
if ($item && isset($K2ItemExtraFieldsInstances[$item->id]))
{
$this->buildAliasBasedExtraFields($K2ItemExtraFieldsInstances[$item->id], $item);
return $K2ItemExtraFieldsInstances[$item->id];
}
jimport('joomla.filesystem.file');
$db = JFactory::getDBO();
require_once (JPATH_ADMINISTRATOR.DS.'components'.DS.'com_k2'.DS.'lib'.DS.'JSON.php');
$json = new Services_JSON;
$jsonObjects = $json->decode($itemExtraFields);
$imgExtensions = array(
'jpg',
'jpeg',
'gif',
'png'
);
$params = K2HelperUtilities::getParams('com_k2');
if (count($jsonObjects) < 1)
{
return NULL;
}
foreach ($jsonObjects as $object)
{
$extraFieldsIDs[] = $object->id;
}
JArrayHelper::toInteger($extraFieldsIDs);
$condition = @implode(',', $extraFieldsIDs);
$query = "SELECT extraFieldsGroup FROM #__k2_categories WHERE id=".(int)$item->catid;
$db->setQuery($query);
$group = $db->loadResult();
$query = "SELECT * FROM #__k2_extra_fields WHERE `group` = ".(int)$group." AND published=1 AND (id IN ({$condition}) OR `type` = 'header') ORDER BY ordering ASC";
$db->setQuery($query);
$rows = $db->loadObjectList();
$size = count($rows);
for ($i = 0; $i < $size; $i++)
{
$value = '';
$values = array();
foreach ($jsonObjects as $object)
{
if ($rows[$i]->id == $object->id)
{
if ($rows[$i]->type == 'textfield' || $rows[$i]->type == 'textarea' || $rows[$i]->type == 'date')
{
$value = $object->value;
if ($rows[$i]->type == 'date' && $value)
{
$offset = (K2_JVERSION != '15') ? null : 0;
$value = JHTML::_('date', $value, JText::_('K2_DATE_FORMAT_LC'), $offset);
}
}
else if ($rows[$i]->type == 'image')
{
if ($object->value)
{
$src = '';
if (JString::strpos('http://', $object->value) === false)
{
$src .= JURI::root(true);
}
$src .= $object->value;
$value = '<img src="'.$src.'" alt="'.$rows[$i]->name.'" />';
}
else
{
$value = false;
}
}
else if ($rows[$i]->type == 'labels')
{
$labels = explode(',', $object->value);
if (!is_array($labels))
{
$labels = (array)$labels;
}
$value = '';
foreach ($labels as $label)
{
$label = JString::trim($label);
$label = str_replace('-', ' ', $label);
$value .= '<a href="'.JRoute::_('index.php?option=com_k2&view=itemlist&task=search&searchword='.urlencode($label)).'">'.$label.'</a> ';
}
}
else if ($rows[$i]->type == 'select' || $rows[$i]->type == 'radio')
{
foreach ($json->decode($rows[$i]->value) as $option)
{
if ($option->value == $object->value)
{
$value .= $option->name;
}
}
}
else if ($rows[$i]->type == 'multipleSelect')
{
foreach ($json->decode($rows[$i]->value) as $option)
{
if (@in_array($option->value, $object->value))
{
$values[] = $option->name;
}
}
$value = @implode(', ', $values);
}
else if ($rows[$i]->type == 'csv')
{
$array = $object->value;
if (count($array))
{
$value .= '<table cellspacing="0" cellpadding="0" class="csvTable">';
foreach ($array as $key => $row)
{
$value .= '<tr>';
foreach ($row as $cell)
{
$value .= ($key > 0) ? '<td>'.$cell.'</td>' : '<th>'.$cell.'</th>';
}
$value .= '</tr>';
}
$value .= '</table>';
}
}
else
{
switch ($object->value[2])
{
case 'same' :
default :
$attributes = '';
break;
case 'new' :
$attributes = 'target="_blank"';
break;
case 'popup' :
$attributes = 'class="classicPopup" rel="{\'x\':'.$params->get('linkPopupWidth').',\'y\':'.$params->get('linkPopupHeight').'}"';
break;
case 'lightbox' :
// Joomla! modal required
if (!defined('K2_JOOMLA_MODAL_REQUIRED'))
define('K2_JOOMLA_MODAL_REQUIRED', true);
$filename = @basename($object->value[1]);
$extension = JFile::getExt($filename);
if (!empty($extension) && in_array($extension, $imgExtensions))
{
$attributes = 'class="modal"';
}
else
{
$attributes = 'class="modal" rel="{handler:\'iframe\',size:{x:'.$params->get('linkPopupWidth').',y:'.$params->get('linkPopupHeight').'}}"';
}
break;
}
$object->value[0] = JString::trim($object->value[0]);
$object->value[1] = JString::trim($object->value[1]);
if ($object->value[1] && $object->value[1] != 'http://' && $object->value[1] != 'https://')
{
if ($object->value[0] == '')
{
$object->value[0] = $object->value[1];
}
$value = '<a href="'.$object->value[1].'" '.$attributes.'>'.$object->value[0].'</a>';
}
else
{
$value = false;
}
}
}
}
if ($rows[$i]->type == 'header')
{
$tmp = json_decode($rows[$i]->value);
if (!$tmp[0]->displayInFrontEnd)
{
$value = null;
}
else
{
$value = $tmp[0]->value;
}
}
// Detect alias
$tmpValues = $json->decode($rows[$i]->value);
if (isset($tmpValues[0]) && isset($tmpValues[0]->alias) && !empty($tmpValues[0]->alias))
{
$rows[$i]->alias = $tmpValues[0]->alias;
}
else
{
$filter = JFilterInput::getInstance();
$rows[$i]->alias = $filter->clean($rows[$i]->name, 'WORD');
if (!$rows[$i]->alias)
{
$rows[$i]->alias = 'extraField'.$rows[$i]->id;
}
}
if (JString::trim($value) != '')
{
$rows[$i]->value = $value;
if (!is_null($item))
{
if (!isset($item->extraFields))
{
$item->extraFields = new stdClass;
}
$tmpAlias = $rows[$i]->alias;
$item->extraFields->$tmpAlias = $rows[$i];
}
}
else
{
unset($rows[$i]);
}
}
if ($item)
{
$K2ItemExtraFieldsInstances[$item->id] = $rows;
}
$this->buildAliasBasedExtraFields($K2ItemExtraFieldsInstances[$item->id], $item);
return $K2ItemExtraFieldsInstances[$item->id];
}
function buildAliasBasedExtraFields($extraFields, &$item)
{
if (is_null($item))
{
return false;
}
if (!isset($item->extraFields))
{
$item->extraFields = new stdClass;
}
foreach ($extraFields as $extraField)
{
$tmpAlias = $extraField->alias;
$item->extraFields->$tmpAlias = $extraField;
}
}
}