diff --git a/addressbook/inc/class.addressbook_ui.inc.php b/addressbook/inc/class.addressbook_ui.inc.php index e59742f1f3..3fb4b30d8e 100644 --- a/addressbook/inc/class.addressbook_ui.inc.php +++ b/addressbook/inc/class.addressbook_ui.inc.php @@ -756,8 +756,12 @@ class addressbook_ui extends addressbook_bo 'disableClass' => 'rowNoEdit', ); } - if (isset($actions['export']['children']['csv']) && !importexport_helper_functions::has_definitions('addressbook','export')) unset($actions['export']['children']['csv']); - + if (isset($actions['export']['children']['csv']) && + (!isset($GLOBALS['egw_info']['user']['apps']['importexport']) || + !importexport_helper_functions::has_definitions('addressbook','export'))) + { + unset($actions['export']['children']['csv']); + } // Intercept open action in order to open entry into view mode instead of edit if (Api\Header\UserAgent::mobile()) { diff --git a/api/js/etemplate/etemplate2.js b/api/js/etemplate/etemplate2.js index 64416370ad..1b696aa05f 100644 --- a/api/js/etemplate/etemplate2.js +++ b/api/js/etemplate/etemplate2.js @@ -284,7 +284,7 @@ etemplate2.prototype.bind_unload = function() { this.destroy_session = jQuery.proxy(function(ev) { - var request = egw.json(this.app+".etemplate_new.ajax_destroy_session.etemplate", + var request = egw.json("EGroupware\\Api\\Etemplate::ajax_destroy_session", [this.etemplate_exec_id], null, null, false); request.sendRequest(); }, this); diff --git a/api/js/framework/fw_base.js b/api/js/framework/fw_base.js index 55e916a6d1..a977332c61 100644 --- a/api/js/framework/fw_base.js +++ b/api/js/framework/fw_base.js @@ -415,7 +415,7 @@ var fw_base = (function(){ "use strict"; return Class.extend( { this.serializedTabState = serialized; - egw.jsonq("api.jdots_framework.ajax_tab_changed_state", [data]); + egw.jsonq("api.jdots_framework.ajax_tab_changed_state.template", [data]); } }, @@ -998,7 +998,7 @@ var fw_base = (function(){ "use strict"; return Class.extend( var app = framework.activeApp; framework.activeApp = ''; framework.setActiveApp(app); - + egw.loading_prompt(app.appName,true,egw.lang('please wait...'),app.browser.baseDiv, egwIsMobile()?'horizental':'spinner'); // Give framework a chance to deal, then reset the etemplates diff --git a/api/js/framework/fw_desktop.js b/api/js/framework/fw_desktop.js index d6293472c5..e9aa3e99f2 100644 --- a/api/js/framework/fw_desktop.js +++ b/api/js/framework/fw_desktop.js @@ -302,7 +302,7 @@ } //Send the sort order to the server via ajax - var req = egw.jsonq('api.jdots_framework.ajax_appsort', [name_array]); + var req = egw.jsonq('api.jdots_framework.ajax_appsort.template', [name_array]); }, /** diff --git a/api/js/jsapi/egw.js b/api/js/jsapi/egw.js index 5abe6ea438..90f398c533 100644 --- a/api/js/jsapi/egw.js +++ b/api/js/jsapi/egw.js @@ -289,7 +289,7 @@ window.setTimeout(resize_popup, 50); }); } - var et2 = new etemplate2(node, currentapp+".etemplate_new.ajax_process_content.etemplate"); + var et2 = new etemplate2(node, "EGroupware\\Api\\Etemplate::ajax_process_content"); et2.load(data.name,data.url,data.data); if (typeof data.response != 'undefined') { diff --git a/api/js/jsapi/egw_data.js b/api/js/jsapi/egw_data.js index 969076ec61..62357bfc41 100644 --- a/api/js/jsapi/egw_data.js +++ b/api/js/jsapi/egw_data.js @@ -283,7 +283,7 @@ egw.extend("data", egw.MODULE_APP_LOCAL, function (_app, _wnd) /** * The dataFetch function provides an abstraction layer for the - * corresponding "etemplate_widget_nextmatch::ajax_get_rows" function. + * corresponding "EGroupware\Api\Etemplate\Widget\Nextmatch::ajax_get_rows" function. * The server returns the following structure: * { * order: [uid, ...], @@ -429,7 +429,7 @@ egw.extend("data", egw.MODULE_APP_LOCAL, function (_app, _wnd) // independent of changes happening while waiting for the response _context.filters = jQuery.extend({}, _filters); var request = egw.json( - _app+".etemplate_widget_nextmatch.ajax_get_rows.etemplate", + "EGroupware\\Api\\Etemplate\\Widget\\Nextmatch::ajax_get_rows", [ _execId, _queriedRange, @@ -836,7 +836,7 @@ egw.extend("data_storage", egw.MODULE_GLOBAL, function (_app, _wnd) { if(typeof registeredCallbacks[_uid] !== "undefined" && registeredCallbacks[_uid].length > 0) { var _execId = registeredCallbacks[_uid][0].execId; - // This widget ID MUST be a nextmatch, because the data call is to etemplate_widget_nexmatch + // This widget ID MUST be a nextmatch, because the data call is to Etemplate\Widget\Nexmatch var nextmatchId = registeredCallbacks[_uid][0].widgetId; var uid = _uid.split("::"); var context = { diff --git a/api/js/jsapi/egw_links.js b/api/js/jsapi/egw_links.js index bb080844c5..b4f3743a42 100644 --- a/api/js/jsapi/egw_links.js +++ b/api/js/jsapi/egw_links.js @@ -398,7 +398,7 @@ egw.extend('links', egw.MODULE_GLOBAL, function() // if there's no active jsonq request, start a new one if (title_uid == null) { - title_uid = this.jsonq(_app+'.etemplate_widget_link.ajax_link_titles.etemplate',[{}], this.link_title_callback, this, this.link_title_before_send); + title_uid = this.jsonq('EGroupware\\Api\\Etemplate\\Widget\\Link::ajax_link_titles',[{}], this.link_title_callback, this, this.link_title_before_send); } }, diff --git a/api/src/Header/Referer.php b/api/src/Header/Referer.php new file mode 100644 index 0000000000..9461840692 --- /dev/null +++ b/api/src/Header/Referer.php @@ -0,0 +1,50 @@ + + * @copyright 2001-2016 by RalfBecker@outdoor-training.de + * @package api + * @subpackage header + * @version $Id$ + */ + +namespace EGroupware\Api\Header; + +/** + * Handling of HTTP_REFERER header + */ +class Referer +{ + /** + * gets an eGW conformant referer from $_SERVER['HTTP_REFERER'], suitable for direct use in the link function + * + * @param string $default ='' default to use if referer is not set by webserver or not determinable + * @param string $referer ='' referer string to use, default ('') use $_SERVER['HTTP_REFERER'] + * @return string + * @todo get "real" referer for jDots template + */ + static function get($default='',$referer='') + { + // HTTP_REFERER seems NOT to get urldecoded + if (!$referer) $referer = urldecode($_SERVER['HTTP_REFERER']); + + $webserver_url = $GLOBALS['egw_info']['server']['webserver_url']; + if (empty($webserver_url) || $webserver_url{0} == '/') // url is just a path + { + $referer = preg_replace('/^https?:\/\/[^\/]+/','',$referer); // removing the domain part + } + if (strlen($webserver_url) > 1) + { + list(,$referer) = explode($webserver_url,$referer,2); + } + $ret = str_replace('/etemplate/process_exec.php', '/index.php', $referer); + + if (empty($ret) || strpos($ret, 'cd=yes') !== false) $ret = $default; + + return $ret; + } +} +UserAgent::_init_static(); diff --git a/api/src/Translation.php b/api/src/Translation.php index a624bdd847..4ce8ae6163 100644 --- a/api/src/Translation.php +++ b/api/src/Translation.php @@ -195,7 +195,7 @@ class Translation } $apps = array('common'); // for eTemplate apps, load etemplate before app itself (allowing app to overwrite etemplate translations) - if (class_exists('etemplate_new', false) || class_exists('etemplate', false)) $apps[] = 'etemplate'; + if (class_exists('EGroupware\\Api\\Etemplate', false) || class_exists('etemplate', false)) $apps[] = 'etemplate'; if ($GLOBALS['egw_info']['flags']['currentapp']) $apps[] = $GLOBALS['egw_info']['flags']['currentapp']; // load instance specific translations last, so they can overwrite everything $apps[] = 'custom'; diff --git a/calendar/inc/class.boholiday.inc.php b/calendar/inc/class.boholiday.inc.php index 5c7d4fee0e..ae20b41dae 100755 --- a/calendar/inc/class.boholiday.inc.php +++ b/calendar/inc/class.boholiday.inc.php @@ -56,15 +56,16 @@ class boholiday function boholiday() { - $this->so =& CreateObject('calendar.soholiday'); + require_once(__DIR__.'/class.soholiday.inc.php'); + $this->so = new soholiday(); - $this->start = (int)get_var('start',array('POST','GET')); - $this->query = get_var('query',array('POST','GET')); - $this->sort = get_var('sort',array('POST','GET')); - $this->order = get_var('order',array('POST','GET')); - $this->id = get_var('id',array('POST','GET')); - $this->year = get_var('year',array('POST','GET'),date('Y')); - $this->locale = get_var('locale',array('POST','GET')); + $this->start = (int)$_REQUEST['start']; + $this->query = $_REQUEST['query']; + $this->sort = $_REQUEST['sort']; + $this->order = $_REQUEST['order']; + $this->id = $_REQUEST['id']; + $this->year = (int)(!empty($_REQUEST['year']) ? $_REQUEST['year'] : date('Y')); + $this->locale = $_REQUEST['locale']; if ($this->locale) { $this->locales[] = $this->locale; diff --git a/calendar/inc/class.calendar_bo.inc.php b/calendar/inc/class.calendar_bo.inc.php index 0993985d47..b55e3cb302 100644 --- a/calendar/inc/class.calendar_bo.inc.php +++ b/calendar/inc/class.calendar_bo.inc.php @@ -1474,11 +1474,11 @@ class calendar_bo if ($end_m == 24*60-1) ++$duration; $duration = floor($duration/60).lang('h').($duration%60 ? $duration%60 : ''); - $timespan = $t = common::formattime(sprintf('%02d',$start_m/60),sprintf('%02d',$start_m%60)); + $timespan = $t = Api\DateTime::to('20000101T'.sprintf('%02d',$start_m/60).sprintf('%02d',$start_m%60).'00', false); if ($both) // end-time too { - $timespan .= ' - '.common::formattime(sprintf('%02d',$end_m/60),sprintf('%02d',$end_m%60)); + $timespan .= ' - '.Api\DateTime::to('20000101T'.sprintf('%02d',$end_m/60).sprintf('%02d',$end_m%60).'00', false); // dont double am/pm if they are the same in both times if ($this->common_prefs['timeformat'] == 12 && substr($timespan,-2) == substr($t,-2)) { diff --git a/calendar/inc/class.calendar_uiforms.inc.php b/calendar/inc/class.calendar_uiforms.inc.php index d90590e5d8..60bd4029a3 100644 --- a/calendar/inc/class.calendar_uiforms.inc.php +++ b/calendar/inc/class.calendar_uiforms.inc.php @@ -2031,7 +2031,7 @@ class calendar_uiforms extends calendar_ui */ function conflicts($event,$conflicts,$preserv) { - $etpl = CreateObject('etemplate.etemplate_new','calendar.conflicts'); + $etpl = new Etemplate('calendar.conflicts'); $allConflicts = array(); foreach($conflicts as $k => $conflict) diff --git a/calendar/inc/class.calendar_uiviews.inc.php b/calendar/inc/class.calendar_uiviews.inc.php index 2233a8a6b2..6130f7d697 100644 --- a/calendar/inc/class.calendar_uiviews.inc.php +++ b/calendar/inc/class.calendar_uiviews.inc.php @@ -412,7 +412,7 @@ class calendar_uiviews extends calendar_ui /** * Displays the planner view * - * @param boolean|etemplate_new $home = false if etemplate return content suitable for home-page + * @param boolean|Etemplate $home = false if etemplate return content suitable for home-page */ function &planner($content = array(), $home=false) { diff --git a/doc/fix_api.php b/doc/fix_api.php index 73188d6901..926a785128 100755 --- a/doc/fix_api.php +++ b/doc/fix_api.php @@ -85,6 +85,7 @@ foreach(array( 'common::egw_footer' => "\$GLOBALS['egw']->framework->footer", 'common::show_date' => 'Api\\DateTime::server2user', 'common::get_tpl_dir' => 'Api\\Framework\\Template::get_dir', + 'common::get_referer' => 'Api\\Header\\Referer::get', 'country' => 'Api\\Country', 'egw' => 'Api\\Egw', 'egw_minimal' => 'Api\\Egw\\Base', @@ -158,6 +159,7 @@ foreach(array( 'etemplate_request' => 'Api\\Etemplate\\Request', 'nextmatch_widget::category_action' => 'Api\\Etemplate\\Widget\\Nextmatch::category_action', 'nextmatch_widget::DEFAULT_MAX_MENU_LENGTH' => 'Api\\Etemplate\\Widget\\Nextmatch::DEFAULT_MAX_MENU_LENGTH', + 'customfields_widget::update_customfield_links' => 'Api\Storage\Customfields::update_links', 'egw_keymanager' => 'Api\\Etemplate\\KeyManager', // so_sql and friends 'so_sql' => 'Api\\Storage\\Base', diff --git a/home/inc/class.home_birthday_portlet.inc.php b/home/inc/class.home_birthday_portlet.inc.php index 8359d6c98d..1c52e161cd 100644 --- a/home/inc/class.home_birthday_portlet.inc.php +++ b/home/inc/class.home_birthday_portlet.inc.php @@ -133,10 +133,12 @@ use EGroupware\Api\Etemplate; $text = lang("Tomorrow is %1's birthday.", $contact['n_given'].' '.$contact['n_family']); break; default: - list($y,$m,$d) = explode('-',$contact['bday']); - if ($GLOBALS['egw_info']['server']['hide_birthdays'] == 'dateonly') $y = ''; - $text = lang("In %1 days (%2) is %3's birthday.",$n, - common::dateformatorder($y,$m,$d,true), + $date = Api\DateTime::to($contact['bday'], true); + if ($GLOBALS['egw_info']['server']['hide_birthdays'] == 'dateonly') + { + $date = preg_replace('/\d{4}/', '', $date); + } + $text = lang("In %1 days (%2) is %3's birthday.", $n, $date, $contact['n_given'].' '.$contact['n_family']); break; } diff --git a/index.php b/index.php index f8daf0b4dc..001c9b0d78 100755 --- a/index.php +++ b/index.php @@ -86,7 +86,7 @@ if (isset($_GET['tz'])) $GLOBALS['egw']->preferences->add('common','tz',$_GET['tz']); $GLOBALS['egw']->preferences->save_repository(); - if (($referer = common::get_referer())) + if (($referer = Api\Header\Referer::get())) { Egw::redirect_link($referer); } diff --git a/infolog/inc/class.infolog_bo.inc.php b/infolog/inc/class.infolog_bo.inc.php index 70d12419d0..e0ff184018 100644 --- a/infolog/inc/class.infolog_bo.inc.php +++ b/infolog/inc/class.infolog_bo.inc.php @@ -596,7 +596,7 @@ class infolog_bo } } - if (($data = $this->so->read($info_id)) === False) + if (!$info_id || ($data = $this->so->read($info_id)) === False) { return null; } @@ -948,7 +948,7 @@ class infolog_bo $to_write['info_responsible'] = $values['info_responsible']; } // create (and remove) links in custom fields - customfields_widget::update_customfield_links('infolog',$values,$old,'info_id'); + Api\Storage\Customfields::update_links('infolog',$values,$old,'info_id'); // Check for restore of deleted entry, restore held links if($old['info_status'] == 'deleted' && $values['info_status'] != 'deleted') @@ -1361,7 +1361,7 @@ class infolog_bo foreach ($infos as $info) { $start = new Api\DateTime($info['info_startdate'],Api\DateTime::$user_timezone); - $title = ($do_events?common::formattime($start->format('H'),$start->format('i')).' ':''). + $title = ($do_events ? $start->format(false).' ' : ''). $info['info_subject']; $view = Link::view('infolog',$info['info_id']); $size = null; diff --git a/infolog/inc/class.infolog_ui.inc.php b/infolog/inc/class.infolog_ui.inc.php index 5de088a98a..8ddf9442a9 100644 --- a/infolog/inc/class.infolog_ui.inc.php +++ b/infolog/inc/class.infolog_ui.inc.php @@ -704,7 +704,7 @@ class infolog_ui } elseif ($own_referer === '') { - $own_referer = common::get_referer(); + $own_referer = Api\Header\Referer::get(); if (strpos($own_referer,'menuaction=infolog.infolog_ui.edit') !== false) { $own_referer = Api\Cache::getSession('infolog', 'own_session'); @@ -787,9 +787,9 @@ class infolog_ui } if (!$action) { - $action = is_array($values) && $values['action'] ? $values['action'] : get_var('action',array('POST','GET')); - $action_id = is_array($values) && $values['action_id'] ? $values['action_id'] : get_var('action_id',array('POST','GET')); - $action_title = is_array($values) && $values['action_title'] ? $values['action_title'] : get_var('action_title',array('POST','GET')); + $action = is_array($values) && $values['action'] ? $values['action'] : $_REQUEST['action']; + $action_id = is_array($values) && $values['action_id'] ? $values['action_id'] : $_REQUEST['action_id']; + $action_title = is_array($values) && $values['action_title'] ? $values['action_title'] : $_REQUEST['action_title']; } //echo "

".__METHOD__."(action='$action/$action_id',called_as='$called_as/$values[referer]',own_referer='$own_referer') values=\n"; _debug_array($values); if (!is_array($values)) @@ -1881,12 +1881,12 @@ class infolog_ui else // new call via GET { //echo "

infolog_ui::edit: info_id=$info_id, action='$action', action_id='$action_id', type='$type', referer='$referer'

\n"; - $action = $action ? $action : get_var('action', array('POST','GET')); - $action_id = $action_id ? $action_id : get_var('action_id',array('POST','GET')); - $info_id = $content ? $content : get_var('info_id', array('POST','GET')); - $type = $type ? $type : get_var('type', array('POST','GET')); + $action = $action ? $action : $_REQUEST['action']; + $action_id = $action_id ? $action_id : $_REQUEST['action_id']; + $info_id = $content ? $content : $_REQUEST['info_id']; + $type = $type ? $type : $_REQUEST['type']; $referer = $referer !== '' ? $referer : ($_GET['referer'] ? $_GET['referer'] : - common::get_referer('/index.php?menuaction=infolog.infolog_ui.index')); + Api\Header\Referer::get('/index.php?menuaction=infolog.infolog_ui.index')); if (strpos($referer, 'msg=') !== false) $referer = preg_replace('/([&?]{1})msg=[^&]+&?/','\\1',$referer); // remove previou/old msg from referer $no_popup = $_GET['no_popup']; $print = (int) $_REQUEST['print']; @@ -2360,7 +2360,7 @@ class infolog_ui { $icon = $this->icons[$cat][$id]; } - if ($icon && !is_readable(common::get_image_dir() . '/' . $icon)) + if ($icon && !Api\Image::find('infolog', $icon)) { $icon = False; } diff --git a/json.php b/json.php index 73645a24c3..ec4dfaa349 100644 --- a/json.php +++ b/json.php @@ -101,7 +101,7 @@ if (isset($_GET['menuaction'])) 'no_exception_handler' => true, // we already installed our own // only log ajax requests which represent former GET requests or submits // cuts down updates to egw_access_log table - 'no_dla_update' => !preg_match('/(\.etemplate_new\.ajax_process_content\.etemplate|\.jdots_framework\.ajax_exec\.template)$/', $_GET['menuaction']), + 'no_dla_update' => !preg_match('/(Etemplate::ajax_process_content|\.jdots_framework\.ajax_exec\.template)$/', $_GET['menuaction']), ) ); include_once('./header.inc.php'); diff --git a/phpgwapi/inc/class.common.inc.php b/phpgwapi/inc/class.common.inc.php index dd4a615fc8..44f7fb7255 100644 --- a/phpgwapi/inc/class.common.inc.php +++ b/phpgwapi/inc/class.common.inc.php @@ -1213,32 +1213,16 @@ class common } /** - * gets an eGW conformat referer from $_SERVER['HTTP_REFERER'], suitable for direct use in the link function + * gets an eGW conformant referer from $_SERVER['HTTP_REFERER'], suitable for direct use in the link function * * @param string $default ='' default to use if referer is not set by webserver or not determinable * @param string $referer ='' referer string to use, default ('') use $_SERVER['HTTP_REFERER'] * @return string - * @todo get "real" referer for jDots template + * @deprecated use Api\Header\Referer::get */ static function get_referer($default='',$referer='') { - // HTTP_REFERER seems NOT to get urldecoded - if (!$referer) $referer = urldecode($_SERVER['HTTP_REFERER']); - - $webserver_url = $GLOBALS['egw_info']['server']['webserver_url']; - if (empty($webserver_url) || $webserver_url{0} == '/') // url is just a path - { - $referer = preg_replace('/^https?:\/\/[^\/]+/','',$referer); // removing the domain part - } - if (strlen($webserver_url) > 1) - { - list(,$referer) = explode($webserver_url,$referer,2); - } - $ret = str_replace('/etemplate/process_exec.php', '/index.php', $referer); - - if (empty($ret) || strpos($ret, 'cd=yes') !== false) $ret = $default; - - return $ret; + return Api\Header\Referer::get($default, $referer); } // some depricated functions for the migration