diff --git a/infolog/inc/class.boinfolog.inc.php b/infolog/inc/class.boinfolog.inc.php index 518ea9bc35..984a8a99e4 100644 --- a/infolog/inc/class.boinfolog.inc.php +++ b/infolog/inc/class.boinfolog.inc.php @@ -438,10 +438,10 @@ class boinfolog { if (is_array($info_id)) { - $info_id = (int) (isset($info_id['info_id']) ? $info_id['info_id'] : $info_id[0]); + $info_id = isset($info_id['info_id']) ? $info_id['info_id'] : $info_id[0]; } - if ($this->so->read($info_id) === False) + if (($data = $this->so->read($info_id)) === False) { if ($this->xmlrpc) { @@ -449,7 +449,9 @@ class boinfolog } return null; } - if (!$this->check_access($info_id,EGW_ACL_READ)) // check behind read, to prevent a double read + $info_id = $data['info_id']; // in case the uid was specified + + if (!$this->check_access($data,EGW_ACL_READ)) // check behind read, to prevent a double read { if ($this->xmlrpc) { @@ -457,7 +459,6 @@ class boinfolog } return False; } - $data = $this->so->data; if ($data['info_subject'] == $this->subject_from_des($data['info_des'])) { diff --git a/infolog/inc/class.soinfolog.inc.php b/infolog/inc/class.soinfolog.inc.php index 5869d5c518..2533271ccc 100644 --- a/infolog/inc/class.soinfolog.inc.php +++ b/infolog/inc/class.soinfolog.inc.php @@ -353,18 +353,17 @@ class soinfolog // DB-Layer * * some cacheing is done to prevent multiple reads of the same entry * - * @param $info_id id of log-entry + * @param $info_id id or uid of entry * @return array/boolean the entry as array or False on error (eg. entry not found) */ function read($info_id) // did _not_ ensure ACL { - $info_id = (int) $info_id; - - if ($info_id && $info_id == $this->data['info_id']) + if ($info_id && ((int)$info_id == $this->data['info_id'] || $info_id == $this->data['info_uid'])) { return $this->data; // return the already read entry } - if ($info_id <= 0 || !$this->db->select($this->info_table,'*',array('info_id'=>$info_id),__LINE__,__FILE__) || + if (!$info_id || !$this->db->select($this->info_table,'*', + $this->db->expression($this->info_table,array('info_id'=>$info_id),' OR ',array('info_uid'=>$info_id)),__LINE__,__FILE__) || !(($this->data = $this->db->row(true)))) { $this->init( ); @@ -374,7 +373,7 @@ class soinfolog // DB-Layer { $this->data['info_responsible'] = $this->data['info_responsible'] ? explode(',',$this->data['info_responsible']) : array(); } - $this->db->select($this->extra_table,'info_extra_name,info_extra_value',array('info_id'=>$info_id),__LINE__,__FILE__); + $this->db->select($this->extra_table,'info_extra_name,info_extra_value',array('info_id'=>$this->data['info_id']),__LINE__,__FILE__); while ($this->db->next_record()) { $this->data['#'.$this->db->f(0)] = $this->db->f(1); @@ -527,9 +526,14 @@ class soinfolog // DB-Layer if ($check_modified) $where['info_datemodified'] = $check_modified; if (!$this->db->update($this->info_table,$to_write,$where,__LINE__,__FILE__)) { + //error_log("### soinfolog::write(".print_r($to_write,true).") where=".print_r($where,true)." returning false"); return false; // Error } - if ($this->db->affected_rows() < 1) return 0; // someone else updated the modtime or deleted the entry + if ($check_modified && $this->db->affected_rows() < 1) + { + //error_log("### soinfolog::write(".print_r($to_write,true).") where=".print_r($where,true)." returning 0 (nothing updated, eg. condition not met)"); + return 0; // someone else updated the modtime or deleted the entry + } } else { @@ -537,6 +541,12 @@ class soinfolog // DB-Layer $this->db->insert($this->info_table,$to_write,false,__LINE__,__FILE__); $info_id = $this->data['info_id'] = $this->db->get_last_insert_id($this->info_table,'info_id'); + + if (!$this->data['info_uid']) // new entry without uid --> create one based on our info_id and save it + { + $this->data['info_uid'] = $GLOBALS['egw']->common->generate_uid('infolog',$info_id); + $this->db->update($this->info_table,array('info_uid'=>$this->data['info_uid']),array('info_id'=>$info_id),__LINE__,__FILE__); + } } //echo "
soinfolog.write values= "; _debug_array($values); @@ -557,6 +567,7 @@ class soinfolog // DB-Layer ),__LINE__,__FILE__); } // echo "
soinfolog.write this->data= "; _debug_array($this->data); + //error_log("### soinfolog::write(".print_r($to_write,true).") where=".print_r($where,true)." returning id=".$this->data['info_id']); return $this->data['info_id']; } diff --git a/infolog/setup/setup.inc.php b/infolog/setup/setup.inc.php index 42f0eeb6c4..b60bce382a 100755 --- a/infolog/setup/setup.inc.php +++ b/infolog/setup/setup.inc.php @@ -12,7 +12,7 @@ */ $setup_info['infolog']['name'] = 'infolog'; -$setup_info['infolog']['version'] = '1.4'; +$setup_info['infolog']['version'] = '1.5.001'; $setup_info['infolog']['app_order'] = 5; $setup_info['infolog']['tables'] = array('egw_infolog','egw_infolog_extra'); $setup_info['infolog']['enable'] = 1; @@ -72,3 +72,4 @@ $setup_info['infolog']['depends'][] = array( 'appname' => 'etemplate', 'versions' => Array('1.3','1.4','1.5') ); + diff --git a/infolog/setup/tables_current.inc.php b/infolog/setup/tables_current.inc.php index 99225ff8ef..f2e9dfd8dd 100644 --- a/infolog/setup/tables_current.inc.php +++ b/infolog/setup/tables_current.inc.php @@ -40,7 +40,8 @@ 'info_percent' => array('type' => 'int','precision' => '2','default' => '0'), 'info_datecompleted' => array('type' => 'int','precision' => '8'), 'info_location' => array('type' => 'varchar','precision' => '255'), - 'info_custom_from' => array('type' => 'int','precision' => '1') + 'info_custom_from' => array('type' => 'int','precision' => '1'), + 'info_uid' => array('type' => 'varchar','precision' => '255') ), 'pk' => array('info_id'), 'fk' => array(), diff --git a/infolog/setup/tables_update.inc.php b/infolog/setup/tables_update.inc.php index f6c7563346..607b5c56ff 100644 --- a/infolog/setup/tables_update.inc.php +++ b/infolog/setup/tables_update.inc.php @@ -574,3 +574,18 @@ { return $GLOBALS['setup_info']['infolog']['currentver'] = '1.4'; } + + $test[] = '1.4'; + function infolog_upgrade1_4() + { + $GLOBALS['egw_setup']->oProc->AddColumn('egw_infolog','info_uid',array( + 'type' => 'varchar', + 'precision' => '255' + )); + $GLOBALS['egw_setup']->db->query("SELECT config_value FROM egw_config WHERE config_app='phpgwapi' AND config_name='install_id'",__LINE__,__FILE__); + $install_id = $GLOBALS['egw_setup']->db->next_record() ? $GLOBALS['egw_setup']->db->f(0) : md5(time()); + $GLOBALS['egw_setup']->db->query('UPDATE egw_infolog SET info_uid='.$GLOBALS['egw_setup']->db->concat("'infolog-'",'info_id',"'-$install_id'"),__LINE__,__FILE__); + + return $GLOBALS['setup_info']['infolog']['currentver'] = '1.5.001'; + } +?>