/** * 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(); }
/** * Delete connection * * @return Result object (or Error object) */ function delete() { global $DB, $CFG, $USER, $HUB_SQL; try { $this->candelete(); } catch (Exception $e) { return access_denied_error(); } $dt = time(); $this->load(); $xml = format_object('xml', $this); $params = array(); $params[0] = $this->connid; $res = $DB->delete($HUB_SQL->DATAMODEL_CONNECTION_DELETE, $params); if (!$res) { return database_error(); } if (!auditConnection($USER->userid, $this->connid, "", $this->from->nodeid, $this->to->nodeid, $this->linktype->linktypeid, $this->fromrole->roleid, $this->torole->roleid, $CFG->actionDelete, $xml)) { return database_error(); } return new Result("deleted", "true", "1"); }
/** * 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"); }
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 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"); }
/** * Delete the news node from the system, if your an admin only. * @param $nodeid the id of the theme node to delete. * @return true if it all went well, else false. */ function adminDeleteNews($nodeid) { global $CFG, $DB, $USER, $HUB_SQL; if (isset($USER) && $USER != "" && $USER->getIsAdmin() == "Y") { $n = new CNode($nodeid); if (!$n instanceof Error) { $n = $n->load(); if ($n->role->name == "News") { $xml = format_object('xml', $n); $params = array(); $params[0] = $nodeid; $sql = $HUB_SQL->DATAMODEL_NODE_DELETE; $res = $DB->delete($sql, $params); if ($res) { auditIdea($USER->userid, $n->nodeid, $n->name, $n->description, $CFG->actionDelete, $xml); } return true; } } } return false; }
/** * Delete node * * @return Result object (or Error object) */ function delete() { global $DB, $CFG, $USER, $HUB_FLM, $HUB_SQL; $this->load(); try { $this->candelete(); } catch (Exception $e) { return access_denied_error(); } $dt = time(); $params = array(); $params[0] = $this->viewid; $params[1] = $this->userid; $params[2] = $this->connid; $res = $DB->delete($HUB_SQL->DATAMODEL_VIEWCONNECTION_DELETE, $params); if ($res) { // Need to bypass check. // If you can delete the viewconnection you can delete it's underlying connection which needs to be deleted. $xml = format_object('xml', $this->connection); $params = array(); $params[0] = $this->connection->connid; $res2 = $DB->delete($HUB_SQL->DATAMODEL_CONNECTION_DELETE, $params); if ($res2) { auditConnection($USER->userid, $this->connection->connid, "", $this->connection->from->nodeid, $this->connection->to->nodeid, $this->connection->linktype->linktypeid, $this->connection->fromrole->roleid, $this->connection->torole->roleid, $CFG->actionDelete, $xml); } auditViewTriple($USER->userid, $this->viewid, $this->connid, $CFG->actionDelete); } else { return database_error(); } return new Result("deleted", "true"); }