/** * Find latest Global reset * * @access protected * @param array Array of data (DB field names) * @param string App to check * @return int Timestamp */ protected function _findLatestGlobalReset($data, $app) { $_time = 0; $_times = array(); $_key = $this->_makeKey($data); $cookie = $this->_fetchCookieData('itemMarking_' . $app); $cookieItems = $this->_fetchCookieData('itemMarking_' . $app . '_items'); if (!$this->memberData['member_id'] and $this->_noGuestMarking) { return time(); } $mainKey = $this->_findMainRowByKey($data, $app); /* Got all fields? */ if (isset($this->_itemMarkers[$app][$mainKey]['item_global_reset'])) { $_times[] = $this->_itemMarkers[$app][$mainKey]['item_global_reset']; } if (isset($cookie['greset'][$this->_makeKey($data, TRUE)])) { $_times[] = intval($cookie['greset'][$this->_makeKey($data, TRUE)]); } if (isset($cookie['global'])) { $_times[] = intval($cookie['global']); } if (isset($this->memberData['_cache']['gb_mark__' . $app])) { $_times[] = $this->memberData['_cache']['gb_mark__' . $app]; } /* Get most recent time */ $_time = IPSLib::fetchHighestNumber($_times); return $_time; }
/** * Builds a where statement for get new posts * * @access private * @return int */ private function _viewNewPosts_where() { /* Loop through the forums and build a list of forums we're allowed access to */ $where = array(); $forumIdsOk = array(); $forumIdsBad = array(); $bvnp = explode(',', $this->settings['vnp_block_forums']); foreach ($this->registry->class_forums->forum_by_id as $id => $data) { /* Can we read? */ if (!$this->registry->permissions->check('read', $data)) { $forumIdsBad[] = $id; continue; } if (!$this->registry->class_forums->forumsCheckAccess($id, 0, 'forum', array(), true)) { $forumIdsBad[] = $id; continue; } if (in_array($id, $bvnp) or !$data['sub_can_post'] or !$data['can_view_others']) { $forumIdsBad[] = $id; continue; } $forumIdsOk[] = $id; } $forumIdsOk = count($forumIdsOk) ? $forumIdsOk : array(0 => 0); $where[] = "t.forum_id IN (" . implode(",", $forumIdsOk) . ")"; /* Generate last post times */ if (!$this->memberData['bw_vnc_type']) { $where[] = "t.last_post > " . IPSLib::fetchHighestNumber(array(intval($this->memberData['_cache']['gb_mark__forums']), intval($this->memberData['last_visit']))); } else { $_or = array(); foreach ($this->registry->class_forums->forum_by_id as $forumId => $forumData) { $lastMarked = $this->registry->getClass('classItemMarking')->fetchTimeLastMarked(array('forumID' => $forumId), 'forums'); $readItems = $this->registry->getClass('classItemMarking')->fetchReadIds(array('forumID' => $forumId), 'forums'); $readItems = (is_array($readItems) and count($readItems)) ? $readItems : array(); if (count($readItems)) { $_or[] = "(t.forum_id={$forumId} AND t.tid NOT IN(" . implode(",", $readItems) . ") AND t.last_post > " . intval($lastMarked) . ")"; } else { $_or[] = "(t.forum_id={$forumId} AND t.last_post > " . intval($lastMarked) . ")"; } } if (count($_or)) { $where[] = '(' . implode(" OR ", $_or) . ')'; } } /* Add in last bits */ $where[] = "t.state != 'link'"; $where[] = "t.approved=1"; return implode(" AND ", $where); }