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
    • ContentRssCreator
    • ContentSitemapHtml
    • ContentSitemapXml
    • ContentUserForum
    • NavigationTop
    • ScriptCookieDirective
  • 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
  • Smarty
    • Cacher
    • Compiler
    • Config
    • Debug
    • PluginsBlock
    • PluginsFilter
    • PluginsFunction
    • PluginsInternal
    • PluginsModifier
    • PluginsModifierCompiler
    • PluginsShared
    • Security
    • Template
    • TemplateResources
  • Swift
    • ByteStream
    • CharacterStream
    • Encoder
    • Events
    • KeyCache
    • Mailer
    • Mime
    • Plugins
    • Transport

Classes

  • Swift_FailoverTransport
  • Swift_LoadBalancedTransport
  • Swift_MailTransport
  • Swift_Plugins_Loggers_ArrayLogger
  • Swift_Plugins_Loggers_EchoLogger
  • Swift_SendmailTransport
  • Swift_SmtpTransport
  • Swift_Transport_AbstractSmtpTransport
  • Swift_Transport_Esmtp_Auth_CramMd5Authenticator
  • Swift_Transport_Esmtp_Auth_LoginAuthenticator
  • Swift_Transport_Esmtp_Auth_PlainAuthenticator
  • Swift_Transport_Esmtp_AuthHandler
  • Swift_Transport_EsmtpTransport
  • Swift_Transport_FailoverTransport
  • Swift_Transport_LoadBalancedTransport
  • Swift_Transport_MailTransport
  • Swift_Transport_SendmailTransport
  • Swift_Transport_SimpleMailInvoker
  • Swift_Transport_StreamBuffer

Interfaces

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