/** * Remove a URL from this node * * @param string $nodeid * @return URL object (this) (or Error object) */ function removeIdea($nodeid) { global $DB, $CFG, $USER, $HUB_SQL, $HUB_CACHE; //check user can edit the URL try { $this->canedit(); } catch (Exception $e) { return access_denied_error(); } //check user can edit the Node $node = new CNode($nodeid); $node = $node->load(); try { $node->canedit(); } catch (Exception $e) { return access_denied_error(); } if (isset($HUB_CACHE)) { $HUB_CACHE->deleteData($this->urlid . $this->style); } $dt = time(); $currentuser = ''; if (isset($USER->userid)) { $currentuser = $USER->userid; } $params = array(); $params[0] = $nodeid; $params[1] = $this->urlid; $params[2] = $currentuser; $res = $DB->delete($HUB_SQL->DATAMODEL_URL_IDEA_DELETE, $params); if (res) { if (!auditURL($USER->userid, $this->urlid, $nodeid, "", "", "", "", "", "", "", $CFG->actionDelete, format_object('xml', $node))) { return database_error(); } } else { return database_error(); } return $this->load(); }
/** * Set the privacy setting of this Connection * * @return Connection object (this) (or Error object) */ function setPrivacy($private) { global $DB, $CFG, $USER, $HUB_SQL; //check user owns the Connection try { $this->canedit(); } catch (Exception $e) { return access_denied_error(); } $dt = time(); $params = array(); $params[0] = $private; $params[1] = $dt; $params[2] = $this->connid; $res = $DB->insert($HUB_SQL->DATAMODEL_CONNECTION_PRIVACY_UPDATE, $params); if (!$res) { return database_error(); } return $this->load(); }
/** * Load the activity object. * @param String $itemid the id of the item whose activity was auditied. * @param String $userid the id of the user who caused the audit to happen. Who performed the activity. * @param String $type the type of audited item ('Vote', 'Node', 'Connection', 'Follow', 'View') * @param int $modificationdate the time of the audit in seconds from epoch * @param String $changetype the type of activity (view, edit, add, delete etc) * @param String $xml the xml for the audited history object * @param String $style (optional - default 'long') may be 'short' or 'long' or 'cif' */ function load($itemid, $userid, $type, $modificationdate, $changetype, $xml, $style = 'long') { $this->itemid = $itemid; $this->userid = $userid; $this->type = $type; $this->modificationdate = $modificationdate; $this->changetype = $changetype; $this->xml = $xml; $this->user = new User($userid); if ($style != 'cif') { $this->user = $this->user->load($style); } switch ($this->type) { case "Node": if ($style == 'long') { $this->node = getIdeaFromAuditXML($this->xml); } $this->currentnode = getNode($this->itemid, $style); if ($this->currentnode instanceof Error) { if ($this->currentnode->code == 7007) { // NODE NOT FOUND $this->tombstone == true; } } break; case "Connection": if ($style == 'long') { $this->con = getConnectionFromAuditXML($this->xml); } $this->currentcon = getConnection($this->itemid, $style); if ($this->currentcon instanceof Error) { if ($this->currentcon->code == 7008) { // CONNECTION NODE FOUND $this->tombstone == true; } } break; } try { $this->canview($style); } catch (Exception $e) { $this->itemid = ""; $this->userid = ""; $this->type = ""; $this->modificationdate = ""; $this->changetype = ""; $this->xml = ""; $this->user = ""; $this->node = ""; $this->con = ""; $this->currentnode = ""; $this->currentcon = ""; return access_denied_error(); } }
/** * Delete this linktype and any of this users connections using it. * * @return Result object (or Error object) */ function delete() { global $DB, $CFG, $USER, $HUB_SQL, $HUB_CACHE; try { $this->candelete(); } catch (Exception $e) { return access_denied_error(); } if (isset($HUB_CACHE)) { $HUB_CACHE->deleteData($this->linktypeid); } $currentuser = ''; if (isset($USER->userid)) { $currentuser = $USER->userid; } $params = array(); $params[0] = $this->linktypeid; $params[1] = $currentuser; $resArray = $DB->select($HUB_SQL->DATAMODEL_LINKTYPE_DELETE_CHECK, $params); if ($resArray !== false) { $count = count($resArray); for ($i = 0; $i < $count; $i++) { $array = $resArray[$i]; $c = new Connection($array['TripleID']); $c = $c->load(); if (!auditConnection($USER->userid, $array['TripleID'], $array['Label'], $array['FromID'], $array['ToID'], $array['LinkTypeID'], $array['FromContextTypeID'], $array['ToContextTypeID'], $CFG->actionDelete, format_object('xml', $c))) { return database_error(); } } $res = $DB->delete($HUB_SQL->DATAMODEL_LINKTYPE_DELETE_TRIPLE, $params); if ($res) { $res1 = $DB->delete($HUB_SQL->DATAMODEL_LINKTYPE_DELETE, $params); if (!$res1) { return database_error(); } } else { return database_error(); } } else { return database_error(); } return new Result("deleted", "true"); }
/** * Check whether the current user can delete the map * * @throws Exception */ function candelete() { global $USER, $USER; // need to be allowed to delete the associated view node. try { $node = new CNode($this->nodeid); $node->candelete(); } catch (Exception $e) { return access_denied_error(); } }
/** * Remove a Tag from this user * * @param string $urlid * @return User object (this) (or Error object) */ function removeTag($tagid) { global $DB, $CFG, $USER, $HUB_SQL, $HUB_CACHE; if (isset($HUB_CACHE)) { $HUB_CACHE->deleteData($this->userid . $this->style); } //check user can edit the Tag $tag = new Tag($tagid); $tag = $tag->load(); try { $tag->canedit(); } catch (Exception $e) { return access_denied_error(); } $dt = time(); $params = array(); $params[0] = $this->userid; $params[1] = $tagid; $res = $DB->delete($HUB_SQL->DATAMODEL_USER_DELETE, $params); if (!$res) { return database_error(); } return $this->load(); }
function deleteNodeProperty($property) { global $DB, $HUB_SQL, $CFG; try { $this->candelete(); } catch (Exception $e) { return access_denied_error(); } $dt = time(); $params = array(); $params[0] = $this->nodeid; $params[1] = $property; $res = $DB->delete($HUB_SQL->DATAMODEL_NODE_PROPERTY_DELETE, $params); if (!$res) { return database_error(); } else { $temp = $this->load(); auditIdea($USER->userid, $temp->nodeid, $temp->name, $temp->description, $CFG->actionEdit, format_object('xml', $temp)); return $temp; } }
/** * Delete this tag * * @return Result object (or Error object) */ function delete() { global $DB, $CFG, $USER, $HUB_SQL, $HUB_CACHE; try { $this->candelete(); } catch (Exception $e) { return access_denied_error(); } if (isset($HUB_CACHE)) { $HUB_CACHE->deleteData($this->tagid); } $currentuser = ''; if (isset($USER->userid)) { $currentuser = $USER->userid; } $params = array(); $params[0] = $currentuser; $params[1] = $this->tagid; $res = $DB->delete($HUB_SQL->DATAMODEL_TAG_DELETE, $params); if (!$res) { return database_error(); } return new Result("deleted", "true"); }
/** * Mark that this user was removed from the group by marking thier requested record as reported * Only group admins can run this function. * * @param string $userid of the user to mark as reported * @return Group object (this) */ function reportpendingmember($userid) { global $DB, $CFG, $USER, $HUB_SQL, $LNG; //check user can edit the group if (!$this->isgroupadmin($USER->userid)) { return access_denied_error(); } // check user exists $user = new User($userid); if ($user->load() instanceof Error) { global $ERROR; $ERROR = new error(); return $ERROR->createUserNotFoundError($userid); } // now add the user $params = array(); $params[0] = $USER->userid; $params[1] = time(); $params[2] = $this->groupid; $params[3] = $userid; $res = $DB->insert($HUB_SQL->DATAMODEL_GROUP_JOIN_REPORT, $params); if (!$res) { return database_error(); } return $this; }
/** * Check whether current user is logged in or not * * @return Error object */ function api_check_login() { global $USER; if (!isset($USER->userid)) { return access_denied_error(); } return true; }
/** * Delete this role * * @return Result object (or Error object) */ function delete() { global $DB, $CFG, $USER, $HUB_SQL, $HUB_CACHE; try { $this->candelete(); } catch (Exception $e) { return access_denied_error(); } if (isset($HUB_CACHE)) { $HUB_CACHE->deleteData($this->roleid); } $currentuser = ''; if (isset($USER->userid)) { $currentuser = $USER->userid; } $params = array(); $params[0] = $this->roleid; $params[1] = $this->roleid; $params[2] = $currentuser; $resArray = $DB->select($HUB_SQL->DATAMODEL_ROLE_DELETE_CHECK, $params); if ($resArray !== false) { $count = count($resArray); // Get the default role for this user $defRoleID = getDefaultRoleID(); for ($i = 0; $i < $count; $i++) { $array = $resArray[$i]; $fromContextType = $array['FromContextTypeID']; $toContextType = $array['ToContextTypeID']; if ($fromContextType == $this->roleid) { $fromContextType = $defRoleID; } if ($toContextType == $this->roleid) { $toContextType = $defRoleID; } $c = new Connection($array['TripleID']); $c = $c->load(); if (!auditConnection($USER->userid, $array['TripleID'], $array['Label'], $array['FromID'], $array['ToID'], $array['LinkTypeID'], $fromContextType, $toContextType, $CFG->actionEdit, format_object('xml', $c))) { return database_error(); } } $params = array(); $params[0] = $defRoleID; $params[1] = $this->roleid; $params[2] = $currentuser; $res1 = $DB->insert($HUB_SQL->DATAMODEL_ROLE_DELETE_UPDATE_TRIPLE_FROM, $params); $params = array(); $params[0] = $defRoleID; $params[1] = $this->roleid; $params[2] = $currentuser; $res2 = $DB->insert($HUB_SQL->DATAMODEL_ROLE_DELETE_UPDATE_TRIPLE_TO, $params); if ($res1 && $res2) { $params = array(); $params[0] = $currentuser; $params[1] = $this->roleid; $res = $DB->delete($HUB_SQL->DATAMODEL_ROLE_DELETE, $params); if (!$res) { return database_error(); } else { //delete any associated user assigned icon if ($this->image != null && $this->image != "" && substr($this->image, 0, 7) == 'uploads') { unlink($CFG->dirAddress . $this->image); } } } else { return database_error(); } } else { return database_error(); } return new Result("deleted", "true"); }
/** * Check whether the current user can delete the current ViewNode record * * @throws Exception */ function candelete() { global $DB, $USER, $HUB_SQL, $LNG; api_check_login(); /** CHANGED: If you can edit the map you can remove a node from the map **/ try { $view = new View($this->viewid); $view->canedit(); } catch (Exception $e) { return access_denied_error(); } /*$currentuser = ''; if (isset($USER->userid)) { $currentuser = $USER->userid; } if ($currentuser !== $this->userid) { throw new Exception($LNG->ERROR_ACCESS_DENIED_MESSAGE); } //can delete only if owner of this ViewNode record $params = array(); $params[0] = $this->viewid; $params[1] = $this->nodeid; $params[2] = $currentuser; $resArray = $DB->select($HUB_SQL->DATAMODEL_VIEWNODE_CAN_EDIT, $params); if($resArray !== false){ if (count($resArray) == 0) { throw new Exception($LNG->ERROR_ACCESS_DENIED_MESSAGE); } } else { throw new Exception($LNG->ERROR_ACCESS_DENIED_MESSAGE); } */ }
function delete() { global $DB, $CFG, $USER, $HUB_SQL; try { $this->candelete(); } catch (Exception $e) { return access_denied_error(); } $currentuser = ''; if (isset($USER->userid)) { $currentuser = $USER->userid; } $params = array(); $params[0] = $this->itemid; $params[1] = $currentuser; $res = $DB->delete($HUB_SQL->DATAMODEL_FOLLOW_DELETE, $params); if (!$res) { return database_error(); } $this->load(); return $this; }