function countPublishedByDate($mydirname, $caldate) { if (preg_match('/([0-9]{4})-([0-9]{2})-([0-9]{2})/', $caldate, $datearr)) { $year = $datearr[1]; $month = $datearr[2]; $day = $datearr[3]; $startday4sql = mktime(0, 0, 0, $month, $day, $year); $endday4sql = mktime(0, 0, 0, $month, $day + 1, $year); $criteria = array(); $criteria[] = 'type > 0'; $criteria[] = 'published > 0'; $criteria[] = 'published <= ' . time(); $criteria[] = '(expired = 0 OR expired > ' . time() . ')'; $criteria[] = $startday4sql . ' <= published'; $criteria[] = 'published < ' . $endday4sql; return Bulletin::countAll($mydirname, $criteria); } return false; }
function countPublishedByDate($mydirname, $caldate, $gpermited = false) { $gperm =& BulletinGP::getInstance($mydirname); if (preg_match('/([0-9]{4})-([0-9]{2})-([0-9]{2})/', $caldate, $datearr)) { $year = $datearr[1]; $month = $datearr[2]; $day = $datearr[3]; $startday4sql = mktime(0, 0, 0, $month, $day, $year); $endday4sql = mktime(0, 0, 0, $month, $day + 1, $year); $criteria = array(); //ver2.0 $criteria[] = 'type > 0'; //ver3.0 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() . ')'; $criteria[] = $startday4sql . ' <= published'; $criteria[] = 'published < ' . $endday4sql; //ver3.0 if ($gpermited) { $can_read_topic_ids = $gperm->makeOnTopics('can_read'); $criteria[] = "topicid IN (" . implode(',', $can_read_topic_ids) . ")"; } return Bulletin::countAll($mydirname, $criteria); } return false; }