diff --git a/emailadmin/inc/class.emailadmin_script.inc.php b/emailadmin/inc/class.emailadmin_script.inc.php index 5bdc434723..751928e431 100644 --- a/emailadmin/inc/class.emailadmin_script.inc.php +++ b/emailadmin/inc/class.emailadmin_script.inc.php @@ -101,13 +101,12 @@ class emailadmin_script { #print "



get Script ". $this->name ."
"; - 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()); return $script; } #print "
AAA: Script is ". htmlentities($script) ."
"; - $lines = array(); $lines = preg_split("/\n/",$script); //,PREG_SPLIT_NO_EMPTY); $rules = array(); @@ -125,8 +124,8 @@ class emailadmin_script { /* next line should be the recognised encoded head. if not, the script * is of an unrecognised format, and we should not overwrite it. */ - $line = array_shift($lines); - if (!preg_match("/^# ?Mail(.*)rules for/", $line)){ + $line1 = array_shift($lines); + if (!preg_match("/^# ?Mail(.*)rules for/", $line1)){ $this->errstr = 'retrieveRules: encoding not recognised'; $this->so = false; if ($this->debug) error_log(__CLASS__.'::'.__METHOD__.": encoding not recognised"); @@ -136,7 +135,9 @@ class emailadmin_script { $line = array_shift($lines); - while (isset($line)){ + while (isset($line)) + { + $matches = null; if (preg_match("/^ *#(#PSEUDO|rule|vacation|mode|notify)/i",$line,$matches)){ $line = rtrim($line); switch ($matches[1]){ @@ -182,9 +183,7 @@ class emailadmin_script { if (preg_match("/^ *#vacation&&(.*)&&(.*)&&(.*)&&(.*)&&(.*)/i",$line,$bits) || preg_match("/^ *#vacation&&(.*)&&(.*)&&(.*)&&(.*)/i",$line,$bits)) { $vacation['days'] = $bits[1]; - $vaddresslist = $bits[2]; - $vaddresslist = preg_replace("/\"|\s/","",$vaddresslist); - $vaddresses = array(); + $vaddresslist = preg_replace("/\"|\s/","",$bits[2]); $vaddresses = preg_split("/,/",$vaddresslist); $vacation['text'] = $bits[3]; @@ -587,11 +586,10 @@ class emailadmin_script { $this->script = $newscript; //error_log(__METHOD__.__LINE__.array2string($newscript)); //print "
$newscript
"; exit; - $scriptfile = $this->name; //print "
".htmlentities($newscript)."

"; $ret = $connection->installScript($this->name, $newscript, true); - if (!$ret || PEAR::isError($ret)) { - $this->errstr = 'updateScript: putscript failed: ' . (PEAR::isError($ret)?$ret->message:$connection->errstr); + if (!$ret || self::isError($ret)) { + $this->errstr = 'updateScript: putscript failed: ' . (self::isError($ret)?$ret->message:$connection->errstr); error_log(__METHOD__.__LINE__.' # Error: ->'.$this->errstr); 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']); @@ -600,4 +598,25 @@ class emailadmin_script { 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); + } } diff --git a/emailadmin/inc/class.emailadmin_sieve.inc.php b/emailadmin/inc/class.emailadmin_sieve.inc.php index 2165646b80..0dee845d22 100644 --- a/emailadmin/inc/class.emailadmin_sieve.inc.php +++ b/emailadmin/inc/class.emailadmin_sieve.inc.php @@ -195,7 +195,7 @@ class emailadmin_sieve extends Net_Sieve $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) { @@ -215,7 +215,7 @@ class emailadmin_sieve extends Net_Sieve $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) { @@ -274,7 +274,7 @@ class emailadmin_sieve extends Net_Sieve 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; } @@ -282,14 +282,14 @@ class emailadmin_sieve extends Net_Sieve $this->_state = NET_SIEVE_STATE_TRANSACTION; } else { $this->_state = NET_SIEVE_STATE_AUTHORISATION; - if (PEAR::isError($res = $this->_doCmd())) { + if (self::isError($res = $this->_doCmd())) { return $res; } } // Explicitly ask for the capabilities in case the connection is // picked up from an existing connection. - if (PEAR::isError($res = $this->_cmdCapability())) { + if (self::isError($res = $this->_cmdCapability())) { return PEAR::raiseError( 'Failed to connect, server said: ' . $res->getMessage(), 2 ); @@ -299,7 +299,7 @@ class emailadmin_sieve extends Net_Sieve if ($useTLS && !empty($this->_capability['starttls']) && function_exists('stream_socket_enable_crypto') ) { - if (PEAR::isError($res = $this->_startTLS())) { + if (self::isError($res = $this->_startTLS())) { return $res; } } @@ -368,14 +368,14 @@ class emailadmin_sieve extends Net_Sieve */ function _cmdAuthenticate($uid , $pwd , $userMethod = null , $euser = '' ) { - if ( PEAR::isError( $method = $this->_getBestAuthMethod($userMethod) ) ) { + if ( self::isError( $method = $this->_getBestAuthMethod($userMethod) ) ) { return $method; } //error_log(__METHOD__.__LINE__.' using AuthMethod: '.$method); switch ($method) { case 'DIGEST-MD5': $result = $this->_authDigestMD5( $uid , $pwd , $euser ); - if (!PEAR::isError($result)) + if (!self::isError($result)) { break; } @@ -385,7 +385,7 @@ class emailadmin_sieve extends Net_Sieve return $this->_cmdAuthenticate($uid , $pwd, null, $euser); case 'CRAM-MD5': $result = $this->_authCRAMMD5( $uid , $pwd, $euser); - if (!PEAR::isError($result)) + if (!self::isError($result)) { break; } @@ -395,7 +395,7 @@ class emailadmin_sieve extends Net_Sieve return $this->_cmdAuthenticate($uid , $pwd, null, $euser); case 'LOGIN': $result = $this->_authLOGIN( $uid , $pwd , $euser ); - if (!PEAR::isError($result)) + if (!self::isError($result)) { break; } @@ -410,16 +410,16 @@ class emailadmin_sieve extends Net_Sieve $result = new PEAR_Error( "$method is not a supported authentication method" ); break; } - if (PEAR::isError($result)) + if (self::isError($result)) { return $result; } - if (PEAR::isError($res = $this->_doCmd())) { + if (self::isError($res = $this->_doCmd())) { return $res; } // 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( 'Failed to connect, server said: ' . $res->getMessage(), 2 ); @@ -532,4 +532,25 @@ class emailadmin_sieve extends Net_Sieve 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); + } }