/** * Create access denied error message * * @return Error object */ function access_denied_error() { global $ERROR; $ERROR = new error(); $ERROR->createAccessDeniedError(); return $ERROR; }
/** * Log into the site * * @uses $CFG * @param string $email * @param string $password * @return User object if successful else Error object */ function userLogin($email, $password) { global $CFG, $ERROR; clearSession(); /** Just in case **/ if ($password == "" || $email == "") { $ERROR = new error(); $ERROR->createLoginFailedError(); return $ERROR; } $user = new User(); $user->setEmail($email); $user = $user->getByEmail(); if ($user instanceof User) { // make sure this user is an active user $status = $user->getStatus(); if ($status == $CFG->USER_STATUS_ACTIVE || $status == $CFG->USER_STATUS_REPORTED) { if (strcmp($user->getAuthType(), $CFG->AUTH_TYPE_EVHUB) == 0) { $passwordCheck = $user->validPassword($password); if ($passwordCheck) { createSession($user); $user->resetInvitationCode(); // hang over from Cohere groups code $user->load(); return $user; } else { $ERROR = new error(); $ERROR->createLoginFailedError(); return $ERROR; } } else { $ERROR = new error(); $provider = ucfirst($user->getAuthType()); $ERROR->createLoginFailedExternalError($provider); return $ERROR; } } else { $ERROR = new error(); if ($status == $CFG->USER_STATUS_UNAUTHORIZED) { $ERROR->createLoginFailedUnauthorizedError(); } else { if ($status == $CFG->USER_STATUS_SUSPENDED) { $ERROR->createLoginFailedSuspendedError(); } else { if ($status == $CFG->USER_STATUS_UNVALIDATED) { $ERROR->createLoginFailedUnvalidatedError(); } else { $ERROR->createAccessDeniedError(); } } } return $ERROR; } } else { $ERROR = new error(); $ERROR->createLoginFailedError(); return $ERROR; } }
/** * Import nodes and connections from the given CIF url for the selected nodeids into the given map. * The node import limit is set by '$CFG->ImportLimit'. * @param url the url for the CIF data to load * @param mapid the id of the map to get alerts for * @param selectedids an array of the CIF node ides to import * @param poses an array of the positions of the nodes in the map each array item is in * the format 'x:y' and the position in the array should correspond ot the position of * its node in the selectednodeids array. * before it is considered out of date and should be refetched and recalculated. * Defaults to 60 seconds. * @param private true if the data should be created as private, else false. * @return View object of the map or Error. * */ function addNodesAndConnectionsFromJsonld($url, $mapid, $selectedids, $poses, $private) { global $USER, $HUB_FLM, $CFG, $ERROR; require_once $HUB_FLM->getCodeDirPath("core/io/catalyst/catalyst_jsonld_reader.class.php"); require_once $HUB_FLM->getCodeDirPath("core/lib/url-validation.class.php"); //error_log(print_r($selectedids, true)); if (count($selectedids) > $CFG->ImportLimit) { $ERROR = new error(); $ERROR->createAccessDeniedError(); return $ERROR; } //error_log(print_r($poses, true)); // Check if the map is in a group and if so get the group id. $groupid = ""; $v = new View($mapid); $view = $v->load(); if (!$view instanceof Error) { if (isset($view->viewnode->groups)) { $groups = $view->viewnode->groups; if (count($groups) > 0) { $groupid = $groups[0]->groupid; } } } else { return $view; } // make sure current user in group, if group set. if ($groupid != "") { $group = new Group($groupid); if (!$group instanceof Error) { if (!$group->ismember($USER->userid)) { $error = new Error(); return $error->createNotInGroup($group->name); } } } $withhistory = false; $withvotes = false; $reader = new catalyst_jsonld_reader(); $reader = $reader->load($url, $withhistory, $withvotes); if (!$reader instanceof Error) { $nodeset = $reader->nodeSet; $nodes = $nodeset->nodes; $count = count($nodes); $newnodeSet = new NodeSet(); $newNodeCheck = array(); for ($i = 0; $i < $count; $i++) { $node = $nodes[$i]; $position = array_search($node->nodeid, $selectedids); //error_log("position:".$position); if ($position !== FALSE) { $position = intval($position); $positem = $poses[$position]; $positemArray = explode(":", $positem); $xpos = ""; $ypos = ""; if (count($positemArray) == 2) { $xpos = $positemArray[0]; $ypos = $positemArray[1]; } //error_log("xpos:".$xpos.":ypos:".$ypos); $role = getRoleByName($node->rolename); $description = ""; if (isset($node->description)) { $description = $node->description; } $newnode = addNode($node->name, $description, $private, $role->roleid); //error_log(print_r($newnode, true)); if (!$newnode instanceof Error) { $newNodeCheck[$node->nodeid] = $newnode; //error_log($node->nodeid); // if we have positioning information add the node to the map. if ($xpos != "" && $ypos != "") { $viewnode = $view->addNode($newnode->nodeid, $xpos, $ypos); //if (!$viewnode instanceof Error) { } if (isset($node->homepage) && $node->homepage != "") { $URLValidator = new mrsnk_URL_validation($node->homepage, MRSNK_URL_DO_NOT_PRINT_ERRORS, MRSNK_URL_DO_NOT_CONNECT_2_URL); if ($URLValidator->isValid()) { $urlObj = addURL($node->homepage, $node->homepage, "", $private, "", "", "", "cohere", ""); $newnode->addURL($urlObj->urlid, ""); // Add url to group? - not done on forms at present } else { error_log('Invalid node homepage: ' . $node->homepage . ': for ' . $node->nodeid); } } if (isset($node->users[0])) { $user = $node->users[0]; if (isset($user->homepage) && $user->homepage != "") { $URLValidator = new mrsnk_URL_validation($user->homepage, MRSNK_URL_DO_NOT_PRINT_ERRORS, MRSNK_URL_DO_NOT_CONNECT_2_URL); if ($URLValidator->isValid()) { $urlObj = addURL($user->homepage, $user->homepage, "", $private, "", "", "", "cohere", ""); $newnode->addURL($urlObj->urlid, ""); // Add url to group? - not done on forms at present } else { error_log('Invalid user homepage: ' . $user->homepage . ': for ' . $user->userid); } } } //if ($groupid != "") { // $newnode->addGroup($groupid); //} $newnodeSet->add($newnode); } else { error_log(print_r($newnode, true)); } } } $connectionset = $reader->connectionSet; $connections = $connectionset->connections; $count = count($connections); for ($i = 0; $i < $count; $i++) { $conn = $connections[$i]; $from = $conn->from; $to = $conn->to; $fromrole = $conn->fromrole; $torole = $conn->torole; if (isset($newNodeCheck[$from->nodeid]) && isset($newNodeCheck[$to->nodeid])) { $newFromNode = $newNodeCheck[$from->nodeid]; $newToNode = $newNodeCheck[$to->nodeid]; // Might not need this as it might be done already //if ($newFromNode->role->name != $fromrole->name) { // updateNodeRole($newFromNode->nodeid,$fromrole->name); //} $linklabelname = $conn->linklabelname; //error_log($linklabelname); $lt = getLinkTypeByLabel($linklabelname); if (!$lt instanceof Error) { $linkType = $lt->linktypeid; //$frole = getRoleByName($fromrole->name); //$trole = getRoleByName($torole->name); $connection = addConnection($newFromNode->nodeid, $newFromNode->role->roleid, $linkType, $newToNode->nodeid, $newToNode->role->roleid, 'N', ""); //error_log(print_r($connection, true)); if (!$connection instanceof Error) { // add to group if (isset($groupid) && $groupid != "") { $connection->addGroup($groupid); } $viewcon = $view->addConnection($connection->connid); //error_log(print_r($viewcon,true)); } else { error_log(print_r($connection, true)); } } else { error_log("for label:" . $linklabelname . ":" . print_r($lt, true)); } } } } else { return $reader; } return $view; }
die; } $group = getConversationData($id); $group->cipher = $cipher; if (isset($unobfuscationid) && $unobfuscationid != "") { $group->unobfuscationid = $unobfuscationid; } if ($len == 4) { $subtype = check_param($parts[3], PARAM_ALPHA); $group->filter = $subtype; } $response = $group; } else { global $ERROR; $ERROR = new error(); $ERROR->createAccessDeniedError(); include $HUB_FLM->getCodeDirPath("core/formaterror.php"); die; } } break; default: //error as method not defined. global $ERROR; $ERROR = new error(); $ERROR->createInvalidMethodError(); include $HUB_FLM->getCodeDirPath("core/formaterror.php"); die; } //error_log("ENDING Initial data gathering"); // finally format the output
/** * Get the users with the given status. For admin area. * * @param integer $status * <br>$CFG->USER_STATUS_ACTIVE = live and active account * <br>$CFG->USER_STATUS_REPORTED = user has been reported as spammer (not used at present) * <br>$CFG->USER_STATUS_UNVALIDATED = new user account that has not had the email address verified yet. * <br>$CFG->USER_STATUS_UNAUTHORIZED = new user account that has not been authorized yet. * <br>$CFG->USER_STATUS_SUSPENDED = user account that has been suspended. * * @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 getUsersByStatus($status = 0, $start = 0, $max = 20, $orderby = 'date', $sort = 'DESC', $style = 'long') { global $CFG, $USER, $HUB_SQL; if ($USER->getIsAdmin() == "Y") { $params = array(); $params[0] = $status; $sql = $HUB_SQL->UTILLIB_USERS_BY_STATUS; $us = new UserSet(); return $us->load($sql, $params, $start, $max, $orderby, $sort, $style); } else { $ERROR = new error(); return $ERROR->createAccessDeniedError(); } }