Skip to content

Commit

Permalink
Some bugfixes.
Browse files Browse the repository at this point in the history
  • Loading branch information
ngodfraind committed Feb 26, 2016
1 parent 88829f8 commit 38995b0
Show file tree
Hide file tree
Showing 11 changed files with 63 additions and 86 deletions.
8 changes: 8 additions & 0 deletions Command/Dev/InitTestSchemaCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,18 @@ private function createSchema(OutputInterface $output)

foreach ($this->getContainer()->get('kernel')->getBundles() as $bundle) {
if ($bundle instanceof InstallableBundle && $bundle->hasMigrations()) {

if (count($migrator->getBundleStatus($bundle)[Migrator::STATUS_AVAILABLE]) > 1) {
$migrator->upgradeBundle($bundle, Migrator::VERSION_FARTHEST);
}

if ($bundle instanceof PluginBundle) {
$this->getContainer()->get('claroline.plugin.installer')->install($bundle);
} elseif ($bundle instanceof InstallableInterface) {
$this->getContainer()->get('claroline.installation.manager')->setLogger($consoleLogger);
$this->getContainer()->get('claroline.installation.manager')->install($bundle, true);
}

if ($fixturesDir = $bundle->getRequiredFixturesDirectory($this->environment)) {
$output->writeln('Loading required fixtures...');
$fixtureLoader->load($bundle, $fixturesDir);
Expand Down
17 changes: 9 additions & 8 deletions Entity/Organization/Organization.php
Original file line number Diff line number Diff line change
Expand Up @@ -133,11 +133,7 @@ class Organization
/**
* @var User[]|ArrayCollection
*
* @ORM\ManyToMany(
* targetEntity="Claroline\CoreBundle\Entity\User",
* inversedBy="administratedOrganizations"
* )
* @ORM\JoinTable(name="claro_user_administrator")
* @ORM\ManyToMany(targetEntity="Claroline\CoreBundle\Entity\User", mappedBy="administratedOrganizations")
* @Groups({"api_organization_tree", "api_organization_list"})
*/
protected $administrators;
Expand Down Expand Up @@ -244,17 +240,22 @@ public function getAdministrators()

public function addAdministrator(User $user)
{
if (!$this->administrators->contains($user)) $this->administrators->add($user);
if (!$this->administrators->contains($user)) {
$this->administrators->add($user);
$user->addAdministratedOrganization($this);
}
}

public function removeAdministrator(User $user)
{
if ($this->administrators->contains($user)) $this->administrators->removeElement($user);
if ($this->administrators->contains($user)) {
$this->administrators->removeElement($user);
$user->removeAdministratedOrganization($this);
}
}

public function setAdministrators(ArrayCollection $users)
{
var_dump('sett');
$this->administrators = $users;
}

Expand Down
18 changes: 12 additions & 6 deletions Entity/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -401,10 +401,7 @@ class User extends AbstractRoleSubject implements Serializable, AdvancedUserInte
protected $events;

/**
* @ORM\ManyToMany(
* targetEntity="Claroline\CoreBundle\Entity\Organization\Organization",
* mappedBy="administrators"
* )
* @ORM\ManyToMany(targetEntity="Claroline\CoreBundle\Entity\Organization\Organization", inversedBy="administrators")
* @ORM\JoinTable(name="claro_user_administrator")
* @Groups({"api_user"})
*/
Expand Down Expand Up @@ -1164,12 +1161,12 @@ public function getOrganizations($includeGroups = true)
}
}

return array_unique(array_merge($organizations, $this->organizations->toArray()));
return array_merge($organizations, $this->organizations->toArray());
}

public function addOrganization(Organization $organization)
{
$this->organizations->add($organization);
if (!$this->organizations->contains($organization)) $this->organizations->add($organization);
}

//sometimes it's passed as an array and I don't understand why.
Expand Down Expand Up @@ -1204,4 +1201,13 @@ public function addAdministratedOrganization(Organization $organization)
$this->administratedOrganizations->add($organization);
}

public function removeAdministratedOrganization(Organization $organization)
{
$this->administratedOrganizations->remove($organization);
}

public function setAdministratedOrganizations($organizations)
{
$this->administratedOrganizations = $organizations;
}
}
4 changes: 2 additions & 2 deletions Manager/GroupManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -466,8 +466,8 @@ public function searchPartialList($searches, $page, $limit, $count = false)
if (!$this->container->get('security.authorization_checker')->isGranted('ROLE_ADMIN')) {

$currentUser = $this->container->get('security.token_storage')->getToken()->getUser();
$qb->leftJoin('g.organizations', 'go');
$qb->leftJoin('go.administrators', 'ga');
$qb->join('g.organizations', 'go');
$qb->join('go.administrators', 'ga');
$qb->andWhere('ga.id = :userId');
$qb->setParameter('userId', $currentUser->getId());
}
Expand Down
10 changes: 8 additions & 2 deletions Manager/Organization/OrganizationManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,14 @@ public function create(Organization $organization)

public function edit(Organization $organization)
{
//var_dump(count($organization->getAdministrators()));
//var_dump(count($organization->getLocations()));
//if I inverse the mappedBy and inversedBy doctrine mapping, I don't need to do this.
//but it it's done, the search request will break.
//no idea why
foreach ($organization->getAdministrators() as $administrator) {
$administrator->addOrganization($organization);
$this->om->persist($administrator);
}

$this->om->persist($organization);
$this->om->flush();

Expand Down
2 changes: 1 addition & 1 deletion Manager/UserManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -1198,7 +1198,7 @@ public function updateImportedUsers(array $users, $additionalRoles = array())
$existingUser->setFirstName($firstName);
$existingUser->setLastName($lastName);
$existingUser->setUsername($username);
$existingUser->setPlainPassword($pwd);
if ($pwd != '') $existingUser->setPlainPassword($pwd);
$existingUser->setMail($email);
$existingUser->setAdministrativeCode($code);
$existingUser->setPhone($phone);
Expand Down
27 changes: 0 additions & 27 deletions Resources/rootDir/make.js

This file was deleted.

21 changes: 0 additions & 21 deletions Resources/rootDir/package.json

This file was deleted.

14 changes: 10 additions & 4 deletions Resources/views/Workspace/layout.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,16 @@

{% block title %}
{% spaceless %}
{{ workspace.getName() }}
{% if _resource is defined %}
{{ _resource.getResourceNode().getName() | striptags | raw }}
{% endif %}
{% if workspace is defined %}
{{ workspace.getName() }}
{% else %}
{% if _resource is defined %}
{% if _resource.getWorkspace() %}
{{ _resource.getWorkspace.getName() }} -
{% endif %}
{{ _resource.getResourceNode().getName() | striptags | raw }}
{% endif %}
{% endif %}
{% endspaceless %}
{% endblock %}

Expand Down
13 changes: 9 additions & 4 deletions Tests/API/User/GroupControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,19 +35,24 @@ protected function setUp()
{
parent::setUp();
$this->persister = $this->client->getContainer()->get('claroline.library.testing.persister');
//users
$this->john = $this->persister->user('john');
$roleAdmin = $this->persister->role('ROLE_ADMIN');
$this->teacherRole = $this->persister->role('ROLE_TEACHER');
$this->baseRole = $this->persister->role('ROLE_BASE');
$this->admin = $this->persister->user('admin');
$this->admin->addRole($roleAdmin);

//organization
$organization = $this->persister->organization('organization');
$this->adminOrga = $this->persister->user('adminOrga');
$this->groupOrga = $this->persister->group('groupOrga');
$this->groupOrga->addRole($this->baseRole);
$this->groupBase = $this->persister->group('groupBase');
$this->groupOrga->addOrganization($organization);
$this->adminOrga->addAdministratedOrganization($organization);

//persist
$this->persister->persist($this->groupOrga);
$this->persister->persist($this->adminOrga);
$this->persister->persist($this->admin);
Expand Down Expand Up @@ -99,15 +104,15 @@ public function testGetGroupActionIsProtected()
//@method: POST
public function testPostGroupAction()
{
$this->markTestIncomplete('This test has not been implemented yet.');
$this->markTestSkipped('This test has not been implemented yet.');
}

//@route: api_post_group
//@url: /api/groups.{_format}
//@method: POST
public function testPostGroupActionIsProtected()
{
$this->markTestIncomplete('This test has not been implemented yet.');
$this->markTestSkipped('This test has not been implemented yet.');
}


Expand All @@ -116,15 +121,15 @@ public function testPostGroupActionIsProtected()
//@method: PUT
public function testPutGroupAction()
{
$this->markTestIncomplete('This test has not been implemented yet.');
$this->markTestSkipped('This test has not been implemented yet.');
}

//@route: api_put_group
//@url: /api/groups/{group}.{_format}
//@method: PUT
public function testPutGroupActionIsProtected()
{
$this->markTestIncomplete('This test has not been implemented yet.');
$this->markTestSkipped('This test has not been implemented yet.');
}

//@route: api_delete_group
Expand Down
15 changes: 4 additions & 11 deletions Tests/API/User/UserControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,6 @@ protected function setUp()
$this->persister->flush();
}

private function initGroup()
{
$this->group = $this->persister->group('group');
//Do more stuff here. Yolo.
}

//@url: /api/users.{_format}
//@route: api_get_users
public function testGetUsersAction()
Expand All @@ -81,7 +75,6 @@ public function testGetUsersActionIsSecured()
$this->assertEquals(403, $this->client->getResponse()->getStatusCode());
}


//@url: /api/searches/{page}/users/{limit}.{_format}
//@route: api_get_search_users
public function testGetSearchUsersAction()
Expand Down Expand Up @@ -343,30 +336,30 @@ public function testRemoveUserRoleActionIsProtected()
//@url: /api/users/{user}/groups/{group}/add.{_format}
public function testAddUserGroupAction()
{
$this->markTestIncomplete('This test has not been implemented yet.');
$this->markTestSkipped('This test has not been implemented yet.');
}


//@route: api_add_user_group
//@url: /api/users/{user}/groups/{group}/add.{_format}
public function testAddUserGroupActionIsProtected()
{
$this->markTestIncomplete('This test has not been implemented yet.');
$this->markTestSkipped('This test has not been implemented yet.');
}


//@route: api_remove_user_group
//@url: /api/users/{user}/groups/{group}/remove.{_format}
public function testRemoveUserGroupAction()
{
$this->markTestIncomplete('This test has not been implemented yet.');
$this->markTestSkipped('This test has not been implemented yet.');
}

//@route: api_remove_user_group
//@url: /api/users/{user}/groups/{group}/remove.{_format}
public function testRemoveUserGroupActionIsProtected()
{
$this->markTestIncomplete('This test has not been implemented yet.');
$this->markTestSkipped('This test has not been implemented yet.');
}


Expand Down

0 comments on commit 38995b0

Please sign in to comment.