Ejemplo n.º 1
0
 /**
  * Get datetime of the last post/item
  * @todo dh> Optimize this, if this can be said after having done {@link query()} already.
  * @todo dh> Cache result
  * @param string Date format (see {@link date()})
  * @return string 'Y-m-d H:i:s' formatted; If there are no items this will be {@link $localtimenow}.
  */
 function get_lastpostdate($dateformat = 'Y-m-d H:i:s')
 {
     global $localtimenow, $DB;
     if (empty($this->filters)) {
         // Filters have no been set before, we'll use the default filterset:
         // echo ' Query:Setting default filterset ';
         $this->set_filters($this->default_filters);
     }
     // GENERATE THE QUERY:
     // The SQL Query object:
     $lastpost_ItemQuery = new ItemQuery($this->Cache->dbtablename, $this->Cache->dbprefix, $this->Cache->dbIDname);
     /*
      * filtering stuff:
      */
     $lastpost_ItemQuery->where_chapter2($this->Blog, $this->filters['cat_array'], $this->filters['cat_modifier'], $this->filters['cat_focus'], $this->filters['coll_IDs']);
     $lastpost_ItemQuery->where_author($this->filters['authors']);
     $lastpost_ItemQuery->where_author_logins($this->filters['authors_login']);
     $lastpost_ItemQuery->where_assignees($this->filters['assignees']);
     $lastpost_ItemQuery->where_assignees_logins($this->filters['assignees_login']);
     $lastpost_ItemQuery->where_locale($this->filters['lc']);
     $lastpost_ItemQuery->where_statuses($this->filters['statuses']);
     $lastpost_ItemQuery->where_types($this->filters['types']);
     $lastpost_ItemQuery->where_keywords($this->filters['keywords'], $this->filters['phrase'], $this->filters['exact'], $this->filters['keyword_scope']);
     $lastpost_ItemQuery->where_ID($this->filters['post_ID'], $this->filters['post_title']);
     $lastpost_ItemQuery->where_datestart($this->filters['ymdhms'], $this->filters['week'], $this->filters['ymdhms_min'], $this->filters['ymdhms_max'], $this->filters['ts_min'], $this->filters['ts_max']);
     $lastpost_ItemQuery->where_visibility($this->filters['visibility_array']);
     /*
      * order by stuff:
      * LAST POST FIRST!!! (That's the whole point!)
      */
     $lastpost_ItemQuery->order_by($this->Cache->dbprefix . 'datestart DESC');
     /*
      * Paging limits:
      * ONLY THE LAST POST!!!
      */
     $lastpost_ItemQuery->LIMIT('1');
     // Select the datestart:
     $lastpost_ItemQuery->select($this->Cache->dbprefix . 'datestart');
     $lastpostdate = $DB->get_var($lastpost_ItemQuery->get(), 0, 0, 'Get last post date');
     if (empty($lastpostdate)) {
         // echo 'we have no last item';
         $lastpostdate = date($dateformat, $localtimenow);
     } elseif ($dateformat != 'Y-m-d H:i:s') {
         $lastpostdate = date($dateformat, strtotime($lastpostdate));
     }
     // echo $lastpostdate;
     return $lastpostdate;
 }