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
    • SmartyWrapper
    • UrlShortener
    • UserForum
    • Workflow
  • PluginManager
  • Setup
    • Form
    • GUI
    • Helper
      • Environment
      • Filesystem
      • MySQL
      • PHP
    • UpgradeJob

Classes

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