<?php

class blogOffice extends blogBase {

  protected function getActiveBlogSql($activeType, $matchType) {
    $location_query = $this->getLocationQuery();
    switch ($activeType) {
      case 'all':
        return
         "select bl_id, bl_hit from tblblog, tblblogcheckinfo
          where ci_userid=bl_user and $location_query and
          bl_type $matchType
          order by bl_hit desc limit 9";

      case 'week':
        $week = myUtility::dateToWeek(date('Y-m-d'));
        return
         "select std_blog, sum(std_visitors) as s, ci_province, ci_district, ci_school
          from tblblogstatday use index (std_date), tblblogcheckinfo
          where ci_userid=std_blogadmin and
          std_date>='$week' and std_blogtype $matchType
          group by(std_blog) having $location_query
          order by s desc limit 9";

      case 'day':
        $today = date('Y-m-d');
        return
         "select std_blog, std_visitors from tblblogstatday, tblblogcheckinfo
          where ci_userid=std_blogadmin and $location_query and
          std_date='$today' and std_blogtype $matchType
          order by std_visitors desc limit 9";
    }
  }

}
?>
