Overview

Packages

  • Core
    • Authentication
    • Backend
    • Cache
    • CEC
    • Chain
    • ContentType
    • Database
    • Datatype
    • Debug
    • Exception
    • Frontend
      • Search
      • URI
      • Util
    • GenericDB
      • Model
    • GUI
      • HTML
    • I18N
    • LayoutHandler
    • Log
    • Security
    • Session
    • Util
    • Validation
    • Versioning
    • XML
  • Module
    • ContentSitemapHtml
    • ContentSitemapXml
    • ContentUserForum
    • NavigationMain
    • NavigationTop
  • mpAutoloaderClassMap
  • None
  • Plugin
    • ContentAllocation
    • CronjobOverview
    • FormAssistant
    • FrontendLogic
    • FrontendUsers
    • Linkchecker
    • ModRewrite
    • Newsletter
    • Repository
      • FrontendNavigation
      • KeywordDensity
    • SearchSolr
    • SmartyWrapper
    • UrlShortener
    • UserForum
    • Workflow
  • PluginManager
  • Setup
    • Form
    • GUI
    • Helper
      • Environment
      • Filesystem
      • MySQL
      • PHP
    • UpgradeJob

Classes

  • UserForumArticle
  • Overview
  • Package
  • Class
  • Tree
  • Deprecated
  • Todo
  1: <?php
  2: 
  3: /**
  4:  * description:
  5:  *
  6:  * @package Module
  7:  * @subpackage ContentUserForum
  8:  * @version SVN Revision $Rev:$
  9:  *
 10:  * @author claus.schunk@4fb.de
 11:  * @copyright four for business AG <www.4fb.de>
 12:  * @license http://www.contenido.org/license/LIZENZ.txt
 13:  * @link http://www.4fb.de
 14:  * @link http://www.contenido.org
 15:  */
 16: 
 17: defined('CON_FRAMEWORK') or die('Illegal call');
 18: //call userforum administration
 19: if(cRegistry::isBackendEditMode()){
 20:     echo "CMS_USERFORUM[2]";
 21: }
 22: 
 23: /**
 24:  *
 25:  * @author claus.schunk
 26:  */
 27: class UserForumArticle {
 28: 
 29:     /**
 30:      *
 31:      * @var unknown_type
 32:      */
 33:     protected $_qoute = true;
 34: 
 35:     /**
 36:      *
 37:      * @var unknown_type
 38:      */
 39:     protected $_messageText = '';
 40: 
 41:     /**
 42:      *
 43:      * @var unknown_type
 44:      */
 45:     protected $_generate = true;
 46: 
 47:     /**
 48:      *
 49:      * @var unknown_type
 50:      */
 51:     protected $_allowDeleting;
 52: 
 53:     /**
 54:      *
 55:      * @var unknown_type
 56:      */
 57:     protected $_userLoggedIn;
 58: 
 59:     /**
 60:      *
 61:      * @var unknown_type
 62:      */
 63:     protected $_allowedToEditForum;
 64: 
 65:     /**
 66:      *
 67:      * @var unknown_type
 68:      */
 69:     protected $_modMode;
 70: 
 71:     /**
 72:      *
 73:      * @access protected
 74:      * @var cSmartyFrontend
 75:      */
 76:     protected $_tpl;
 77: 
 78:     /**
 79:      *
 80:      * @access protected
 81:      * @var string email
 82:      */
 83:     protected $_currentEmail;
 84: 
 85:     /**
 86:      *
 87:      * @access protected
 88:      * @var string realname
 89:      */
 90:     protected $_currentRealname;
 91: 
 92:     /**
 93:      *
 94:      * @access protected
 95:      * @var bool counter
 96:      *      used from checkCookie for validation if like/dislike feature was
 97:      *      already used from same user.
 98:      */
 99:     protected $_counter;
100: 
101:     /**
102:      *
103:      * @access protected
104:      * @var int articleId
105:      */
106:     protected $_idart;
107: 
108:     /**
109:      *
110:      * @access protected
111:      * @var int CategoryId
112:      */
113:     protected $_idcat;
114: 
115:     /**
116:      *
117:      * @access protected
118:      * @var int LanguageId
119:      */
120:     protected $_idlang;
121: 
122:     /**
123:      *
124:      * @access protected
125:      * @var string userid
126:      */
127:     protected $_userid;
128: 
129:     /**
130:      *
131:      * @access protected
132:      * @var ArticleForumCollection
133:      */
134:     protected $_collection;
135: 
136:     /**
137:      *
138:      */
139:     public function __construct() {
140:         $this->_tpl = cSmartyFrontend::getInstance();
141:         $this->_messageText = '';
142:         $this->_generate = true;
143:         $this->_idart = cRegistry::getArticleId();
144:         $this->_idcat = cRegistry::getCategoryId();
145:         $this->_idlang = cRegistry::getLanguageId();
146:         $this->_collection = new ArticleForumCollection();
147:         $this->_qoute = ($this->_collection->getQuoteState($this->_idart));
148:         $this->_modMode = ($this->_collection->getModeModeActive($this->_idart));
149:     }
150: 
151:     /**
152:      * main method for controlling different actions received from $_REQUEST[]
153:      *
154:      * @param received $_REQUEST[]
155:      */
156:     public function receiveData(array $request) {
157:         $this->_checkCookie();
158: 
159:         (stristr($auth->auth['perm'], 'admin') === FALSE)? $this->_allowDeleting = false : $this->_allowDeleting = true;
160:         (getEffectiveSetting('user_forum', 'allow_anonymous_forum', '1') == '1')? $bAllowAnonymousforum = true : $bAllowAnonymousforum = false;
161: 
162:         $this->_getUser($auth->auth['uid']);
163:         ($bAllowAnonymousforum || $this->_userLoggedIn && !$bAllowAnonymousforum)? $this->_allowedToEditForum = true : $this->_allowedToEditForum = false;
164: 
165:         switch ($_REQUEST['user_forum_action']) {
166:             // user interaction click on like button
167:             case 'like_forum':
168:                 $this->_incrementLike();
169:                 $this->_listForum();
170:                 break;
171:             // user interaction click on dislike button
172:             case 'dislike_forum':
173:                 $this->_incrementDislike();
174:                 $this->_listForum();
175:                 break;
176:             // user interaction click on new comment
177:             case 'new_forum':
178:                 $this->_newEntry();
179:                 break;
180:             // user interaction click at save in input new comment dialog
181:             case 'save_new_forum':
182:                 if($this->_modMode && $this->_saveForum()){
183:                     echo '<br />';
184:                     echo mi18n("FEEDBACK");
185:                 }
186:                 $this->_listForum();
187:                 break;
188:             default:
189:                 $this->_listForum();
190:                 break;
191:         }
192:     }
193: 
194:     /**
195:      *
196:      * @param unknown_type $userid
197:      */
198:     private function _getUser($userid) {
199:         $db = cRegistry::getDb();
200:         $cfg = cRegistry::getConfig();
201:         if (($userid != '') && ($userid != 'nobody')) {
202:             $this->_userLoggedIn = true;
203:             $user = $this->_collection->selectUser($userid);
204:             $this->_currentEmail = $user['email'];
205:             $this->_currentRealname = $user['realname'];
206:         } else {
207:             $this->_userLoggedIn = false;
208:             $this->_userid = '';
209:         }
210:     }
211: 
212:     /**
213:      * increments the current number of likes
214:      */
215:     private function _incrementLike() {
216:         $form_id = (int) $_REQUEST['user_forum_id'];
217:         if ($form_id > 0 && $this->_counter) {
218:             $this->_collection->incrementLike($form_id);
219:         }
220:     }
221: 
222:     /**
223:      * increments the current number of dislikes
224:      */
225:     private function _incrementDislike() {
226:         $form_id = (int) $_REQUEST['user_forum_id'];
227:         if ($form_id > 0 && $this->_counter) {
228:             $this->_collection->incrementDislike($form_id);
229:         }
230:     }
231: 
232:     /**
233:      * submit for new entry will be called after click at new comment
234:      */
235:     private function _saveForum() {
236:         $regex = '/^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$/';
237:         // Run the preg_match() function on regex against the email address
238: 
239:         if ($this->_allowedToEditForum) {
240: 
241:             $this->_userid = $_REQUEST['userid'];
242:             $this->_allowDeleting = $_REQUEST['deleting'];
243:             $contenido = $_REQUEST['contenido'];
244:             $bInputOK = true;
245: 
246:             $email = trim($_REQUEST['email']);
247:             $realname = trim($_REQUEST['realname']);
248:             $forum = trim($_REQUEST['forum']);
249:             $parent = (int) $_REQUEST['user_forum_parent'];
250:             $forum_quote = trim($_REQUEST['forum_quote']);
251: 
252:             $this->_getUser($this->_userid);
253: 
254:             // error validation for user inputs
255:             if ($this->_userLoggedIn) {
256:                 if ($forum == '') {
257:                     $this->_messageText .= mi18n("enterYourArticle") . '<br />';
258:                     $bInputOK = false;
259:                 }
260:             } else {
261: 
262:                 if ($email == '') {
263:                     $this->_messageText .= mi18n("enterYourMail") . '<br />';
264:                     $bInputOK = false;
265:                 }
266:                 if ($email != '') {
267:                     if (!preg_match($regex, $email)) {
268:                         $this->_messageText .= mi18n("enterValidMail") . '<br />';
269:                         $bInputOK = false;
270:                     }
271:                 }
272: 
273:                 if ($realname == '') {
274:                     $this->_messageText .= mi18n("enterYourName") . '<br />';
275:                     $bInputOK = false;
276:                 }
277: 
278:                 if ($forum == '') {
279:                     $this->_messageText .= mi18n("enterYourArticle") . '<br />';
280:                     $bInputOK = false;
281:                 }
282:             }
283: 
284:             if ($bInputOK) {
285:                 // build array for language synchonisation
286:                 $ar = array(
287:                     'NEWENTRY' => mi18n("NEWENTRY"),
288:                     'NEWENTRYTEXT' => mi18n("NEWENTRYTEXT"),
289:                     'COMMENT' => mi18n("COMMENT"),
290:                     'USER' => mi18n("USER"),
291:                     'EMAIL' => mi18n("EMAILADR"),
292:                     'ARTICLE' => mi18n("INARTICLE")
293:                 );
294:                 $this->_collection->languageSync($ar);
295:                 // var_dump($this->_collection->getlanguageSync());
296:                 // persist comment
297:                 $this->_collection->insertValues($parent, $this->_idart, $this->_idcat, $this->_idlang, $this->_userid, $email, $realname, $forum, $forum_quote);
298: 
299:                 $this->_messageText .= mi18n("yourArticleSaved");
300:             } else {
301: 
302:                 $this->_tpl->assign('MESSAGE', $this->_messageText);
303: 
304:                 if ($this->_userLoggedIn) {
305:                     $this->_tpl->assign('INPUT_EMAIL', $this->_currentEmail . "<input type=\"hidden\" name=\"email\" value=\"$this->_currentEmail\" />");
306:                     $this->_tpl->assign('INPUT_REALNAME', $this->_currentRealname . "<input type=\"hidden\" name=\"realname\" value=\"$this->_currentRealname\" />");
307:                     $this->_tpl->assign('INPUT_FORUM', $forum);
308:                 } else {
309:                     $this->_tpl->assign('INPUT_EMAIL', "<input type=\"text\" name=\"email\" value=\"$email\" />");
310:                     $this->_tpl->assign('INPUT_REALNAME', "<input type=\"text\" name=\"realname\" value=\"$realname\" />");
311:                     $this->_tpl->assign('INPUT_FORUM', $forum);
312:                     $this->_tpl->assign('INPUT_FORUM_QUOTE', $forum_quote);
313:                 }
314: 
315:                 if (strlen($forum_quote) > 0) {
316:                     $this->_tpl->assign('DISPLAY', 'display:block');
317:                     $this->_tpl->assign('INPUT_FORUM_QUOTE', $forum_quote);
318:                 } else {
319:                     $this->_tpl->assign('DISPLAY', 'display:none');
320:                     $this->_tpl->assign('INPUT_FORUM_QUOTE', '');
321:                 }
322: 
323:                 $this->_tpl->assign('REALNAME', mi18n("yourName"));
324:                 $this->_tpl->assign('EMAIL', mi18n("yourMailAddress"));
325:                 $this->_tpl->assign('FORUM', mi18n("yourArticle"));
326:                 $this->_tpl->assign('FORUM_QUOTE', mi18n("quote"));
327:                 $this->_tpl->assign('IDCAT', $this->_idcat);
328:                 $this->_tpl->assign('IDART', $this->_idart);
329:                 $this->_tpl->assign('SAVE_FORUM', mi18n("saveArticle"));
330:                 $this->_tpl->assign('USER_FORUM_PARENT', (int) $_REQUEST['user_forum_parent']);
331: 
332:                 $this->_tpl->assign('CANCEL_FORUM', mi18n("cancel"));
333:                 $this->_tpl->assign('CANCEL_LINK', "front_content.php?idart=$this->_idart");
334: 
335:                 $this->_tpl->assign('USERID', $this->_userid);
336:                 $this->_tpl->assign('CONTENIDO', $contenido);
337: 
338:                 // check for replied comments
339:                 $replyId = (int) $_REQUEST['user_forum_parent'];
340:                 if ($replyId > 0) {
341: 
342:                     $content = $this->_collection->selectNameAndNameByForumId($replyId);
343:                     (count($content) > 0)? $empty = false : $empty = true;
344: 
345:                     if (!$empty) {
346:                         $transTemplate = mi18n("answerToQuote");
347:                         $transTemplateAfter = mi18n("from");
348:                         $this->_tpl->assign('FORUM_REPLYMENT', $transTemplate . '<br/>' . $content['forum'] . "<br/><br/>" . $transTemplateAfter . ' ' . $content['realname']);
349:                     } else {
350:                         $this->_tpl->assign('FORUM_REPLYMENT', '');
351:                     }
352:                 } else {
353:                     $this->_tpl->assign('FORUM_REPLYMENT', '');
354:                 }
355: 
356:                 $this->_generate = false;
357:                 // template for new entry
358:                 $this->_tpl->display('user_forum_new.tpl');
359:             }
360:         }
361:         return $bInputOK;
362:     }
363: 
364:     /**
365:      * displays all existing comments
366:      */
367:     private function _listForum() {
368:         $linkText = "$this->_userid&deleting=$this->_allowDeleting&idart=$this->_idart";
369:         if ($this->_generate) {
370: 
371:             // fetch all comments for this article from db.
372:             $arrUserforum = $this->_collection->getExistingforumFrontend($this->_idcat, $this->_idart, $this->_idlang, true);
373: 
374:             if (count($arrUserforum) == 0) {
375:                 $this->_tpl->assign('MESSAGE', mi18n("noCommentsYet"));
376:                 $this->_tpl->assign('FORUM_TEXT', mi18n("articles"));
377:                 $this->_tpl->assign(mi18n("writeNewEntry"));
378:                 if ($this->_allowedToEditForum) {
379:                     $link = $linkText;
380:                     $this->_tpl->assign('LINK_NEW_FORUM', $link);
381:                 } else {
382:                     $this->_tpl->assign('LINK_NEW_FORUM', mi18n("noPosibleInputForArticle"));
383:                 }
384:                 $this->_tpl->assign('LINKTEXT', mi18n("writeNewEntry"));
385:                 $this->_tpl->display('user_forum_list_empty.tpl');
386:             } else {
387:                 $this->_tpl->assign('MESSAGE', $this->_messageText);
388:                 $this->_tpl->assign('AMOUNT_forum', count($arrUserforum));
389:                 $this->_tpl->assign('FORUM_TEXT', mi18n("articlesLabel"));
390: 
391:                 $number = 1;
392:                 $tplData = array();
393: 
394:                 // build array for smarty
395:                 foreach ($arrUserforum as $key => $value) {
396: 
397:                     $record = array();
398:                     $record['REALNAME'] = str_replace('\\','',$value['realname']);
399:                     $record['EMAIL'] =   str_replace('\\','',$value['email']);
400:                     $record['NUMBER'] = $number;
401:                     $number++;
402: 
403:                     // string manipulation for time
404:                     $arrTmp = preg_split('/ /', $value['timestamp']);
405:                     $arrTmp2 = preg_split('/-/', $arrTmp[0]);
406:                     $ts = $arrTmp2[2] . '.' . $arrTmp2[1] . '.' . $arrTmp2[0] . ' ' . mi18n("about") . ' ';
407:                     $ts .= substr($arrTmp[1], 0, 5) . ' ' . mi18n("clock");
408: 
409:                     $record['AM'] = mi18n("AM");
410:                     $record['WROTE_ON'] = mi18n("wroteAt");
411:                     $record['WRITE_EMAIL'] = mi18n("emailToAuthor");
412:                     $record['TIMESTAMP'] = $ts;
413: 
414:                     if (strlen($value['forum_quote']) > 0) {
415:                         $record['FORUM_QUOTE'] = '<div class="forum_quote">' . $value['forum_quote'] . '</div>';
416:                     } else {
417:                         $record['FORUM_QUOTE'] = '';
418:                     }
419: 
420:                     $record['FORUM'] = str_replace('\\','',$value['forum']);
421: 
422:                     if (($value['editedby'] != '') && ($value['editedat'] != "0000-00-00 00:00:00")) {
423: 
424:                         // string manipulation for edittime
425:                         $arrTmp = explode(' ', $value['editedat']);
426:                         $edittime = substr($arrTmp[1], 0, 5);
427:                         $arrTmp2 = explode('-', $arrTmp[0]);
428:                         $editdate = $arrTmp2[2] . '.' . $arrTmp2[1] . '.' . $arrTmp2[0];
429: 
430:                         // displays information if the comment was edited in
431:                         // backend mode.
432:                         $tmp = mi18n("articleWasEditAt");
433: 
434:                         $userColl = new cApiUserCollection();
435:                         $user = $userColl->loadItem($value['editedby'])->get('username');
436: 
437:                         $edit_information = sprintf($tmp, $editdate, $edittime, $user);
438:                         $record['EDIT_INFORMATION'] = "<br /><br /><em>$edit_information</em>";
439:                     }
440: 
441:                     // ansers allowed or not.
442:                     if ($this->_qoute) {
443:                         $record['REPLY'] = sprintf($linkText, $key);
444:                     } else {
445:                         $record['REPLY'] = NULL;
446:                     }
447: 
448:                     $record['REPLY_QUOTE'] = sprintf($linkText, $key, $key);
449:                     $record['LIKE'] = sprintf($linkText, $key, $value['like']);
450:                     $record['DISLIKE'] = sprintf($linkText, $key, $value['dislike']);
451:                     $record['FROM'] = mi18n("from");
452:                     $record['OPINION'] = mi18n("sameOpinion");
453:                     $record['LIKE_COUNT'] = $value['like'];
454:                     $record['DISLIKE_COUNT'] = $value['dislike'];
455:                     $record['PADDING'] = $value['level'] * 20;
456:                     $record['LINKTEXT'] = mi18n("writeNewEntry");
457:                     $record['REPLYTEXT'] = mi18n("answers");
458:                     $record['QUOTETEXT'] = mi18n("replyQuote");
459:                     $record['FORMID'] = $value['id_user_forum'];
460:                     $record['LINKBEGIN'] = "";
461:                     $record['LINKEND'] = "";
462:                     $record['MAILTO'] = '#';
463:                     $record['EMAIL'] = '';
464: 
465:                     array_push($tplData, $record);
466:                 }
467: 
468:                 $this->_tpl->assign('POSTS', $tplData);
469: 
470:                 $sTemp = mi18n("showHideArticles");
471:                 $sTemp = str_replace('___', count($arrUserforum), $sTemp);
472: 
473:                 if ($this->_allowedToEditForum) {
474:                     $link = $linkText;
475: 
476:                     $tplOptionList = new cTemplate();
477:                     $tplOptionList->set('s', 'SHOW_forum', $sTemp);
478: 
479:                     $this->_tpl->assign('SHOW_FORUM_OPTION', $tplOptionList->generate('templates/user_forum_option_list.tpl', 1));
480:                     $this->_tpl->assign('LINKTEXT', mi18n("writeNewEntry"));
481:                     $this->_tpl->assign('LINK_NEW_FORUM', $linkText);
482:                 } else {
483:                     $this->_tpl->assign('LINK_NEW_FORUM', mi18n("noPosibleInputForArticle"));
484:                 }
485: 
486:                 $this->_tpl->assign('NUM_FORUM', count($arrUserforum));
487:                 // template : list all entries
488:                 $this->_tpl->display('user_forum_list.tpl');
489:             }
490:         }
491:     }
492: 
493:     /**
494:      * generate view for new entrys
495:      */
496:     private function _newEntry() {
497:         if ($this->_allowedToEditForum) {
498:             $db = cRegistry::getDb();
499:             $this->_tpl->assign('MESSAGE', $this->_messageText);
500:             $idquote = (int) $_REQUEST['user_forum_quote'];
501: 
502:             if ($idquote > 0) {
503:                 $content = $this->_collection->selectNameAndNameByForumId($idquote);
504:                 (count($content) > 0)? $empty = false : $empty = true;
505:                 if (!$empty) {
506:                     $transTemplate = mi18n("quoteFrom");
507:                     $this->_tpl->assign('INPUT_FORUM_QUOTE', $transTemplate . ' ' . $content['realname'] . "\n" . $content['forum']);
508:                     $this->_tpl->assign('DISPLAY', 'display:block');
509:                 } else {
510:                     $this->_tpl->assign('DISPLAY', 'display:none');
511:                     $this->_tpl->assign('INPUT_FORUM_QUOTE', '');
512:                 }
513:             } else {
514:                 $this->_tpl->assign('DISPLAY', 'display:none');
515:                 $this->_tpl->assign('INPUT_FORUM_QUOTE', '');
516:             }
517: 
518:             $replyId = (int) $_REQUEST['user_forum_parent'];
519: 
520:             if ($replyId > 0) {
521:                 $content = $this->_collection->selectNameAndNameByForumId($replyId);
522:                 (count($content) > 0)? $empty = false : $empty = true;
523: 
524:                 if (!$empty) {
525:                     // Quote anser content
526:                     $ar = $this->_collection->getCommentContent($replyId);
527:                     $transTemplate = mi18n("answerToQuote");
528:                     $transTemplateContent = $ar['content'];
529:                     $transTemplateAfter = mi18n("from");
530:                     $transTemplateName = $ar['name'];
531:                     $this->_tpl->assign('FORUM_REPLYMENT', $transTemplate . '<br/>' . $transTemplateContent . "<br/><br/>" . $transTemplateAfter . ' ' . $transTemplateName);
532:                 } else {
533:                     $this->_tpl->assign('FORUM_REPLYMENT', '');
534:                 }
535:             } else {
536:                 $this->_tpl->assign('FORUM_REPLYMENT', '');
537:             }
538: 
539:             if ($this->_modMode) {
540:                 $this->_tpl->assign('MODEMODETEXT', mi18n('MODEMODETEXT'));
541:             }
542: 
543:             $this->_tpl->assign('INPUT_EMAIL', "<input type=\"text\" name=\"email\" value=\"\" />");
544:             $this->_tpl->assign('INPUT_REALNAME', "<input type=\"text\" name=\"realname\" value=\"\" />");
545:             $this->_tpl->assign('INPUT_FORUM', '');
546:             $this->_tpl->assign('REALNAME', mi18n("yourName"));
547:             $this->_tpl->assign('EMAIL', mi18n("yourMailAddress"));
548:             $this->_tpl->assign('FORUM', mi18n("yourArticle"));
549:             $this->_tpl->assign('FORUM_QUOTE', mi18n("quote"));
550:             $this->_tpl->assign('IDCAT', $this->_idcat);
551:             $this->_tpl->assign('IDART', $this->_idart);
552:             $this->_tpl->assign('SAVE_FORUM', mi18n("saveArticle"));
553:             $this->_tpl->assign('CANCEL_FORUM', mi18n("cancel"));
554:             $this->_tpl->assign('CANCEL_LINK', "front_content.php?idart=$this->_idart");
555:             $this->_tpl->assign('USERID', $_REQUEST['userid']);
556:             $this->_tpl->assign('DELETING', $_REQUEST['deleting']);
557:             $this->_tpl->assign('CONTENIDO', $_REQUEST['contenido']);
558:             $this->_tpl->assign('USER_FORUM_PARENT', (int) $_REQUEST['user_forum_parent']);
559:             $this->_tpl->display('user_forum_new.tpl');
560:         }
561:     }
562: 
563:     /**
564:      * this function sets a cookie when receiving a click on like/dislike -
565:      * buttons.
566:      * After the first click the user can“t add likes/dislikes for the same
567:      * comment for a fixed time intervall (value in cookie).
568:      */
569:     private function _checkCookie() {
570:         // global $REMOTE_ADDR;
571:         $ip = $REMOTE_ADDR? $REMOTE_ADDR : $_SERVER['REMOTE_ADDR'];
572:         $time = time();
573: 
574:         if ($_REQUEST['user_forum_action'] == 'dislike_forum' && isset($_COOKIE['cookie'][$ip][$_REQUEST['user_forum_id']][$_REQUEST['user_forum_action']])) {
575:             $this->_counter = false;
576:         } elseif ($_REQUEST['user_forum_action'] == 'dislike_forum' && !isset($_COOKIE['cookie'][$ip][$_REQUEST['user_forum_id']][$_REQUEST['user_forum_action']])) {
577:             setcookie("cookie[" . $ip . "][" . $_REQUEST['user_forum_id'] . "][" . $_REQUEST['user_forum_action'] . "]", 1, $time + 3600);
578:             $this->_counter = true;
579:         }
580:         if ($_REQUEST['user_forum_action'] == 'like_forum' && isset($_COOKIE['cookie'][$ip][$_REQUEST['user_forum_id']][$_REQUEST['user_forum_action']])) {
581:             $this->_counter = false;
582:         } elseif ($_REQUEST['user_forum_action'] == 'like_forum' && !isset($_COOKIE['cookie'][$ip][$_REQUEST['user_forum_id']][$_REQUEST['user_forum_action']])) {
583:             setcookie("cookie[" . $ip . "][" . $_REQUEST['user_forum_id'] . "][" . $_REQUEST['user_forum_action'] . "]", 1, $time + 3600);
584:             $this->_counter = true;
585:         }
586:     }
587: }
588: 
589: // generate object
590: $userForumArticle = new UserForumArticle();
591: $userForumArticle->receiveData($_REQUEST);
592: 
593: ?>
CMS CONTENIDO 4.9.0 API documentation generated by ApiGen 2.8.0