Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 0 additions & 11 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,6 @@ You want to contribute to iTop? Many thanks to you! 🎉 👍
Here are some guidelines that will help us integrate your work!


## Contributions


```
_ _ _ _ _ __ _
| | | | __ _ ___| | _| |_ ___ | |__ ___ _ __ / _| ___ ___| |_
| |_| |/ _` |/ __| |/ / __/ _ \| '_ \ / _ \ '__| |_ / _ \/ __| __|
| _ | (_| | (__| <| || (_) | |_) | __/ | | _| __/\__ \ |_
|_| |_|\__,_|\___|_|\_\\__\___/|_.__/ \___|_| |_| \___||___/\__|
```
This repository is part of Hacktoberfest. Contributions are welcome! Feel free to suggest improvements, add translation, fix bugs, or propose new features. Thank you for contributing !


### Subjects
Expand Down
12 changes: 7 additions & 5 deletions addons/userrights/userrightsprofile.class.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,11 @@ protected function CheckIfProfileIsAllowed($iActionCode)
{
throw new SecurityException(Dict::Format('UI:Login:Error:AccessRestricted'));
}
if (!UserRights::IsActionAllowed(get_class($this), $iActionCode, DBObjectSet::FromObject($this)))

$oSet = new \ormLinkSet(get_class($oUser), 'profile_list', \DBObjectSet::FromScratch(\URP_UserProfile::class));
$oSet->AddItem(MetaModel::NewObject('URP_UserProfile', ['profileid' => $this->GetKey(), 'reason' => 'CheckIfProfileIsAllowed']));

if (!UserRights::IsActionAllowed(get_class($this), $iActionCode, $oSet))
{
throw new SecurityException(Dict::Format('UI:Error:ObjectCannotBeUpdated'));
}
Expand Down Expand Up @@ -495,10 +499,8 @@ public function CreateAdministrator($sAdminUser, $sAdminPwd, $sLanguage = 'EN US
$oAdminProfile = MetaModel::GetObjectFromOQL("SELECT URP_Profiles WHERE name = :name", array('name' => ADMIN_PROFILE_NAME), true /*all data*/);
if (is_object($oAdminProfile))
{
$oUserProfile = new URP_UserProfile();
$oUserProfile->Set('profileid', $oAdminProfile->GetKey());
$oUserProfile->Set('reason', 'By definition, the administrator must have the administrator profile');
$oSet = DBObjectSet::FromObject($oUserProfile);
$oSet = new \ormLinkSet(UserLocal::class, 'profile_list', \DBObjectSet::FromScratch(\URP_UserProfile::class));
$oSet->AddItem(MetaModel::NewObject('URP_UserProfile', ['profileid' => $oAdminProfile->GetKey(), 'reason' => 'CreateAdministrator']));
$oUser->Set('profile_list', $oSet);
}
$iUserId = $oUser->DBInsertNoReload();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -193,8 +193,7 @@

$sTicketListAttCode = 'tickets_list';

if (MetaModel::IsValidAttCode(get_class($this), $sTicketListAttCode))
{
if (MetaModel::HasChildrenClasses('Ticket') && MetaModel::IsValidAttCode(get_class($this), $sTicketListAttCode)) {
// Display one list per leaf class (the only way to display the status as of now)

$oAttDef = MetaModel::GetAttributeDef(get_class($this), $sTicketListAttCode);
Expand Down
7 changes: 3 additions & 4 deletions tests/php-unit-tests/src/BaseTestCase/ItopDataTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -616,10 +616,9 @@ protected function CreateContactlessUser($sLogin, $iProfileId, $sPassword=null)
$sPassword = $sLogin;
}

$oUserProfile = new URP_UserProfile();
$oUserProfile->Set('profileid', $iProfileId);
$oUserProfile->Set('reason', 'UNIT Tests');
$oSet = DBObjectSet::FromObject($oUserProfile);
$oSet = new \ormLinkSet(\UserLocal::class, 'profile_list', \DBObjectSet::FromScratch(\URP_UserProfile::class));
$oSet->AddItem(MetaModel::NewObject('URP_UserProfile', ['profileid' => $iProfileId, 'reason' => 'UNIT Tests']));

/** @var \UserLocal $oUser */
$oUser = $this->createObject('UserLocal', array(
'login' => $sLogin,
Expand Down
8 changes: 3 additions & 5 deletions tests/php-unit-tests/unitary-tests/core/UserRightsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
use DBObjectSearch;
use DBObjectSet;
use DeleteException;
use URP_UserProfile;
use MetaModel;
use UserRights;
use utils;

Expand Down Expand Up @@ -421,10 +421,8 @@ public function testDenyingUserModification()
$this->AddProfileToUser($oUser, 3);

// Keep only the profile 3 (remove profile 1)
$oUserProfile = new URP_UserProfile();
$oUserProfile->Set('profileid', 3);
$oUserProfile->Set('reason', 'UNIT Tests');
$oSet = DBObjectSet::FromObject($oUserProfile);
$oSet = new \ormLinkSet(\UserLocal::class, 'profile_list', \DBObjectSet::FromScratch(\URP_UserProfile::class));
$oSet->AddItem(MetaModel::NewObject('URP_UserProfile', ['profileid' => 3, 'reason' => 'UNIT Tests']));
$oUser->Set('profile_list', $oSet);

try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,8 @@ private function createAnotherUserInAnotherOrg() {

$sUid = $this->GetUid();

$oUserProfile = new \URP_UserProfile();
$oUserProfile->Set('profileid', $oProfile->GetKey());
$oUserProfile->Set('reason', 'UNIT Tests');
$oSet = \DBObjectSet::FromObject($oUserProfile);
$oSet = new \ormLinkSet(\UserLocal::class, 'profile_list', \DBObjectSet::FromScratch(\URP_UserProfile::class));
$oSet->AddItem(MetaModel::NewObject('URP_UserProfile', ['profileid' => $oProfile->GetKey(), 'reason' => 'UNIT Tests']));

$oPerson = $this->CreatePerson('666', $oOrg2->GetKey());
$oUser = $this->createObject('UserLocal', array(
Expand Down