[ Index ] |
|
Code source de eGroupWare 1.2.106-2 |
1 <?php 2 /**************************************************************************\ 3 * eGroupWare - Calendar - Listview and Search * 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.uilist.inc.php 20394 2006-03-04 09:59:18Z ralfbecker $ */ 14 15 include_once (EGW_INCLUDE_ROOT . '/calendar/inc/class.uical.inc.php'); 16 17 /** 18 * Class to generate the calendar listview and the search 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 * The state of the UI elements is managed in the uical class, which all UI classes extend. 26 * 27 * All permanent debug messages of the calendar-code should done via the debug-message method of the bocal class !!! 28 * 29 * @package calendar 30 * @author Ralf Becker <RalfBecker-AT-outdoor-training.de> 31 * @copyright (c) 2004/5 by RalfBecker-At-outdoor-training.de 32 * @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License 33 */ 34 class uilist extends uical 35 { 36 var $public_functions = array( 37 'listview' => True, 38 ); 39 /** 40 * @var $debug mixed integer level or string function- or widget-name 41 */ 42 var $debug=false; 43 44 /** 45 * Constructor 46 * 47 * @param array $set_states=null to manualy set / change one of the states, default NULL = use $_REQUEST 48 */ 49 function uilist($set_states=null) 50 { 51 $this->uical(true,$set_states); // call the parent's constructor 52 53 $GLOBALS['egw_info']['flags']['app_header'] = $GLOBALS['egw_info']['apps']['calendar']['title'].' - '.lang('Listview'). 54 // for a single owner we add it's name to the app-header 55 (count(explode(',',$this->owner)) == 1 ? ': '.$this->bo->participant_name($this->owner) : ''); 56 57 $this->date_filters = array( 58 'after' => lang('After current date'), 59 'before' => lang('Before current date'), 60 'all' => lang('All events'), 61 ); 62 63 $this->check_owners_access(); 64 } 65 66 /** 67 * Show the calendar on the home page 68 * 69 * @return string with content 70 */ 71 function &home() 72 { 73 // set the defaults for the home-page 74 $this->uilist(array( 75 'date' => $this->bo->date2string($this->bo->now_su), 76 'cat_id' => 0, 77 'filter' => 'all', 78 'owner' => $this->user, 79 'multiple' => 0, 80 'view' => $this->bo->cal_prefs['defaultcalendar'], 81 )); 82 $GLOBALS['egw']->session->appsession('calendar_list','calendar',''); // in case there's already something set 83 84 return $this->listview(null,'',true); 85 } 86 87 /** 88 * Show the listview 89 */ 90 function listview($content=null,$msg='',$home=false) 91 { 92 if ($_GET['msg']) $msg .= $_GET['msg']; 93 if ($this->group_warning) $msg .= $this->group_warning; 94 95 $etpl =& CreateObject('etemplate.etemplate','calendar.list'); 96 97 if (is_array($content) && $content['nm']['rows']['delete']) 98 { 99 list($id) = each($content['nm']['rows']['delete']); 100 101 if ($this->bo->delete($id)) 102 { 103 $msg = lang('Event deleted'); 104 } 105 } 106 $content = array( 107 'nm' => $GLOBALS['egw']->session->appsession('calendar_list','calendar'), 108 'msg' => $msg, 109 ); 110 if (!is_array($content['nm'])) 111 { 112 $content['nm'] = array( 113 'get_rows' => 'calendar.uilist.get_rows', 114 'filter_no_lang' => True, // I set no_lang for filter (=dont translate the options) 115 'no_filter2' => True, // I disable the 2. filter (params are the same as for filter) 116 'no_cat' => True, // I disable the cat-selectbox 117 // 'bottom_too' => True,// I show the nextmatch-line (arrows, filters, search, ...) again after the rows 118 'filter' => 'after', 119 'order' => 'cal_start',// IO name of the column to sort after (optional for the sortheaders) 120 'sort' => 'ASC',// IO direction of the sort: 'ASC' or 'DESC' 121 ); 122 } 123 if (isset($_REQUEST['keywords'])) // new search => set filters so every match is shown 124 { 125 $this->adjust_for_search($_REQUEST['keywords'],$content['nm']); 126 } 127 return $etpl->exec('calendar.uilist.listview',$content,array( 128 'filter' => &$this->date_filters, 129 ),$readonlys,'',$home ? -1 : 0); 130 } 131 132 /** 133 * set filter for search, so that everything is shown 134 */ 135 function adjust_for_search($keywords,&$params) 136 { 137 $params['search'] = $keywords; 138 $params['start'] = 0; 139 $params['order'] = 'cal_start'; 140 if ($keywords) 141 { 142 $params['filter'] = 'all'; 143 $params['sort'] = 'DESC'; 144 unset($params['col_filter']['participant']); 145 } 146 else 147 { 148 $params['filter'] = 'after'; 149 $params['sort'] = 'ASC'; 150 } 151 } 152 153 /** 154 * query calendar for nextmatch in the listview 155 * 156 * @internal 157 * @param array &$params parameters 158 * @param array &$rows returned rows/events 159 * @param array &$readonlys eg. to disable buttons based on acl 160 */ 161 function get_rows(&$params,&$rows,&$readonlys) 162 { 163 //echo "uilist::get_rows() params="; _debug_array($params); 164 $old_params = $GLOBALS['egw']->session->appsession('calendar_list','calendar'); 165 if ($old_params['filter'] && $old_params['filter'] != $params['filter']) // filter changed => order accordingly 166 { 167 $params['order'] = 'cal_start'; 168 $params['sort'] = $params['filter'] == 'after' ? 'ASC' : 'DESC'; 169 } 170 if ($old_params['search'] != $params['search']) 171 { 172 $this->adjust_for_search($params['search'],$params); 173 } 174 $GLOBALS['egw']->session->appsession('calendar_list','calendar',$params); 175 176 $search_params = array( 177 'cat_id' => $this->cat_id, 178 'filter' => $this->filter, 179 'query' => $params['search'], 180 'offset' => (int) $params['start'], 181 'order' => $params['order'] ? $params['order'].' '.$params['sort'] : 'cal_start', 182 ); 183 switch($params['filter']) 184 { 185 case 'all': 186 break; 187 case 'before': 188 $search_params['end'] = $this->date; 189 break; 190 case 'after': 191 default: 192 $search_params['start'] = $this->date; 193 break; 194 } 195 if ((int) $params['col_filter']['participant']) 196 { 197 $search_params['users'] = (int) $params['col_filter']['participant']; 198 } 199 elseif(empty($params['search'])) // active search displays entries from all users 200 { 201 $search_params['users'] = explode(',',$this->owner); 202 } 203 $rows = array(); 204 foreach((array) $this->bo->search($search_params) as $event) 205 { 206 $readonlys['edit['.$event['id'].']'] = !$this->bo->check_perms(EGW_ACL_EDIT,$event); 207 $readonlys['delete['.$event['id'].']'] = !$this->bo->check_perms(EGW_ACL_DELETE,$event); 208 $readonlys['view['.$event['id'].']'] = !$this->bo->check_perms(EGW_ACL_READ,$event); 209 210 $event['parts'] = implode(",\n",$this->bo->participants($event)); 211 $event['recure'] = $this->bo->recure2string($event); 212 $event['date'] = $this->bo->date2string($event['start']); 213 if (empty($event['description'])) $event['description'] = ' '; // no description screws the titles horz. alignment 214 if (empty($event['location'])) $event['location'] = ' '; // no location screws the owner horz. alignment 215 $rows[] = $event; 216 } 217 //_debug_array($rows); 218 return $this->bo->total; 219 } 220 }
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Sun Feb 25 17:20:01 2007 | par Balluche grâce à PHPXref 0.7 |