Beispiel #1
0
 function countPublished($mydirname, $topicid = 0, $topic_recursive = false, $gpermited = false)
 {
     $gperm =& BulletinGP::getInstance($mydirname);
     $criteria = array();
     if ($gpermited && !$gperm->group_perm(2)) {
         $criteria[] = 'type > 0';
     } else {
         $criteria[] = 'type > 0';
     }
     $criteria[] = 'published > 0';
     $criteria[] = 'published <= ' . time();
     $criteria[] = '(expired = 0 OR expired > ' . time() . ')';
     //ver3.0
     if ($gpermited) {
         $can_read_topic_ids = $gperm->makeOnTopics('can_read');
         $criteria[] = "topicid IN (" . implode(',', $can_read_topic_ids) . ")";
     }
     if (!empty($topicid)) {
         if ($topic_recursive) {
             $topic = new BulletinTopic($mydirname, intval($topicid));
             $topics = $topic->getAllChildId(null, $gpermited);
             $topics[] = intval($topicid);
             $criteria[] = "topicid IN (" . implode(',', $topics) . ")";
         } else {
             $criteria[] = 'topicid=' . intval($topicid);
         }
     } else {
         $criteria[] = 'ihome=1';
     }
     return Bulletin::countAll($mydirname, $criteria);
 }