示例#1
0
 public function mod($data)
 {
     freemed::acl_enforce('emr', 'modify');
     if (!is_array($data) and !is_object($data)) {
         syslog(LOG_INFO, get_class($this) . "| no data presented");
         return false;
     }
     $ourdata = (array) $data;
     if (!$ourdata['id']) {
         syslog(LOG_INFO, get_class($this) . "| no id presented");
         return false;
     }
     // Check for modification locking
     if (!freemed::lock_override()) {
         if ($this->locked($ourdata['id'])) {
             return false;
         }
     }
     // Handle row-level locking mechanism
     $lock = CreateObject('org.freemedsoftware.core.RecordLock', $this->table_name);
     if ($lock->IsLocked($ourdata['id'])) {
         return false;
     } else {
         $lock->LockRow($ourdata['id']);
     }
     $ourdata = $this->prepare($ourdata);
     $this->mod_pre($ourdata);
     $GLOBALS['sql']->load_data($ourdata);
     $result = $GLOBALS['sql']->query($GLOBALS['sql']->update_query($this->table_name, $this->variables, array("id" => $data['id']), $this->date_variables));
     $this->mod_post($ourdata);
     $this->moduleFieldCheck(get_class($this), $data['id'], $data);
     // Unlock row, since update is done
     $lock->UnlockRow($data['id']);
     return $result ? true : false;
 }
示例#2
0
 function del($_id = NULL)
 {
     $id = $_id ? $_id : $_REQUEST['id'];
     if (!freemed::lock_override()) {
         if ($this->locked($id)) {
             $GLOBALS['display_buffer'] .= __("Record is locked.");
             return false;
         }
     }
     // Delete all attached pieces
     $q = "DELETE FROM form_record WHERE fr_id = '" . addslashes($id) . "'";
     $GLOBALS['sql']->query($q);
     // Stock deletion routine
     $this->_del();
 }