コード例 #1
0
ファイル: Item.php プロジェクト: Zipcore/GMDonate
            $this->ChangeValue("Image", $ImageURLName);
        }
    }
    public function DeleteImage()
    {
        if (!empty($this->Data["Image"]) && $this->Data["Image"] != "item_default.png") {
            @unlink("includes/images/uploaded/" . $this->Data["Image"]);
        }
    }
    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));
    }
}
ItemCategory::PrecacheAll("Item");