mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-11-25 01:13:25 +01:00
first steps on infolog port to etemplates
This commit is contained in:
parent
3adb76644e
commit
eea5281759
@ -253,23 +253,31 @@
|
||||
|
||||
function write($values)
|
||||
{
|
||||
if ($values['responsible'] && $values['status'] == 'offer')
|
||||
while (list($key,$val) = each($values))
|
||||
{
|
||||
$values['status'] = 'ongoing'; // have to match if not finished
|
||||
if (substr($key,0,5) != 'info_')
|
||||
{
|
||||
$values['info_'.$key] = $val;
|
||||
unset($values[$key]);
|
||||
}
|
||||
}
|
||||
if (!$values['info_id'] && !$values['owner'])
|
||||
if ($values['info_responsible'] && $values['info_status'] == 'offer')
|
||||
{
|
||||
$values['owner'] = $this->so->user;
|
||||
$values['info_status'] = 'ongoing'; // have to match if not finished
|
||||
}
|
||||
$values['datemodified'] = time();
|
||||
if (!$values['info_id'] && !$values['info_owner'])
|
||||
{
|
||||
$values['info_owner'] = $this->so->user;
|
||||
}
|
||||
$values['info_datemodified'] = time();
|
||||
|
||||
if (!$values['subject'])
|
||||
if (!$values['info_subject'])
|
||||
{
|
||||
$values['subject'] = substr($values['des'],0,60).' ...';
|
||||
$values['info_subject'] = substr($values['info_des'],0,60).' ...';
|
||||
}
|
||||
if ($values['addr_id'] && !$values['from'])
|
||||
if ($values['info_addr_id'] && !$values['info_from'])
|
||||
{
|
||||
$values['from'] = $this->addr2name( $this->readAddr( $values['addr_id'] ));
|
||||
$values['info_from'] = $this->addr2name( $this->readAddr( $values['info_addr_id'] ));
|
||||
}
|
||||
$this->so->write($values);
|
||||
}
|
||||
|
@ -97,7 +97,7 @@
|
||||
{
|
||||
echo "<p>bolink.link('$app1',$id1,'$app2',$id2,'$remark',$owner)</p>\n";
|
||||
}
|
||||
if (!$app1 || !$app2 || !$id1 && isarray($id2) || $app1 == $app2 && $id1 == $id2)
|
||||
if (!$app1 || !$app2 || !$id1 && is_array($id2) || $app1 == $app2 && $id1 == $id2)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
@ -31,21 +31,30 @@
|
||||
$this->link = CreateObject('infolog.bolink');
|
||||
}
|
||||
|
||||
function pre_process(&$cell,&$value,&$extension_data,&$readonlys)
|
||||
function pre_process($name,&$value,&$cell,&$readonlys,&$extension_data,&$tmpl)
|
||||
{
|
||||
$app = $value['app'] = 'addressbook';
|
||||
$id = $value['id'] = 921;
|
||||
if (!is_array($value))
|
||||
{
|
||||
$value = array('to_id' => $value,'to_app' => $GLOBALS['phpgw_info']['flags']['currentapp']);
|
||||
}
|
||||
$app = $value['to_app'];
|
||||
$id = $value['to_id'];
|
||||
//echo "<p>linklist_widget.preprocess: app='$app', id='$id', value="; _debug_array($value);
|
||||
|
||||
if (!$value['title'])
|
||||
{
|
||||
$value['title'] = $this->link->title($app,$id);
|
||||
$value['title'] = $this->link->title($to_app,$to_id);
|
||||
}
|
||||
$extension_data = $value;
|
||||
|
||||
$links = $this->link->get_links($app,$id);
|
||||
|
||||
for($row=1; list(,$link) = each($links); ++$row)
|
||||
if (!count($links))
|
||||
{
|
||||
$cell = $tmpl->empty_cell();
|
||||
return False;
|
||||
}
|
||||
$tpl = new etemplate('infolog.linklist_widget');
|
||||
for($row=$tpl->rows-1; list(,$link) = each($links); ++$row)
|
||||
{
|
||||
$value[$row] = $link;
|
||||
$value[$row]['title'] = $this->link->title($link['app'],$link['id']);
|
||||
@ -53,11 +62,12 @@
|
||||
$cell['size'] = $cell['name'];
|
||||
$cell['type'] = 'template';
|
||||
$cell['name'] = 'infolog.linklist_widget';
|
||||
$cell['obj'] = &$tpl;
|
||||
|
||||
return True; // extra Label is ok
|
||||
}
|
||||
|
||||
function post_process(&$cell,&$value,&$extension_data,&$loop)
|
||||
function post_process($name,&$value,&$extension_data,&$loop,&$tmpl,$value_in)
|
||||
{
|
||||
list($unlink) = @each($value['unlink']);
|
||||
$pre_value = $extension_data;
|
||||
@ -70,4 +80,4 @@
|
||||
$value = $pre_value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -31,13 +31,15 @@
|
||||
$this->link = CreateObject('infolog.bolink');
|
||||
}
|
||||
|
||||
function pre_process(&$cell,&$value,&$extension_data,&$readonlys)
|
||||
function pre_process($name,&$value,&$cell,&$readonlys,&$extension_data,&$tmpl)
|
||||
{
|
||||
$search = $value['search'] ? 1 : 0;
|
||||
$create = $value['create'] ? 1 : 0;
|
||||
//echo "<p>linkto_widget.preprocess: query='$value[query]',app='$value[app]',search=$search,create=$create</p>\n";
|
||||
if (!is_array($value))
|
||||
{
|
||||
$value = array('to_id' => $value,'to_app' => $GLOBALS['phpgw_info']['flags']['currentapp']);
|
||||
}
|
||||
//echo "<p>linkto_widget.preprocess: name='$name', query='$value[query]',app='$value[app]',button=$value[button]</p>\n";
|
||||
|
||||
if ($search && count($ids = $this->link->query($value['app'],$value['query'])))
|
||||
if ($value['button'] == 'search' && count($ids = $this->link->query($value['app'],$value['query'])))
|
||||
{
|
||||
$extension_data['app'] = $value['app'];
|
||||
|
||||
@ -50,7 +52,7 @@
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!$create)
|
||||
if (!$value['button'])
|
||||
{
|
||||
$extension_data = $value;
|
||||
}
|
||||
@ -58,7 +60,7 @@
|
||||
'app' => $value['app'],
|
||||
'options-app' => $this->link->app_list(),
|
||||
'query' => $value['query'],
|
||||
'msg' => $search ? 'Nothing found - try again !!!' : ''
|
||||
'msg' => $value['button'] == 'search' ? 'Nothing found - try again !!!' : ''
|
||||
);
|
||||
$next = 'search';
|
||||
}
|
||||
@ -69,15 +71,24 @@
|
||||
return True; // extra Label is ok
|
||||
}
|
||||
|
||||
function post_process(&$cell,&$value,&$extension_data,&$loop)
|
||||
function post_process($name,&$value,&$extension_data,&$loop,&$tmpl,$value_in)
|
||||
{
|
||||
$search = $value['search'] ? 1 : 0;
|
||||
$create = $value['create'] ? 1 : 0;
|
||||
list($value['app']) = @$value['app']; // no multiselection
|
||||
list($value['id']) = @$value['id'];
|
||||
//echo "<p>linkto_widget.postprocess: query='$value[query]',app='$value[app]',id='$value[id]', search=$search,create=$create</p>\n";
|
||||
if ($value['search'])
|
||||
{
|
||||
$button = 'search';
|
||||
}
|
||||
elseif ($value['create'])
|
||||
{
|
||||
$button = 'create';
|
||||
}
|
||||
elseif ($value['new'])
|
||||
{
|
||||
$button = 'new';
|
||||
}
|
||||
unset($value[$button]);
|
||||
//echo "<p>linkto_widget.postprocess: query='$value[query]',app='$value[app]',id='$value[id]', button='$button'</p>\n";
|
||||
|
||||
if ($create)
|
||||
if ($button == 'create')
|
||||
{
|
||||
$value = array_merge($value,$extension_data);
|
||||
if ($value['to_app']) // make the link
|
||||
@ -86,6 +97,7 @@
|
||||
echo "<p>linkto($value[app],$value[id],'$value[remark]')</p>\n";
|
||||
}
|
||||
}
|
||||
$loop = $search || $create;
|
||||
$value['button'] = $button;
|
||||
$loop = $button != '';
|
||||
}
|
||||
}
|
@ -205,17 +205,20 @@
|
||||
|
||||
function write($values) // did _not_ ensure ACL
|
||||
{
|
||||
include(PHPGW_SERVER_ROOT.'/infolog/setup/tables_current.inc.php');
|
||||
$db_cols = $phpgw_baseline['phpgw_infolog']['fd'];
|
||||
unset($phpgw_baseline);
|
||||
|
||||
while (list($key,$val) = each($values))
|
||||
{
|
||||
if ($key != 'info_id')
|
||||
{
|
||||
$key = 'info_'.$key;
|
||||
|
||||
if (!isset($db_cols[$key]))
|
||||
{
|
||||
continue; // not in infolog-table
|
||||
}
|
||||
$this->data[$key] = $val; // update internal data
|
||||
|
||||
if ($key == 'info_addr_id' || $key == 'info_proj_id' || $key == 'info_event_id')
|
||||
continue; // not longer in infolog-table
|
||||
|
||||
if ($this->maybe_slashes[$key])
|
||||
{
|
||||
$val = addslashes($val);
|
||||
@ -229,8 +232,6 @@
|
||||
{
|
||||
$query = "UPDATE phpgw_infolog SET $query where info_id='".$values['info_id']."'";
|
||||
$this->db->query($query,__LINE__,__FILE__);
|
||||
|
||||
$this->links->unlink(0,'infolog',$values['info_id']);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -240,12 +241,13 @@
|
||||
}
|
||||
// echo "<p>soinfolog.write values= "; _debug_array($values);
|
||||
// echo "<p>soinfolog.write this->data= "; _debug_array($this->data);
|
||||
/*
|
||||
if ($this->data['info_addr_id'])
|
||||
$this->links->link('infolog',$this->data['info_id'],'addressbook',$this->data['info_addr_id']);
|
||||
if ($this->data['info_proj_id'])
|
||||
$this->links->link('infolog',$this->data['info_id'],'projects',$this->data['info_proj_id']);
|
||||
if ($this->data['info_event_id'])
|
||||
$this->links->link('infolog',$this->data['info_id'],'calendar',$this->data['info_event_id']);
|
||||
$this->links->link('infolog',$this->data['info_id'],'calendar',$this->data['info_event_id']); */
|
||||
}
|
||||
|
||||
function anzSubs( $info_id )
|
||||
|
@ -18,8 +18,7 @@
|
||||
var $public_functions = array
|
||||
(
|
||||
'get_list' => True,
|
||||
'view' => True,
|
||||
'add' => True,
|
||||
'index' => True,
|
||||
'edit' => True,
|
||||
'delete' => True,
|
||||
'get_file' => True,
|
||||
@ -58,21 +57,28 @@
|
||||
);
|
||||
|
||||
$this->filters = array(
|
||||
'none' => lang('no Filter'),
|
||||
'done' => lang('done'),
|
||||
'own' => lang('own'),
|
||||
'own-open-today' => lang('own open'),
|
||||
'own-open-overdue'=> lang('own overdue'),
|
||||
'own-upcoming' => lang('own upcoming'),
|
||||
'open-today' => lang('open'),
|
||||
'open-overdue' => lang('overdue'),
|
||||
'upcoming' => lang('upcoming')
|
||||
'none' => 'no Filter',
|
||||
'done' => 'done',
|
||||
'own' => 'own',
|
||||
'own-open-today' => 'own open',
|
||||
'own-open-overdue'=> 'own overdue',
|
||||
'own-upcoming' => 'own upcoming',
|
||||
'open-today' => 'open',
|
||||
'open-overdue' => 'overdue',
|
||||
'upcoming' => 'upcoming'
|
||||
);
|
||||
|
||||
$this->messages = array(
|
||||
'edit' => 'InfoLog - Edit',
|
||||
'add' => 'InfoLog - New',
|
||||
'add_sub' => 'InfoLog - New Subproject'
|
||||
);
|
||||
|
||||
$this->html = CreateObject('etemplate.html');
|
||||
$this->categories = CreateObject('phpgwapi.categories');
|
||||
$this->nextmatchs = CreateObject('phpgwapi.nextmatchs');
|
||||
$this->link = CreateObject('infolog.uilink');
|
||||
|
||||
$this->tmpl = CreateObject('etemplate.etemplate');
|
||||
}
|
||||
|
||||
function menuaction($action = 'get_list',$app='infolog')
|
||||
@ -381,24 +387,25 @@
|
||||
$action_vars = array('action'=>'sp','info_id'=>$action_id);
|
||||
$GLOBALS['phpgw']->template->set_var(lang_info_action,lang('InfoLog - Subprojects from'));
|
||||
break;
|
||||
case 'proj':
|
||||
$action_vars += array( 'id_project' => $action_id,
|
||||
'proj_id' => $action_id);
|
||||
case 'proj': case 'projects':
|
||||
$action_vars = array( /*'id_project' => $action_id, 'proj_id' => $action_id */
|
||||
'action' => 'projects', 'action_id' => $action_id );
|
||||
$GLOBALS['phpgw']->template->set_var(lang_info_action,lang('InfoLog').' - '.
|
||||
$this->bo->proj2name($action_id));
|
||||
break;
|
||||
case 'addr':
|
||||
$action_vars += array( 'id_addr' => $action_id,
|
||||
'addr_id' => $action_id );
|
||||
case 'addr': case 'addressbook':
|
||||
$action_vars = array( /*'id_addr' => $action_id,'addr_id' => $action_id */
|
||||
'action' => 'addressbook', 'action_id' => $action_id );
|
||||
$GLOBALS['phpgw']->template->set_var(lang_info_action,lang('InfoLog').' - '.
|
||||
$this->bo->addr2name($action_id));
|
||||
break;
|
||||
case 'event':
|
||||
$action_vars += array( 'id_event' => $action_id,'event_id' => $action_id);
|
||||
case 'event': case 'calendar':
|
||||
$action_vars = array( /*'id_event' => $action_id,'event_id' => $action_id */
|
||||
'action' => 'calendar', 'action_id' => $action_id );
|
||||
$GLOBALS['phpgw']->template->set_var(lang_info_action,lang('InfoLog').' - '.
|
||||
$this->bo->event2name($action_id));
|
||||
break;
|
||||
default:
|
||||
default:
|
||||
if ($filter && $filter != 'none')
|
||||
{
|
||||
$filter_name = ': '.$this->filters[ $filter ];
|
||||
@ -685,8 +692,125 @@
|
||||
$GLOBALS['phpgw']->template->fp('phpgw_body','info_add_file');
|
||||
}
|
||||
|
||||
function index()
|
||||
{
|
||||
$this->get_list();
|
||||
}
|
||||
|
||||
function edit( )
|
||||
function edit($content = 0,$action = '',$action_id=0,$type='')
|
||||
{
|
||||
if (is_array($content))
|
||||
{
|
||||
$info_id = $content['info_id'];
|
||||
$action = $content['action'];
|
||||
$action_id = $content['action_id'];
|
||||
|
||||
if ($content['save'] || $content['delete'] || $content['cancel'])
|
||||
{
|
||||
if ($content['save'] && (!$info_id || $this->bo->check_access($info_id,PHPGW_ACL_EDIT)))
|
||||
{
|
||||
$this->bo->write($content);
|
||||
|
||||
if (!$info_id && is_array($content['link_to']['to_id']))
|
||||
{
|
||||
$this->link->link('infolog',$this->bo->so->data['info_id'],$content['link_to']['to_id']);
|
||||
}
|
||||
}
|
||||
elseif ($content['delete'] && $info_id > 0 && $this->bo->check_access($info_id,PHPGW_ACL_DELETE))
|
||||
{
|
||||
return $this->delete($info_id);
|
||||
}
|
||||
return $this->index();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$action = $action ? $action : get_var('action', array('POST','GET'));
|
||||
$action_id = $action_id ? $action_id : get_var('action_id',array('POST','GET'));
|
||||
$info_id = $content ? $content : get_var('info_id', array('POST','GET'));
|
||||
$type = $type ? $type : get_var('type', array('POST','GET'));
|
||||
if (!isset($this->bo->enums['type'][$type]))
|
||||
{
|
||||
$type = 'note';
|
||||
}
|
||||
$this->bo->read( $info_id );
|
||||
$content = $this->bo->so->data;
|
||||
|
||||
if ($info_id && $action == 'sp') // new SubProject
|
||||
{
|
||||
if (!$this->bo->check_access($info_id,PHPGW_ACL_ADD))
|
||||
{
|
||||
return $this->index();
|
||||
Header('Location: ' . $this->html->link($referer));
|
||||
$GLOBALS['phpgw']->common->phpgw_exit();
|
||||
}
|
||||
$parent = $this->bo->so->data;
|
||||
$content['info_id'] = $info_id = 0;
|
||||
$content['info_owner'] = $GLOBALS['phpgw_info']['user']['account_id'];
|
||||
$content['info_id_parent'] = $parent['info_id'];
|
||||
/*
|
||||
if ($parent['info_type']=='task' && $parent['info_status']=='offer')
|
||||
{
|
||||
$content['info_type'] = 'confirm'; // confirmation to parent
|
||||
$content['info_responsible'] = $parent['info_owner'];
|
||||
}
|
||||
*/
|
||||
$content['info_status'] = 'ongoing';
|
||||
$content['info_confirm'] = 'not';
|
||||
$content['info_subject']=lang('Re:').' '.$parent['info_subject'];
|
||||
$content['info_des'] = '';
|
||||
}
|
||||
else
|
||||
{
|
||||
if ($info_id && !$this->bo->check_access($info_id,PHPGW_ACL_EDIT))
|
||||
{
|
||||
return $this->index();
|
||||
Header('Location: ' . $this->html->link($referer));
|
||||
$GLOBALS['phpgw']->common->phpgw_exit();
|
||||
}
|
||||
}
|
||||
$content['links'] = $content['link_to'] = array(
|
||||
'to_id' => $info_id,
|
||||
'to_app' => 'infolog'
|
||||
);
|
||||
switch ($action)
|
||||
{
|
||||
case 'sp':
|
||||
break;
|
||||
case 'addressbook':
|
||||
case 'projects':
|
||||
case 'calendar':
|
||||
$this->link->link('infolog',$content['link_to']['to_id'],$action,$action_id);
|
||||
case 'new':
|
||||
$content['info_type'] = $type;
|
||||
break;
|
||||
default:
|
||||
$action = '';
|
||||
break;
|
||||
}
|
||||
if (!isset($this->bo->enums['type'][$content['info_type']]))
|
||||
{
|
||||
$content['info_type'] = 'note';
|
||||
}
|
||||
}
|
||||
$readonlys['delete'] = $action != '';
|
||||
$content['appheader'] = $this->messages[$action ? ($action == 'sp' ? 'add_sub' : 'add') : 'edit'];
|
||||
|
||||
//echo "<p>uiinfolog.edit(info_id=$info_id,mode=$mode) content = "; _debug_array($content);
|
||||
$this->tmpl->read('infolog.edit');
|
||||
$this->tmpl->exec('infolog.uiinfolog.edit',$content,array(
|
||||
'info_type' => $this->bo->enums['type'],
|
||||
'info_priority' => $this->bo->enums['priority'],
|
||||
'info_confirm' => $this->bo->enums['confirm'],
|
||||
'info_status' => $this->bo->status[$content['info_type']]
|
||||
),$readonlys,array(
|
||||
'info_id' => $info_id,
|
||||
'action' => $action,
|
||||
'action_id' => $action_id
|
||||
));
|
||||
}
|
||||
|
||||
function old_edit( )
|
||||
{
|
||||
global $action,$info_id,$save,$add,$query_addr,$query_project;
|
||||
// formular fields
|
||||
@ -1215,4 +1339,16 @@
|
||||
}
|
||||
$GLOBALS['phpgw']->template->fp('phpgw_body','info_prefs');
|
||||
}
|
||||
|
||||
/*!
|
||||
@function writeLangFile
|
||||
@abstract writes langfile with all templates and messages registered here
|
||||
@discussion can be called via http://domain/phpgroupware/index.php?infolog.uiinfolog.writeLangFile
|
||||
*/
|
||||
function writeLangFile()
|
||||
{
|
||||
$il = new uiinfolog(False); // no lang on messages
|
||||
|
||||
$this->tmpl->writeLangFile('et_media','en',$il->messages);
|
||||
}
|
||||
}
|
||||
|
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue
Block a user