1: <?php
2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14:
15:
16: defined('CON_FRAMEWORK') || die('Illegal call: Missing framework initialization - request aborted.');
17:
18: 19: 20: 21: 22: 23: 24:
25:
26: global $area;
27:
28: 29: 30:
31: class ArticleForumRightBottom extends cGuiPage {
32:
33: 34: 35:
36: private $_indentFactor = 20;
37:
38: 39: 40:
41: protected $_collection;
42:
43: 44: 45:
46: function __construct() {
47:
48: $this->_collection = new ArticleForumCollection();
49: parent::__construct('right_bottom', 'user_forum');
50: $this->addStyle('right_bottom.css');
51: $this->addScript('location.js');
52:
53: $this->setReload();
54: }
55:
56: 57: 58: 59: 60:
61: protected function formatTimeString($timeStamp) {
62: $nullstring = '0';
63: if ($timeStamp == "0000-00-00 00:00:00") {
64: return array();
65: } else {
66: $ar = (date_parse($timeStamp));
67:
68:
69: (strlen($ar['day']) < 2) ? $ar['day'] = $nullstring . $ar['day'] : '';
70: (strlen($ar['month']) < 2) ? $ar['month'] = $nullstring . $ar['month'] : '';
71: (strlen($ar['minute']) < 2) ? $ar['minute'] = $nullstring . $ar['minute'] : '';
72: (strlen($ar['hour']) < 2) ? $ar['hour'] = $nullstring . $ar['hour'] : '';
73: }
74:
75: return $ar;
76: }
77:
78: 79: 80: 81: 82: 83: 84: 85:
86: protected function checkValidEmail($emailadr, $realname) {
87: $regex = '/^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$/';
88:
89: if (preg_match($regex, $emailadr)) {
90: $mail = new cHTMLLink();
91: $mail->setClass('emailactive');
92: $mail->setLink("mailto:" . $emailadr);
93: $mail->setContent($realname);
94: } else {
95: $mail = new cHTMLLink();
96: $mail->setLink('#');
97: $mail->setClass('emaildeactive');
98: $mail->setContent($realname);
99: }
100: return $mail;
101: }
102:
103: 104: 105: 106: 107: 108: 109: 110: 111: 112:
113: protected function buildOnlineButtonBackendListMode(&$key, &$cont, &$cfg, $mod = null) {
114: global $area;
115: $buttons = array();
116:
117: $id = $cont['id_user_forum'];
118:
119:
120: $online = new cHTMLLink();
121: if ($cont['online'] == 1) {
122: $online->setImage($cfg['path']['images'] . 'online.gif');
123: $online->setCustom('action', 'online_toggle');
124: $online->setAlt(UserForum::i18n('SETOFFLINE'));
125: } else {
126: $online->setImage($cfg['path']['images'] . 'offline.gif');
127: $online->setCustom('action', 'offline_toggle');
128: $online->setAlt(UserForum::i18n('SETONLINE'));
129: }
130:
131: $online->setCLink($area, 4, 'show_form');
132: $online->setTargetFrame('right_bottom');
133: $online->setStyle('margin-right:10px;');
134:
135: $online->setCustom('action', 'online_toggle');
136: $online->setCustom('idart', $cont['idart']);
137: $online->setCustom('id_user_forum', $cont['id_user_forum']);
138: $online->setCustom('idcat', $cont['idcat']);
139: $online->setCustom('online', $cont['online']);
140:
141: $online->setAttribute('method', 'get');
142:
143:
144: $edit = new cHTMLButton("edit");
145: $edit->setImageSource($cfg['path']['images'] . 'but_todo.gif');
146: $edit->setEvent('click', "$('form[name=$id]').submit()");
147: $edit->setStyle('margin-right:10px; ');
148: $edit->setMode('image');
149: $edit->setAlt(UserForum::i18n('EDIT'));
150:
151:
152: if (isset($mod)) {
153: $online->setCustom('mod', true);
154:
155: }
156:
157: $message = UserForum::i18n('ALLDELETEFROMCATHIER');
158: $level = $cont['level'];
159: $keyy = $key;
160: $id = $cont['id_user_forum'];
161: $idacat = $cont['idcat'];
162: $idaart = $cont['idart'];
163:
164:
165: $deleteButton = '<a title="' . $cont['title'] . '" href="javascript:void(0)" onclick="Con.showConfirmation("' . $message . '", function(){ deleteArticlesByIdRight(' . $level . ', ' . $keyy . ', ' . $id . ', ' . $idacat . ', ' . $idaart . '); });return false;"><img src="' . $cfg['path']['images'] . 'delete.gif" border="0" title="' . $message . '" alt="' . $message . '"></a>';
166:
167:
168: $buttons['online'] = $online;
169: $buttons['edit'] = $edit;
170: $buttons['delete'] = $deleteButton;
171:
172: return $buttons;
173: }
174:
175: 176: 177: 178: 179: 180:
181: public function (&$result, $mod = null) {
182: $table = new cHTMLTable();
183: if (count($result) < 1) {
184: return new cHTMLTable();
185: }
186: $table->setCellPadding('100px');
187: global $area;
188: $table->updateAttributes(array(
189: "class" => "generic",
190: "cellspacing" => "0",
191: "cellpadding" => "2"
192: ));
193:
194: if (count($result) > 0) {
195: $tr = new cHTMLTableRow();
196: $th = new cHTMLTableHead();
197: $th->setContent(i18n("FORUM_POST", "user_forum"));
198: $th->setStyle('text-align: center');
199: $tr->appendContent($th);
200:
201: $th = new cHTMLTableHead();
202: $th->setContent(i18n("ACTIONS", "user_forum"));
203: $th->setStyle('widht:20px');
204: $th->setStyle('text-align: center');
205: $th->setAttribute('valign', 'top');
206: $tr->appendContent($th);
207:
208: $table->appendContent($tr);
209: }
210:
211: $menu = new cGuiMenu();
212: $cfg = cRegistry::getConfig();
213:
214: foreach ($result as $key => $cont) {
215:
216: $set = false;
217: $like = $cont['like'];
218: $dislike = $cont['dislike'];
219: $timestamp = $cont['timestamp'];
220:
221: $datearray = $this->formatTimeString($cont['timestamp']);
222: $date = (empty($datearray)) ? '' : $datearray['day'] . '.' . $datearray['month'] . '.' . $datearray['year'] . ' ' . UserForum::i18n("AT") . ' ' . $datearray['hour'] . ':' . $datearray['minute'] . ' ' . UserForum::i18n("CLOCK");
223:
224: $buttons = array();
225: $buttons = $this->buildOnlineButtonBackendListMode($key, $cont, $cfg, $mod);
226:
227: $online = $buttons['online'];
228: $edit = $buttons['edit'];
229: $delete = $buttons['delete'];
230:
231:
232: $tr = new cHTMLTableRow();
233: $trLike = new cHTMLTableRow();
234:
235: $likeButton = new cHTMLImage($cfg['path']['images'] . 'like.png');
236:
237: $dislikeButton = new cHTMLImage($cfg['path']['images'] . 'dislike.png');
238:
239:
240: $maili = $this->checkValidEmail($cont['email'], $cont['realname']);
241: $text = $cont['forum'];
242:
243: $timestamp = $cont['editedat'];
244:
245: $editarray = $this->formatTimeString($cont['editedat']);
246: $editdate = (empty($editarray)) ? '' : $editarray['day'] . '.' . $editarray['month'] . '.' . $editarray['year'] . ' ' . UserForum::i18n("AT") . ' ' . $editarray['hour'] . ':' . $editarray['minute'] . ' ' . UserForum::i18n("CLOCK");
247:
248: $userColl = new cApiUserCollection();
249: $user = $userColl->loadItem($cont['editedby'])->get('username');
250:
251: if (($cont['editedby'] != '') && ($cont['editedat'] != '') && $cont['editedat'] != "0000-00-00 00:00:00") {
252: $edit_information = (UserForum::i18n("EDITED") . $editdate . ' ' . UserForum::i18n("FROM") . $user);
253: $edit_information = "<em>$edit_information</em>";
254: } else {
255: $edit_information = "<br>";
256: }
257:
258: $tdEmpty = new cHTMLTableData();
259: $tdEmpty->appendContent($edit_information);
260: $tdLike = new cHTMLTableData();
261: $tdEmpty->setAttribute('valign', 'top');
262: $tdLike->setAttribute('valign', 'top');
263: $tdLike->setStyle('text-align: center');
264:
265:
266: $tdLike->appendContent($likeButton);
267: $tdLike->appendContent(" $like ");
268: $tdLike->appendContent($dislikeButton);
269: $tdLike->appendContent(" $dislike");
270:
271:
272: $trLike->appendContent($tdEmpty);
273: $trLike->appendContent($tdLike);
274:
275:
276: $form = new cHTMLForm($cont['id_user_forum']);
277: $form->setAttribute('action', 'main.php?' . "area=" . $area . '&frame=4');
278:
279: $tdForm = new cHTMLTableData();
280: $tdForm->setStyle('padding-left:' . $cont['level'] * $this->_indentFactor . 'px');
281:
282:
283: $tdButtons = new cHTMLTableData();
284: $tdButtons->setAttribute('valign', 'top');
285: $tdButtons->setStyle(' text-align: center');
286:
287: $tdButtons->appendContent($online);
288:
289:
290: $tdButtons->appendContent($edit);
291: if (!isset($mod)) {
292: $tdButtons->appendContent($delete);
293: }
294:
295: $tdButtons->appendContent('<br>');
296: $tdButtons->appendContent('<br>');
297:
298:
299: $hiddenIdart = new cHTMLHiddenField('idart');
300: $hiddenIdcat = new cHTMLHiddenField('idcat');
301: $hiddenId_user_forum = new cHTMLHiddenField('id_user_forum');
302: $hiddenLike = new cHTMLHiddenField('like');
303: $hiddenDislike = new cHTMLHiddenField('dislike');
304: $hiddenName = new cHTMLHiddenField('realname');
305: $hiddenEmail = new cHTMLHiddenField('email');
306: $hiddenLevel = new cHTMLHiddenField('level');
307: $hiddenEditdat = new cHTMLHiddenField('editedat');
308: $hiddenEditedby = new cHTMLHiddenField('editedby');
309: $hiddenTimestamp = new cHTMLHiddenField('timestamp');
310: $hiddenForum = new cHTMLHiddenField('forum');
311: $hiddenOnline = new cHTMLHiddenField('online');
312: $hiddenMode = new cHTMLHiddenField('mode');
313: $hiddenKey = new cHTMLHiddenField('key');
314: $hiddenaction = new cHTMLHiddenField('action');
315:
316:
317: $hiddenIdart->setValue($cont['idart']);
318: $hiddenIdcat->setValue($cont['idcat']);
319: $hiddenId_user_forum->setValue($cont['id_user_forum']);
320: $hiddenLike->setValue($cont['like']);
321: $hiddenDislike->setValue($cont['dislike']);
322: $hiddenName->setValue(str_replace('\\', '', conHtmlSpecialChars($cont['realname'])));
323: $hiddenEmail->setValue(str_replace('\\', '', conHtmlSpecialChars($cont['email'])));
324: $hiddenLevel->setValue($cont['level']);
325: $hiddenEditdat->setValue($cont['editedat']);
326: $hiddenEditedby->setValue($cont['editedby']);
327: $hiddenTimestamp->setValue($date);
328: $hiddenForum->setValue(str_replace('\\', '', conHtmlSpecialChars($cont['forum'])));
329: $hiddenOnline->setValue($cont['online']);
330: $hiddenMode->setValue('edit');
331: $hiddenKey->setValue($key);
332: $hiddenaction->setValue('edit');
333:
334:
335: $form->appendContent($hiddenIdart);
336: $form->appendContent($hiddenIdcat);
337: $form->appendContent($hiddenId_user_forum);
338: $form->appendContent($hiddenLike);
339: $form->appendContent($hiddenDislike);
340: $form->appendContent($hiddenName);
341: $form->appendContent($hiddenEmail);
342: $form->appendContent($hiddenLevel);
343: $form->appendContent($hiddenForum);
344: $form->appendContent($hiddenEditdat);
345: $form->appendContent($hiddenEditedby);
346: $form->appendContent($hiddenTimestamp);
347: $form->appendContent($hiddenMode);
348: $form->appendContent($hiddenOnline);
349: $form->appendContent($hiddenKey);
350: $form->appendContent($hiddenaction);
351:
352: if (isset($mod)) {
353: $form->appendContent(new cHTMLHiddenField('mod'));
354: }
355:
356:
357: $form->appendContent($date . " von " . str_replace('\\', '', $maili) . " <br><br>");
358: $form->appendContent((str_replace('\\', '', $text)) . "<br><br>");
359:
360: $tdForm->setContent($form);
361: $tdForm->setAttribute('valign', 'top');
362: $tr->setContent($tdForm);
363: $tr->appendContent($tdButtons);
364: $tr->appendContent($trLike);
365: $table->appendContent($tr);
366: }
367:
368: $this->appendContent($table);
369:
370: return $this;
371: }
372:
373: 374: 375: 376: 377: 378:
379: protected function ($post) {
380:
381: global $area;
382: $changes = 0;
383: $cfg = cRegistry::getConfig();
384: $idart = cRegistry::getArticleId();
385: $idcat = cRegistry::getCategoryId();
386: $menu = new cGuiMenu();
387: $tr = new cHTMLTableRow();
388:
389: $th = new cHTMLTableHead();
390: $th->setContent(UserForum::i18n("PARAMETER", "user_forum"));
391:
392: $th2 = new cHTMLTableHead();
393: $th2->setContent(UserForum::i18n("CONTENT", "user_forum"));
394: $th2->setStyle('widht:50px');
395: $th2->setAttribute('valign', 'top');
396: $tr->appendContent($th);
397: $tr->appendContent($th2);
398:
399:
400: $form1 = new cGuiTableForm("comment", "main.php?area=user_forum&frame=4", "post");
401: $form1->addHeader($tr);
402: $form1->setTableID("table");
403:
404: $user = new cApiUser();
405: $user->loadByPrimaryKey($post['editedby']);
406: $username = $user->getField('username');
407:
408: $id = $post['id_user_forum'];
409:
410: $likeButton = new cHTMLImage($cfg['path']['images'] . 'like.png');
411: $dislikeButton = new cHTMLImage($cfg['path']['images'] . 'dislike.png');
412:
413:
414: $name = new cHTMLTextBox("realname", str_replace('\\', '',(conHtmlSpecialChars($post['realname']))), 30, 255);
415: $email = new cHTMLTextBox("email", $post['email'], 30, 255);
416: $like = new cHTMLTextBox("like", $post['like'], 7, 7);
417: $dislike = new cHTMLTextBox("dislike", $post['dislike'], 7, 7);
418:
419: $text = str_replace("<br />", "\n", conHtmlSpecialChars($post['forum']));
420: $text = str_replace('\\', '', $text);
421:
422: $forum = new cHTMLTextArea("forum", $text);
423:
424: $datearray = $this->formatTimeString($post['timestamp']);
425: $date = (empty($datearray)) ? '' : $datearray['day'] . '.' . $datearray['month'] . '.' . $datearray['year'] . ' ' . UserForum::i18n("AT") . ' ' . $datearray['hour'] . ':' . $datearray['minute'] . ' ' . UserForum::i18n("CLOCK");
426:
427: $editedatearray = $this->formatTimeString($post['editedat']);
428: $editedat = (empty($editedatearray)) ? '' : $editedatearray['day'] . '.' . $editedatearray['month'] . '.' . $editedatearray['year'] . ' ' . UserForum::i18n("AT") . ' ' . $editedatearray['hour'] . ':' . $editedatearray['minute'] . ' ' . UserForum::i18n("CLOCK");
429:
430: $timestamp = new cHTMLTextBox("timestamp", $date, 30, 255);
431: $editedat = new cHTMLTextBox("editedat", $editedat, 30, 255);
432: $editedby = new cHTMLTextBox("editedby", $username, 30, 255);
433:
434: $editedat->setDisabled(true);
435: $timestamp->setDisabled(true);
436: $editedby->setDisabled(true);
437:
438:
439: $form1->add(UserForum::i18n("USER"), $name, '');
440: $form1->add(UserForum::i18n("EMAIL"), $email, '');
441: $form1->add(UserForum::i18n("LIKE"), $like, '');
442: $form1->add(UserForum::i18n("DISLIKE"), $dislike, '');
443: $form1->add(UserForum::i18n("TIME"), $timestamp, '');
444: $form1->add(UserForum::i18n("EDITDAT"), $editedat, '');
445: $form1->add(UserForum::i18n("EDITEDBY"), $editedby, '');
446:
447:
448: if (isset($post['mod'])) {
449: $form1->setVar('mod', 'mod');
450: $form1->addCancel("main.php?area=user_forum&frame=4&action=back&mod=mod");
451: } else {
452: $form1->addCancel("main.php?area=user_forum&frame=4&action=back&idart=$idart&idcat=$idcat");
453: }
454:
455: $onlineBox = new cHTMLCheckbox("onlineState", "");
456:
457: $onlineBox->setChecked(($post['online'] == 1) ? true : false);
458: $form1->add(UserForum::i18n("ONLINE"), $onlineBox, '');
459:
460: $idart = $post['idart'];
461: $idcat = $post['idcat'];
462:
463: $form1->add(UserForum::i18n("COMMENT"), $forum, '');
464:
465:
466: $form1->setVar("id_user_forum", $post['id_user_forum']);
467: $form1->setVar("idart", $post['idart']);
468: $form1->setVar("idcat", $post['idcat']);
469: $form1->setVar("action", 'update');
470: $form1->setVar("mode", "list");
471: $form1->setVar("activeChanges", $changes);
472:
473: $this->appendContent($form1);
474:
475: return $this;
476: }
477:
478: 479: 480: 481: 482: 483: 484:
485: public function getForum($id_cat, $id_art, $id_lang) {
486: $arrUsers = $this->_collection->getExistingforum();
487:
488: $arrforum = array();
489:
490: $this->_collection->getTreeLevel($id_cat, $id_art, $id_lang, $arrUsers, $arrforum);
491: $result = array();
492: $this->normalizeArray($arrforum, $result);
493:
494: $ret = $this->getMenu($result);
495:
496: return $ret;
497: }
498:
499: 500: 501: 502: 503:
504: protected function normalizeArray($arrforum, &$result, $level = 0) {
505: if (is_array($arrforum)) {
506: foreach ($arrforum as $key => $value) {
507: $value['level'] = $level;
508: unset($value['children']);
509: $result[$key] = $value;
510: $this->normalizeArray($arrforum[$key]['children'], $result, $level + 1);
511: }
512: }
513: }
514:
515: 516: 517: 518: 519: 520: 521: 522:
523: public function receiveData(&$get, &$post) {
524: if (isset($_REQUEST['action']) && $_REQUEST['action'] != NULL) {
525: $this->switchActions();
526: }
527: }
528:
529:
530: 531:
532: public function getStartpage() {
533:
534:
535: $cGuiNotification = new cGuiNotification();
536: echo $cGuiNotification->returnNotification(cGuiNotification::LEVEL_INFO, UserForum::i18n('MODMODE'));
537: echo '<br />';
538:
539: $comments = $this->_collection->getUnmoderatedComments();
540: $this->getMenu($comments, 'mod');
541:
542: }
543:
544:
545: 546: 547: 548: 549:
550: protected function switchActions() {
551:
552: $lang = cRegistry::getLanguageId();
553: $idart = $_REQUEST['idart'];
554: $idcat = $_REQUEST['idcat'];
555: $action = $_REQUEST["action"];
556: $online = (isset($_REQUEST['onlineState'])) ? 1 : 0;
557:
558:
559: switch ($action) {
560:
561:
562: case 'online_toggle':
563: $this->_collection->toggleOnlineState($_REQUEST['online'], $_REQUEST['id_user_forum'], $idart);
564:
565: if(!isset($_REQUEST['mod'])) {
566: $this->getForum($idcat, $idart, $lang);
567: } else{
568: $this->getStartpage();
569: }
570:
571: break;
572:
573: case 'deleteComment':
574: $this->_collection->deleteHierarchy($_REQUEST['key'], $_REQUEST['level'], $idart, $idcat, $lang);
575: $this->getForum($idcat, $idart, $lang);
576: break;
577:
578: case 'update':
579: $this->_collection->updateValues($_POST['id_user_forum'], $_POST['realname'], $_POST['email'], $_POST['like'], $_POST['dislike'], $_POST['forum'], $online);
580: if(!isset($_REQUEST['mod'])) {
581: $this->getForum($idcat, $idart, $lang);
582: } else{
583: $this->getStartpage();
584: }
585:
586: break;
587: case 'show_form':
588:
589: $this->getForum($idcat, $idart, $lang);
590: break;
591: case 'edit':
592:
593: $this->getEditModeMenu($_POST);
594: break;
595:
596: case 'back':
597: if(!isset($_REQUEST['mod'])) {
598: $this->getForum($idcat, $idart, $lang);
599: } else{
600: $this->getStartpage();
601: }
602:
603: break;
604: case 'empty':
605:
606: break;
607: default:
608: $this->getForum($idcat, $idart, $lang);
609: throw new Exception('$_GET["action"] type ' . $_REQUEST["action"] . ' not implemented');
610: }
611: }
612:
613: }
614:
615: ?>