Overview

Packages

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

Classes

  • ArticleForum
  • ArticleForumCollection
  • ArticleForumItem
  • ArticleForumLeftBottom
  • ArticleForumRightBottom
  • cContentTypeUserForum
  • UserForum
  • Overview
  • Package
  • Class
  • Tree
  • Deprecated
  • Todo
  1: <?php
  2: /**
  3:  * This file contains the collection class for userforum plugin.
  4:  *
  5:  * @package    Plugin
  6:  * @subpackage UserForum
  7:  * @author     Claus Schunk
  8:  * @copyright  four for business AG <www.4fb.de>
  9:  * @license    http://www.contenido.org/license/LIZENZ.txt
 10:  * @link       http://www.4fb.de
 11:  * @link       http://www.contenido.org
 12:  */
 13: defined('CON_FRAMEWORK') || die('Illegal call: Missing framework initialization - request aborted.');
 14: 
 15: /**
 16:  * This class contains functions for dB manipulations and for the interaction
 17:  * between the frontend module
 18:  * content_user_forum and the backend plugin.
 19:  *
 20:  * @package    Plugin
 21:  * @subpackage UserForum
 22:  * @method ArticleForum createNewItem
 23:  * @method ArticleForum next
 24:  */
 25: class ArticleForumCollection extends ItemCollection {
 26: 
 27:     /**
 28:      *
 29:      * @var array
 30:      */
 31:     protected $cfg = 0;
 32: 
 33:     /**
 34:      *
 35:      * @var cDb
 36:      */
 37:     protected $db = 0;
 38: 
 39:     /**
 40:      *
 41:      * @var ArticleForumItem
 42:      */
 43:     protected $item = 0;
 44: 
 45:     // contents array of translations from frontend module
 46:     /**
 47:      *
 48:      * @var array
 49:      */
 50:     protected $languageSync = 0;
 51: 
 52:     /**
 53:      *
 54:      * @var int
 55:      */
 56:     protected $idContentType = 0;
 57: 
 58:     /**
 59:      * @throws cDbException
 60:      * @throws cInvalidArgumentException
 61:      */
 62:     public function __construct() {
 63:         // sync time
 64:         date_default_timezone_set('Europe/Berlin');
 65:         $this->db  = cRegistry::getDb();
 66:         $this->cfg = cRegistry::getConfig();
 67: 
 68:         parent::__construct($this->cfg['tab']['user_forum'], 'id_user_forum');
 69:         $this->_setItemClass('ArticleForum');
 70:         $this->item          = new ArticleForumItem();
 71:         $this->idContentType = $this->getIdUserForumContenType();
 72:     }
 73: 
 74:     /**
 75:      * @return array
 76:      * @throws cDbException
 77:      */
 78:     public function getAllCommentedArticles() {
 79: 
 80:         $idclient = cRegistry::getClientId();
 81: 
 82:         $this->db->query("-- ArticleForumCollection->getAllCommentedArticles()
 83:             SELECT DISTINCT
 84:                 art_lang.title
 85:                 , art_lang.idart
 86:                 , f.idcat
 87:             FROM
 88:                 `{$this->cfg['tab']['art_lang']}` AS art_lang
 89:                 , `$this->table` AS  f
 90:             WHERE
 91:                 art_lang.idart = f.idart
 92:                 AND art_lang.idlang = f.idlang
 93:                 AND idclient = " . $idclient . "
 94:             ORDER BY
 95:                 id_user_forum ASC
 96:             ;");
 97: 
 98:         $data = array();
 99:         while ($this->db->nextRecord()) {
100:             array_push($data, $this->db->toArray());
101:         }
102: 
103:         return $data;
104:     }
105: 
106:     /**
107:      * deletes comment with all subcomments from this comment
108:      *
109:      * @param $keyPost
110:      * @param $level
111:      * @param $idart
112:      * @param $idcat
113:      * @param $lang
114:      *
115:      * @throws cDbException
116:      * @throws cException
117:      * @throws cInvalidArgumentException
118:      */
119:     public function deleteHierarchy($keyPost, $level, $idart, $idcat, $lang) {
120:         $comments = $this->_getCommentHierarchy($idcat, $idart, $lang);
121: 
122:         $arri = array();
123: 
124:         foreach ($comments as $key => $com) {
125:             $com['key'] = $key;
126:             $arri[]     = $com;
127:         }
128:         $idEntry       = 0;
129:         $id_user_forum = array();
130:         $lastLevel     = 0;
131:         for ($i = 0; $i < count($arri); $i++) {
132:             // select Entry
133:             if ($arri[$i]['key'] == $keyPost) {
134:                 $idEntry = $arri[$i]['id_user_forum'];
135:                 if ($arri[$i]['level'] < $arri[$i + 1]['level']) {
136:                     // check for more sub comments
137:                     for ($j = $i + 1; $j < $arri[$j]; $j++) {
138:                         if ($arri[$i]['level'] < $arri[$j]['level']) {
139:                             $id_user_forum[] = $arri[$j]['id_user_forum'];
140:                         }
141:                     }
142:                 }
143:             }
144:         }
145: 
146:         if (empty($id_user_forum)) {
147:             $this->deleteBy('id_user_forum', $idEntry);
148:         } else {
149:             $this->deleteBy('id_user_forum', $idEntry);
150:             foreach ($id_user_forum as $com) {
151:                 $this->deleteBy('id_user_forum', $com);
152:             }
153:         }
154:     }
155: 
156:     /**
157:      *
158:      * @param int $id_cat
159:      * @param int $id_art
160:      * @param int $id_lang
161:      *
162:      * @return array
163:      * @throws cDbException
164:      * @throws cException
165:      */
166:     protected function _getCommentHierarchy($id_cat, $id_art, $id_lang) {
167:         $this->query();
168:         while (false != $field = $this->next()) {
169:             $arrUsers[$field->get('userid')]['email']    = $field->get('email');
170:             $arrUsers[$field->get('userid')]['realname'] = $field->get('realname');
171:         }
172:         $arrforum = array();
173:         $this->getTreeLevel($id_cat, $id_art, $id_lang, $arrUsers, $arrforum);
174:         $result = array();
175:         $this->normalizeArray($arrforum, $result);
176: 
177:         return $result;
178:     }
179: 
180:     /**
181:      *
182:      * @param array $arrforum
183:      * @param array $result
184:      * @param int   $level
185:      */
186:     public function normalizeArray($arrforum, &$result, $level = 0) {
187:         if (is_array($arrforum)) {
188:             foreach ($arrforum as $key => $value) {
189:                 $value['level'] = $level;
190:                 unset($value['children']);
191:                 $result[$key] = $value;
192:                 $this->normalizeArray($arrforum[$key]['children'], $result, $level + 1);
193:             }
194:         }
195:     }
196: 
197:     /**
198:      *
199:      * @param int   $id_cat
200:      * @param int   $id_art
201:      * @param int   $id_lang
202:      * @param array $arrUsers
203:      * @param array $arrforum
204:      * @param int   $parent
205:      * @param bool  $frontend
206:      *
207:      * @throws cDbException
208:      */
209:     public function getTreeLevel($id_cat, $id_art, $id_lang, &$arrUsers, &$arrforum, $parent = 0, $frontend = false) {
210:         $db = cRegistry::getDb();
211:         if ($frontend) {
212:             // select only comments that are marked visible in frontendmode.
213:             $db->query("-- ArticleForumCollection->getTreeLevel()
214:                 SELECT
215:                     *
216:                 FROM
217:                     `{$this->cfg['tab']['user_forum']}`
218:                 WHERE
219:                     idart = $id_art
220:                     AND idcat = $id_cat
221:                     AND idlang = $id_lang
222:                     AND id_user_forum_parent = $parent
223:                     AND online = 1
224:                 ORDER BY
225:                     timestamp DESC
226:                 ;");
227:         } else {
228:             // select all comments -> used in backendmode.
229:             $db->query("-- ArticleForumCollection->getTreeLevel()
230:                 SELECT
231:                     *
232:                 FROM
233:                     `{$this->cfg['tab']['user_forum']}`
234:                 WHERE
235:                     idart = $id_art
236:                     AND idcat = $id_cat
237:                     AND idlang = $id_lang
238:                     AND id_user_forum_parent = $parent
239:                 ORDER BY
240:                     timestamp DESC
241:                 ;");
242:         }
243: 
244:         while ($db->nextRecord()) {
245:             $arrforum[$db->f('id_user_forum')]['userid'] = $db->f('userid');
246: 
247:             if (array_key_exists($db->f('userid'), $arrUsers)) {
248:                 $arrforum[$db->f('id_user_forum')]['email']    = $arrUsers[$db->f('userid')]['email'];
249:                 $arrforum[$db->f('id_user_forum')]['realname'] = $arrUsers[$db->f('userid')]['realname'];
250:             } else {
251:                 $arrforum[$db->f('id_user_forum')]['email']    = $db->f('email');
252:                 $arrforum[$db->f('id_user_forum')]['realname'] = $db->f('realname');
253:             }
254:             $arrforum[$db->f('id_user_forum')]['forum']       = str_replace("\r\n", '<br />', $db->f('forum'));
255:             $arrforum[$db->f('id_user_forum')]['forum_quote'] = str_replace("\r\n", '<br />', $db->f('forum_quote'));
256:             $arrforum[$db->f('id_user_forum')]['timestamp']   = $db->f('timestamp');
257:             $arrforum[$db->f('id_user_forum')]['like']        = $db->f('like');
258:             $arrforum[$db->f('id_user_forum')]['dislike']     = $db->f('dislike');
259: 
260:             $arrforum[$db->f('id_user_forum')]['editedat'] = $db->f('editedat');
261:             $arrforum[$db->f('id_user_forum')]['editedby'] = $db->f('editedby');
262: 
263:             // Added values to array for allocation
264:             $arrforum[$db->f('id_user_forum')]['idcat']         = $db->f('idcat');
265:             $arrforum[$db->f('id_user_forum')]['idart']         = $db->f('idart');
266:             $arrforum[$db->f('id_user_forum')]['id_user_forum'] = $db->f('id_user_forum');
267:             $arrforum[$db->f('id_user_forum')]['online']        = $db->f('online');
268:             $arrforum[$db->f('id_user_forum')]['editedat']      = $db->f('editedat');
269:             $arrforum[$db->f('id_user_forum')]['editedby']      = $db->f('editedby');
270: 
271:             $this->getTreeLevel($id_cat, $id_art, $id_lang, $arrUsers, $arrforum[$db->f('id_user_forum')]['children'], $db->f('id_user_forum'), $frontend);
272:         }
273:     }
274: 
275:     /**
276:      *
277:      * @param int          $id_user_forum
278:      * @param string       $name
279:      * @param string       $email
280:      * @param int          $like
281:      * @param int          $dislike
282:      * @param unknown_type $forum
283:      * @param int          $online
284:      *
285:      * @throws cDbException
286:      * @throws cException
287:      */
288:     public function updateValues($id_user_forum, $name, $email, $like, $dislike, $forum, $online) {
289:         $uuid = cRegistry::getAuth()->isAuthenticated();
290: 
291:         $this->item->loadByPrimaryKey($id_user_forum);
292: 
293:         if ($this->item->getField('realname') == $name && $this->item->getField('email') == $email && $this->item->getField('forum') == $forum) {
294: 
295:             // load timestamp from db to check if the article was already
296:             // edited.
297:             if ($this->item->getField('editedat') === "0000-00-00 00:00:00") {
298:                 // case : never edited
299:                 $timeStamp = "0000-00-00 00:00:00";
300:             } else {
301:                 $timeStamp = $this->item->getField('editedat');
302:             }
303:         } else {
304:             // actual timestamp: Content was edited
305:             $timeStamp = date('Y-m-d H:i:s', time());
306:         }
307: 
308:         if (preg_match('/\D/', $like)) {
309:             $like = $this->item->getField('like');
310:         }
311: 
312:         if (preg_match('/\D/', $dislike)) {
313:             $dislike = $this->item->getField('dislike');
314:         }
315: 
316:         // check for negative inputs
317:         // does not work with php 5.2
318:         // (!preg_match('/\D/', $like)) ? : $like =
319:         // $this->item->getField('like');
320:         // (!preg_match('/\D/', $dislike)) ? : $dislike =
321:         // $this->item->getField('dislike');
322: 
323:         $fields = array(
324:             'realname'  => $name,
325:             'editedby'  => $uuid,
326:             'email'     => $email,
327:             'forum'     => $forum,
328:             'editedat'  => $timeStamp,
329:             'like'      => $like,
330:             'dislike'   => $dislike,
331:             'online'    => $online,
332:             // update moderated flag with update => comment is moderated now.
333:             'moderated' => 1
334:         );
335: 
336:         $whereClauses = array(
337:             'id_user_forum' => $id_user_forum
338:         );
339:         $statement    = $this->db->buildUpdate($this->table, $fields, $whereClauses);
340:         $this->db->query($statement);
341:     }
342: 
343:     /**
344:      * toggles the given input with update in db.
345:      *
346:      * @param int $onlineState
347:      * @param int $id_user_forum primary key
348:      * @param int $idart         article ID [optional]
349:      *
350:      * @throws cDbException
351:      */
352:     public function toggleOnlineState($onlineState, $id_user_forum, $idart = NULL) {
353: 
354:         // toggle state
355:         $onlineState = ($onlineState == 0) ? 1 : 0;
356: 
357:         if (isset($idart)) {
358:             $fields = array(
359:                 'online'    => $onlineState,
360:                 'moderated' => 1,
361:             );
362:         } else {
363:             $fields = array(
364:                 'online' => $onlineState
365:             );
366:         }
367: 
368:         $whereClauses = array(
369:             'id_user_forum' => (int)$id_user_forum
370:         );
371:         $statement    = $this->db->buildUpdate($this->table, $fields, $whereClauses);
372:         $this->db->query($statement);
373:     }
374: 
375:     /**
376:      *
377:      * email notification for registred moderator.
378:      * before calling this function it is necessary to receive the converted
379:      * language string from frontend module.
380:      *
381:      * @param     $realname
382:      * @param     $email
383:      * @param     $forum
384:      * @param     $idart
385:      * @param     $lang
386:      * @param int $forum_quote
387:      *
388:      * @throws cDbException
389:      * @throws cException
390:      * @throws cInvalidArgumentException
391:      */
392:     public function mailToModerator($realname, $email, $forum, $idart, $lang, $forum_quote = 0) {
393: 
394:         // get article name
395:         $ar = $this->getArticleTitle($idart, $lang);
396: 
397:         $mail = new cMailer();
398:         $mail->setCharset('UTF-8');
399: 
400:         // build message content
401:         $message = $this->languageSync['NEWENTRYTEXT'] . " " . $this->languageSync['ARTICLE'] . $ar[0]["title"] . "\n" . "\n";
402:         $message .= $this->languageSync['USER'] . ' : ' . $realname . "\n";
403:         $message .= $this->languageSync['EMAIL'] . ' : ' . $email . "\n" . "\n";
404:         $message .= $this->languageSync['COMMENT'] . ' : ' . "\n" . $forum . "\n";
405:         if ($forum_quote != 0) {
406:             $message .= UserForum::i18n('QUOTE') . ' : ' . $forum_quote . "\n";
407:         }
408: 
409:         // send mail only if modEmail is set -> minimize traffic.
410:         if ($this->getModEmail($idart) != NULL) {
411:             $mail->sendMail(getEffectiveSetting("userforum", "mailfrom"), $this->getModEmail($idart), $this->languageSync['NEWENTRY'], $message);
412:         }
413:     }
414: 
415:     /**
416:      * @param int $idart
417:      * @param int $idlang
418:      *
419:      * @return array
420:      * @throws cDbException
421:      */
422:     public function getArticleTitle($idart, $idlang) {
423:         $this->db->query("-- ArticleForumCollection->getArticleTitle()
424:             SELECT DISTINCT
425:                 title
426:             FROM
427:                 `{$this->cfg['tab']['art_lang']}` AS art_lang
428:             WHERE
429:                 idart = $idart
430:                 AND idlang = $idlang
431:             ;");
432: 
433:         $data = array();
434:         while ($this->db->nextRecord()) {
435:             array_push($data, $this->db->toArray());
436:         }
437: 
438:         return $data;
439:     }
440: 
441:     /**
442:      * @return array
443:      * @throws cDbException
444:      * @throws cException
445:      */
446:     public function getExistingforum() {
447:         $userColl = new cApiUserCollection();
448:         $userColl->query();
449: 
450:         $arrUsers = array();
451: 
452:         while (($field = $userColl->next()) != false) {
453:             $arrUsers[$field->get('user_id')]['email']    = $field->get('email');
454:             $arrUsers[$field->get('user_id')]['realname'] = $field->get('realname');
455:         }
456: 
457:         return $arrUsers;
458:     }
459: 
460:     /**
461:      *
462:      * @param int $idquote
463:      *
464:      * @return array
465:      * @throws cDbException
466:      * @throws cException
467:      */
468:     function selectNameAndNameByForumId($idquote) {
469:         $ar = array();
470:         $this->item->loadByPrimaryKey($this->db->escape($idquote));
471:         $ar[] = $this->item->get('realname');
472: 
473:         return $ar;
474:     }
475: 
476:     /**
477:      * @param $userid
478:      *
479:      * @return bool
480:      * @throws cDbException
481:      * @throws cException
482:      */
483:     public function selectUser($userid) {
484:         return $this->item->loadByPrimaryKey($this->db->escape($userid));
485:     }
486: 
487:     /**
488:      * this function increments the actual value of likes from a comment and
489:      * persists it.
490:      *
491:      * @param $forum_user_id int identifies a comment
492:      *
493:      * @throws cDbException
494:      * @throws cException
495:      */
496:     public function incrementLike($forum_user_id) {
497:         $db = cRegistry::getDb();
498:         // load actual value
499:         $this->item->loadByPrimaryKey($db->escape($forum_user_id));
500:         $ar      = $this->item->toArray();
501:         $current = $ar['like'];
502:         // increment value
503:         $current += 1;
504: 
505:         $fields       = array(
506:             'like' => $current
507:         );
508:         $whereClauses = array(
509:             'id_user_forum' => $forum_user_id
510:         );
511:         // persist inkremented value
512:         $statement = $this->db->buildUpdate($this->table, $fields, $whereClauses);
513:         $this->db->query($statement);
514:     }
515: 
516:     /**
517:      * this function inkrements the actual value of dislikes from a comment and
518:      * persists it.
519:      *
520:      * @param $forum_user_id int identifies a comment
521:      *
522:      * @throws cDbException
523:      * @throws cException
524:      */
525:     public function incrementDislike($forum_user_id) {
526:         $db = cRegistry::getDb();
527:         // load actual value
528:         $this->item->loadByPrimaryKey($db->escape($forum_user_id));
529:         $ar      = $this->item->toArray();
530:         $current = $ar['dislike'];
531:         // increment value
532:         $current += 1;
533: 
534:         $fields       = array(
535:             'dislike' => $current
536:         );
537:         $whereClauses = array(
538:             'id_user_forum' => $forum_user_id
539:         );
540:         // persist incremented value
541:         $statement = $this->db->buildUpdate($this->table, $fields, $whereClauses);
542:         $this->db->query($statement);
543:     }
544: 
545:     /**
546:      * persists a new comment created at the frontend module.
547:      *
548:      * @param $parent
549:      * @param $idart
550:      * @param $idcat
551:      * @param $lang
552:      * @param $userid
553:      * @param $email
554:      * @param $realname
555:      * @param $forum
556:      * @param $forum_quote
557:      *
558:      * @throws cDbException
559:      * @throws cException
560:      * @throws cInvalidArgumentException
561:      */
562:     public function insertValues($parent, $idart, $idcat, $lang, $userid, $email, $realname, $forum, $forum_quote) {
563:         $db = cRegistry::getDb();
564: 
565:         // comments are marked as offline if the moderator mode is turned on.
566:         $modCheck = $this->getModModeActive($idart);
567:         $online   = $modCheck ? 0 : 1;
568: 
569:         // build array for sql statemant
570:         $fields = array(
571:             'id_user_forum'        => NULL,
572:             'id_user_forum_parent' => $db->escape($parent),
573:             'idart'                => $db->escape($idart),
574:             'idcat'                => $db->escape($idcat),
575:             'idlang'               => $db->escape($lang),
576:             'userid'               => $db->escape($userid),
577:             'email'                => $db->escape($email),
578:             'realname'             => $db->escape($realname),
579:             'forum'                => ($forum),
580:             'forum_quote'          => ($forum_quote),
581:             'idclient'             => cRegistry::getClientId(),
582:             'like'                 => 0,
583:             'dislike'              => 0,
584:             'editedat'             => NULL,
585:             'editedby'             => NULL,
586:             'timestamp'            => date('Y-m-d H:i:s'),
587:             'online'               => $online
588:         );
589: 
590:         $db->insert($this->table, $fields);
591: 
592:         // if moderator mode is turned on the moderator will receive an email
593:         // with the new comment and is able to
594:         // change the online state in the backend.
595:         if ($modCheck) {
596:             $this->mailToModerator($realname, $email, $forum, $idart, $lang, $forum_quote = 0);
597:         }
598:     }
599: 
600:     /**
601:      * this function deletes all comments related to the same articleId
602:      *
603:      * @param int $idart
604:      *
605:      * @throws cDbException
606:      * @throws cInvalidArgumentException
607:      */
608:     public function deleteAllCommentsById($idart) {
609:         $this->deleteBy('idart', (int)$idart);
610:     }
611: 
612:     /**
613:      *
614:      * @param int  $id_cat
615:      * @param int  $id_art
616:      * @param int  $id_lang
617:      * @param bool $frontend
618:      *
619:      * @return array
620:      * @throws cDbException
621:      * @throws cException
622:      */
623:     public function getExistingforumFrontend($id_cat, $id_art, $id_lang, $frontend) {
624:         $userColl = new cApiUserCollection();
625:         $userColl->query();
626: 
627:         while (($field = $userColl->next()) != false) {
628:             $arrUsers[$field->get('user_id')]['email']    = $field->get('email');
629:             $arrUsers[$field->get('user_id')]['realname'] = $field->get('realname');
630:         }
631: 
632:         $arrforum = array();
633:         $this->getTreeLevel($id_cat, $id_art, $id_lang, $arrUsers, $arrforum, 0, $frontend);
634: 
635:         $result = array();
636:         $this->normalizeArray($arrforum, $result);
637: 
638:         return $result;
639:     }
640: 
641:     /**
642:      * returns the emailadress from the moderator for this article
643:      *
644:      * @param int $idart
645:      *
646:      * @return string
647:      */
648:     public function getModEmail($idart) {
649:         $data = $this->readXML();
650:         for ($i = 0; $i < count($data); $i++) {
651:             if ($data[$i]['idart'] == $idart) {
652:                 return $data[$i]["email"];
653:             }
654:         }
655: 
656:         return NULL;
657:     }
658: 
659:     /**
660:      * returns if moderator mode is active for this article
661:      *
662:      * @param int $idart
663:      *
664:      * @return bool
665:      */
666:     public function getModModeActive($idart) {
667:         $data = $this->readXML();
668:         for ($i = 0; $i < count($data); $i++) {
669:             if ($data[$i]['idart'] == $idart) {
670:                 if ($data[$i]["modactive"] === 'false') {
671:                     return false;
672:                 }
673:             }
674:         }
675: 
676:         return true;
677:     }
678: 
679:     /**
680:      * returns if quotes for comments are allowed in this article
681:      *
682:      * @param int $idart
683:      *
684:      * @return bool
685:      */
686:     public function getQuoteState($idart) {
687:         // get content from con_type
688:         $data = $this->readXML();
689:         for ($i = 0; $i < count($data); $i++) {
690:             if ($data[$i]['idart'] == $idart) {
691:                 if ($data[$i]["subcomments"] === 'false') {
692:                     return false;
693:                 }
694:             }
695:         }
696: 
697:         return true;
698:     }
699: 
700:     /**
701:      * This function loads and returns the xml content from the contentType
702:      * aditionally the return array implies the articleId because of an easier
703:      * mapping in the frontend.
704:      *
705:      * @return array
706:      */
707:     public function readXML() {
708:         // get variables from global context
709:         $idtype = $this->idContentType;
710: 
711:         $array = array();
712: 
713:         try {
714:             $this->db->query("-- ArticleForumCollection->readXML()
715:                 SELECT
716:                     art_lang.idart
717:                     , content.value
718:                 FROM
719:                     `{$this->cfg['tab']['art_lang']}` AS art_lang
720:                     , `{$this->cfg['tab']['content']}` AS content
721:                 WHERE
722:                     art_lang.idartlang = content.idartlang
723:                     AND content.idtype = $idtype
724:                 ;");
725: 
726:             $data = array();
727:             while ($this->db->nextRecord()) {
728:                 array_push($data, $this->db->toArray());
729:             }
730: 
731:             $array = array();
732:             for ($i = 0; $i < count($data); $i++) {
733:                 $array[$i] = cXmlBase::xmlStringToArray($data[$i]['value']);
734:                 // add articleId
735:                 $array[$i]['idart'] = $data[$i]['idart'];
736:             }
737:         } catch (Exception $e) {
738: 
739:         }
740: 
741:         return $array;
742:     }
743: 
744:     /**
745:      * this function is used to get translations from the language of the
746:      * frontend module for example to generate
747:      * the e-mail text with correct language settings.
748:      *
749:      * @param array $str
750:      */
751:     public function languageSync(array &$str) {
752:         $this->languageSync = $str;
753:     }
754: 
755:     /**
756:      * @return array
757:      */
758:     public function getlanguageSync() {
759:         if ($this->languageSync != 0) {
760:             return $this->languageSync;
761:         } else {
762:             return array();
763:         }
764:     }
765: 
766:     /**
767:      *
768:      * @param int $id_user_forum
769:      *
770:      * @return array
771:      * @throws cException
772:      */
773:     public function getCommentContent($id_user_forum) {
774:         $item = $this->loadItem($id_user_forum);
775: 
776:         return array(
777:             'name'    => $item->get("realname"),
778:             'content' => $item->get("forum")
779:         );
780:     }
781: 
782:     /**
783:      * @return int|boolean
784:      * @throws cDbException
785:      */
786:     protected function getIdUserForumContenType() {
787:         $this->db->query("-- ArticleForumCollection->getIdUserForumContenType()
788:             SELECT
789:                 idtype
790:             FROM
791:                 `{$this->cfg['tab']['type']}`
792:             WHERE
793:                 type = 'CMS_USERFORUM'
794:             ;");
795:         if ($this->db->nextRecord()) {
796:             return $this->db->f('idtype');
797:         } else {
798:             return false;
799:         }
800:     }
801: 
802:     /**
803:      * @return array
804:      * @throws cDbException
805:      */
806:     public function getUnmoderatedComments() {
807: 
808:         $comments =  array();
809: 
810:         $idlang   = cRegistry::getLanguageId();
811:         $idclient = cRegistry::getClientId();
812: 
813:         $db = cRegistry::getDb();
814:             $db->query("-- ArticleForumCollection->getUnmoderatedComments()
815:                 SELECT
816:                     *
817:                 FROM
818:                     `{$this->cfg['tab']['user_forum']}`
819:                 WHERE
820:                     moderated = 0
821:                     AND idclient = $idclient
822:                     AND idlang = $idlang
823:                     AND online = 0
824:                 ORDER BY
825:                     timestamp DESC
826:                 ;");
827: 
828:         while ($db->nextRecord()) {
829: 
830:         // filter only mod mode active articles
831:         $modCheck = $this->getModModeActive($db->f('idart'));
832:            if(isset($modCheck)) {
833:                 $comments[] = $db->getRecord();
834:             }
835:         }
836:         return $comments;
837:     }
838: }
839: 
840: ?>
CMS CONTENIDO 4.10.1 API documentation generated by ApiGen 2.8.0