[ Index ]
 

Code source de eGroupWare 1.2.106-2

Accédez au Source d'autres logiciels libresSoutenez Angelica Josefina !

title

Body

[fermer]

/home/ -> index.php (source)

   1  <?php
   2    /**************************************************************************\
   3    * eGroupWare                                                               *
   4    * http://www.egroupware.org                                                *
   5    * The file written by Joseph Engo <jengo@phpgroupware.org>                 *
   6    * This file modified by Greg Haygood <shrykedude@bellsouth.net>            *
   7    * This file modified by Edo van Bruggend <edovanbruggen@raketnet.nl>       *
   8    * --------------------------------------------                             *
   9    *  This program is free software; you can redistribute it and/or modify it *
  10    *  under the terms of the GNU General Public License as published by the   *
  11    *  Free Software Foundation; either version 2 of the License, or (at your  *
  12    *  option) any later version.                                              *
  13    \**************************************************************************/
  14  
  15    /* $Id: index.php 21296 2006-04-09 05:53:25Z ralfbecker $ */
  16  
  17      /*
  18      ** Initializing the home application
  19      */
  20      $GLOBALS['egw_info'] = array(
  21          'flags' => array(
  22              'noheader'                => False,
  23              'nonavbar'                => False,
  24              'currentapp'              => 'home',
  25              'enable_network_class'    => False,
  26              'enable_contacts_class'   => False,
  27              'enable_nextmatchs_class' => False
  28          )
  29      );
  30  
  31      include('../header.inc.php');
  32  
  33      /*
  34      ** Initializing the template
  35      */
  36  
  37      $GLOBALS['tpl'] =& CreateObject('phpgwapi.Template',$GLOBALS['egw']->common->get_tpl_dir('home'));
  38      $GLOBALS['tpl']->set_unknowns('remove');
  39  
  40      $GLOBALS['tpl']->set_file(
  41          array(
  42              'home' => 'home.tpl'
  43          )
  44      );
  45  
  46      $GLOBALS['tpl']->set_block('home','notify_window','notify_window');
  47      $GLOBALS['tpl']->set_block('home','begin_table','begin_table');
  48      $GLOBALS['tpl']->set_block('home','end_table','end_table');
  49      $GLOBALS['tpl']->set_block('home','begin_row','begin_row');
  50      $GLOBALS['tpl']->set_block('home','end_row','end_row');
  51      $GLOBALS['tpl']->set_block('home','cell','cell');
  52  
  53      // Commented by alpeb: The following prevented anonymous users to get a home page. Perhaps it was done with anonymous users such as the ones
  54      // used by  wiki and sitemgr in mind. However, if you mark a normal user as anonymous just to avoid being shown in sessions and access log (like you would for an admin that doesn't want to be noticed), the user won't be able to login anymore. That's why I commented the code.
  55      /*if ($GLOBALS['egw']->session->session_flags == 'A')
  56      {
  57          if ($_SERVER['HTTP_REFERER'] && strstr($_SERVER['HTTP_REFERER'],'home.php') === False)
  58          {
  59              $GLOBALS['egw']->redirect($_SERVER['HTTP_REFERER']);
  60          }
  61          else
  62          {
  63              // redirect to the login-page, better then giving an empty page
  64              $GLOBALS['egw']->redirect('login.php');
  65          }
  66          exit;
  67      }*/
  68  
  69      /*
  70      ** Show the updates
  71      */
  72      $GLOBALS['egw']->hooks->single('showUpdates','home');
  73  
  74      /*
  75      ** Display the mainscreen message
  76      */
  77      $GLOBALS['egw']->translation->add_app('mainscreen');
  78      if (lang('mainscreen_message') != 'mainscreen_message*')
  79      {
  80          echo '<div style="text-align: center;">' . lang('mainscreen_message') . "</div>\n";
  81      }
  82  
  83      /*
  84      ** Display the notification window
  85      */
  86      if (isset($GLOBALS['egw_info']['user']['apps']['notifywindow']) && $GLOBALS['egw_info']['user']['apps']['notifywindow'])
  87      {
  88          $var['link'] = $GLOBALS['egw']->link('/notify.php');
  89          $var['notifywindow'] = lang('Open notify window');
  90          $GLOBALS['tpl']->set_var($var);
  91          $GLOBALS['tpl']->pfp('out','notify_window');
  92      }
  93  
  94      /* This initializes the users portal_order preference if it does not exist. */
  95      if(!is_array($GLOBALS['egw_info']['user']['preferences']['portal_order']) && $GLOBALS['egw_info']['apps'])
  96      {
  97          $GLOBALS['egw']->preferences->delete('portal_order');
  98          @reset($GLOBALS['egw_info']['apps']);
  99          $order = 0;
 100          while (list(,$p) = each($GLOBALS['egw_info']['apps']))
 101          {
 102              if($GLOBALS['egw_info']['user']['apps'][$p['name']])
 103              {
 104                  $GLOBALS['egw']->preferences->add('portal_order',$order++,$p['id']);
 105              }
 106          }
 107          $GLOBALS['egw_info']['user']['preferences'] = $GLOBALS['egw']->preferences->save_repository();
 108      }
 109  
 110      if(is_array($GLOBALS['egw_info']['user']['preferences']['portal_order']))
 111      {
 112          $app_check = Array();
 113          @ksort($GLOBALS['egw_info']['user']['preferences']['portal_order']);
 114          while(list($order,$app) = each($GLOBALS['egw_info']['user']['preferences']['portal_order']))
 115          {
 116              if(!isset($app_check[(int)$app]) || !$app_check[(int)$app])
 117              {
 118                  $app_check[(int)$app] = True;
 119                  $sorted_apps[] = $GLOBALS['egw']->applications->id2name((int)$app);
 120              }
 121          }
 122      }
 123      else
 124      {
 125          $sorted_apps = Array(
 126              'calendar',
 127              'email',
 128              'infolog',
 129              'news_admin'
 130          );
 131      }
 132  
 133      // Now add the rest of the user's apps, to make sure we pick up any additions to the home display
 134      foreach($GLOBALS['egw_info']['user']['apps'] as $app)
 135      {
 136          $sorted_apps[] = $app['name'];
 137      }
 138      //$GLOBALS['egw']->hooks->process('home',$sorted_apps);
 139  
 140      /*
 141      ** Migrate preferences
 142      ** @param $appname, $var_old, $var_new, $type='user'
 143      **
 144      */
 145  	function migrate_pref($appname,$var_old,$var_new,$type='user')
 146      {
 147          if(empty($appname) || empty($var_old) || empty($var_new))
 148          {
 149              return false;
 150          }
 151          $allowedtypes = array('user','default','forced');
 152          if($type=='all')
 153          {
 154              $types = $allowedtypes;
 155          }
 156          elseif(in_array($type,$allowedtypes))
 157          {
 158              $types[] = $type;
 159          }
 160          else
 161          {
 162              return false;
 163          }
 164          $result = false;
 165          foreach($types as $_type)
 166          {
 167              if(isset($GLOBALS['egw']->preferences->$_type[$appname][$var_old]))
 168              {
 169                  $GLOBALS['egw']->preferences->$_type[$appname][$var_new] =
 170                  $GLOBALS['egw']->preferences->$_type[$appname][$var_old];
 171                  $result = true;
 172                  $GLOBALS['egw_info']['user']['preferences'] =
 173                  $GLOBALS['egw']->preferences->save_repository(false,$_type);
 174              }
 175          }
 176          return $result;
 177      }
 178  
 179      $portal_oldvarnames = array('mainscreen_showevents', 'homeShowEvents','homeShowLatest','mainscreen_showmail','mainscreen_showbirthdays','mainscreen_show_new_updated');
 180      $migrate_oldvarnames = false;
 181      if($migrate_oldvarnames)
 182      {
 183          $_apps = $GLOBALS['egw_info']['user']['apps'];
 184          @reset($_apps);
 185          foreach($_apps as $_appname)
 186          {
 187              @reset($portal_oldvarnames);
 188              foreach($portal_oldvarnames as $varname)
 189              {
 190                  //echo "Want to migrate '$appname' from '$varname' to 'homepage_display'.<br>";
 191                  //migrate_pref($appname,$varname,'homepage_display','all');
 192              }
 193          }
 194      }
 195  
 196      $neworder = array();
 197      $done = array();
 198  
 199      /*
 200      ** Display application hooks
 201      **
 202      */
 203  
 204      $GLOBALS['tpl']->pfp('out','begin_table');
 205      $tropen=0;
 206      $tdopen=0;
 207      $lastd = 0;
 208      $numcols = 2;
 209      $curcol = 1;
 210      foreach($sorted_apps as $appname)
 211      {
 212          if((int)$done[$appname] == 1 || empty($appname))
 213          {
 214              continue;
 215          }
 216          $varnames = $portal_oldvarnames;
 217          $varnames[] = 'homepage_display';
 218          foreach($varnames as $varcheck)
 219          {
 220              //echo "$appname:$varcheck=".$GLOBALS['egw_info']['user']['preferences'][$appname][$varcheck]."<br>";
 221              $thisd = (int)$GLOBALS['egw_info']['user']['preferences'][$appname][$varcheck];
 222              if (!$thisd && $GLOBALS['egw_info']['user']['preferences'][$appname][$varcheck]) $thisd = 1;
 223              if($thisd>0)
 224              {
 225                  //echo "Found $appname=$_thisd through $varcheck<br>";
 226                  break;
 227              }
 228          }
 229          //echo "$appname: $thisd<br>";
 230          if($thisd>0)
 231          {
 232              if((($curcol++>$numcols) || ($thisd+$lastd==3)) && $tropen==1)
 233              {
 234                  $GLOBALS['tpl']->pfp('out','end_row');
 235                  $tropen = 0;
 236                  //$curcol = 1;
 237              }
 238              if(!$tropen)
 239              {
 240                  $GLOBALS['tpl']->pfp('out','begin_row');
 241                  $tropen=1;
 242              }
 243              $var['tdwidth'] = ($thisd==2)?'50':'100';
 244              $var['colspan'] = ($thisd==2)?'1':'2';
 245  
 246              ob_start();
 247              $var['content'] = $GLOBALS['egw']->hooks->single('home',$appname);
 248              if (!$var['content'] || $var['content'] == 1)    // content has been echoed and not returned
 249              {
 250                  $var['content'] = ob_get_contents();
 251                  ob_end_clean();
 252              }
 253              $GLOBALS['tpl']->set_var($var);
 254  
 255              $GLOBALS['tpl']->pfp('out','cell');
 256  
 257              if(($thisd!=2 || ($thisd==2&&$lastd==2)) && $tropen)
 258              {
 259                  $GLOBALS['tpl']->pfp('out','end_row');
 260                  $tropen = 0;
 261                  $lastd = 0;
 262                  $curcol = 1;
 263              }
 264              else
 265              {
 266                  $lastd = $thisd;
 267              }
 268              $neworder[] = $appname;
 269          }
 270          $done[$appname] = 1;
 271      }
 272  
 273      $GLOBALS['tpl']->pfp('out','end_table');
 274  
 275      // Update stored value of order
 276      //_debug_array($neworder);
 277      if(count($neworder)>0)//$GLOBALS['portal_order'])
 278      {
 279          $GLOBALS['egw']->preferences->delete('portal_order');
 280          @reset($neworder);
 281          while(list($app_order,$app_name) = each($neworder))
 282          {
 283              $app_id = $GLOBALS['egw']->applications->name2id($app_name);
 284              //echo "neworder: $app_order=$app_id:$app_name<br>";
 285              $GLOBALS['egw']->preferences->add('portal_order',$app_order,$app_id);
 286          }
 287          $GLOBALS['egw_info']['user']['preferences'] = $GLOBALS['egw']->preferences->save_repository();
 288      }
 289      //_debug_array($GLOBALS['egw_info']['user']['preferences']);
 290  
 291      //$GLOBALS['egw']->common->debug_phpgw_info();
 292      //$GLOBALS['egw']->common->debug_list_core_functions();
 293      $GLOBALS['egw']->common->egw_footer();
 294  ?>


Généré le : Sun Feb 25 17:20:01 2007 par Balluche grâce à PHPXref 0.7