예제 #1
0
 /**
  * @author Sebastien Piraux <*****@*****.**> old code
  * @author Julio Montoya 2013
  * @desc Record information for login event when an user identifies himself with username & password
  */
 function event_login(User $user)
 {
     $userId = $user->getUserId();
     $TABLETRACK_LOGIN = Database::get_main_table(TABLE_STATISTIC_TRACK_E_LOGIN);
     $reallyNow = api_get_utc_datetime();
     $sql = "INSERT INTO " . $TABLETRACK_LOGIN . " (login_user_id, login_ip, login_date, logout_date) VALUES\n                    ('" . $userId . "',\n                    '" . Database::escape_string(api_get_real_ip()) . "',\n                    '" . $reallyNow . "',\n                    '" . $reallyNow . "'\n                    )";
     Database::query($sql);
     $roles = $user->getRoles();
     // auto subscribe
     foreach ($roles as $role) {
         $userStatusParsed = 'student';
         switch ($role) {
             case 'ROLE_SESSION_MANAGER':
                 $userStatusParsed = 'sessionadmin';
                 break;
             case 'ROLE_TEACHER':
                 $userStatusParsed = 'teacher';
                 break;
             case 'ROLE_RRHH':
                 $userStatusParsed = 'DRH';
                 break;
         }
         $autoSubscribe = api_get_setting($userStatusParsed . '_autosubscribe');
         if ($autoSubscribe) {
             $autoSubscribe = explode('|', $autoSubscribe);
             foreach ($autoSubscribe as $code) {
                 if (CourseManager::course_exists($code)) {
                     CourseManager::subscribe_user($userId, $code);
                 }
             }
         }
     }
 }
예제 #2
0
 /**
  * Creates the users/upload/X/my_files folder
  * @param User $user
  */
 public function createMyFilesFolder(User $user)
 {
     $userId = $user->getUserId();
     $path = \UserManager::get_user_picture_path_by_id($userId, 'system');
     if (!$this->fs->exists($path['dir'] . 'my_files')) {
         $this->createFolders(array($path['dir'] . 'my_files'));
     }
 }
 /**
  * Get all users that are registered in the course. No matter the status
  *
  * @param \Chamilo\CoreBundle\Entity\CurriculumItem $course
  * @return bool
  */
 public function isAllowToInsert(\Chamilo\CoreBundle\Entity\CurriculumItem $item, \Chamilo\UserBundle\Entity\User $user)
 {
     $max = $item->getMaxRepeat();
     $count = $this->createQueryBuilder('a')->select('COUNT(a)')->where('a.itemId = :itemId')->andWhere('a.userId = :userId')->setParameters(array('itemId' => $item->getId(), 'userId' => $user->getUserId()))->getQuery()->getSingleScalarResult();
     return $count <= $max ? true : false;
 }