Example #1
0
 /**
  * Restore a software from dustbin
  *
  * @param $ID  the ID of the software to put in dustbin
  *
  * @return boolean (success)
  **/
 function removeFromTrash($ID)
 {
     $res = $this->restore(array("id" => $ID));
     $softcatrule = new RuleSoftwareCategoryCollection();
     $result = $softcatrule->processAllRules(null, null, $this->fields);
     if (!empty($result) && isset($result['softwarecategories_id']) && $result['softwarecategories_id'] != $this->fields['softwarecategories_id']) {
         $this->update(array('id' => $ID, 'softwarecategories_id' => $result['softwarecategories_id']));
     }
     return $res;
 }
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with GLPI; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
--------------------------------------------------------------------------
*/
// ----------------------------------------------------------------------
// Original Author of file: Julien Dombre
// Purpose of file:
// ----------------------------------------------------------------------
define('GLPI_ROOT', '..');
include GLPI_ROOT . "/inc/includes.php";
// COMPUTER ONLY UNDEF CATEGORIES
$ONLY_UNDEFINED = true;
$softcatrule = new RuleSoftwareCategoryCollection();
$soft = new Software();
$query = "SELECT `id`, `softwarecategories_id`\n          FROM `glpi_softwares`";
if ($result = $DB->query($query)) {
    if ($DB->numrows($result) > 0) {
        while ($data = $DB->fetch_array($result)) {
            if (!$ONLY_UNDEFINED || $data['softwarecategories_id'] == 0) {
                $params = array();
                //Get software name and manufacturer
                $soft->getFromDB($data['id']);
                $params["name"] = $soft->fields["name"];
                $params["manufacturers_id"] = $soft->fields["manufacturers_id"];
                //Process rules
                $soft->update($softcatrule->processAllRules(null, $soft->fields, $params));
            }
        }