/** * Get the link type usage for each user * return an array with two items; 1=Array of arrays of link type use counts, 2=An array of users for thos counts. * Both return arrays are associative mapped to the userids. * @param $groupid the id of the group to filter on */ function getLinkTypeUsageByGroup($groupid) { global $DB, $HUB_SQL; $params = array(); $qryStart = $HUB_SQL->STATSLIB_GLOBAL_LINKTYPE_USAGE_PART1; $qryNames = ""; $qryMiddle = $HUB_SQL->STATSLIB_GLOBAL_LINKTYPE_USAGE_PART2; $qryIDs = ""; $qryEnd = $HUB_SQL->STATSLIB_GLOBAL_LINKTYPE_USAGE_PART3; $qry = ""; $userSet = getActiveConnectionUsers(0, 10); if ($userSet->count > 0) { for ($i = 0; $i < $userSet->count; $i++) { $user = $userSet->users[$i]; if ($user->userid && $user->userid != "") { $name = "_" . $user->userid; // because can't use a number to start an alias name if ($i == 0) { $qryNames .= $name; $qryIDs .= "'" . $user->userid . "'"; } else { $qryNames .= "," . $name; $qryIDs .= ",'" . $user->userid . "'"; } $qry .= $HUB_SQL->STATSLIB_GLOBAL_LINKTYPE_USAGE_PART4 . $name; $params[count($params)] = $groupid; $params[count($params)] = $user->userid; $qry .= $HUB_SQL->STATSLIB_GLOBAL_LINKTYPE_USAGE_PART5_GROUPS . $user->userid; $qry .= $HUB_SQL->STATSLIB_GLOBAL_LINKTYPE_USAGE_PART6 . $user->userid; $qry .= $HUB_SQL->STATSLIB_GLOBAL_LINKTYPE_USAGE_PART7; } } } if ($qryNames != "" && $qryIDs != "") { $qryFinal = $qryStart; $qryFinal .= $qryNames; $qryFinal .= $qryMiddle; $qryFinal .= $qryIDs; $qryFinal .= $qryEnd; $qryFinal .= $qry; $qryFinal .= $HUB_SQL->CLOSING_BRACKET; $linktypeUse = array(); //error_log($qryFinal); $resArray = $DB->select($qryFinal, $params); if ($resArray !== false) { $count = count($resArray); for ($i = 0; $i < $count; $i++) { $array = $resArray[$i]; $linktypeUse[count($linktypeUse)] = $array; } } $qry = $HUB_SQL->STATSLIB_GLOBAL_LINKTYPE_USAGE_SELECT; $qry .= $qryIDs; $qry .= $HUB_SQL->CLOSING_BRACKET; $linktypeName = array(); $resArray = $DB->select($qry, $params); if ($resArray !== false) { $count = count($resArray); for ($i = 0; $i < $count; $i++) { $array = $resArray[$i]; $linktypeName[$array['UserID']] = $array['Name']; } } } return array($linktypeUse, $linktypeName); }
$response = getRoleByName($rolename); break; /** LINK TYPES **/ /** LINK TYPES **/ case "getlinktypebylabel": $label = required_param('label', PARAM_TEXT); $response = getLinkTypeByLabel($label); break; /** USERS **/ /** USERS **/ case "getuser": $userid = required_param('userid', PARAM_ALPHANUMEXT); $response = getUser($userid, $style); break; case "getactiveconnectionusers": $response = getActiveConnectionUsers($start, $max, $style); break; case "getactiveideausers": $response = getActiveIdeaUsers($start, $max, $style); break; case "getusersbyfollowing": $itemid = required_param('itemid', PARAM_ALPHANUMEXT); $response = getUsersByFollowing($itemid, $start, $max, $o, $s, $style); break; case "getusersbymostfollowed": $limit = required_param('limit', PARAM_TEXT); $response = getUsersByMostFollowed($limit, $style); break; case "getusersmostactive": $limit = required_param('limit', PARAM_TEXT); $from = required_param('from', PARAM_INT);