コード例 #1
0
ファイル: activities.php プロジェクト: rair/yacs
 /**
  * list most recent activities
  *
  * @param string reference of the handled object (e.g., 'article:123')
  * @param string description of the action (e.g., 'post' or 'like')
  * @param int maximum number of activities to list
  * @param string layout of matching records
  * @return array list of matching user profiles
  */
 public static function list_at($anchor, $action = NULL, $count = 50, $variant = 'raw')
 {
     global $context;
     // limit the query to one anchor
     $where = "(anchor LIKE '" . SQL::escape($anchor) . "')";
     // for some actions only
     if (is_array($action)) {
         $where .= " AND (action IN ('" . implode("', '", $action) . "'))";
     } elseif ($action) {
         $where .= " AND (action LIKE '" . SQL::escape($action) . "')";
     }
     // the list of activities
     $query = "SELECT * FROM " . SQL::table_name('activities') . " AS activities" . " WHERE " . $where . " GROUP BY activities.action ORDER BY activities.edit_date DESC LIMIT " . $count;
     // use existing listing facility
     $output = Activities::list_selected(SQL::query($query), $variant);
     return $output;
 }