コード例 #1
0
ファイル: mtdb.base.php プロジェクト: OCMO/movabletype
 public function get_latest_touch($blog_id, $types)
 {
     $type_user = false;
     if (is_array($types)) {
         $array = preg_grep('/author/', $types);
         if (!empty($array)) {
             $type_user = true;
         }
     } else {
         $type_user = $types == 'author';
     }
     $blog_filter = '';
     if (!empty($blog_id)) {
         if ($type_user) {
             $blog_filter = 'and touch_blog_id = 0';
         } else {
             $blog_filter = 'and touch_blog_id = ' . $blog_id;
         }
     }
     $type_filter = '';
     if (!empty($types)) {
         if ($type_user) {
             $type_filter = 'and touch_object_type ="author"';
         } else {
             if (is_array($types)) {
                 foreach ($types as $type) {
                     if ($type_filter != '') {
                         $type_filter .= ',';
                     }
                     $type_filter .= "'{$type}'";
                 }
                 $type_filter = 'and touch_object_type in (' . $type_filter . ')';
             } else {
                 $type_filter = "and touch_object_type ='{$types}'";
             }
         }
     }
     $where = "1 = 1\n                  {$blog_filter}\n                  {$type_filter}\n                  order by\n                    touch_modified_on desc";
     $extras['limit'] = 1;
     require_once 'class.mt_touch.php';
     $touch = new Touch();
     $touches = $touch->Find($where, false, false, $extras);
     if (!empty($touches)) {
         return $touches[0];
     }
     return false;
 }