Add entities.

1.10.x
Julio Montoya 10 years ago
parent 153d7c8e9f
commit ba95269ead
  1. 2
      src/Chamilo/CoreBundle/Entity/AccessUrl.php
  2. 92
      src/Chamilo/CoreBundle/Entity/AccessUrlRelCourse.php
  3. 4
      src/Chamilo/CoreBundle/Entity/Course.php
  4. 45
      src/Chamilo/CoreBundle/Entity/Listener/CourseListener.php
  5. 104
      src/Chamilo/CoreBundle/Entity/Repository/CourseRepository.php
  6. 160
      src/Chamilo/CoreBundle/Entity/Usergroup.php
  7. 585
      src/Chamilo/CourseBundle/Entity/CGroupInfo.php
  8. 612
      src/Chamilo/CourseBundle/Entity/CTool.php
  9. 5
      src/Chamilo/UserBundle/Entity/Repository/UserRepository.php
  10. 11
      src/Chamilo/UserBundle/Entity/User.php

@ -72,7 +72,7 @@ class AccessUrl
/**
* @ORM\OneToMany(targetEntity="Chamilo\CoreBundle\Entity\SettingsCurrent", mappedBy="url", cascade={"persist"}, orphanRemoval=true)
**/
protected $settings;
//protected $settings;
/**
* @ORM\OneToMany(targetEntity="Chamilo\CoreBundle\Entity\SessionCategory", mappedBy="url", cascade={"persist"}, orphanRemoval=true)

@ -0,0 +1,92 @@
<?php
/* For licensing terms, see /license.txt */
namespace Chamilo\CoreBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
/**
* AccessUrlRelCourse
*
* @ORM\Table(name="access_url_rel_course")
* @ORM\Entity
*/
class AccessUrlRelCourse
{
/**
* @var integer
*
* @ORM\Column(name="id", type="integer", precision=0, scale=0, nullable=false, unique=false)
* @ORM\Id
* @ORM\GeneratedValue(strategy="AUTO")
*/
private $id;
/**
* @ORM\ManyToOne(targetEntity="Course", inversedBy="urls", cascade={"persist"})
* @ORM\JoinColumn(name="c_id", referencedColumnName="id")
*/
protected $course;
/**
* @ORM\ManyToOne(targetEntity="AccessUrl", inversedBy="course", cascade={"persist"})
* @ORM\JoinColumn(name="access_url_id", referencedColumnName="id")
*/
protected $url;
/**
* @return string
*/
public function __toString()
{
return strval('-');
}
/**
* Get id
*
* @return integer
*/
public function getId()
{
return $this->id;
}
/**
* Set url
*
* @param $url
* @return AccessUrlRelCourse
*/
public function setUrl($url)
{
$this->url = $url;
return $this;
}
/**
* @return mixed
*/
public function getUrl()
{
return $this->url;
}
/**
* @param $course
*/
public function setCourse($course)
{
$this->course = $course;
}
/**
* @return mixed
*/
public function getCourse()
{
return $this->course;
}
}

@ -3,7 +3,7 @@
namespace Chamilo\CoreBundle\Entity;
use Chamilo\CourseBundle\Entity\CTool;
//use Chamilo\CourseBundle\Entity\CTool;
use Doctrine\Common\Collections\Criteria;
use Doctrine\ORM\Mapping as ORM;
use Doctrine\Common\Collections\ArrayCollection;
@ -11,7 +11,7 @@ use Gedmo\Mapping\Annotation as Gedmo;
use Symfony\Component\Validator\Constraints as Assert;
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
use Chamilo\UserBundle\Entity\User;
// @ORM\EntityListeners({"Chamilo\CoreBundle\Entity\Listener\CourseListener"})
/**
* Class Course
*

@ -0,0 +1,45 @@
<?php
/* For licensing terms, see /license.txt */
namespace Chamilo\CoreBundle\Entity\Listener;
use Chamilo\CoreBundle\Entity\Tool;
use Chamilo\CourseBundle\ToolChain;
use Doctrine\ORM\Event\LifecycleEventArgs;
use Chamilo\CoreBundle\Entity\Course;
use Doctrine\ORM\Mapping as ORM;
/**
* Class CourseListener
* Course entity listener, when a course is created the tool chain is loaded.
* @package Chamilo\CoreBundle\EventListener
*/
class CourseListener
{
protected $toolChain;
/**
* @param ToolChain $toolChain
*/
public function __construct(ToolChain $toolChain)
{
$this->toolChain = $toolChain;
}
/**
* new object : prePersist
* edited object: preUpdate
* @param Course $course
* @param LifecycleEventArgs $args
*/
public function prePersist(Course $course, LifecycleEventArgs $args)
{
//$this->toolChain->addToolsInCourse($course);
/*
error_log('ddd');
$course->setDescription( ' dq sdqs dqs dqs ');
$args->getEntityManager()->persist($course);
$args->getEntityManager()->flush();*/
}
}

@ -0,0 +1,104 @@
<?php
/* For licensing terms, see /license.txt */
namespace Chamilo\CoreBundle\Entity\Repository;
use Chamilo\CoreBundle\Entity\Course;
use Chamilo\UserBundle\Entity\User;
use Doctrine\ORM\EntityRepository;
use Doctrine\ORM\QueryBuilder;
/**
* Class CourseRepository
* The functions inside this class must return an instance of QueryBuilder
* @package Chamilo\CoreBundle\Entity\Repository
*/
class CourseRepository extends EntityRepository
{
/**
* Get all users that are registered in the course. No matter the status
*
* @param Course $course
*
* @return \Doctrine\ORM\QueryBuilder
*/
public function getSubscribedUsers(Course $course)
{
$queryBuilder = $this->createQueryBuilder('a');
// Selecting user info.
$queryBuilder->select('DISTINCT u');
// Loading EntityUser.
$queryBuilder->from('Chamilo\UserBundle\Entity\User', 'u');
// Selecting courses for users.
$queryBuilder->innerJoin('u.courses', 'c');
//@todo check app settings
$queryBuilder->add('orderBy', 'u.lastname ASC');
$wherePart = $queryBuilder->expr()->andx();
// Get only users subscribed to this course
$wherePart->add($queryBuilder->expr()->eq('c.cId', $course->getId()));
// $wherePart->add($queryBuilder->expr()->eq('c.status', $status));
$queryBuilder->where($wherePart);
//$q = $queryBuilder->getQuery();
//return $q->execute();
return $queryBuilder;
}
/**
* Gets students subscribed in the course
*
* @param Course $course
*
* @return QueryBuilder
*/
public function getSubscribedStudents(Course $course)
{
return self::getSubscribedUsersByStatus($course, STUDENT);
}
/**
* Gets the students subscribed in the course
* @param Course $course
*
* @return QueryBuilder
*/
public function getSubscribedCoaches(Course $course)
{
$queryBuilder = $this->getSubscribedUsers($course);
//@todo add criterias
return $queryBuilder;
}
/**
*
* Gets the teachers subscribed in the course
* @param Course $course
*
* @return QueryBuilder
*/
public function getSubscribedTeachers(Course $course)
{
return self::getSubscribedUsersByStatus($course, COURSEMANAGER);
}
/**
* @param Course $course
* @param int $status use legacy chamilo constants COURSEMANAGER|STUDENT
* @return QueryBuilder
*/
public function getSubscribedUsersByStatus(Course $course, $status)
{
$queryBuilder = $this->getSubscribedUsers($course);
$wherePart = $queryBuilder->expr()->andx();
$wherePart->add($queryBuilder->expr()->eq('c.status', $status));
return $queryBuilder;
}
}

@ -0,0 +1,160 @@
<?php
/* For licensing terms, see /license.txt */
namespace Chamilo\CoreBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
use Doctrine\Common\Collections\ArrayCollection;
/**
* Usergroup
*
* @ORM\Table(name="usergroup")
* @ORM\Entity
*/
class Usergroup
{
/**
* @var integer
*
* @ORM\Column(name="id", type="integer", precision=0, scale=0, nullable=false, unique=false)
* @ORM\Id
* @ORM\GeneratedValue(strategy="AUTO")
*/
protected $id;
/**
* @var string
*
* @ORM\Column(name="name", type="string", length=255, precision=0, scale=0, nullable=false, unique=false)
*/
protected $name;
/**
* @var string
*
* @ORM\Column(name="description", type="text", precision=0, scale=0, nullable=false, unique=false)
*/
protected $description;
/**
* @ORM\OneToMany(targetEntity="UsergroupRelUser", mappedBy="usergroup", cascade={"persist"}, orphanRemoval=true)
**/
protected $users;
/**
*
*/
public function __construct()
{
//$this->users = new ArrayCollection();
}
/**
* @return string
*/
public function __toString()
{
return (string) $this->getName();
}
/**
* @return ArrayCollection
*/
public function getUsers()
{
return $this->users;
}
/**
* @param $users
*/
public function setUsers($users)
{
$this->users = new ArrayCollection();
foreach ($users as $user) {
$this->addUsers($user);
}
}
/**
* @param UsergroupRelUser $user
*/
public function addUsers(UsergroupRelUser $user)
{
$user->setUsergroup($this);
$this->users[] = $user;
}
/**
* Remove $user
*
* @param UsergroupRelUser $user
*/
public function removeUsers(UsergroupRelUser $user)
{
foreach ($this->users as $key => $value) {
if ($value->getId() == $user->getId()) {
unset($this->users[$key]);
}
}
}
/**
* Get id
*
* @return integer
*/
public function getId()
{
return $this->id;
}
/**
* Set name
*
* @param string $name
* @return Usergroup
*/
public function setName($name)
{
$this->name = $name;
return $this;
}
/**
* Get name
*
* @return string
*/
public function getName()
{
return $this->name;
}
/**
* Set description
*
* @param string $description
* @return Usergroup
*/
public function setDescription($description)
{
$this->description = $description;
return $this;
}
/**
* Get description
*
* @return string
*/
public function getDescription()
{
return $this->description;
}
}

@ -0,0 +1,585 @@
<?php
namespace Chamilo\CourseBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
use Doctrine\Common\Collections\ArrayCollection;
/**
* CGroupInfo
*
* @ORM\Table(name="c_group_info")
* @ORM\Entity
*/
class CGroupInfo
{
/**
* @var integer
*
* @ORM\Column(name="iid", type="integer", precision=0, scale=0, nullable=false, unique=false)
* @ORM\Id
* @ORM\GeneratedValue(strategy="AUTO")
*/
private $iid;
/**
* @var integer
*
* @ORM\Column(name="c_id", type="integer", precision=0, scale=0, nullable=false, unique=false)
*/
private $cId;
/**
* @var integer
*
* @ORM\Column(name="id", type="integer", precision=0, scale=0, unique=false)
*/
private $id;
/**
* @var string
*
* @ORM\Column(name="name", type="string", length=100, precision=0, scale=0, nullable=true, unique=false)
*/
private $name;
/**
* @var integer
*
* @ORM\Column(name="category_id", type="integer", precision=0, scale=0, nullable=false, unique=false)
*/
private $categoryId;
/**
* @var string
*
* @ORM\Column(name="description", type="text", precision=0, scale=0, nullable=true, unique=false)
*/
private $description;
/**
* @var integer
*
* @ORM\Column(name="max_student", type="integer", precision=0, scale=0, nullable=false, unique=false)
*/
private $maxStudent;
/**
* @var boolean
*
* @ORM\Column(name="doc_state", type="boolean", precision=0, scale=0, nullable=false, unique=false)
*/
private $docState;
/**
* @var boolean
*
* @ORM\Column(name="calendar_state", type="boolean", precision=0, scale=0, nullable=false, unique=false)
*/
private $calendarState;
/**
* @var boolean
*
* @ORM\Column(name="work_state", type="boolean", precision=0, scale=0, nullable=false, unique=false)
*/
private $workState;
/**
* @var boolean
*
* @ORM\Column(name="announcements_state", type="boolean", precision=0, scale=0, nullable=false, unique=false)
*/
private $announcementsState;
/**
* @var boolean
*
* @ORM\Column(name="forum_state", type="boolean", precision=0, scale=0, nullable=false, unique=false)
*/
private $forumState;
/**
* @var boolean
*
* @ORM\Column(name="wiki_state", type="boolean", precision=0, scale=0, nullable=false, unique=false)
*/
private $wikiState;
/**
* @var boolean
*
* @ORM\Column(name="chat_state", type="boolean", precision=0, scale=0, nullable=false, unique=false)
*/
private $chatState;
/**
* @var string
*
* @ORM\Column(name="secret_directory", type="string", length=255, precision=0, scale=0, nullable=true, unique=false)
*/
private $secretDirectory;
/**
* @var boolean
*
* @ORM\Column(name="self_registration_allowed", type="boolean", precision=0, scale=0, nullable=false, unique=false)
*/
private $selfRegistrationAllowed;
/**
* @var boolean
*
* @ORM\Column(name="self_unregistration_allowed", type="boolean", precision=0, scale=0, nullable=false, unique=false)
*/
private $selfUnregistrationAllowed;
/**
* @var integer
*
* @ORM\Column(name="session_id", type="integer", precision=0, scale=0, nullable=false, unique=false)
*/
private $sessionId;
/**
* @ORM\OneToMany(targetEntity="CItemProperty", mappedBy="group")
**/
//private $items;
/**
* @ORM\OneToMany(targetEntity="Chamilo\CoreBundle\Entity\CourseRelUser", mappedBy="group")
**/
protected $course;
/**
*
*/
public function __construct()
{
$this->items = new ArrayCollection();
}
/**
*
* @return ArrayCollection
*/
public function getItems()
{
return $this->items;
}
/**
* Set cId
*
* @param integer $cId
*
* @return CGroupInfo
*/
public function setCId($cId)
{
$this->cId = $cId;
return $this;
}
/**
* Get cId
*
* @return integer
*/
public function getCId()
{
return $this->cId;
}
/**
* Set iid
*
* @param integer $id
* @return CGroupInfo
*/
public function setIid($iid)
{
$this->iid = $iid;
return $this;
}
/**
* Get id
*
* @return integer
*/
public function getIid()
{
return $this->iid;
}
/**
* Set id
*
* @param integer $id
* @return CGroupInfo
*/
public function setId($id)
{
$this->id = $id;
return $this;
}
/**
* Get id
*
* @return integer
*/
public function getId()
{
return $this->id;
}
/**
* Set name
*
* @param string $name
* @return CGroupInfo
*/
public function setName($name)
{
$this->name = $name;
return $this;
}
/**
* Get name
*
* @return string
*/
public function getName()
{
return $this->name;
}
/**
* Set categoryId
*
* @param integer $categoryId
* @return CGroupInfo
*/
public function setCategoryId($categoryId)
{
$this->categoryId = $categoryId;
return $this;
}
/**
* Get categoryId
*
* @return integer
*/
public function getCategoryId()
{
return $this->categoryId;
}
/**
* Set description
*
* @param string $description
* @return CGroupInfo
*/
public function setDescription($description)
{
$this->description = $description;
return $this;
}
/**
* Get description
*
* @return string
*/
public function getDescription()
{
return $this->description;
}
/**
* Set maxStudent
*
* @param integer $maxStudent
* @return CGroupInfo
*/
public function setMaxStudent($maxStudent)
{
$this->maxStudent = $maxStudent;
return $this;
}
/**
* Get maxStudent
*
* @return integer
*/
public function getMaxStudent()
{
return $this->maxStudent;
}
/**
* Set docState
*
* @param boolean $docState
* @return CGroupInfo
*/
public function setDocState($docState)
{
$this->docState = $docState;
return $this;
}
/**
* Get docState
*
* @return boolean
*/
public function getDocState()
{
return $this->docState;
}
/**
* Set calendarState
*
* @param boolean $calendarState
* @return CGroupInfo
*/
public function setCalendarState($calendarState)
{
$this->calendarState = $calendarState;
return $this;
}
/**
* Get calendarState
*
* @return boolean
*/
public function getCalendarState()
{
return $this->calendarState;
}
/**
* Set workState
*
* @param boolean $workState
* @return CGroupInfo
*/
public function setWorkState($workState)
{
$this->workState = $workState;
return $this;
}
/**
* Get workState
*
* @return boolean
*/
public function getWorkState()
{
return $this->workState;
}
/**
* Set announcementsState
*
* @param boolean $announcementsState
* @return CGroupInfo
*/
public function setAnnouncementsState($announcementsState)
{
$this->announcementsState = $announcementsState;
return $this;
}
/**
* Get announcementsState
*
* @return boolean
*/
public function getAnnouncementsState()
{
return $this->announcementsState;
}
/**
* Set forumState
*
* @param boolean $forumState
* @return CGroupInfo
*/
public function setForumState($forumState)
{
$this->forumState = $forumState;
return $this;
}
/**
* Get forumState
*
* @return boolean
*/
public function getForumState()
{
return $this->forumState;
}
/**
* Set wikiState
*
* @param boolean $wikiState
* @return CGroupInfo
*/
public function setWikiState($wikiState)
{
$this->wikiState = $wikiState;
return $this;
}
/**
* Get wikiState
*
* @return boolean
*/
public function getWikiState()
{
return $this->wikiState;
}
/**
* Set chatState
*
* @param boolean $chatState
* @return CGroupInfo
*/
public function setChatState($chatState)
{
$this->chatState = $chatState;
return $this;
}
/**
* Get chatState
*
* @return boolean
*/
public function getChatState()
{
return $this->chatState;
}
/**
* Set secretDirectory
*
* @param string $secretDirectory
* @return CGroupInfo
*/
public function setSecretDirectory($secretDirectory)
{
$this->secretDirectory = $secretDirectory;
return $this;
}
/**
* Get secretDirectory
*
* @return string
*/
public function getSecretDirectory()
{
return $this->secretDirectory;
}
/**
* Set selfRegistrationAllowed
*
* @param boolean $selfRegistrationAllowed
* @return CGroupInfo
*/
public function setSelfRegistrationAllowed($selfRegistrationAllowed)
{
$this->selfRegistrationAllowed = $selfRegistrationAllowed;
return $this;
}
/**
* Get selfRegistrationAllowed
*
* @return boolean
*/
public function getSelfRegistrationAllowed()
{
return $this->selfRegistrationAllowed;
}
/**
* Set selfUnregistrationAllowed
*
* @param boolean $selfUnregistrationAllowed
* @return CGroupInfo
*/
public function setSelfUnregistrationAllowed($selfUnregistrationAllowed)
{
$this->selfUnregistrationAllowed = $selfUnregistrationAllowed;
return $this;
}
/**
* Get selfUnregistrationAllowed
*
* @return boolean
*/
public function getSelfUnregistrationAllowed()
{
return $this->selfUnregistrationAllowed;
}
/**
* Set sessionId
*
* @param integer $sessionId
* @return CGroupInfo
*/
public function setSessionId($sessionId)
{
$this->sessionId = $sessionId;
return $this;
}
/**
* Get sessionId
*
* @return integer
*/
public function getSessionId()
{
return $this->sessionId;
}
}

@ -0,0 +1,612 @@
<?php
/* For licensing terms, see /license.txt */
namespace Chamilo\CourseBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Validator\Constraints as Assert;
use Symfony\Component\Validator\Mapping\ClassMetadata;
use Chamilo\CoreBundle\Entity\Course;
use Symfony\Component\HttpFoundation\File\UploadedFile;
use APY\DataGridBundle\Grid\Mapping as GRID;
/**
* CTool
* @GRID\Source(columns="iid, name")
* @ORM\HasLifecycleCallbacks
* @ORM\Table(name="c_tool", indexes={@ORM\Index(name="session_id", columns={"session_id"})})
* @ORM\Entity
*/
class CTool
{
/**
* @var integer
*
* @ORM\Column(name="iid", type="integer", precision=0, scale=0, nullable=false, unique=false)
* @ORM\Id
* @ORM\GeneratedValue(strategy="AUTO")
*/
private $iid;
/**
* @var integer
*
* @ORM\Column(name="id", type="integer", precision=0, scale=0, nullable=false, unique=false)
*/
private $id;
/**
* @var integer
*
* @ORM\Column(name="c_id", type="integer", precision=0, scale=0, nullable=false, unique=false)
*/
private $cId;
/**
* @var string
*
* @ORM\Column(name="name", type="string", length=255, precision=0, scale=0, nullable=false, unique=false)
*/
private $name;
/**
* @var string
*
* @ORM\Column(name="link", type="string", length=255, precision=0, scale=0, nullable=false, unique=false)
*/
private $link;
/**
* @var string
* @ORM\Column(name="image", type="string", length=255, precision=0, scale=0, nullable=true, unique=false)
*/
private $image;
/**
* @var string
* @ORM\Column(name="custom_icon", type="string", length=255, precision=0, scale=0, nullable=true, unique=false)
*/
private $customIcon;
/**
* @var boolean
*
* @ORM\Column(name="visibility", type="boolean", precision=0, scale=0, nullable=true, unique=false)
*/
private $visibility;
/**
* @var string
*
* @ORM\Column(name="admin", type="string", length=255, precision=0, scale=0, nullable=true, unique=false)
*/
private $admin;
/**
* @var string
*
* @ORM\Column(name="address", type="string", length=255, precision=0, scale=0, nullable=true, unique=false)
*/
private $address;
/**
* @var boolean
*
* @ORM\Column(name="added_tool", type="boolean", precision=0, scale=0, nullable=true, unique=false)
*/
private $addedTool;
/**
* @var string
*
* @ORM\Column(name="target", type="string", precision=0, scale=0, nullable=false, unique=false)
*/
private $target;
/**
* @var string
*
* @ORM\Column(name="category", type="string", length=20, precision=0, scale=0, nullable=false, unique=false)
*/
private $category;
/**
* @var integer
*
* @ORM\Column(name="session_id", type="integer", precision=0, scale=0, nullable=true, unique=false)
*/
private $sessionId;
/**
* @var string
*
* @ORM\Column(name="description", type="text", precision=0, scale=0, nullable=true, unique=false)
*/
private $description;
/**
* @ORM\ManyToOne(targetEntity="Chamilo\CoreBundle\Entity\Course", inversedBy="tools")
* @ORM\JoinColumn(name="c_id", referencedColumnName="id")
*/
private $course;
protected $originalImage;
/**
*/
public function __construct()
{
// Default values
$this->id = 0;
$this->sessionId = 0;
$this->address = 'squaregrey.gif';
}
/**
* @param Course $course
*/
public function setCourse($course)
{
$this->course = $course;
}
/**
* @param ClassMetadata $metadata
*/
public static function loadValidatorMetadata(ClassMetadata $metadata)
{
$metadata->addPropertyConstraint(
'customIcon',
new Assert\File(array('mimeTypes' => array("image/png")))
);
$metadata->addPropertyConstraint(
'customIcon',
new Assert\Image(array('maxWidth' => 64, 'minHeight' => 64))
);
$metadata->addPropertyConstraint('cId', new Assert\NotBlank());
}
/**
* @return Course
*/
public function getCourse()
{
return $this->course;
}
/**
* @return null|string
*/
public function getAbsolutePath()
{
return null === $this->getCustomIcon()
? null
: $this->getUploadRootDir().'/'.$this->getCustomIcon();
}
/**
* @return string
*/
protected function getUploadRootDir()
{
// the absolute directory path where uploaded
// documents should be saved
$dir = $this->getCourse()->getAbsoluteSysCoursePath().$this->getUploadDir();
if (is_dir($dir)) {
return $dir;
} else {
mkdir($dir);
return $dir;
}
}
/**
* @return string
*/
protected function getUploadDir()
{
// get rid of the __DIR__ so it doesn't screw up
// when displaying uploaded doc/image in the view.
return 'upload/course_home_icons';
}
/**
* Called before saving the entity
*
* @ORM\PrePersist()
* @ORM\PreUpdate()
*/
public function preUpload()
{
if (null !== $this->getCustomIcon()) {
// do whatever you want to generate a unique name
//$filename = sha1(uniqid(mt_rand(), true));
$this->originalImage = $this->getCustomIcon();
$this->customIcon = $this->getName().'_'.$this->getSessionId().'.'.$this->getCustomIcon()->guessExtension();
}
}
/**
* Called before entity removal
*
* @ORM\PostRemove()
*/
public function removeUpload()
{
if ($file = $this->getAbsolutePath()) {
unlink($file);
}
}
/**
* Called after entity persistence
*
* @ORM\PostPersist()
* @ORM\PostUpdate()
*/
public function upload()
{
// the file property can be empty if the field is not required
if (null === $this->getCustomIcon()) {
return;
}
// use the original file name here but you should
// sanitize it at least to avoid any security issues
// move takes the target directory and then the
// target filename to move to
$this->originalImage->move(
$this->getUploadRootDir(),
$this->customIcon
);
// clean up the file property as you won't need it anymore
$this->originalImage = null;
}
/**
* Set cId
*
* @param integer $cId
* @return CTool
*/
public function setCId($cId)
{
$this->cId = $cId;
return $this;
}
/**
* Get cId
*
* @return integer
*/
public function getCId()
{
return $this->cId;
}
/**
* Set id
*
* @param integer $id
* @return CTool
*/
public function setId($id)
{
$this->id = $id;
return $this;
}
/**
* Get id
*
* @return integer
*/
public function getId()
{
return $this->id;
}
/**
* Set name
*
* @param string $name
* @return CTool
*/
public function setName($name)
{
$this->name = $name;
return $this;
}
/**
* Get name
*
* @return string
*/
public function getName()
{
return $this->name;
}
/**
* Set link
*
* @param string $link
* @return CTool
*/
public function setLink($link)
{
$this->link = $link;
return $this;
}
/**
* Get link
*
* @return string
*/
public function getLink()
{
return $this->link;
}
/**
* Set image
*
* @param string $image
* @return CTool
*/
public function setImage($image)
{
$this->image = $image;
return $this;
}
/**
* Get image
*
* @return string
*/
public function getImage()
{
return $this->image;
}
/**
* Set visibility
*
* @param boolean $visibility
* @return CTool
*/
public function setVisibility($visibility)
{
$this->visibility = $visibility;
return $this;
}
/**
* Get visibility
*
* @return boolean
*/
public function getVisibility()
{
return $this->visibility;
}
/**
* Set admin
*
* @param string $admin
* @return CTool
*/
public function setAdmin($admin)
{
$this->admin = $admin;
return $this;
}
/**
* Get admin
*
* @return string
*/
public function getAdmin()
{
return $this->admin;
}
/**
* Set address
*
* @param string $address
* @return CTool
*/
public function setAddress($address)
{
$this->address = $address;
return $this;
}
/**
* Get address
*
* @return string
*/
public function getAddress()
{
return $this->address;
}
/**
* Set addedTool
*
* @param boolean $addedTool
* @return CTool
*/
public function setAddedTool($addedTool)
{
$this->addedTool = $addedTool;
return $this;
}
/**
* Get addedTool
*
* @return boolean
*/
public function getAddedTool()
{
return $this->addedTool;
}
/**
* Set target
*
* @param string $target
* @return CTool
*/
public function setTarget($target)
{
$this->target = $target;
return $this;
}
/**
* Get target
*
* @return string
*/
public function getTarget()
{
return $this->target;
}
/**
* Set category
*
* @param string $category
* @return CTool
*/
public function setCategory($category)
{
$this->category = $category;
return $this;
}
/**
* Get category
*
* @return string
*/
public function getCategory()
{
return $this->category;
}
/**
* Set sessionId
*
* @param integer $sessionId
* @return CTool
*/
public function setSessionId($sessionId)
{
$this->sessionId = $sessionId;
return $this;
}
/**
* Get sessionId
*
* @return integer
*/
public function getSessionId()
{
return $this->sessionId;
}
/**
* @return string
*/
public function getCustomIcon()
{
return $this->customIcon;
}
/**
* @param string $customIcon
* @return $this
*/
public function setCustomIcon($customIcon)
{
$this->customIcon = $customIcon;
return $this;
}
/**
* @return string
*/
public function getDescription()
{
return $this->description;
}
/**
* @param string $description
* @return $this
*/
public function setDescription($description)
{
$this->description = $description;
return $this;
}
/**
* Creates a gray icon.
* @param \Imagine\Image\ImagineInterface $imagine
* @return bool
*/
public function createGrayIcon($imagine)
{
$customIcon = $this->getCustomIcon();
if (empty($customIcon)) {
return false;
}
if (file_exists($this->getAbsolutePath())) {
$image = $imagine->open($this->getAbsolutePath());
$fileInfo = pathinfo($this->getAbsolutePath());
$originalFilename = $fileInfo['basename'];
$filename = $fileInfo['filename'].'_na.'.$fileInfo['extension'];
$newPath = str_replace($originalFilename, $filename, $this->getAbsolutePath());
$transformation = new \Imagine\Filter\Advanced\Grayscale();
$transformation->apply($image)->save($newPath);
}
}
/**
* Replace the $this->image png extension to gif
* @return string
*/
public function imageGifToPng()
{
return str_replace('.gif', '.png', $this->getImage());
}
}

@ -1,7 +1,7 @@
<?php
/* For licensing terms, see /license.txt */
namespace Chamilo\UserBundle\Repository;
namespace Chamilo\UserBundle\Entity\Repository;
use Doctrine\ORM\EntityRepository;
use Doctrine\ORM\NoResultException;
@ -11,14 +11,13 @@ use Chamilo\UserBundle\Entity\User as User;
/**
* Class UserRepository
* @package Entity\Repository
* @package Chamilo\UserBundle\Repository
*/
class UserRepository extends EntityRepository
{
public function getGroupsByUser($userId)
{
$user = $this->find($userId);
}
/**

@ -31,14 +31,11 @@ use Chamilo\CoreBundle\Entity\ExtraFieldValues;
* @ORM\HasLifecycleCallbacks
* @ORM\Table(name="user")
* //Vich\Uploadable
* UniqueEntity("username")
* @ORM\Entity()
* ORM\Entity(repositoryClass="Chamilo\UserBundle\Repository\UserRepository")
* @UniqueEntity("username")
* @ORM\Entity(repositoryClass="Chamilo\UserBundle\Entity\Repository\UserRepository")
*
*/
//class User extends BaseUser implements ParticipantInterface, ThemeUser
class User
class User //class User extends BaseUser implements ParticipantInterface, ThemeUser
{
const COURSE_MANAGER = 1;
const TEACHER = 1;
@ -289,7 +286,7 @@ class User
*/
//protected $salt;
private $isActive;
//private $isActive;
/**
* ORM\OneToMany(targetEntity="Chamilo\CoreBundle\Entity\CurriculumItemRelUser", mappedBy="user")

Loading…
Cancel
Save