using new api for InfoLog

This commit is contained in:
Ralf Becker 2016-04-30 17:05:23 +00:00
parent 70e084972a
commit f94aa623db
22 changed files with 567 additions and 787 deletions

View File

@ -11,13 +11,21 @@
* @version $Id$ * @version $Id$
*/ */
define('EGW_ACL_UNDELETE',EGW_ACL_CUSTOM_1); // undelete right use EGroupware\Api;
use EGroupware\Api\Link;
use EGroupware\Api\Acl;
use EGroupware\Api\Vfs;
/** /**
* This class is the BO-layer of InfoLog * This class is the BO-layer of InfoLog
*/ */
class infolog_bo class infolog_bo
{ {
/**
* Undelete right
*/
const ACL_UNDELETE = Acl::CUSTOM1;
var $enums; var $enums;
var $status; var $status;
/** /**
@ -204,7 +212,7 @@ class infolog_bo
'ongoing' => 'ongoing', // iCal has no status on notes 'ongoing' => 'ongoing', // iCal has no status on notes
'done' => 'done' ), 'done' => 'done' ),
); );
if (($config_data = config::read('infolog'))) if (($config_data = Api\Config::read('infolog')))
{ {
if (isset($config_data['status']) && is_array($config_data['status'])) if (isset($config_data['status']) && is_array($config_data['status']))
{ {
@ -226,7 +234,7 @@ class infolog_bo
} }
if ($config_data['group_owners']) $this->group_owners = $config_data['group_owners']; if ($config_data['group_owners']) $this->group_owners = $config_data['group_owners'];
$this->customfields = egw_customfields::get('infolog'); $this->customfields = Api\Storage\Customfields::get('infolog');
if ($this->customfields) if ($this->customfields)
{ {
foreach($this->customfields as $name => $field) foreach($this->customfields as $name => $field)
@ -244,7 +252,7 @@ class infolog_bo
$save_config = true; $save_config = true;
} }
} }
if ($save_config) config::save_value('customfields',$this->customfields,'infolog'); if ($save_config) Api\Config::save_value('customfields',$this->customfields,'infolog');
} }
if (is_array($config_data['responsible_edit'])) if (is_array($config_data['responsible_edit']))
{ {
@ -278,7 +286,7 @@ class infolog_bo
$this->user = $GLOBALS['egw_info']['user']['account_id']; $this->user = $GLOBALS['egw_info']['user']['account_id'];
$this->now = time(); $this->now = time();
$this->user_time_now = egw_time::server2user($this->now,'ts'); $this->user_time_now = Api\DateTime::server2user($this->now,'ts');
$this->grants = $GLOBALS['egw']->acl->get_grants('infolog',$this->group_owners ? $this->group_owners : true); $this->grants = $GLOBALS['egw']->acl->get_grants('infolog',$this->group_owners ? $this->group_owners : true);
$this->so = new infolog_so($this->grants); $this->so = new infolog_so($this->grants);
@ -297,17 +305,13 @@ class infolog_bo
* checks if there are customfields for typ $typ * checks if there are customfields for typ $typ
* *
* @param string $type * @param string $type
* @param boolean $links = false if true check only customfields containing links, default false = all custom fields
* @return boolean True if there are customfields for $typ, else False * @return boolean True if there are customfields for $typ, else False
*/ */
function has_customfields($type,$links=false) function has_customfields($type)
{ {
if ($links) $link_types = customfields_widget::get_customfield_link_types();
foreach($this->customfields as $field) foreach($this->customfields as $field)
{ {
if ((!$type || empty($field['type2']) || in_array($type,is_array($field['type2']) ? $field['type2'] : explode(',',$field['type2']))) && if ((!$type || empty($field['type2']) || in_array($type,is_array($field['type2']) ? $field['type2'] : explode(',',$field['type2']))))
(!$links || in_array($field['type'],$link_types)))
{ {
return True; return True;
} }
@ -319,7 +323,7 @@ class infolog_bo
* check's if user has the requiered rights on entry $info_id * check's if user has the requiered rights on entry $info_id
* *
* @param int|array $info data or info_id of infolog entry to check * @param int|array $info data or info_id of infolog entry to check
* @param int $required_rights EGW_ACL_{READ|EDIT|ADD|DELETE} * @param int $required_rights ACL::{READ|EDIT|ADD|DELETE}|infolog_bo::ACL_UNDELETE
* @param int $other uid to check (if info==0) or 0 to check against $this->user * @param int $other uid to check (if info==0) or 0 to check against $this->user
* @param int $user = null user whos rights to check, default current user * @param int $user = null user whos rights to check, default current user
* @return boolean * @return boolean
@ -356,14 +360,14 @@ class infolog_bo
if (!is_array($info) && !($info = $this->so->read(array('info_id' => $info_id)))) return false; if (!is_array($info) && !($info = $this->so->read(array('info_id' => $info_id)))) return false;
if ($info['info_status'] == 'deleted' && if ($info['info_status'] == 'deleted' &&
($required_rights == EGW_ACL_EDIT || // no edit rights for deleted entries ($required_rights == Acl::EDIT || // no edit rights for deleted entries
$required_rights == EGW_ACL_ADD || // no add rights for deleted entries $required_rights == Acl::ADD || // no add rights for deleted entries
$required_rights == EGW_ACL_DELETE && ($this->history == 'history_no_delete' || // no delete at all! $required_rights == Acl::DELETE && ($this->history == 'history_no_delete' || // no delete at all!
$this->history == 'history_admin_delete' && (!isset($GLOBALS['egw_info']['user']['apps']['admin']) || $user!=$this->user)))) // delete only for admins $this->history == 'history_admin_delete' && (!isset($GLOBALS['egw_info']['user']['apps']['admin']) || $user!=$this->user)))) // delete only for admins
{ {
$access = false; $access = false;
} }
elseif ($required_rights == EGW_ACL_UNDELETE) elseif ($required_rights == self::ACL_UNDELETE)
{ {
if ($info['info_status'] != 'deleted') if ($info['info_status'] != 'deleted')
{ {
@ -372,11 +376,11 @@ class infolog_bo
else else
{ {
// undelete requires edit rights // undelete requires edit rights
$access = $this->so->check_access( $info,EGW_ACL_EDIT,$this->implicit_rights == 'edit',$grants,$user ); $access = $this->so->check_access( $info,Acl::EDIT,$this->implicit_rights == 'edit',$grants,$user );
} }
} }
} }
elseif ($required_rights == EGW_ACL_UNDELETE) elseif ($required_rights == self::ACL_UNDELETE)
{ {
$access = false; $access = false;
} }
@ -423,7 +427,7 @@ class infolog_bo
if ($info['info_link_id'] > 0 && if ($info['info_link_id'] > 0 &&
(isset($info['links']) && ($link = $info['links'][$info['info_link_id']]) || // use supplied links info (isset($info['links']) && ($link = $info['links'][$info['info_link_id']]) || // use supplied links info
($link = egw_link::get_link($info['info_link_id'])) !== False)) // if link not found in supplied links, we always search! ($link = Link::get_link($info['info_link_id'])) !== False)) // if link not found in supplied links, we always search!
{ {
if (isset($info['links']) && isset($link['app'])) if (isset($info['links']) && isset($link['app']))
{ {
@ -436,7 +440,7 @@ class infolog_bo
$app = $link['link_app'.$nr]; $app = $link['link_app'.$nr];
$id = $link['link_id'.$nr]; $id = $link['link_id'.$nr];
} }
$title = egw_link::title($app,$id); $title = Link::title($app,$id);
if ((string)$info['info_custom_from'] === '') // old entry if ((string)$info['info_custom_from'] === '') // old entry
{ {
@ -493,7 +497,7 @@ class infolog_bo
if ($fromTZId === $toTZId) return; if ($fromTZId === $toTZId) return;
$tz = egw_time::$server_timezone; $tz = Api\DateTime::$server_timezone;
if ($fromTZId) if ($fromTZId)
{ {
@ -505,12 +509,12 @@ class infolog_bo
} }
elseif (is_null($fromTZId)) elseif (is_null($fromTZId))
{ {
$tz = egw_time::$user_timezone; $tz = Api\DateTime::$user_timezone;
$fromTZ = egw_time::$user_timezone; $fromTZ = Api\DateTime::$user_timezone;
} }
else else
{ {
$fromTZ = egw_time::$server_timezone; $fromTZ = Api\DateTime::$server_timezone;
} }
if ($toTZId) if ($toTZId)
{ {
@ -522,30 +526,30 @@ class infolog_bo
} }
elseif (is_null($toTZId)) elseif (is_null($toTZId))
{ {
$toTZ = egw_time::$user_timezone; $toTZ = Api\DateTime::$user_timezone;
} }
else else
{ {
$toTZ = egw_time::$server_timezone; $toTZ = Api\DateTime::$server_timezone;
} }
//error_log(__METHOD__.'(values[info_enddate]='.date('Y-m-d H:i:s',$values['info_enddate']).", from=".array2string($fromTZId).", to=".array2string($toTZId).") tz=".$tz->getName().', fromTZ='.$fromTZ->getName().', toTZ='.$toTZ->getName().', userTZ='.egw_time::$user_timezone->getName()); //error_log(__METHOD__.'(values[info_enddate]='.date('Y-m-d H:i:s',$values['info_enddate']).", from=".array2string($fromTZId).", to=".array2string($toTZId).") tz=".$tz->getName().', fromTZ='.$fromTZ->getName().', toTZ='.$toTZ->getName().', userTZ='.Api\DateTime::$user_timezone->getName());
foreach($this->timestamps as $key) foreach($this->timestamps as $key)
{ {
if ($values[$key]) if ($values[$key])
{ {
$time = new egw_time($values[$key], $tz); $time = new Api\DateTime($values[$key], $tz);
$time->setTimezone($fromTZ); $time->setTimezone($fromTZ);
if ($time->format('Hi') == '0000') if ($time->format('Hi') == '0000')
{ {
// we keep dates the same in new timezone // we keep dates the same in new timezone
$arr = egw_time::to($time,'array'); $arr = Api\DateTime::to($time,'array');
$time = new egw_time($arr, $toTZ); $time = new Api\DateTime($arr, $toTZ);
} }
else else
{ {
$time->setTimezone($toTZ); $time->setTimezone($toTZ);
} }
$values[$key] = egw_time::to($time,'ts'); $values[$key] = Api\DateTime::to($time,'ts');
} }
} }
//error_log(__METHOD__.'() --> values[info_enddate]='.date('Y-m-d H:i:s',$values['info_enddate'])); //error_log(__METHOD__.'() --> values[info_enddate]='.date('Y-m-d H:i:s',$values['info_enddate']));
@ -562,7 +566,7 @@ class infolog_bo
{ {
if (empty($ts) || $date_format == 'server') return $ts; if (empty($ts) || $date_format == 'server') return $ts;
return egw_time::server2user($ts,$date_format); return Api\DateTime::server2user($ts,$date_format);
} }
/** /**
@ -596,9 +600,8 @@ class infolog_bo
{ {
return null; return null;
} }
$info_id = $data['info_id']; // in case the uid was specified
if (!$ignore_acl && !$this->check_access($data,EGW_ACL_READ)) // check behind read, to prevent a double read if (!$ignore_acl && !$this->check_access($data,Acl::READ)) // check behind read, to prevent a double read
{ {
return False; return False;
} }
@ -640,7 +643,7 @@ class infolog_bo
{ {
return False; return False;
} }
if (!$this->check_access($info,EGW_ACL_DELETE)) if (!$this->check_access($info,Acl::DELETE))
{ {
return False; return False;
} }
@ -649,7 +652,7 @@ class infolog_bo
{ {
foreach($children as $id => $owner) foreach($children as $id => $owner)
{ {
if ($delete_children && $this->so->grants[$owner] & EGW_ACL_DELETE) if ($delete_children && $this->so->grants[$owner] & Acl::DELETE)
{ {
$this->delete($id,$delete_children,$new_parent,$skip_notification); // call ourself recursive to delete the child $this->delete($id,$delete_children,$new_parent,$skip_notification); // call ourself recursive to delete the child
} }
@ -674,13 +677,13 @@ class infolog_bo
$this->so->write($deleted); $this->so->write($deleted);
egw_link::unlink(0,'infolog',$info_id,'','!file','',true); // keep the file attachments, hide the rest Link::unlink(0,'infolog',$info_id,'','!file','',true); // keep the file attachments, hide the rest
} }
else else
{ {
$this->so->delete($info_id,false); // we delete the children via bo to get all notifications! $this->so->delete($info_id,false); // we delete the children via bo to get all notifications!
egw_link::unlink(0,'infolog',$info_id); Link::unlink(0,'infolog',$info_id);
} }
if ($info['info_status'] != 'deleted') // dont notify of final purge of already deleted items if ($info['info_status'] != 'deleted') // dont notify of final purge of already deleted items
{ {
@ -717,8 +720,8 @@ class infolog_bo
{ {
$values = $values_in; $values = $values_in;
//echo "boinfolog::write()values="; _debug_array($values); //echo "boinfolog::write()values="; _debug_array($values);
if (!$values['info_id'] && !$this->check_access(0,EGW_ACL_EDIT,$values['info_owner']) && if (!$values['info_id'] && !$this->check_access(0,Acl::EDIT,$values['info_owner']) &&
!$this->check_access(0,EGW_ACL_ADD,$values['info_owner'])) !$this->check_access(0,Acl::ADD,$values['info_owner']))
{ {
return false; return false;
} }
@ -728,7 +731,7 @@ class infolog_bo
$old = $this->read($values['info_id'], false, 'server'); $old = $this->read($values['info_id'], false, 'server');
} }
if (($status_only = $values['info_id'] && !$this->check_access($values,EGW_ACL_EDIT))) if (($status_only = $values['info_id'] && !$this->check_access($values,Acl::EDIT)))
{ {
if (!isset($values['info_responsible'])) if (!isset($values['info_responsible']))
{ {
@ -744,11 +747,11 @@ class infolog_bo
} }
if (!$status_only && $values['info_status'] != 'deleted') if (!$status_only && $values['info_status'] != 'deleted')
{ {
$status_only = $undelete = $this->check_access($values['info_id'],EGW_ACL_UNDELETE); $status_only = $undelete = $this->check_access($values['info_id'],self::ACL_UNDELETE);
} }
} }
if ($values['info_id'] && !$this->check_access($values['info_id'],EGW_ACL_EDIT) && !$status_only || if ($values['info_id'] && !$this->check_access($values['info_id'],Acl::EDIT) && !$status_only ||
!$values['info_id'] && $values['info_id_parent'] && !$this->check_access($values['info_id_parent'],EGW_ACL_ADD)) !$values['info_id'] && $values['info_id_parent'] && !$this->check_access($values['info_id_parent'],Acl::ADD))
{ {
return false; return false;
} }
@ -851,7 +854,7 @@ class infolog_bo
// Check required custom fields // Check required custom fields
if($throw_exception) if($throw_exception)
{ {
$custom = egw_customfields::get('infolog'); $custom = Api\Storage\Customfields::get('infolog');
foreach($custom as $c_name => $c_field) foreach($custom as $c_name => $c_field)
{ {
if($c_field['type2']) $type2 = is_array($c_field['type2']) ? $c_field['type2'] : explode(',',$c_field['type2']); if($c_field['type2']) $type2 = is_array($c_field['type2']) ? $c_field['type2'] : explode(',',$c_field['type2']);
@ -860,7 +863,7 @@ class infolog_bo
// Required custom field // Required custom field
if(!$values['#'.$c_name]) if(!$values['#'.$c_name])
{ {
throw new egw_exception_wrong_userinput(lang('For infolog type %1, %2 is required',lang($values['info_type']),$c_field['label'])); throw new Api\Exception\WrongUserinput(lang('For infolog type %1, %2 is required',lang($values['info_type']),$c_field['label']));
} }
} }
} }
@ -869,10 +872,10 @@ class infolog_bo
if (isset($this->group_owners[$values['info_type']])) if (isset($this->group_owners[$values['info_type']]))
{ {
$values['info_owner'] = $this->group_owners[$values['info_type']]; $values['info_owner'] = $this->group_owners[$values['info_type']];
if (!($this->grants[$this->group_owners[$values['info_type']]] & EGW_ACL_EDIT)) if (!($this->grants[$this->group_owners[$values['info_type']]] & Acl::EDIT))
{ {
if (!$this->check_access($values['info_id'],EGW_ACL_EDIT) || if (!$this->check_access($values['info_id'],Acl::EDIT) ||
!$values['info_id'] && !$this->check_access($values,EGW_ACL_ADD) !$values['info_id'] && !$this->check_access($values,Acl::ADD)
) )
{ {
return false; // no edit rights from the group-owner and no implicit rights (delegated and sufficient rights) return false; // no edit rights from the group-owner and no implicit rights (delegated and sufficient rights)
@ -950,11 +953,11 @@ class infolog_bo
// Check for restore of deleted entry, restore held links // Check for restore of deleted entry, restore held links
if($old['info_status'] == 'deleted' && $values['info_status'] != 'deleted') if($old['info_status'] == 'deleted' && $values['info_status'] != 'deleted')
{ {
egw_link::restore('infolog', $info_id); Link::restore('infolog', $info_id);
} }
// notify the link-class about the update, as other apps may be subscribt to it // notify the link-class about the update, as other apps may be subscribt to it
egw_link::notify_update('infolog',$info_id,$values); Link::notify_update('infolog',$info_id,$values);
// pre-cache the new values // pre-cache the new values
self::set_link_cache($values); self::set_link_cache($values);
@ -1056,7 +1059,7 @@ class infolog_bo
{ {
if (!empty($query['col_filter'][$key])) if (!empty($query['col_filter'][$key]))
{ {
$query['col_filter'][$key] = egw_time::user2server($query['col_filter'][$key],'ts'); $query['col_filter'][$key] = Api\DateTime::user2server($query['col_filter'][$key],'ts');
} }
} }
} }
@ -1069,7 +1072,7 @@ class infolog_bo
{ {
foreach ($ret as $id => &$data) foreach ($ret as $id => &$data)
{ {
if (!$this->check_access($data,EGW_ACL_READ)) if (!$this->check_access($data,Acl::READ))
{ {
unset($ret[$id]); unset($ret[$id]);
continue; continue;
@ -1079,21 +1082,21 @@ class infolog_bo
{ {
if ($data[$key]) if ($data[$key])
{ {
$time = new egw_time($data[$key], egw_time::$server_timezone); $time = new Api\DateTime($data[$key], Api\DateTime::$server_timezone);
if (!isset($query['date_format']) || $query['date_format'] != 'server') if (!isset($query['date_format']) || $query['date_format'] != 'server')
{ {
if ($time->format('Hi') == '0000') if ($time->format('Hi') == '0000')
{ {
// we keep dates the same in user-time // we keep dates the same in user-time
$arr = egw_time::to($time,'array'); $arr = Api\DateTime::to($time,'array');
$time = new egw_time($arr, egw_time::$user_timezone); $time = new Api\DateTime($arr, Api\DateTime::$user_timezone);
} }
else else
{ {
$time->setTimezone(egw_time::$user_timezone); $time->setTimezone(Api\DateTime::$user_timezone);
} }
} }
$data[$key] = egw_time::to($time,'ts'); $data[$key] = Api\DateTime::to($time,'ts');
} }
} }
// pre-cache title and file access // pre-cache title and file access
@ -1161,7 +1164,7 @@ class infolog_bo
'info_addr' => implode(', ',$emails), 'info_addr' => implode(', ',$emails),
'info_subject' => $_subject, 'info_subject' => $_subject,
'info_des' => $_message, 'info_des' => $_message,
'info_startdate' => egw_time::server2user($_date), 'info_startdate' => Api\DateTime::server2user($_date),
'info_status' => $status, 'info_status' => $status,
'info_priority' => 1, 'info_priority' => 1,
'info_percent' => $status == 'done' ? 100 : 0, 'info_percent' => $status == 'done' ? 100 : 0,
@ -1173,7 +1176,7 @@ class infolog_bo
); );
if ($GLOBALS['egw_info']['user']['preferences']['infolog']['cat_add_default']) $info['info_cat'] = $GLOBALS['egw_info']['user']['preferences']['infolog']['cat_add_default']; if ($GLOBALS['egw_info']['user']['preferences']['infolog']['cat_add_default']) $info['info_cat'] = $GLOBALS['egw_info']['user']['preferences']['infolog']['cat_add_default'];
// find the addressbookentry to link with // find the addressbookentry to link with
$addressbook = new addressbook_bo(); $addressbook = new Api\Contacts();
$contacts = array(); $contacts = array();
foreach ($emails as $mailadr) foreach ($emails as $mailadr)
{ {
@ -1196,7 +1199,7 @@ class infolog_bo
// create the rest a "ordinary" links // create the rest a "ordinary" links
foreach ($contacts as $contact) foreach ($contacts as $contact)
{ {
egw_link::link('infolog',$info['link_to']['to_id'],'addressbook',$contact['id']); Link::link('infolog',$info['link_to']['to_id'],'addressbook',$contact['id']);
} }
} }
if (is_array($_attachments)) if (is_array($_attachments))
@ -1205,12 +1208,12 @@ class infolog_bo
{ {
if($attachment['egw_data']) if($attachment['egw_data'])
{ {
egw_link::link('infolog',$info['link_to']['to_id'],egw_link::DATA_APPNAME, $attachment); Link::link('infolog',$info['link_to']['to_id'],Link::DATA_APPNAME, $attachment);
} }
else if(is_readable($attachment['tmp_name']) || else if(is_readable($attachment['tmp_name']) ||
(egw_vfs::is_readable($attachment['tmp_name']) && parse_url($attachment['tmp_name'], PHP_URL_SCHEME) === 'vfs')) (Vfs::is_readable($attachment['tmp_name']) && parse_url($attachment['tmp_name'], PHP_URL_SCHEME) === 'vfs'))
{ {
egw_link::link('infolog',$info['link_to']['to_id'],'file', $attachment); Link::link('infolog',$info['link_to']['to_id'],'file', $attachment);
} }
} }
} }
@ -1294,7 +1297,7 @@ class infolog_bo
* Check access to the file store * Check access to the file store
* *
* @param int|array $id id of entry or entry array * @param int|array $id id of entry or entry array
* @param int $check EGW_ACL_READ for read and EGW_ACL_EDIT for write or delete access * @param int $check Acl::READ for read and Acl::EDIT for write or delete access
* @param string $rel_path = null currently not used in InfoLog * @param string $rel_path = null currently not used in InfoLog
* @param int $user = null for which user to check, default current user * @param int $user = null for which user to check, default current user
* @return boolean true if access is granted or false otherwise * @return boolean true if access is granted or false otherwise
@ -1312,10 +1315,10 @@ class infolog_bo
*/ */
function set_link_cache(array $info) function set_link_cache(array $info)
{ {
egw_link::set_cache('infolog',$info['info_id'], Link::set_cache('infolog',$info['info_id'],
$this->link_title($info), $this->link_title($info),
$this->file_access($info,EGW_ACL_EDIT) ? EGW_ACL_READ|EGW_ACL_EDIT : $this->file_access($info,Acl::EDIT) ? EGW_ACL_READ|EGW_ACL_EDIT :
($this->file_access($info,EGW_ACL_READ) ? EGW_ACL_READ : 0)); ($this->file_access($info,Acl::READ) ? Acl::READ : 0));
} }
/** /**
@ -1334,7 +1337,7 @@ class infolog_bo
{ {
return False; return False;
} }
$GLOBALS['egw']->translation->add_app('infolog'); Api\Translation::add_app('infolog');
$do_events = $args['location'] == 'calendar_include_events'; $do_events = $args['location'] == 'calendar_include_events';
$to_include = array(); $to_include = array();
@ -1357,12 +1360,12 @@ class infolog_bo
{ {
foreach ($infos as $info) foreach ($infos as $info)
{ {
$start = new egw_time($info['info_startdate'],egw_time::$user_timezone); $start = new Api\DateTime($info['info_startdate'],Api\DateTime::$user_timezone);
$title = ($do_events?common::formattime($start->format('H'),$start->format('i')).' ':''). $title = ($do_events?common::formattime($start->format('H'),$start->format('i')).' ':'').
$info['info_subject']; $info['info_subject'];
$view = egw_link::view('infolog',$info['info_id']); $view = Link::view('infolog',$info['info_id']);
$size = null; $size = null;
$edit = egw_link::edit('infolog',$info['info_id'], $size); $edit = Link::edit('infolog',$info['info_id'], $size);
$edit['size'] = $size; $edit['size'] = $size;
$content=array(); $content=array();
$status = $this->status[$info['info_type']][$info['info_status']]; $status = $this->status[$info['info_type']][$info['info_status']];
@ -1372,10 +1375,10 @@ class infolog_bo
$status => 'status' $status => 'status'
) as $icon => $default) ) as $icon => $default)
{ {
$icons[common::image('infolog',$icon) ? $icon : $default] = $icon; $icons[Api\Image::find('infolog',$icon) ? $icon : $default] = $icon;
} }
$content[] = html::a_href($title,$view); $content[] = Api\Html::a_href($title,$view);
$html = html::table(array(1 => $content)); $html = Api\Html::table(array(1 => $content));
$to_include[] = array( $to_include[] = array(
'starttime' => $info['info_startdate'], 'starttime' => $info['info_startdate'],
@ -1421,8 +1424,8 @@ class infolog_bo
'ongoing' : 'infolog/'.$row['info_status'], 'ongoing' : 'infolog/'.$row['info_status'],
'class' => $row['info_id_parent'] ? 'infolog_rowHasParent' : null, 'class' => $row['info_id_parent'] ? 'infolog_rowHasParent' : null,
); );
if (common::image('infolog', $icon=$row['info_type'].'_element') || if (Api\Image::find('infolog', $icon=$row['info_type'].'_element') ||
common::image('infolog', $icon=$row['info_type'])) Api\Image::find('infolog', $icon=$row['info_type']))
{ {
$infos[$row['info_id']]['icon'] = 'infolog/'.$icon; $infos[$row['info_id']]['icon'] = 'infolog/'.$icon;
} }
@ -1450,19 +1453,19 @@ class infolog_bo
{ {
if (!is_object($this->categories)) if (!is_object($this->categories))
{ {
$this->categories = new categories($this->user,'infolog'); $this->categories = new Api\Categories($this->user,'infolog');
} }
$old_cats_preserve = array(); $old_cats_preserve = array();
if ($info_id && $info_id > 0) if ($info_id && $info_id > 0)
{ {
// preserve categories without users read access // preserve Api\Categories without users read access
$old_infolog = $this->read($info_id); $old_infolog = $this->read($info_id);
$old_categories = explode(',',$old_infolog['info_cat']); $old_categories = explode(',',$old_infolog['info_cat']);
if (is_array($old_categories) && count($old_categories) > 0) if (is_array($old_categories) && count($old_categories) > 0)
{ {
foreach ($old_categories as $cat_id) foreach ($old_categories as $cat_id)
{ {
if ($cat_id && !$this->categories->check_perms(EGW_ACL_READ, $cat_id)) if ($cat_id && !$this->categories->check_perms(Acl::READ, $cat_id))
{ {
$old_cats_preserve[] = $cat_id; $old_cats_preserve[] = $cat_id;
} }
@ -1518,7 +1521,7 @@ class infolog_bo
{ {
if (!is_object($this->categories)) if (!is_object($this->categories))
{ {
$this->categories = new categories($this->user,'infolog'); $this->categories = new Api\Categories($this->user,'infolog');
} }
if (!is_array($cat_id_list)) if (!is_array($cat_id_list))
@ -1528,7 +1531,7 @@ class infolog_bo
$cat_list = array(); $cat_list = array();
foreach($cat_id_list as $cat_id) foreach($cat_id_list as $cat_id)
{ {
if ($cat_id && $this->categories->check_perms(EGW_ACL_READ, $cat_id) && if ($cat_id && $this->categories->check_perms(Acl::READ, $cat_id) &&
($cat_name = $this->categories->id2name($cat_id)) && $cat_name != '--') ($cat_name = $this->categories->id2name($cat_id)) && $cat_name != '--')
{ {
$cat_list[] = $cat_name; $cat_list[] = $cat_name;
@ -1671,13 +1674,13 @@ class infolog_bo
* X-INFOLOG-STATUS is only used, if translated to the vtodo-status gives the identical vtodo status * X-INFOLOG-STATUS is only used, if translated to the vtodo-status gives the identical vtodo status
* --> the user did not changed it * --> the user did not changed it
* *
* @param string $vtodo_status {CANCELLED|NEEDS-ACTION|COMPLETED|IN-PROCESS} * @param string $_vtodo_status {CANCELLED|NEEDS-ACTION|COMPLETED|IN-PROCESS}
* @param string $x_infolog_status preserved original infolog status * @param string $x_infolog_status preserved original infolog status
* @return string * @return string
*/ */
function vtodo2status($vtodo_status,$x_infolog_status=null) function vtodo2status($_vtodo_status,$x_infolog_status=null)
{ {
$vtodo_status = strtoupper($vtodo_status); $vtodo_status = strtoupper($_vtodo_status);
if ($x_infolog_status && $this->status2vtodo($x_infolog_status) == $vtodo_status) if ($x_infolog_status && $this->status2vtodo($x_infolog_status) == $vtodo_status)
{ {
@ -1800,7 +1803,7 @@ class infolog_bo
$filter = array('col_filter' => array('info_uid' => $infoData['info_uid'])); $filter = array('col_filter' => array('info_uid' => $infoData['info_uid']));
foreach($this->so->search($filter) as $egwData) foreach($this->so->search($filter) as $egwData)
{ {
if (!$this->check_access($egwData,EGW_ACL_READ)) continue; if (!$this->check_access($egwData,Acl::READ)) continue;
$foundInfoLogs[$egwData['info_id']] = $egwData['info_id']; $foundInfoLogs[$egwData['info_id']] = $egwData['info_id'];
} }
return $foundInfoLogs; return $foundInfoLogs;
@ -1852,7 +1855,7 @@ class infolog_bo
foreach ($this->so->search($filter) as $itemID => $egwData) foreach ($this->so->search($filter) as $itemID => $egwData)
{ {
if (!$this->check_access($egwData,EGW_ACL_READ)) continue; if (!$this->check_access($egwData,Acl::READ)) continue;
switch ($infoData['info_type']) switch ($infoData['info_type'])
{ {
@ -1925,7 +1928,7 @@ class infolog_bo
// __FILE__, __LINE__, PEAR_LOG_DEBUG); // __FILE__, __LINE__, PEAR_LOG_DEBUG);
foreach ($this->so->search($filter) as $itemID => $egwData) foreach ($this->so->search($filter) as $itemID => $egwData)
{ {
if (!$this->check_access($egwData,EGW_ACL_READ)) continue; if (!$this->check_access($egwData,Acl::READ)) continue;
// Horde::logMessage("findVTODO Trying\n" // Horde::logMessage("findVTODO Trying\n"
// . print_r($egwData, true), // . print_r($egwData, true),
// __FILE__, __LINE__, PEAR_LOG_DEBUG); // __FILE__, __LINE__, PEAR_LOG_DEBUG);
@ -1947,8 +1950,8 @@ class infolog_bo
if (isset($egwData['info_startdate']) && $egwData['info_startdate']) if (isset($egwData['info_startdate']) && $egwData['info_startdate'])
{ {
// We compare the date only // We compare the date only
$taskTime = new egw_time($infoData['info_startdate'],egw_time::$server_timezone); $taskTime = new Api\DateTime($infoData['info_startdate'],Api\DateTime::$server_timezone);
$egwTime = new egw_time($egwData['info_startdate'],egw_time::$server_timezone); $egwTime = new Api\DateTime($egwData['info_startdate'],Api\DateTime::$server_timezone);
if ($taskTime->format('Ymd') != $egwTime->format('Ymd')) if ($taskTime->format('Ymd') != $egwTime->format('Ymd'))
{ {
if ($this->log) if ($this->log)
@ -1992,8 +1995,8 @@ class infolog_bo
if (isset($egwData['info_enddate']) && $egwData['info_enddate']) if (isset($egwData['info_enddate']) && $egwData['info_enddate'])
{ {
// We compare the date only // We compare the date only
$taskTime = new egw_time($infoData['info_enddate'],egw_time::$server_timezone); $taskTime = new Api\DateTime($infoData['info_enddate'],Api\DateTime::$server_timezone);
$egwTime = new egw_time($egwData['info_enddate'],egw_time::$server_timezone); $egwTime = new Api\DateTime($egwData['info_enddate'],Api\DateTime::$server_timezone);
if ($taskTime->format('Ymd') != $egwTime->format('Ymd')) if ($taskTime->format('Ymd') != $egwTime->format('Ymd'))
{ {
if ($this->log) if ($this->log)
@ -2021,8 +2024,8 @@ class infolog_bo
if (isset($egwData['info_datecompleted']) && $egwData['info_datecompleted']) if (isset($egwData['info_datecompleted']) && $egwData['info_datecompleted'])
{ {
// We compare the date only // We compare the date only
$taskTime = new egw_time($infoData['info_datecompleted'],egw_time::$server_timezone); $taskTime = new Api\DateTime($infoData['info_datecompleted'],Api\DateTime::$server_timezone);
$egwTime = new egw_time($egwData['info_datecompleted'],egw_time::$server_timezone); $egwTime = new Api\DateTime($egwData['info_datecompleted'],Api\DateTime::$server_timezone);
if ($taskTime->format('Ymd') != $egwTime->format('Ymd')) if ($taskTime->format('Ymd') != $egwTime->format('Ymd'))
{ {
if ($this->log) if ($this->log)

View File

@ -5,11 +5,14 @@
* @link http://www.egroupware.org * @link http://www.egroupware.org
* @author Ralf Becker <RalfBecker-AT-outdoor-training.de> * @author Ralf Becker <RalfBecker-AT-outdoor-training.de>
* @package infolog * @package infolog
* @copyright (c) 2003-14 by Ralf Becker <RalfBecker-AT-outdoor-training.de> * @copyright (c) 2003-16 by Ralf Becker <RalfBecker-AT-outdoor-training.de>
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License * @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
* @version $Id$ * @version $Id$
*/ */
use EGroupware\Api;
use EGroupware\Api\Etemplate;
require_once(EGW_INCLUDE_ROOT . '/admin/inc/class.customfields.inc.php'); require_once(EGW_INCLUDE_ROOT . '/admin/inc/class.customfields.inc.php');
/** /**
* Administration of custom fields, type and status * Administration of custom fields, type and status
@ -26,7 +29,7 @@ class infolog_customfields extends customfields
/** /**
* instance of the config class for infolog * instance of the config class for infolog
* *
* @var config * @var Api\Config
*/ */
var $config_data; var $config_data;
/** /**
@ -39,12 +42,12 @@ class infolog_customfields extends customfields
function __construct( ) function __construct( )
{ {
parent::__construct('infolog'); parent::__construct('infolog');
$this->bo = new infolog_bo(); $this->bo = new infolog_bo();
$this->tmpl = new etemplate_new(); $this->tmpl = new Etemplate();
$this->content_types = &$this->bo->enums['type']; $this->content_types = &$this->bo->enums['type'];
$this->status = &$this->bo->status; $this->status = &$this->bo->status;
$this->config_data = config::read('infolog'); $this->config_data = Api\Config::read('infolog');
$this->fields = &$this->bo->customfields; $this->fields = &$this->bo->customfields;
$this->group_owners =& $this->bo->group_owners; $this->group_owners =& $this->bo->group_owners;
} }
@ -55,6 +58,8 @@ class infolog_customfields extends customfields
*/ */
protected function app_index(&$content, &$sel_options, &$readonlys, &$preserve) protected function app_index(&$content, &$sel_options, &$readonlys, &$preserve)
{ {
unset($sel_options); // not used, but required by function signature
$n = 0; $n = 0;
foreach($this->status[$this->content_type] as $name => $label) foreach($this->status[$this->content_type] as $name => $label)
{ {
@ -83,7 +88,6 @@ class infolog_customfields extends customfields
function update_fields(&$content) function update_fields(&$content)
{ {
$typ = $content['type2'];
$fields = &$content['fields']; $fields = &$content['fields'];
$create = $fields['create']; $create = $fields['create'];
@ -129,8 +133,8 @@ class infolog_customfields extends customfields
{ {
foreach(explode("\n",$field['values']) as $line) foreach(explode("\n",$field['values']) as $line)
{ {
list($var,$value) = explode('=',trim($line),2); list($var2,$value) = explode('=',trim($line),2);
$var = trim($var); $var = trim($var2);
$values[$var] = empty($value) ? $var : $value; $values[$var] = empty($value) ? $var : $value;
} }
} }
@ -156,7 +160,7 @@ class infolog_customfields extends customfields
uasort($this->fields,sort_by_order); uasort($this->fields,sort_by_order);
$n = 0; $n = 0;
foreach($this->fields as $name => $data) foreach(array_keys($this->fields) as $name)
{ {
$this->fields[$name]['order'] = ($n += 10); $this->fields[$name]['order'] = ($n += 10);
} }
@ -265,7 +269,7 @@ class infolog_customfields extends customfields
} }
else else
{ {
foreach($this->content_types as $letter => $name) foreach($this->content_types as $name)
{ {
if($name == $new_name) if($name == $new_name)
{ {
@ -285,15 +289,15 @@ class infolog_customfields extends customfields
$this->save_repository(); $this->save_repository();
return $new_name; return $new_name;
} }
function save_repository() function save_repository()
{ {
// save changes to repository // save changes to repository
config::save_value('types',$this->content_types,'infolog'); Api\Config::save_value('types',$this->content_types,'infolog');
//echo '<p>'.__METHOD__.'() \$this->status=<pre style="text-aling: left;">'; print_r($this->status); echo "</pre>\n"; //echo '<p>'.__METHOD__.'() \$this->status=<pre style="text-aling: left;">'; print_r($this->status); echo "</pre>\n";
config::save_value('status',$this->status,'infolog'); Api\Config::save_value('status',$this->status,'infolog');
//echo '<p>'.__METHOD__.'() \$this->fields=<pre style="text-aling: left;">'; print_r($this->fields); echo "</pre>\n"; //echo '<p>'.__METHOD__.'() \$this->fields=<pre style="text-aling: left;">'; print_r($this->fields); echo "</pre>\n";
egw_customfields::save('infolog', $this->fields); Api\Storage\Customfields::save('infolog', $this->fields);
config::save_value('group_owners',$this->group_owners,'infolog'); Api\Config::save_value('group_owners',$this->group_owners,'infolog');
} }
} }

View File

@ -6,11 +6,14 @@
* @author Ralf Becker <RalfBecker-AT-outdoor-training.de> * @author Ralf Becker <RalfBecker-AT-outdoor-training.de>
* @package infolog * @package infolog
* @subpackage projectmanager * @subpackage projectmanager
* @copyright (c) 2005-8 by Ralf Becker <RalfBecker-AT-outdoor-training.de> * @copyright (c) 2005-16 by Ralf Becker <RalfBecker-AT-outdoor-training.de>
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License * @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
* @version $Id$ * @version $Id$
*/ */
use EGroupware\Api\Link;
use EGroupware\Api\Acl;
include_once(EGW_INCLUDE_ROOT.'/projectmanager/inc/class.datasource.inc.php'); include_once(EGW_INCLUDE_ROOT.'/projectmanager/inc/class.datasource.inc.php');
/** /**
@ -93,11 +96,13 @@ class infolog_datasource extends datasource
* *
* @param array $element source project element representing an InfoLog entry, $element['pe_app_id'] = info_id * @param array $element source project element representing an InfoLog entry, $element['pe_app_id'] = info_id
* @param int $target target project id * @param int $target target project id
* @param array $target_data=null data of target-project, atm not used by the infolog datasource * @param array $extra =null data of target-project, atm not used by the infolog datasource
* @return array/boolean array(info_id,link_id) on success, false otherwise * @return array/boolean array(info_id,link_id) on success, false otherwise
*/ */
function copy($element,$target,$extra=null) function copy($element,$target,$extra=null)
{ {
unset($extra); // not used, but required by function signature
$info =& $this->infolog_bo->read((int) $element['pe_app_id']); $info =& $this->infolog_bo->read((int) $element['pe_app_id']);
if (!is_array($info)) return false; if (!is_array($info)) return false;
@ -116,11 +121,11 @@ class infolog_datasource extends datasource
if(!($info['info_id'] = $this->infolog_bo->write($info))) return false; if(!($info['info_id'] = $this->infolog_bo->write($info))) return false;
// link the new infolog against the project and setting info_link_id and evtl. info_from // link the new infolog against the project and setting info_link_id and evtl. info_from
$old_link = $info['info_link_id'] ? egw_link::get_link($info['info_link']) : $info['info_link']; $old_link = $info['info_link_id'] ? Link::get_link($info['info_link']) : $info['info_link'];
$info['info_link_id'] = egw_link::link('projectmanager',$target,'infolog',$info['info_id'],$element['pe_remark'],0,0,1); $info['info_link_id'] = Link::link('projectmanager',$target,'infolog',$info['info_id'],$element['pe_remark'],0,0,1);
if (!$info['info_from'] || $old_link && $info['info_from'] == $old_link['title']) if (!$info['info_from'] || $old_link && $info['info_from'] == $old_link['title'])
{ {
$info['info_from'] = egw_link::title('projectmanager',$target); $info['info_from'] = Link::title('projectmanager',$target);
} }
if ($info['info_status'] == 'template') if ($info['info_status'] == 'template')
{ {
@ -129,14 +134,14 @@ class infolog_datasource extends datasource
$this->infolog_bo->write($info); $this->infolog_bo->write($info);
// creating again all links, beside the one to the source-project // creating again all links, beside the one to the source-project
foreach(egw_link::get_links('infolog',$element['pe_app_id']) as $link) foreach(Link::get_links('infolog',$element['pe_app_id']) as $link)
{ {
if ($link['app'] == 'projectmanager' && $link['id'] == $element['pm_id'] || // ignoring the source project if ($link['app'] == 'projectmanager' && $link['id'] == $element['pm_id'] || // ignoring the source project
$link['app'] == egw_link::VFS_APPNAME) // ignoring files attachments for now $link['app'] == Link::VFS_APPNAME) // ignoring files attachments for now
{ {
continue; continue;
} }
egw_link::link('infolog',$info['info_id'],$link['app'],$link['id'],$link['remark']); Link::link('infolog',$info['info_id'],$link['app'],$link['id'],$link['remark']);
} }
$ret = array($info['info_id'],$info['info_link_id']); $ret = array($info['info_id'],$info['info_link_id']);
@ -181,7 +186,7 @@ class infolog_datasource extends datasource
$GLOBALS['infolog_bo'] = new infolog_bo(); $GLOBALS['infolog_bo'] = new infolog_bo();
} }
// dont delete infolog, which are linked to other elements, but their project // dont delete infolog, which are linked to other elements, but their project
if (count(egw_link::get_links('infolog',$id)) > 1) if (count(Link::get_links('infolog',$id)) > 1)
{ {
return false; return false;
} }
@ -198,7 +203,7 @@ class infolog_datasource extends datasource
function change_status($id,$status) function change_status($id,$status)
{ {
//error_log("datasource_infolog::change_status($id,$status)"); //error_log("datasource_infolog::change_status($id,$status)");
if (($info = $this->infolog_bo->read($id)) && $this->infolog_bo->check_access($info,EGW_ACL_EDIT)) if (($info = $this->infolog_bo->read($id)) && $this->infolog_bo->check_access($info,Acl::EDIT))
{ {
if ($status == 'active' && in_array($info['info_status'],array('template','nonactive','archive'))) if ($status == 'active' && in_array($info['info_status'],array('template','nonactive','archive')))
{ {

View File

@ -1,6 +1,6 @@
<?php <?php
/** /**
* eGroupWare * EGroupware Infolog - export plugin
* *
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License * @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
* @package infolog * @package infolog
@ -11,6 +11,9 @@
* @version $Id$ * @version $Id$
*/ */
use EGroupware\Api;
use EGroupware\Api\Link;
/** /**
* export plugin of infolog * export plugin of infolog
*/ */
@ -18,7 +21,7 @@ class infolog_export_csv implements importexport_iface_export_plugin {
public function __construct() { public function __construct() {
translation::add_app('infolog'); Api\Translation::add_app('infolog');
$this->bo = new infolog_bo(); $this->bo = new infolog_bo();
$this->get_selects(); $this->get_selects();
} }
@ -42,7 +45,7 @@ class infolog_export_csv implements importexport_iface_export_plugin {
switch($options['selection']) switch($options['selection'])
{ {
case 'search': case 'search':
$query = array_merge((array)$GLOBALS['egw']->session->appsession('session_data','infolog'), $query); $query = array_merge((array)Api\Cache::getSession('infolog', 'session_data'), $query);
// Fall through // Fall through
case 'filter': case 'filter':
case 'all': case 'all':
@ -94,7 +97,7 @@ class infolog_export_csv implements importexport_iface_export_plugin {
if($row[$field]) $cf_preload[$app][] = $row[$field]; if($row[$field]) $cf_preload[$app][] = $row[$field];
} }
if($cf_preload[$app]){ if($cf_preload[$app]){
$selects[$field] = egw_link::titles($app, $cf_preload[$app]); $selects[$field] = Link::titles($app, $cf_preload[$app]);
//error_log('Preload ' . $field . '['.$app . ']: ' . implode(',',$cf_preload[$app])); //error_log('Preload ' . $field . '['.$app . ']: ' . implode(',',$cf_preload[$app]));
} }
} }
@ -104,7 +107,7 @@ class infolog_export_csv implements importexport_iface_export_plugin {
} while($query['start'] < $query['total']); } while($query['start'] < $query['total']);
return $this->export_object; return $this->export_object;
break;
default: default:
$ids = $selection = explode(',',$options['selection']); $ids = $selection = explode(',',$options['selection']);
$this->export_records($this->export_object, $options, $selection, $ids); $this->export_records($this->export_object, $options, $selection, $ids);
@ -118,22 +121,22 @@ class infolog_export_csv implements importexport_iface_export_plugin {
// Pre-load links all at once // Pre-load links all at once
if($ids && $options['mapping']['info_link_id']) if($ids && $options['mapping']['info_link_id'])
{ {
$links = egw_link::get_links_multiple('infolog', $ids, true, '!'.egw_link::VFS_APPNAME); $links = Link::get_links_multiple('infolog', $ids, true, '!'.Link::VFS_APPNAME);
foreach($links as $id => $link) { foreach($links as $id => $link) {
if(!is_array($selection[$id])) break; if(!is_array($selection[$id])) break;
$selection[$id]['info_link_id'] = $link; $selection[$id]['info_link_id'] = $link;
if($options['convert']) $selection[$id]['info_link_id'] = egw_link::title($link['app'], $link['id']); if($options['convert']) $selection[$id]['info_link_id'] = Link::title($link['app'], $link['id']);
} }
} }
// If exporting PM fields, pre-load them all at once // If exporting PM fields, pre-load them all at once
if($ids && ($options['mapping']['pm_id'] || $options['mapping']['project'])) if($ids && ($options['mapping']['pm_id'] || $options['mapping']['project']))
{ {
$projects = egw_link::get_links_multiple('infolog', $ids, true, 'projectmanager'); $projects = Link::get_links_multiple('infolog', $ids, true, 'projectmanager');
foreach($projects as $id => $links) foreach($projects as $id => $links)
{ {
if(!is_array($selection[$id])) break; if(!is_array($selection[$id])) break;
$selection[$id]['pm_id'] = current($links); $selection[$id]['pm_id'] = current($links);
$selection[$id]['project'] = egw_link::title('projectmanager', $selection[$id]['pm_id']); $selection[$id]['project'] = Link::title('projectmanager', $selection[$id]['pm_id']);
$this->selects['pl_id'] = ExecMethod('projectmanager.projectmanager_pricelist_bo.pricelist',$selection[$id]['pm_id']); $this->selects['pl_id'] = ExecMethod('projectmanager.projectmanager_pricelist_bo.pricelist',$selection[$id]['pm_id']);
} }
} }
@ -141,11 +144,11 @@ class infolog_export_csv implements importexport_iface_export_plugin {
foreach ($selection as $_identifier) { foreach ($selection as $_identifier) {
if(!is_array($_identifier)) { if(!is_array($_identifier)) {
$record = new infolog_egw_record($_identifier); $record = new infolog_egw_record($_identifier);
if($link = $links[$record->info_id]) $record->info_link_id = $options['convert'] ? egw_link::title($link['app'], $link['id']) : $link; if(($link = $links[$record->info_id])) $record->info_link_id = $options['convert'] ? Link::title($link['app'], $link['id']) : $link;
if($project = $projects[$record->info_id]) if(($project = $projects[$record->info_id]))
{ {
$record->pm_id = current($project); $record->pm_id = current($project);
$record->project = egw_link::title('projectmanager', $record->pm_id); $record->project = Link::title('projectmanager', $record->pm_id);
} }
} else { } else {
$record = new infolog_egw_record(); $record = new infolog_egw_record();
@ -249,7 +252,7 @@ class infolog_export_csv implements importexport_iface_export_plugin {
foreach($filters as $field_name => &$settings) foreach($filters as $field_name => &$settings)
{ {
if($this->selects[$field_name]) $settings['values'] = $this->selects[$field_name]; if($this->selects[$field_name]) $settings['values'] = $this->selects[$field_name];
// Infolog can't handle ranges in custom fields due to the way searching is done. // Infolog can't handle ranges in custom fields due to the way searching is done.
if(strpos($field_name, '#') === 0 && strpos($settings['type'],'date') === 0) unset($filters[$field_name]); if(strpos($field_name, '#') === 0 && strpos($settings['type'],'date') === 0) unset($filters[$field_name]);
} }

View File

@ -11,6 +11,8 @@
* @version $Id$ * @version $Id$
*/ */
use EGroupware\Api;
/** /**
* export iCal plugin of infolog * export iCal plugin of infolog
*/ */
@ -25,15 +27,15 @@ class infolog_export_ical extends infolog_export_csv {
$options = $_definition->plugin_options; $options = $_definition->plugin_options;
$this->bo = new infolog_bo(); $this->bo = new infolog_bo();
$limit_exception = bo_merge::is_export_limit_excepted(); $limit_exception = Api\Storage\Merge::is_export_limit_excepted();
if (!$limit_exception) $export_limit = bo_merge::getExportLimit('infolog'); if (!$limit_exception) $export_limit = Api\Storage\Merge::getExportLimit('infolog');
$ids = array(); $ids = array();
$query = array(); $query = array();
switch($options['selection']) switch($options['selection'])
{ {
case 'search': case 'search':
$query = array_merge($GLOBALS['egw']->session->appsession('session_data','infolog'), $query); $query = array_merge(Api\Cache::getSession('infolog', 'session_data'), $query);
// Fall through // Fall through
case 'all': case 'all':
$query['num_rows'] = $export_limit ? $export_limit : -1; $query['num_rows'] = $export_limit ? $export_limit : -1;

View File

@ -5,16 +5,17 @@
* @link http://www.egroupware.org * @link http://www.egroupware.org
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License * @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
* @package infolog * @package infolog
* @subpackage groupdav * @subpackage caldav
* @author Ralf Becker <RalfBecker-AT-outdoor-training.de> * @author Ralf Becker <RalfBecker-AT-outdoor-training.de>
* @copyright (c) 2007-16 by Ralf Becker <RalfBecker-AT-outdoor-training.de> * @copyright (c) 2007-16 by Ralf Becker <RalfBecker-AT-outdoor-training.de>
* @version $Id$ * @version $Id$
*/ */
use EGroupware\Api; use EGroupware\Api;
use EGroupware\Api\Acl;
/** /**
* EGroupware: GroupDAV access: infolog handler * EGroupware: CalDAV access: infolog handler
* *
* Permanent error_log() calls should use $this->caldav->log($str) instead, to be send to PHP error_log() * Permanent error_log() calls should use $this->caldav->log($str) instead, to be send to PHP error_log()
* and our request-log (prefixed with "### " after request and response, like exceptions). * and our request-log (prefixed with "### " after request and response, like exceptions).
@ -623,7 +624,7 @@ class infolog_groupdav extends Api\CalDAV\Handler
$action = $GLOBALS['egw_info']['user']['preferences']['groupdav']['infolog-cat-action']; $action = $GLOBALS['egw_info']['user']['preferences']['groupdav']['infolog-cat-action'];
//error_log(__METHOD__.'('.array2string($task).', '.array2string($oldTask).") action=$action"); //error_log(__METHOD__.'('.array2string($task).', '.array2string($oldTask).") action=$action");
if ($task['info_cat'] && ($new_cat = categories::id2name($task['info_cat'])) && if ($task['info_cat'] && ($new_cat = Api\Categories::id2name($task['info_cat'])) &&
strpos($new_cat, '@') !== false) strpos($new_cat, '@') !== false)
{ {
$new_user = $GLOBALS['egw']->accounts->name2id($new_cat, 'account_email'); $new_user = $GLOBALS['egw']->accounts->name2id($new_cat, 'account_email');
@ -633,17 +634,17 @@ class infolog_groupdav extends Api\CalDAV\Handler
if ($new_user) if ($new_user)
{ {
// make sure category is global, as otherwise it will not be transmitted to other users // make sure category is global, as otherwise it will not be transmitted to other users
if (!categories::is_global($task['info_cat'])) if (!Api\Categories::is_global($task['info_cat']))
{ {
$cat_obj = new categories(categories::GLOBAL_ACCOUNT, 'infolog'); $cat_obj = new Api\Categories(categories::GLOBAL_ACCOUNT, 'infolog');
$cat = categories::read($task['info_cat']); $cat = Api\Categories::read($task['info_cat']);
$cat['owner'] = categories::GLOBAL_ACCOUNT; $cat['owner'] = Api\Categories::GLOBAL_ACCOUNT;
$cat['access'] = 'public'; $cat['access'] = 'public';
$cat_obj->edit($cat); $cat_obj->edit($cat);
} }
// if replace, remove user of old category from responsible // if replace, remove user of old category from responsible
if ($action == 'replace' && $oldTask && $oldTask['info_cat'] && if ($action == 'replace' && $oldTask && $oldTask['info_cat'] &&
($old_cat = categories::id2name($oldTask['info_cat'])) && strpos($old_cat, '@') !== false && ($old_cat = Api\Categories::id2name($oldTask['info_cat'])) && strpos($old_cat, '@') !== false &&
($old_user = $GLOBALS['egw']->accounts->name2id($old_cat, 'account_email')) && ($old_user = $GLOBALS['egw']->accounts->name2id($old_cat, 'account_email')) &&
($key = array_search($old_user, (array)$task['info_responsible'])) !== false) ($key = array_search($old_user, (array)$task['info_responsible'])) !== false)
{ {
@ -722,7 +723,7 @@ class infolog_groupdav extends Api\CalDAV\Handler
/** /**
* Check if user has the neccessary rights on a task / infolog entry * Check if user has the neccessary rights on a task / infolog entry
* *
* @param int $acl EGW_ACL_READ, EGW_ACL_EDIT or EGW_ACL_DELETE * @param int $acl Acl::READ, Acl::EDIT or Acl::DELETE
* @param array|int $task task-array or id * @param array|int $task task-array or id
* @return boolean null if entry does not exist, false if no access, true if access permitted * @return boolean null if entry does not exist, false if no access, true if access permitted
*/ */
@ -732,7 +733,7 @@ class infolog_groupdav extends Api\CalDAV\Handler
$access = $this->bo->check_access($task,$acl); $access = $this->bo->check_access($task,$acl);
if (!$access && $acl == EGW_ACL_EDIT && $this->bo->is_responsible($task)) if (!$access && $acl == Acl::EDIT && $this->bo->is_responsible($task))
{ {
$access = true; // access limited to $this->bo->responsible_edit fields (handled in infolog_bo::write()) $access = true; // access limited to $this->bo->responsible_edit fields (handled in infolog_bo::write())
} }
@ -774,7 +775,7 @@ class infolog_groupdav extends Api\CalDAV\Handler
/** /**
* Add extra properties for calendar collections * Add extra properties for calendar collections
* *
* @param array $props =array() regular props by the groupdav handler * @param array $props =array() regular props by the Api\CalDAV handler
* @param string $displayname * @param string $displayname
* @param string $base_uri =null base url of handler * @param string $base_uri =null base url of handler
* @param int $user =null account_id of owner of collection * @param int $user =null account_id of owner of collection
@ -785,7 +786,7 @@ class infolog_groupdav extends Api\CalDAV\Handler
unset($base_uri); // not used, but required by function signature unset($base_uri); // not used, but required by function signature
// calendar description // calendar description
$displayname = translation::convert(lang('Tasks of'),translation::charset(),'utf-8').' '.$displayname; $displayname = Api\Translation::convert(lang('Tasks of'),Api\Translation::charset(),'utf-8').' '.$displayname;
$props['calendar-description'] = Api\CalDAV::mkprop(Api\CalDAV::CALDAV,'calendar-description',$displayname); $props['calendar-description'] = Api\CalDAV::mkprop(Api\CalDAV::CALDAV,'calendar-description',$displayname);
// supported components, currently only VEVENT // supported components, currently only VEVENT
$props['supported-calendar-component-set'] = Api\CalDAV::mkprop(Api\CalDAV::CALDAV,'supported-calendar-component-set',array( $props['supported-calendar-component-set'] = Api\CalDAV::mkprop(Api\CalDAV::CALDAV,'supported-calendar-component-set',array(
@ -802,7 +803,7 @@ class infolog_groupdav extends Api\CalDAV\Handler
Api\CalDAV::mkprop(Api\CalDAV::CALDAV,'calendar-multiget',''))))), Api\CalDAV::mkprop(Api\CalDAV::CALDAV,'calendar-multiget',''))))),
); );
// only advertice rfc 6578 sync-collection report, if "delete-prevention" is switched on (deleted entries get marked deleted but not actualy deleted // only advertice rfc 6578 sync-collection report, if "delete-prevention" is switched on (deleted entries get marked deleted but not actualy deleted
$config = config::read('infolog'); $config = Api\Config::read('infolog');
if ($config['history']) if ($config['history'])
{ {
$props['supported-report-set']['sync-collection'] = Api\CalDAV::mkprop('supported-report',array( $props['supported-report-set']['sync-collection'] = Api\CalDAV::mkprop('supported-report',array(
@ -842,7 +843,7 @@ class infolog_groupdav extends Api\CalDAV\Handler
{ {
if (!isset($hook_data['setup'])) if (!isset($hook_data['setup']))
{ {
translation::add_app('infolog'); Api\Translation::add_app('infolog');
$infolog = new infolog_bo(); $infolog = new infolog_bo();
$types = $infolog->enums['type']; $types = $infolog->enums['type'];
} }

View File

@ -1,15 +1,21 @@
<?php <?php
/** /**
* InfoLog - Admin-, Preferences- and SideboxMenu-Hooks * EGroupware InfoLog - Admin-, Preferences- and SideboxMenu-Hooks
* *
* @link http://www.egroupware.org * @link http://www.egroupware.org
* @author Ralf Becker <RalfBecker-AT-outdoor-training.de> * @author Ralf Becker <RalfBecker-AT-outdoor-training.de>
* @package infolog * @package infolog
* @copyright (c) 2003-13 by Ralf Becker <RalfBecker-AT-outdoor-training.de> * @copyright (c) 2003-16 by Ralf Becker <RalfBecker-AT-outdoor-training.de>
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License * @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
* @version $Id$ * @version $Id$
*/ */
use EGroupware\Api;
use EGroupware\Api\Link;
use EGroupware\Api\Framework;
use EGroupware\Api\Egw;
use EGroupware\Api\Acl;
/** /**
* Class containing admin, preferences and sidebox-menus (used as hooks) * Class containing admin, preferences and sidebox-menus (used as hooks)
*/ */
@ -24,7 +30,7 @@ class infolog_hooks
static function not_enum_group_acls($location) static function not_enum_group_acls($location)
{ {
unset($location); // not used, but part of hook signature unset($location); // not used, but part of hook signature
$config = config::read('infolog'); $config = Api\Config::read('infolog');
return $config['group_owners']; return $config['group_owners'];
} }
@ -38,15 +44,6 @@ class infolog_hooks
static function search_link($location) static function search_link($location)
{ {
unset($location); // not used, but part of hook signature unset($location); // not used, but part of hook signature
// register our not_enum_group_acls hook, if not already registered
// can be removed after next infolog version update after 1.6
if ($GLOBALS['egw']->hooks->single('not_enum_group_acls', 'infolog') === false)
{
$setup_info = array();
include(EGW_INCLUDE_ROOT.'/infolog/setup/setup.inc.php');
$GLOBALS['egw']->hooks->register_hooks('infolog',$setup_info['infolog']['hooks']);
unset($setup_info);
}
return array( return array(
'query' => 'infolog.infolog_bo.link_query', 'query' => 'infolog.infolog_bo.link_query',
@ -93,32 +90,32 @@ class infolog_hooks
if ($location == 'sidebox_menu') if ($location == 'sidebox_menu')
{ {
// Magic etemplate2 favorites menu (from nextmatch widget) // Magic etemplate2 favorites menu (from nextmatch widget)
display_sidebox($appname, lang('Favorites'), egw_framework::favorite_list($appname)); display_sidebox($appname, lang('Favorites'), Framework\Favorites::list_favorites($appname));
$file = array( $file = array(
'infolog list' => egw::link('/index.php',array( 'infolog list' => Egw::link('/index.php',array(
'menuaction' => 'infolog.infolog_ui.index', 'menuaction' => 'infolog.infolog_ui.index',
'ajax' => 'true')), 'ajax' => 'true')),
array( array(
'text' => lang('Add %1',lang(egw_link::get_registry($appname, 'entry'))), 'text' => lang('Add %1',lang(Link::get_registry($appname, 'entry'))),
'no_lang' => true, 'no_lang' => true,
'link' => "javascript:app.infolog.add_link_sidemenu();" 'link' => "javascript:app.infolog.add_link_sidemenu();"
), ),
'Placeholders' => egw::link('/index.php','menuaction=infolog.infolog_merge.show_replacements') 'Placeholders' => Egw::link('/index.php','menuaction=infolog.infolog_merge.show_replacements')
); );
display_sidebox($appname,$GLOBALS['egw_info']['apps']['infolog']['title'].' '.lang('Menu'),$file); display_sidebox($appname,$GLOBALS['egw_info']['apps']['infolog']['title'].' '.lang('Menu'),$file);
} }
if ($GLOBALS['egw_info']['user']['apps']['admin'] && !html::$ua_mobile) if ($GLOBALS['egw_info']['user']['apps']['admin'] && !Api\Header\UserAgent::mobile())
{ {
$file = Array( $file = Array(
'Site configuration' => egw::link('/index.php',array( 'Site configuration' => Egw::link('/index.php',array(
'menuaction' => 'infolog.infolog_ui.admin' )), 'menuaction' => 'infolog.infolog_ui.admin' )),
'Global Categories' => egw::link('/index.php',array( 'Global Categories' => Egw::link('/index.php',array(
'menuaction' => 'admin.admin_categories.index', 'menuaction' => 'admin.admin_categories.index',
'appname' => $appname, 'appname' => $appname,
'global_cats'=> True)), 'global_cats'=> True)),
'Custom fields, typ and status' => egw::link('/index.php',array( 'Custom fields, typ and status' => Egw::link('/index.php',array(
'menuaction' => 'infolog.infolog_customfields.index')), 'menuaction' => 'infolog.infolog_customfields.index')),
); );
if ($location == 'admin') if ($location == 'admin')
@ -133,7 +130,7 @@ class infolog_hooks
} }
/** /**
* populates $settings for the preferences * populates $settings for the Api\Preferences
* *
* @return array * @return array
*/ */
@ -488,7 +485,7 @@ class infolog_hooks
*/ */
private static function all_cats() private static function all_cats()
{ {
$categories = new categories('','infolog'); $categories = new Api\Categories('','infolog');
$accountId = $GLOBALS['egw_info']['user']['account_id']; $accountId = $GLOBALS['egw_info']['user']['account_id'];
foreach((array)$categories->return_sorted_array(0,False,'','','',true) as $cat) foreach((array)$categories->return_sorted_array(0,False,'','','',true) as $cat)
@ -524,7 +521,7 @@ class infolog_hooks
if ($data['prefs']['notify_due_delegated'] || $data['prefs']['notify_due_responsible'] || if ($data['prefs']['notify_due_delegated'] || $data['prefs']['notify_due_responsible'] ||
$data['prefs']['notify_start_delegated'] || $data['prefs']['notify_start_responsible']) $data['prefs']['notify_start_delegated'] || $data['prefs']['notify_start_responsible'])
{ {
$async = new asyncservice(); $async = new Api\AsyncService();
if (!$async->read('infolog-async-notification')) if (!$async->read('infolog-async-notification'))
{ {
@ -537,17 +534,17 @@ class infolog_hooks
* ACL rights and labels used * ACL rights and labels used
* *
* @param string|array string with location or array with parameters incl. "location", specially "owner" for selected acl owner * @param string|array string with location or array with parameters incl. "location", specially "owner" for selected acl owner
* @return array acl::(READ|ADD|EDIT|DELETE|PRIVAT|CUSTOM(1|2|3)) => $label pairs * @return array Acl::(READ|ADD|EDIT|DELETE|PRIVAT|CUSTOM(1|2|3)) => $label pairs
*/ */
public static function acl_rights($params) public static function acl_rights($params)
{ {
unset($params); // not used, but default function signature for hooks unset($params); // not used, but default function signature for hooks
return array( return array(
acl::READ => 'read', Acl::READ => 'read',
acl::ADD => 'add', Acl::ADD => 'add',
acl::EDIT => 'edit', Acl::EDIT => 'edit',
acl::DELETE => 'delete', Acl::DELETE => 'delete',
acl::PRIVAT => 'private', Acl::PRIVAT => 'private',
); );
} }
@ -562,7 +559,7 @@ class infolog_hooks
unset($location); // not used, but part of hook signature unset($location); // not used, but part of hook signature
return true; return true;
} }
/** /**
* Mail integration hook to import mail message contents into an infolog entry * Mail integration hook to import mail message contents into an infolog entry
* *
@ -570,9 +567,11 @@ class infolog_hooks
*/ */
public static function mail_import($args) public static function mail_import($args)
{ {
unset($args); // not used, but required by function signature
return array ( return array (
'menuaction' => 'infolog.infolog_ui.mail_import', 'menuaction' => 'infolog.infolog_ui.mail_import',
'popup' => egw_link::get_registry('infolog', 'edit_popup') 'popup' => Link::get_registry('infolog', 'edit_popup')
); );
} }
} }

View File

@ -12,6 +12,7 @@
*/ */
use EGroupware\Api; use EGroupware\Api;
use EGroupware\Api\Acl;
/** /**
* InfoLog: Create and parse iCal's * InfoLog: Create and parse iCal's
@ -180,8 +181,8 @@ class infolog_ical extends infolog_bo
$taskData['info_cat'] = $cats[0]; $taskData['info_cat'] = $cats[0];
} }
$taskData = translation::convert($taskData, $taskData = Api\Translation::convert($taskData,
translation::charset(), $charset); Api\Translation::charset(), $charset);
if ($this->log) if ($this->log)
{ {
@ -201,8 +202,8 @@ class infolog_ical extends infolog_bo
// check if we have vtimezone component data for tzid of event, if not default to user timezone (default to server tz) // check if we have vtimezone component data for tzid of event, if not default to user timezone (default to server tz)
if (!calendar_timezones::add_vtimezone($vcal, $tzid)) if (!calendar_timezones::add_vtimezone($vcal, $tzid))
{ {
error_log(__METHOD__."() unknown TZID='$tzid', defaulting to user timezone '".egw_time::$user_timezone->getName()."'!"); error_log(__METHOD__."() unknown TZID='$tzid', defaulting to user timezone '".Api\DateTime::$user_timezone->getName()."'!");
calendar_timezones::add_vtimezone($vcal, egw_time::$user_timezone->getName()); calendar_timezones::add_vtimezone($vcal, Api\DateTime::$user_timezone->getName());
$tzid = null; $tzid = null;
} }
if (!isset(self::$tz_cache[$tzid])) if (!isset(self::$tz_cache[$tzid]))
@ -457,22 +458,22 @@ class infolog_ical extends infolog_bo
} }
elseif(is_null($tzid)) elseif(is_null($tzid))
{ {
$tz = egw_time::$user_timezone; $tz = Api\DateTime::$user_timezone;
} }
else else
{ {
$tz = egw_time::$server_timezone; $tz = Api\DateTime::$server_timezone;
} }
if (!is_a($time,'DateTime')) if (!is_a($time,'DateTime'))
{ {
$time = new egw_time($time,egw_time::$server_timezone); $time = new Api\DateTime($time,Api\DateTime::$server_timezone);
} }
$time->setTimezone($tz); $time->setTimezone($tz);
// check for date --> export it as such // check for date --> export it as such
if ($time->format('Hi') == '0000') if ($time->format('Hi') == '0000')
{ {
$arr = egw_time::to($time, 'array'); $arr = Api\DateTime::to($time, 'array');
$value = array( $value = array(
'year' => $arr['year'], 'year' => $arr['year'],
'month' => $arr['month'], 'month' => $arr['month'],
@ -493,7 +494,7 @@ class infolog_ical extends infolog_bo
} }
else else
{ {
$value = egw_time::to($time, 'ts'); $value = Api\DateTime::to($time, 'ts');
} }
} }
//error_log(__METHOD__."(, '$attr', ".array2string($time_in).', '.array2string($tzid).') tz='.$tz->getName().', value='.array2string($value).(is_int($value)?date('Y-m-d H:i:s',$value):'')); //error_log(__METHOD__."(, '$attr', ".array2string($time_in).', '.array2string($tzid).') tz='.$tz->getName().', value='.array2string($value).(is_int($value)?date('Y-m-d H:i:s',$value):''));
@ -542,7 +543,7 @@ class infolog_ical extends infolog_bo
// setting owner or responsible for new tasks based on folder // setting owner or responsible for new tasks based on folder
if (!is_null($user) && $_taskID == -1) if (!is_null($user) && $_taskID == -1)
{ {
if ($this->check_access($taskData, EGW_ACL_ADD)) if ($this->check_access($taskData, Acl::ADD))
{ {
$taskData['info_owner'] = $user; $taskData['info_owner'] = $user;
} }
@ -632,7 +633,7 @@ class infolog_ical extends infolog_bo
*/ */
protected static function date2ts($date) protected static function date2ts($date)
{ {
return is_scalar($date) ? $date : egw_time::to($date, 'ts'); return is_scalar($date) ? $date : Api\DateTime::to($date, 'ts');
} }
/** /**
@ -922,8 +923,8 @@ class infolog_ical extends infolog_bo
{ {
if(!($note = $this->read($_noteID, true, 'server'))) return false; if(!($note = $this->read($_noteID, true, 'server'))) return false;
$note = translation::convert($note, $note = Api\Translation::convert($note,
translation::charset(), $charset); Api\Translation::charset(), $charset);
switch ($_type) switch ($_type)
{ {
@ -935,8 +936,8 @@ class infolog_ical extends infolog_bo
if (!empty($note['info_cat'])) if (!empty($note['info_cat']))
{ {
$cats = $this->get_categories(array($note['info_cat'])); $cats = $this->get_categories(array($note['info_cat']));
$note['info_cat'] = translation::convert($cats[0], $note['info_cat'] = Api\Translation::convert($cats[0],
translation::charset(), $charset); Api\Translation::charset(), $charset);
} }
$vnote = new Horde_Icalendar_Vnote(); $vnote = new Horde_Icalendar_Vnote();
$vnote->setAttribute('PRODID','-//EGroupware//NONSGML EGroupware InfoLog '.$GLOBALS['egw_info']['apps']['infolog']['version'].'//'. $vnote->setAttribute('PRODID','-//EGroupware//NONSGML EGroupware InfoLog '.$GLOBALS['egw_info']['apps']['infolog']['version'].'//'.
@ -1084,7 +1085,7 @@ class infolog_ical extends infolog_bo
case 'text/plain': case 'text/plain':
$note = array(); $note = array();
$note['info_type'] = 'note'; $note['info_type'] = 'note';
$txt = str_replace("\r\n", "\n", translation::convert($_data, $charset)); $txt = str_replace("\r\n", "\n", Api\Translation::convert($_data, $charset));
$match = null; $match = null;
if (preg_match('/([^\n]+)\n\n(.*)/ms', $txt, $match)) if (preg_match('/([^\n]+)\n\n(.*)/ms', $txt, $match))
@ -1208,13 +1209,13 @@ class infolog_ical extends infolog_bo
error_log(__FILE__.'['.__LINE__.'] '.__METHOD__. error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.
'(' . $this->productManufacturer . '(' . $this->productManufacturer .
', '. $this->productName .', ' . ', '. $this->productName .', ' .
($this->tzid ? $this->tzid : egw_time::$user_timezone->getName()) . ($this->tzid ? $this->tzid : Api\DateTime::$user_timezone->getName()) .
")\n" , 3, $this->logfile); ")\n" , 3, $this->logfile);
} }
//Horde::logMessage('setSupportedFields(' . $this->productManufacturer . ', ' //Horde::logMessage('setSupportedFields(' . $this->productManufacturer . ', '
// . $this->productName .', ' . // . $this->productName .', ' .
// ($this->tzid ? $this->tzid : egw_time::$user_timezone->getName()) .')', // ($this->tzid ? $this->tzid : Api\DateTime::$user_timezone->getName()) .')',
// __FILE__, __LINE__, PEAR_LOG_DEBUG); // __FILE__, __LINE__, PEAR_LOG_DEBUG);
} }
} }

View File

@ -1,6 +1,6 @@
<?php <?php
/** /**
* eGroupWare * EGroupware - Infolog iCal import
* *
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License * @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
* @package calendar * @package calendar
@ -11,7 +11,6 @@
* @version $Id$ * @version $Id$
*/ */
/** /**
* import ical for infolog * import ical for infolog
* Not a lot of options for this, just uses the ical class * Not a lot of options for this, just uses the ical class
@ -30,7 +29,6 @@ class infolog_import_ical implements importexport_iface_import_plugin {
'action' => insert, 'action' => insert,
'last' => true, 'last' => true,
),*/ ),*/
); );
/** /**
@ -71,9 +69,9 @@ class infolog_import_ical implements importexport_iface_import_plugin {
protected $errors = array(); protected $errors = array();
/** /**
* List of actions, and how many times that action was taken * List of actions, and how many times that action was taken
*/ */
protected $results = array(); protected $results = array();
/** /**
* imports entries according to given definition object. * imports entries according to given definition object.
@ -109,7 +107,7 @@ class infolog_import_ical implements importexport_iface_import_plugin {
return $success; return $success;
} }
/** /**
* returns translated name of plugin * returns translated name of plugin
* *
@ -163,39 +161,38 @@ class infolog_import_ical implements importexport_iface_import_plugin {
} }
/** /**
* Returns warnings that were encountered during importing * Returns warnings that were encountered during importing
* Maximum of one warning message per record, but you can append if you need to * Maximum of one warning message per record, but you can append if you need to
* *
* @return Array ( * @return Array (
* record_# => warning message * record_# => warning message
* ) * )
*/ */
public function get_warnings() { public function get_warnings() {
return $this->warnings; return $this->warnings;
} }
/** /**
* Returns errors that were encountered during importing * Returns errors that were encountered during importing
* Maximum of one error message per record, but you can append if you need to * Maximum of one error message per record, but you can append if you need to
* *
* @return Array ( * @return Array (
* record_# => error message * record_# => error message
* ) * )
*/ */
public function get_errors() { public function get_errors() {
return $this->errors; return $this->errors;
} }
/** /**
* Returns a list of actions taken, and the number of records for that action. * Returns a list of actions taken, and the number of records for that action.
* Actions are things like 'insert', 'update', 'delete', and may be different for each plugin. * Actions are things like 'insert', 'update', 'delete', and may be different for each plugin.
* *
* @return Array ( * @return Array (
* action => record count * action => record count
* ) * )
*/ */
public function get_results() { public function get_results() {
return $this->results; return $this->results;
} }
} // end of iface_export_plugin }
?>

View File

@ -10,6 +10,8 @@
* @version $Id$ * @version $Id$
*/ */
use EGroupware\Api;
use EGroupware\Api\Link;
/** /**
* class import_csv for infolog * class import_csv for infolog
@ -129,7 +131,7 @@ class infolog_import_infologs_csv implements importexport_iface_import_plugin {
$this->tracking = new infolog_tracking($this->boinfolog); $this->tracking = new infolog_tracking($this->boinfolog);
// Need translations for some human stuff (early type detection) // Need translations for some human stuff (early type detection)
translation::add_app('infolog'); Api\Translation::add_app('infolog');
// set FieldMapping. // set FieldMapping.
$import_csv->mapping = $_definition->plugin_options['field_mapping']; $import_csv->mapping = $_definition->plugin_options['field_mapping'];
@ -193,7 +195,7 @@ class infolog_import_infologs_csv implements importexport_iface_import_plugin {
if(!$record['info_type'] || $record['info_type'] && !$this->boinfolog->enums['type'][$record['info_type']]) if(!$record['info_type'] || $record['info_type'] && !$this->boinfolog->enums['type'][$record['info_type']])
{ {
// Check for translated type // Check for translated type
$un_trans = translation::get_message_id($record['info_type'],'infolog'); $un_trans = Api\Translation::get_message_id($record['info_type'],'infolog');
if($record['info_type'] && $this->boinfolog->enums['type'][$un_trans]) if($record['info_type'] && $this->boinfolog->enums['type'][$un_trans])
{ {
$record['info_type'] = $un_trans; $record['info_type'] = $un_trans;
@ -339,8 +341,8 @@ class infolog_import_infologs_csv implements importexport_iface_import_plugin {
// Check for link during dry run // Check for link during dry run
if($_data['link_custom']) if($_data['link_custom'])
{ {
list($app, $app_id) = explode(':', $_data['link_custom'],2); list($app, $app_id2) = explode(':', $_data['link_custom'],2);
$app_id = $this->link_by_cf($record_num, $app, $field, $app_id); $app_id = $this->link_by_cf($record_num, $app, $field, $app_id2);
} }
$this->results[$_action]++; $this->results[$_action]++;
@ -371,7 +373,7 @@ class infolog_import_infologs_csv implements importexport_iface_import_plugin {
break; break;
} }
default: default:
throw new egw_exception('Unsupported action'); throw new Api\Exception('Unsupported action');
} }
// Process some additional fields // Process some additional fields
@ -379,7 +381,7 @@ class infolog_import_infologs_csv implements importexport_iface_import_plugin {
return $result; return $result;
} }
$info_link_id = $_data['info_link_id']; $info_link_id = $_data['info_link_id'];
foreach(self::$special_fields as $field => $desc) { foreach(array_keys(self::$special_fields) as $field) {
if(!$_data[$field]) continue; if(!$_data[$field]) continue;
if(strpos($field, 'link') === 0) { if(strpos($field, 'link') === 0) {
list($app, $app_id) = explode(':', $_data[$field],2); list($app, $app_id) = explode(':', $_data[$field],2);
@ -396,7 +398,7 @@ class infolog_import_infologs_csv implements importexport_iface_import_plugin {
if ($app && $app_id) { if ($app && $app_id) {
$id = $_data['info_id'] ? $_data['info_id'] : (int)$result; $id = $_data['info_id'] ? $_data['info_id'] : (int)$result;
//echo "<p>linking infolog:$id with $app:$app_id</p>\n"; //echo "<p>linking infolog:$id with $app:$app_id</p>\n";
$link_id = egw_link::link('infolog',$id,$app,$app_id); $link_id = Link::link('infolog',$id,$app,$app_id);
if ($link_id && !$info_link_id) if ($link_id && !$info_link_id)
{ {
$to_write = array( $to_write = array(
@ -503,7 +505,7 @@ class infolog_import_infologs_csv implements importexport_iface_import_plugin {
// Extra conversion functions - must be static // Extra conversion functions - must be static
public static function project_id($num_or_title) public static function project_id($num_or_title)
{ {
static $boprojects; static $boprojects=null;
if (!$num_or_title) return false; if (!$num_or_title) return false;
@ -526,15 +528,15 @@ class infolog_import_infologs_csv implements importexport_iface_import_plugin {
* This is a copy of what's in importexport_basic_import_csv, and can go * This is a copy of what's in importexport_basic_import_csv, and can go
* away if this is changed to extend it * away if this is changed to extend it
*/ */
protected function link_by_cf($record_num, $app, $fieldname, $value) protected function link_by_cf($record_num, $app, $fieldname, $_value)
{ {
$app_id = false; $app_id = false;
list($custom_field, $value) = explode(':',$value); list($custom_field, $value) = explode(':',$_value);
// Find matching entry // Find matching entry
if($app && $custom_field && $value) if($app && $custom_field && $value)
{ {
$cfs = config::get_customfields($app); $cfs = Api\Storage\Customfields::get($app);
// Error if no custom fields, probably something wrong in definition // Error if no custom fields, probably something wrong in definition
if(!$cfs[$custom_field]) if(!$cfs[$custom_field])
{ {
@ -558,10 +560,10 @@ class infolog_import_infologs_csv implements importexport_iface_import_plugin {
if($custom_field[0] != '#') $custom_field = '#' . $custom_field; if($custom_field[0] != '#') $custom_field = '#' . $custom_field;
// Search // Search
if(egw_link::get_registry($app, 'query')) if(Link::get_registry($app, 'query'))
{ {
$options = array('filter' => array("$custom_field = " . $GLOBALS['egw']->db->quote($value))); $options = array('filter' => array("$custom_field = " . $GLOBALS['egw']->db->quote($value)));
$result = egw_link::query($app, '', $options); $result = Link::query($app, '', $options);
// Only one allowed // Only one allowed
if(count($result) != 1) if(count($result) != 1)

View File

@ -6,16 +6,19 @@
* @author Ralf Becker <RalfBecker-AT-outdoor-training.de> * @author Ralf Becker <RalfBecker-AT-outdoor-training.de>
* @author Nathan Gray * @author Nathan Gray
* @package infolog * @package infolog
* @copyright (c) 2007-14 by Ralf Becker <RalfBecker-AT-outdoor-training.de> * @copyright (c) 2007-16 by Ralf Becker <RalfBecker-AT-outdoor-training.de>
* @copyright 2011 Nathan Gray * @copyright 2011 Nathan Gray
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License * @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
* @version $Id$ * @version $Id$
*/ */
use EGroupware\Api;
use EGroupware\Api\Link;
/** /**
* Infolog - document merge object * Infolog - document merge object
*/ */
class infolog_merge extends bo_merge class infolog_merge extends Api\Storage\Merge
{ {
/** /**
* Functions that can be called via menuaction * Functions that can be called via menuaction
@ -49,8 +52,8 @@ class infolog_merge extends bo_merge
'info_created', 'info_created',
); );
// switch of handling of html formated content, if html is not used // switch of handling of Api\Html formated content, if Api\Html is not used
$this->parse_html_styles = egw_customfields::use_html('infolog'); $this->parse_html_styles = Api\Storage\Customfields::use_html('infolog');
} }
/** /**
@ -118,11 +121,11 @@ class infolog_merge extends bo_merge
{ {
$array['#'.$name] = ''; $array['#'.$name] = '';
} }
// Format date cfs per user preferences // Format date cfs per user Api\Preferences
if($field['type'] == 'date' || $field['type'] == 'date-time') if($field['type'] == 'date' || $field['type'] == 'date-time')
{ {
$this->date_fields[] = '#'.$name; $this->date_fields[] = '#'.$name;
$array['#'.$name] = egw_time::to($array['#'.$name], $field['type'] == 'date' ? true : ''); $array['#'.$name] = Api\DateTime::to($array['#'.$name], $field['type'] == 'date' ? true : '');
} }
} }
@ -132,17 +135,17 @@ class infolog_merge extends bo_merge
// Timesheet time // Timesheet time
if(strpos($content, 'info_sum_timesheets')) if(strpos($content, 'info_sum_timesheets'))
{ {
$links = egw_link::get_links('infolog',$id,'timesheet'); $links = Link::get_links('infolog',$id,'timesheet');
$sum = ExecMethod('timesheet.timesheet_bo.sum',$links); $sum = ExecMethod('timesheet.timesheet_bo.sum',$links);
$info['$$info_sum_timesheets$$'] = $sum['duration']; $info['$$info_sum_timesheets$$'] = $sum['duration'];
} }
// Check for linked project ID // Check for linked project ID
$links = egw_link::get_links('infolog', $id, 'projectmanager'); $links = Link::get_links('infolog', $id, 'projectmanager');
foreach($links as $app_id) foreach($links as $app_id)
{ {
$array['pm_id'] = $app_id; $array['pm_id'] = $app_id;
$array['project'] = egw_link::title('projectmanager', $app_id); $array['project'] = Link::title('projectmanager', $app_id);
break; break;
} }
@ -162,14 +165,14 @@ class infolog_merge extends bo_merge
} }
/** /**
* Generate table with replacements for the preferences * Generate table with replacements for the Api\Preferences
* *
*/ */
public function show_replacements() public function show_replacements()
{ {
$GLOBALS['egw_info']['flags']['app_header'] = lang('infolog').' - '.lang('Replacements for inserting entries into documents'); $GLOBALS['egw_info']['flags']['app_header'] = lang('infolog').' - '.lang('Replacements for inserting entries into documents');
$GLOBALS['egw_info']['flags']['nonavbar'] = false; $GLOBALS['egw_info']['flags']['nonavbar'] = false;
common::egw_header(); $GLOBALS['egw']->framework->header();
echo "<table width='90%' align='center'>\n"; echo "<table width='90%' align='center'>\n";
echo '<tr><td colspan="4"><h3>'.lang('Infolog fields:')."</h3></td></tr>"; echo '<tr><td colspan="4"><h3>'.lang('Infolog fields:')."</h3></td></tr>";
@ -177,7 +180,7 @@ class infolog_merge extends bo_merge
$n = 0; $n = 0;
$tracking = new infolog_tracking($this->bo); $tracking = new infolog_tracking($this->bo);
$fields = array('info_id' => lang('Infolog ID'), 'pm_id' => lang('Project ID'), 'project' => lang('Project name')) + $tracking->field2label + array('info_sum_timesheets' => lang('Used time')); $fields = array('info_id' => lang('Infolog ID'), 'pm_id' => lang('Project ID'), 'project' => lang('Project name')) + $tracking->field2label + array('info_sum_timesheets' => lang('Used time'));
translation::add_app('projectmanager'); Api\Translation::add_app('projectmanager');
foreach($fields as $name => $label) foreach($fields as $name => $label)
{ {
if (in_array($name,array('custom'))) continue; // dont show them if (in_array($name,array('custom'))) continue; // dont show them
@ -228,7 +231,7 @@ class infolog_merge extends bo_merge
echo '<tr><td colspan="4"><h3>'.lang('Custom fields').":</h3></td></tr>"; echo '<tr><td colspan="4"><h3>'.lang('Custom fields').":</h3></td></tr>";
foreach($this->contacts->customfields as $name => $field) foreach($this->contacts->customfields as $name => $field)
{ {
echo '<tr><td>{{info_contact/#'.$name.'}}</td><td colspan="3">'.$field['label']."</td></tr>\n"; echo '<tr><td>{{info_contact/#'.$name.'}}</td><td colspan="3">'.$field['label']."</td></tr>\n";
} }
echo '<tr><td colspan="4"><h3>'.lang('General fields:')."</h3></td></tr>"; echo '<tr><td colspan="4"><h3>'.lang('General fields:')."</h3></td></tr>";
@ -258,6 +261,6 @@ class infolog_merge extends bo_merge
echo "</table>\n"; echo "</table>\n";
common::egw_footer(); $GLOBALS['egw']->framework->footer();
} }
} }

View File

@ -5,11 +5,15 @@
* @link http://www.egroupware.org * @link http://www.egroupware.org
* @author Ralf Becker <RalfBecker-AT-outdoor-training.de> * @author Ralf Becker <RalfBecker-AT-outdoor-training.de>
* @package infolog * @package infolog
* @copyright (c) 2003-13 by Ralf Becker <RalfBecker-AT-outdoor-training.de> * @copyright (c) 2003-16 by Ralf Becker <RalfBecker-AT-outdoor-training.de>
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License * @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
* @version $Id$ * @version $Id$
*/ */
use EGroupware\Api;
use EGroupware\Api\Link;
use EGroupware\Api\Acl;
/** /**
* storage object / db-layer for InfoLog * storage object / db-layer for InfoLog
* *
@ -21,7 +25,7 @@ class infolog_so
/** /**
* Instance of the db class * Instance of the db class
* *
* @var egw_db * @var Api\Db
*/ */
var $db; var $db;
/** /**
@ -64,7 +68,7 @@ class infolog_so
/** /**
* Constructor * Constructor
* *
* @param array $grants=array() * @param array $grants =array()
* @return soinfolog * @return soinfolog
*/ */
function __construct( $grants=array() ) function __construct( $grants=array() )
@ -102,9 +106,9 @@ class infolog_so
* *
* @param array|int $info data or info_id of InfoLog entry * @param array|int $info data or info_id of InfoLog entry
* @param int $required_rights EGW_ACL_xyz anded together * @param int $required_rights EGW_ACL_xyz anded together
* @param boolean $implicit_edit=false responsible has only implicit read and add rigths, unless this is set to true * @param boolean $implicit_edit =false responsible has only implicit read and add rigths, unless this is set to true
* @param array $grants=null grants to use, default (null) $this->grants * @param array $grants =null grants to use, default (null) $this->grants
* @param int $user=null user to check, default (null) $this->user * @param int $user =null user to check, default (null) $this->user
* @return boolean True if access is granted else False * @return boolean True if access is granted else False
*/ */
function check_access( $info,$required_rights,$implicit_edit=false,array $grants=null,$user=null ) function check_access( $info,$required_rights,$implicit_edit=false,array $grants=null,$user=null )
@ -139,8 +143,8 @@ class infolog_so
// ACL only on public entrys || $owner granted _PRIVATE // ACL only on public entrys || $owner granted _PRIVATE
(!!($grants[$owner] & $required_rights) || (!!($grants[$owner] & $required_rights) ||
$this->is_responsible($info,$user) && // implicite rights for responsible user(s) and his memberships $this->is_responsible($info,$user) && // implicite rights for responsible user(s) and his memberships
($required_rights == EGW_ACL_READ || $required_rights == EGW_ACL_ADD || $implicit_edit && $required_rights == EGW_ACL_EDIT)) && ($required_rights == Acl::READ || $required_rights == Acl::ADD || $implicit_edit && $required_rights == Acl::EDIT)) &&
($info['info_access'] == 'public' || !!($this->grants[$user] & EGW_ACL_PRIVATE)); ($info['info_access'] == 'public' || !!($this->grants[$user] & Acl::PRIVAT));
// error_log(__METHOD__."($info[info_id],$required_rights,$implicit_edit,".array2string($grants).",$user) returning ".array2string($access_ok)); // error_log(__METHOD__."($info[info_id],$required_rights,$implicit_edit,".array2string($grants).",$user) returning ".array2string($access_ok));
return $access_ok; return $access_ok;
@ -181,16 +185,16 @@ class infolog_so
/** /**
* generate sql to be AND'ed into a query to ensure ACL is respected (incl. _PRIVATE) * generate sql to be AND'ed into a query to ensure ACL is respected (incl. _PRIVATE)
* *
* @param string $filter: ''|all - list all entrys user have rights to see<br> * @param string $_filter ''|all - list all entrys user have rights to see<br>
* private|own - list only his personal entrys (incl. those he is responsible for !!!), * private|own - list only his personal entrys (incl. those he is responsible for !!!),
* responsible|my = entries the user is responsible for * responsible|my = entries the user is responsible for
* delegated = entries the user delegated to someone else * delegated = entries the user delegated to someone else
* @return string the necesary sql * @return string the necesary sql
*/ */
function aclFilter($filter = False) function aclFilter($_filter = False)
{ {
$vars = null; $vars = null;
preg_match('/(my|responsible|delegated|own|privat|private|all|user)([0-9,-]*)/',$filter_was=$filter,$vars); preg_match('/(my|responsible|delegated|own|privat|private|all|user)([0-9,-]*)/',$_filter,$vars);
$filter = $vars[1]; $filter = $vars[1];
$f_user = $vars[2]; $f_user = $vars[2];
@ -224,7 +228,7 @@ class infolog_so
{ {
$public_user_list[] = $user; $public_user_list[] = $user;
} }
if ($grant & EGW_ACL_PRIVATE) if ($grant & Acl::PRIVAT)
{ {
$private_user_list[] = $user; $private_user_list[] = $user;
} }
@ -266,21 +270,21 @@ class infolog_so
)," AND info_responsible='0' OR ",$this->responsible_filter($f_user),')'); )," AND info_responsible='0' OR ",$this->responsible_filter($f_user),')');
} }
} }
//echo "<p>aclFilter(filter='$filter_was',user='$f_user') = '$filtermethod', privat_user_list=".print_r($privat_user_list,True).", public_user_list=".print_r($public_user_list,True)."</p>\n"; //echo "<p>aclFilter(filter='$_filter',user='$f_user') = '$filtermethod', privat_user_list=".print_r($privat_user_list,True).", public_user_list=".print_r($public_user_list,True)."</p>\n";
return $this->acl_filter[$filter.$f_user] = $filtermethod; // cache the filter return $this->acl_filter[$filter.$f_user] = $filtermethod; // cache the filter
} }
/** /**
* generate sql to filter based on the status of the log-entry * generate sql to filter based on the status of the log-entry
* *
* @param string $filter done = done or billed, open = not (done, billed, cancelled or deleted), offer = offer * @param string $_filter done = done or billed, open = not (done, billed, cancelled or deleted), offer = offer
* @param boolean $prefix_and=true if true prefix the fileter with ' AND ' * @param boolean $prefix_and =true if true prefix the fileter with ' AND '
* @return string the necesary sql * @return string the necesary sql
*/ */
function statusFilter($filter = '',$prefix_and=true) function statusFilter($_filter = '',$prefix_and=true)
{ {
$vars = null; $vars = null;
preg_match('/(done|open|offer|deleted|\+deleted)/',$filter,$vars); preg_match('/(done|open|offer|deleted|\+deleted)/',$_filter,$vars);
$filter = $vars[1]; $filter = $vars[1];
switch ($filter) switch ($filter)
@ -298,7 +302,7 @@ class infolog_so
/** /**
* generate sql to filter based on the start- and enddate of the log-entry * generate sql to filter based on the start- and enddate of the log-entry
* *
* @param string $filter upcoming = startdate is in the future * @param string $_filter upcoming = startdate is in the future
* today: startdate < tomorrow * today: startdate < tomorrow
* overdue: enddate < tomorrow * overdue: enddate < tomorrow
* date: today <= startdate && startdate < tomorrow * date: today <= startdate && startdate < tomorrow
@ -306,10 +310,10 @@ class infolog_so
* limitYYYY/MM/DD not older or open * limitYYYY/MM/DD not older or open
* @return string the necesary sql * @return string the necesary sql
*/ */
function dateFilter($filter = '') function dateFilter($_filter = '')
{ {
$vars = null; $vars = null;
preg_match('/(open-upcoming|upcoming|today|overdue|date|enddate)([-\\/.0-9]*)/',$filter,$vars); preg_match('/(open-upcoming|upcoming|today|overdue|date|enddate)([-\\/.0-9]*)/',$_filter,$vars);
$filter = $vars[1]; $filter = $vars[1];
if (isset($vars[2]) && !empty($vars[2]) && ($date = preg_split('/[-\\/.]/',$vars[2]))) if (isset($vars[2]) && !empty($vars[2]) && ($date = preg_split('/[-\\/.]/',$vars[2])))
@ -393,7 +397,7 @@ class infolog_so
// entry without uid --> create one based on our info_id and save it // entry without uid --> create one based on our info_id and save it
if (!$this->data['info_uid'] || strlen($this->data['info_uid']) < $minimum_uid_length) if (!$this->data['info_uid'] || strlen($this->data['info_uid']) < $minimum_uid_length)
{ {
$this->data['info_uid'] = common::generate_uid('infolog', $this->data['info_id']); $this->data['info_uid'] = Api\CalDAV::generate_uid('infolog', $this->data['info_id']);
$this->db->update($this->info_table, $this->db->update($this->info_table,
array('info_uid' => $this->data['info_uid']), array('info_uid' => $this->data['info_uid']),
array('info_id' => $this->data['info_id']), __LINE__,__FILE__); array('info_id' => $this->data['info_id']), __LINE__,__FILE__);
@ -428,7 +432,7 @@ class infolog_so
} }
$this->db->delete($this->info_table,array('info_id'=>$info_id),__LINE__,__FILE__); $this->db->delete($this->info_table,array('info_id'=>$info_id),__LINE__,__FILE__);
$this->db->delete($this->extra_table,array('info_id'=>$info_id),__LINE__,__FILE__); $this->db->delete($this->extra_table,array('info_id'=>$info_id),__LINE__,__FILE__);
egw_link::unlink(0,'infolog',$info_id); Link::unlink(0,'infolog',$info_id);
if ($this->data['info_id'] == $info_id) if ($this->data['info_id'] == $info_id)
{ {
@ -499,15 +503,14 @@ class infolog_so
'info_responsible' => implode(',',$new_responsible), 'info_responsible' => implode(',',$new_responsible),
),array('info_id' => $row['info_id']),__LINE__,__FILE__,'infolog'); ),array('info_id' => $row['info_id']),__LINE__,__FILE__,'infolog');
} }
} }
/** /**
* writes the given $values to InfoLog, a new entry gets created if info_id is not set or 0 * writes the given $values to InfoLog, a new entry gets created if info_id is not set or 0
* *
* @param array $values with the data of the log-entry * @param array $values with the data of the log-entry
* @param int $check_modified=0 old modification date to check before update (include in WHERE) * @param int $check_modified =0 old modification date to check before update (include in WHERE)
* @param string $purge_cfs=null null=dont, 'ical'=only iCal X-properties (cfs name starting with "#"), 'all'=all cfs * @param string $purge_cfs =null null=dont, 'ical'=only iCal X-properties (cfs name starting with "#"), 'all'=all cfs
* @return int|boolean info_id, false on error or 0 if the entry has been updated in the meantime * @return int|boolean info_id, false on error or 0 if the entry has been updated in the meantime
*/ */
function write($values, $check_modified=0, $purge_cfs=null) // did _not_ ensure ACL function write($values, $check_modified=0, $purge_cfs=null) // did _not_ ensure ACL
@ -567,7 +570,7 @@ class infolog_so
// entry without (reasonable) uid --> create one based on our info_id and save it // entry without (reasonable) uid --> create one based on our info_id and save it
if (!$this->data['info_uid'] || strlen($this->data['info_uid']) < $minimum_uid_length) if (!$this->data['info_uid'] || strlen($this->data['info_uid']) < $minimum_uid_length)
{ {
$update['info_uid'] = $this->data['info_uid'] = common::generate_uid('infolog', $info_id); $update['info_uid'] = $this->data['info_uid'] = Api\CalDAV::generate_uid('infolog', $info_id);
} }
// entry without caldav_name --> generate one based on info_id plus '.ics' extension // entry without caldav_name --> generate one based on info_id plus '.ics' extension
if (empty($this->data['caldav_name'])) if (empty($this->data['caldav_name']))
@ -685,7 +688,7 @@ class infolog_so
$action = isset($action2app[$query['action']]) ? $action2app[$query['action']] : $query['action']; $action = isset($action2app[$query['action']]) ? $action2app[$query['action']] : $query['action'];
if ($action) if ($action)
{ {
$links = solink::get_links($action=='sp'?'infolog':$action, $links = Link\Storage::get_links($action=='sp'?'infolog':$action,
is_array($query['action_id']) ? $query['action_id'] : explode(',',$query['action_id']),'infolog','',$query['col_filter']['info_status'] =='deleted'); is_array($query['action_id']) ? $query['action_id'] : explode(',',$query['action_id']),'infolog','',$query['col_filter']['info_status'] =='deleted');
if (count($links)) if (count($links))
@ -767,14 +770,14 @@ class infolog_so
if ($col[0] == '#' && $query['custom_fields'] && $data) if ($col[0] == '#' && $query['custom_fields'] && $data)
{ {
$filtermethod .= " AND main.info_id IN (SELECT DISTINCT info_id FROM $this->extra_table WHERE "; $filtermethod .= " AND main.info_id IN (SELECT DISTINCT info_id FROM $this->extra_table WHERE ";
$custom_fields = config::get_customfields('infolog'); $custom_fields = Api\Storage\Customfields::get('infolog');
if($custom_fields[substr($col,1)]['type'] == 'select' && $custom_fields[substr($col,1)]['rows'] > 1) if($custom_fields[substr($col,1)]['type'] == 'select' && $custom_fields[substr($col,1)]['rows'] > 1)
{ {
// Multi-select - any entry with the filter value selected matches // Multi-select - any entry with the filter value selected matches
$filtermethod .= $this->db->expression($this->extra_table, array( $filtermethod .= $this->db->expression($this->extra_table, array(
'info_extra_name' => substr($col,1), 'info_extra_name' => substr($col,1),
$this->db->concat("','",'info_extra_value',"','").' '.$this->db->capabilities[egw_db::CAPABILITY_CASE_INSENSITIV_LIKE].' '.$this->db->quote('%,'.$data.',%'), $this->db->concat("','",'info_extra_value',"','").' '.$this->db->capabilities[Api\Db::CAPABILITY_CASE_INSENSITIV_LIKE].' '.$this->db->quote('%,'.$data.',%'),
)).')'; )).')';
} }
else else
@ -792,7 +795,7 @@ class infolog_so
if ((int)$query['cat_id']) if ((int)$query['cat_id'])
{ {
$categories = new categories('','infolog'); $categories = new Api\Categories('','infolog');
$cats = $categories->return_all_children((int)$query['cat_id']); $cats = $categories->return_all_children((int)$query['cat_id']);
$filtermethod .= ' AND info_cat'.(count($cats)>1? ' IN ('.implode(',',$cats).') ' : '='.(int)$query['cat_id']); $filtermethod .= ' AND info_cat'.(count($cats)>1? ' IN ('.implode(',',$cats).') ' : '='.(int)$query['cat_id']);
} }
@ -805,7 +808,7 @@ class infolog_so
if ($this->db->capabilities['like_on_text']) $columns[] = 'info_des'; if ($this->db->capabilities['like_on_text']) $columns[] = 'info_des';
$wildcard = $op = null; $wildcard = $op = null;
$so_sql = new so_sql('infolog', $this->info_table, $this->db); $so_sql = new Api\Storage\Base('infolog', $this->info_table, $this->db);
$search = $so_sql->search2criteria($query['search'], $wildcard, $op, null, $columns); $search = $so_sql->search2criteria($query['search'], $wildcard, $op, null, $columns);
$sql_query = 'AND ('.(is_numeric($query['search']) ? 'main.info_id='.(int)$query['search'].' OR ' : ''). $sql_query = 'AND ('.(is_numeric($query['search']) ? 'main.info_id='.(int)$query['search'].' OR ' : '').
implode($op, $search) .')'; implode($op, $search) .')';
@ -841,7 +844,7 @@ class infolog_so
if ($sortbycf != '') if ($sortbycf != '')
{ {
$sort_col = "(SELECT DISTINCT info_extra_value FROM $this->extra_table sub2 WHERE sub2.info_id=main.info_id AND info_extra_name=".$this->db->quote($sortbycf).")"; $sort_col = "(SELECT DISTINCT info_extra_value FROM $this->extra_table sub2 WHERE sub2.info_id=main.info_id AND info_extra_name=".$this->db->quote($sortbycf).")";
if (!isset($custom_fields)) $custom_fields = config::get_customfields('infolog'); if (!isset($custom_fields)) $custom_fields = Api\Storage\Customfields::get('infolog');
switch($custom_fields[$sortbycf]['type']) switch($custom_fields[$sortbycf]['type'])
{ {
case 'int': case 'int':
@ -863,7 +866,7 @@ class infolog_so
$cols = isset($query['cols']) ? $query['cols'] : 'main.*'; $cols = isset($query['cols']) ? $query['cols'] : 'main.*';
if (is_array($cols)) $cols = implode(',',$cols); if (is_array($cols)) $cols = implode(',',$cols);
$rs = $this->db->query($sql='SELECT '.$mysql_calc_rows.' '.$distinct.' '.$cols.' '.$info_customfield.' '.$sql_query.$query['append'].' '.$ordermethod,__LINE__,__FILE__, $rs = $this->db->query($sql='SELECT '.$mysql_calc_rows.' '.$distinct.' '.$cols.' '.$info_customfield.' '.$sql_query.$query['append'].' '.$ordermethod,__LINE__,__FILE__,
(int) $query['start'],isset($query['start']) ? (int) $query['num_rows'] : -1,false,egw_db::FETCH_ASSOC); (int) $query['start'],isset($query['start']) ? (int) $query['num_rows'] : -1,false,Api\Db::FETCH_ASSOC);
//echo "<p>db::query('$sql',,,".(int)$query['start'].','.(isset($query['start']) ? (int) $query['num_rows'] : -1).")</p>\n"; //echo "<p>db::query('$sql',,,".(int)$query['start'].','.(isset($query['start']) ? (int) $query['num_rows'] : -1).")</p>\n";
if ($mysql_calc_rows) if ($mysql_calc_rows)
@ -887,7 +890,7 @@ class infolog_so
static $index_load_cfs = null; static $index_load_cfs = null;
if (is_null($index_load_cfs) && $query['col_filter']['info_type']) if (is_null($index_load_cfs) && $query['col_filter']['info_type'])
{ {
$config_data = config::read('infolog'); $config_data = Api\Config::read('infolog');
$index_load_cfs = $config_data['index_load_cfs']; $index_load_cfs = $config_data['index_load_cfs'];
if (!is_array($index_load_cfs)) $index_load_cfs = explode(',', $index_load_cfs); if (!is_array($index_load_cfs)) $index_load_cfs = explode(',', $index_load_cfs);
} }

View File

@ -5,15 +5,18 @@
* @link http://www.egroupware.org * @link http://www.egroupware.org
* @author Ralf Becker <RalfBecker-AT-outdoor-training.de> * @author Ralf Becker <RalfBecker-AT-outdoor-training.de>
* @package tracker * @package tracker
* @copyright (c) 2007-12 by Ralf Becker <RalfBecker-AT-outdoor-training.de> * @copyright (c) 2007-16 by Ralf Becker <RalfBecker-AT-outdoor-training.de>
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License * @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
* @version $Id$ * @version $Id$
*/ */
use EGroupware\Api;
use EGroupware\Api\Link;
/** /**
* Tracker - tracking object for the tracker * Tracker - tracking object for the tracker
*/ */
class infolog_tracking extends bo_tracking class infolog_tracking extends Api\Storage\Tracking
{ {
/** /**
* Application we are tracking (required!) * Application we are tracking (required!)
@ -176,16 +179,16 @@ class infolog_tracking extends bo_tracking
if (!$old || $old['info_status'] == 'deleted') if (!$old || $old['info_status'] == 'deleted')
{ {
return lang('New %1 created by %2 at %3',lang($this->infolog->enums['type'][$data['info_type']]), return lang('New %1 created by %2 at %3',lang($this->infolog->enums['type'][$data['info_type']]),
common::grab_owner_name($this->infolog->user),$this->datetime('now')); Api\Accounts::username($this->infolog->user),$this->datetime('now'));
} }
elseif($data['info_status'] == 'deleted') elseif($data['info_status'] == 'deleted')
{ {
return lang('%1 deleted by %2 at %3',lang($this->infolog->enums['type'][$data['info_type']]), return lang('%1 deleted by %2 at %3',lang($this->infolog->enums['type'][$data['info_type']]),
common::grab_owner_name($data['info_modifier']), Api\Accounts::username($data['info_modifier']),
$this->datetime($data['info_datemodified'])); $this->datetime($data['info_datemodified']));
} }
return lang('%1 modified by %2 at %3',lang($this->infolog->enums['type'][$data['info_type']]), return lang('%1 modified by %2 at %3',lang($this->infolog->enums['type'][$data['info_type']]),
common::grab_owner_name($data['info_modifier']), Api\Accounts::username($data['info_modifier']),
$this->datetime($data['info_datemodified'])); $this->datetime($data['info_datemodified']));
} }
@ -205,7 +208,7 @@ class infolog_tracking extends bo_tracking
{ {
foreach($data['info_responsible'] as $uid) foreach($data['info_responsible'] as $uid)
{ {
$responsible[] = common::grab_owner_name($uid); $responsible[] = Api\Accounts::username($uid);
} }
} }
if ($GLOBALS['egw_info']['user']['preferences']['infolog']['show_id']) if ($GLOBALS['egw_info']['user']['preferences']['infolog']['show_id'])
@ -218,7 +221,7 @@ class infolog_tracking extends bo_tracking
'info_addr' => $data['info_addr'], 'info_addr' => $data['info_addr'],
'info_cat' => $data['info_cat'] ? $GLOBALS['egw']->categories->id2name($data['info_cat']) : '', 'info_cat' => $data['info_cat'] ? $GLOBALS['egw']->categories->id2name($data['info_cat']) : '',
'info_priority' => lang($this->infolog->enums['priority'][$data['info_priority']]), 'info_priority' => lang($this->infolog->enums['priority'][$data['info_priority']]),
'info_owner' => common::grab_owner_name($data['info_owner']), 'info_owner' => Api\Accounts::username($data['info_owner']),
'info_status' => lang($data['info_status']=='deleted'?'deleted':$this->infolog->status[$data['info_type']][$data['info_status']]), 'info_status' => lang($data['info_status']=='deleted'?'deleted':$this->infolog->status[$data['info_type']][$data['info_status']]),
'info_percent' => (int)$data['info_percent'].'%', 'info_percent' => (int)$data['info_percent'].'%',
'info_datecompleted' => $data['info_datecompleted'] ? $this->datetime($data['info_datecompleted']) : '', 'info_datecompleted' => $data['info_datecompleted'] ? $this->datetime($data['info_datecompleted']) : '',
@ -236,7 +239,7 @@ class infolog_tracking extends bo_tracking
if (in_array($data['info_contact'],$lkeys)) if (in_array($data['info_contact'],$lkeys))
{ {
list($app,$id) = explode(':',$data['info_contact']); list($app,$id) = explode(':',$data['info_contact']);
if (!empty($app)&&!empty($id)) $value = egw_link::title($app,$id); if (!empty($app)&&!empty($id)) $value = Link::title($app,$id);
} }
} }
$details[$name] = array( $details[$name] = array(
@ -328,7 +331,7 @@ class infolog_tracking extends bo_tracking
} }
break; break;
case self::CUSTOM_NOTIFICATION: case self::CUSTOM_NOTIFICATION:
$info_config = config::read('infolog'); $info_config = Api\Config::read('infolog');
if(!$info_config[self::CUSTOM_NOTIFICATION]) if(!$info_config[self::CUSTOM_NOTIFICATION])
{ {
return ''; return '';

View File

@ -10,6 +10,13 @@
* @version $Id$ * @version $Id$
*/ */
use EGroupware\Api;
use EGroupware\Api\Link;
use EGroupware\Api\Framework;
use EGroupware\Api\Egw;
use EGroupware\Api\Acl;
use EGroupware\Api\Etemplate;
/** /**
* This class is the UI-layer (user interface) of InfoLog * This class is the UI-layer (user interface) of InfoLog
*/ */
@ -40,7 +47,7 @@ class infolog_ui
/** /**
* instance of the etemplate class * instance of the etemplate class
* *
* @var etemplate * @var Etemplate
*/ */
var $tmpl; var $tmpl;
/** /**
@ -90,17 +97,17 @@ class infolog_ui
*/ */
function __construct() function __construct()
{ {
if ($GLOBALS['egw_info']['flags']['currentapp'] != 'infolog') translation::add_app('infolog'); if ($GLOBALS['egw_info']['flags']['currentapp'] != 'infolog') Api\Translation::add_app('infolog');
// Make sure Global category is infolog - on first load, it may not be // Make sure Global category is infolog - on first load, it may not be
if($GLOBALS['egw_info']['flags']['currentapp'] == 'infolog' && !$GLOBALS['egw']->categories->app_name) if($GLOBALS['egw_info']['flags']['currentapp'] == 'infolog' && !$GLOBALS['egw']->categories->app_name)
{ {
$GLOBALS['egw']->categories = new categories(); $GLOBALS['egw']->categories = new Api\Categories();
} }
$this->bo = new infolog_bo(); $this->bo = new infolog_bo();
$this->tmpl = new etemplate_new(); $this->tmpl = new Etemplate();
$this->user = $GLOBALS['egw_info']['user']['account_id']; $this->user = $GLOBALS['egw_info']['user']['account_id'];
@ -109,7 +116,7 @@ class infolog_ui
// read the duration format from project-manager // read the duration format from project-manager
if ($GLOBALS['egw_info']['apps']['projectmanager']) if ($GLOBALS['egw_info']['apps']['projectmanager'])
{ {
$pm_config = config::read('projectmanager'); $pm_config = Api\Config::read('projectmanager');
$this->duration_format = str_replace(',','',implode('', (array)$pm_config['duration_units'])); $this->duration_format = str_replace(',','',implode('', (array)$pm_config['duration_units']));
//error_log(__METHOD__."() ".__LINE__." duration_format=$this->duration_format, duration_unit=".array2string($pm_config['duration_units'])); //error_log(__METHOD__."() ".__LINE__." duration_format=$this->duration_format, duration_unit=".array2string($pm_config['duration_units']));
$this->hours_per_workday = $pm_config['hours_per_workday']; $this->hours_per_workday = $pm_config['hours_per_workday'];
@ -135,12 +142,6 @@ class infolog_ui
} }
*/ */
$GLOBALS['infolog_ui'] =& $this; // make ourself availible for ExecMethod of get_rows function $GLOBALS['infolog_ui'] =& $this; // make ourself availible for ExecMethod of get_rows function
// can be removed for next release / infolog update
if (!$GLOBALS['egw']->hooks->hook_exists('calendar_set','infolog'))
{
$GLOBALS['egw']->hooks->register_single_app_hook('infolog','calendar_set');
}
} }
/** /**
@ -173,14 +174,14 @@ class infolog_ui
if (!isset($info['info_anz_subs'])) $info['info_anz_subs'] = $this->bo->anzSubs($id); if (!isset($info['info_anz_subs'])) $info['info_anz_subs'] = $this->bo->anzSubs($id);
$this->bo->link_id2from($info,$action,$action_id); // unset from for $action:$action_id $this->bo->link_id2from($info,$action,$action_id); // unset from for $action:$action_id
$info['info_percent'] = (int) $info['info_percent'].'%'; $info['info_percent'] = (int) $info['info_percent'].'%';
$editrights = $this->bo->check_access($info,EGW_ACL_EDIT); $editrights = $this->bo->check_access($info,Acl::EDIT);
$isresposible = $this->bo->is_responsible($info); $isresposible = $this->bo->is_responsible($info);
if ((!($editrights || // edit rights or more then standard responsible rights if ((!($editrights || // edit rights or more then standard responsible rights
$isresposible && array_diff($this->bo->responsible_edit,array('info_status','info_percent','info_datecompleted'))))) $isresposible && array_diff($this->bo->responsible_edit,array('info_status','info_percent','info_datecompleted')))))
{ {
$info['class'] .= 'rowNoEdit '; $info['class'] .= 'rowNoEdit ';
} }
if ($info['status'] == 'deleted' && !$this->bo->check_access($info, EGW_ACL_UNDELETE)) if ($info['status'] == 'deleted' && !$this->bo->check_access($info, infolog_bo::ACL_UNDELETE))
{ {
$info['class'] .= 'rowNoUndelete '; $info['class'] .= 'rowNoUndelete ';
} }
@ -195,11 +196,11 @@ class infolog_ui
{ {
$info['class'] .= 'rowNoCloseAll '; $info['class'] .= 'rowNoCloseAll ';
} }
if (!$this->bo->check_access($info,EGW_ACL_DELETE)) if (!$this->bo->check_access($info,Acl::DELETE))
{ {
$info['class'] .= 'rowNoDelete '; $info['class'] .= 'rowNoDelete ';
} }
if (!$this->bo->check_access($info,EGW_ACL_ADD)) if (!$this->bo->check_access($info,Acl::ADD))
{ {
$info['class'] .= 'rowNoSubs '; $info['class'] .= 'rowNoSubs ';
} }
@ -211,13 +212,13 @@ class infolog_ui
if (!$show_links) $show_links = $this->prefs['show_links']; if (!$show_links) $show_links = $this->prefs['show_links'];
if (($show_links != 'none' && $show_links != 'no_describtion' || if (($show_links != 'none' && $show_links != 'no_describtion' ||
$this->prefs['show_times'] || isset($GLOBALS['egw_info']['user']['apps']['timesheet'])) && $this->prefs['show_times'] || isset($GLOBALS['egw_info']['user']['apps']['timesheet'])) &&
(isset($info['links']) || ($info['links'] = egw_link::get_links('infolog',$info['info_id'],'','link_lastmod DESC',true,true)))) (isset($info['links']) || ($info['links'] = Link::get_links('infolog',$info['info_id'],'','link_lastmod DESC',true,true))))
{ {
$timesheets = array(); $timesheets = array();
foreach ($info['links'] as $link) foreach ($info['links'] as $link)
{ {
// incl. link modification time into row_mod (link's lastmod is always in server-time!) // incl. link modification time into row_mod (link's lastmod is always in server-time!)
$link_mod = egw_time::server2user($link['lastmod']); $link_mod = Api\DateTime::server2user($link['lastmod']);
if ($info['row_mod'] < $link_mod) $info['row_mod'] = $link_mod; if ($info['row_mod'] < $link_mod) $info['row_mod'] = $link_mod;
if ($link['deleted']) continue; // skip deleted links, but incl. them in row_mod! if ($link['deleted']) continue; // skip deleted links, but incl. them in row_mod!
@ -225,7 +226,7 @@ class infolog_ui
if ($show_links != 'none' && $show_links != 'no_describtion' && if ($show_links != 'none' && $show_links != 'no_describtion' &&
$link['link_id'] != $info['info_link_id'] && $link['link_id'] != $info['info_link_id'] &&
($link['app'] != $action || $link['id'] != $action_id) && ($link['app'] != $action || $link['id'] != $action_id) &&
($show_links == 'all' || ($show_links == 'links') === ($link['app'] != egw_link::VFS_APPNAME))) ($show_links == 'all' || ($show_links == 'links') === ($link['app'] != Link::VFS_APPNAME)))
{ {
$info['filelinks'][] = $link; $info['filelinks'][] = $link;
} }
@ -315,7 +316,7 @@ class infolog_ui
unset($query['col_filter']['parent_id']); unset($query['col_filter']['parent_id']);
if(!$query['action']) if(!$query['action'])
{ {
egw_cache::setSession('infolog', $query['session_for'].'session_data', $query); Api\Cache::setSession('infolog', $query['session_for'].'session_data', $query);
} }
$query['actions'] = $this->get_actions($query); $query['actions'] = $this->get_actions($query);
$query['row_id'] = 'info_id'; $query['row_id'] = 'info_id';
@ -364,7 +365,7 @@ class infolog_ui
$id = $link['id']; $id = $link['id'];
} }
if(!is_array($id)) $id = explode(',',$id); if(!is_array($id)) $id = explode(',',$id);
if (!($linked = egw_link::get_links_multiple($app,$id,true,'infolog','',$query['col_filter']['info_status'] == 'deleted'))) if (!($linked = Link::get_links_multiple($app,$id,true,'infolog','',$query['col_filter']['info_status'] == 'deleted')))
{ {
$rows = array(); // no infologs linked to selected link --> no rows to return $rows = array(); // no infologs linked to selected link --> no rows to return
return 0; return 0;
@ -378,7 +379,7 @@ class infolog_ui
$links[$key] = array_unique($links[$key]); $links[$key] = array_unique($links[$key]);
if($key == 'linked') if($key == 'linked')
{ {
$linked = array('app' => $app, 'id' => $id, 'title' => (count($id) == 1 ? egw_link::title($app, $id) : lang('multiple'))); $linked = array('app' => $app, 'id' => $id, 'title' => (count($id) == 1 ? Link::title($app, $id) : lang('multiple')));
} }
} }
if(count($links)) if(count($links))
@ -397,7 +398,7 @@ class infolog_ui
unset($query['custom_fields']); unset($query['custom_fields']);
if ($query['col_filter']['info_type']) if ($query['col_filter']['info_type'])
{ {
$tpl = new etemplate_new; $tpl = new Etemplate;
if ($tpl->read('infolog.index.rows.'.$query['col_filter']['info_type'])) if ($tpl->read('infolog.index.rows.'.$query['col_filter']['info_type']))
{ {
$query['template'] = $tpl->name; $query['template'] = $tpl->name;
@ -411,7 +412,7 @@ class infolog_ui
$clear_status_filter = true; $clear_status_filter = true;
} }
} }
// Template change forces the UI to do a full update first, no point in getting rows right now // Framework\Template change forces the UI to do a full update first, no point in getting rows right now
if($old_template && $old_template != $query['template']) return 0; if($old_template && $old_template != $query['template']) return 0;
// do we need to read the custom fields, depends on the column is enabled and customfields exist, prefs are filter specific // do we need to read the custom fields, depends on the column is enabled and customfields exist, prefs are filter specific
@ -455,7 +456,7 @@ class infolog_ui
// query all links and sub counts in one go // query all links and sub counts in one go
if ($infos && (!$query['csv_export'] || !is_array($query['csv_export']))) if ($infos && (!$query['csv_export'] || !is_array($query['csv_export'])))
{ {
$links = egw_link::get_links_multiple('infolog',array_keys($infos),true,'','link_lastmod DESC',true); // true=incl. deleted $links = Link::get_links_multiple('infolog',array_keys($infos),true,'','link_lastmod DESC',true); // true=incl. deleted
$anzSubs = $this->bo->anzSubs(array_keys($infos)); $anzSubs = $this->bo->anzSubs(array_keys($infos));
} }
$rows = array(); $rows = array();
@ -551,7 +552,7 @@ class infolog_ui
$headers[] = lang($this->filters[$query['filter']]); $headers[] = lang($this->filters[$query['filter']]);
} }
if ($query['action'] && ($title = $query['action_title'] || is_array($query['action_id']) ? if ($query['action'] && ($title = $query['action_title'] || is_array($query['action_id']) ?
$query['action_title'] : egw_link::title($query['action']=='sp'?'infolog':$query['action'],$query['action_id']))) $query['action_title'] : Link::title($query['action']=='sp'?'infolog':$query['action'],$query['action_id'])))
{ {
$headers[] = $title; $headers[] = $title;
} }
@ -581,9 +582,9 @@ class infolog_ui
{ {
if ($info['info_cat']) $set['cat_id'] = $info['info_cat']; if ($info['info_cat']) $set['cat_id'] = $info['info_cat'];
foreach(egw_link::get_links('infolog',$info['info_id'],'','link_lastmod DESC',true) as $link) foreach(Link::get_links('infolog',$info['info_id'],'','link_lastmod DESC',true) as $link)
{ {
if ($link['app'] != 'timesheet' && $link['app'] != egw_link::VFS_APPNAME) if ($link['app'] != 'timesheet' && $link['app'] != Link::VFS_APPNAME)
{ {
$set['link_app'][] = $link['app']; $set['link_app'][] = $link['app'];
$set['link_id'][] = $link['id']; $set['link_id'][] = $link['id'];
@ -607,7 +608,7 @@ class infolog_ui
return $data; return $data;
} }
$event = array_merge($data,array( $event = array_merge($data,array(
'category' => $GLOBALS['egw']->categories->check_list(EGW_ACL_READ, $infolog['info_cat']), 'category' => $GLOBALS['egw']->categories->check_list(Acl::READ, $infolog['info_cat']),
'priority' => $infolog['info_priority'] + 1, 'priority' => $infolog['info_priority'] + 1,
'public' => $infolog['info_access'] != 'private', 'public' => $infolog['info_access'] != 'private',
'title' => $infolog['info_subject'], 'title' => $infolog['info_subject'],
@ -619,8 +620,8 @@ class infolog_ui
unset($event['entry_id']); unset($event['entry_id']);
if (!$event['end']) $event['end'] = $event['start'] + (int) $GLOBALS['egw_info']['user']['preferences']['calendar']['defaultlength']*60; if (!$event['end']) $event['end'] = $event['start'] + (int) $GLOBALS['egw_info']['user']['preferences']['calendar']['defaultlength']*60;
// Match categories by name // Match Api\Categories by name
$event['category'] = $GLOBALS['egw']->categories->name2id(categories::id2name($infolog['info_cat'])); $event['category'] = $GLOBALS['egw']->categories->name2id(Api\Categories::id2name($infolog['info_cat']));
// make current user the owner of the new event, not the selected calendar, if current user has rights for it // make current user the owner of the new event, not the selected calendar, if current user has rights for it
$event['owner'] = $user = $GLOBALS['egw_info']['user']['account_id']; $event['owner'] = $user = $GLOBALS['egw_info']['user']['account_id'];
@ -665,16 +666,16 @@ class infolog_ui
$event['link_id'][] = $infolog['info_link']['id']; $event['link_id'][] = $infolog['info_link']['id'];
// Copy infolog's links // Copy infolog's links
foreach(egw_link::get_links('infolog',$infolog['info_id'],'','link_lastmod DESC',true) as $link) foreach(Link::get_links('infolog',$infolog['info_id'],'','link_lastmod DESC',true) as $link)
{ {
if ($link['app'] != egw_link::VFS_APPNAME) if ($link['app'] != Link::VFS_APPNAME)
{ {
$event['link_app'][] = $link['app']; $event['link_app'][] = $link['app'];
$event['link_id'][] = $link['id']; $event['link_id'][] = $link['id'];
} }
} }
// Copy same custom fields // Copy same custom fields
foreach(array_keys(config::get_customfields('calendar')) as $name) foreach(array_keys(Api\Storage\Customfields::get('calendar')) as $name)
{ {
if ($this->bo->customfields[$name]) $event['#'.$name] = $infolog['#'.$name]; if ($this->bo->customfields[$name]) $event['#'.$name] = $infolog['#'.$name];
} }
@ -706,11 +707,11 @@ class infolog_ui
$own_referer = common::get_referer(); $own_referer = common::get_referer();
if (strpos($own_referer,'menuaction=infolog.infolog_ui.edit') !== false) if (strpos($own_referer,'menuaction=infolog.infolog_ui.edit') !== false)
{ {
$own_referer = $GLOBALS['egw']->session->appsession('own_session','infolog'); $own_referer = Api\Cache::getSession('infolog', 'own_session');
} }
else else
{ {
$GLOBALS['egw']->session->appsession('own_session','infolog',$own_referer); Api\Cache::setSession('infolog', 'own_session', $own_referer);
} }
} }
@ -768,17 +769,17 @@ class infolog_ui
$success, $failed, $action_msg, $values['nm'], $msg, $values['nm']['checkboxes']['no_notifications'])) $success, $failed, $action_msg, $values['nm'], $msg, $values['nm']['checkboxes']['no_notifications']))
{ {
$msg .= lang('%1 entries %2',$success,$action_msg); $msg .= lang('%1 entries %2',$success,$action_msg);
egw_framework::message($msg); Framework::message($msg);
} }
elseif(is_null($msg)) elseif(is_null($msg))
{ {
$msg .= lang('%1 entries %2, %3 failed because of insufficent rights !!!',$success,$action_msg,$failed); $msg .= lang('%1 entries %2, %3 failed because of insufficent rights !!!',$success,$action_msg,$failed);
egw_framework::message($msg,'error'); Framework::message($msg,'error');
} }
elseif($msg) elseif($msg)
{ {
$msg .= "\n".lang('%1 entries %2, %3 failed.',$success,$action_msg,$failed); $msg .= "\n".lang('%1 entries %2, %3 failed.',$success,$action_msg,$failed);
egw_framework::message($msg,'error'); Framework::message($msg,'error');
} }
unset($values['nm']['multi_action']); unset($values['nm']['multi_action']);
unset($values['nm']['select_all']); unset($values['nm']['select_all']);
@ -793,7 +794,7 @@ class infolog_ui
//echo "<p>".__METHOD__."(action='$action/$action_id',called_as='$called_as/$values[referer]',own_referer='$own_referer') values=\n"; _debug_array($values); //echo "<p>".__METHOD__."(action='$action/$action_id',called_as='$called_as/$values[referer]',own_referer='$own_referer') values=\n"; _debug_array($values);
if (!is_array($values)) if (!is_array($values))
{ {
$nm = egw_cache::getSession('infolog', $this->called_by.'session_data'); $nm = Api\Cache::getSession('infolog', $this->called_by.'session_data');
unset($nm['rows']); unset($nm['rows']);
if ($values === 'reset_action_view') if ($values === 'reset_action_view')
{ {
@ -807,10 +808,10 @@ class infolog_ui
$nm['action_id'] = 0; $nm['action_id'] = 0;
$nm['action_title'] = ''; $nm['action_title'] = '';
// check if action-view reset filter and restore it // check if action-view reset filter and restore it
if (($filter = egw_cache::getSession('infolog', 'filter_reset_from'))) if (($filter = Api\Cache::getSession('infolog', 'filter_reset_from')))
{ {
$nm['filter'] = $filter; $nm['filter'] = $filter;
egw_cache::unsetSession('infolog', 'filter_reset_from'); Api\Cache::unsetSession('infolog', 'filter_reset_from');
} }
} }
$values = array('nm' => $nm); $values = array('nm' => $nm);
@ -852,7 +853,7 @@ class infolog_ui
{ {
unset($values['nm']['multi_action']); unset($values['nm']['multi_action']);
unset($values['nm']['action_id']); unset($values['nm']['action_id']);
egw_cache::setSession('infolog', $values['nm']['session_for'].'session_data', $values['nm']); Api\Cache::setSession('infolog', $values['nm']['session_for'].'session_data', $values['nm']);
$this->tmpl->location($own_referer); $this->tmpl->location($own_referer);
} }
else else
@ -1018,7 +1019,7 @@ class infolog_ui
// remove types owned by groups the user has no edit grant // remove types owned by groups the user has no edit grant
foreach($this->bo->group_owners as $type => $group) foreach($this->bo->group_owners as $type => $group)
{ {
if (!($this->bo->grants[$group] & EGW_ACL_EDIT)) if (!($this->bo->grants[$group] & Acl::EDIT))
{ {
unset($types[$type]); unset($types[$type]);
} }
@ -1046,7 +1047,7 @@ class infolog_ui
unset($types['delete']); unset($types['delete']);
foreach($types as $type => &$data) foreach($types as $type => &$data)
{ {
$image_exists = common::image('infolog',$type); $image_exists = Api\Image::find('infolog',$type);
$data = array( $data = array(
'caption' => $data, 'caption' => $data,
'icon' => $image_exists ? $type : 'infolog/navbar', 'icon' => $image_exists ? $type : 'infolog/navbar',
@ -1060,7 +1061,7 @@ class infolog_ui
$statis = $this->bo->get_status($query['col_filter']['info_type'], $icons); $statis = $this->bo->get_status($query['col_filter']['info_type'], $icons);
foreach($statis as $type => &$data) foreach($statis as $type => &$data)
{ {
$image_exists = common::image('infolog',$icons[$type]); $image_exists = Api\Image::find('infolog',$icons[$type]);
$data = array( $data = array(
'caption' => $data, 'caption' => $data,
'icon' => $image_exists ? $icons[$type] : 'infolog/status', 'icon' => $image_exists ? $icons[$type] : 'infolog/status',
@ -1072,9 +1073,9 @@ class infolog_ui
'caption' => 'Open', 'caption' => 'Open',
'default' => true, 'default' => true,
'allowOnMultiple' => false, 'allowOnMultiple' => false,
'onExecute' => html::$ua_mobile?'javaScript:app.infolog.viewEntry':'', 'onExecute' => Api\Header\UserAgent::mobile()?'javaScript:app.infolog.viewEntry':'',
'url' => 'menuaction=infolog.infolog_ui.edit&info_id=$id', 'url' => 'menuaction=infolog.infolog_ui.edit&info_id=$id',
'popup' => egw_link::get_registry('infolog', 'add_popup'), 'popup' => Link::get_registry('infolog', 'add_popup'),
'group' => $group=1, 'group' => $group=1,
), ),
'parent' => array( 'parent' => array(
@ -1098,7 +1099,7 @@ class infolog_ui
'sub' => array( 'sub' => array(
'caption' => 'Sub-entry', 'caption' => 'Sub-entry',
'url' => 'menuaction=infolog.infolog_ui.edit&action=sp&action_id=$id', 'url' => 'menuaction=infolog.infolog_ui.edit&action=sp&action_id=$id',
'popup' => egw_link::get_registry('infolog', 'add_popup'), 'popup' => Link::get_registry('infolog', 'add_popup'),
'allowOnMultiple' => false, 'allowOnMultiple' => false,
'hint' => 'Add a new sub-task, -note, -call to this entry', 'hint' => 'Add a new sub-task, -note, -call to this entry',
'icon' => 'new', 'icon' => 'new',
@ -1106,7 +1107,7 @@ class infolog_ui
'copy' => array( 'copy' => array(
'caption' => 'Copy', 'caption' => 'Copy',
'url' => 'menuaction=infolog.infolog_ui.edit&action=copy&info_id=$id', 'url' => 'menuaction=infolog.infolog_ui.edit&action=copy&info_id=$id',
'popup' => egw_link::get_registry('infolog', 'add_popup'), 'popup' => Link::get_registry('infolog', 'add_popup'),
'allowOnMultiple' => false, 'allowOnMultiple' => false,
'icon' => 'copy', 'icon' => 'copy',
), ),
@ -1147,7 +1148,7 @@ class infolog_ui
'group' => $group, 'group' => $group,
'icon' => 'completed', 'icon' => 'completed',
), ),
'cat' => nextmatch_widget::category_action( 'cat' => Etemplate\Widget\Nextmatch::category_action(
'infolog',$group,'Change category','cat_' 'infolog',$group,'Change category','cat_'
), ),
'responsible' => array( 'responsible' => array(
@ -1203,9 +1204,9 @@ class infolog_ui
'caption' => 'Schedule appointment', 'caption' => 'Schedule appointment',
'group' => $group, 'group' => $group,
'url' => 'menuaction=calendar.calendar_uiforms.edit&'. 'url' => 'menuaction=calendar.calendar_uiforms.edit&'.
egw_link::get_registry('calendar', 'add_app') . '[]=infolog&'.egw_link::get_registry('calendar','add_id').'[]=$id', Link::get_registry('calendar', 'add_app') . '[]=infolog&'.Link::get_registry('calendar','add_id').'[]=$id',
'allowOnMultiple' => false, 'allowOnMultiple' => false,
'popup' => egw_link::get_registry('calendar', 'add_popup'), 'popup' => Link::get_registry('calendar', 'add_popup'),
); );
} }
if ($GLOBALS['egw_info']['user']['apps']['timesheet']) if ($GLOBALS['egw_info']['user']['apps']['timesheet'])
@ -1216,7 +1217,7 @@ class infolog_ui
'url' => 'menuaction=timesheet.timesheet_ui.edit&link_app[]=infolog&link_id[]=$id', 'url' => 'menuaction=timesheet.timesheet_ui.edit&link_app[]=infolog&link_id[]=$id',
'group' => $group, 'group' => $group,
'allowOnMultiple' => false, 'allowOnMultiple' => false,
'popup' => egw_link::get_registry('timesheet', 'add_popup'), 'popup' => Link::get_registry('timesheet', 'add_popup'),
); );
} }
if ($GLOBALS['egw_info']['user']['apps']['tracker']) if ($GLOBALS['egw_info']['user']['apps']['tracker'])
@ -1227,9 +1228,9 @@ class infolog_ui
'hint' => 'Convert to a ticket', 'hint' => 'Convert to a ticket',
'group' => $group, 'group' => $group,
'url' => 'menuaction=tracker.tracker_ui.edit&'. 'url' => 'menuaction=tracker.tracker_ui.edit&'.
egw_link::get_registry('tracker', 'add_app') . '[]=infolog&'.egw_link::get_registry('tracker','add_id').'[]=$id', Link::get_registry('tracker', 'add_app') . '[]=infolog&'.Link::get_registry('tracker','add_id').'[]=$id',
'allowOnMultiple' => false, 'allowOnMultiple' => false,
'popup' => egw_link::get_registry('tracker', 'add_popup'), 'popup' => Link::get_registry('tracker', 'add_popup'),
); );
} }
@ -1322,10 +1323,10 @@ class infolog_ui
$msg = lang('You need to select an entry for linking.'); $msg = lang('You need to select an entry for linking.');
break; break;
} }
$title = egw_link::title($app, $link_id); $title = Link::title($app, $link_id);
foreach($checked as $id) foreach($checked as $id)
{ {
if(!$this->bo->check_access($id, EGW_ACL_EDIT)) if(!$this->bo->check_access($id, Acl::EDIT))
{ {
$failed++; $failed++;
continue; continue;
@ -1333,7 +1334,7 @@ class infolog_ui
if($add_remove == 'add') if($add_remove == 'add')
{ {
$action_msg = lang('linked to %1', $title); $action_msg = lang('linked to %1', $title);
if(egw_link::link('infolog', $id, $app, $link_id)) if(Link::link('infolog', $id, $app, $link_id))
{ {
$success++; $success++;
} }
@ -1345,7 +1346,7 @@ class infolog_ui
else else
{ {
$action_msg = lang('unlinked from %1', $title); $action_msg = lang('unlinked from %1', $title);
$count = egw_link::unlink(0, 'infolog', $id, '', $app, $link_id); $count = Link::unlink(0, 'infolog', $id, '', $app, $link_id);
$success += $count; $success += $count;
} }
} }
@ -1360,9 +1361,9 @@ class infolog_ui
case 'ical': case 'ical':
// infolog_ical lets horde be auto-loaded, so it must go first // infolog_ical lets horde be auto-loaded, so it must go first
$boical = new infolog_ical(); $boical = new infolog_ical();
html::content_header('todo.ics','text/calendar'); Api\Header\Content::type('todo.ics','text/calendar');
echo $boical->exportvCalendar($checked); echo $boical->exportvCalendar($checked);
common::egw_exit(); exit();
} }
@ -1397,7 +1398,7 @@ class infolog_ui
case 'type': case 'type':
$action_msg = lang('changed type'); $action_msg = lang('changed type');
// Dont allow to change the type, if user has no delete rights from the group-owner // Dont allow to change the type, if user has no delete rights from the group-owner
if ($id && !($this->bo->grants[$entry['info_owner']] & EGW_ACL_DELETE)) if ($id && !($this->bo->grants[$entry['info_owner']] & Acl::DELETE))
{ {
$failed++; $failed++;
break; break;
@ -1406,7 +1407,7 @@ class infolog_ui
try { try {
$this->bo->write($entry, true,true,true,$skip_notifications,true); // Throw exceptions $this->bo->write($entry, true,true,true,$skip_notifications,true); // Throw exceptions
} }
catch (egw_exception_wrong_userinput $e) catch (Api\Exception\WrongUserinput $e)
{ {
$msg .= "\n".$e->getMessage(); $msg .= "\n".$e->getMessage();
$failed++; $failed++;
@ -1475,7 +1476,7 @@ class infolog_ui
case 'cat': case 'cat':
if($settings) if($settings)
{ {
$cat_name = categories::id2name($settings); $cat_name = Api\Categories::id2name($settings);
$action_msg = lang('changed category to %1', $cat_name); $action_msg = lang('changed category to %1', $cat_name);
} }
else else
@ -1500,7 +1501,7 @@ class infolog_ui
$users = explode(',', $user_str); $users = explode(',', $user_str);
foreach($users as $account_id) foreach($users as $account_id)
{ {
$names[] = common::grab_owner_name($account_id); $names[] = Api\Accounts::username($account_id);
} }
$action_msg .= implode(', ', $names); $action_msg .= implode(', ', $names);
$function = $add_remove == 'add' ? 'array_merge' : 'array_diff'; $function = $add_remove == 'add' ? 'array_merge' : 'array_diff';
@ -1590,7 +1591,7 @@ class infolog_ui
if (is_array($values) || $info_id <= 0) if (is_array($values) || $info_id <= 0)
{ {
if (($values['delete'] || $values['delete_subs']) && $info_id > 0 && $this->bo->check_access($info_id,EGW_ACL_DELETE)) if (($values['delete'] || $values['delete_subs']) && $info_id > 0 && $this->bo->check_access($info_id,Acl::DELETE))
{ {
$deleted = $this->bo->delete($info_id,$values['delete_subs'],$values['info_id_parent'], $skip_notification); $deleted = $this->bo->delete($info_id,$values['delete_subs'],$values['info_id_parent'], $skip_notification);
} }
@ -1677,7 +1678,7 @@ class infolog_ui
if (in_array($button,array('copy','schedule','ical','tracker'))) if (in_array($button,array('copy','schedule','ical','tracker')))
{ {
$action = $button; $action = $button;
if (!$info_id || $this->bo->check_access($info_id,EGW_ACL_EDIT)) if (!$info_id || $this->bo->check_access($info_id,Acl::EDIT))
{ {
$button = 'apply'; // need to store infolog first $button = 'apply'; // need to store infolog first
} }
@ -1701,10 +1702,10 @@ class infolog_ui
if (($button == 'save' || $button == 'apply') && $info_id) if (($button == 'save' || $button == 'apply') && $info_id)
{ {
$old = $this->bo->read($info_id); $old = $this->bo->read($info_id);
if (!($edit_acl = $this->bo->check_access($info_id,EGW_ACL_EDIT))) if (!($edit_acl = $this->bo->check_access($info_id,Acl::EDIT)))
{ {
$status_only = $this->bo->is_responsible($old); $status_only = $this->bo->is_responsible($old);
$undelete = $this->bo->check_access($old,EGW_ACL_UNDELETE); $undelete = $this->bo->check_access($old,infolog_bo::ACL_UNDELETE);
} }
} }
if (($button == 'save' || $button == 'apply') && (!$info_id || $edit_acl || $status_only || $undelete)) if (($button == 'save' || $button == 'apply') && (!$info_id || $edit_acl || $status_only || $undelete))
@ -1730,7 +1731,7 @@ class infolog_ui
{ {
$content['link_to'] = array(); $content['link_to'] = array();
} }
$content['info_link_id'] = (int)($info_link_id = egw_link::link('infolog',$content['link_to']['to_id'],$app,$id)); $content['info_link_id'] = (int)($info_link_id = Link::link('infolog',$content['link_to']['to_id'],$app,$id));
} }
else else
{ {
@ -1738,13 +1739,13 @@ class infolog_ui
} }
if ($old_link_id && $old_link_id != $content['info_link_id']) if ($old_link_id && $old_link_id != $content['info_link_id'])
{ {
$link = egw_link::get_link($old_link_id); $link = Link::get_link($old_link_id);
// remove selected project, if removed link is that project // remove selected project, if removed link is that project
if($link['link_app2'] == 'projectmanager' && $link['link_id2'] == $content['old_pm_id']) if($link['link_app2'] == 'projectmanager' && $link['link_id2'] == $content['old_pm_id'])
{ {
unset($content['pm_id'], $content['old_pm_id']); unset($content['pm_id'], $content['old_pm_id']);
} }
egw_link::unlink($old_link_id); Link::unlink($old_link_id);
} }
// if added link is a project and no other project selected, also add as project // if added link is a project and no other project selected, also add as project
if ($app == 'projectmanager' && $id && !$content['pm_id']) if ($app == 'projectmanager' && $id && !$content['pm_id'])
@ -1762,7 +1763,7 @@ class infolog_ui
$content['msg'] = $info_id !== 0 || !$content['info_id'] ? lang('Error: saving the entry') : $content['msg'] = $info_id !== 0 || !$content['info_id'] ? lang('Error: saving the entry') :
lang('Error: the entry has been updated since you opened it for editing!').'<br />'. lang('Error: the entry has been updated since you opened it for editing!').'<br />'.
lang('Copy your changes to the clipboard, %1reload the entry%2 and merge them.','<a href="'. lang('Copy your changes to the clipboard, %1reload the entry%2 and merge them.','<a href="'.
htmlspecialchars(egw::link('/index.php',array( htmlspecialchars(Egw::link('/index.php',array(
'menuaction' => 'infolog.infolog_ui.edit', 'menuaction' => 'infolog.infolog_ui.edit',
'info_id' => $content['info_id'], 'info_id' => $content['info_id'],
'no_popup' => $no_popup, 'no_popup' => $no_popup,
@ -1776,7 +1777,7 @@ class infolog_ui
$GLOBALS['egw']->preferences->add('infolog','preferred_type',$content['info_type']); $GLOBALS['egw']->preferences->add('infolog','preferred_type',$content['info_type']);
$GLOBALS['egw']->preferences->save_repository(false,'user',false); $GLOBALS['egw']->preferences->save_repository(false,'user',false);
$content['msg'] = lang('InfoLog entry saved'); $content['msg'] = lang('InfoLog entry saved');
egw_framework::refresh_opener($content['msg'],'infolog',$info_id,$operation); Framework::refresh_opener($content['msg'],'infolog',$info_id,$operation);
} }
$content['tabs'] = $active_tab; $content['tabs'] = $active_tab;
if ((int) $content['pm_id'] != (int) $content['old_pm_id']) if ((int) $content['pm_id'] != (int) $content['old_pm_id'])
@ -1786,7 +1787,7 @@ class infolog_ui
if ($content['pm_id']) if ($content['pm_id'])
{ {
//echo "<p>this->link->link('infolog',{$content['link_to']['to_id']},'projectmanager',{$content['pm_id']});</p>"; //echo "<p>this->link->link('infolog',{$content['link_to']['to_id']},'projectmanager',{$content['pm_id']});</p>";
egw_link::link('infolog',$content['link_to']['to_id'],'projectmanager',$content['pm_id']); Link::link('infolog',$content['link_to']['to_id'],'projectmanager',$content['pm_id']);
// making the project the selected link, if no other link selected // making the project the selected link, if no other link selected
if (!$info_link_id || $info_link_id == 'projectmanager:'.$content['old_pm_id']) if (!$info_link_id || $info_link_id == 'projectmanager:'.$content['old_pm_id'])
{ {
@ -1796,7 +1797,7 @@ class infolog_ui
if ($content['old_pm_id']) if ($content['old_pm_id'])
{ {
//echo "<p>this->link->unlink2(0,infolog,{$content['link_to']['to_id']},0,'projectmanager',{$content['old_pm_id']});</p>\n"; //echo "<p>this->link->unlink2(0,infolog,{$content['link_to']['to_id']},0,'projectmanager',{$content['old_pm_id']});</p>\n";
egw_link::unlink2(0,infolog,$content['link_to']['to_id'],0,'projectmanager',$content['old_pm_id']); Link::unlink2(0,infolog,$content['link_to']['to_id'],0,'projectmanager',$content['old_pm_id']);
} }
$content['old_pm_id'] = $content['pm_id']; $content['old_pm_id'] = $content['pm_id'];
} }
@ -1804,13 +1805,13 @@ class infolog_ui
if ($info_id && is_array($content['link_to']['to_id']) && count($content['link_to']['to_id'])) if ($info_id && is_array($content['link_to']['to_id']) && count($content['link_to']['to_id']))
{ {
//echo "<p>writing links for new entry $info_id</p>\n"; _debug_array($content['link_to']['to_id']); //echo "<p>writing links for new entry $info_id</p>\n"; _debug_array($content['link_to']['to_id']);
egw_link::link('infolog',$info_id,$content['link_to']['to_id']); Link::link('infolog',$info_id,$content['link_to']['to_id']);
$content['link_to']['to_id'] = $info_id; $content['link_to']['to_id'] = $info_id;
} }
if ($info_link_id && strpos($info_link_id,':') !== false) // updating info_link_id if necessary if ($info_link_id && strpos($info_link_id,':') !== false) // updating info_link_id if necessary
{ {
list($app,$id) = explode(':',$info_link_id); list($app,$id) = explode(':',$info_link_id);
$link = egw_link::get_link('infolog',$info_id,$app,$id); $link = Link::get_link('infolog',$info_id,$app,$id);
if ((int) $content['info_link_id'] != (int) $link['link_id']) if ((int) $content['info_link_id'] != (int) $link['link_id'])
{ {
$content['info_link_id'] = $link['link_id']; $content['info_link_id'] = $link['link_id'];
@ -1838,20 +1839,20 @@ class infolog_ui
); );
if (!($content['msg'] = $this->delete($info_id,$referer,'edit'))) return; // checks ACL first if (!($content['msg'] = $this->delete($info_id,$referer,'edit'))) return; // checks ACL first
egw_framework::refresh_opener($content['msg'],'infolog',$info_id,'delete'); Framework::refresh_opener($content['msg'],'infolog',$info_id,'delete');
} }
// called again after delete confirmation dialog // called again after delete confirmation dialog
elseif ($button == 'deleted' && $content['msg']) elseif ($button == 'deleted' && $content['msg'])
{ {
egw_framework::refresh_opener($content['msg'],'infolog',$info_id,'delete'); Framework::refresh_opener($content['msg'],'infolog',$info_id,'delete');
} }
if ($button == 'save' || $button == 'cancel' || $button == 'delete' || $button == 'deleted') if ($button == 'save' || $button == 'cancel' || $button == 'delete' || $button == 'deleted')
{ {
if ($no_popup) if ($no_popup)
{ {
egw::redirect_link($referer,array('msg' => $content['msg'])); Egw::redirect_link($referer,array('msg' => $content['msg']));
} }
egw_framework::window_close(); Framework::window_close();
} }
} }
// on a type-change, set the status to the default status of that type, if the actual status is not supported by the new type // on a type-change, set the status to the default status of that type, if the actual status is not supported by the new type
@ -1915,7 +1916,7 @@ class infolog_ui
// set blank behind all , and . if words are too long, apply wordwrap afterwards to make sure we get // set blank behind all , and . if words are too long, apply wordwrap afterwards to make sure we get
if (strlen($word)>75) if (strlen($word)>75)
{ {
$buff = html::activate_links($word); $buff = Api\Html::activate_links($word);
if (strlen($buff) == strlen($word)) // no links -> try to break overlong words if (strlen($buff) == strlen($word)) // no links -> try to break overlong words
{ {
if (!(strpos($word,',')===false) && strpos($word,', ')===false) $word = str_replace(',',', ',$word); if (!(strpos($word,',')===false) && strpos($word,', ')===false) $word = str_replace(',',', ',$word);
@ -1948,21 +1949,21 @@ class infolog_ui
case 'datetime': $set_startdate = $this->bo->user_time_now; break; case 'datetime': $set_startdate = $this->bo->user_time_now; break;
case 'empty': $set_startdate = 0; break; case 'empty': $set_startdate = 0; break;
} }
if ((int)$content['info_link_id'] > 0 && !egw_link::get_link($content['info_link_id'])) if ((int)$content['info_link_id'] > 0 && !Link::get_link($content['info_link_id']))
{ {
$content['info_link_id'] = 0; // link has been deleted $content['info_link_id'] = 0; // link has been deleted
if (!$content['info_custom_link']) $content['info_from'] = ''; if (!$content['info_custom_link']) $content['info_from'] = '';
} }
if (!$info_id && $action_id && $action == 'sp') // new SubProject if (!$info_id && $action_id && $action == 'sp') // new SubProject
{ {
if (!$this->bo->check_access($action_id,EGW_ACL_ADD)) if (!$this->bo->check_access($action_id,Acl::ADD))
{ {
return $referer ? $this->tmpl->location($referer) : $this->index(0,$action,$action_id); return $referer ? $this->tmpl->location($referer) : $this->index(0,$action,$action_id);
} }
} }
else else
{ {
$undelete = $this->bo->check_access($info_id,EGW_ACL_UNDELETE); $undelete = $this->bo->check_access($info_id,infolog_bo::ACL_UNDELETE);
} }
$content['links'] = $content['link_to'] = array( $content['links'] = $content['link_to'] = array(
'to_id' => $info_id, 'to_id' => $info_id,
@ -1975,7 +1976,7 @@ class infolog_ui
switch ($action) switch ($action)
{ {
case 'schedule': case 'schedule':
egw::redirect_link('/index.php',array( Egw::redirect_link('/index.php',array(
'menuaction' => 'calendar.calendar_uiforms.edit', 'menuaction' => 'calendar.calendar_uiforms.edit',
'link_app' => 'infolog', 'link_app' => 'infolog',
'link_id' => $info_id, 'link_id' => $info_id,
@ -1984,9 +1985,9 @@ class infolog_ui
case 'ical': case 'ical':
$boical = new infolog_ical(); $boical = new infolog_ical();
$result = $boical->exportVTODO($content,'2.0','PUBLISH',false); $result = $boical->exportVTODO($content,'2.0','PUBLISH',false);
html::content_header('todo.ics', 'text/calendar'); Api\Header\Content::type('todo.ics', 'text/calendar');
echo $result; echo $result;
common::egw_exit(); exit();
case 'sp': case 'sp':
case 'copy': case 'copy':
$info_id = 0; $info_id = 0;
@ -1999,16 +2000,16 @@ class infolog_ui
unset($action); // it get stored in $content and will cause an other copy after [apply] unset($action); // it get stored in $content and will cause an other copy after [apply]
break; break;
case 'to_tracker': case 'to_tracker':
egw::redirect_link('/index.php',array( Egw::redirect_link('/index.php',array(
'menuaction' => 'tracker.tracker_ui.edit', 'menuaction' => 'tracker.tracker_ui.edit',
egw_link::get_registry('tracker', 'add_app').'[]' => 'infolog', Link::get_registry('tracker', 'add_app').'[]' => 'infolog',
egw_link::get_registry('tracker','add_id').'[]' => $info_id, Link::get_registry('tracker','add_id').'[]' => $info_id,
)); ));
break; break;
case 'projectmanager': case 'projectmanager':
$pm_links = array($action_id); $pm_links = array($action_id);
default: // to allow other apps to participate default: // to allow other apps to participate
$content['info_subject'] = egw_link::title($action, $id); $content['info_subject'] = Link::title($action, $id);
$action_ids = explode(',',$action_id); $action_ids = explode(',',$action_id);
if(count($action_ids) == 1) if(count($action_ids) == 1)
{ {
@ -2016,14 +2017,14 @@ class infolog_ui
} }
foreach ($action_ids as $n => $id) foreach ($action_ids as $n => $id)
{ {
egw_link::link('infolog', $content['link_to']['to_id'], $action, $id); Link::link('infolog', $content['link_to']['to_id'], $action, $id);
// calling "infolog_set" hook for first, in case app wants to set some more values // calling "infolog_set" hook for first, in case app wants to set some more values
if (!$n && ($set = $GLOBALS['egw']->hooks->single(array('location'=>'infolog_set','id'=>$action_id),$action))) if (!$n && ($set = Api\Hooks::single(array('location'=>'infolog_set','id'=>$action_id),$action)))
{ {
foreach((array)$set['link_app'] as $i => $l_app) foreach((array)$set['link_app'] as $i => $l_app)
{ {
if (($l_id=$set['link_id'][$i])) egw_link::link('infolog',$content['link_to']['to_id'],$l_app,$l_id); if (($l_id=$set['link_id'][$i])) Link::link('infolog',$content['link_to']['to_id'],$l_app,$l_id);
} }
unset($set['link_app']); unset($set['link_app']);
unset($set['link_id']); unset($set['link_id']);
@ -2037,7 +2038,7 @@ class infolog_ui
{ {
if (!isset($pm_links)) if (!isset($pm_links))
{ {
$pm_links = egw_link::get_links('infolog',$info_id,'projectmanager'); $pm_links = Link::get_links('infolog',$info_id,'projectmanager');
} }
break; // normal edit break; // normal edit
} }
@ -2069,7 +2070,7 @@ class infolog_ui
// remove types owned by groups the user has no edit grant (current type is made readonly) // remove types owned by groups the user has no edit grant (current type is made readonly)
foreach($this->bo->group_owners as $type => $group) foreach($this->bo->group_owners as $type => $group)
{ {
if (!($this->bo->grants[$group] & EGW_ACL_EDIT)) if (!($this->bo->grants[$group] & Acl::EDIT))
{ {
if ($type == $content['info_type']) if ($type == $content['info_type'])
{ {
@ -2087,7 +2088,7 @@ class infolog_ui
{ {
$content['info_owner'] = $this->bo->group_owners[$content['info_type']]; $content['info_owner'] = $this->bo->group_owners[$content['info_type']];
// Dont allow to change the type, if user has no delete rights from the group-owner // Dont allow to change the type, if user has no delete rights from the group-owner
if ($info_id && !($this->bo->grants[$content['info_owner']] & EGW_ACL_DELETE)) if ($info_id && !($this->bo->grants[$content['info_owner']] & Acl::DELETE))
{ {
//echo "<p>setting type to r/o as user has no delete rights from group #$group</p>\n"; //echo "<p>setting type to r/o as user has no delete rights from group #$group</p>\n";
$readonlys['info_type'] = true; $readonlys['info_type'] = true;
@ -2107,7 +2108,7 @@ class infolog_ui
unset($preserv['links']); unset($preserv['link_to']); unset($preserv['links']); unset($preserv['link_to']);
// for no edit rights or implizit edit of responsible user make all fields readonly, but status and percent // for no edit rights or implizit edit of responsible user make all fields readonly, but status and percent
if ($info_id && !$this->bo->check_access($info_id,EGW_ACL_EDIT) && !$undelete) if ($info_id && !$this->bo->check_access($info_id,Acl::EDIT) && !$undelete)
{ {
$readonlys['__ALL__'] = true; // make all fields not explicitly set readonly $readonlys['__ALL__'] = true; // make all fields not explicitly set readonly
if ($this->bo->is_responsible($content)) if ($this->bo->is_responsible($content))
@ -2131,7 +2132,7 @@ class infolog_ui
$this->tmpl->setElementAttribute('button[save]', 'label', 'Un-Delete'); $this->tmpl->setElementAttribute('button[save]', 'label', 'Un-Delete');
} }
if (!($readonlys['button[delete]'] = !$info_id || !$this->bo->check_access($info_id,EGW_ACL_DELETE))) if (!($readonlys['button[delete]'] = !$info_id || !$this->bo->check_access($info_id,Acl::DELETE)))
{ {
$content['info_anz_subs'] = $this->bo->anzSubs($info_id); // to determine js confirmation of delete or not $content['info_anz_subs'] = $this->bo->anzSubs($info_id); // to determine js confirmation of delete or not
} }
@ -2303,16 +2304,16 @@ class infolog_ui
// Get links to be copied, if not excluded // Get links to be copied, if not excluded
if (!in_array('link_to',$exclude_fields) || !in_array('attachments',$exclude_fields)) if (!in_array('link_to',$exclude_fields) || !in_array('attachments',$exclude_fields))
{ {
foreach(egw_link::get_links($content['link_to']['to_app'], $info_id) as $link) foreach(Link::get_links($content['link_to']['to_app'], $info_id) as $link)
{ {
if ($link['app'] != egw_link::VFS_APPNAME && !in_array('link_to', $exclude_fields)) if ($link['app'] != Link::VFS_APPNAME && !in_array('link_to', $exclude_fields))
{ {
egw_link::link('infolog', $content['link_to']['to_id'], $link['app'], $link['id'], $link['remark']); Link::link('infolog', $content['link_to']['to_id'], $link['app'], $link['id'], $link['remark']);
} }
elseif ($link['app'] == egw_link::VFS_APPNAME && !in_array('attachments', $exclude_fields)) elseif ($link['app'] == Link::VFS_APPNAME && !in_array('attachments', $exclude_fields))
{ {
egw_link::link('infolog', $content['link_to']['to_id'], egw_link::VFS_APPNAME, array( Link::link('infolog', $content['link_to']['to_id'], Link::VFS_APPNAME, array(
'tmp_name' => egw_link::vfs_path($link['app2'], $link['id2']).'/'.$link['id'], 'tmp_name' => Link::vfs_path($link['app2'], $link['id2']).'/'.$link['id'],
'name' => $link['id'], 'name' => $link['id'],
), $link['remark']); ), $link['remark']);
} }
@ -2326,19 +2327,19 @@ class infolog_ui
// we need this if copy is triggered via context menu action // we need this if copy is triggered via context menu action
if (!isset($content['info_contact']) || empty($content['info_contact']) || $content['info_contact'] === 'copy:') if (!isset($content['info_contact']) || empty($content['info_contact']) || $content['info_contact'] === 'copy:')
{ {
$linkinfos = egw_link::get_link($info_link_id); $linkinfos = Link::get_link($info_link_id);
$content['info_contact'] = $linkinfos['link_app1']=='infolog'? $linkinfos['link_app2'].':'.$linkinfos['link_id2']:$linkinfos['link_app1'].':'.$linkinfos['link_id1']; $content['info_contact'] = $linkinfos['link_app1']=='infolog'? $linkinfos['link_app2'].':'.$linkinfos['link_id2']:$linkinfos['link_app1'].':'.$linkinfos['link_id1'];
if (stripos($content['info_contact'],'projectmanager')!==false) $content['pm_id'] = $linkinfos['link_app1']=='projectmanager'? $linkinfos['link_id1']:$linkinfos['link_id2']; if (stripos($content['info_contact'],'projectmanager')!==false) $content['pm_id'] = $linkinfos['link_app1']=='projectmanager'? $linkinfos['link_id1']:$linkinfos['link_id2'];
} }
unset($content['info_link_id']); unset($content['info_link_id']);
} }
$content['info_owner'] = !(int)$this->owner || !$this->bo->check_perms(EGW_ACL_ADD,0,$this->owner) ? $this->user : $this->owner; $content['info_owner'] = !(int)$this->owner || !$this->bo->check_perms(Acl::ADD,0,$this->owner) ? $this->user : $this->owner;
if (!empty($content['info_subject'])) if (!empty($content['info_subject']))
{ {
if ($create_sub) if ($create_sub)
{ {
$config = config::read('infolog'); $config = Api\Config::read('infolog');
$prefix = lang(empty($config['sub_prefix']) ? 'Re:': $config['sub_prefix']); $prefix = lang(empty($config['sub_prefix']) ? 'Re:': $config['sub_prefix']);
} }
else else
@ -2370,7 +2371,7 @@ class infolog_ui
$alt = $id; $alt = $id;
} }
} }
return $icon ? html::image('infolog',$icon,lang($alt),'border=0') : lang($alt); return $icon ? Api\Html::image('infolog',$icon,lang($alt),'border=0') : lang($alt);
} }
/** /**
@ -2443,14 +2444,14 @@ class infolog_ui
'info_cc' => 'CC', 'info_cc' => 'CC',
); );
// add customfields to field list // add customfields to field list
foreach(config::get_customfields('infolog') as $name => $data) foreach(Api\Storage\Customfields::get('infolog') as $name => $data)
{ {
$excludefields['#'.$name] = $data['label']; $excludefields['#'.$name] = $data['label'];
} }
$sub_excludefields = $excludefields; $sub_excludefields = $excludefields;
unset($sub_excludefields['info_id_parent']); // always set to parent! unset($sub_excludefields['info_id_parent']); // always set to parent!
$config = config::read('infolog'); $config = Api\Config::read('infolog');
if($content) if($content)
{ {
@ -2465,23 +2466,23 @@ class infolog_ui
$extra = array_intersect($content['responsible_edit'],array_keys($fields)); $extra = array_intersect($content['responsible_edit'],array_keys($fields));
$this->bo->responsible_edit = array_unique(array_merge($this->bo->responsible_edit,$extra)); $this->bo->responsible_edit = array_unique(array_merge($this->bo->responsible_edit,$extra));
} }
config::save_value('copy_excludefields', $content['copy_excludefields'] ? $content['copy_excludefields'] : null, 'infolog'); Api\Config::save_value('copy_excludefields', $content['copy_excludefields'] ? $content['copy_excludefields'] : null, 'infolog');
config::save_value('sub_excludefields', $content['sub_excludefields'] ? $content['sub_excludefields'] : array('*NONE*'), 'infolog'); Api\Config::save_value('sub_excludefields', $content['sub_excludefields'] ? $content['sub_excludefields'] : array('*NONE*'), 'infolog');
config::save_value('responsible_edit', $this->bo->responsible_edit, 'infolog'); Api\Config::save_value('responsible_edit', $this->bo->responsible_edit, 'infolog');
config::save_value('implicit_rights', $this->bo->implicit_rights = $content['implicit_rights'] == 'edit' ? 'edit' : 'read', 'infolog'); Api\Config::save_value('implicit_rights', $this->bo->implicit_rights = $content['implicit_rights'] == 'edit' ? 'edit' : 'read', 'infolog');
config::save_value('history', $this->bo->history = $content['history'], 'infolog'); Api\Config::save_value('history', $this->bo->history = $content['history'], 'infolog');
config::save_value('index_load_cfs', implode(',', (array)$content['index_load_cfs']), 'infolog'); Api\Config::save_value('index_load_cfs', implode(',', (array)$content['index_load_cfs']), 'infolog');
config::save_value('sub_prefix', $content['sub_prefix'], 'infolog'); Api\Config::save_value('sub_prefix', $content['sub_prefix'], 'infolog');
// Notifications // Notifications
$notifications =& $config[infolog_tracking::CUSTOM_NOTIFICATION]; $notifications =& $config[infolog_tracking::CUSTOM_NOTIFICATION];
$notifications[$content['notification_type']] = $content['notification']; $notifications[$content['notification_type']] = $content['notification'];
config::save_value(infolog_tracking::CUSTOM_NOTIFICATION, $notifications,'infolog'); Api\Config::save_value(infolog_tracking::CUSTOM_NOTIFICATION, $notifications,'infolog');
} }
if($button == 'save' || $button == 'cancel') if($button == 'save' || $button == 'cancel')
{ {
egw::redirect_link('/index.php', array( Egw::redirect_link('/index.php', array(
'menuaction' => 'admin.admin_ui.index', 'menuaction' => 'admin.admin_ui.index',
'ajax' => 'true' 'ajax' => 'true'
), 'admin'); ), 'admin');
@ -2541,7 +2542,7 @@ class infolog_ui
if (!is_array($mailContent) && ($_GET['egw_data'])) if (!is_array($mailContent) && ($_GET['egw_data']))
{ {
// get the mail raw data // get the mail raw data
egw_link::get_data ($_GET['egw_data']); Link::get_data ($_GET['egw_data']);
return false; return false;
} }
@ -2561,7 +2562,7 @@ class infolog_ui
* @param $args['view_id'] name of the id-var for location == 'infolog' * @param $args['view_id'] name of the id-var for location == 'infolog'
* @param $args[$args['view_id']] id of the entry * @param $args[$args['view_id']] id of the entry
* this function can be called for any app, which should include infolog: \ * this function can be called for any app, which should include infolog: \
* $GLOBALS['egw']->hooks->process(array( \ * Api\Hooks::process(array( \
* * 'location' => 'infolog', \ * * 'location' => 'infolog', \
* * 'app' => <your app>, \ * * 'app' => <your app>, \
* * 'view_id' => <id name>, \ * * 'view_id' => <id name>, \
@ -2572,7 +2573,7 @@ class infolog_ui
function hook_view($args) function hook_view($args)
{ {
// Load JS for infolog actions // Load JS for infolog actions
egw_framework::validate_file('.','app','infolog'); Framework::includeJS('.','app','infolog');
switch ($args['location']) switch ($args['location'])
{ {
@ -2605,10 +2606,10 @@ class infolog_ui
// Set to calling app, so actions wind up in the correct place client side // Set to calling app, so actions wind up in the correct place client side
$GLOBALS['egw_info']['flags']['currentapp'] = $app; $GLOBALS['egw_info']['flags']['currentapp'] = $app;
translation::add_app('infolog'); Api\Translation::add_app('infolog');
// Still want infolog categories though // Still want infolog Api\Categories though
$GLOBALS['egw']->categories = new categories('','infolog'); $GLOBALS['egw']->categories = new Api\Categories('','infolog');
$this->index(null,$app,$args[$view_id],array( $this->index(null,$app,$args[$view_id],array(
'menuaction' => $view, 'menuaction' => $view,
isset($view_id2) ? $view_id2 : $view_id => $args[$view_id] isset($view_id2) ? $view_id2 : $view_id => $args[$view_id]

View File

@ -10,6 +10,9 @@
* @version $Id$ * @version $Id$
*/ */
use EGroupware\Api;
use EGroupware\Api\Etemplate;
/** /**
* Infolog widget et2 representation: * Infolog widget et2 representation:
* Both infolog-value and infolog-fields widgets are using client-side et2_widget_entry * Both infolog-value and infolog-fields widgets are using client-side et2_widget_entry
@ -19,8 +22,8 @@
* options="[field(e.g. sum), compare, alternate_fields(e.g. (-)#customfileds, use '-' if we need subtraction)]" * options="[field(e.g. sum), compare, alternate_fields(e.g. (-)#customfileds, use '-' if we need subtraction)]"
* /> * />
* *
*/ */
/** /**
* eTemplate extension: InfoLog widget * eTemplate extension: InfoLog widget
* *
@ -32,7 +35,7 @@
* 3) colon (:) separted list of alternative fields: the first non-empty one is used if the selected value is empty * 3) colon (:) separted list of alternative fields: the first non-empty one is used if the selected value is empty
* There's a special field "sum" in 1), which sums up all fields given in alternatives. * There's a special field "sum" in 1), which sums up all fields given in alternatives.
*/ */
class infolog_widget extends etemplate_widget_entry class infolog_widget extends Etemplate\Widget\Entry
{ {
/** /**
* exported methods of this class * exported methods of this class
@ -66,16 +69,18 @@ class infolog_widget extends etemplate_widget_entry
/** /**
* Constructor of the extension * Constructor of the extension
*
*/ */
function __construct($xml) function __construct($xml)
{ {
parent::__construct($xml); parent::__construct($xml);
$this->infolog = new infolog_bo(); $this->infolog = new infolog_bo();
} }
public function get_entry($value, array $attrs) public function get_entry($value, array $attrs)
{ {
unset($attrs); // not used
// Already done // Already done
if (is_array($value) && !(array_key_exists('app',$value) && array_key_exists('id', $value))) return $value; if (is_array($value) && !(array_key_exists('app',$value) && array_key_exists('id', $value))) return $value;
@ -90,200 +95,54 @@ class infolog_widget extends etemplate_widget_entry
} }
return array(); return array();
} }
/**
* pre-processing of the extension
*
* This function is called before the extension gets rendered
*
* @param string $name form-name of the control
* @param mixed &$value value / existing content, can be modified
* @param array &$cell array with the widget, can be modified for ui-independent widgets
* @param array &$readonlys names of widgets as key, to be made readonly
* @param mixed &$extension_data data the extension can store persisten between pre- and post-process
* @param etemplate &$tmpl reference to the template we belong too
* @return boolean true if extra label is allowed, false otherwise
*/
function pre_process($name,&$value,&$cell,&$readonlys,&$extension_data,&$tmpl)
{
switch($cell['type'])
{
case 'infolog-fields':
translation::add_app('addressbook');
$cell['sel_options'] = $this->_get_fields();
$cell['type'] = 'select';
$cell['no_lang'] = 1;
break;
case 'infolog-value':
default:
if (substr($value,0,8) == 'infolog:') $value = substr($value,8); // link-entry syntax
if (!$value || !$cell['size'] || (!is_array($this->data) || $this->data['info_id'] != $value) &&
!($this->data = $this->infolog->read($value)))
{
$cell = $tmpl->empty_cell();
$value = '';
break;
}
list($type,$compare,$alternatives,$contactfield,$regex,$replace) = explode(',',$cell['size'],6);
$value = $this->data[$type];
$cell['size'] = '';
$cell['no_lang'] = 1;
$cell['readonly'] = true;
switch($type)
{
case '': // Sum of the alternatives, field-name can be prefixed with a minus to substract it's value
$cell['type'] = 'float';
$cell['size'] = ',,,%0.2lf';
$value = 0.0;
foreach(explode(':',$alternatives) as $name)
{
if ($name[0] === '-')
{
$val = '-'.$this->data[substr($name, 1)];
}
else
{
$val = $this->data[$name];
}
$value += str_replace(array(' ',','), array('','.'), $val);
}
$alternatives = '';
break;
case 'info_startdate':
case 'info_datemodified':
case 'info_datecompleted':
$cell['type'] = 'date-time';
break;
case 'info_enddate':
$cell['type'] = 'date';
break;
case 'info_owner':
case 'info_responsible':
$cell['type'] = 'select-owner';
break;
case 'info_cat':
$cell['type'] = 'select-cat';
break;
case 'info_access':
$cell['type'] = 'select-access';
break;
case 'info_type':
case 'info_priority':
case 'info_confirm':
$cell['sel_options'] = $this->infolog->enums[$type];
$cell['type'] = 'select';
break;
case 'info_status':
$cell['sel_options'] = $this->infolog->status[$this->data['info_type']];
$cell['type'] = 'select';
break;
default:
if ($type{0} == '#') // custom field --> use field-type itself
{
$field = $this->infolog->customfields[substr($type,1)];
if (($cell['type'] = $field['type']))
{
if ($field['type'] == 'select')
{
$cell['sel_options'] = $field['values'];
}
break;
}
}
$cell['type'] = 'label';
break;
}
if ($alternatives && empty($value)) // use first non-empty alternative if value is empty
{
foreach(explode(':',$alternatives) as $name)
{
if (($value = $this->data[$name])) break;
}
}
if (!empty($compare)) // compare with value and print a X is equal and nothing otherwise
{
$value = $value == $compare ? 'X' : '';
$cell['type'] = 'label';
}
// modify the value with a regular expression
if (!empty($regex))
{
$parts = explode('/',$regex);
if (strchr(array_pop($parts),'e') === false) // dont allow e modifier, which would execute arbitrary php code
{
$value = preg_replace($regex,$replace,$value);
}
$cell['type'] = 'label';
$cell['size'] = '';
}
// use a contact widget to render the value, eg. to fetch contact data from an linked infolog
if (!empty($contactfield))
{
$cell['type'] = 'contact-value';
$cell['size'] = $contactfield;
}
break;
}
$cell['id'] = ($cell['id'] ? $cell['id'] : $cell['name'])."[$type]";
return True; // extra label ok
}
function _get_fields() function _get_fields()
{ {
static $fields; static $fields=null;
if (!is_null($fields)) return $fields; if (!isset($fields))
$fields = array(
'' => lang('Sum'),
'info_type' => lang('Type'),
'info_subject' => lang('Subject'),
'info_des' => lang('Description'),
'info_cat' => lang('Category'),
'info_from' => lang('Contact'),
'info_addr' => lang('Phone/Email'),
'info_responsible' => lang('Responsible'),
'info_startdate' => lang('Startdate'),
'info_enddate' => lang('Enddate'),
'info_status' => lang('Status'),
'info_priority' => lang('Priority'),
'info_location' => lang('Location'),
'info_percent' => lang('Completed'),
'info_datecompleted' => lang('Date completed'),
// meta data
// PM fields
'info_planned_time' => lang('planned time'),
'info_used_time' => lang('used time'),
'pl_id' => lang('Pricelist'),
'info_price' => lang('Price'),
// other
'info_owner' => lang('Owner'),
'info_access' => lang('Access'),
'info_id' => lang('Id#'),
'info_link_id' => lang('primary link'),
'info_modifier' => lang('Modifierer'),
'info_datemodified' => lang('Last modified'),
// 'info_id_parent' => lang('Parent'),
// 'info_confirm' => lang('Confirm'),
// 'info_custom_from' => lang('Custom from'),
);
foreach(config::get_customfields('infolog') as $name => $data)
{ {
$fields['#'.$name] = lang($data['label']); $fields = array(
'' => lang('Sum'),
'info_type' => lang('Type'),
'info_subject' => lang('Subject'),
'info_des' => lang('Description'),
'info_cat' => lang('Category'),
'info_from' => lang('Contact'),
'info_addr' => lang('Phone/Email'),
'info_responsible' => lang('Responsible'),
'info_startdate' => lang('Startdate'),
'info_enddate' => lang('Enddate'),
'info_status' => lang('Status'),
'info_priority' => lang('Priority'),
'info_location' => lang('Location'),
'info_percent' => lang('Completed'),
'info_datecompleted' => lang('Date completed'),
// meta data
// PM fields
'info_planned_time' => lang('planned time'),
'info_used_time' => lang('used time'),
'pl_id' => lang('Pricelist'),
'info_price' => lang('Price'),
// other
'info_owner' => lang('Owner'),
'info_access' => lang('Access'),
'info_id' => lang('Id#'),
'info_link_id' => lang('primary link'),
'info_modifier' => lang('Modifierer'),
'info_datemodified' => lang('Last modified'),
// 'info_id_parent' => lang('Parent'),
// 'info_confirm' => lang('Confirm'),
// 'info_custom_from' => lang('Custom from'),
);
foreach(Api\Storage\Customfields::get('infolog') as $name => $data)
{
$fields['#'.$name] = lang($data['label']);
}
} }
return $fields; return $fields;
} }
} }
// register widgets for etemplate2 // register widgets for etemplate2
etemplate_widget::registerWidget('infolog_widget',array('infolog-value', 'infolog-fields')); Etemplate\Widget::registerWidget('infolog_widget',array('infolog-value', 'infolog-fields'));

View File

@ -1,6 +1,6 @@
<?php <?php
/** /**
* eGroupWare - Wizard for Infolog CSV export * EGroupware - Wizard for Infolog CSV export
* *
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License * @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
* @package infolog * @package infolog
@ -10,6 +10,8 @@
* @version $Id$ * @version $Id$
*/ */
use EGroupware\Api;
class infolog_wizard_export_csv extends importexport_wizard_basic_export_csv class infolog_wizard_export_csv extends importexport_wizard_basic_export_csv
{ {
public function __construct() { public function __construct() {
@ -24,7 +26,7 @@ class infolog_wizard_export_csv extends importexport_wizard_basic_export_csv
// Custom fields // Custom fields
unset($this->export_fields['custom']); // Heading, not a real field unset($this->export_fields['custom']); // Heading, not a real field
$custom = config::get_customfields('infolog', true); $custom = Api\Storage\Customfields::get('infolog', true);
foreach($custom as $name => $data) { foreach($custom as $name => $data) {
$this->export_fields['#'.$name] = $data['label']; $this->export_fields['#'.$name] = $data['label'];
} }

View File

@ -1,6 +1,6 @@
<?php <?php
/** /**
* eGroupWare - Wizard for Infolog CSV import * EGroupware - Wizard for Infolog CSV import
* *
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License * @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
* @package infolog * @package infolog
@ -9,6 +9,9 @@
* @version $Id$ * @version $Id$
*/ */
use EGroupware\Api;
use EGroupware\Api\Acl;
class infolog_wizard_import_infologs_csv extends importexport_wizard_basic_import_csv class infolog_wizard_import_infologs_csv extends importexport_wizard_basic_import_csv
{ {
@ -30,7 +33,7 @@ class infolog_wizard_import_infologs_csv extends importexport_wizard_basic_impor
$this->mapping_fields = array('info_id' => 'Infolog ID') + $tracking->field2label + infolog_import_infologs_csv::$special_fields; $this->mapping_fields = array('info_id' => 'Infolog ID') + $tracking->field2label + infolog_import_infologs_csv::$special_fields;
// List each custom field // List each custom field
unset($this->mapping_fields['custom']); unset($this->mapping_fields['custom']);
$custom = config::get_customfields('infolog'); $custom = Api\Storage\Customfields::get('infolog');
foreach($custom as $name => $data) { foreach($custom as $name => $data) {
$this->mapping_fields['#'.$name] = $data['label']; $this->mapping_fields['#'.$name] = $data['label'];
} }
@ -52,10 +55,10 @@ class infolog_wizard_import_infologs_csv extends importexport_wizard_basic_impor
function wizard_step50(&$content, &$sel_options, &$readonlys, &$preserv) function wizard_step50(&$content, &$sel_options, &$readonlys, &$preserv)
{ {
$result = parent::wizard_step50($content, $sel_options, $readonlys, $preserv); $result = parent::wizard_step50($content, $sel_options, $readonlys, $preserv);
return $result; return $result;
} }
# Skipped for now (or forever) # Skipped for now (or forever)
function wizard_step60(&$content, &$sel_options, &$readonlys, &$preserv) function wizard_step60(&$content, &$sel_options, &$readonlys, &$preserv)
{ {
@ -66,7 +69,7 @@ class infolog_wizard_import_infologs_csv extends importexport_wizard_basic_impor
if($content['record_owner']) if($content['record_owner'])
{ {
$bo = new infolog_bo(); $bo = new infolog_bo();
$access = $bo->check_access(0,EGW_ACL_EDIT, $content['record_owner']); $access = $bo->check_access(0,Acl::EDIT, $content['record_owner']);
} }
// return from step60 // return from step60
@ -115,6 +118,6 @@ class infolog_wizard_import_infologs_csv extends importexport_wizard_basic_impor
unset ($preserv['button']); unset ($preserv['button']);
return 'infolog.importexport_wizard_chooseowner'; return 'infolog.importexport_wizard_chooseowner';
} }
} }
} }

View File

@ -10,6 +10,9 @@
* @version $Id$ * @version $Id$
*/ */
use EGroupware\Api;
use EGroupware\Api\Acl;
/** /**
* InfoLog activesync plugin * InfoLog activesync plugin
*/ */
@ -69,7 +72,7 @@ class infolog_zpush implements activesync_plugin_write
* *
* Currently we only return an own infolog * Currently we only return an own infolog
* *
* @param int $account=null account_id of addressbook or null to get array of all addressbooks * @param int $account =null account_id of addressbook or null to get array of all addressbooks
* @return string|array folder name of array with int account_id => folder name pairs * @return string|array folder name of array with int account_id => folder name pairs
*/ */
private function get_folders($account=null) private function get_folders($account=null)
@ -109,6 +112,7 @@ class infolog_zpush implements activesync_plugin_write
*/ */
public function GetFolder($id) public function GetFolder($id)
{ {
$type = $owner = null;
$this->backend->splitID($id, $type, $owner); $this->backend->splitID($id, $type, $owner);
$folderObj = new SyncFolder(); $folderObj = new SyncFolder();
@ -151,6 +155,7 @@ class infolog_zpush implements activesync_plugin_write
*/ */
public function StatFolder($id) public function StatFolder($id)
{ {
$type = $owner = null;
$this->backend->splitID($id, $type, $owner); $this->backend->splitID($id, $type, $owner);
$stat = array( $stat = array(
@ -183,13 +188,16 @@ class infolog_zpush implements activesync_plugin_write
* will work OK apart from that. * will work OK apart from that.
* *
* @param string $id folder id * @param string $id folder id
* @param int $cutoffdate=null * @param int $cutoffdate =null
* @return array * @return array
*/ */
function GetMessageList($id, $cutoffdate=NULL) function GetMessageList($id, $cutoffdate=NULL)
{ {
unset($cutoffdate); // not used, but required by function signature
if (!isset($this->infolog)) $this->infolog = new infolog_bo(); if (!isset($this->infolog)) $this->infolog = new infolog_bo();
$type = $user = null;
$this->backend->splitID($id,$type,$user); $this->backend->splitID($id,$type,$user);
if (!($infolog_types = $GLOBALS['egw_info']['user']['preferences']['activesync']['infolog-types'])) if (!($infolog_types = $GLOBALS['egw_info']['user']['preferences']['activesync']['infolog-types']))
{ {
@ -232,6 +240,7 @@ class infolog_zpush implements activesync_plugin_write
$bodypreference = $contentparameters->GetBodyPreference(); /* fmbiete's contribution r1528, ZP-320 */ $bodypreference = $contentparameters->GetBodyPreference(); /* fmbiete's contribution r1528, ZP-320 */
debugLog (__METHOD__."('$folderid', $id, truncsize=$truncsize, bodyprefence=$bodypreference, mimesupport=$mimesupport)"); debugLog (__METHOD__."('$folderid', $id, truncsize=$truncsize, bodyprefence=$bodypreference, mimesupport=$mimesupport)");
$type = $account = null;
$this->backend->splitID($folderid, $type, $account); $this->backend->splitID($folderid, $type, $account);
if ($type != 'infolog' || !($infolog = $this->infolog->read($id, true, 'server'))) if ($type != 'infolog' || !($infolog = $this->infolog->read($id, true, 'server')))
{ {
@ -267,7 +276,7 @@ class infolog_zpush implements activesync_plugin_write
$message->$key = array(); $message->$key = array();
foreach($infolog[$attr] ? explode(',',$infolog[$attr]) : array() as $cat_id) foreach($infolog[$attr] ? explode(',',$infolog[$attr]) : array() as $cat_id)
{ {
$message->categories[] = categories::id2name($cat_id); $message->categories[] = Api\Categories::id2name($cat_id);
} }
break; break;
@ -304,6 +313,8 @@ class infolog_zpush implements activesync_plugin_write
*/ */
public function StatMessage($folderid, $infolog) public function StatMessage($folderid, $infolog)
{ {
unset($folderid); // not used, info_id does not depend on folder
if (!isset($this->infolog)) $this->infolog = new infolog_bo(); if (!isset($this->infolog)) $this->infolog = new infolog_bo();
if (!is_array($infolog)) $infolog = $this->infolog->read($infolog, true, 'server'); if (!is_array($infolog)) $infolog = $this->infolog->read($infolog, true, 'server');
@ -338,6 +349,8 @@ class infolog_zpush implements activesync_plugin_write
*/ */
public function ChangeFolder($id, $oldid, $displayname, $type) public function ChangeFolder($id, $oldid, $displayname, $type)
{ {
unset($id, $oldid, $displayname, $type); // not used
debugLog(__METHOD__." not implemented"); debugLog(__METHOD__." not implemented");
} }
@ -353,6 +366,8 @@ class infolog_zpush implements activesync_plugin_write
*/ */
public function DeleteFolder($parentid, $id) public function DeleteFolder($parentid, $id)
{ {
unset($parentid, $id); // not used
debugLog(__METHOD__." not implemented"); debugLog(__METHOD__." not implemented");
} }
@ -377,6 +392,7 @@ class infolog_zpush implements activesync_plugin_write
{ {
if (!isset($this->infolog)) $this->infolog = new infolog_bo(); if (!isset($this->infolog)) $this->infolog = new infolog_bo();
unset($contentParameters); // not used but required unset($contentParameters); // not used but required
$type = $account = null;
$this->backend->splitID($folderid, $type, $account); $this->backend->splitID($folderid, $type, $account);
//debugLog(__METHOD__. " Id " .$id. " Account ". $account . " FolderID " . $folderid); //debugLog(__METHOD__. " Id " .$id. " Account ". $account . " FolderID " . $folderid);
if ($type != 'infolog') // || !($infolog = $this->addressbook->read($id))) if ($type != 'infolog') // || !($infolog = $this->addressbook->read($id)))
@ -385,8 +401,8 @@ class infolog_zpush implements activesync_plugin_write
return false; return false;
} }
$infolog = array(); $infolog = array();
if (empty($id) && $this->infolog->check_access(0, EGW_ACL_EDIT, $account) || if (empty($id) && $this->infolog->check_access(0, Acl::EDIT, $account) ||
($infolog = $this->infolog->read($id)) && $this->infolog->check_access($infolog, EGW_ACL_EDIT)) ($infolog = $this->infolog->read($id)) && $this->infolog->check_access($infolog, Acl::EDIT))
{ {
if (!$infolog) $infolog = array(); if (!$infolog) $infolog = array();
foreach (self::$mapping as $key => $attr) foreach (self::$mapping as $key => $attr)
@ -472,6 +488,8 @@ class infolog_zpush implements activesync_plugin_write
*/ */
public function DeleteMessage($folderid, $id, $contentParameters) public function DeleteMessage($folderid, $id, $contentParameters)
{ {
unset($contentParameters); // not used
if (!isset($this->infolog)) $this->infolog = new infolog_bo(); if (!isset($this->infolog)) $this->infolog = new infolog_bo();
$ret = $this->infolog->delete($id); $ret = $this->infolog->delete($id);
@ -498,6 +516,8 @@ class infolog_zpush implements activesync_plugin_write
*/ */
public function SetReadFlag($folderid, $id, $flags, $contentParameters) public function SetReadFlag($folderid, $id, $flags, $contentParameters)
{ {
unset($folderid, $id, $flags, $contentParameters); // not used
return false; return false;
} }
@ -513,6 +533,8 @@ class infolog_zpush implements activesync_plugin_write
*/ */
function ChangeMessageFlag($folderid, $id, $flags) function ChangeMessageFlag($folderid, $id, $flags)
{ {
unset($folderid, $id, $flags); // not used
return false; return false;
} }
@ -527,6 +549,7 @@ class infolog_zpush implements activesync_plugin_write
*/ */
function AlterPingChanges($folderid, &$syncstate) function AlterPingChanges($folderid, &$syncstate)
{ {
$type = $owner = null;
$this->backend->splitID($folderid, $type, $owner); $this->backend->splitID($folderid, $type, $owner);
if ($type != 'infolog') return false; if ($type != 'infolog') return false;
@ -544,7 +567,7 @@ class infolog_zpush implements activesync_plugin_write
)); ));
$changes = array(); // no change $changes = array(); // no change
$syncstate_was = $syncstate; //$syncstate_was = $syncstate;
if ($ctag !== $syncstate) if ($ctag !== $syncstate)
{ {
@ -556,14 +579,14 @@ class infolog_zpush implements activesync_plugin_write
} }
/** /**
* Populates $settings for the preferences * Populates $settings for the Api\Preferences
* *
* @param array|string $hook_data * @param array|string $hook_data
* @return array * @return array
*/ */
function egw_settings($hook_data) function egw_settings($hook_data)
{ {
if (!$hook_data['setup']) translation::add_app('infolog'); if (!$hook_data['setup']) Api\Translation::add_app('infolog');
if (!isset($this->infolog)) $this->infolog = new infolog_bo(); if (!isset($this->infolog)) $this->infolog = new infolog_bo();
if (!($types = $this->infolog->enums['type'])) if (!($types = $this->infolog->enums['type']))

View File

@ -1,11 +1,11 @@
<?php <?php
/** /**
* eGroupWare - InfoLog * EGroupware - InfoLog
* *
* @link http://www.egroupware.org * @link http://www.egroupware.org
* @author Ralf Becker <RalfBecker-AT-outdoor-training.de> * @author Ralf Becker <RalfBecker-AT-outdoor-training.de>
* @package infolog * @package infolog
* @copyright (c) 2003-12 by Ralf Becker <RalfBecker-AT-outdoor-training.de> * @copyright (c) 2003-16 by Ralf Becker <RalfBecker-AT-outdoor-training.de>
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License * @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
* @version $Id$ * @version $Id$
*/ */
@ -18,14 +18,14 @@ $GLOBALS['egw_info'] = array(
) )
); );
include('../header.inc.php'); include('../header.inc.php');
auth::check_password_age('infolog','index');
include_once(EGW_INCLUDE_ROOT.'/infolog/setup/setup.inc.php'); include_once(EGW_INCLUDE_ROOT.'/infolog/setup/setup.inc.php');
if ($setup_info['infolog']['version'] != $GLOBALS['egw_info']['apps']['infolog']['version']) if ($setup_info['infolog']['version'] != $GLOBALS['egw_info']['apps']['infolog']['version'])
{ {
$GLOBALS['egw']->framework->render('<p style="text-align: center; color:red; font-weight: bold;">'.lang('Your database is NOT up to date (%1 vs. %2), please run %3setup%4 to update your database.', $GLOBALS['egw']->framework->render('<p style="text-align: center; color:red; font-weight: bold;">'.lang('Your database is NOT up to date (%1 vs. %2), please run %3setup%4 to update your database.',
$setup_info['infolog']['version'],$GLOBALS['egw_info']['apps']['infolog']['version'], $setup_info['infolog']['version'],$GLOBALS['egw_info']['apps']['infolog']['version'],
'<a href="../setup/">','</a>')."</p>\n"); '<a href="../setup/">','</a>')."</p>\n");
$GLOBALS['egw']->common->egw_exit(); exit();
} }
unset($setup_info); unset($setup_info);

File diff suppressed because one or more lines are too long

View File

@ -6,13 +6,13 @@
* @author Ralf Becker <RalfBecker-AT-outdoor-training.de> * @author Ralf Becker <RalfBecker-AT-outdoor-training.de>
* @package infolog * @package infolog
* @subpackage setup * @subpackage setup
* @copyright (c) 2003-14 by Ralf Becker <RalfBecker-AT-outdoor-training.de> * @copyright (c) 2003-16 by Ralf Becker <RalfBecker-AT-outdoor-training.de>
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License * @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
* @version $Id$ * @version $Id$
*/ */
$setup_info['infolog']['name'] = 'infolog'; $setup_info['infolog']['name'] = 'infolog';
$setup_info['infolog']['version'] = '14.3'; $setup_info['infolog']['version'] = '16.1';
$setup_info['infolog']['app_order'] = 5; $setup_info['infolog']['app_order'] = 5;
$setup_info['infolog']['tables'] = array('egw_infolog','egw_infolog_extra'); $setup_info['infolog']['tables'] = array('egw_infolog','egw_infolog_extra');
$setup_info['infolog']['enable'] = 1; $setup_info['infolog']['enable'] = 1;
@ -65,15 +65,8 @@ $setup_info['infolog']['hooks']['timesheet_set'] = 'infolog.infolog_ui.timesheet
$setup_info['infolog']['hooks']['calendar_set'] = 'infolog.infolog_ui.calendar_set'; $setup_info['infolog']['hooks']['calendar_set'] = 'infolog.infolog_ui.calendar_set';
$setup_info['infolog']['hooks']['mail_import'] = 'infolog_hooks::mail_import'; $setup_info['infolog']['hooks']['mail_import'] = 'infolog_hooks::mail_import';
/* Dependencies for this app to work */ // Dependencies for this app to work
$setup_info['infolog']['depends'][] = array( $setup_info['infolog']['depends'][] = array(
'appname' => 'phpgwapi', 'appname' => 'api',
'versions' => Array('14.1') 'versions' => Array('16.1')
); );
$setup_info['infolog']['depends'][] = array(
'appname' => 'etemplate',
'versions' => Array('14.1')
);

View File

@ -6,7 +6,7 @@
* @author Ralf Becker <RalfBecker-AT-outdoor-training.de> * @author Ralf Becker <RalfBecker-AT-outdoor-training.de>
* @package infolog * @package infolog
* @subpackage setup * @subpackage setup
* @copyright (c) 2003-14 by Ralf Becker <RalfBecker-AT-outdoor-training.de> * @copyright (c) 2003-16 by Ralf Becker <RalfBecker-AT-outdoor-training.de>
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License * @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
* @version $Id$ * @version $Id$
*/ */
@ -797,3 +797,9 @@ function infolog_upgrade14_2_001()
return $GLOBALS['setup_info']['infolog']['currentver'] = '14.3'; return $GLOBALS['setup_info']['infolog']['currentver'] = '14.3';
} }
function infolog_upgrade14_3()
{
return $GLOBALS['setup_info']['infolog']['currentver'] = '16.1';
}