[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Fmsystem-commits] [17029] More on preparing for php 7.2
From: |
sigurdne |
Subject: |
[Fmsystem-commits] [17029] More on preparing for php 7.2 |
Date: |
Sun, 3 Sep 2017 11:16:01 -0400 (EDT) |
Revision: 17029
http://svn.sv.gnu.org/viewvc/?view=rev&root=fmsystem&revision=17029
Author: sigurdne
Date: 2017-09-03 11:16:01 -0400 (Sun, 03 Sep 2017)
Log Message:
-----------
More on preparing for php 7.2
Modified Paths:
--------------
trunk/felamimail/inc/class.ajax_contacts.inc.php
trunk/phpgwapi/inc/class.data_cleaner.inc.php
Modified: trunk/felamimail/inc/class.ajax_contacts.inc.php
===================================================================
--- trunk/felamimail/inc/class.ajax_contacts.inc.php 2017-09-03 11:43:36 UTC
(rev 17028)
+++ trunk/felamimail/inc/class.ajax_contacts.inc.php 2017-09-03 15:16:01 UTC
(rev 17029)
@@ -1,35 +1,48 @@
<?php
-
/***************************************************************************\
- * eGroupWare - FeLaMiMail
*
- * http://www.linux-at-work.de
*
- * http://www.phpgw.de
*
- * http://www.egroupware.org
*
- * Written by : Lars Kneschke address@hidden *
- * -------------------------------------------------
*
- * This program is free software; you can redistribute it and/or modify
it *
- * under the terms of the GNU General Public License as published by the
*
- * Free Software Foundation; either version 2 of the License, or (at
your *
- * option) any later version.
*
-
\***************************************************************************/
+ /* *
*************************************************************************\
+ * eGroupWare - FeLaMiMail
*
+ * http://www.linux-at-work.de
*
+ * http://www.phpgw.de
*
+ * http://www.egroupware.org
*
+ * Written by : Lars Kneschke address@hidden *
+ * -------------------------------------------------
*
+ * This program is free software; you can redistribute it and/or modify
it *
+ * under the terms of the GNU General Public License as published by
the *
+ * Free Software Foundation; either version 2 of the License, or (at
your *
+ * option) any later version.
*
+
\************************************************************************** */
/* $Id$ */
phpgw::import_class('phpgwapi.sql_criteria');
- class ajax_contacts {
- function __construct() {
+
+ class ajax_contacts
+ {
+
+ function __construct()
+ {
$GLOBALS['phpgw']->session->commit_session();
- $this->charset = 'utf-8';
+ $this->charset = 'utf-8';
$this->translation =
createObject('felamimail.translation');
}
-
- function searchAddress($_searchString) {
- if
(method_exists($GLOBALS['phpgw']->contacts,'search')) {
+
+ function searchAddress( $_searchString )
+ {
+
+ function compare( $a, $b )
+ {
+ return strcasecmp($a["n_fn"],$b["n_fn"]);
+ }
+
+ if (method_exists($GLOBALS['phpgw']->contacts,
'search'))
+ {
// 1.3+
$contacts =
$GLOBALS['phpgw']->contacts->search(array(
- 'n_fn' => $_searchString,
- 'email' => $_searchString,
+ 'n_fn' => $_searchString,
+ 'email' => $_searchString,
'email_home' => $_searchString,
-
),array('n_fn','email','email_home'),'n_fn','','%',false,'OR',array(0,20));
+ ), array('n_fn', 'email',
'email_home'), 'n_fn', '', '%', false, 'OR', array(
+ 0, 20));
// additionally search the accounts, if the
contact storage is not the account storage
if
($GLOBALS['phpgw_info']['server']['account_repository'] == 'ldap' &&
@@ -36,71 +49,82 @@
$GLOBALS['phpgw_info']['server']['contact_repository'] == 'sql')
{
$accounts =
$GLOBALS['phpgw']->contacts->search(array(
- 'n_fn' => $_searchString,
- 'email' => $_searchString,
+ 'n_fn' => $_searchString,
+ 'email' => $_searchString,
'email_home' => $_searchString,
-
),array('n_fn','email','email_home'),'n_fn','','%',false,'OR',array(0,20),array('owner'
=> 0));
-
+ ), array('n_fn', 'email',
'email_home'), 'n_fn', '', '%', false, 'OR', array(
+ 0, 20), array('owner' => 0));
+
if ($contacts && $accounts)
{
- $contacts =
array_merge($contacts,$accounts);
-
usort($contacts,create_function('$a,$b','return
strcasecmp($a["n_fn"],$b["n_fn"]);'));
+ $contacts =
array_merge($contacts, $accounts);
+ usort($contacts, 'compare');
}
- elseif($accounts)
+ elseif ($accounts)
{
- $contacts =& $accounts;
+ $contacts = & $accounts;
}
unset($accounts);
}
- } else {
+ }
+ else
+ {
// < 1.3
$d = CreateObject('phpgwapi.contacts');
- $fields = array ('per_first_name',
'per_last_name', 'email', 'email_home');
+ $fields = array('per_first_name',
'per_last_name', 'email', 'email_home');
$criteria_search[] =
phpgwapi_sql_criteria::token_begin('per_first_name', $_searchString);
$criteria_search[] =
phpgwapi_sql_criteria::token_begin('per_last_name', $_searchString);
- $criteria_search[] =
phpgwapi_sql_criteria::token_has('email', $_searchString);
+ $criteria_search[] =
phpgwapi_sql_criteria::token_has('email', $_searchString);
$criteria[] =
phpgwapi_sql_criteria::_append_or($criteria_search);
- $criteria[] = $d->criteria_for_index((int)
$GLOBALS['phpgw_info']['user']['account_id']);
+ $criteria[] =
$d->criteria_for_index((int)$GLOBALS['phpgw_info']['user']['account_id']);
$criteria_token =
phpgwapi_sql_criteria::_append_and($criteria);
//FIXME : the sql_builder/sql_criteria has issues.
$contacts = $d->get_persons($fields, 0, 0,
'per_last_name', 'ASC', '', $criteria_token);
}
- $response =& new xajaxResponse();
+ $response = & new xajaxResponse();
- if(is_array($contacts)) {
- $innerHTML = '';
- $jsArray = array();
- $i = 0;
-
- foreach($contacts as $contact) {
-
foreach(array($contact['email'],$contact['email_home']) as $email) {
+ if (is_array($contacts))
+ {
+ $innerHTML = '';
+ $jsArray = array();
+ $i = 0;
+
+ foreach ($contacts as $contact)
+ {
+ foreach (array($contact['email'],
$contact['email_home']) as $email)
+ {
// avoid wrong addresses, if an
rfc822 encoded address is in addressbook
- $email =
preg_replace("/(^.*<)(address@hidden)(.*)/",'$2',$email);
- if(!empty($email) &&
!isset($jsArray[$email])) {
+ $email =
preg_replace("/(^.*<)(address@hidden)(.*)/", '$2', $email);
+ if (!empty($email) &&
!isset($jsArray[$email]))
+ {
$i++;
- $str =
$this->translation->convert(trim($contact['n_fn'] ? $contact['n_fn'] :
$contact['fn']) .' <'. trim($email) .'>', $this->charset, 'utf-8');
+ $str =
$this->translation->convert(trim($contact['n_fn'] ? $contact['n_fn'] :
$contact['fn']) . ' <' . trim($email) . '>', $this->charset, 'utf-8');
#$innerHTML .= '<div
class="inactiveResultRow" onclick="selectSuggestion('. $i .')">'.
- $innerHTML .= '<div
class="inactiveResultRow" onmousedown="keypressed(13,1)"
onmouseover="selectSuggestion('.($i-1).')">'.
-
htmlentities($str, ENT_QUOTES, 'utf-8') .'</div>';
- $jsArray[$email] =
addslashes(trim($contact['n_fn'] ? $contact['n_fn'] : $contact['fn']) .' <'.
trim($email) .'>');
+ $innerHTML .= '<div
class="inactiveResultRow" onmousedown="keypressed(13,1)"
onmouseover="selectSuggestion(' . ($i - 1) . ')">' .
+
htmlentities($str, ENT_QUOTES, 'utf-8') . '</div>';
+ $jsArray[$email] =
addslashes(trim($contact['n_fn'] ? $contact['n_fn'] : $contact['fn']) . ' <' .
trim($email) . '>');
}
- if ($i > 10) break; // we
check for # of results here, as we might have empty email addresses
+ if ($i > 10)
+ break; // we check for
# of results here, as we might have empty email addresses
}
}
- if($jsArray) {
+ if ($jsArray)
+ {
$response->addAssign('resultBox',
'innerHTML', $innerHTML);
- $response->addScript('results = new
Array("'.implode('","',$jsArray).'");');
+ $response->addScript('results = new
Array("' . implode('","', $jsArray) . '");');
$response->addScript('displayResultBox();');
}
//$response->addScript("getResults();");
//$response->addScript("selectSuggestion(-1);");
- } else {
+ }
+ else
+ {
$response->addAssign('resultBox', 'className',
'resultBoxHidden');
}
return $response->getXML();
}
- }
+ }
\ No newline at end of file
Modified: trunk/phpgwapi/inc/class.data_cleaner.inc.php
===================================================================
--- trunk/phpgwapi/inc/class.data_cleaner.inc.php 2017-09-03 11:43:36 UTC
(rev 17028)
+++ trunk/phpgwapi/inc/class.data_cleaner.inc.php 2017-09-03 15:16:01 UTC
(rev 17029)
@@ -251,11 +251,21 @@
//XXX external references begin with http(s) isnt'it ?
what should I do if it's not external ?? like href="/tata"
// Just try to save a <a href="titi.org"> my site </a>
// you get a <a href="/phpgw/redirect.php?go=titi.org">
my site </a>
- // Save a second time and you will get :
- // <a
href="/phpgw/redirect.php?go=/phpgw/redirect.php?go=titi.org"> my site </a>
- // ....
$data =
preg_replace_callback('/href\s*=\s*([\\\]?["\']?)((?(1)[^\1]*?|[^\s]+))(?(1)\1|)/i',
- create_function('$m', 'return \'href="\' .
(strlen($m[2]) && $m[2]{0} == \'#\' ? $m[2] :
$GLOBALS[\'phpgw\']->safe_redirect(urldecode($m[2]))) . \'"\';'),
+// create_function('$m', 'return \'href="\' .
(strlen($m[2]) && $m[2]{0} == \'#\' ? $m[2] :
$GLOBALS[\'phpgw\']->safe_redirect(urldecode($m[2]))) . \'"\';'),
+ function ($m)
+ {
+ if(preg_match('/redirect.php\?go=/i',
$m[2]))
+ {
+ $url = $m[2];
+ }
+ else
+ {
+ $url = strlen($m[2]) &&
$m[2]{0} == '#' ? $m[2] : $GLOBALS['phpgw']->safe_redirect(urldecode($m[2]));
+ }
+ $ret = 'href="'. $url .'"';
+ return $ret;
+ },
$data);
}
return $data;
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Fmsystem-commits] [17029] More on preparing for php 7.2,
sigurdne <=