How does one uses conditions in Roundcube's templates?
I tried this in taskbar.html:
And it always shows the button, even if $_SESSION['admin'] evaluates to false.
I tested with:
$_SESSION=false;
$_SESSION=0;
(and by not setting $_SESSION['admin'] at all)
Thanks.
Since 0.1.0 stable $_SESSION is managed by $USER object. This means you have to store $_SESSION['admin'] in the user properties (Database !) before you can use it...
$a_prefs = $USER->get_prefs();
$a_prefs = .... your modifications
$USER->save_prefs($a_user);
unset($USER);
$USER = new rcube_user($_SESSION['user_id']);
... now you modifications are present in the $CONFIG and you can use ...
config:admin
SECURITY ... SECURITY
-Roland
I have modifyed taskbar.html in this way (and also main.inc.php adding config var flag_admin).
<div id="taskbar">
<roundcube:button command="mail" label="mail" class="button-mail" />
<roundcube:button command="addressbook" label="addressbook" class="button-addressbook" />
<roundcube:button command="settings" label="settings" class="button-settings" />
<roundcube:button command="logout" label="logout" class="button-logout" />
<roundcube:if condition="config:flag_admin == true" />
<roundcube:button command="admin" label="admin" class="button-admin" />
<roundcube:endif />
</div>
Condition in var_dump debugging is working (switching config var true or false), but
the content of if condition is always displayed (not switch).
Someone is able to do this? :eek:
My debugging is based on rcube_template.php modifying
private function xml_command($command, $str_attrib, $add_attrib = array())
{
$command = strtolower($command);
$attrib = parse_attrib_string($str_attrib) + $add_attrib;
var_dump($attrib);
echo 'command: '.$command."\n";
echo 'check: '.$this->check_condition($attrib['condition'])."\n\n";
// empty output if required condition is not met
if (!empty($attrib['condition']) && !$this->check_condition($attrib['condition'])) {
echo "\nRitorna vuoto!!\n";
return '';
}
so I can see that condition is working (eg false) but in the next call to xml_command
is still visible.
Why?