/** * Constructor. * * @param Content_Users_Manager A user manager object. */ public function __construct(Content_Users_Manager $userManager) { $this->_userManager = $userManager; try { $this->_userId = current($this->_userManager->ensureUsers($GLOBALS['registry']->getAuth())); } catch (Content_Exception $e) { throw new Trean_Exception($e); } }
/** * Return users related to a given user along with a similarity rank. */ public function getSimilarUsers($args) { $args['userId'] = current($this->_userManager->ensureUsers($args['userId'])); $radius = isset($args['radius']) ? (int) $args['radius'] : $this->_defaultRadius; $sql = 'SELECT others.user_id, (others.count - self.count) AS rank FROM ' . $this->_t('user_tag_stats') . ' others INNER JOIN (SELECT tag_id, count FROM ' . $this->_t('user_tag_stats') . ' WHERE user_id = ' . (int) $args['userId'] . ' AND count >= ' . $radius . ') self ON others.tag_id = self.tag_id ORDER BY rank DESC'; if (isset($args['limit'])) { $sql = $this->_db->addLimitOffset($sql, array('limit' => $args['limit'])); } return $this->_db->selectAssoc($sql); }