[ Index ]
 

Code source de eGroupWare 1.2.106-2

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

title

Body

[fermer]

/timesheet/inc/ -> class.ts_admin_prefs_sidebox_hooks.inc.php (source)

   1  <?php
   2  /**************************************************************************\
   3  * eGroupWare - TimeSheet: Admin-, Preferences- and SideboxMenu-Hooks       *
   4  * http://www.eGroupWare.org                                                *
   5  * Written and (c) 2005 by Ralf Becker <RalfBecker@outdoor-training.de>     *
   6  * -------------------------------------------------------                  *
   7  *  This program is free software; you can redistribute it and/or modify it *
   8  *  under the terms of the GNU General Public License as published by the   *
   9  *  Free Software Foundation; either version 2 of the License, or (at your  *
  10  *  option) any later version.                                              *
  11  \**************************************************************************/
  12  
  13  /* $Id: class.ts_admin_prefs_sidebox_hooks.inc.php 20295 2006-02-15 12:31:25Z  $ */
  14  
  15  if (!defined('TIMESHEET_APP'))
  16  {
  17      define('TIMESHEET_APP','timesheet');
  18  }
  19  
  20  class ts_admin_prefs_sidebox_hooks
  21  {
  22      var $public_functions = array(
  23  //        'check_set_default_prefs' => true,
  24      );
  25      var $config = array();
  26  
  27  	function pm_admin_prefs_sidebox_hooks()
  28      {
  29          $config =& CreateObject('phpgwapi.config',TIMESHEET_APP);
  30          $config->read_repository();
  31          $this->config =& $config->config_data;
  32          unset($config);
  33      }
  34  
  35      /**
  36       * hooks to build projectmanager's sidebox-menu plus the admin and preferences sections
  37       *
  38       * @param string/array $args hook args
  39       */
  40  	function all_hooks($args)
  41      {
  42          $appname = TIMESHEET_APP;
  43          $location = is_array($args) ? $args['location'] : $args;
  44          //echo "<p>ts_admin_prefs_sidebox_hooks::all_hooks(".print_r($args,True).") appname='$appname', location='$location'</p>\n";
  45  
  46          if ($location == 'sidebox_menu')
  47          {
  48              $file = array(
  49              );
  50              display_sidebox($appname,$GLOBALS['egw_info']['apps'][$appname]['title'].' '.lang('Menu'),$file);
  51          }
  52  
  53          if ($GLOBALS['egw_info']['user']['apps']['preferences'] && $location != 'admin')
  54          {
  55              $file = array(
  56  //                'Preferences'     => $GLOBALS['egw']->link('/index.php','menuaction=preferences.uisettings.index&appname='.$appname),
  57                  'Grant Access'    => $GLOBALS['egw']->link('/index.php','menuaction=preferences.uiaclprefs.index&acl_app='.$appname),
  58                  'Edit Categories' => $GLOBALS['egw']->link('/index.php','menuaction=preferences.uicategories.index&cats_app=' . $appname . '&cats_level=True&global_cats=True')
  59              );
  60              if ($location == 'preferences')
  61              {
  62                  display_section($appname,$file);
  63              }
  64              else
  65              {
  66                  display_sidebox($appname,lang('Preferences'),$file);
  67              }
  68          }
  69  
  70          if ($GLOBALS['egw_info']['user']['apps']['admin'] && $location != 'preferences')
  71          {
  72              $file = Array(
  73  //                'Site configuration' => $GLOBALS['egw']->link('/index.php','menuaction=projectmanager.admin.config'),
  74  //                'Custom fields' => $GLOBALS['egw']->link('/index.php','menuaction=admin.customfields.edit&appname='.$appname),
  75                  'Global Categories'  => $GLOBALS['egw']->link('/index.php',array(
  76                      'menuaction' => 'admin.uicategories.index',
  77                      'appname'    => $appname,
  78                      'global_cats'=> True)),
  79              );
  80              if ($location == 'admin')
  81              {
  82                  display_section($appname,$file);
  83              }
  84              else
  85              {
  86                  display_sidebox($appname,lang('Admin'),$file);
  87              }
  88          }
  89      }
  90      
  91      /**
  92       * populates $GLOBALS['settings'] for the preferences
  93       */
  94  	function settings()
  95      {
  96          $this->check_set_default_prefs();
  97  
  98          return true;    // otherwise prefs say it cant find the file ;-)
  99      }
 100      
 101      /**
 102       * Check if reasonable default preferences are set and set them if not
 103       *
 104       * It sets a flag in the app-session-data to be called only once per session
 105       */
 106  	function check_set_default_prefs()
 107      {
 108          if ($GLOBALS['egw']->session->appsession('default_prefs_set',TIMESHEET_APP))
 109          {
 110              return;
 111          }
 112          $GLOBALS['egw']->session->appsession('default_prefs_set',TIMESHEET_APP,'set');
 113  
 114          $default_prefs =& $GLOBALS['egw']->preferences->default[TIMESHEET_APP];
 115  
 116          $defaults = array(
 117          );
 118          foreach($defaults as $var => $default)
 119          {
 120              if (!isset($default_prefs[$var]) || $default_prefs[$var] === '')
 121              {
 122                  $GLOBALS['egw']->preferences->add(TIMESHEET_APP,$var,$default,'default');
 123                  $need_save = True;
 124              }
 125          }
 126          if ($need_save)
 127          {
 128              $GLOBALS['egw']->preferences->save_repository(False,'default');
 129          }
 130      }
 131  }


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