Example #1
0
 protected function _postCreateAction($path)
 {
     $xmlstr = $this->getRawPost();
     $xml_in = simplexml_load_string($xmlstr);
     @($in_guid = (string) $xml_in->guid);
     @($in_name = (string) $xml_in->name);
     if (empty($in_guid) || empty($in_name)) {
         $this->_error("All required fields were not provided.");
     }
     if (null != ($device = DAO_Device::getByGUID($in_guid))) {
         $this->_error("GUID already exists.");
     }
     $id = DAO_Device::create(array(DAO_Device::GUID => $in_guid, DAO_Device::NAME => $in_name, DAO_Device::LAST_UPDATED => time()));
     // Render the new device
     $this->_getAction(array($id));
 }
Example #2
0
 function saveDeviceAction()
 {
     @($id = DevblocksPlatform::importGPC($_REQUEST['id'], 'integer', ''));
     @($device_name = DevblocksPlatform::importGPC($_REQUEST['device_name'], 'string', ''));
     @($device_guid = DevblocksPlatform::importGPC($_REQUEST['device_guid'], 'string', ''));
     @($delete = DevblocksPlatform::importGPC($_REQUEST['do_delete'], 'integer', 0));
     $device_guid = str_replace(' ', '_', strtolower($device_guid));
     // Required args
     if (empty($device_name)) {
         $device_name = "(no device name)";
     }
     if (!empty($id)) {
         // update
         if ($delete) {
             DAO_Device::delete($id);
         } else {
             DAO_Device::update($id, array(DAO_Device::NAME => $device_name, DAO_Device::GUID => $device_guid));
         }
     } else {
         // insert
         $device_id = DAO_Device::create(array(DAO_Device::NAME => $device_name, DAO_Device::GUID => $device_guid, DAO_Device::LAST_UPDATED => time()));
     }
     DevblocksPlatform::redirect(new DevblocksHttpResponse(array('config', 'devices')));
 }