From 77c5102792c92ade89f8790c61339c5ef9ea141d Mon Sep 17 00:00:00 2001 From: Ralf Becker Date: Mon, 21 Mar 2016 21:21:40 +0000 Subject: [PATCH] fixed more namespace issues found by doc/check_namespace.php I wrote and forgot about it ;-) --- api/js/etemplate/et2_core_widget.js | 5 +++++ api/src/Accounts/Ads.php | 12 ++++++------ api/src/Accounts/Ldap.php | 3 ++- api/src/Contacts/Ads.php | 2 +- api/src/Contacts/Storage.php | 2 +- api/src/Contacts/Univention.php | 4 +++- api/src/DateTime.php | 5 ++--- api/src/Db.php | 4 ++-- api/src/Db/Backup.php | 8 ++++---- api/src/Db/Deprecated.php | 4 ++-- api/src/Etemplate/Widget/Contact.php | 2 +- api/src/Etemplate/Widget/Customfields.php | 6 ++---- api/src/Html.php | 2 +- api/src/Html/HtmLawed.php | 6 +++++- api/src/Link.php | 8 ++++---- api/src/Storage/Base.php | 2 +- api/src/Vfs/Sqlfs/Utils.php | 6 +++--- 17 files changed, 45 insertions(+), 36 deletions(-) diff --git a/api/js/etemplate/et2_core_widget.js b/api/js/etemplate/et2_core_widget.js index 408519d85e..97ee449021 100644 --- a/api/js/etemplate/et2_core_widget.js +++ b/api/js/etemplate/et2_core_widget.js @@ -74,6 +74,11 @@ function et2_createWidget(_name, _attrs, _parent) _attrs = {}; } + if (typeof _attrs != "object") + { + _attrs = {}; + } + if (typeof _parent == "undefined") { _parent = null; diff --git a/api/src/Accounts/Ads.php b/api/src/Accounts/Ads.php index 80f5642df5..767cd2d32d 100644 --- a/api/src/Accounts/Ads.php +++ b/api/src/Accounts/Ads.php @@ -214,7 +214,7 @@ class Ads if ($set_if_empty && ($dn = $this->id2name(-self::DOMAIN_USERS_GROUP, 'account_dn'))) { $dn = preg_replace('/^CN=.*?,(CN|OU)=/i', '$1=', $dn); - config::save_value(self::ADS_CONTEXT, $this->frontend->config[self::ADS_CONTEXT]=$dn, 'phpgwapi'); + Api\Config::save_value(self::ADS_CONTEXT, $this->frontend->config[self::ADS_CONTEXT]=$dn, 'phpgwapi'); } else { @@ -522,7 +522,7 @@ class Ads public function user_active(array $data) { $user = $this->_ldap2user($data); - $active = accounts::is_active($user); + $active = Api\Accounts::is_active($user); //error_log(__METHOD__."(cn={$data['cn'][0]}, useraccountcontrol={$data['useraccountcontrol'][0]}, accountexpires={$data['accountexpires'][0]}) user=".array2string($user)." returning ".array2string($active)); return $active; } @@ -562,7 +562,7 @@ class Ads protected static function _when2ts($_when) { static $utc=null; - if (!isset($utc)) $utc = new DateTimeZone('UTC'); + if (!isset($utc)) $utc = new \DateTimeZone('UTC'); list($when) = explode('.', $_when); // remove .0Z not understood by createFromFormat $datetime = Api\DateTime::createFromFormat(self::WHEN_FORMAT, $when, $utc); @@ -778,8 +778,8 @@ class Ads break; case 'account_lastpwd_change': // Samba4 does not understand -1 for current time, but Win2008r2 only allows to set -1 (beside 0) - // call auth_ads::setLastPwdChange with true to get correct modification for both - $ldap = array_merge($ldap, auth_ads::setLastPwdChange($data['account_lid'], null, $data[$egw], true)); + // call Api\Auth\Ads::setLastPwdChange with true to get correct modification for both + $ldap = array_merge($ldap, Api\Auth\Ads::setLastPwdChange($data['account_lid'], null, $data[$egw], true)); break; default: $attributes[$adldap] = $data[$egw]; @@ -910,7 +910,7 @@ class Ads { continue; } - $account['account_fullname'] = common::display_fullname($account['account_lid'],$account['account_firstname'],$account['account_lastname'],$account['account_id']); + $account['account_fullname'] = Api\Accounts::format_username($account['account_lid'],$account['account_firstname'],$account['account_lastname'],$account['account_id']); $accounts[$account_id] = $account; } } diff --git a/api/src/Accounts/Ldap.php b/api/src/Accounts/Ldap.php index 65212b3e82..f663e5ea91 100644 --- a/api/src/Accounts/Ldap.php +++ b/api/src/Accounts/Ldap.php @@ -23,6 +23,7 @@ use EGroupware\Api; // explicitly reference classes still in phpgwapi or old structure use common; // next_id +use setup_cmd_ldap; /** * LDAP Backend for accounts @@ -595,7 +596,7 @@ class Ldap { if (preg_match('/^[a-f0-9]{32}$/', $data['account_passwd'])) // md5 --> ldap md5 { - $data['account_passwd'] = setup_cmd_Api\Ldap::hash_sql2ldap($data['account_passwd']); + $data['account_passwd'] = setup_cmd_ldap::hash_sql2ldap($data['account_passwd']); } elseif (!preg_match('/^\\{[a-z5]{3,5}\\}.+/i',$data['account_passwd'])) // if it's not already entcrypted, do so now { diff --git a/api/src/Contacts/Ads.php b/api/src/Contacts/Ads.php index a933e52ead..435abd50fe 100644 --- a/api/src/Contacts/Ads.php +++ b/api/src/Contacts/Ads.php @@ -158,7 +158,7 @@ class Ads extends Ldap // we cant use ldap::quote() for win2008r2 hex GUID, as it contains backslashes if (!preg_match('/^[0-9A-Fa-f-]+/', $contact_id)) { - throw new egw_exception_assertion_failed("'$contact_id' is NOT a valid GUID!"); + throw new Api\Exception\AssertionFailed("'$contact_id' is NOT a valid GUID!"); } // samba4 can only search by string representation of objectGUID, while win2008r2 requires hex representation diff --git a/api/src/Contacts/Storage.php b/api/src/Contacts/Storage.php index 49bb9af5d0..a948734bd3 100755 --- a/api/src/Contacts/Storage.php +++ b/api/src/Contacts/Storage.php @@ -909,7 +909,7 @@ class Storage $sql_contacts = new Sql(); // we need an admin connection $ds = $GLOBALS['egw']->ldap->ldapConnect(); - $ldap_contacts = new addressbook_ldap(null, $ds); + $ldap_contacts = new Ldap(null, $ds); if (!is_array($type)) $type = explode(',', $type); diff --git a/api/src/Contacts/Univention.php b/api/src/Contacts/Univention.php index e05ae9084e..428a148619 100644 --- a/api/src/Contacts/Univention.php +++ b/api/src/Contacts/Univention.php @@ -12,6 +12,8 @@ namespace EGroupware\Api\Contacts; +use EGroupware\Api\Accounts; + /** * Univention backend for addressbook * @@ -22,7 +24,7 @@ class Univention extends Ldap function __construct($ldap_config = null, $ds = null) { $this->schema2egw['univentionmail'] = array( - 'email' => accounts_univention::MAIL_ATTR, + 'email' => Accounts\Univention::MAIL_ATTR, ); parent::__construct($ldap_config, $ds); } diff --git a/api/src/DateTime.php b/api/src/DateTime.php index bd57bc9078..be01e6cb75 100644 --- a/api/src/DateTime.php +++ b/api/src/DateTime.php @@ -167,7 +167,7 @@ class DateTime extends \DateTime } // fall through default: - throw new egw_exception_assertion_failed("Not implemented for type ($type)$time!"); + throw new Exception\AssertionFailed("Not implemented for type ($type)$time!"); } } @@ -483,7 +483,6 @@ class DateTime extends \DateTime * @param string $tz timezone, eg. 'Europe/Berlin' or 'UTC' * @param string $dateformat ='' eg. 'Y-m-d' or 'd.m.Y' * @param string|int $timeformat ='' integer 12, 24, or format string eg. 'H:i' - * @throws egw_exception_wrong_userinput if invalid $tz parameter * @return DateTimeZone */ public static function setUserPrefs($tz,$dateformat='',$timeformat='') @@ -508,7 +507,7 @@ class DateTime extends \DateTime try { self::$user_timezone = new DateTimeZone($tz); } - catch(Exception $e) + catch(\Exception $e) { unset($e); // silently use server timezone, as we have no means to report the wrong timezone to the user from this class diff --git a/api/src/Db.php b/api/src/Db.php index 9a3a804f9d..a7432b96c0 100644 --- a/api/src/Db.php +++ b/api/src/Db.php @@ -1562,7 +1562,7 @@ class Db if ($this === $GLOBALS['egw']->db && $app != self::API_APPNAME) { // prevent that anyone switches the global db object to an other app - throw new Api\Exception\WrongParameter('You are not allowed to call set_app for $GLOBALS[egw]->db or a refence to it, you have to clone it!'); + throw new Exception\WrongParameter('You are not allowed to call set_app for $GLOBALS[egw]->db or a refence to it, you have to clone it!'); } $this->app = $app; } @@ -1735,7 +1735,7 @@ class Db $inputarr = false; if (isset($data[0]) && is_array($data[0])) // multiple data rows { - if ($where) throw new Api\Exception\WrongParameter('Can NOT use $where together with multiple data rows in $data!'); + if ($where) throw new Exception\WrongParameter('Can NOT use $where together with multiple data rows in $data!'); $sql = "$cmd INTO $table "; foreach($data as $k => $d) diff --git a/api/src/Db/Backup.php b/api/src/Db/Backup.php index e8a1e07216..a7b9a40153 100644 --- a/api/src/Db/Backup.php +++ b/api/src/Db/Backup.php @@ -313,11 +313,11 @@ class Backup */ function saveConfig($minCount,$backupFiles=null) { - Config::save_value('backup_mincount',$this->backup_mincount=(int)$minCount,'phpgwapi'); + Api\Config::save_value('backup_mincount',$this->backup_mincount=(int)$minCount,'phpgwapi'); if (!is_null($backupFiles)) { - Config::save_value('backup_files',$this->backup_files=(boolean)$backupFiles,'phpgwapi'); + Api\Config::save_value('backup_files',$this->backup_files=(boolean)$backupFiles,'phpgwapi'); } } @@ -426,7 +426,7 @@ class Backup if ($convert_to_system_charset) // store the changed charset { - $this->db->insert(Config::TABLE, array( + $this->db->insert(Api\Config::TABLE, array( 'config_value' => $this->schema_proc->system_charset, ),array( 'config_app' => 'phpgwapi', @@ -918,7 +918,7 @@ class Backup { $zippresent = true; //echo '-> is_object($zip); '.$filename.'
'; // ! - $res = $zip->open($filename, ZIPARCHIVE::CREATE); + $res = $zip->open($filename, ZipArchive::CREATE); if($res !== TRUE) { //echo ' -> !$res
'; // ! diff --git a/api/src/Db/Deprecated.php b/api/src/Db/Deprecated.php index 7ada4ba3f8..95fff586fb 100644 --- a/api/src/Db/Deprecated.php +++ b/api/src/Db/Deprecated.php @@ -119,7 +119,7 @@ class Deprecated extends Api\Db { if (!$this->Query_ID) { - throw new Exception\Db('next_record called with no query pending.'); + throw new Exception('next_record called with no query pending.'); } if ($this->Row) // first row is already fetched { @@ -174,7 +174,7 @@ class Deprecated extends Api\Db { if (!$this->Query_ID || !$this->Query_ID->Move($this->Row = $pos)) { - throw new Exception\Db("seek($pos) failed: resultset has " . $this->num_rows() . " rows"); + throw new Exception("seek($pos) failed: resultset has " . $this->num_rows() . " rows"); } return True; } diff --git a/api/src/Etemplate/Widget/Contact.php b/api/src/Etemplate/Widget/Contact.php index 8b56dce729..bcdc6f0a05 100644 --- a/api/src/Etemplate/Widget/Contact.php +++ b/api/src/Etemplate/Widget/Contact.php @@ -124,7 +124,7 @@ class Contact extends Entry */ public function get_contact_fields() { - ApiTranslation::add_app('addressbook'); + Api\Translation::add_app('addressbook'); $this->contacts->__construct(); $options = $this->contacts->contact_fields; diff --git a/api/src/Etemplate/Widget/Customfields.php b/api/src/Etemplate/Widget/Customfields.php index daa8b40b16..f0387f60e3 100644 --- a/api/src/Etemplate/Widget/Customfields.php +++ b/api/src/Etemplate/Widget/Customfields.php @@ -130,10 +130,8 @@ class Customfields extends Transformer } // if we are in the etemplate editor or the app has no cf's, load the cf's from the app the tpl belongs too - if ($app && $app != 'stylite' && $app != $GLOBALS['egw_info']['flags']['currentapp'] && !isset($customfields) && ( - $GLOBALS['egw_info']['flags']['currentapp'] == 'etemplate' || !$this->attrs['customfields'] || - Etemplate::$hooked - ) || !isset($customfields)) + if ($app && $app != 'stylite' && $app != $GLOBALS['egw_info']['flags']['currentapp'] && !isset($customfields) && + ($GLOBALS['egw_info']['flags']['currentapp'] == 'etemplate' || !$this->attrs['customfields']) || !isset($customfields)) { // app changed $customfields =& Api\Storage\Customfields::get($app); diff --git a/api/src/Html.php b/api/src/Html.php index d505ea6b62..69437d1eb6 100644 --- a/api/src/Html.php +++ b/api/src/Html.php @@ -1133,7 +1133,7 @@ egw_LAB.wait(function() { $html .= "