当前位置: 首页>>代码示例>>PHP>>正文


PHP Software::delete方法代码示例

本文整理汇总了PHP中Software::delete方法的典型用法代码示例。如果您正苦于以下问题:PHP Software::delete方法的具体用法?PHP Software::delete怎么用?PHP Software::delete使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Software的用法示例。


在下文中一共展示了Software::delete方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: Software

if (!isset($_GET["order"])) {
    $_GET["order"] = "";
}
if (!isset($_GET["withtemplate"])) {
    $_GET["withtemplate"] = "";
}
$soft = new Software();
if (isset($_POST["add"])) {
    $soft->check(-1, 'w', $_POST);
    $newID = $soft->add($_POST);
    Event::log($newID, "software", 4, "inventory", $_SESSION["glpiname"] . " " . $LANG['log'][20] . " " . $_POST["name"] . ".");
    glpi_header($_SERVER['HTTP_REFERER']);
} else {
    if (isset($_POST["delete"])) {
        $soft->check($_POST["id"], 'd');
        $soft->delete($_POST);
        Event::log($_POST["id"], "software", 4, "inventory", $_SESSION["glpiname"] . " " . $LANG['log'][22]);
        $soft->redirectToList();
    } else {
        if (isset($_POST["restore"])) {
            $soft->check($_POST["id"], 'd');
            $soft->restore($_POST);
            Event::log($_POST["id"], "software", 4, "inventory", $_SESSION["glpiname"] . " " . $LANG['log'][23]);
            $soft->redirectToList();
        } else {
            if (isset($_REQUEST["purge"])) {
                $soft->check($_REQUEST["id"], 'd');
                $soft->delete($_REQUEST, 1);
                Event::log($_REQUEST["id"], "software", 4, "inventory", $_SESSION["glpiname"] . " " . $LANG['log'][24]);
                $soft->redirectToList();
            } else {
开发者ID:ryukansent,项目名称:Thesis-SideB,代码行数:31,代码来源:software.form.php

示例2: cleanSoftwares

 function cleanSoftwares()
 {
     if (!isset($this->already_transfer['Software'])) {
         return;
     }
     $soft = new Software();
     foreach ($this->already_transfer['Software'] as $old => $new) {
         if (countElementsInTable("glpi_softwarelicenses", "softwares_id={$old}") == 0 && countElementsInTable("glpi_softwareversions", "softwares_id={$old}") == 0) {
             if ($this->options['clean_software'] == 1) {
                 // delete
                 $soft->delete(array('id' => $old), 0);
             } else {
                 if ($this->options['clean_software'] == 2) {
                     // purge
                     $soft->delete(array('id' => $old), 1);
                 }
             }
         }
     }
 }
开发者ID:ryukansent,项目名称:Thesis-SideB,代码行数:20,代码来源:transfer.class.php

示例3: Software

    $_GET["withtemplate"] = "";
}
$soft = new Software();
if (isset($_POST["add"])) {
    $soft->check(-1, CREATE, $_POST);
    if ($newID = $soft->add($_POST)) {
        Event::log($newID, "software", 4, "inventory", sprintf(__('%1$s adds the item %2$s'), $_SESSION["glpiname"], $_POST["name"]));
        if ($_SESSION['glpibackcreated']) {
            Html::redirect($soft->getFormURL() . "?id=" . $newID);
        }
    }
    Html::back();
} else {
    if (isset($_POST["delete"])) {
        $soft->check($_POST["id"], DELETE);
        $soft->delete($_POST);
        Event::log($_POST["id"], "software", 4, "inventory", sprintf(__('%s deletes an item'), $_SESSION["glpiname"]));
        $soft->redirectToList();
    } else {
        if (isset($_POST["restore"])) {
            $soft->check($_POST["id"], DELETE);
            $soft->restore($_POST);
            Event::log($_POST["id"], "software", 4, "inventory", sprintf(__('%s restores an item'), $_SESSION["glpiname"]));
            $soft->redirectToList();
        } else {
            if (isset($_POST["purge"])) {
                $soft->check($_POST["id"], PURGE);
                $soft->delete($_POST, 1);
                Event::log($_POST["id"], "software", 4, "inventory", sprintf(__('%s purges an item'), $_SESSION["glpiname"]));
                $soft->redirectToList();
            } else {
开发者ID:glpi-project,项目名称:glpi,代码行数:31,代码来源:software.form.php

示例4: resetSoftwares

 /**
  * Delete all old softwares of a computer.
  *
  * @param $glpi_computers_id integer : glpi computer id.
  *
  * @return nothing.
  **/
 static function resetSoftwares($glpi_computers_id)
 {
     global $DB;
     $query = "SELECT*\n                FROM `glpi_computers_softwareversions`\n                WHERE `computers_id` = '{$glpi_computers_id}'";
     $result = $DB->query($query);
     if ($DB->numrows($result) > 0) {
         while ($data = $DB->fetch_assoc($result)) {
             $query2 = "SELECT COUNT(*)\n                       FROM `glpi_computers_softwareversions`\n                       WHERE `softwareversions_id` = '" . $data['softwareversions_id'] . "'";
             $result2 = $DB->query($query2);
             if ($DB->result($result2, 0, 0) == 1) {
                 $vers = new SoftwareVersion();
                 $vers->getFromDB($data['softwareversions_id']);
                 $query3 = "SELECT COUNT(*)\n                          FROM `glpi_softwareversions`\n                          WHERE `softwares_id`='" . $vers->fields['softwares_id'] . "'";
                 $result3 = $DB->query($query3);
                 if ($DB->result($result3, 0, 0) == 1) {
                     $soft = new Software();
                     $soft->delete(array('id' => $vers->fields['softwares_id']), 1);
                 }
                 $vers->delete(array("id" => $data['softwareversions_id']));
             }
         }
         $query = "DELETE\n                   FROM `glpi_computers_softwareversions`\n                   WHERE `computers_id` = '{$glpi_computers_id}'";
         $DB->query($query);
     }
 }
开发者ID:geldarr,项目名称:hack-space,代码行数:32,代码来源:ocsserver.class.php

示例5: testSoftwareCategory

 /**
  * Test software category Rule and putInTrash / removeFromTrash
  */
 public function testSoftwareCategory()
 {
     global $CFG_GLPI;
     $ent0 = $this->sharedFixture['entity'][0];
     // Clean preload rules
     $tmp = SingletonRuleList::getInstance('RuleSoftwareCategory');
     $tmp->load = 0;
     $this->assertArrayHasKey('softwarecategories_id_ondelete', $CFG_GLPI, "Fail: no softwarecategories_id_ondelete");
     $idcat[0] = Dropdown::import('SoftwareCategory', array('name' => 'Trashed'));
     $this->assertGreaterThan(0, $idcat[0], "Fail: can't create SoftwareCategory");
     $idcat[1] = Dropdown::import('SoftwareCategory', array('name' => 'OpenSource'));
     $this->assertGreaterThan(0, $idcat[1], "Fail: can't create SoftwareCategory");
     $rule = new RuleSoftwareCategory();
     $crit = new RuleCriteria();
     $acte = new RuleAction();
     $idr[0] = $rule->add(array('name' => 'OSS', 'sub_type' => 'RuleSoftwareCategory', 'match' => 'AND', 'is_active' => 1));
     $this->assertGreaterThan(0, $idr[0], "Fail: can't create rule 1");
     $this->assertTrue($rule->getFromDB($idr[0]));
     $this->assertEquals(1, $rule->fields['ranking'], "Fail: ranking not set");
     $idc[0] = $crit->add(array('rules_id' => $idr[0], 'criteria' => 'manufacturer', 'condition' => Rule::PATTERN_IS, 'pattern' => 'Indepnet'));
     $this->assertGreaterThan(0, $idc[0], "Fail: can't create rule 1 criteria");
     $ida[0] = $acte->add(array('rules_id' => $idr[0], 'action_type' => 'assign', 'field' => 'softwarecategories_id', 'value' => $idcat[1]));
     $this->assertGreaterThan(0, $ida[0], "Fail: can't create rule 1 action");
     // Createthe software
     $soft = new Software();
     $id[0] = $soft->addOrRestoreFromTrash('GLPI', 'Indepnet', $ent0);
     $this->assertGreaterThan(0, $id[0], "Fail: can't create software 1");
     // Check name
     $this->assertTrue($soft->getFromDB($id[0]), "Fail: can't read new soft");
     $this->assertEquals('GLPI', $soft->getField('name'), "Fail: name not set");
     // Check category
     $catid = $soft->getField('softwarecategories_id');
     $this->assertEquals($idcat[1], $catid, "Fail: category not set");
     // Change configuration
     $CFG_GLPI["softwarecategories_id_ondelete"] = $idcat[0];
     // Delete
     $this->assertTrue($soft->putInTrash($id[0]), "Fail: can't put soft in trash");
     $this->assertTrue($soft->getFromDB($id[0]), "Fail: can't read new soft");
     $catid = $soft->getField('softwarecategories_id');
     $this->assertEquals($idcat[0], $catid, "Fail: category not set");
     $this->assertEquals(1, $soft->getField('is_deleted'), "Fail: soft not deleted");
     // Restore
     $this->assertTrue($soft->removeFromTrash($id[0]), "Fail: can't put soft in trash");
     $this->assertTrue($soft->getFromDB($id[0]), "Fail: can't read new soft");
     $catid = $soft->getField('softwarecategories_id');
     $this->assertEquals($idcat[1], $catid, "Fail: category not set");
     $this->assertEquals(0, $soft->getField('is_deleted'), "Fail: soft not restored");
     // Clean
     $this->assertTrue($soft->delete(array('id' => $id[0]), true), "Fail: can't delete software 1)");
 }
开发者ID:btry,项目名称:glpi,代码行数:53,代码来源:Import.php

示例6: software_delete

 /**
  *	@fn software_delete
  *	@short Action method to delete a software product.
  *	@warning This method has potentially destructive consquences.
  *	Do not use it without a really good reason.
  */
 public function software_delete()
 {
     if (isset($_GET['id'])) {
         $this->software = new Software();
         $this->software->find_by_id($_GET['id']);
     } else {
         if (isset($_POST['id'])) {
             $software = new Software();
             $software->find_by_id($_POST['id']);
             $software->delete();
             // Expires the cache of Software & Sparkle feeds
             $this->expire_cached_software_pages();
         }
         $this->redirect_to(array('action' => 'software_list'));
     }
 }
开发者ID:emeraldion,项目名称:zelda,代码行数:22,代码来源:backend_controller.php

示例7: updateOfficePack

 /**
  *
  * Update config of a new software office
  *
  * This function create a officepack in GLPI with some general data.
  *
  * @param type $computers_id
  * @param $entity
  * @param type $ocsComputer
  * @param type $cfg_ocs
  *
  * @internal param \type $ocsservers_id
  */
 static function updateOfficePack($computers_id, $entity, $ocsComputer, $cfg_ocs)
 {
     global $DB;
     $software = new Software();
     $ocsOfficePacks = $ocsComputer;
     // Read imported software in last sync
     $query = "SELECT `glpi_computers_softwarelicenses`.`id` as id,\n                          `glpi_softwares`.`name` as sname,\n                          `glpi_softwarelicenses`.`name` as lname,\n                          `glpi_softwareversions`.`name` as vname\n                   FROM `glpi_computers_softwarelicenses`\n                   INNER JOIN `glpi_softwarelicenses`\n                           ON `glpi_softwarelicenses`.`id`= `glpi_computers_softwarelicenses`.`softwarelicenses_id`\n                   INNER JOIN `glpi_softwares`\n                           ON `glpi_softwares`.`id`= `glpi_softwarelicenses`.`softwares_id`\n                   INNER JOIN `glpi_softwareversions`\n                           ON `glpi_softwarelicenses`.`softwareversions_id_use` = `glpi_softwareversions`.`id`\n                   WHERE `glpi_computers_softwarelicenses`.`computers_id`='{$computers_id}'\n                         AND `is_dynamic`";
     $imported = array();
     foreach ($DB->request($query) as $data) {
         $imported[$data['id']] = strtolower($data['vname']);
     }
     if (count($ocsOfficePacks) > 0) {
         foreach ($ocsOfficePacks as $ocsOfficePack) {
             $ocsOfficePack = Toolbox::clean_cross_side_scripting_deep(Toolbox::addslashes_deep($ocsOfficePack));
             $query1 = "SELECT `glpi_softwares`.`id` AS softwares_id,\n                              `glpi_softwareversions`.`id` AS softwareversions_id,\n                              `glpi_softwareversions`.`name` AS softwareversions_name\n                     FROM `glpi_softwares`\n                     LEFT JOIN `glpi_softwareversions` ON `glpi_softwareversions`.`softwares_id` = `glpi_softwares`.`id`\n                     LEFT JOIN `glpi_computers_softwareversions` ON `glpi_computers_softwareversions`.softwareversions_id = `glpi_softwareversions`.`id`\n                     WHERE `glpi_computers_softwareversions`.`computers_id` = '" . $computers_id . "'\n                      AND `is_dynamic` \n                      AND `glpi_softwares`.`name` = '" . $ocsOfficePack['PRODUCT'] . "'\n                      AND `glpi_softwareversions`.`name` = '" . $ocsOfficePack['OFFICEVERSION'] . "'";
             $result = $DB->query($query1);
             if ($DB->numrows($result) > 0) {
                 $softwares_id = $DB->result($result, 0, 'softwares_id');
                 $softwareversions_id = $DB->result($result, 0, 'softwareversions_id');
                 $soft_l['softwares_id'] = $softwares_id;
                 $soft_l['softwareversions_id_use'] = $softwareversions_id;
                 $soft_l['entities_id'] = $entity;
                 $soft_l['name'] = $ocsOfficePack['OFFICEKEY'];
                 $soft_l['serial'] = $ocsOfficePack['OFFICEKEY'];
                 $soft_l['comment'] = $ocsOfficePack['NOTE'];
                 $id = array_search(strtolower(stripslashes($ocsOfficePack['OFFICEVERSION'])), $imported);
                 $software_licenses = new SoftwareLicense();
                 $computer_softwarelicenses = new Computer_SoftwareLicense();
                 if ($id) {
                     //-------------------------------------------------------------------------//
                     //---- The software exists in this license for this computer --------------//
                     //---------------------------- Update comments ----------------------------//
                     //---------------------------------------------------- --------------------//
                     if ($software_licenses->getFromDBByQuery("WHERE `softwares_id` = " . $softwares_id . " \n                                                         AND `serial` = '" . $ocsOfficePack['OFFICEKEY'] . "'\n                                                         AND `softwareversions_id_use` = " . $softwareversions_id)) {
                         $software_licenses->update(array('id' => $software_licenses->getID(), 'comment' => $ocsOfficePack['NOTE']));
                         if (!$computer_softwarelicenses->getFromDBByQuery("WHERE `computers_id` = " . $computers_id . "\n                           AND `softwarelicenses_id` = " . $software_licenses->getID())) {
                             $computer_soft_l['computers_id'] = $computers_id;
                             $computer_soft_l['softwarelicenses_id'] = $software_licenses->getID();
                             $computer_soft_l['is_dynamic'] = -1;
                             $computer_softwarelicenses->add($computer_soft_l);
                         }
                     }
                     unset($imported[$id]);
                 } else {
                     //------------------------------------------------------------------------//
                     //---- The software doesn't exists in this license for this computer -----//
                     //------------------------------------------------------------------------//
                     if ($software_licenses->getFromDBByQuery("WHERE `softwares_id` = " . $softwares_id . " \n                                                         AND `serial` = '" . $ocsOfficePack['OFFICEKEY'] . "'\n                                                         AND `softwareversions_id_use` = " . $softwareversions_id)) {
                         $id_software_licenses = $software_licenses->getID();
                     } else {
                         $software_licenses->fields['softwares_id'] = $softwares_id;
                         $id_software_licenses = $software_licenses->add($soft_l, array(), $cfg_ocs['history_software']);
                     }
                     if ($id_software_licenses) {
                         $computer_soft_l['computers_id'] = $computers_id;
                         $computer_soft_l['softwarelicenses_id'] = $id_software_licenses;
                         $computer_soft_l['is_dynamic'] = 1;
                         $computer_soft_l['number'] = -1;
                         $computer_softwarelicenses->add($computer_soft_l);
                     }
                 }
             }
         }
     }
     foreach ($imported as $id => $unused) {
         $computer_softwarelicenses->delete(array('id' => $id), true, $cfg_ocs['history_software']);
         // delete cause a getFromDB, so fields contains values
         $verid = $computer_softwarelicenses->getField('softwareversions_id');
         if (countElementsInTable('glpi_computers_softwarelicenses', "softwarelicenses_id = '{$verid}'") == 0) {
             $vers = new SoftwareVersion();
             if ($vers->getFromDB($verid) && countElementsInTable('glpi_softwarelicenses', "softwares_id = '" . $vers->fields['softwares_id'] . "'") == 0) {
                 $soft = new Software();
                 $soft->delete(array('id' => $vers->fields['softwares_id']), 1);
             }
             $vers->delete(array("id" => $verid));
         }
     }
 }
开发者ID:pluginsGLPI,项目名称:ocsinventoryng,代码行数:91,代码来源:ocsserver.class.php


注:本文中的Software::delete方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。