-
Notifications
You must be signed in to change notification settings - Fork 62
Expand file tree
/
Copy pathforum.class.php
More file actions
625 lines (541 loc) · 26 KB
/
Copy pathforum.class.php
File metadata and controls
625 lines (541 loc) · 26 KB
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
<?php
/**
*
* @author user
*
*/
class EfrontForumException
{
}
//This file cannot be called directly, only included.
if (str_replace(DIRECTORY_SEPARATOR, "/", __FILE__) == $_SERVER['SCRIPT_FILENAME']) {
exit;
}
/**
*
* @author user
*
*/
class f_forums extends EfrontEntity
{
/**
*
* @var unknown_type
*/
public $tree;
/**
*
* @return unknown_type
*/
public function __construct($param) {
//$this -> entity = 'f_forums';
parent :: __construct($param);
}
/**
* (non-PHPdoc)
* @see libraries/EfrontEntity#delete()
*/
public function delete() {
$forumTree = self :: getForumTree();
$children = $forumTree[$this -> {$this -> entity}['id']]; //Get all the forum's direct siblings
for ($i = 0; isset($children[$i]); $i++) { //Find all the forum siblings' siblings
$children = array_merge ($children, $forumTree[$children[$i]]);
}
$children[] = $this -> {$this -> entity}['id']; //Append the deleted forum to the childrens list
$topics = eF_getTableDataFlat("f_topics", "id", "f_forums_ID in (".implode(",", $children).")"); //Get forums' topics
if (sizeof($topics) > 0) { //Delete forums' messages and topics
$fmid = eF_getTableDataFlat("f_messages", "id", "f_topics_ID in (".implode(",", $topics['id']).")");
if (sizeof($fmid) > 0) {
EfrontSearch :: removeText('f_messages', implode(",", $fmid['id']), '', true);
}
eF_deleteTableData("f_messages", "f_topics_id in (".implode(",", $topics['id']).")");
eF_deleteTableData("f_topics", "id in (".implode(",", $topics['id']).")");
}
$fpid = eF_getTableDataFlat("f_poll", "id", "f_forums_ID in (".implode(",", $children).")");
if (sizeof($fpid) > 0) {
EfrontSearch :: removeText('f_poll', implode(",", $fpid['id']), '', true);
}
eF_deleteTableData("f_poll", "f_forums_ID in (".implode(",", $children).")"); //Delete polls
EfrontSearch :: removeText('f_forums', implode(",", $children), '', true);
eF_deleteTableData("f_forums", "id in (".implode(",", $children).")"); //Finally, delete forums themselves
}
/**
*
* @param $forums
* @return unknown_type
*/
public static function getForumTree($forums = false) {
if ($forums === false) {
$forums = f_forums :: getAll("f_forums");
}
$forumTree = array();
$tempForums = $forums;
$count = 0;
//Convert array to tree. At the end of the loop, the $forums array will hold the forum tree, where each node is an array of its child nodes
while (sizeof($tempForums) > 0 && $count++ < 1000) { //$count is put here to prevent infinite loops
$node = current($tempForums); //Get the key/node pairs of the first array element
$key = key($tempForums);
$parent_id = $node['parent_id'];
$forumTree[$parent_id][] = $node['id']; //Append to the tree array, at the forum id index, the id of its child
if (!isset($forumTree[$node['id']])) {
$forumTree[$node['id']] = array();
}
$forums[$node['id']] = $node; //Copy node to forums, which will be used later as forums source
unset($tempForums[$key]); //We visited the node, so delete it from the (array) graph
reset($tempForums); //Fixed issue in getForumTree()(#1354)
}
return $forumTree;
}
/**
* (non-PHPdoc)
* @see libraries/EfrontEntity#getForm($form)
*/
public function getForm($form) {
$form -> addElement('text', 'title', _TITLE, 'class = "inputText"');
$form -> addRule('title', _THEFIELD.' "'._TITLE.'" '._ISMANDATORY, 'required', null, 'client');
$form -> addElement('select', 'status', _STATUS, array(1 => _PUBLIC, 2 => _LOCKED, 3 => _INVISIBLE));
$form -> addElement('textarea', 'comments', _COMMENTS, 'class = "inputTextarea simpleEditor"');
$form -> addElement('submit', 'submit_add_forum', _SUBMIT, 'class = "flatButton"');
$form -> setDefaults(array('title' => $this -> {$this -> entity}['title'],
'lessons_ID' => $this -> {$this -> entity}['lessons_ID'],
'status' => $this -> {$this -> entity}['status'],
'comments' => $this -> {$this -> entity}['comments']));
return $form;
}
/**
* (non-PHPdoc)
* @see libraries/EfrontEntity#handleForm($form)
*/
public function handleForm($form) {
$values = $form -> exportValues();
$fields = array("title" => $values['title'],
"lessons_ID" => isset($values['lessons_ID']) ? $values['lessons_ID'] : $defaultLesson,
"status" => isset($values['status']) ? $values['status']: 1,
"comments" => $values['comments']);
if (isset($_GET['edit'])) {
$this -> {$this -> entity} = array_merge($this -> {$this -> entity}, $fields);
$this -> persist();
} else {
$fields['users_LOGIN'] = $_SESSION['s_login'];
$fields['parent_id'] = isset($_GET['parent_forum_id']) ? $_GET['parent_forum_id'] : 0;
self :: create($fields);
}
}
/**
* (non-PHPdoc)
* @see libraries/EfrontEntity#persist()
*/
public function persist() {
parent :: persist();
//Propagate the forum status to all of its subforums and topics
$result = eF_getTableData("f_forums", "*", "id=".$this -> {$this -> entity}['id']);
$fields = $result[0];
$childrenTempList = array($result[0]['id']);
//pr($childrenTempList);
$childrenList = $childrenTempList;
while (!empty($childrenTempList)) {
$list = implode(",", $childrenTempList);
$result = eF_getTableDataFlat("f_forums", "id", "parent_id IN ($list)");
$childrenTempList = $result['id'];
if (!empty($childrenTempList)) {
$childrenList = array_merge($childrenList, $childrenTempList);
}
}
$list = implode(",",$childrenList);
eF_updateTableData("f_forums", array("status" => $fields['status']), "id IN ($list)");
eF_updateTableData("f_topics", array("status" => $fields['status']), "f_forums_ID IN ($list)");
EfrontSearch :: removeText('f_forums', $this -> {$this -> entity}['id'], '');
EfrontSearch :: insertText($fields['title'], $this -> {$this -> entity}['id'], "f_forums", "title");
if (mb_strlen($fields['comments']) > 3) {
EfrontSearch :: insertText(strip_tags($fields['comments']), $this -> {$this -> entity}['id'], "f_forums", "data");
}
}
/**
*
* @param $fields
* @return unknown_type
*/
public static function create($fields = array()) {
$new_id = eF_insertTableData("f_forums", $fields);
EfrontSearch :: insertText($fields['title'], $new_id, "f_forums", "title");
if (mb_strlen($fields['comments']) > 3) {
EfrontSearch :: insertText(strip_tags($fields['comments']), $new_id, "f_forums", "data");
}
$post_lesson_id = $post_lesson_name = null;
if (!empty($fields['lessons_ID']) && eF_checkParameter($fields['lessons_ID'], 'id')) {
$result = eF_getTableData("lessons", "id,name", "id={$fields['lessons_ID']}");
$post_lesson_id = $result[0]['id'];
$post_lesson_name = $result[0]['name'];
}
// Timelines add event
EfrontEvent::triggerEvent(array("type" => EfrontEvent::NEW_FORUM,
"users_LOGIN" => $_SESSION['s_login'],
"lessons_ID" => $post_lesson_id,
"lessons_name" => $post_lesson_name,
"entity_ID" => $new_id,
"entity_name" => $fields['title']));
}
/**
*
* @param $tree
* @param $node
* @param $topics
* @param $polls
* @param $messages
* @param $last_post
* @return unknown_type
*/
public static function calculateForumStats($tree, $node, $topics, $polls, $messages, &$last_post) {
$total = array();
$total['topics'] += $topics[$node];
$total['polls'] += $polls[$node];
$total['messages'] += $messages[$node];
$total['last_post'] = $last_post[$node];
foreach ($tree[$node] as $id) {
if (in_array($id, array_keys($tree))) {
$temp = self :: calculateForumStats($tree, $id, $topics, $polls, $messages, $last_post);
$total['topics'] += $temp['topics'];
$total['polls'] += $temp['polls'];
$total['messages'] += $temp['messages'];
$last_post[$node]['timestamp'] < $temp['last_post']['timestamp'] ? $last_post[$node] = $temp['last_post'] :'';
$total['last_post'] = $last_post[$node];
} else {
$total['topics'] += $topics[$id];
$total['polls'] += $polls[$id];
$total['messages'] += $messages[$id];
$last_post[$node]['timestamp'] < $temp['last_post']['timestamp'] ? $last_post[$node] = $temp['last_post'] :'';
$total['last_post'] = $last_post[$node];
}
}
return $total;
}
}
/**
*
* @author user
*
*/
class f_topics extends EfrontEntity
{
/**
*
* @return unknown_type
*/
public function __construct($param) {
$this -> entity = 'f_topics';
parent :: __construct($param);
}
/**
* (non-PHPdoc)
* @see libraries/EfrontEntity#delete()
*/
public function delete() {
$fmid = eF_getTableDataFlat("f_messages", "id", "f_topics_ID=".$this -> {$this -> entity}['id']);
eF_deleteTableData("f_messages", "f_topics_ID=".$this -> {$this -> entity}['id']);
parent :: delete();
if (sizeof($fmid['id']) > 0) {
EfrontSearch :: removeText('f_messages', implode(",", $fmid['id']), '', true);
}
EfrontSearch :: removeText('f_topics', $this -> {$this -> entity}['id'], '');
}
/**
* (non-PHPdoc)
* @see libraries/EfrontEntity#getForm($form)
*/
public function getForm($form) {
$form -> addElement('text', 'title', _TITLE, 'class = "inputText"');
$form -> addRule('title', _THEFIELD.' "'._TITLE.'" '._ISMANDATORY, 'required', null, 'client');
$form -> addElement('select', 'status', _STATUS, array(1 => _PUBLIC, 2 => _LOCKED, 3 => _INVISIBLE));
$form -> addElement('textarea', 'message', _MESSAGE, 'class = "inputTextarea simpleEditor"');
$form -> addElement('submit', 'submit_add_topic', _SUBMIT, 'class = "flatButton"');
$form -> setDefaults(array('title' => $this -> {$this -> entity}['title'],
'status' => $this -> {$this -> entity}['status']));
return $form;
}
/**
* (non-PHPdoc)
* @see libraries/EfrontEntity#handleForm($form)
*/
public function handleForm($form) {
$values = $form -> exportValues();
if (isset($_GET['edit'])) {
$fields = array("title" => $values['title'],
"status" => $values['status']);
$this -> {$this -> entity} = array_merge($this -> {$this -> entity}, $fields);
$this -> persist();
} else {
$fields = array("title" => $values['title'],
"message" => $values['message'],
"status" => $values['status'] ? $values['status'] : 1,
"f_forums_ID" => $_GET['forum_id'],
"users_LOGIN" => $_SESSION['s_login'],
"timestamp" => time(),
"sticky" => 0);
self :: create($fields);
}
}
public function persist() {
parent :: persist();
EfrontSearch :: removeText('f_topics', $this -> {$this -> entity}['id'], '');
EfrontSearch :: insertText($fields['title'], $this -> {$this -> entity}['id'], "f_topics", "title");
}
/**
*
* @param $fields
* @return unknown_type
*/
public static function create($fields = array()) {
//The message field is only used for creating the topic's initial message
$message = $fields['message'];
unset($fields['message']);
$topic_id = eF_insertTableData("f_topics", $fields);
$message_fields = array("title" => $fields['title'],
"body" => $message,
"f_topics_ID" => $topic_id,
"users_LOGIN" => $_SESSION['s_login'],
"timestamp" => time(),
"replyto" => 0);
$new_id = eF_insertTableData("f_messages", $message_fields);
EfrontSearch :: insertText($message_fields['title'], $new_id, "f_messages", "title");
EfrontSearch :: insertText($fields['title'], $topic_id, "f_topics", "title");
if (mb_strlen($message_fields['body']) > 3) {
EfrontSearch :: insertText(strip_tags($message_fields['body']), $new_id, "f_messages", "data");
}
$post_lesson_id = $post_lesson_name = null;
$result = eF_getTableData("lessons l, f_forums f", "l.id,l.name", "l.id=f.lessons_ID and f.id={$fields['f_forums_ID']}");
if (!empty($result)) {
$post_lesson_id = $result[0]['id'];
$post_lesson_name = $result[0]['name'];
}
// Timelines add event for topic
EfrontEvent::triggerEvent(array("type" => EfrontEvent::NEW_TOPIC,
"users_LOGIN" => $_SESSION['s_login'],
"lessons_ID" => $post_lesson_id,
"lessons_name" => $post_lesson_name,
"entity_ID" => $topic_id,
"entity_name" => $fields['title']));
//trigger event for message
EfrontEvent::triggerEvent(array("type" => EfrontEvent::NEW_FORUM_MESSAGE_POST,
"users_LOGIN" => $_SESSION['s_login'],
"lessons_ID" => $post_lesson_id,
"lessons_name" => $post_lesson_name,
"entity_ID" => $new_id,
"entity_name" => $fields['title']));
}
}
class f_messages extends EfrontEntity {
/**
*
* @return unknown_type
*/
public function __construct($param) {
$this -> entity = 'f_messages';
parent :: __construct($param);
}
/**
* (non-PHPdoc)
* @see libraries/EfrontEntity#delete()
*/
public function delete() {
parent :: delete();
EfrontSearch :: removeText('f_messages', $this -> {$this -> entity}['id'], '');
}
/**
* (non-PHPdoc)
* @see libraries/EfrontEntity#getForm($form)
*/
public function getForm($form) {
$form -> addElement('text', 'title', _TITLE, 'class = "inputText"');
$form -> addElement('textarea', 'body', _BODY, 'id = "editor_message_data" class = "inputTextarea simpleEditor"');
$form -> addElement('hidden', 'replyto', null);
$form -> addElement('submit', 'submit_add_message', _SUBMIT, 'class = "flatButton"');
if (isset($_GET['replyto']) && in_array($_GET['replyto'], $GLOBALS['legalValues'])) {
$replyto = eF_getTableData("f_messages", "*", "id=".$_GET['replyto']);
$form -> setDefaults(array('title' => 'Re: '.$replyto[0]['title']));
if (isset($_GET['quote'])) {
$form -> setDefaults(array('body' => '[quote]'.str_replace(array('<p>', '</p>'), '', $replyto[0]['body']).'[/quote]'));
}
}
$form -> setDefaults(array('title' => $this -> {$this -> entity}['title'],
'body' => $this -> {$this -> entity}['body']));
return $form;
}
/**
* (non-PHPdoc)
* @see libraries/EfrontEntity#handleForm($form)
*/
public function handleForm($form) {
$values = $form -> exportValues();
if (isset($_GET['edit'])) {
$fields = array("title" => $values['title'],
"body" => $values['body']);
$this -> {$this -> entity} = array_merge($this -> {$this -> entity}, $fields);
$this -> persist();
} else {
$fields = array("title" => $values['title'],
"body" => $values['body'],
"f_topics_ID" => $_GET['topic_id'],
"users_LOGIN" => $_SESSION['s_login'],
"timestamp" => time(),
"replyto" => $values['replyto'] ? $values['replyto'] : 0);
self :: create($fields);
}
}
/**
* (non-PHPdoc)
* @see libraries/EfrontEntity#persist()
*/
public function persist() {
parent :: persist();
EfrontSearch :: removeText('f_messages', $this -> {$this -> entity}['id'], '');
EfrontSearch :: insertText($fields['title'], $this -> {$this -> entity}['id'], "f_messages", "title");
if (mb_strlen($fields['body']) > 3) {
EfrontSearch :: insertText(strip_tags($fields['body']), $this -> {$this -> entity}['id'], "f_messages", "data");
}
}
/**
*
* @param $fields
* @return unknown_type
*/
public static function create($fields = array()) {
$new_id = eF_insertTableData("f_messages", $fields);
EfrontSearch :: insertText($fields['title'], $new_id, "f_messages", "title");
if (mb_strlen($fields['body']) > 3) {
EfrontSearch :: insertText(strip_tags($fields['body']), $new_id, "f_messages", "data");
}
$post_lesson_id = $post_lesson_name = null;
$result = eF_getTableData("lessons l, f_forums f, f_topics t", "l.id,l.name", "l.id=f.lessons_ID and f.id=t.f_forums_ID and t.id={$fields['f_topics_ID']}");
if (!empty($result)) {
$post_lesson_id = $result[0]['id'];
$post_lesson_name = $result[0]['name'];
}
// Timelines add event
EfrontEvent::triggerEvent(array("type" => EfrontEvent::NEW_FORUM_MESSAGE_POST,
"users_LOGIN" => $_SESSION['s_login'],
"lessons_ID" => $post_lesson_id,
"lessons_name" => $post_lesson_name,
"entity_ID" => $new_id,
"entity_name" => $fields['title']));
}
}
class f_poll extends EfrontEntity {
/**
*
* @return unknown_type
*/
public function __construct($param) {
$this -> entity = 'f_poll';
parent :: __construct($param);
}
/**
* (non-PHPdoc)
* @see libraries/EfrontEntity#delete()
*/
public function delete() {
$result = eF_getTableData("f_poll", "users_LOGIN", "id=".$this -> {$this -> entity}['id']); //Get poll information, to make sure that the user has the priviledge to delete it
eF_deleteTableData("f_users_to_polls", "f_poll_ID=".$this -> {$this -> entity}['id']);
parent :: delete();
EfrontSearch :: removeText('f_poll', $this -> {$this -> entity}['id'], '');
}
/**
* (non-PHPdoc)
* @see libraries/EfrontEntity#getForm($form)
*/
public function getForm($form) {
$form -> addElement('text', 'poll_subject', _SUBJECT, 'class = "inputText"');
$form -> addRule('poll_subject', _THEFIELD.' "'._TITLE.'" '._ISMANDATORY, 'required', null, 'client');
$form -> addElement('textarea', 'poll_text', _QUESTIONTEXT, 'class = "inputTextarea simpleEditor"');
$formatDate = eF_dateFormat();
$options = array(
'format' => $formatDate,
'minYear' => date("Y"),
'maxYear' => date('Y') + 2,
);
$form -> addElement('date', 'from', null, $options);
$form -> addElement('date', 'to', null, $options);
$form -> setDefaults(array('from' => time(), 'to' => time() + 30 * 86400)); //1 month forward
$form -> addElement('text', 'options[0]', _INSERTMULTIPLEQUESTIONS, 'class = "inputText inputText_QuestionChoice"');
$form -> addRule('options[0]', _THEFIELD.' "'._INSERTMULTIPLEQUESTIONS.'" '._ISMANDATORY, 'required', null, 'client');
$form -> addElement('text', 'options[1]', '', 'class = "inputText inputText_QuestionChoice"');
$form -> addRule('options[1]', _THEFIELD.' "'._INSERTMULTIPLEQUESTIONS.'" '._ISMANDATORY, 'required', null, 'client');
$form -> addElement('submit', 'submit_add_poll', _SUBMIT, 'class = "flatButton"');
$form -> setDefaults(array('poll_subject' => $this -> {$this -> entity}['title'],
'poll_text' => $this -> {$this -> entity}['question']));
$values['options'] = array_values(unserialize($this -> {$this -> entity}['options'])); //We put array_values to make sure that the array starts from zero
foreach ($values['options'] as $key => $value) {
if ($key > 2) {
$form -> addElement('text', 'options['.$key.']', null, 'class = "inputText inputText_QuestionChoice"');
$form -> addRule('options['.$key.']', _THEFIELD.' '._ISMANDATORY, 'required', null, 'client');
}
$form -> setDefaults(array('options['.$key.']' => htmlspecialchars_decode($value, ENT_QUOTES)));
}
return $form;
}
/**
* (non-PHPdoc)
* @see libraries/EfrontEntity#handleForm($form)
*/
public function handleForm($form) {
$values = $form -> getSubmitValues();
foreach ($values['options'] as $key => $value) {
$values['options'][$key] = htmlspecialchars($value, ENT_QUOTES,'UTF-8');
}
$options = serialize(array_values($values['options'])); //Array values are put here to reindex array, if the keys are not in order
$form_values = $form -> exportValues();
$start = mktime(0, 0, 0, $form_values['from']['m'], $form_values['from']['d'], $form_values['from']['Y']);
$end = mktime(0, 0, 0, $form_values['to']['m'], $form_values['to']['d'], $form_values['to']['Y']);
if ($start > $end) {
throw new Exception(_ENDDATEMUSTBEBEFORESTARTDATE);
} else if ($form -> validate()) {
$fields = array('options' => $options,
'title' => $form_values['poll_subject'],
'question' => $form_values['poll_text'],
'timestamp_start' => $start,
'timestamp_end' => $end);
if (isset($_GET['edit'])) { //If we are changing an existing question
$this -> {$this -> entity} = array_merge($this -> {$this -> entity}, $fields);
$this -> persist();
} else {
$fields['timestamp_created'] = time();
$fields['f_forums_ID'] = $_GET['forum_id'];
$fields['users_LOGIN'] = $_SESSION['s_login'];
self :: create($fields);
}
}
}
/**
* (non-PHPdoc)
* @see libraries/EfrontEntity#persist()
*/
public function persist() {
parent :: persist();
EfrontSearch :: removeText('f_poll', $this -> {$this -> entity}['id'], 'title');
EfrontSearch :: insertText($fields['title'], $this -> {$this -> entity}['id'], "f_poll", "title");
}
/**
*
* @param $fields
* @return unknown_type
*/
public static function create($fields = array()) {
$new_id = eF_insertTableData("f_poll", $fields);
EfrontSearch :: insertText($fields['title'], $new_id, "f_poll", "title");
if (mb_strlen($fields['question']) > 3) {
EfrontSearch :: insertText(strip_tags($fields['question']), $new_id, "f_poll","data");
}
$post_lesson_id = $post_lesson_name = null;
$result = eF_getTableData("lessons l, f_forums f", "l.id,l.name", "l.id=f.lessons_ID and f.id={$fields['f_forums_ID']}");
if (!empty($result)) {
$post_lesson_id = $result[0]['id'];
$post_lesson_name = $result[0]['name'];
}
// Timelines add event
EfrontEvent::triggerEvent(array("type" => EfrontEvent::NEW_POLL,
"users_LOGIN" => $_SESSION['s_login'],
"lessons_ID" => $post_lesson_id,
"lessons_name" => $post_lesson_name,
"entity_ID" => $new_id,
"entity_name" => $fields['title']));
}
}