mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-12-25 16:19:00 +01:00
session->app_session used now for the sessiondata (not longer hidden vars)
the content of the form is now the first param. to the callback (no longer in HTTP_POST_VARS)
This commit is contained in:
parent
46a635b73c
commit
50c595ff8b
@ -160,4 +160,39 @@
|
||||
}
|
||||
return $Ok;
|
||||
}
|
||||
|
||||
/*!
|
||||
@function save_appsession()
|
||||
@abstract saves content,readonlys,template-keys, ... via the appsession function
|
||||
@discussion As a user may open several windows with the same content/template wie generate a location-id from microtime
|
||||
@discussion which is used as location for appsession to descriminate between the different windows. This location-id
|
||||
@discussion is then saved as a hidden-var in the form. The above mentions session-id has nothing to do / is different
|
||||
@discussion from the session-id which is constant for all windows opened in one session.
|
||||
@returns the location-id
|
||||
*/
|
||||
function save_appsession($data)
|
||||
{
|
||||
list($msec,$sec) = explode(' ',microtime());
|
||||
$id = $GLOBALS['phpgw_info']['flags']['currentapp'] . (intval(1000000 * $msec) + 1000000 * ($sec % 100000));
|
||||
//echo "<p>microtime()=".microtime().", sec=$sec, msec=$msec, id=$id</p>\n";
|
||||
|
||||
$GLOBALS['phpgw']->session->appsession($id,'etemplate',$data);
|
||||
|
||||
return $id;
|
||||
}
|
||||
|
||||
/*!
|
||||
@function get_appsession()
|
||||
@abstract gets content,readonlys,template-keys, ... back from the appsession function
|
||||
@param $id the location-id
|
||||
@returns the session-data
|
||||
*/
|
||||
function get_appsession($id)
|
||||
{
|
||||
$data = $GLOBALS['phpgw']->session->appsession($id,'etemplate');
|
||||
|
||||
//echo "<p>get_appsession('$id') data="; _debug_array($data);
|
||||
|
||||
return $data;
|
||||
}
|
||||
};
|
@ -32,7 +32,7 @@
|
||||
'not_found' => 'Not found !!!',
|
||||
'select_one' => 'Select one ...',
|
||||
'writen' => 'File writen',
|
||||
'error_writing' => 'Error: writing file !!!',
|
||||
'error_writing' => 'Error: writing file (no write-permission for the webserver) !!!',
|
||||
'give_table_name' => 'Please enter table-name first !!!',
|
||||
'new_table' => 'New table created',
|
||||
'select_app' => 'Select an app first !!!'
|
||||
@ -79,31 +79,30 @@
|
||||
}
|
||||
|
||||
/*!
|
||||
@function edit()
|
||||
@function edit($content='',$msg='')
|
||||
@abstract this is the table editor (and the callback/submit-method too)
|
||||
*/
|
||||
function edit($msg = '')
|
||||
function edit($content='',$msg = '')
|
||||
{
|
||||
if (isset($GLOBALS['HTTP_GET_VARS']['app']))
|
||||
{
|
||||
$this->app = $GLOBALS['HTTP_GET_VARS']['app'];
|
||||
}
|
||||
if (isset($GLOBALS['HTTP_POST_VARS']['cont']))
|
||||
if (is_array($content))
|
||||
{
|
||||
$content = $GLOBALS['HTTP_POST_VARS']['cont'];
|
||||
if ($this->debug)
|
||||
{
|
||||
echo "HTTP_POST_VARS ="; _debug_array($GLOBALS['HTTP_POST_VARS']);
|
||||
echo "content ="; _debug_array($content);
|
||||
}
|
||||
$this->app = $content['app']; // this is what the user selected
|
||||
$this->table = $content['table_name'];
|
||||
$posted_app = $GLOBALS['HTTP_POST_VARS']['posted_app']; // this is the old selection
|
||||
$posted_table = $GLOBALS['HTTP_POST_VARS']['posted_table'];
|
||||
$posted_app = $content['posted_app']; // this is the old selection
|
||||
$posted_table = $content['posted_table'];
|
||||
}
|
||||
if ($posted_app && $posted_table && // user changed app or table
|
||||
($posted_app != $this->app || $posted_table != $this->table))
|
||||
{
|
||||
if ($this->needs_save($posted_app,$posted_table,$this->content2table($content)))
|
||||
if ($this->needs_save('',$posted_app,$posted_table,$this->content2table($content)))
|
||||
{
|
||||
return;
|
||||
}
|
||||
@ -201,10 +200,10 @@
|
||||
{
|
||||
$table_names[$this->table] = $this->table;
|
||||
}
|
||||
$sel_options = array(
|
||||
$sel_options = array(
|
||||
'table_name' => $table_names,
|
||||
'type' => $this->types,
|
||||
'app' => array('' => lang($this->messages['select_one'])) + $this->apps
|
||||
'app' => array('' => $this->messages['select_one']) + $this->apps
|
||||
);
|
||||
if ($this->table != '' && isset($this->data[$this->table]))
|
||||
{
|
||||
@ -224,39 +223,35 @@
|
||||
}
|
||||
|
||||
/*!
|
||||
@function needs_save($posted_app,$posted_table,$edited_table)
|
||||
@function needs_save($cont='',$posted_app='',$posted_table='',$edited_table='')
|
||||
@abstract checks if table was changed and if so offers user to save changes
|
||||
@param $cont the content of the form (if called by process_exec)
|
||||
@param $posted_app the app the table is from
|
||||
@param $posted_table the table-name
|
||||
@param $edited_table the edited table-definitions
|
||||
@returns only if no changes
|
||||
*/
|
||||
function needs_save($posted_app='',$posted_table='',$edited_table='')
|
||||
function needs_save($cont='',$posted_app='',$posted_table='',$edited_table='')
|
||||
{
|
||||
if (!$posted_app && isset($GLOBALS['HTTP_POST_VARS']['cont']))
|
||||
if (!$posted_app && is_array($cont))
|
||||
{
|
||||
$cont = $GLOBALS['HTTP_POST_VARS']['cont'];
|
||||
$preserv = unserialize(stripslashes($GLOBALS['HTTP_POST_VARS']['preserv']));
|
||||
|
||||
if (isset($cont['yes']))
|
||||
{
|
||||
$this->app = $preserv['app'];
|
||||
$this->table = $preserv['table'];
|
||||
$this->app = $cont['app'];
|
||||
$this->table = $cont['table'];
|
||||
$this->read($this->app,$this->data);
|
||||
$this->data[$this->table] = $preserv['edited_table'];
|
||||
$this->data[$this->table] = $cont['edited_table'];
|
||||
$this->write($this->app,$this->data);
|
||||
$msg .= $this->messages[$this->write($this->app,$this->data) ?
|
||||
'writen' : 'error_writing'];
|
||||
}
|
||||
// return to edit with everything set, so the user gets the table he asked for
|
||||
$GLOBALS['HTTP_POST_VARS'] = array(
|
||||
'cont' => array(
|
||||
'app' => $preserv['new_app'],
|
||||
'table_name' => $preserv['app']==$preserv['new_app'] ? $preserv['new_table']:''
|
||||
),
|
||||
'posted_app' => $preserv['new_app'],
|
||||
);
|
||||
$this->edit($msg);
|
||||
$this->edit(array(
|
||||
'app' => $cont['new_app'],
|
||||
'table_name' => $cont['app']==$cont['new_app'] ? $cont['new_table'] : '',
|
||||
'posted_app' => $cont['new_app']
|
||||
),$msg);
|
||||
|
||||
return True;
|
||||
}
|
||||
$new_app = $this->app; // these are the ones, the users whiches to change too
|
||||
@ -284,8 +279,7 @@
|
||||
);
|
||||
$tmpl = new etemplate('etemplate.db-tools.ask_save');
|
||||
|
||||
$tmpl->exec('etemplate.db_tools.needs_save',$content,array(),array(),
|
||||
array('preserv' => $preserv));
|
||||
$tmpl->exec('etemplate.db_tools.needs_save',$content,array(),array(),$preserv);
|
||||
|
||||
return True; // dont continue in edit
|
||||
}
|
||||
@ -478,8 +472,10 @@
|
||||
$header = substr($header,0,strpos($header,'$phpgw_baseline'));
|
||||
fclose($f);
|
||||
|
||||
rename($file,PHPGW_SERVER_ROOT."/$app/setup/tables_current.old.inc.php");
|
||||
|
||||
if (is_writable(PHPGW_SERVER_ROOT."/$app/setup"))
|
||||
{
|
||||
rename($file,PHPGW_SERVER_ROOT."/$app/setup/tables_current.old.inc.php");
|
||||
}
|
||||
while ($header[strlen($header)-1] == "\t")
|
||||
{
|
||||
$header = substr($header,0,strlen($header)-1);
|
||||
@ -489,7 +485,7 @@
|
||||
{
|
||||
$header = "<?php\n\n";
|
||||
}
|
||||
if (!($f = fopen($file,'w')))
|
||||
if (!is_writeable($file) || !($f = fopen($file,'w')))
|
||||
{
|
||||
return False;
|
||||
}
|
||||
@ -556,7 +552,7 @@
|
||||
function writeLangFile()
|
||||
{
|
||||
$m = new db_tools(False); // no lang on messages
|
||||
$this->tmpl->writeLangFile('etemplate','en',$m->messages);
|
||||
$this->editor->writeLangFile('etemplate','en',$m->messages);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -93,7 +93,7 @@
|
||||
{
|
||||
while(list($k,$v) = each($cell)) // so spanned (not shown) cells got
|
||||
{ // reported back like regular one
|
||||
$cols_spanned["cont[$col$row][$k]"] = $v;
|
||||
$cols_spanned[$col.$row][$k] = $v;
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -134,9 +134,9 @@
|
||||
$t = $a; $a = $b; $b = $t;
|
||||
}
|
||||
|
||||
function process_edit()
|
||||
function process_edit($content)
|
||||
{
|
||||
$content = $GLOBALS['HTTP_POST_VARS']['cont'];
|
||||
//$content = $GLOBALS['HTTP_POST_VARS']['cont'];
|
||||
|
||||
if ($this->debug)
|
||||
{
|
||||
@ -318,13 +318,17 @@
|
||||
$this->edit($msg);
|
||||
}
|
||||
|
||||
function delete($back = 'edit')
|
||||
function delete($post_vars='',$back = 'edit')
|
||||
{
|
||||
if (isset($GLOBALS['HTTP_POST_VARS']['name']))
|
||||
if (!$post_vars)
|
||||
{
|
||||
$read_ok = $this->etemplate->read($GLOBALS['HTTP_POST_VARS']);
|
||||
$post_vars = array();
|
||||
}
|
||||
if (isset($GLOBALS['HTTP_POST_VARS']['yes'])) // Delete
|
||||
if (isset($post_vars['name']))
|
||||
{
|
||||
$read_ok = $this->etemplate->read($post_vars);
|
||||
}
|
||||
if (isset($post_vars['yes'])) // Delete
|
||||
{
|
||||
if ($read_ok)
|
||||
{
|
||||
@ -333,9 +337,9 @@
|
||||
$this->edit($this->messages[$read_ok ? 'deleted' : 'not_found']);
|
||||
return;
|
||||
}
|
||||
if (isset($GLOBALS['HTTP_POST_VARS']['no'])) // Back to ...
|
||||
if (isset($post_vars['no'])) // Back to ...
|
||||
{
|
||||
if (($back = $GLOBALS['HTTP_POST_VARS']['back']) != 'show')
|
||||
if (($back = $post_vars['back']) != 'show')
|
||||
{
|
||||
$back = 'edit';
|
||||
}
|
||||
@ -354,10 +358,12 @@
|
||||
$delete->exec('etemplate.editor.delete',$content,array(),array(),$content,'');
|
||||
}
|
||||
|
||||
function show()
|
||||
function show($post_vars='')
|
||||
{
|
||||
$post_vars = $GLOBALS['HTTP_POST_VARS'];
|
||||
|
||||
if (!$post_vars)
|
||||
{
|
||||
$post_vars = array();
|
||||
}
|
||||
if (isset($GLOBALS['HTTP_GET_VARS']['name']) && !$this->etemplate->read($GLOBALS['HTTP_GET_VARS']) ||
|
||||
isset($post_vars['name']) && !$this->etemplate->read($post_vars))
|
||||
{
|
||||
@ -365,7 +371,7 @@
|
||||
}
|
||||
if (!$msg && isset($post_vars['delete']))
|
||||
{
|
||||
$this->delete('show');
|
||||
$this->delete(array(),'show');
|
||||
return;
|
||||
}
|
||||
if (isset($post_vars['edit']))
|
||||
@ -376,12 +382,17 @@
|
||||
$content = $this->etemplate->as_array() + array('msg' => $msg);
|
||||
|
||||
$show = new etemplate('etemplate.editor.show');
|
||||
$no_buttons = array('save' => True,'show' => True,'dump' => True,'langfile' => True,'size' => True);
|
||||
|
||||
if (!$msg && isset($post_vars['values']) && !isset($GLOBALS['HTTP_POST_VARS']['vals']))
|
||||
$no_buttons = array(
|
||||
'save' => True,
|
||||
'show' => True,
|
||||
'dump' => True,
|
||||
'langfile' => True,
|
||||
'size' => True
|
||||
);
|
||||
if (!$msg && isset($post_vars['values']) && !isset($post_vars['vals']))
|
||||
{
|
||||
$cont = $this->etemplate->process_show($GLOBALS['HTTP_POST_VARS']);
|
||||
for ($r = 1; list($key,$val) = each($cont); ++$r)
|
||||
$cont = $this->etemplate->process_show($post_vars);
|
||||
for ($r = 1; list($key,$val) = @each($cont); ++$r)
|
||||
{
|
||||
$vals["A$r"] = $key;
|
||||
$vals["B$r"] = $val;
|
||||
@ -393,8 +404,8 @@
|
||||
else
|
||||
{
|
||||
$show->data[$show->rows]['A']['name'] = $this->etemplate;
|
||||
$vals = $GLOBALS['HTTP_POST_VARS']['vals'];
|
||||
$olds = unserialize(stripslashes($GLOBALS['HTTP_POST_VARS']['olds']));
|
||||
$vals = $post_vars['vals'];
|
||||
$olds = unserialize(stripslashes($post_vars['olds']));
|
||||
|
||||
for ($r = 1; isset($vals["B$r"]); ++$r)
|
||||
{
|
||||
|
@ -75,10 +75,9 @@
|
||||
@param $readonlys Array with field-names as keys for fields with should be readonly
|
||||
@param (eg. to implement ACL grants on field-level or to remove buttons not applicable)
|
||||
@param $preserv Array with vars which should be transported to the $method-call (eg. an id) array('id' => $id) sets $HTTP_POST_VARS['id'] for the $method-call
|
||||
@param $cname Basename for the submitted content in $HTTP_POST_VARS (default = 'cont')
|
||||
@returns nothing
|
||||
*/
|
||||
function exec($method,$content,$sel_options='',$readonlys='',$preserv='',$cname='cont')
|
||||
function exec($method,$content,$sel_options='',$readonlys='',$preserv='')
|
||||
{
|
||||
if (!$sel_options)
|
||||
{
|
||||
@ -95,16 +94,21 @@
|
||||
$GLOBALS['phpgw']->common->phpgw_header();
|
||||
echo parse_navbar();
|
||||
|
||||
$id = $this->save_appsession(array(
|
||||
'name' => $this->name,
|
||||
'template' => $this->template,
|
||||
'lang' => $this->lang,
|
||||
'group' => $this->group,
|
||||
'readonlys' => $readonlys,
|
||||
'content' => $content,
|
||||
'sel_options' => $sel_options,
|
||||
'preserv' => $preserv,
|
||||
'method' => $method
|
||||
));
|
||||
|
||||
echo $this->html->nextMatchStyles($this->style)."\n\n". // so they get included once
|
||||
$this->html->form($this->show($content,$sel_options,$readonlys,$cname),array(
|
||||
'etemplate_exec[name]' => $this->name,
|
||||
'etemplate_exec[template]' => $this->template,
|
||||
'etemplate_exec[lang]' => $this->lang,
|
||||
'etemplate_exec[group]' => $this->group,
|
||||
'etemplate_exec[readonlys]' => $readonlys,
|
||||
'etemplate_exec[cname]' => $cname,
|
||||
'etemplate_exec[method]' => $method
|
||||
)+$preserv,'/index.php?menuaction=etemplate.etemplate.process_exec');
|
||||
$this->html->form($this->show($content,$sel_options,$readonlys,'exec'),
|
||||
array('etemplate_exec_id' => $id),'/index.php?menuaction=etemplate.etemplate.process_exec');
|
||||
}
|
||||
|
||||
/*!
|
||||
@ -114,23 +118,25 @@
|
||||
@discussion All eTemplates / forms executed with exec are submited to this function
|
||||
@discussion (via the global index.php and menuaction). It then calls process_show
|
||||
@discussion for the eTemplate (to adjust the content of the HTTP_POST_VARS) and
|
||||
@discussion ExecMethod's the given callback from the app.
|
||||
@discussion ExecMethod's the given callback from the app with the content of the form as first argument.
|
||||
*/
|
||||
function process_exec()
|
||||
{
|
||||
$exec = $GLOBALS['HTTP_POST_VARS']['etemplate_exec'];
|
||||
//echo "<p>uietemplate.process_exec('${exec['name']}'): exec = "; _debug_array($exec);
|
||||
$session_data = $this->get_appsession($GLOBALS['HTTP_POST_VARS']['etemplate_exec_id']);
|
||||
|
||||
$this->read($exec);
|
||||
$readonlys = unserialize(stripslashes($exec['readonlys']));
|
||||
//echo "<p>uietemplate.process_exec: process_show(cname=${exec['cname']}): readonlys ="; _debug_array($readonlys);
|
||||
$this->process_show($GLOBALS['HTTP_POST_VARS'][$exec['cname']],$readonlys);
|
||||
$content = $GLOBALS['HTTP_POST_VARS']['exec'];
|
||||
if (!is_array($content))
|
||||
{
|
||||
$content = array();
|
||||
}
|
||||
$this->read($session_data);
|
||||
$this->process_show($content,$session_data['readonlys']);
|
||||
|
||||
// set application name so that lang, etc. works
|
||||
list($GLOBALS['phpgw_info']['flags']['currentapp']) = explode('.',$exec['method']);
|
||||
list($GLOBALS['phpgw_info']['flags']['currentapp']) = explode('.',$session_data['method']);
|
||||
|
||||
//echo "<p>uietemplate.process_exec: ExecMethod('${exec['method']}')</p>\n";
|
||||
ExecMethod($exec['method']);
|
||||
ExecMethod($session_data['method'],array_merge($content,$session_data['preserv']));
|
||||
}
|
||||
|
||||
/*!
|
||||
@ -588,11 +594,16 @@
|
||||
|
||||
if ($idx_cname == '' && $cell['type'] == 'template') // only templates
|
||||
{
|
||||
if ($readonly) // can't unset whole content!!!
|
||||
if ($readonly && !isset($readonlys['__ALL__'])) // can't unset whole content!!!
|
||||
{
|
||||
$readonlys['__ALL__'] = True;
|
||||
$this->process_show_cell($cell,$name,$c,$r,$readonlys,$content);
|
||||
unset($readonlys['__ALL__']); // unset it after or everything gets set readonly
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->process_show_cell($cell,$name,$c,$r,$readonlys,$content);
|
||||
}
|
||||
$this->process_show_cell($cell,$name,$c,$r,$readonlys,$content);
|
||||
}
|
||||
elseif (ereg('^([^[]*)\\[(.*)\\]$',$idx_cname,$regs)) // name contains array-index
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user