Merge pull request #1273 from dnos/chamilo-pr/1.11.x
	
		
	
				
					
				
			New feature to let choose which users can see or not which courses in the cataloguepull/2487/head
						commit
						7c9d14b81b
					
				@ -0,0 +1,42 @@ | 
				
			||||
<?php | 
				
			||||
/* For licensing terms, see /license.txt */ | 
				
			||||
 | 
				
			||||
namespace Application\Migrations\Schema\V111; | 
				
			||||
 | 
				
			||||
use Application\Migrations\AbstractMigrationChamilo; | 
				
			||||
use Doctrine\DBAL\Schema\Schema; | 
				
			||||
use Doctrine\DBAL\Types\Type; | 
				
			||||
 | 
				
			||||
/** | 
				
			||||
 * Class Version20160706182000 | 
				
			||||
 * Add new table to save user visibility on courses in the catalogue | 
				
			||||
 * @package Application\Migrations\Schema\V111 | 
				
			||||
 */ | 
				
			||||
class Version20160706182000 extends AbstractMigrationChamilo | 
				
			||||
{ | 
				
			||||
    /** | 
				
			||||
     * @param Schema $schema | 
				
			||||
     * | 
				
			||||
     * @throws \Doctrine\DBAL\DBALException | 
				
			||||
     * @throws \Doctrine\DBAL\Schema\SchemaException | 
				
			||||
     */ | 
				
			||||
    public function up(Schema $schema) | 
				
			||||
    { | 
				
			||||
         $this->addSql( | 
				
			||||
             'CREATE TABLE course_rel_user_catalogue (id int NOT NULL AUTO_INCREMENT, user_id int DEFAULT NULL, c_id int DEFAULT NULL, visible int NOT NULL, PRIMARY KEY (id), KEY (user_id), KEY (c_id), CONSTRAINT FOREIGN KEY (c_id) REFERENCES course (id) ON DELETE CASCADE, CONSTRAINT FOREIGN KEY (user_id) REFERENCES user (id) ON DELETE CASCADE) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci' | 
				
			||||
             ); | 
				
			||||
    } | 
				
			||||
 | 
				
			||||
     /** | 
				
			||||
      * @param Schema $schema | 
				
			||||
      * | 
				
			||||
      * @throws \Doctrine\DBAL\DBALException | 
				
			||||
      * @throws \Doctrine\DBAL\Schema\SchemaException | 
				
			||||
      */ | 
				
			||||
    public function down(Schema $schema) | 
				
			||||
    { | 
				
			||||
        $this->addSql( | 
				
			||||
         'DROP TABLE course_rel_user_catalogue' | 
				
			||||
         ); | 
				
			||||
    } | 
				
			||||
} | 
				
			||||
@ -0,0 +1,171 @@ | 
				
			||||
<?php | 
				
			||||
/* For licensing terms, see /license.txt */ | 
				
			||||
 | 
				
			||||
namespace Chamilo\CoreBundle\Entity; | 
				
			||||
 | 
				
			||||
use Chamilo\UserBundle\Entity\User; | 
				
			||||
use Doctrine\ORM\Mapping as ORM; | 
				
			||||
 | 
				
			||||
/** | 
				
			||||
 * CourseRelUserCatalogue | 
				
			||||
 * | 
				
			||||
 * @ORM\Table( | 
				
			||||
 *      name="course_rel_user_catalogue", | 
				
			||||
 *      indexes={ | 
				
			||||
 *          @ORM\Index(name="course_rel_user_catalogue_user_id", columns={"user_id"}), | 
				
			||||
 *          @ORM\Index(name="course_rel_user_catalogue_c_id", columns={"c_id"}) | 
				
			||||
 *      } | 
				
			||||
 * ) | 
				
			||||
 * @ORM\Entity | 
				
			||||
 * @ORM\Table(name="course_rel_user_catalogue") | 
				
			||||
 */ | 
				
			||||
class CourseRelUserCatalogue | 
				
			||||
{ | 
				
			||||
    /** | 
				
			||||
     * @var integer | 
				
			||||
     * | 
				
			||||
     * @ORM\Column(name="id", type="integer", precision=0, scale=0, nullable=false, unique=false) | 
				
			||||
     * @ORM\Id | 
				
			||||
     * @ORM\GeneratedValue | 
				
			||||
     */ | 
				
			||||
    private $id; | 
				
			||||
 | 
				
			||||
    /** | 
				
			||||
     * @var boolean | 
				
			||||
     * | 
				
			||||
     * @ORM\Column(name="visible", type="integer", precision=0, scale=0, nullable=false, unique=false) | 
				
			||||
     */ | 
				
			||||
    private $visible; | 
				
			||||
 | 
				
			||||
    /** | 
				
			||||
     * @ORM\ManyToOne(targetEntity="Chamilo\UserBundle\Entity\User", inversedBy="courses", cascade={"persist"}) | 
				
			||||
     * @ORM\JoinColumn(name="user_id", referencedColumnName="id") | 
				
			||||
     */ | 
				
			||||
    protected $user; | 
				
			||||
 | 
				
			||||
    /** | 
				
			||||
     * @ORM\ManyToOne(targetEntity="Chamilo\CoreBundle\Entity\Course", inversedBy="users", cascade={"persist"}) | 
				
			||||
     * @ORM\JoinColumn(name="c_id", referencedColumnName="id") | 
				
			||||
     */ | 
				
			||||
    protected $course; | 
				
			||||
 | 
				
			||||
    /** | 
				
			||||
     * Constructor | 
				
			||||
     */ | 
				
			||||
    public function __construct() | 
				
			||||
    { | 
				
			||||
    } | 
				
			||||
 | 
				
			||||
    /** | 
				
			||||
     * @return string | 
				
			||||
     */ | 
				
			||||
    public function __toString() | 
				
			||||
    { | 
				
			||||
        return strval($this->getCourse()->getCode()); | 
				
			||||
    } | 
				
			||||
 | 
				
			||||
    /** | 
				
			||||
     * @return int | 
				
			||||
     */ | 
				
			||||
    public function getId() | 
				
			||||
    { | 
				
			||||
        return $this->id; | 
				
			||||
    } | 
				
			||||
 | 
				
			||||
    /** | 
				
			||||
     * @param int $id | 
				
			||||
     */ | 
				
			||||
    public function setId($id) | 
				
			||||
    { | 
				
			||||
        $this->id = $id; | 
				
			||||
    } | 
				
			||||
 | 
				
			||||
    /** | 
				
			||||
     * @param Course $course | 
				
			||||
     * @return $this | 
				
			||||
     */ | 
				
			||||
    public function setCourse(Course $course) | 
				
			||||
    { | 
				
			||||
        $this->course = $course; | 
				
			||||
 | 
				
			||||
        return $this; | 
				
			||||
    } | 
				
			||||
 | 
				
			||||
    /** | 
				
			||||
     * Get Course | 
				
			||||
     * | 
				
			||||
     * @return Course | 
				
			||||
     */ | 
				
			||||
    public function getCourse() | 
				
			||||
    { | 
				
			||||
        return $this->course; | 
				
			||||
    } | 
				
			||||
 | 
				
			||||
    /** | 
				
			||||
     * @param $user | 
				
			||||
     * @return $this | 
				
			||||
     */ | 
				
			||||
    public function setUser($user) | 
				
			||||
    { | 
				
			||||
        $this->user = $user; | 
				
			||||
 | 
				
			||||
        return $this; | 
				
			||||
    } | 
				
			||||
 | 
				
			||||
    /** | 
				
			||||
     * Get User | 
				
			||||
     * | 
				
			||||
     * @return User | 
				
			||||
     */ | 
				
			||||
    public function getUser() | 
				
			||||
    { | 
				
			||||
        return $this->user; | 
				
			||||
    } | 
				
			||||
 | 
				
			||||
    /** | 
				
			||||
     * Set relationType | 
				
			||||
     * | 
				
			||||
     * @param integer $relationType | 
				
			||||
     * @return CourseRelUserCatalogue | 
				
			||||
     */ | 
				
			||||
    public function setRelationType($relationType) | 
				
			||||
    { | 
				
			||||
        $this->relationType = $relationType; | 
				
			||||
 | 
				
			||||
        return $this; | 
				
			||||
    } | 
				
			||||
 | 
				
			||||
    /** | 
				
			||||
     * Get relationType | 
				
			||||
     * | 
				
			||||
     * @return integer | 
				
			||||
     */ | 
				
			||||
    public function getRelationType() | 
				
			||||
    { | 
				
			||||
        return $this->relationType; | 
				
			||||
    } | 
				
			||||
 | 
				
			||||
    /** | 
				
			||||
     * Set visible | 
				
			||||
     * | 
				
			||||
     * @param boolean $visible | 
				
			||||
     * @return CourseRelUserCatalogue | 
				
			||||
     */ | 
				
			||||
    public function setVisible($visible) | 
				
			||||
    { | 
				
			||||
        $this->visible = $visible; | 
				
			||||
 | 
				
			||||
        return $this; | 
				
			||||
    } | 
				
			||||
 | 
				
			||||
    /** | 
				
			||||
     * Get visible | 
				
			||||
     * | 
				
			||||
     * @return boolean | 
				
			||||
     */ | 
				
			||||
    public function getVisible() | 
				
			||||
    { | 
				
			||||
        return $this->visible; | 
				
			||||
    } | 
				
			||||
 | 
				
			||||
} | 
				
			||||
					Loading…
					
					
				
		Reference in new issue