forked from extern/egroupware
rework of home area (moving of portal_boxes, deletion of portal_boxes); modification/fixes to preferences::delete; adding app_id to trackers portal-box
This commit is contained in:
parent
897209a04b
commit
5339d85c56
104
home/index.php
104
home/index.php
@ -92,22 +92,6 @@
|
||||
$GLOBALS['tpl']->pfp('out','notify_window');
|
||||
}
|
||||
|
||||
/* This initializes the users portal_order preference if it does not exist. */
|
||||
if(!is_array($GLOBALS['egw_info']['user']['preferences']['portal_order']) && $GLOBALS['egw_info']['apps'])
|
||||
{
|
||||
$GLOBALS['egw']->preferences->delete('portal_order');
|
||||
@reset($GLOBALS['egw_info']['apps']);
|
||||
$order = 0;
|
||||
while (list(,$p) = each($GLOBALS['egw_info']['apps']))
|
||||
{
|
||||
if($GLOBALS['egw_info']['user']['apps'][$p['name']])
|
||||
{
|
||||
$GLOBALS['egw']->preferences->add('portal_order',$order++,$p['id']);
|
||||
}
|
||||
}
|
||||
$GLOBALS['egw_info']['user']['preferences'] = $GLOBALS['egw']->preferences->save_repository();
|
||||
}
|
||||
|
||||
if(is_array($GLOBALS['egw_info']['user']['preferences']['portal_order']))
|
||||
{
|
||||
$app_check = Array();
|
||||
@ -134,7 +118,10 @@
|
||||
// Now add the rest of the user's apps, to make sure we pick up any additions to the home display
|
||||
foreach($GLOBALS['egw_info']['user']['apps'] as $app)
|
||||
{
|
||||
$sorted_apps[] = $app['name'];
|
||||
if(!in_array($app['name'], $sorted_apps))
|
||||
{
|
||||
$sorted_apps[] = $app['name'];
|
||||
}
|
||||
}
|
||||
//$GLOBALS['egw']->hooks->process('home',$sorted_apps);
|
||||
|
||||
@ -208,6 +195,7 @@
|
||||
$lastd = 0;
|
||||
$numcols = 2;
|
||||
$curcol = 1;
|
||||
$searchlist = array();
|
||||
foreach($sorted_apps as $appname)
|
||||
{
|
||||
if((int)$done[$appname] == 1 || empty($appname))
|
||||
@ -230,45 +218,53 @@
|
||||
//echo "$appname: $thisd<br>";
|
||||
if($thisd>0)
|
||||
{
|
||||
if((($curcol++>$numcols) || ($thisd+$lastd==3)) && $tropen==1)
|
||||
{
|
||||
$GLOBALS['tpl']->pfp('out','end_row');
|
||||
$tropen = 0;
|
||||
//$curcol = 1;
|
||||
}
|
||||
if(!$tropen)
|
||||
{
|
||||
$GLOBALS['tpl']->pfp('out','begin_row');
|
||||
$tropen=1;
|
||||
}
|
||||
$var['tdwidth'] = ($thisd==2)?'50':'100';
|
||||
$var['colspan'] = ($thisd==2)?'1':'2';
|
||||
|
||||
ob_start();
|
||||
$var['content'] = $GLOBALS['egw']->hooks->single('home',$appname);
|
||||
if (!$var['content'] || $var['content'] == 1) // content has been echoed and not returned
|
||||
{
|
||||
$var['content'] = ob_get_contents();
|
||||
ob_end_clean();
|
||||
}
|
||||
$GLOBALS['tpl']->set_var($var);
|
||||
|
||||
$GLOBALS['tpl']->pfp('out','cell');
|
||||
|
||||
if(($thisd!=2 || ($thisd==2&&$lastd==2)) && $tropen)
|
||||
{
|
||||
$GLOBALS['tpl']->pfp('out','end_row');
|
||||
$tropen = 0;
|
||||
$lastd = 0;
|
||||
$curcol = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
$lastd = $thisd;
|
||||
}
|
||||
$searchlist[$appname] = $thisd;
|
||||
$neworder[] = $appname;
|
||||
$done[$appname] = 1;
|
||||
}
|
||||
}
|
||||
foreach($neworder as $index => $appname)
|
||||
{
|
||||
$thisd = $searchlist[$appname];
|
||||
//echo "$appname: $thisd<br>";
|
||||
if((($curcol++>$numcols) || ($thisd==1)) && $tropen==1)
|
||||
{
|
||||
$GLOBALS['tpl']->pfp('out','end_row');
|
||||
$tropen = 0;
|
||||
//$curcol = 1;
|
||||
}
|
||||
if(!$tropen)
|
||||
{
|
||||
$GLOBALS['tpl']->pfp('out','begin_row');
|
||||
$tropen=1;
|
||||
}
|
||||
|
||||
$small = ($thisd>1) && (count($neworder) > $index + 1) && ($searchlist[$neworder[$index + 1]] > 1);
|
||||
$var['tdwidth'] = $small ? '50' : '100';
|
||||
$var['colspan'] = $small ? '1' : '2';
|
||||
|
||||
ob_start();
|
||||
$var['content'] = $GLOBALS['egw']->hooks->single('home',$appname);
|
||||
if (!$var['content'] || $var['content'] == 1) // content has been echoed and not returned
|
||||
{
|
||||
$var['content'] = ob_get_contents();
|
||||
ob_end_clean();
|
||||
}
|
||||
$GLOBALS['tpl']->set_var($var);
|
||||
|
||||
$GLOBALS['tpl']->pfp('out','cell');
|
||||
|
||||
if(($thisd<=1 || ($thisd>1&&$lastd>1)) && $tropen && $var['content'])
|
||||
{
|
||||
$GLOBALS['tpl']->pfp('out','end_row');
|
||||
$tropen = 0;
|
||||
$lastd = 0;
|
||||
$curcol = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
$lastd = $thisd;
|
||||
}
|
||||
$done[$appname] = 1;
|
||||
}
|
||||
|
||||
$GLOBALS['tpl']->pfp('out','end_table');
|
||||
|
@ -482,7 +482,7 @@ class preferences
|
||||
}
|
||||
break;
|
||||
|
||||
case user:
|
||||
case 'user':
|
||||
default:
|
||||
$this->user[$app_name][$var] = $value;
|
||||
if (!isset($this->forced[$app_name][$var]) || $this->forced[$app_name][$var] === '')
|
||||
@ -520,38 +520,39 @@ class preferences
|
||||
}
|
||||
$pref = &$this->$type;
|
||||
|
||||
if (($all = (is_string($var) && $var == '')))
|
||||
//if (($all = (is_string($var) && $var == ''))) // old condition replaced, as all ($all) means that var is not a string and does not have content
|
||||
if (($all = empty($var))) // to check if $var is regarded as empty (false, 0, '', null, array() should do the trick
|
||||
{
|
||||
unset($pref[$app_name]);
|
||||
$pref[$app_name] = null;
|
||||
unset($this->data[$app_name]);
|
||||
}
|
||||
else
|
||||
{
|
||||
unset($pref[$app_name][$var]);
|
||||
$pref[$app_name][$var] = null;
|
||||
unset($this->data[$app_name][$var]);
|
||||
}
|
||||
// set the effectiv pref again if needed
|
||||
//
|
||||
foreach ($set_via[$type] as $set_from)
|
||||
{
|
||||
$arr = &$this->$set_from;
|
||||
if ($all)
|
||||
{
|
||||
if (isset($this->$set_from[$app_name]))
|
||||
if (isset($arr[$app_name]))
|
||||
{
|
||||
$this->data[$app_name] = $this->$set_from[$app_name];
|
||||
$this->data[$app_name] = $arr[$app_name];
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$arr = $this->$set_from;
|
||||
if($var && @isset($arr[$app_name][$var]) && $arr[$app_name][$var] !== '')
|
||||
{
|
||||
$this->data[$app_name][$var] = $this->$set_from[$app_name][$var];
|
||||
$this->data[$app_name][$var] = $arr[$app_name][$var];
|
||||
break;
|
||||
}
|
||||
unset($arr);
|
||||
}
|
||||
unset($arr);
|
||||
}
|
||||
reset ($this->data);
|
||||
return $this->data;
|
||||
|
17
set_box.php
17
set_box.php
@ -25,7 +25,8 @@
|
||||
|
||||
function move_boxes($curr_position,$new_order,$offset,$value_to_check,$max_num)
|
||||
{
|
||||
//echo "MOVE: $curr_position,$new_order,$offset,$value_to_check,$max_num<br>";
|
||||
//error_log(__METHOD__."MOVE: $curr_position,$new_order,$offset,$value_to_check,$max_num<br>");
|
||||
$move_app_id = (int)$GLOBALS['egw_info']['user']['preferences']['portal_order'][$curr_position];
|
||||
if(isset($GLOBALS['egw_info']['user']['preferences']['portal_order'][$new_order]))
|
||||
{
|
||||
if($new_order == $max_num)
|
||||
@ -38,24 +39,21 @@
|
||||
{
|
||||
@krsort($GLOBALS['egw_info']['user']['preferences']['portal_order']);
|
||||
}
|
||||
while(list($seq_order,$appid) = each($GLOBALS['egw_info']['user']['preferences']['portal_order']))
|
||||
foreach($GLOBALS['egw_info']['user']['preferences']['portal_order'] as $seq_order => $appid)
|
||||
{
|
||||
if($seq_order != $value_to_check)
|
||||
{
|
||||
$prev_seq = $seq_order + $offset;
|
||||
$GLOBALS['egw']->preferences->delete('portal_order',$prev_seq);
|
||||
$GLOBALS['egw']->preferences->add('portal_order',$prev_seq,$appid);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$GLOBALS['egw']->preferences->delete('portal_order',$curr_position);
|
||||
$GLOBALS['egw']->preferences->add('portal_order',$curr_position,(int)$GLOBALS['egw_info']['user']['preferences']['portal_order'][$new_order]);
|
||||
}
|
||||
}
|
||||
$GLOBALS['egw']->preferences->delete('portal_order',$new_order);
|
||||
$GLOBALS['egw']->preferences->add('portal_order',$new_order,(int)$_GET['app']);
|
||||
$GLOBALS['egw']->preferences->add('portal_order',$new_order,$move_app_id);
|
||||
|
||||
$GLOBALS['egw']->preferences->save_repository();
|
||||
}
|
||||
@ -93,8 +91,11 @@
|
||||
move_boxes($curr_position,$new_order,$offset,$max_count,0);
|
||||
break;
|
||||
case 'close':
|
||||
$GLOBALS['egw']->preferences->add($GLOBALS['egw']->applications->id2name($_GET['app']), 'homepage_display', 0);
|
||||
$GLOBALS['egw']->preferences->save_repository();
|
||||
$portal_varnames = array('mainscreen_showevents', 'homeShowEvents','homeShowLatest','mainscreen_showmail','mainscreen_showbirthdays','mainscreen_show_new_updated','homepage_display');
|
||||
$appname = $GLOBALS['egw']->applications->id2name($_GET['app']);
|
||||
foreach($portal_varnames as $varname)
|
||||
$GLOBALS['egw']->preferences->add($appname, $varname, 0);
|
||||
$GLOBALS['egw_info']['user']['preferences'] = $GLOBALS['egw']->preferences->save_repository();
|
||||
break;
|
||||
case 'edit':
|
||||
case 'question':
|
||||
|
Loading…
Reference in New Issue
Block a user