Author: nathangray
New Revision: 55070
URL: http://svn.stylite.de/viewvc/egroupware?rev=55070&view=rev
Log:
Promote calendar-owner to full widget, loadable by etemplate on its own
Added:
trunk/calendar/inc/class.calendar_owner_etemplate_widget.inc.php
Modified:
trunk/calendar/inc/class.calendar_export_csv.inc.php
trunk/calendar/inc/class.calendar_ui.inc.php
trunk/calendar/inc/class.calendar_uiforms.inc.php
trunk/calendar/js/et2_widget_owner.js
trunk/calendar/templates/default/export_csv_select.xet
trunk/calendar/templates/default/sidebox.xet
— trunk/calendar/inc/class.calendar_export_csv.inc.php (original)
+++ trunk/calendar/inc/class.calendar_export_csv.inc.php Thu Feb 18 20:45:37 2016
@@ -237,21 +237,30 @@
*
*/
public function get_selectors_etpl($definition = null) {
-
$states = $GLOBALS['egw']->session->appsession('session_data','calendar');
-
switch($states['view']) {
-
case 'month':
-
$query = $this->get_query_month($states);
-
break;
-
case 'week':
-
case 'weekN':
-
$query = $this->get_query_week($states);
-
break;
-
case 'day':
-
$query = $this->get_query_day($states);
-
break;
-
}
-
$start= new egw_time($query['start']);
-
$end = new egw_time($query['end']);
-
$states = $this->bo->cal_prefs['saved_states'];
-
$list = $GLOBALS['egw']->session->appsession('calendar_list','calendar');
-
if(!$list['startdate'])
-
{
-
switch($states['view']) {
-
case 'month':
-
$query = $this->get_query_month($states);
-
break;
-
case 'week':
-
case 'weekN':
-
$query = $this->get_query_week($states);
-
break;
-
case 'day':
-
$query = $this->get_query_day($states);
-
break;
-
}
-
$start= new egw_time($query['start']);
-
$end = new egw_time($query['end']);
-
}
-
else
-
{
-
$start= new egw_time($list['startdate']);
-
$end = new egw_time($list['enddate']);
-
}
if ($states['view'] == 'listview')
{
$list = $GLOBALS['egw']->session->appsession('calendar_list','calendar');
@@ -375,6 +384,9 @@
‘no-enum-groups’ => lang(‘only group-events’),
‘not-unknown’ => lang(‘No meeting requests’),
);
+
+
— trunk/calendar/inc/class.calendar_owner_etemplate_widget.inc.php (added)
+++ trunk/calendar/inc/class.calendar_owner_etemplate_widget.inc.php Thu Feb 18 20:45:37 2016
@@ -1,0 +1,160 @@
+<?php
+/**
-
- EGroupware - eTemplate serverside of owner list widget
-
-
-
-
-
-
-
-
@copyright 2016 Nathan Gray
-
- */
-
+/**
-
- eTemplate tag list widget
-
-
- The naming convention is __etemplate_widget
- */
+class calendar_owner_etemplate_widget extends etemplate_widget_taglist
+{
-
- /**
-
- Make sure all the needed select options are there
-
-
-
- @param array $expand values for keys ‘c’, ‘row’, ‘c_’, ‘row_’, ‘cont’
- */
- public function beforeSendToClient($cname, array $expand=null)
- {
-
-
egw_framework::validate_file('.','et2_widget_owner','calendar');
-
egw_framework::includeCSS('calendar');
-
-
$bo = new calendar_bo();
-
-
$form_name = self::form_name($cname, $this->id, $expand);
-
-
$value =& self::get_array(self::$request->content, $form_name);
-
if (!is_array(self::$request->sel_options[$form_name]))
-
{
-
self::$request->sel_options[$form_name] = array();
-
}
-
$sel_options =& self::$request->sel_options[$form_name];
-
-
// Get user accounts, formatted nicely for grouping and matching
-
// the ajax call calendar_uiforms->ajax_owner() - users first
-
$accounts = array();
-
$list = array('accounts', 'owngroups');
-
foreach($list as $type)
-
{
-
$account_options = array('account_type' => $type);
-
$accounts += accounts::link_query('',$account_options);
-
}
-
$accounts = array_intersect_key($accounts, $GLOBALS['egw']->acl->get_grants('calendar'));
-
$sel_options += array_map(
-
function($account_id, $account_name) {
-
return array(
-
'value' => ''.$account_id,
-
'label' => $account_name,
-
'app' => lang('home-accounts')
-
);
-
},
-
array_keys($accounts), $accounts
-
);
-
-
-
// Add external owners that a select account widget will not find
-
foreach($value as &$owner)
-
{
-
// Make sure it's a string for comparison
-
$owner = ''.$owner;
-
if(!is_numeric($owner))
-
{
-
$resource = $bo->resources[substr($owner, 0,1)];
-
$label = egw_link::title($resource['app'], substr($owner,1));
-
$linked_owners[$resource['app']][substr($owner,1)] = $label;
-
}
-
else if (!in_array($owner, array_keys($accounts)))
-
{
-
$label = egw_link::title('home-accounts',$owner);
-
$resource = array('app'=> 'home-accounts');
-
}
-
else
-
{
-
continue;
-
}
-
$sel_options[] = array('value' => $owner, 'label' => $label, 'app' => lang($resource['app']));
-
}
- }
-
- /**
-
- Handle ajax searches for owner across all supported resources
-
-
- @return Array List of matching results
- */
- public static function ajax_owner()
- {
-
$bo = new calendar_bo();
-
-
$query = $_REQUEST['query'];
-
// Arbitrarily limited to 50 / resource
-
$options = ['start' => 0, 'num_rows' => 50];
-
$results = [];
-
-
$resources = array_merge(array('' => $bo->resources['']),$bo->resources);
-
foreach($resources as $type => $data)
-
{
-
$mapped = array();
-
$_results = array();
-
-
// Handle accounts seperately
-
if($type == '')
-
{
-
$list = array('accounts', 'owngroups');
-
foreach($list as $a_type)
-
{
-
$account_options = $options + array('account_type' => $a_type);
-
$_results += accounts::link_query('',$account_options);
-
}
-
$_results = array_intersect_key($_results, $GLOBALS['egw']->acl->get_grants('calendar'));
-
}
-
else if ($data['app'] && egw_link::get_registry($data['app'], 'query'))
-
{
-
$_results = egw_link::query($data['app'], $query,$options);
-
}
-
if(!$_results) continue;
-
$_results = array_unique($_results);
-
-
foreach($_results as $id => $title)
-
{
-
if($id && $title)
-
{
-
// Magicsuggest uses id, not value.
-
$value = [
-
'id' => $type.$id,
-
'value'=> $type.$id,
-
'label' => $title,
-
'app' => lang($data['app'])
-
];
-
if(is_array($value['label']))
-
{
-
$value = array_merge($value, $value['label']);
-
}
-
$mapped[] = $value;
-
}
-
}
-
if(count($mapped))
-
{
-
$results = array_merge($results, $mapped);
-
}
-
}
-
-
// switch regular JSON response handling off
-
egw_json_request::isJSONRequest(false);
-
-
header('Content-Type: application/json; charset=utf-8');
-
echo json_encode($results);
-
common::egw_exit();
- }
+}
— trunk/calendar/inc/class.calendar_ui.inc.php (original)
+++ trunk/calendar/inc/class.calendar_ui.inc.php Thu Feb 18 20:45:37 2016
@@ -616,61 +616,7 @@
$content = $this->cal_prefs[‘saved_states’];
$content[‘view’] = $this->view ? $this->view : ‘week’;
$content[‘date’] = $this->date ? $this->date : egw_time();
-
$owners = $this->owner ? is_array($this->owner) ? array($this->owner) : explode(',',$this->owner) : array($GLOBALS['egw_info']['user']['account_id']);
-
-
-
$sel_options = array('owner' => array());
-
-
// Get user accounts, formatted nicely for grouping and matching
-
// the ajax call calendar_uiforms->ajax_owner() - users first
-
$accounts = array();
-
$list = array('accounts', 'owngroups');
-
foreach($list as $type)
-
{
-
$account_options = array('account_type' => $type);
-
$accounts += accounts::link_query('',$account_options);
-
}
-
$accounts = array_intersect_key($accounts, $GLOBALS['egw']->acl->get_grants('calendar'));
-
$sel_options['owner'] = array_map(
-
function($account_id, $account_name) {
-
return array(
-
'value' => ''.$account_id,
-
'label' => $account_name,
-
'app' => lang('home-accounts')
-
);
-
},
-
array_keys($accounts), $accounts
-
);
-
-
// Add external owners that a select account widget will not find
-
$linked_owners = array();
-
foreach($owners as &$owner)
-
{
-
$owner = ''.$owner;
-
if(!is_numeric($owner))
-
{
-
$resource = $this->bo->resources[substr($owner, 0,1)];
-
$label = egw_link::title($resource['app'], substr($owner,1));
-
$linked_owners[$resource['app']][substr($owner,1)] = $label;
-
}
-
else if (!in_array($owner, array_keys($accounts)))
-
{
-
$label = egw_link::title('home-accounts',$owner);
-
$resource = array('app'=> 'home-accounts');
-
}
-
else
-
{
-
continue;
-
}
-
$sel_options['owner'][] = array('value' => $owner, 'label' => $label, 'app' => lang($resource['app']));
-
}
-
if($linked_owners)
-
{
-
// Send them to link registry too
-
egw_json_response::get()->call('egw.link_title_callback',$linked_owners);
-
}
-
$readonlys = array();
$sel_options['status_filter'] = array(
array('value' => 'default', 'label' => lang('Not rejected'), 'title' => lang('Show all status, but rejected')),
— trunk/calendar/inc/class.calendar_uiforms.inc.php (original)
+++ trunk/calendar/inc/class.calendar_uiforms.inc.php Thu Feb 18 20:45:37 2016
@@ -2942,75 +2942,6 @@
}
/**
-
- Handle ajax searches for owner across all supported resources
-
-
- @return Array List of matching results
- */
- public function ajax_owner()
- {
-
$query = $_REQUEST['query'];
-
// Arbitrarily limited to 50 / resource
-
$options = ['start' => 0, 'num_rows' => 50];
-
$results = [];
-
if($query)
-
{
-
$resources = array_merge(array('' => $this->bo->resources['']),$this->bo->resources);
-
foreach($resources as $type => $data)
-
{
-
$mapped = array();
-
$_results = array();
-
-
// Handle accounts seperately
-
if($type == '')
-
{
-
$list = array('accounts', 'owngroups');
-
foreach($list as $a_type)
-
{
-
$account_options = $options + array('account_type' => $a_type);
-
$_results += accounts::link_query('',$account_options);
-
}
-
$_results = array_intersect_key($_results, $GLOBALS['egw']->acl->get_grants('calendar'));
-
}
-
else if ($data['app'] && egw_link::get_registry($data['app'], 'query'))
-
{
-
$_results = egw_link::query($data['app'], $query,$options);
-
}
-
if(!$_results) continue;
-
$_results = array_unique($_results);
-
-
foreach($_results as $id => $title)
-
{
-
if($id && $title)
-
{
-
// Magicsuggest uses id, not value.
-
$value = [
-
'id' => $type.$id,
-
'value'=> $type.$id,
-
'label' => $title,
-
'app' => lang($data['app'])
-
];
-
if(is_array($value['label']))
-
{
-
$value = array_merge($value, $value['label']);
-
}
-
$mapped[] = $value;
-
}
-
}
-
if(count($mapped))
-
{
-
$results = array_merge($results, $mapped);
-
}
-
}
-
}
-
// switch regular JSON response handling off
-
egw_json_request::isJSONRequest(false);
-
-
header('Content-Type: application/json; charset=utf-8');
-
echo json_encode($results);
-
common::egw_exit();
- }
-
- /**
- imports a mail as Calendar
-
- @param array $mailContent = null mail content
— trunk/calendar/js/et2_widget_owner.js (original)
+++ trunk/calendar/js/et2_widget_owner.js Thu Feb 18 20:45:37 2016
@@ -29,7 +29,7 @@
{
attributes: {
“autocomplete_url”: {
@@ -90,4 +90,4 @@
return this.taglist.getValue();
}
});
-et2_register_widget(et2_calendar_owner, [“calendar_owner”]);
+et2_register_widget(et2_calendar_owner, [“calendar-owner”]);
— trunk/calendar/templates/default/export_csv_select.xet (original)
+++ trunk/calendar/templates/default/export_csv_select.xet Thu Feb 18 20:45:37 2016
@@ -38,7 +38,7 @@
— trunk/calendar/templates/default/sidebox.xet (original)
+++ trunk/calendar/templates/default/sidebox.xet Thu Feb 18 20:45:37 2016
@@ -27,7 +27,7 @@
Site24x7 APM Insight: Get Deep Visibility into Application Performance
APM + Mobile APM + RUM: Monitor 3 App instances at just $35/Month
Monitor end-to-end web transactions and take corrective actions now
Troubleshoot faster and improve end-user experience. Signup Now!
http://pubads.g.doubleclick.net/gampad/clk?id=272487151&iu=/4140
eGroupWare-cvs mailing list
eGroupWare-cvs@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/egroupware-cvs