Пример #1
0
 public function Delete()
 {
     if (!$this->Exist()) {
         return false;
     }
     if ($this->initParent()) {
         $this->parent_obj->OnDeleteComment();
     }
     return parent::Delete();
 }
 public function Delete()
 {
     global $bd_names;
     if (!$this->Exist()) {
         return false;
     }
     $skin_way = $this->base_dir . $this->fname;
     $preview_way = $this->base_dir . 'preview/' . $this->fname;
     $result = BD("SELECT `hash` FROM `{$this->db}` WHERE `id`='" . $this->id . "'");
     if (mysql_num_rows($result)) {
         $line = mysql_fetch_array($result);
         BD("INSERT INTO {$this->db_bad_skins} (hash) VALUES ('" . $line['hash'] . "')");
     }
     if (file_exists($skin_way)) {
         unlink($skin_way);
     }
     if (file_exists($preview_way)) {
         unlink($preview_way);
     }
     BD("DELETE FROM `{$this->db_likes}` WHERE `item_id`='" . $this->id . "' AND `item_type`='" . ItemType::Skin . "'");
     BD("LOCK TABLES `{$this->db_ratio}` WRITE;");
     BD("UPDATE `{$this->db_ratio}` SET `num` = num - 1 WHERE `ratio`='" . $this->ratio . "'");
     BD("UNLOCK TABLES;");
     return parent::Delete();
 }
Пример #3
0
 public function Delete()
 {
     global $user, $bd_names;
     if (empty($user) or !$user->getPermission('add_news') or !$this->Exist()) {
         return false;
     }
     $result = getDB()->ask("SELECT `id` FROM `{$bd_names['comments']}` " . "WHERE `item_id`='" . $this->id . "' AND `item_type` = '" . $this->type() . "'");
     loadTool('comment.class.php');
     while ($line = $result->fetch('num')) {
         $comments_item = new Comments_Item($line[0], false);
         $comments_item->Delete();
         unset($comments_item);
     }
     getDB()->ask("DELETE FROM `{$bd_names['likes']}` " . "WHERE `item_id` = '" . $this->id . "' AND `item_type` = '" . $this->type() . "'");
     return parent::Delete();
 }
Пример #4
0
 public function testFindAllItems()
 {
     $items_before = Item::GetAll();
     $item = Item::CreateAsset('Test Item Name Additional', 120, 10, '', 120);
     $items_after = Item::GetAll();
     $this->assertTrue(count($items_after) == count($items_before) + 1);
     foreach ($items_after as $itm) {
         $this->assertInstanceOf('Item', $itm);
     }
     Item::Delete($item->id);
     $post_after = Item::GetAll();
     $this->assertTrue(count($post_after) == count($items_before));
 }
Пример #5
0
// id required
if ($id == "") {
    header("Location:mainpage.php");
    exit;
}
// if form was submitted
if ($_POST['commit'] == "Cancel") {
    $objItem = new Item($id);
    $category = new Category($objItem->CategoryId);
    header("Location:item_list.php?cat=" . $category->Id);
    exit;
}
if ($_POST['commit'] == "Delete Item") {
    $objItem = new Item($id);
    $category = new Category($objItem->CategoryId);
    $objItem->Delete($id);
    header("Location:item_list.php?cat=" . $category->Id);
    exit;
}
$objItem = new Item($id);
$category = new Category($objItem->CategoryId);
include "includes/pagetemplate.php";
function PageContent()
{
    global $objItem;
    global $category;
    global $id;
    ?>

            <div class="layout laymidwidth">
Пример #6
0
 public function deleteItem($id)
 {
     if (Item::Delete($id)) {
         echo 1;
     } else {
         echo 0;
     }
 }