Skip to content
Snippets Groups Projects
Commit acafbea6 authored by efalcy's avatar efalcy
Browse files

Groupes de formation : ajout de la notion de categorie de groupe

parent bab29383
Branches
Tags
No related merge requests found
......@@ -2200,6 +2200,7 @@ cosmogramme/sql/patch/patch_171.sql -text
cosmogramme/sql/patch/patch_172.sql -text
cosmogramme/sql/patch/patch_173.sql -text
cosmogramme/sql/patch/patch_174.sql -text
cosmogramme/sql/patch/patch_175.sql -text
cosmogramme/storm_init.php -text
cosmogramme/tests/bootstrap.php -text
cosmogramme/tests/php/classes/AbonneIntegrationTest.php -text
......@@ -2484,6 +2485,7 @@ library/Class/UploadMover/Abstract.php -text
library/Class/UploadMover/HttpPost.php -text
library/Class/UploadMover/LocalFile.php -text
library/Class/UserGroup.php -text
library/Class/UserGroupCategorie.php -text
library/Class/UserGroupMembership.php -text
library/Class/Users.php -text
library/Class/Video.php -text
......@@ -6084,6 +6086,7 @@ tests/library/Class/TimeSourceForTest.php -text
tests/library/Class/ToutApprendreLinkTest.php -text
tests/library/Class/TypeDocTest.php -text
tests/library/Class/UploadTest.php -text
tests/library/Class/UserGroupCategorieTest.php -text
tests/library/Class/UserGroupTest.php -text
tests/library/Class/UsersTest.php -text
tests/library/Class/VodeclicLinkTest.php -text
......
<?PHP
// Constantes
define("VERSION_COSMOGRAMME","6.38");
define("PATCH_LEVEL","174");
define("PATCH_LEVEL","175");
define("APPLI","cosmogramme");
define("COSMOPATH", "/var/www/html/vhosts/opac2/www/htdocs");
define("CRLF", chr(13) . chr(10));
......
CREATE TABLE IF NOT EXISTS `user_group_categorie` (
`id` int( 11 ) NOT NULL AUTO_INCREMENT ,
`parent_id` int( 11 ) NOT NULL default '0',
`libelle` varchar( 100 ) default NULL ,
PRIMARY KEY ( `id` )
) ENGINE = MYISAM DEFAULT CHARSET = utf8;
alter table user_groups add column id_cat int(11) not null;
......@@ -26,7 +26,8 @@ class Class_UserGroup extends Storm_Model_Abstract {
'dependent' => 'delete' ],
'users' => [ 'through' => 'user_group_memberships',
'unique' => true ] ];
protected $_belongs_to = ['categorie' => ['model' => 'Class_UserGroupCategorie',
'referenced_in' => 'ID_CAT']];
// Les droits doivent être une puissance de 2 (ce sont des masques)
const RIGHT_SUIVRE_FORMATION = 1;
const RIGHT_DIRIGER_FORMATION = 2;
......
<?php
/**
* Copyright (c) 2012, Agence Française Informatique (AFI). All rights reserved.
*
* AFI-OPAC 2.0 is free software; you can redistribute it and/or modify
* it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE as published by
* the Free Software Foundation.
*
* There are special exceptions to the terms and conditions of the AGPL as it
* is applied to this software (see README file).
*
* AFI-OPAC 2.0 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU AFFERO GENERAL PUBLIC LICENSE for more details.
*
* You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE
* along with AFI-OPAC 2.0; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
class Class_UserGroupCategorie extends Storm_Model_Abstract {
protected $_table_name = 'user_group_categorie';
protected $_has_many = [ 'user_group' => [ 'model' => 'Class_UserGroup',
'role' => 'categorie',
'dependent' => 'delete' ],
'sous_categories' => ['model' => 'Class_UserGroupCategorie',
'role' => 'parent',
'dependents' => 'delete'],
];
protected $_belongs_to = ['parent_categorie' => ['model' => 'Class_UserGroupCategorie',
'referenced_in' => 'parent_id']];
public static function getLoader() {
return self::getLoaderFor(__CLASS__);
}
}
\ No newline at end of file
<?php
/**
* Copyright (c) 2012, Agence Française Informatique (AFI). All rights reserved.
*
* AFI-OPAC 2.0 is free software; you can redistribute it and/or modify
* it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE as published by
* the Free Software Foundation.
*
* There are special exceptions to the terms and conditions of the AGPL as it
* is applied to this software (see README file).
*
* AFI-OPAC 2.0 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU AFFERO GENERAL PUBLIC LICENSE for more details.
*
* You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE
* along with AFI-OPAC 2.0; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
class UserGroupCategorieWithNoGroupTest extends Storm_Test_ModelTestCase {
protected $_association;
protected $_etablissement;
public function setup() {
parent::setup();
$this->_etablissement = Class_UserGroupCategorie::newInstanceWithId(1,['libelle'=>'Etablissement']);
$this->_association =
Class_UserGroupCategorie::newInstanceWithId(2,['libelle'=>'Association',
'parent_categorie' => $this->_etablissement]);
$this->_etablissement->setSousCategories([$this->_association]);
}
/** @test **/
public function associationShouldNotHaveUserGroup() {
$this->assertEmpty($this->_association->getUserGroup());
}
/** @test **/
public function associationShouldHaveParentCategorieEtablissement() {
$this->assertEquals($this->_association->getParentCategorie(), $this->_etablissement);
}
/** @test **/
public function etablissementShouldHaveSousCategorieAssociation() {
$this->assertEquals([$this->_association], $this->_etablissement->getSousCategories());
}
/** @test **/
public function associationShouldNotHaveSousCategorie() {
$this->assertEmpty($this->_association->getSousCategories());
}
}
?>
\ No newline at end of file
......@@ -215,4 +215,21 @@ class UserGroupWithNoUsersTest extends UserGroupTestCase {
}
class UserGroupWithCategorieUserGroupTest extends UserGroupTestCase {
protected $_zork_group;
public function setUp() {
parent::setUp();
$this->_categorie = Class_UserGroupCategorie::newInstanceWithId(10, ['libelle' => 'Association']);
$this->_zork_group = Class_UserGroup::newInstanceWithId(999999, ['categorie' => $this->_categorie]);
}
/** @test */
public function zorkGroupShouldBelongsToCategorieAssociation() {
$this->assertEquals('Association' , $this->_zork_group->getCategorie()->getLibelle());
}
}
?>
\ No newline at end of file
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment