Esempio n. 1
0
 public function filterLogs($id, $transaction)
 {
     if (Session::has('username') && (Session::get('user_type') == "Root" || Session::get('user_type') == "Admin" || Session::get("user_type") == "User")) {
         if (Session::get("user_type") == "User") {
             return Redirect::to("assets/software/logs/" . $id);
         }
         $view = View::make("Assets.Software.software_logs");
         $view->nav = "assets";
         $software = Software::find($id);
         if (!$software) {
             return Redirect::to("assets/software");
         }
         $view->software = $software;
         if (!in_array($transaction, array("history", "updates"))) {
             return Redirect::to("assets/software/logs/" . $id);
         }
         $view->transaction = $transaction;
         $view->logs = SoftwareLog::where("software_id", "=", $id)->where("transaction", "=", $transaction)->orderBy("datetime", "desc")->paginate(25);
         $view->logCount = SoftwareLog::where("software_id", "=", $id)->where("transaction", "=", $transaction)->count();
         return $view;
     } else {
         return Redirect::to("/");
     }
 }
 public function deleteAssets()
 {
     if (Session::has('username') && Session::get('user_type') == "Root") {
         $software = Input::get("software_id");
         $hasDeletedAny = false;
         $noOfDeletedAssets = 0;
         foreach ($software as $s) {
             $soft = Software::find($s);
             if (!$soft) {
                 continue;
             }
             $desc = "(" . Session::get('user_type') . ") " . "<strong>" . Session::get('username') . "</strong> has deleted software asset ( type: " . $soft->type->software_type . ") <strong>" . $soft->asset_tag . "</strong>.";
             //Log the changes made
             $newLog = new UserLog();
             $newLog->description = $desc;
             $newLog->user_id = Session::get('user_id');
             $newLog->type = "System";
             $newLog->save();
             $hasDeletedAny = true;
             $noOfDeletedAssets += 1;
             $soft->delete();
         }
         if ($hasDeletedAny) {
             $desc = "(" . Session::get('user_type') . ") " . "<strong>" . Session::get('username') . "</strong> has deleted <strong>" . $noOfDeletedAssets . "</strong> software asset(s).";
             //Log the changes made
             $newLog = new UserLog();
             $newLog->description = $desc;
             $newLog->user_id = Session::get('user_id');
             $newLog->type = "System";
             $newLog->save();
         }
         return Redirect::to(Session::get("page"));
     } else {
         return Redirect::to("/");
     }
 }
 /**
  * @test
  */
 public function SoftwareUniqueForTwoComputers()
 {
     global $DB;
     $DB->connect();
     $date = date('Y-m-d H:i:s');
     $_SESSION["plugin_fusioninventory_entity"] = 0;
     $_SESSION['glpiactiveentities_string'] = 0;
     $_SESSION['glpishowallentities'] = 1;
     $_SESSION["glpiname"] = 'Plugin_FusionInventory';
     $a_inventory = array('fusioninventorycomputer' => array('winowner' => 'test', 'wincompany' => 'siprossii', 'operatingsystem_installationdate' => '2012-10-16 08:12:56', 'last_fusioninventory_update' => $date), 'soundcard' => array(), 'graphiccard' => array(), 'controller' => array(), 'processor' => array(), 'computerdisk' => array(), 'memory' => array(), 'monitor' => array(), 'printer' => array(), 'peripheral' => array(), 'networkport' => array(), 'SOFTWARES' => array(), 'harddrive' => array(), 'virtualmachine' => array(), 'antivirus' => array(), 'storage' => array(), 'licenseinfo' => array(), 'networkcard' => array(), 'drive' => array(), 'batteries' => array(), 'itemtype' => 'Computer');
     $a_inventory['Computer'] = array('name' => 'pcJ1', 'comment' => 'amd64/-1-11-30 22:04:44', 'users_id' => 0, 'operatingsystems_id' => 'freebsd', 'operatingsystemversions_id' => '9.1-RELEASE', 'uuid' => '68405E00-E5BE-11DF-801C-B05981201220', 'domains_id' => 'mydomain.local', 'os_licenseid' => '', 'os_license_number' => '', 'operatingsystemservicepacks_id' => 'GENERIC ()root@farrell.cse.buffalo.edu', 'manufacturers_id' => '', 'computermodels_id' => '', 'serial' => 'XB63J7J1', 'computertypes_id' => 'Notebook', 'is_dynamic' => 1, 'contact' => 'ddurieux');
     $a_inventory['software'] = array('acrobat_reader_9.2$$$$1.0.0.0$$$$192$$$$0' => array('name' => 'acrobat_Reader_9.2', 'version' => '1.0.0.0', 'manufacturers_id' => 192, 'entities_id' => 0, 'is_template_computer' => 0, 'is_deleted_computer' => 0));
     $pfiComputerLib = new PluginFusioninventoryInventoryComputerLib();
     $computer = new Computer();
     $pfFormatconvert = new PluginFusioninventoryFormatconvert();
     $software = new Software();
     $a_inventory = $pfFormatconvert->replaceids($a_inventory);
     $serialized = gzcompress(serialize($a_inventory));
     $a_inventory['fusioninventorycomputer']['serialized_inventory'] = Toolbox::addslashes_deep($serialized);
     $this->items_id = $computer->add(array('serial' => 'XB63J7J1', 'entities_id' => 0));
     $_SESSION['glpiactive_entity'] = 0;
     $pfiComputerLib->updateComputer($a_inventory, $this->items_id, FALSE);
     $a_software = $software->find("`name`='acrobat_Reader_9.2'");
     $this->assertEquals(1, count($a_software), "First computer added");
     $a_inventory['Computer']['name'] = "pcJ2";
     $a_inventory['Computer']['serial'] = "XB63J7J2";
     $pfiComputerLib->updateComputer($a_inventory, $this->items_id, FALSE);
     $a_software = $software->find("`name`='acrobat_Reader_9.2'");
     $this->assertEquals(1, count($a_software), "Second computer added");
 }
Esempio n. 4
0
 /**
  * Gets a single installed software from this server
  *
  * @param integer $id
  * @param array $scopes optional
  *
  * @return Software
  */
 public function software($id, $scopes = [])
 {
     if (!$this->id) {
         throw new Exception("The server has no ID, can\\'t get software");
     }
     $software = new Software($this->patrol);
     $software->defaults(['server_id' => $this->id]);
     return $software->find($id, $scopes);
 }