/** * Get the nodes for given group * * @param string $groupid * @param integer $start (optional - default: 0) * @param integer $max (optional - default: 20) * @param string $orderby (optional, either 'date', 'nodeid', 'name', 'connectedness' or 'moddate' - default: 'date') * @param string $sort (optional, either 'ASC' or 'DESC' - default: 'DESC') * @param string $filterusers (optional, a list of user ids to filter by) * @param string $filternodetypes (optional, a list of node type names to filter by) * @param String $style (optional - default 'long') may be 'short' or 'long' - how much of a nodes details to load (long includes: description, tags, groups and urls). * @param string $q the query term(s) * @param integer $status, defaults to 0. (0 - active, 1 - reported, 2 - retired) * @return NodeSet or Error * @param string $connectionfilter filter by connections. Defaults to empty string which means disregard connection count. Possible values; '','connected','unconnected'. */ function getNodesByGroup($groupid, $start = 0, $max = 20, $orderby = 'date', $sort = 'DESC', $filterusers = '', $filternodetypes = '', $style = 'long', $q = "", $connectionfilter = '', $status = 0) { global $CFG, $USER, $HUB_SQL; $currentuser = ''; if (isset($USER->userid)) { $currentuser = $USER->userid; } $params = array(); $sql = $HUB_SQL->APILIB_NODES_BY_GROUP_SELECT; // FILTER NODE TYPES if ($filternodetypes != "") { // This comes first in HUB_SQL->APILIB_NODES_BY_GROUP_NODETYPE // Before node type list. $params[count($params)] = $groupid; $pieces = explode(",", $filternodetypes); $sqlList = ""; $loopCount = 0; foreach ($pieces as $value) { $params[count($params)] = $value; if ($loopCount == 0) { $sqlList .= "?"; } else { $sqlList .= ",?"; } $loopCount++; } $sql .= $HUB_SQL->APILIB_NODES_BY_GROUP_NODETYPE . $HUB_SQL->OPENING_BRACKET; $sql .= $sqlList; $sql .= $HUB_SQL->CLOSING_BRACKET . $HUB_SQL->AND; } else { $params[count($params)] = $groupid; $HUB_SQL->APILIB_NODES_BY_GROUP_NODETYPE_NONE . $HUB_SQL->AND; } if ($filterusers != "") { $pieces = explode(",", $filterusers); $loopCount = 0; $searchUsers = ""; foreach ($pieces as $value) { $params[count($params)] = $value; if ($loopCount == 0) { $searchUsers .= "?"; } else { $searchUsers .= ",?"; } $loopCount++; } $sql .= $HUB_SQL->FILTER_USERS . $HUB_SQL->OPENING_BRACKET; $sql .= $searchUsers; $sql .= $HUB_SQL->CLOSING_BRACKET . $HUB_SQL->AND; } // SEARCH if ($q != "") { $querySQL = getSearchQueryString($params, $q, true, true); $sql .= $querySQL; if ($querySQL != "") { $sql .= $HUB_SQL->AND; } } // PERMISSIONS $params[count($params)] = 'N'; $params[count($params)] = $currentuser; $params[count($params)] = $currentuser; $sql .= $HUB_SQL->APILIB_NODES_PERMISSIONS_ALL; // FILTER STATUS $params[count($params)] = $status; $sql .= $HUB_SQL->AND . $HUB_SQL->APILIB_FILTER_STATUS; // ORDER BY VOTE if ($orderby == 'vote') { $sql = $HUB_SQL->APILIB_NODE_ORDERBY_VOTE_PART1 . $sql . $HUB_SQL->APILIB_NODE_ORDERBY_VOTE_PART2; } if ($connectionfilter == 'unconnected') { $sql .= $HUB_SQL->APILIB_HAVING_UNCONNECTED; } else { if ($connectionfilter == 'connected') { $sql .= $HUB_SQL->APILIB_HAVING_CONNECTED; } } $ns = new NodeSet(); return $ns->load($sql, $params, $start, $max, $orderby, $sort, $style); }
/** * Get all the maps that the node with the given nodeid is in * @param nodeid the id of the node to get the maps for. * @return NodeSet a set of the map nodes that the given node is part of. */ function getMapsForNode($nodeid, $start = 0, $max = 20, $orderby = 'date', $sort = 'DESC', $style = 'long') { global $USER, $HUB_SQL, $DB; if (!isset($nodeid) || $nodeid == "") { return database_error(); } $params = array(); $currentuser = ''; if (isset($USER->userid)) { $currentuser = $USER->userid; } $params[0] = $nodeid; $sql = $HUB_SQL->APILIB_MAPS_FOR_NODE_SELECT; // PERMISSIONS //if($scope == 'my'){ // $params[count($params)] = currentuser; // $sql .= $HUB_SQL->APILIB_NODES_PERMISSIONS_MY; //} else { $params[count($params)] = 'N'; $params[count($params)] = $currentuser; $params[count($params)] = $currentuser; $sql .= $HUB_SQL->AND . $HUB_SQL->APILIB_NODES_PERMISSIONS_ALL; //} //error_log("Search=".$sql); $ns = new NodeSet(); return $ns->load($sql, $params, $start, $max, $orderby, $sort, $style); }
/** * Get the nodes with the given status. * * @param integer $status (0 = non-spam or 1 = spam) * @param integer $start (optional - default: 0) * @param integer $max (optional - default: 20) * @param string $orderby (optional, either 'date', 'nodeid', 'name', 'connectedness' or 'moddate' - default: 'date') * @param string $sort (optional, either 'ASC' or 'DESC' - default: 'DESC') * @param String $style (optional - default 'long') may be 'short' or 'long' - how much of a nodes details to load (long includes: description, tags, groups and urls). * @return NodeSet or Error */ function getNodesByStatus($status = 0, $start = 0, $max = 20, $orderby = 'date', $sort = 'DESC', $style = 'long') { global $CFG, $USER, $HUB_SQL; $params = array(); $params[0] = $status; $sql = $HUB_SQL->UTILLIB_NODES_BY_STATUS; $ns = new NodeSet(); return $ns->load($sql, $params, $start, $max, $orderby, $sort, $style); }