From 328ec52c884d2ff05eed5b7796a452bc728d59a1 Mon Sep 17 00:00:00 2001 From: Eric Date: Mon, 31 Aug 2020 11:38:24 +0200 Subject: [PATCH] =?UTF-8?q?N=C2=B03162=20-=20Remove=20default=20admin=20ph?= =?UTF-8?q?one=20number=20(can=20be=20incompatible=20with=20validation=20p?= =?UTF-8?q?attern)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../userrightsprofile.class.inc.php | 20 ++++++++++--------- .../userrightsprofile.db.class.inc.php | 10 +++------- 2 files changed, 14 insertions(+), 16 deletions(-) diff --git a/addons/userrights/userrightsprofile.class.inc.php b/addons/userrights/userrightsprofile.class.inc.php index 294164d20..15155db7e 100644 --- a/addons/userrights/userrightsprofile.class.inc.php +++ b/addons/userrights/userrightsprofile.class.inc.php @@ -434,7 +434,7 @@ class UserRightsProfile extends UserRightsAddOnAPI // Support drastic data model changes: no organization class (or not writable)! if (MetaModel::IsValidClass('Organization') && !MetaModel::IsAbstract('Organization')) { - $oOrg = new Organization(); + $oOrg = MetaModel::NewObject('Organization'); $oOrg->Set('name', 'My Company/Department'); $oOrg->Set('code', 'SOMECODE'); $iOrgId = $oOrg->DBInsertNoReload(); @@ -442,17 +442,13 @@ class UserRightsProfile extends UserRightsAddOnAPI // Support drastic data model changes: no Person class (or not writable)! if (MetaModel::IsValidClass('Person') && !MetaModel::IsAbstract('Person')) { - $oContact = new Person(); + $oContact = MetaModel::NewObject('Person'); $oContact->Set('name', 'My last name'); $oContact->Set('first_name', 'My first name'); if (MetaModel::IsValidAttCode('Person', 'org_id')) { $oContact->Set('org_id', $iOrgId); } - if (MetaModel::IsValidAttCode('Person', 'phone')) - { - $oContact->Set('phone', '+00 000 000 000'); - } $oContact->Set('email', 'my.email@foo.org'); $iContactId = $oContact->DBInsertNoReload(); } @@ -561,7 +557,7 @@ class UserRightsProfile extends UserRightsAddOnAPI /** * @param $oUser User - * @return array + * @return bool */ public function IsAdministrator($oUser) { @@ -571,16 +567,22 @@ class UserRightsProfile extends UserRightsAddOnAPI /** * @param $oUser User - * @return array + * @return bool */ public function IsPortalUser($oUser) { // UserRights caches the list for us return UserRights::HasProfile(PORTAL_PROFILE_NAME, $oUser); } + /** * @param $oUser User - * @return bool + * + * @return array + * @throws \ArchivedObjectException + * @throws \CoreException + * @throws \CoreUnexpectedValue + * @throws \MySQLException */ public function ListProfiles($oUser) { diff --git a/addons/userrights/userrightsprofile.db.class.inc.php b/addons/userrights/userrightsprofile.db.class.inc.php index 2115f1b8d..f35fa6af7 100644 --- a/addons/userrights/userrightsprofile.db.class.inc.php +++ b/addons/userrights/userrightsprofile.db.class.inc.php @@ -535,7 +535,7 @@ class UserRightsProfile extends UserRightsAddOnAPI // Support drastic data model changes: no organization class (or not writable)! if (MetaModel::IsValidClass('Organization') && !MetaModel::IsAbstract('Organization')) { - $oOrg = new Organization(); + $oOrg = MetaModel::NewObject('Organization'); $oOrg->Set('name', 'My Company/Department'); $oOrg->Set('code', 'SOMECODE'); $oOrg::SetCurrentChange($oChange); @@ -544,17 +544,13 @@ class UserRightsProfile extends UserRightsAddOnAPI // Support drastic data model changes: no Person class (or not writable)! if (MetaModel::IsValidClass('Person') && !MetaModel::IsAbstract('Person')) { - $oContact = new Person(); + $oContact = MetaModel::NewObject('Person'); $oContact->Set('name', 'My last name'); $oContact->Set('first_name', 'My first name'); if (MetaModel::IsValidAttCode('Person', 'org_id')) { $oContact->Set('org_id', $iOrgId); } - if (MetaModel::IsValidAttCode('Person', 'phone')) - { - $oContact->Set('phone', '+00 000 000 000'); - } $oContact->Set('email', 'my.email@foo.org'); $oContact::SetCurrentChange($oChange); $iContactId = $oContact->DBInsertNoReload(); @@ -711,7 +707,7 @@ class UserRightsProfile extends UserRightsAddOnAPI public function LoadCache() { - if (!is_null($this->m_aProfiles)) return; + if (!is_null($this->m_aProfiles)) return false; // Could be loaded in a shared memory (?) $oKPI = new ExecutionKPI();