/** * @return string html */ function isSubscribed($feed_id) { if (!$this->isLoggedIn()) { return "<img src='{$this->url}/media/{$this->partition}/assets/sticky.gif' border='0' width='12' height='12' alt='' />"; } // Get config variables for template $tpl = new suxTemplate($this->module); $tpl->configLoad('my.conf', $this->module); $image = $tpl->getConfigVars('imgUnsubscribed'); // Don't query the database unnecessarily. static $img_cache = array(); if (isset($img_cache[$feed_id])) { $image = $img_cache[$feed_id]; } else { // If subscribed, change image $query = 'SELECT COUNT(*) FROM link__rss_feeds__users WHERE rss_feeds_id = ? AND users_id = ? '; $db = suxDB::get(); $st = $db->prepare($query); $st->execute(array($feed_id, $_SESSION['users_id'])); if ($st->fetchColumn() > 0) { $image = $tpl->getConfigVars('imgSubscribed'); } $img_cache[$feed_id] = $image; } $html = "<img src='{$this->url}/media/{$this->partition}/assets/{$image}' border='0' width='12' height='12' alt=''\n onclick=\"toggleSubscription('{$feed_id}');\"\n style='cursor: pointer;'\n class='subscription{$feed_id}'\n />"; return $html; }
/** * Get the stalkers * * @param int $users_id * @return string html */ function stalkers($users_id) { if (!filter_var($users_id, FILTER_VALIDATE_INT) || $users_id < 1) { return null; } // Cache static $html = null; if ($html != null) { return $html; } $html = ''; $soc = new suxSocialNetwork(); $rel = $soc->getStalkers($users_id); if (!$rel) { return $html; } $tpl = new suxTemplate('user'); $tpl->configLoad('my.conf', 'user'); $tw = $tpl->getConfigVars('thumbnailWidth'); $th = $tpl->getConfigVars('thumbnailHeight'); foreach ($rel as $val) { $u = $this->user->getByID($val['users_id'], true); if (!$u) { continue; } // Skip $url = suxFunct::makeUrl('/user/profile/' . $u['nickname']); if (empty($u['image'])) { $img = suxFunct::makeUrl('/') . "/media/{$this->partition}/assets/proletariat.gif"; } else { $u['image'] = rawurlencode($u['image']); $img = suxFunct::makeUrl('/') . "/data/user/{$u['image']}"; } $html .= "<a href='{$url}' class='stalker'>"; $html .= "<img src='{$img}' class='stalker' width='{$tw}' height='{$th}' alt='{$u['nickname']}' title = '{$u['nickname']}' />"; $html .= "</a>"; } return $html; }
// --------------------------------------------------------------------------- // Secondary error checking // --------------------------------------------------------------------------- $feed = new suxRSS(); if (!$feed->getFeedByID($id)) { failure('Invalid feed'); } // --------------------------------------------------------------------------- // Go // --------------------------------------------------------------------------- $module = 'feeds'; $link = 'link__rss_feeds__users'; $col = 'rss_feeds'; // Get image names from template config $tpl = new suxTemplate($module); $tpl->configLoad('my.conf', $module); $image = $tpl->getConfigVars('imgUnsubscribed'); $db = suxDB::get(); $query = "SELECT COUNT(*) FROM {$link} WHERE {$col}_id = ? AND users_id = ? "; $st = $db->prepare($query); $st->execute(array($id, $_SESSION['users_id'])); if ($st->fetchColumn() > 0) { // Delete $query = "DELETE FROM {$link} WHERE {$col}_id = ? AND users_id = ? "; $st = $db->prepare($query); $st->execute(array($id, $_SESSION['users_id'])); } else { // Insert $suxLink = new suxLink(); $suxLink->saveLink($link, 'users', $_SESSION['users_id'], $col, $id); $image = $tpl->getConfigVars('imgSubscribed');