public function Delete() { $ItemActions = ItemAction::GetAllByField("ItemAction", "ItemID", $this->GetValue("ID")); // Delete all actions related to this item foreach ($ItemActions as $ItemAction) { // Delete all of the user actions using this Item Action $UserActions = UserAction::GetAllByField("UserAction", "ItemAction", $ItemAction->GetValue("ID")); foreach ($UserActions as $UserAction) { $UserAction->Delete(); } // Delete the actual item action $ItemAction->Delete(); } // Delete the saved image (we warned them) $this->DeleteImage(); // Literally delete the item itself Database::Query("DELETE FROM `%s` WHERE `ID` = %s;", static::$TableName, $this->Data["ID"]); DB_Accessor::FlushMemCache(get_class($this)); }
<?php $ItemAction = ItemAction::GetByField("ItemAction", "ID", $_GET["editaction"]); $ItemActionData = $ItemAction->GetData(); $ActionArr = Action::GetAction($ItemAction->GetValue("ActionType")); $ItemObj = Item::GetByField("Item", "ID", $ItemAction->GetValue("ItemID")); if (isset($_POST["doEditAction"])) { $ActionData = ""; $ServerData = ""; foreach ($ActionArr["Arguments"] as $ArgObject) { $ActionData .= $_POST["input_" . $ArgObject->SysName] . ItemAction::$SerialKey; } foreach (Servers::GetCachedResults("Servers") as $ServerObj) { if (isset($_POST["action_server_" . $ServerObj->GetValue("ID")])) { $ServerData .= $ServerObj->GetValue("ID") . ";"; } } $ItemAction->ChangeValue("ActionData", $ActionData); $ItemAction->ChangeValue("Servers", $ServerData); KERNEL::HardNavigate("admin", "&area=items&edit=1&item=" . $ItemObj->GetValue("ID")); } elseif (isset($_GET["del"])) { $ItemAction->Delete(); KERNEL::HardNavigate("admin", "&area=items&edit=1&item=" . $ItemObj->GetValue("ID")); } ?> <h4>Edit Action</h4> <form method="POST" action="?page=admin&area=items&editaction=<?php echo $ItemAction->GetValue("ID"); ?>
<ul id="menu1" class="dropdown-menu" role="menu" aria-labelledby="drop4" style="font-size: 12px;"> <?php foreach (Action::$ActionList as $ActionObj) { echo ' <li role="presentation"> <a role="menuitem" href="?page=admin&area=items&addaction=' . $ActionObj["SysName"] . '&item=' . $ItemObj->GetValue("ID") . '">' . $ActionObj["Name"] . '</a> </li> '; } ?> </ul> </div> <div class="panel panel-default" style="width: 200px;float: left;padding: 3px;"> <?php $ItemActions = ItemAction::GetAllByField("ItemAction", "ItemID", $ItemObj->GetValue("ID")); if (count($ItemActions) == 0) { echo '<div style="text-align: center;padding: 4px;font-style: italic;font-size: 12px;">No Actions to Display!</div>'; } else { foreach ($ItemActions as $ItemAction) { $ActionObj = Action::GetAction($ItemAction->GetValue("ActionType")); echo '<a href="?page=admin&area=items&editaction=' . $ItemAction->GetValue("ID") . '"><div class="actionItem">' . $ActionObj["Name"] . '</div></a>'; } } ?> </div> </div> </div> <div class="row"> <div class="col-sm-6 col-md-4" style="text-align: right;">
function compare_action_alpha(ItemAction $a, ItemAction $b) { return strcasecmp($a->name(), $b->name()); }
<?php $ItemObj = Item::GetByField("Item", "ID", intval($_GET["item"])); $ActionArr = Action::GetAction($_GET["addaction"]); if (isset($_POST["doAddAction"])) { $ActionData = ""; $ServerData = ""; foreach ($ActionArr["Arguments"] as $ArgObject) { $ActionData .= $_POST["input_" . $ArgObject->SysName] . ItemAction::$SerialKey; } foreach (Servers::GetCachedResults("Servers") as $ServerObj) { if (isset($_POST["action_server_" . $ServerObj->GetValue("ID")])) { $ServerData .= $ServerObj->GetValue("ID") . ";"; } } ItemAction::AddItemAction($ItemObj->GetValue("ID"), $ActionArr["SysName"], $ActionData, $ServerData); KERNEL::HardNavigate("admin", "&area=items&edit=1&item=" . $ItemObj->GetValue("ID")); } ?> <h4>Add Action</h4> <form method="POST" action="?page=admin&area=items&addaction=<?php echo $ActionArr["SysName"]; ?> &item=<?php echo $ItemObj->GetValue("ID"); ?> "> <input type="hidden" name="doAddAction" value="yes" />