[ Index ]
 

Code source de eGroupWare 1.2.106-2

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

title

Body

[fermer]

/calendar/inc/ -> class.uical.inc.php (source)

   1  <?php
   2  /**************************************************************************\
   3  * eGroupWare - Calendar - shared base-class of all calendar UI classes     *
   4  * http://www.egroupware.org                                                *
   5  * Written and (c) 2004/5 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.uical.inc.php 21964 2006-06-24 17:34:38Z ralfbecker $ */
  14  
  15  /**
  16   * Shared base-class of all calendar UserInterface classes
  17   *
  18   * It manages eg. the state of the controls in the UI and generated the calendar navigation (sidebox-menu)
  19   *
  20   * The new UI, BO and SO classes have a strikt definition, in which time-zone they operate:
  21   *  UI only operates in user-time, so there have to be no conversation at all !!!
  22   *  BO's functions take and return user-time only (!), they convert internaly everything to servertime, because
  23   *  SO operates only on server-time
  24   *
  25   * All permanent debug messages of the calendar-code should done via the debug-message method of the bocal class !!!
  26   *
  27   * @package calendar
  28   * @author Ralf Becker <RalfBecker-AT-outdoor-training.de>
  29   * @copyright (c) 2004/5 by RalfBecker-At-outdoor-training.de
  30   * @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
  31   */
  32  class uical
  33  {
  34      /**
  35       * @var $debug mixed integer level or string function-name
  36       */
  37      var $debug=false;
  38      /**
  39       * @var $bo class bocal
  40       */
  41      var $bo,$jscal,$html,$datetime,$cats,$accountsel;
  42      /**
  43       * @var array $common_prefs reference to $GLOBALS['egw_info']['user']['preferences']['common']
  44       */
  45      var $common_prefs;
  46      /**
  47       * @var array $cal_prefs reference to $GLOBALS['egw_info']['user']['preferences']['calendar']
  48       */
  49      var $cal_prefs;
  50      /**
  51       * @var int $wd_start user pref. workday start
  52       */
  53      var $wd_start;
  54      /**
  55       * @var int $wd_start user pref. workday end
  56       */
  57      var $wd_end;
  58      /**
  59       * @var int $interval_m user pref. interval
  60       */
  61      var $interval_m;
  62      /**
  63       * @var int $user account_id of loged in user
  64       */
  65      var $user;
  66      /**
  67       * @var string $date session-state: date (Ymd) of shown view
  68       */
  69      var $date;
  70      /**
  71       * @var int $cat_it session-state: selected category
  72       */
  73      var $cat_id;
  74      /**
  75       * @var int $filter session-state: selected filter, NOT used at the moment (was all or private)
  76       */
  77      var $filter;
  78      /**
  79       * @var int/array $owner session-state: selected owner(s) of shown calendar(s)
  80       */
  81      var $owner;
  82      /**
  83       * @var string $sortby session-state: filter of planner: 'category' or 'user'
  84       */
  85      var $sortby;
  86      /**
  87       * @var string $view session-state: selected view
  88       */
  89      var $view;
  90      /**
  91       * @var string $view menuaction of the selected view
  92       */
  93      var $view_menuaction;
  94      
  95      /**
  96       * @var int $first first day of the shown view
  97       */
  98      var $first;
  99      /**
 100       * @var int $last last day of the shown view
 101       */
 102      var $last;
 103  
 104      /**
 105       * Constructor
 106       *
 107       * @param boolean $use_bocalupdate use bocalupdate as parenent instead of bocal
 108       * @param array $set_states=null to manualy set / change one of the states, default NULL = use $_REQUEST
 109       */
 110  	function uical($use_bocalupdate=false,$set_states=NULL)
 111      {
 112          foreach(array(
 113              'bo'    => $use_bocalupdate ? 'calendar.bocalupdate' : 'calendar.bocal',
 114              'jscal' => 'phpgwapi.jscalendar',    // for the sidebox-menu
 115              'html'  => 'phpgwapi.html',
 116              'datetime' => 'phpgwapi.datetime',
 117              'accountsel' => 'phpgwapi.uiaccountsel',
 118          ) as $my => $app_class)
 119          {
 120              list(,$class) = explode('.',$app_class);
 121  
 122              if (!is_object($GLOBALS['egw']->$class))
 123              {
 124                  $GLOBALS['egw']->$class =& CreateObject($app_class);
 125              }
 126              $this->$my = &$GLOBALS['egw']->$class;
 127          }
 128          if (!is_object($this->cats))
 129          {
 130              $this->cats =& CreateObject('phpgwapi.categories','','calendar');    // we need an own instance to get the calendar cats
 131          }
 132          $this->common_prefs    = &$GLOBALS['egw_info']['user']['preferences']['common'];
 133          $this->cal_prefs    = &$GLOBALS['egw_info']['user']['preferences']['calendar'];
 134          $this->wd_start        = 60*$this->cal_prefs['workdaystarts'];
 135          $this->wd_end        = 60*$this->cal_prefs['workdayends'];
 136          $this->interval_m    = $this->cal_prefs['interval'];
 137  
 138          $this->user = $GLOBALS['egw_info']['user']['account_id'];
 139  
 140          $this->manage_states($set_states);
 141  
 142          $GLOBALS['uical'] = &$this;    // make us available for ExecMethod, else it creates a new instance
 143          
 144          // calendar does not work with hidden sidebox atm.
 145          unset($GLOBALS['egw_info']['user']['preferences']['common']['auto_hide_sidebox']);
 146      }
 147      
 148      /**
 149       * Checks and terminates (or returns for home) with a message if $this->owner include a user/resource we have no read-access to
 150       *
 151       * If currentapp == 'home' we return the error instead of terminating with it !!!
 152       *
 153       * @return boolean/string false if there's no error or string with error-message
 154       */
 155  	function check_owners_access()
 156      {
 157          $no_access = $no_access_group = array();
 158          foreach(explode(',',$this->owner) as $owner)
 159          {
 160              if (is_numeric($owner) && $GLOBALS['egw']->accounts->get_type($owner) == 'g')
 161              {
 162                  foreach($GLOBALS['egw']->accounts->member($owner) as $member)
 163                  {
 164                      $member = $member['account_id'];
 165                      if (!$this->bo->check_perms(EGW_ACL_READ,0,$member))
 166                      {
 167                          $no_access_group[$member] = $this->bo->participant_name($member);
 168                      } 
 169                  }
 170              }
 171              elseif (!$this->bo->check_perms(EGW_ACL_READ,0,$owner))
 172              {
 173                  $no_access[$owner] = $this->bo->participant_name($owner);
 174              }
 175          }
 176          if (count($no_access))
 177          {
 178              $msg = '<p class="redItalic" align="center">'.lang('Access denied to the calendar of %1 !!!',implode(', ',$no_access))."</p>\n";
 179          
 180              if ($GLOBALS['egw_info']['flags']['currentapp'] == 'home')
 181              {
 182                  return $msg;
 183              }
 184              $GLOBALS['egw']->common->egw_header();
 185              if ($GLOBALS['egw_info']['flags']['nonavbar']) parse_navbar();
 186  
 187              echo $msg;
 188  
 189              $GLOBALS['egw']->common->egw_footer();
 190              $GLOBALS['egw']->common->egw_exit();
 191          }
 192          if (count($no_access_group))
 193          {
 194              $this->group_warning = lang('Groupmember(s) %1 not included, because you have no access.',implode(', ',$no_access_group));
 195          }
 196          return false;
 197      }
 198      
 199      /**
 200       * show the egw-framework plus possible messages ($_GET['msg'] and $this->group_warning from check_owner_access)
 201       */
 202  	function do_header()
 203      {
 204          $GLOBALS['egw']->common->egw_header();
 205          
 206          if ($_GET['msg']) echo '<p class="redItalic" align="center">'.$this->html->htmlspecialchars($_GET['msg'])."</p>\n";
 207  
 208          if ($this->group_warning) echo '<p class="redItalic" align="center">'.$this->group_warning."</p>\n";
 209      }
 210  
 211      /**
 212       * Manages the states of certain controls in the UI: date shown, category selected, ...
 213       *
 214       * The state of all these controls is updated if they are set in $_REQUEST or $set_states and saved in the session.
 215       * The following states are used:
 216       *    - date or year, month, day: the actual date of the period displayed
 217       *    - cat_id: the selected category
 218       *    - owner: the owner of the displayed calendar
 219       *    - save_owner: the overriden owner of the planner
 220       *    - filter: the used filter: no filter / all or only privat, NOT used atm.
 221       *    - sortby: category or user of planner
 222       *    - view: the actual view, where dialogs should return to or which they refresh
 223       * @param set_states array to manualy set / change one of the states, default NULL = use $_REQUEST
 224       */
 225  	function manage_states($set_states=NULL)
 226      {
 227          $states = $states_session = $GLOBALS['egw']->session->appsession('session_data','calendar');
 228  
 229          if (is_null($set_states))
 230          {
 231              $set_states = $_REQUEST;
 232          }
 233          if (!$states['date'] && $states['year'] && $states['month'] && $states['day'])
 234          {
 235              $states['date'] = $this->bo->date2string($states);
 236          }
 237  
 238          foreach(array(
 239              'date'       => $this->bo->date2string($this->bo->now_su),
 240              'cat_id'     => 0,
 241              'filter'     => 'all',
 242              'owner'      => $this->user,
 243              'save_owner' => 0,
 244              'sortby'     => 'category',
 245              'planner_days'=> 0,    // full month
 246              'view'       => $this->bo->cal_prefs['defaultcalendar'],
 247          ) as $state => $default)
 248          {
 249              if (isset($set_states[$state]))
 250              {
 251                  if ($state == 'owner')
 252                  {
 253                      // only change the owners of the same resource-type as given in set_state[owner]
 254                      $set_owners = explode(',',$set_states['owner']);
 255                      $res_type = is_numeric($set_owners[0]) ? false : $set_owners[0]{0};
 256                      $owners = explode(',',$states['owner'] ? $states['owner'] : $default);
 257                      foreach($owners as $key => $owner)
 258                      {
 259                          if (!$res_type && is_numeric($owner) || $res_type && $owner{0} == $res_type)
 260                          {
 261                              unset($owners[$key]);
 262                          }
 263                      }
 264                      if (!$res_type || !in_array($res_type.'0',$set_owners))
 265                      {
 266                          $owners = array_merge($owners,$set_owners);
 267                      }
 268                      $set_states['owner'] = implode(',',$owners);
 269                  }
 270                  // for the uiforms class (eg. edit), dont store the (new) owner, as it might change the view
 271                  if (substr($_GET['menuaction'],0,16) == 'calendar.uiforms')
 272                  {
 273                      $this->owner = $set_states[$state];
 274                      continue;
 275                  }
 276                  $states[$state] = $set_states[$state];
 277              }
 278              elseif (!is_array($states) || !isset($states[$state]))
 279              {
 280                  $states[$state] = $default;
 281              }
 282              if ($state == 'date')
 283              {
 284                  $date_arr = $this->bo->date2array($states['date']);
 285                  foreach(array('year','month','day') as $name)
 286                  {
 287                      $this->$name = $states[$name] = $date_arr[$name];
 288                  }
 289              }
 290              $this->$state = $states[$state];
 291          }
 292          if (substr($this->view,0,8) == 'planner_')
 293          {
 294              $states['sortby'] = $this->sortby = $this->view == 'planner_cat' ? 'category' : 'user';
 295              $states['view'] = $this->view = 'planner';
 296          }
 297          // set the actual view as return_to
 298          if ($_GET['menuaction'])
 299          {
 300              list($app,$class,$func) = explode('.',$_GET['menuaction']);
 301          }
 302          else    // eg. calendar/index.php
 303          {
 304              $func = $this->view;
 305              $class = $this->view == 'listview' ? 'uilist' : 'uiviews';
 306          }
 307          if ($class == 'uiviews' || $class == 'uilist')
 308          {
 309              // if planner_start_with_group is set in the users prefs: switch owner for planner to planner_start_with_group and back
 310              if ($this->cal_prefs['planner_start_with_group'])
 311              {
 312                  if ($this->cal_prefs['planner_start_with_group'] > 0) $this->cal_prefs['planner_start_with_group'] *= -1;    // fix old 1.0 pref
 313  
 314                  if (!$states_session && !$_GET['menuaction']) $this->view = '';        // first call to calendar 
 315  
 316                  if ($func == 'planner' && $this->view != 'planner' && $this->owner == $this->user)
 317                  {
 318                      //echo "<p>switched for planner to {$this->cal_prefs['planner_start_with_group']}, view was $this->view, func=$func, owner was $this->owner</p>\n";
 319                      $states['save_owner'] = $this->save_owner = $this->owner;
 320                      $states['owner'] = $this->owner = $this->cal_prefs['planner_start_with_group'];
 321                  }
 322                  elseif ($func != 'planner' && $this->view == 'planner' && $this->owner == $this->cal_prefs['planner_start_with_group'] && $this->save_owner)
 323                  {
 324                      //echo "<p>switched back to $this->save_owner, view was $this->view, func=$func, owner was $this->owner</p>\n";
 325                      $states['owner'] = $this->owner = $this->save_owner;
 326                      $states['save_owner'] = $this->save_owner = 0;
 327                  }
 328              }
 329              $this->view = $states['view'] = $func;
 330          }
 331          $this->view_menuaction = $this->view == 'listview' ? 'calendar.uilist.listview' : 'calendar.uiviews.'.$this->view;
 332  
 333          if ($this->debug > 0 || $this->debug == 'menage_states') $this->bo->debug_message('uical::manage_states(%1) session was %2, states now %3',True,$set_states,$states_session,$states);
 334          // save the states in the session
 335          $GLOBALS['egw']->session->appsession('session_data','calendar',$states);
 336      }
 337  
 338      /**
 339      * gets the icons displayed for a given event
 340      *
 341      * @param $event array
 342      * @return array of 'img' / 'title' pairs
 343      */
 344  	function event_icons($event)
 345      {
 346          $is_private = !$event['public'] && !$this->bo->check_perms(EGW_ACL_READ,$event);
 347          $viewable = !$this->bo->printer_friendly && $this->bo->check_perms(EGW_ACL_READ,$event);
 348  
 349          if (!$is_private)
 350          {
 351              if($event['priority'] == 3)
 352              {
 353                  $icons[] = $this->html->image('calendar','high',lang('high priority'));
 354              }
 355              if($event['recur_type'] != MCAL_RECUR_NONE)
 356              {
 357                  $icons[] = $this->html->image('calendar','recur',lang('recurring event'));
 358              }
 359              // icons for single user, multiple users or group(s) and resources
 360              foreach($event['participants'] as  $uid => $status)
 361              {
 362                  if(is_numeric($uid))
 363                  {
 364                      if (isset($icons['single']) || $GLOBALS['egw']->accounts->get_type($uid) == 'g')
 365                      {
 366                          unset($icons['single']);
 367                          $icons['multiple'] = $this->html->image('calendar','users');
 368                      }
 369                      elseif (!isset($icons['multiple']))
 370                      {
 371                          $icons['single'] = $this->html->image('calendar','single');
 372                      }
 373                  }                    
 374                  elseif(!isset($icons[$uid{0}]) && isset($this->bo->resources[$uid{0}]) && isset($this->bo->resources[$uid{0}]['icon']))
 375                  {
 376                       $icons[$uid{0}] = $this->html->image($this->bo->resources[$uid{0}]['app'],
 377                           ($this->bo->resources[$uid{0}]['icon'] ? $this->bo->resources[$uid{0}]['icon'] : 'navbar'),
 378                           lang($this->bo->resources[$uid{0}]['app']),
 379                           'width="16px" height="16px"');
 380                  }
 381              }
 382          }
 383          if($event['non_blocking'])
 384          {
 385              $icons[] = $this->html->image('calendar','nonblocking',lang('non blocking'));
 386          }
 387          if($event['public'] == 0)
 388          {
 389              $icons[] = $this->html->image('calendar','private',lang('private'));
 390          }
 391          if(isset($event['alarm']) && count($event['alarm']) >= 1 && !$is_private)
 392          {
 393              $icons[] = $this->html->image('calendar','alarm',lang('alarm'));
 394          }
 395          return $icons;
 396      }
 397  
 398      /**
 399      * Create a select-box item in the sidebox-menu
 400      * @privat used only by sidebox_menu !
 401      */
 402  	function _select_box($title,$name,$options,$baseurl='')
 403      {
 404          if ($baseurl)    // we append the value to the baseurl
 405          {
 406              $baseurl .= strstr($baseurl,'?') === False ? '?' : '&';
 407              $onchange="location='$baseurl'+this.value;";
 408          }
 409          else            // we add $name=value to the actual location
 410          {
 411              $onchange="location=location+(location.search.length ? '&' : '?')+'".$name."='+this.value;";
 412          }
 413          $select = ' <select style="width: 185px;" name="'.$name.'" onchange="'.$onchange.'" title="'.
 414              lang('Select a %1',lang($title)).'">'.
 415              $options."</select>\n";
 416  
 417          return array(
 418              'text' => $select,
 419              'no_lang' => True,
 420              'link' => False
 421          );
 422      }
 423  
 424      /**
 425       * Generate a link to add an event, incl. the necessary popup
 426       *
 427       * @param string $content content of the link
 428       * @param string $date=null which date should be used as start- and end-date, default null=$this->date
 429       * @param int $hour=null which hour should be used for the start, default null=$this->hour
 430       * @param int $minute=0 start-minute
 431       * @return string the link incl. content
 432       */
 433  	function add_link($content,$date=null,$hour=null,$minute=0)
 434      {
 435          $vars = array(
 436              'menuaction'=>'calendar.uiforms.edit',
 437              'date' => $date ? $date : $this->date,
 438          );
 439          if (!is_null($hour))
 440          {
 441              $vars['hour'] = $hour;
 442              $vars['minute'] = $minute;
 443          }
 444          return $this->html->a_href($content,'/index.php',$vars,' target="_blank" title="'.$this->html->htmlspecialchars(lang('Add')).
 445              '" onclick="'.$this->popup('this.href','this.target').'; return false;"');
 446      }
 447      
 448      /**
 449       * returns javascript to open a popup window: window.open(...)
 450       *
 451       * @param string $link link or this.href
 452       * @param string $target='_blank' name of target or this.target
 453       * @param int $width=750 width of the window
 454       * @param int $height=400 height of the window
 455       * @return string javascript (using single quotes)
 456       */
 457  	function popup($link,$target='_blank',$width=750,$height=410)
 458      {
 459          return 'egw_openWindowCentered2('.($link == 'this.href' ? $link : "'".$link."'").','.
 460              ($target == 'this.target' ? $target : "'".$target."'").",$width,$height,'yes')";
 461  
 462          return 'window.open('.($link == 'this.href' ? $link : "'".$link."'").','.
 463              ($target == 'this.target' ? $target : "'".$target."'").','.
 464              "'dependent=yes,width=$width,height=$height,scrollbars=yes,status=yes')";
 465      }
 466  
 467      /**
 468       * creates the content for the sidebox-menu, called as hook
 469       */
 470  	function sidebox_menu()
 471      {
 472          $base_hidden_vars = $link_vars = array();
 473          if (@$_POST['keywords'])
 474          {
 475              $base_hidden_vars['keywords'] = $_POST['keywords'];
 476          }
 477  
 478          $n = 0;    // index for file-array
 479  
 480          $planner_days_for_view = false;
 481          switch($this->view)
 482          {
 483              case 'month': $planner_days_for_view = 0; break;
 484              case 'week':  $planner_days_for_view = $this->cal_prefs['days_in_weekview'] == 5 ? 5 : 7; break;
 485              case 'day':   $planner_days_for_view = 1; break;
 486          }
 487          // Toolbar with the views
 488          $views = '<table style="width: 100%;"><tr>'."\n";
 489          foreach(array(
 490              'add' => array('icon'=>'new','text'=>'add'),
 491              'day' => array('icon'=>'today','text'=>'Today','menuaction' => 'calendar.uiviews.day','date' => $this->bo->date2string($this->bo->now_su)),
 492              'week' => array('icon'=>'week','text'=>'Weekview','menuaction' => 'calendar.uiviews.week'),
 493              'month' => array('icon'=>'month','text'=>'Monthview','menuaction' => 'calendar.uiviews.month'),
 494              'planner' => array('icon'=>'planner','text'=>'Group planner','menuaction' => 'calendar.uiviews.planner','sortby' => $this->sortby),
 495              'list' => array('icon'=>'list','text'=>'Listview','menuaction'=>'calendar.uilist.listview'),
 496          ) as $view => $data)
 497          {
 498              $icon = array_shift($data);
 499              $title = array_shift($data);
 500              $vars = array_merge($link_vars,$data);
 501  
 502              $icon = $this->html->image('calendar',$icon,lang($title));
 503              $link = $view == 'add' ? $this->add_link($icon) : $this->html->a_href($icon,'/index.php',$vars);
 504  
 505              $views .= '<td align="center">'.$link."</td>\n";
 506          }
 507          $views .= "</tr></table>\n";
 508  
 509          $file[++$n] = array('text' => $views,'no_lang' => True,'link' => False,'icon' => False);
 510  
 511          // special views and view-options menu
 512          $options = '';
 513          foreach(array(
 514              array(
 515                  'text' => lang('dayview'),
 516                  'value' => 'menuaction=calendar.uiviews.day',
 517                  'selected' => $this->view == 'day',
 518              ),
 519              array(
 520                  'text' => lang('four days view'),
 521                  'value' => 'menuaction=calendar.uiviews.day4',
 522                  'selected' => $this->view == 'day4',
 523              ),
 524              array(
 525                  'text' => lang('weekview with weekend'),
 526                  'value' => 'menuaction=calendar.uiviews.week&days=7',
 527                  'selected' => $this->view == 'week' && $this->cal_prefs['days_in_weekview'] != 5,
 528              ),
 529              array(
 530                  'text' => lang('weekview without weekend'),
 531                  'value' => 'menuaction=calendar.uiviews.week&days=5',
 532                  'selected' => $this->view == 'week' && $this->cal_prefs['days_in_weekview'] == 5,
 533              ),
 534              array(
 535                  'text' => lang('monthview'),
 536                  'value' => 'menuaction=calendar.uiviews.month',
 537                  'selected' => $this->view == 'month',
 538              ),
 539              array(
 540                  'text' => lang('planner by category'),
 541                  'value' => 'menuaction=calendar.uiviews.planner&sortby=category'.
 542                      ($planner_days_for_view !== false ? '&planner_days='.$planner_days_for_view : ''),
 543                  'selected' => $this->view == 'planner' && $this->sortby != 'user',
 544              ),
 545              array(
 546                  'text' => lang('planner by user'),
 547                  'value' => 'menuaction=calendar.uiviews.planner&sortby=user'.
 548                      ($planner_days_for_view !== false ? '&planner_days='.$planner_days_for_view : ''),
 549                  'selected' => $this->view == 'planner' && $this->sortby == 'user',
 550              ),
 551              array(
 552                  'text' => lang('listview'),
 553                  'value' => 'menuaction=calendar.uilist.listview',
 554                  'selected' => $this->view == 'listview',
 555              ),
 556          ) as $data)
 557          {
 558              $options .= '<option value="'.$data['value'].'"'.($data['selected'] ? ' selected="1"' : '').'>'.$this->html->htmlspecialchars($data['text'])."</option>\n";
 559          }
 560          $file[++$n] = $this->_select_box('displayed view','view',$options,$GLOBALS['egw']->link('/index.php'));
 561  
 562          // Search
 563          $blur = addslashes($this->html->htmlspecialchars(lang('Search').'...'));
 564          $value = @$_POST['keywords'] ? $this->html->htmlspecialchars($_POST['keywords']) : $blur;
 565          $file[++$n] = array(
 566              'text' => $this->html->form('<input name="keywords" value="'.$value.'" style="width: 185px;"'.
 567                  ' onFocus="if(this.value==\''.$blur.'\') this.value=\'\';"'.
 568                  ' onBlur="if(this.value==\'\') this.value=\''.$blur.'\';" title="'.lang('Search').'">',
 569                  '','/index.php',array('menuaction'=>'calendar.uilist.listview')),
 570              'no_lang' => True,
 571              'link' => False,
 572          );
 573          // Minicalendar
 574          $link = array();
 575          foreach(array(
 576              'day'   => 'calendar.uiviews.day',
 577              'week'  => 'calendar.uiviews.week',
 578              'month' => 'calendar.uiviews.month') as $view => $menuaction)
 579          {
 580              if ($this->view == 'planner')    
 581              {
 582                  switch($view)
 583                  {
 584                      case 'day':   $link_vars['planner_days'] = 1; break;
 585                      case 'week':  $link_vars['planner_days'] = $this->cal_prefs['days_in_weekview'] == 5 ? 5 : 7; break;
 586                      case 'month': $link_vars['planner_days'] = 0; break;
 587                  }
 588                  $link_vars['menuaction'] = $this->view_menuaction;    // stay in the planner
 589              }
 590              elseif ($this->view == 'listview' || $view == 'day' && $this->view == 'day4')
 591              {
 592                  $link_vars['menuaction'] = $this->view_menuaction;    // stay in the listview
 593              }
 594              else
 595              {
 596                  $link_vars['menuaction'] = $menuaction;
 597              }
 598              unset($link_vars['date']);    // gets set in jscal
 599              $link[$view] = $l = $GLOBALS['egw']->link('/index.php',$link_vars);
 600          }
 601          $jscalendar = $GLOBALS['egw']->jscalendar->flat($link['day'],$this->date,
 602              $link['week'],lang('show this week'),$link['month'],lang('show this month'));
 603          $file[++$n] = array('text' => $jscalendar,'no_lang' => True,'link' => False,'icon' => False);
 604  
 605          // Category Selection
 606          $file[++$n] = $this->_select_box('Category','cat_id',
 607              '<option value="0">'.lang('All categories').'</option>'.
 608          $this->cats->formatted_list('select','all',$this->cat_id,'True'));
 609  
 610          // we need a form for the select-boxes => insert it in the first selectbox
 611          $file[$n]['text'] = $this->html->form(False,$base_hidden_vars,'/index.php',array('menuaction' => $_GET['menuaction'])) .
 612              $file[$n]['text'];
 613  
 614          // Filter all or private
 615  /*         NOT used at the moment
 616          if(is_numeric($this->owner) && $this->bo->check_perms(EGW_ACL_PRIVATE,0,$this->owner))
 617          {
 618              $file[] = $this->_select_box('Filter','filter',
 619                  '<option value=" all "'.($this->filter==' all '?' selected="1"':'').'>'.lang('No filter').'</option>'."\n".
 620                  '<option value=" private "'.($this->filter==' private '?' selected="1"':'').'>'.lang('Private Only').'</option>'."\n");
 621          }
 622  */
 623          // Calendarselection: User or Group
 624          if(count($this->bo->grants) > 0 && (!isset($GLOBALS['egw_info']['server']['deny_user_grants_access']) ||
 625              !$GLOBALS['egw_info']['server']['deny_user_grants_access']))
 626          {
 627              $grants = array();
 628              foreach($this->bo->list_cals() as $grant)
 629              {
 630                  $grants[] = $grant['grantor'];
 631              }
 632              // exclude non-accounts from the account-selection
 633              $accounts = array();
 634              foreach(explode(',',$this->owner) as $owner)
 635              {
 636                  if (is_numeric($owner)) $accounts[] = $owner;
 637              }
 638              $file[] = array(
 639                  'text' => "
 640  <script type=\"text/javascript\">
 641  function load_cal(url,id) {
 642      var owner='';
 643      selectBox = document.getElementById(id);
 644      for(i=0; i < selectBox.length; ++i) {
 645          if (selectBox.options[i].selected) {
 646              owner += (owner ? ',' : '') + selectBox.options[i].value;
 647          }
 648      }
 649      if (owner) {
 650          location=url+'&owner='+owner;
 651      }
 652  }
 653  </script>
 654  ".
 655                  $this->accountsel->selection('owner','uical_select_owner',$accounts,'calendar+',count($accounts) > 1 ? 4 : 1,False,
 656                      ' style="width: '.(count($accounts) > 1 && $this->common_prefs['account_selection']=='selectbox' ? 185 : 165).'px;"'.
 657                      ' title="'.lang('select a %1',lang('user')).'" onchange="load_cal(\''.
 658                      $GLOBALS['egw']->link('/index.php',array(
 659                          'menuaction' => $this->view_menuaction,
 660                          'date' => $this->date,
 661                      )).'\',\'uical_select_owner\');"','',$grants),
 662                  'no_lang' => True,
 663                  'link' => False
 664              );
 665          }
 666          // Import & Export
 667          $file[] = array(
 668              'text' => lang('Export').': '.$this->html->a_href(lang('iCal'),'calendar.uiforms.export',$this->first ? array(
 669                  'start' => $this->bo->date2string($this->first),
 670                  'end'   => $this->bo->date2string($this->last),
 671              ) : false),
 672              'no_lang' => True,
 673              'link' => False,
 674          );
 675          $file[] = array(
 676              'text' => lang('Import').': '.$this->html->a_href(lang('iCal'),'calendar.uiforms.import').
 677                  ' &amp; '.$this->html->a_href(lang('CSV'),'/calendar/csv_import.php'),
 678              'no_lang' => True,
 679              'link' => False,
 680          );
 681  /*
 682          $print_functions = array(
 683              'calendar.uiviews.day'    => 'calendar.pdfcal.day',
 684              'calendar.uiviews.week'    => 'calendar.pdfcal.week',
 685          );
 686          if (isset($print_functions[$_GET['menuaction']]))
 687          {
 688              $file[] = array(
 689                  'text'    => 'pdf-export / print',
 690                  'link'    => $GLOBALS['egw']->link('/index.php',array(
 691                      'menuaction' => $print_functions[$_GET['menuaction']],
 692                      'date' => $this->date,
 693                  )),
 694                  'target' => '_blank',
 695              );
 696          }                
 697  */
 698          // we need to set the sidebox-width a bit wider, as idots.css sets it to 147, to small for the jscal
 699          // setting it to auto, uses the smallest possible size, but IE kills the jscal if the width is set to auto !!!
 700          $width = 203;
 701          echo '<style>
 702  .divSidebox
 703  {
 704      width: '.($this->html->user_agent == 'msie' ? $width.'px' : 'auto; max-width: '.$width.'px;').';
 705  }
 706  </style>'."\n";
 707          $appname = 'calendar';
 708          $menu_title = lang('Calendar Menu');
 709          display_sidebox($appname,$menu_title,$file);
 710          echo "</form>\n";
 711          
 712          // resources menu hooks
 713           foreach ($this->bo->resources as $resource)
 714          {
 715              if(!is_array($resource['cal_sidebox'])) continue;
 716              $menu_title = $resource['cal_sidebox']['menu_title'] ? $resource['cal_sidebox']['menu_title'] : lang($resource['app']);
 717              $file = ExecMethod($resource['cal_sidebox']['file'],array(
 718                  'menuaction' => $this->view_menuaction,
 719                  'owner' => $this->owner,
 720              ));
 721              display_sidebox($appname,$menu_title,$file);
 722          }
 723  
 724  
 725          if ($GLOBALS['egw_info']['user']['apps']['preferences'])
 726          {
 727              $menu_title = lang('Preferences');
 728              $file = Array(
 729                  'Calendar preferences'=>$GLOBALS['egw']->link('/index.php','menuaction=preferences.uisettings.index&appname=calendar'),
 730                  'Grant Access'=>$GLOBALS['egw']->link('/index.php','menuaction=preferences.uiaclprefs.index&acl_app=calendar'),
 731                  'Edit Categories' =>$GLOBALS['egw']->link('/index.php','menuaction=preferences.uicategories.index&cats_app=calendar&cats_level=True&global_cats=True'),
 732              );
 733              display_sidebox($appname,$menu_title,$file);
 734          }
 735  
 736          if ($GLOBALS['egw_info']['user']['apps']['admin'])
 737          {
 738              $menu_title = lang('Administration');
 739              $file = Array(
 740                  'Configuration'=>$GLOBALS['egw']->link('/index.php','menuaction=admin.uiconfig.index&appname=calendar'),
 741                  'Custom Fields'=>$GLOBALS['egw']->link('/index.php','menuaction=admin.customfields.edit&appname=calendar'),
 742                  'Holiday Management'=>$GLOBALS['egw']->link('/index.php','menuaction=calendar.uiholiday.admin'),
 743                  'Global Categories' =>$GLOBALS['egw']->link('/index.php','menuaction=admin.uicategories.index&appname=calendar'),
 744              );
 745              display_sidebox($appname,$menu_title,$file);
 746          }
 747      }
 748  }


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