Example #1
0
 function UpdateTemplate()
 {
     $this->MakeSafe();
     $sql = "UPDATE fac_DeviceTemplate SET ManufacturerID={$this->ManufacturerID},\n\t\t\tModel=\"{$this->Model}\", Height={$this->Height}, Weight={$this->Weight}, \n\t\t\tWattage={$this->Wattage}, DeviceType=\"{$this->DeviceType}\", \n\t\t\tPSCount={$this->PSCount}, NumPorts={$this->NumPorts}, Notes=\"{$this->Notes}\", \n\t\t\tFrontPictureFile=\"{$this->FrontPictureFile}\", RearPictureFile=\"{$this->RearPictureFile}\",\n\t\t\tChassisSlots={$this->ChassisSlots}, RearChassisSlots={$this->RearChassisSlots}, SNMPVersion=\"{$this->SNMPVersion}\",\n\t\t\tGlobalID={$this->GlobalID}, ShareToRepo={$this->ShareToRepo}, KeepLocal={$this->KeepLocal}\n\t\t\tWHERE TemplateID={$this->TemplateID};";
     $old = new DeviceTemplate();
     $old->TemplateID = $this->TemplateID;
     $old->GetTemplateByID();
     if ($old->DeviceType == "CDU" && $this->DeviceType != $old->DeviceType) {
         // Template changed from CDU to something else, clean up the mess
         $cdut = new CDUTemplate();
         $cdut->TemplateID = $this->TemplateID;
         $cdut->DeleteTemplate();
     } elseif ($this->DeviceType == "CDU" && $this->DeviceType != $old->DeviceType) {
         // Template changed to CDU from something else, make the extra stuff
         $cdut = new CDUTemplate();
         $cdut->Model = $this->Model;
         $cdut->ManufacturerID = $this->ManufacturerID;
         $cdut->CreateTemplate($this->TemplateID);
     }
     if ($old->DeviceType == "Sensor" && $this->DeviceType != $old->DeviceType) {
         // Template changed from Sensor to something else, clean up the mess
         $st = new SensorTemplate();
         $st->TemplateID = $this->TemplateID;
         $st->DeleteTemplate();
     } elseif ($this->DeviceType == "Sensor" && $this->DeviceType != $old->DeviceType) {
         // Template changed to Sensor from something else, make the extra stuff
         $st = new SensorTemplate();
         $st->Model = $this->Model;
         $st->ManufacturerID = $this->ManufacturerID;
         $st->CreateTemplate($this->TemplateID);
     }
     if (!$this->query($sql)) {
         return false;
     } else {
         class_exists('LogActions') ? LogActions::LogThis($this, $old) : '';
         $this->MakeDisplay();
         return true;
     }
 }