aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorzotlabs <mike@macgirvin.com>2018-08-23 21:01:28 -0700
committerzotlabs <mike@macgirvin.com>2018-08-23 21:01:28 -0700
commita66c43166af5b31a0e2dbfc148cd5ecd73fded51 (patch)
tree12fd2eb31624c994afb018c004b7d2fa4797e201 /include
parent6ecd31a715c3d4fb5f2073f376cb9509bc6427d6 (diff)
downloadvolse-hubzilla-a66c43166af5b31a0e2dbfc148cd5ecd73fded51.tar.gz
volse-hubzilla-a66c43166af5b31a0e2dbfc148cd5ecd73fded51.tar.bz2
volse-hubzilla-a66c43166af5b31a0e2dbfc148cd5ecd73fded51.zip
first_post_date() (used by archive widget) - trigger the query options off of the active module rather than rely on passed parameters
Diffstat (limited to 'include')
-rwxr-xr-xinclude/items.php29
1 files changed, 15 insertions, 14 deletions
diff --git a/include/items.php b/include/items.php
index eb7b9ef78..2990d519e 100755
--- a/include/items.php
+++ b/include/items.php
@@ -3781,33 +3781,34 @@ function delete_item_lowlevel($item, $stage = DROPITEM_NORMAL, $force = false) {
* @brief Return the first post date.
*
* @param int $uid
- * @param boolean $wall (optional) default false
- * hack: $wall = 2 selects articles
+ * @param boolean $wall (optional) no longer used
* @return string|boolean date string, otherwise false
*/
function first_post_date($uid, $wall = false) {
- $wall_sql = (($wall === 1) ? " and item_wall = 1 " : "" );
- if($wall === 2) {
- $wall_sql = " and item_type = 7 ";
- $item_normal = " and item.item_hidden = 0 and item.item_type = 7 and item.item_deleted = 0
- and item.item_unpublished = 0 and item.item_delayed = 0 and item.item_pending_remove = 0
- and item.item_blocked = 0 ";
+ $sql_extra = '';
+ switch(\App::$module) {
+ case 'articles':
+ $sql_extra .= " and item_type = 7 ";
+ $item_normal = " and item.item_hidden = 0 and item.item_type = 7 and item.item_deleted = 0
+ and item.item_unpublished = 0 and item.item_delayed = 0 and item.item_pending_remove = 0
+ and item.item_blocked = 0 ";
+ break;
+ case 'channel':
+ $sql_extra = " and item_wall = 1 ";
+ default:
+ $item_normal = item_normal();
+ break;
}
- else {
- $item_normal = item_normal();
- }
-
$r = q("select id, created from item
- where uid = %d and id = parent $item_normal $wall_sql
+ where uid = %d and id = parent $item_normal $sql_extra
order by created asc limit 1",
intval($uid)
);
if($r) {
-// logger('first_post_date: ' . $r[0]['id'] . ' ' . $r[0]['created'], LOGGER_DATA);
return substr(datetime_convert('',date_default_timezone_get(),$r[0]['created']),0,10);
}