function deleteRackTablesData() { // delete racktables items data $query = 'delete from item_information;'; usePreparedExecuteBlade($query); // delete racktables object data $allObjects = scanRealmByText('object'); foreach ($allObjects as $object) { $racklist = getResidentRacksData($object["id"], FALSE); commitDeleteObject($object["id"]); foreach ($racklist as $rack_id) { usePreparedDeleteBlade('RackThumbnail', array('rack_id' => $rack_id)); } } // delete racktables rack data $allRacks = scanRealmByText('rack'); foreach ($allRacks as $rack) { releaseFiles('rack', $rack['id']); destroyTagsForEntity('rack', $rack['id']); usePreparedDeleteBlade('RackSpace', array('rack_id' => $rack['id'])); commitDeleteObject($rack['id']); resetRackSortOrder($rack['row_id']); } $query = 'delete from rack_position;'; usePreparedExecuteBlade($query); $query = 'delete from rack_airconditioner;'; usePreparedExecuteBlade($query); }
public static function tearDownAfterClass() { // remove sample data commitDeleteObject(self::$objecta_id); commitDeleteObject(self::$objectb_id); commitDeleteObject(self::$objectc_id); commitDeleteObject(self::$objectd_id); commitReduceOPC(self::$objtypea_id, self::$objtypeb_id); commitReduceOPC(self::$objtypea_id, self::$objtypec_id); commitReduceOPC(self::$objtypeb_id, self::$objtypea_id); commitReduceOPC(self::$objtypeb_id, self::$objtypec_id); commitReduceOPC(self::$objtypec_id, self::$objtypea_id); commitReduceOPC(self::$objtypec_id, self::$objtypeb_id); usePreparedDeleteBlade('Dictionary', array('dict_key' => self::$objtypea_id)); usePreparedDeleteBlade('Dictionary', array('dict_key' => self::$objtypeb_id)); usePreparedDeleteBlade('Dictionary', array('dict_key' => self::$objtypec_id)); usePreparedDeleteBlade('Dictionary', array('dict_key' => self::$objtyped_id)); commitDeleteObject(self::$locationa_id); commitDeleteObject(self::$locationb_id); commitDeleteObject(self::$locationc_id); commitDeleteObject(self::$rowa_id); commitDeleteObject(self::$rowb_id); commitDeleteObject(self::$racka_id); commitDeleteObject(self::$rackb_id); }
public function tearDown() { // remove sample data usePreparedExecuteBlade('UPDATE TagTree SET parent_id = NULL WHERE id IN (?,?,?)', array($this->taga_id, $this->tagb_id, $this->tagc_id)); usePreparedDeleteBlade('TagTree', array('id' => $this->taga_id)); usePreparedDeleteBlade('TagTree', array('id' => $this->tagb_id)); usePreparedDeleteBlade('TagTree', array('id' => $this->tagc_id)); }
public static function tearDownAfterClass() { usePreparedExecuteBlade('SET foreign_key_checks=0'); // remove sample locations usePreparedExecuteBlade('DELETE FROM Object WHERE id BETWEEN ? AND ?', array(self::$first_location_id, self::$last_location_id)); usePreparedExecuteBlade("DELETE FROM EntityLink WHERE parent_entity_type='location' AND child_entity_type='location' " . 'AND ((parent_entity_id BETWEEN ? AND ?) OR (child_entity_id BETWEEN ? AND ?))', array(self::$first_location_id, self::$last_location_id, self::$first_location_id, self::$last_location_id)); // remove sample objects usePreparedExecuteBlade('DELETE FROM Object WHERE id BETWEEN ? AND ?', array(self::$first_object_id, self::$last_object_id)); usePreparedExecuteBlade("DELETE FROM EntityLink WHERE parent_entity_type='object' AND child_entity_type='object' " . 'AND ((parent_entity_id BETWEEN ? AND ?) OR (child_entity_id BETWEEN ? AND ?))', array(self::$first_object_id, self::$last_object_id, self::$first_object_id, self::$last_object_id)); commitReduceOPC(self::$objtype_id, self::$objtype_id); usePreparedDeleteBlade('Dictionary', array('dict_key' => self::$objtype_id)); // remove sample tags usePreparedExecuteBlade('DELETE FROM TagTree WHERE id BETWEEN ? AND ?', array(self::$first_tag_id, self::$last_tag_id)); }
function commitDeleteVSG($id) { releaseFiles('ipvs', $id); destroyTagsForEntity('ipvs', $id); usePreparedDeleteBlade('VS', array('id' => $id)); }
function tableHandler() { $opspec = getOpspec(); switch ($opspec['action']) { case 'INSERT': switch ($opspec['table']) { case 'Attribute': $realm = 'attr'; break; case 'Chapter': $realm = 'chapter'; break; case 'Dictionary': $realm = 'dict'; break; case 'TagTree': $realm = 'tag'; break; case 'VLANSwitchTemplate': $realm = 'vst'; break; default: $realm = NULL; } usePreparedInsertBlade($opspec['table'], buildOpspecColumns($opspec, 'arglist')); if (isset($realm)) { lastCreated($realm, lastInsertID()); } $retcode = 48; break; case 'DELETE': usePreparedDeleteBlade($opspec['table'], buildOpspecColumns($opspec, 'arglist'), array_fetch($opspec, 'conjunction', 'AND')); $retcode = 49; break; case 'UPDATE': usePreparedUpdateBlade($opspec['table'], buildOpspecColumns($opspec, 'set_arglist'), buildOpspecColumns($opspec, 'where_arglist'), array_fetch($opspec, 'conjunction', 'AND')); $retcode = 51; break; default: throw new InvalidArgException('opspec/action', $opspec['action']); } showOneLiner($retcode); }
function resetUserConfigVar($varname = '') { global $configCache; global $remote_username; if (!isset($configCache)) { throw new RackTablesError('configuration cache is unavailable', RackTablesError::INTERNAL); } if ($varname == '' or !array_key_exists($varname, $configCache)) { throw new InvalidArgException('$varname', $varname); } if ($configCache[$varname]['is_userdefined'] != 'yes') { throw new InvalidRequestArgException('$varname', $varname, 'a system-wide setting cannot be changed by user'); } if ($configCache[$varname]['is_hidden'] != 'no') { throw new InvalidRequestArgException('$varname', $varname, 'a hidden variable cannot be changed by user'); } // Update cache only if the changes went into DB. usePreparedDeleteBlade('UserConfig', array('varname' => $varname, 'user' => $remote_username)); }
function commitDeleteRSPool($pool_id = 0) { releaseFiles('ipv4rspool', $pool_id); destroyTagsForEntity('ipv4rspool', $pool_id); usePreparedDeleteBlade('IPv4RSPool', array('id' => $pool_id)); }
// UI handler: tableHandler() case 'delete_chapter_entry': require_once 'inc/init.php'; assertUIntArg('chapter_no', TRUE); assertStringArg('dict_value', TRUE); // make sure the chapter exists $chapters = getChapterList(); if (!isset($chapters[$_REQUEST['chapter_no']])) { throw new InvalidArgException('chapter_no', $_REQUEST['chapter_no'], "invalid argument: no such chapter"); } // make sure the entry exists in this chapter $words = readChapter($_REQUEST['chapter_no'], 'o'); if (!in_array($_REQUEST['dict_value'], $words)) { throw new InvalidArgException('dict_value', $_REQUEST['dict_value'], "invalid argument: no such value in chapter ID " . $_REQUEST['chapter_no']); } usePreparedDeleteBlade('Dictionary', array('chapter_id' => $_REQUEST['chapter_no'], 'dict_value' => $_REQUEST['dict_value'])); sendAPIResponse(array(), array('message' => 'dictionary entry deleted successfully', 'chapter_no' => $_REQUEST['chapter_no'], 'dict_value' => $_REQUEST['dict_value'])); break; // perform a generic search // UI equivalent: /index.php?page=search // UI handler: searchEntitiesByText() // perform a generic search // UI equivalent: /index.php?page=search // UI handler: searchEntitiesByText() case 'search': require_once 'inc/init.php'; assertStringArg('term', TRUE); sendAPIResponse(searchEntitiesByText($_REQUEST['term'])); break; // <<DESCRIPTION>> // UI equivalent: /index.php?page=
function commitUpdateAttrForNetwork($network, $attr_id, $value = '') { switch ($network['realm']) { case 'ipv4net': $av_table = 'AttributeValue_IPv4'; break; case 'ipv6net': $av_table = 'AttributeValue_IPv6'; break; default: throw new InvalidArgException('realm', $network['realm'], "Unknown realm"); } $key = array('net_id' => $network['id'], 'attr_id' => $attr_id); $result = usePreparedSelectBlade("SELECT type AS attr_type, av.* FROM Attribute a " . "LEFT JOIN {$av_table} av ON a.id = av.attr_id AND av.net_id = ?" . "WHERE a.id = ?", array($network['id'], $attr_id)); if (!($row = $result->fetch(PDO::FETCH_ASSOC))) { throw new InvalidArgException('$attr_id', $attr_id, 'No such attribute #' . $attr_id); } $attr_type = $row['attr_type']; unset($result); switch ($attr_type) { case 'uint': case 'float': case 'string': $column = $attr_type . '_value'; break; case 'dict': case 'date': $column = 'uint_value'; break; default: throw new InvalidArgException('$attr_type', $attr_type, 'Unknown attribute type found in ' . $network['realm'] . ' #' . $network['id'] . ', attribute #' . $attr_id); } $ret = 0; if (isset($row['attr_id'])) { // AttributeValue row present in table if ($value == '') { $ret = usePreparedDeleteBlade($av_table, $key); } else { $ret = usePreparedUpdateBlade($av_table, array($column => $value), $key); } } elseif ($value != '') { $ret = usePreparedInsertBlade($av_table, $key + array($column => $value)); } return $ret; }
function tableHandler() { $opspec = getOpspec(); switch ($opspec['action']) { case 'INSERT': usePreparedInsertBlade($opspec['table'], buildOpspecColumns($opspec, 'arglist')); $retcode = 48; break; case 'DELETE': $conjunction = array_key_exists('conjunction', $opspec) ? $opspec['conjunction'] : 'AND'; usePreparedDeleteBlade($opspec['table'], buildOpspecColumns($opspec, 'arglist'), $conjunction); $retcode = 49; break; case 'UPDATE': usePreparedUpdateBlade($opspec['table'], buildOpspecColumns($opspec, 'set_arglist'), buildOpspecColumns($opspec, 'where_arglist'), array_key_exists('conjunction', $opspec) ? $opspec['conjunction'] : 'AND'); $retcode = 51; break; default: throw new InvalidArgException('opspec/action', $opspec['action']); } showOneLiner($retcode); }
function linkmgmt_opunlinkPort() { $port_id = $_REQUEST['port_id']; $linktype = $_REQUEST['linktype']; portlist::var_dump_html($_REQUEST); /* check permissions */ if (!permitted(NULL, NULL, 'set_link')) { exit; } if ($linktype == 'back') { $table = 'LinkBackend'; $remote_id = $_REQUEST['remote_id']; $retval = usePreparedExecuteBlade("DELETE FROM {$table} WHERE ( porta = ? and portb = ?) or (portb = ? and porta = ?)", array($port_id, $remote_id, $port_id, $remote_id)); } else { $table = 'Link'; $retval = usePreparedDeleteBlade($table, array('porta' => $port_id, 'portb' => $port_id), 'OR'); } if ($retval == 0) { echo " Link not found"; } else { echo " {$retval} Links deleted"; } unset($_GET['module']); unset($_GET['op']); header('Location: ?' . http_build_query($_GET)); //header('Location: ?page='.$_REQUEST['page'].'&tab='.$_REQUEST['tab'].'&object_id='.$_REQUEST['object_id']); exit; }