diff --git a/calendar/inc/class.calendar_bo.inc.php b/calendar/inc/class.calendar_bo.inc.php index b9edff81bb..eeaffa2029 100644 --- a/calendar/inc/class.calendar_bo.inc.php +++ b/calendar/inc/class.calendar_bo.inc.php @@ -264,7 +264,7 @@ class calendar_bo * users mixed integer user-id or array of user-id's to use, defaults to the current user * cat_id mixed category-id or array of cat-id's, defaults to all if unset, 0 or False * Please note: only a single cat-id, will include all sub-cats (if the common-pref 'cats_no_subs' is False) - * filter string filter-name, atm. 'all' or 'hideprivate' + * filter string all (not rejected), accepted, unknown, tentative, rejected or hideprivate * query string pattern so search for, if unset or empty all matching entries are returned (no search) * Please Note: a search never returns repeating events more then once AND does not honor start+end date !!! * dayswise boolean on True it returns an array with YYYYMMDD strings as keys and an array with events @@ -276,7 +276,6 @@ class calendar_bo * otherwise the original recuring event (with the first start- + enddate) is returned * num_rows int number of entries to return, default or if 0, max_entries from the prefs * order column-names plus optional DESC|ASC separted by comma - * show_rejected if set rejected invitation are shown only when true, otherwise it depends on the cal-pref or a running query * ignore_acl if set and true no check_perms for a general EGW_ACL_READ grants is performed * enum_groups boolean if set and true, group-members will be added as participants with status 'G' * cols string|array columns to select, if set the recordset/iterator will be returned @@ -288,6 +287,17 @@ class calendar_bo { $params_in = $params; + unset($params['sql_filter']); // dont allow to set it via UI or xmlrpc + + // check if any resource wants to hook into + foreach($this->resources as $app => $data) + { + if (isset($data['search_filter'])) + { + $params = ExecMethod($data['search_filter'],$params); + } + } + if (!isset($params['users']) || !$params['users'] || count($params['users']) == 1 && isset($params['users'][0]) && !$params['users'][0]) // null or '' casted to an array { @@ -366,15 +376,14 @@ class calendar_bo $cat_id = isset($params['cat_id']) ? $params['cat_id'] : 0; $filter = isset($params['filter']) ? $params['filter'] : 'all'; $offset = isset($params['offset']) && $params['offset'] !== false ? (int) $params['offset'] : false; - $show_rejected = isset($params['show_rejected']) ? $params['show_rejected'] : $this->cal_prefs['show_rejected'] || $params['query']; if ($this->debug && ($this->debug > 1 || $this->debug == 'search')) { - $this->debug_message('bocal::search(%1) start=%2, end=%3, daywise=%4, cat_id=%5, filter=%6, query=%7, offset=%8, num_rows=%9, order=%10, show_rejected=%11)', - True,$params,$start,$end,$daywise,$cat_id,$filter,$params['query'],$offset,(int)$params['num_rows'],$params['order'],$show_rejected); + $this->debug_message('bocal::search(%1) start=%2, end=%3, daywise=%4, cat_id=%5, filter=%6, query=%7, offset=%8, num_rows=%9, order=%10, sql_filter=%11)', + True,$params,$start,$end,$daywise,$cat_id,$filter,$params['query'],$offset,(int)$params['num_rows'],$params['order'],$params['sql_filter']); } // date2ts(,true) converts to server time, db2data converts again to user-time $events =& $this->so->search(isset($start) ? $this->date2ts($start,true) : null,isset($end) ? $this->date2ts($end,true) : null, - $users,$cat_id,$filter,$params['query'],$offset,(int)$params['num_rows'],$params['order'],$show_rejected,$params['cols'],$params['append']); + $users,$cat_id,$filter,$params['query'],$offset,(int)$params['num_rows'],$params['order'],$params['sql_filter'],$params['cols'],$params['append']); if (isset($params['cols'])) { @@ -385,8 +394,8 @@ class calendar_bo // socal::search() returns rejected group-invitations, as only the user not also the group is rejected // as we cant remove them efficiantly in SQL, we kick them out here, but only if just one user is displayed - $remove_rejected_by_user = !$show_rejected && count($params['users']) == 1 ? $params['users'][0] : false; - //echo "

remove_rejected_by_user=$remove_rejected_by_user, show_rejected=$show_rejected, params[users]=".print_r($param['users'])."

\n"; + $remove_rejected_by_user = !in_array($filter,array('all','rejected')) && count($params['users']) == 1 ? $params['users'][0] : false; + //echo "

remove_rejected_by_user=$remove_rejected_by_user, filter=$filter, params[users]=".print_r($param['users'])."

\n"; foreach($events as $id => $event) { if ($remove_rejected_by_user && $event['participants'][$remove_rejected_by_user] == 'R') diff --git a/calendar/inc/class.calendar_hooks.inc.php b/calendar/inc/class.calendar_hooks.inc.php index eda65f0629..8cf4165d83 100644 --- a/calendar/inc/class.calendar_hooks.inc.php +++ b/calendar/inc/class.calendar_hooks.inc.php @@ -247,15 +247,6 @@ class calendar_hooks $options[$group['account_id']] = $GLOBALS['egw']->common->grab_owner_name($group['account_id']); } } - $defaultfilter = array( - 'all' => lang('all'), - 'private' => lang('private only'), - // 'public' => lang('global public only'), - // 'group' => lang('group public only'), - // 'private+public' => lang('private and global public'), - // 'private+group' => lang('private and group public'), - // 'public+group' => lang('global public and group public') - ); $freebusy_url = calendar_bo::freebusy_url($GLOBALS['egw_info']['user']['account_lid'],$GLOBALS['egw_info']['user']['preferences']['calendar']['freebusy_pw']); $freebusy_help = lang('Should not loged in persons be able to see your freebusy information? You can set an extra password, different from your normal password, to protect this informations. The freebusy information is in iCal format and only include the times when you are busy. It does not include the event-name, description or locations. The URL to your freebusy information is %1.',''.$freebusy_url.''); @@ -296,12 +287,6 @@ class calendar_hooks 'xmlrpc' => True, 'admin' => False ), - 'show_rejected' => array( - 'type' => 'check', - 'label' => 'Show invitations you rejected', - 'name' => 'show_rejected', - 'help' => 'Should invitations you rejected still be shown in your calendar ?
You can only accept them later (eg. when your scheduling conflict is removed), if they are still shown in your calendar!' - ), 'weekdaystarts' => array( 'type' => 'select', 'label' => 'weekday starts on', diff --git a/calendar/inc/class.calendar_so.inc.php b/calendar/inc/class.calendar_so.inc.php index f05bf04e8f..6ef7141770 100644 --- a/calendar/inc/class.calendar_so.inc.php +++ b/calendar/inc/class.calendar_so.inc.php @@ -269,13 +269,13 @@ class calendar_so * @param int|array $users user-id or array of user-id's, !$users means all entries regardless of users * @param int $cat_id=0 mixed category-id or array of cat-id's, default 0 = all * Please note: only a single cat-id, will include all sub-cats (if the common-pref 'cats_no_subs' is False) - * @param string $filter='' string filter-name, atm. all or hideprivate + * @param string $filter='all' string filter-name: all (not rejected), accepted, unknown, tentative, rejected or hideprivate (handled elsewhere!) * @param string $query='' pattern so search for, if unset or empty all matching entries are returned (no search) * Please Note: a search never returns repeating events more then once AND does not honor start+end date !!! * @param int|boolean $offset=False offset for a limited query or False (default) * @param int $num_rows=0 number of rows to return if offset set, default 0 = use default in user prefs * @param string $order='cal_start' column-names plus optional DESC|ASC separted by comma - * @param boolean $show_rejected=true should the search return rejected invitations + * @param string $sql_filter='' sql to be and'ed into query (fully quoted) * @param string|array $_cols=null what to select, default "$this->repeats_table.*,$this->cal_table.*,cal_start,cal_end,cal_recur_date" * if specified an iterator for the rows is returned * @param string $append='' SQL to append to the query before $order, eg. for a GROUP BY clause @@ -283,13 +283,17 @@ class calendar_so * * ToDo: search custom-fields too */ - function &search($start,$end,$users,$cat_id=0,$filter='',$query='',$offset=False,$num_rows=0,$order='cal_start',$show_rejected=true,$_cols=null,$append='') + function &search($start,$end,$users,$cat_id=0,$filter='all',$query='',$offset=False,$num_rows=0,$order='cal_start',$sql_filter='',$_cols=null,$append='') { //echo '

'.__METHOD__.'('.($start ? date('Y-m-d H:i',$start) : '').','.($end ? date('Y-m-d H:i',$end) : '').','.array2string($users).','.array2string($cat_id).",'$filter',".array2string($query).",$offset,$num_rows,$order,$show_rejected,".array2string($_cols).",$append)

\n"; $cols = !is_null($_cols) ? $_cols : "$this->repeats_table.*,$this->cal_table.*,cal_start,cal_end,cal_recur_date"; $where = array(); + if (!empty($sql_filter) && is_string($sql_filter)) + { + $where[] = $sql_filter; + } if (is_array($query)) { $where = $query; @@ -324,10 +328,31 @@ class calendar_so 'cal_user_type' => $type, 'cal_user_id' => $ids, )); + if ($type == 'u' && $filter == 'owner') + { + $cal_table_def = $this->db->get_table_definitions('calendar',$this->cal_table); + $to_or[] = $this->db->expression($cal_table_def,array('cal_owner' => $ids)); + } } $where[] = '('.implode(' OR ',$to_or).')'; - if (!$show_rejected) $where[] = "cal_status != 'R'"; + switch($filter) + { + case 'unknown': + $where[] = "cal_status='U'"; break; + case 'accepted': + $where[] = "cal_status='A'"; break; + case 'tentative': + $where[] = "cal_status='T'"; break; + case 'rejected': + $where[] = "cal_status='R'"; break; + case 'all': + break; + default: + //if (!$show_rejected) // not longer used + $where[] = "cal_status != 'R'"; + break; + } } if ($cat_id) { diff --git a/calendar/inc/class.calendar_ui.inc.php b/calendar/inc/class.calendar_ui.inc.php index 5c5759b106..1b8d4b151c 100644 --- a/calendar/inc/class.calendar_ui.inc.php +++ b/calendar/inc/class.calendar_ui.inc.php @@ -123,7 +123,7 @@ class calendar_ui /** * @var array $states_to_save all states that will be saved to the user prefs */ - var $states_to_save = array('owner'); + var $states_to_save = array('owner','filter'); /** * Constructor @@ -687,10 +687,21 @@ class calendar_ui $this->cats->formatted_list('select','all',$this->cat_id,'True'),$baseurl ? $baseurl.'&cat_id=' : ''); // Filter all or hideprivate - $file[] = $this->_select_box('Filter','filter', - ''."\n". - ''."\n", - $baseurl ? $baseurl.'&filter=' : ''); + $options = ''; + foreach(array( + 'default' => lang('Not rejected'), + 'accepted' => lang('Accepted'), + 'unknown' => lang('Invitations'), + 'tentative' => lang('Tentative'), + 'rejected' => lang('Rejected'), + 'owner' => lang('Owner too'), + 'all' => lang('All incl. rejected'), + 'hideprivate' => lang('Hide private infos'), + ) as $value => $label) + { + $options .= '