mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-12-23 23:29:31 +01:00
get arround: PHP Deprecated: Non-static method self::isError() should not be called statically, plus fixing IDE warnings
This commit is contained in:
parent
8c3360cda9
commit
da993d8a8e
@ -101,13 +101,12 @@ class emailadmin_script {
|
|||||||
|
|
||||||
#print "<br><br><br><br>get Script ". $this->name ."<bR>";
|
#print "<br><br><br><br>get Script ". $this->name ."<bR>";
|
||||||
|
|
||||||
if(PEAR::isError($script = $connection->getScript($this->name))) {
|
if(self::isError($script = $connection->getScript($this->name))) {
|
||||||
if ($this->debug) error_log(__CLASS__.'::'.__METHOD__.": error retrieving script: ".$script->getMessage());
|
if ($this->debug) error_log(__CLASS__.'::'.__METHOD__.": error retrieving script: ".$script->getMessage());
|
||||||
return $script;
|
return $script;
|
||||||
}
|
}
|
||||||
|
|
||||||
#print "<br>AAA: Script is ". htmlentities($script) ."<br>";
|
#print "<br>AAA: Script is ". htmlentities($script) ."<br>";
|
||||||
$lines = array();
|
|
||||||
$lines = preg_split("/\n/",$script); //,PREG_SPLIT_NO_EMPTY);
|
$lines = preg_split("/\n/",$script); //,PREG_SPLIT_NO_EMPTY);
|
||||||
|
|
||||||
$rules = array();
|
$rules = array();
|
||||||
@ -125,8 +124,8 @@ class emailadmin_script {
|
|||||||
|
|
||||||
/* next line should be the recognised encoded head. if not, the script
|
/* next line should be the recognised encoded head. if not, the script
|
||||||
* is of an unrecognised format, and we should not overwrite it. */
|
* is of an unrecognised format, and we should not overwrite it. */
|
||||||
$line = array_shift($lines);
|
$line1 = array_shift($lines);
|
||||||
if (!preg_match("/^# ?Mail(.*)rules for/", $line)){
|
if (!preg_match("/^# ?Mail(.*)rules for/", $line1)){
|
||||||
$this->errstr = 'retrieveRules: encoding not recognised';
|
$this->errstr = 'retrieveRules: encoding not recognised';
|
||||||
$this->so = false;
|
$this->so = false;
|
||||||
if ($this->debug) error_log(__CLASS__.'::'.__METHOD__.": encoding not recognised");
|
if ($this->debug) error_log(__CLASS__.'::'.__METHOD__.": encoding not recognised");
|
||||||
@ -136,7 +135,9 @@ class emailadmin_script {
|
|||||||
|
|
||||||
$line = array_shift($lines);
|
$line = array_shift($lines);
|
||||||
|
|
||||||
while (isset($line)){
|
while (isset($line))
|
||||||
|
{
|
||||||
|
$matches = null;
|
||||||
if (preg_match("/^ *#(#PSEUDO|rule|vacation|mode|notify)/i",$line,$matches)){
|
if (preg_match("/^ *#(#PSEUDO|rule|vacation|mode|notify)/i",$line,$matches)){
|
||||||
$line = rtrim($line);
|
$line = rtrim($line);
|
||||||
switch ($matches[1]){
|
switch ($matches[1]){
|
||||||
@ -182,9 +183,7 @@ class emailadmin_script {
|
|||||||
if (preg_match("/^ *#vacation&&(.*)&&(.*)&&(.*)&&(.*)&&(.*)/i",$line,$bits) ||
|
if (preg_match("/^ *#vacation&&(.*)&&(.*)&&(.*)&&(.*)&&(.*)/i",$line,$bits) ||
|
||||||
preg_match("/^ *#vacation&&(.*)&&(.*)&&(.*)&&(.*)/i",$line,$bits)) {
|
preg_match("/^ *#vacation&&(.*)&&(.*)&&(.*)&&(.*)/i",$line,$bits)) {
|
||||||
$vacation['days'] = $bits[1];
|
$vacation['days'] = $bits[1];
|
||||||
$vaddresslist = $bits[2];
|
$vaddresslist = preg_replace("/\"|\s/","",$bits[2]);
|
||||||
$vaddresslist = preg_replace("/\"|\s/","",$vaddresslist);
|
|
||||||
$vaddresses = array();
|
|
||||||
$vaddresses = preg_split("/,/",$vaddresslist);
|
$vaddresses = preg_split("/,/",$vaddresslist);
|
||||||
$vacation['text'] = $bits[3];
|
$vacation['text'] = $bits[3];
|
||||||
|
|
||||||
@ -587,11 +586,10 @@ class emailadmin_script {
|
|||||||
$this->script = $newscript;
|
$this->script = $newscript;
|
||||||
//error_log(__METHOD__.__LINE__.array2string($newscript));
|
//error_log(__METHOD__.__LINE__.array2string($newscript));
|
||||||
//print "<pre>$newscript</pre>"; exit;
|
//print "<pre>$newscript</pre>"; exit;
|
||||||
$scriptfile = $this->name;
|
|
||||||
//print "<hr><pre>".htmlentities($newscript)."</pre><hr>";
|
//print "<hr><pre>".htmlentities($newscript)."</pre><hr>";
|
||||||
$ret = $connection->installScript($this->name, $newscript, true);
|
$ret = $connection->installScript($this->name, $newscript, true);
|
||||||
if (!$ret || PEAR::isError($ret)) {
|
if (!$ret || self::isError($ret)) {
|
||||||
$this->errstr = 'updateScript: putscript failed: ' . (PEAR::isError($ret)?$ret->message:$connection->errstr);
|
$this->errstr = 'updateScript: putscript failed: ' . (self::isError($ret)?$ret->message:$connection->errstr);
|
||||||
error_log(__METHOD__.__LINE__.' # Error: ->'.$this->errstr);
|
error_log(__METHOD__.__LINE__.' # Error: ->'.$this->errstr);
|
||||||
error_log(__METHOD__.__LINE__.' # ScriptName:'.$this->name.' Script:'.$newscript);
|
error_log(__METHOD__.__LINE__.' # ScriptName:'.$this->name.' Script:'.$newscript);
|
||||||
error_log(__METHOD__.__LINE__.' # Instance='.$GLOBALS['egw_info']['user']['domain'].', User='.$GLOBALS['egw_info']['user']['account_lid']);
|
error_log(__METHOD__.__LINE__.' # Instance='.$GLOBALS['egw_info']['user']['domain'].', User='.$GLOBALS['egw_info']['user']['account_lid']);
|
||||||
@ -600,4 +598,25 @@ class emailadmin_script {
|
|||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tell whether a value is a PEAR error.
|
||||||
|
*
|
||||||
|
* Implemented here to get arround: PHP Deprecated: Non-static method self::isError() should not be called statically
|
||||||
|
*
|
||||||
|
* @param mixed $data the value to test
|
||||||
|
* @param int $code if $data is an error object, return true
|
||||||
|
* only if $code is a string and
|
||||||
|
* $obj->getMessage() == $code or
|
||||||
|
* $code is an integer and $obj->getCode() == $code
|
||||||
|
* @access public
|
||||||
|
* @return bool true if parameter is an error
|
||||||
|
*/
|
||||||
|
protected static function isError($data, $code = null)
|
||||||
|
{
|
||||||
|
static $pear=null;
|
||||||
|
if (!isset($pear)) $pear = new PEAR();
|
||||||
|
|
||||||
|
return $pear->isError($data, $code);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -195,7 +195,7 @@ class emailadmin_sieve extends Net_Sieve
|
|||||||
$this->_timeout = $timeout;
|
$this->_timeout = $timeout;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(PEAR::isError($this->error = $this->connect($sieveHost , $sievePort, $options, $useTLS) ) )
|
if(self::isError($this->error = $this->connect($sieveHost , $sievePort, $options, $useTLS) ) )
|
||||||
{
|
{
|
||||||
if ($this->debug)
|
if ($this->debug)
|
||||||
{
|
{
|
||||||
@ -215,7 +215,7 @@ class emailadmin_sieve extends Net_Sieve
|
|||||||
$this->supportedAuthMethods = $sieveAuthMethods[$_icServerID];
|
$this->supportedAuthMethods = $sieveAuthMethods[$_icServerID];
|
||||||
}
|
}
|
||||||
|
|
||||||
if(PEAR::isError($this->error = $this->login($username, $password, 'LOGIN', $euser) ) )
|
if(self::isError($this->error = $this->login($username, $password, 'LOGIN', $euser) ) )
|
||||||
{
|
{
|
||||||
if ($this->debug)
|
if ($this->debug)
|
||||||
{
|
{
|
||||||
@ -274,7 +274,7 @@ class emailadmin_sieve extends Net_Sieve
|
|||||||
return PEAR::raiseError('Not currently in DISCONNECTED state', 1);
|
return PEAR::raiseError('Not currently in DISCONNECTED state', 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (PEAR::isError($res = $this->_sock->connect($host, $port, false, ($this->_timeout?$this->_timeout:10), $options))) {
|
if (self::isError($res = $this->_sock->connect($host, $port, false, ($this->_timeout?$this->_timeout:10), $options))) {
|
||||||
return $res;
|
return $res;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -282,14 +282,14 @@ class emailadmin_sieve extends Net_Sieve
|
|||||||
$this->_state = NET_SIEVE_STATE_TRANSACTION;
|
$this->_state = NET_SIEVE_STATE_TRANSACTION;
|
||||||
} else {
|
} else {
|
||||||
$this->_state = NET_SIEVE_STATE_AUTHORISATION;
|
$this->_state = NET_SIEVE_STATE_AUTHORISATION;
|
||||||
if (PEAR::isError($res = $this->_doCmd())) {
|
if (self::isError($res = $this->_doCmd())) {
|
||||||
return $res;
|
return $res;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Explicitly ask for the capabilities in case the connection is
|
// Explicitly ask for the capabilities in case the connection is
|
||||||
// picked up from an existing connection.
|
// picked up from an existing connection.
|
||||||
if (PEAR::isError($res = $this->_cmdCapability())) {
|
if (self::isError($res = $this->_cmdCapability())) {
|
||||||
return PEAR::raiseError(
|
return PEAR::raiseError(
|
||||||
'Failed to connect, server said: ' . $res->getMessage(), 2
|
'Failed to connect, server said: ' . $res->getMessage(), 2
|
||||||
);
|
);
|
||||||
@ -299,7 +299,7 @@ class emailadmin_sieve extends Net_Sieve
|
|||||||
if ($useTLS && !empty($this->_capability['starttls'])
|
if ($useTLS && !empty($this->_capability['starttls'])
|
||||||
&& function_exists('stream_socket_enable_crypto')
|
&& function_exists('stream_socket_enable_crypto')
|
||||||
) {
|
) {
|
||||||
if (PEAR::isError($res = $this->_startTLS())) {
|
if (self::isError($res = $this->_startTLS())) {
|
||||||
return $res;
|
return $res;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -368,14 +368,14 @@ class emailadmin_sieve extends Net_Sieve
|
|||||||
*/
|
*/
|
||||||
function _cmdAuthenticate($uid , $pwd , $userMethod = null , $euser = '' )
|
function _cmdAuthenticate($uid , $pwd , $userMethod = null , $euser = '' )
|
||||||
{
|
{
|
||||||
if ( PEAR::isError( $method = $this->_getBestAuthMethod($userMethod) ) ) {
|
if ( self::isError( $method = $this->_getBestAuthMethod($userMethod) ) ) {
|
||||||
return $method;
|
return $method;
|
||||||
}
|
}
|
||||||
//error_log(__METHOD__.__LINE__.' using AuthMethod: '.$method);
|
//error_log(__METHOD__.__LINE__.' using AuthMethod: '.$method);
|
||||||
switch ($method) {
|
switch ($method) {
|
||||||
case 'DIGEST-MD5':
|
case 'DIGEST-MD5':
|
||||||
$result = $this->_authDigestMD5( $uid , $pwd , $euser );
|
$result = $this->_authDigestMD5( $uid , $pwd , $euser );
|
||||||
if (!PEAR::isError($result))
|
if (!self::isError($result))
|
||||||
{
|
{
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -385,7 +385,7 @@ class emailadmin_sieve extends Net_Sieve
|
|||||||
return $this->_cmdAuthenticate($uid , $pwd, null, $euser);
|
return $this->_cmdAuthenticate($uid , $pwd, null, $euser);
|
||||||
case 'CRAM-MD5':
|
case 'CRAM-MD5':
|
||||||
$result = $this->_authCRAMMD5( $uid , $pwd, $euser);
|
$result = $this->_authCRAMMD5( $uid , $pwd, $euser);
|
||||||
if (!PEAR::isError($result))
|
if (!self::isError($result))
|
||||||
{
|
{
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -395,7 +395,7 @@ class emailadmin_sieve extends Net_Sieve
|
|||||||
return $this->_cmdAuthenticate($uid , $pwd, null, $euser);
|
return $this->_cmdAuthenticate($uid , $pwd, null, $euser);
|
||||||
case 'LOGIN':
|
case 'LOGIN':
|
||||||
$result = $this->_authLOGIN( $uid , $pwd , $euser );
|
$result = $this->_authLOGIN( $uid , $pwd , $euser );
|
||||||
if (!PEAR::isError($result))
|
if (!self::isError($result))
|
||||||
{
|
{
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -410,16 +410,16 @@ class emailadmin_sieve extends Net_Sieve
|
|||||||
$result = new PEAR_Error( "$method is not a supported authentication method" );
|
$result = new PEAR_Error( "$method is not a supported authentication method" );
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (PEAR::isError($result))
|
if (self::isError($result))
|
||||||
{
|
{
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
if (PEAR::isError($res = $this->_doCmd())) {
|
if (self::isError($res = $this->_doCmd())) {
|
||||||
return $res;
|
return $res;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Query the server capabilities again now that we are authenticated.
|
// Query the server capabilities again now that we are authenticated.
|
||||||
if (PEAR::isError($res = $this->_cmdCapability())) {
|
if (self::isError($res = $this->_cmdCapability())) {
|
||||||
return PEAR::raiseError(
|
return PEAR::raiseError(
|
||||||
'Failed to connect, server said: ' . $res->getMessage(), 2
|
'Failed to connect, server said: ' . $res->getMessage(), 2
|
||||||
);
|
);
|
||||||
@ -532,4 +532,25 @@ class emailadmin_sieve extends Net_Sieve
|
|||||||
|
|
||||||
return $script;
|
return $script;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tell whether a value is a PEAR error.
|
||||||
|
*
|
||||||
|
* Implemented here to get arround: PHP Deprecated: Non-static method self::isError() should not be called statically
|
||||||
|
*
|
||||||
|
* @param mixed $data the value to test
|
||||||
|
* @param int $code if $data is an error object, return true
|
||||||
|
* only if $code is a string and
|
||||||
|
* $obj->getMessage() == $code or
|
||||||
|
* $code is an integer and $obj->getCode() == $code
|
||||||
|
* @access public
|
||||||
|
* @return bool true if parameter is an error
|
||||||
|
*/
|
||||||
|
protected static function isError($data, $code = null)
|
||||||
|
{
|
||||||
|
static $pear=null;
|
||||||
|
if (!isset($pear)) $pear = new PEAR();
|
||||||
|
|
||||||
|
return $pear->isError($data, $code);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user