gosa-project / gosa-plugins-schoolmanager

GOsa Add-On for Managing Schools
GNU General Public License v2.0
3 stars 5 forks source link

content_importaccounts.tpl contains bogus if elseif else clauses #58

Open sunweaver opened 2 years ago

sunweaver commented 2 years ago

Today I saw plenty of these error messages:

Jul  6 17:06:41 tjener php: GOsa[gabmik]: (view) error : PHP error: Undefined offset: 0 (/var/spool/gosa/297a1c24ad8d79b2a5b76fa519ebf4367eb533f8_0.file.content_importaccounts.tpl.php, line 2730) 
Jul  6 17:06:41 tjener php: GOsa[gabmik]: (view) error : PHP error: Undefined offset: 0 (/var/spool/gosa/297a1c24ad8d79b2a5b76fa519ebf4367eb533f8_0.file.content_importaccounts.tpl.php, line 2730) 

Originating from:

<?php if ($_smarty_tpl->tpl_vars['property']->value != "userPassword" || (isset($_smarty_tpl->tpl_vars['aux_account']->value[$_smarty_tpl->tpl_vars['property']->value][0]) && $_smarty_tpl->tpl_vars['aux_account']->value[$_smarty_tpl->tpl_vars['property']->value][0] === '')) {?>
                                                <?php echo $_smarty_tpl->tpl_vars['aux_account']->value[$_smarty_tpl->tpl_vars['property']->value][0];?>

Rendered from:

{if $property != "userPassword" || ( isset ($aux_account[$property][0]) && $aux_account[$property][0]==="" )}
                                                {$aux_account[$property][0]}
{elseif strpos($aux_account['_status'][0],"exists")!==FALSE }
                                                {t}<keep>{/t}
{elseif strpos($aux_account['_status'][0],"data-incomplete")!==FALSE }
{else}
                                                ************
{/if}

I stared at this if-clause for 20min now and can't make out what it should actually do.

Further up in the code there is another bit like this for the main account:

{if ($property != "userPassword" && $property != "alias") || ( isset($data[$key]['main_account'][$property][0]) && $data[$key]['main_account'][$property][0]==="" )}
                                                {$data[$key]['main_account'][$property][0]}
{elseif $property == "userPassword" && strpos($data[$key]['main_account']['_status'][0],"exists")!==FALSE }
                                                {t}<keep>{/t}
{elseif strpos($data[$key]['main_account']['_status'][0],"data-incomplete")!==FALSE }
{elseif $property == "alias" }
{foreach from=$data[$key]['main_account']['alias'] item=alias key=idx}
{if "$idx" != "count" }
                                                {$alias}<br>
{/if}
{/foreach}
{else}
                                                ************
{/if}

Esp. the first line "{if $property != "userPassword" || ( isset ($aux_account[$property][0]) && $aux_account[$property][0]==="" )}" doesn't really make much sense...

This needs a deep breath and possibly a simplification.