예제 #1
0
 /**
  * @param SessionRepository $repo
  * @param AccessUrl $url
  * @throws \Exception
  */
 private function checkLimit($repo, AccessUrl $url)
 {
     $limit = $url->getLimitSessions();
     if (!empty($limit)) {
         $count = $repo->getCountSessionByUrl($url);
         if ($count >= $limit) {
             api_warn_hosting_contact('hosting_limit_sessions', $limit);
             throw new \Exception('PortalSessionsLimitReached');
         }
     }
 }
예제 #2
0
 /**
  * @param CourseRepository $repo
  * @param Course $course
  * @param AccessUrl $url
  * @throws \Exception
  */
 private function checkLimit($repo, Course $course, AccessUrl $url)
 {
     $limit = $url->getLimitCourses();
     if (!empty($limit)) {
         $count = $repo->getCountCoursesByUrl($url);
         if ($count >= $limit) {
             api_warn_hosting_contact('hosting_limit_courses', $limit);
             throw new \Exception('PortalCoursesLimitReached');
         }
     }
     if ($course->getVisibility() != COURSE_VISIBILITY_HIDDEN) {
         $limit = $url->getLimitActiveCourses();
         if (!empty($limit)) {
             $count = $repo->getCountActiveCoursesByUrl($url);
             if ($count >= $limit) {
                 api_warn_hosting_contact('hosting_limit_active_courses', $limit);
                 throw new \Exception('PortalActiveCoursesLimitReached');
             }
         }
     }
 }
예제 #3
0
 /**
  * @param ObjectManager $manager
  */
 public function load(ObjectManager $manager)
 {
     /** @var HttpKernelInterface $kernel */
     //$kernel = $this->container->get('kernel');
     // Create course categories
     $repo = $manager->getRepository('ChamiloCoreBundle:CourseCategory');
     $courseCategory = $repo->findOneBy(['code' => 'LANG']);
     if (empty($courseCategory)) {
         $courseCategory = new CourseCategory();
         $courseCategory->setName('Language skills');
         $courseCategory->setCode('LANG');
         $courseCategory->setTreePos(1);
         $courseCategory->setAuthCatChild('TRUE');
         $courseCategory->setAuthCourseChild('TRUE');
         $manager->persist($courseCategory);
     }
     $courseCategory = $repo->findOneBy(['code' => 'PC']);
     if (empty($courseCategory)) {
         $courseCategory = new CourseCategory();
         $courseCategory->setName('PC Skills');
         $courseCategory->setCode('PC');
         $courseCategory->setTreePos(2);
         $courseCategory->setAuthCatChild('TRUE');
         $courseCategory->setAuthCourseChild('TRUE');
         $manager->persist($courseCategory);
     }
     $courseCategory = $repo->findOneBy(['code' => 'PROJ']);
     if (empty($courseCategory)) {
         $courseCategory = new CourseCategory();
         $courseCategory->setName('Projects');
         $courseCategory->setCode('PROJ');
         $courseCategory->setTreePos(3);
         $courseCategory->setAuthCatChild('TRUE');
         $courseCategory->setAuthCourseChild('TRUE');
         $manager->persist($courseCategory);
     }
     /* $courseField = new CourseField();
        $courseField->setFieldType(13);
        $courseField->setFieldVariable('special_course');
        $courseField->setFieldDisplayText('Special course');
        $courseField->setFieldDefaultValue('Yes');
        $courseField->setFieldVisible(1);
        $courseField->setFieldChangeable(1);
        $manager->persist($courseField);*/
     /*
         Saving available languages depending in
         the ChamiloCoreBundle/Resources/translations folder
     */
     $repo = $manager->getRepository('ChamiloCoreBundle:AccessUrl');
     $all = $repo->findAll();
     $accessUrlId = 1;
     if (empty($all)) {
         //$adminUser = $this->getUserManager()->findUserByUsername('admin');
         //$adminUser = $this->getUserManager()->find(1);
         // Create first portal (multiple url feature)
         //            $adminUserId = $adminUser->getId();
         $accessUrl = new AccessUrl();
         $accessUrl->setUrl('http://localhost/');
         $accessUrl->setActive(1);
         $accessUrl->setDescription(' ');
         //$accessUrl->setCreatedBy($adminUserId);
         $manager->persist($accessUrl);
         $this->setReference('access_url', $accessUrl);
         // Add admin user to portal 1
         /*$accessUrlRelUser = new AccessUrlRelUser();
           $accessUrlRelUser->setUser($adminUser);
           $accessUrlRelUser->setPortal($accessUrl);
           $manager->persist($accessUrlRelUser);*/
     }
     /*$systemTemplate = new SystemTemplate();
       $systemTemplate->setTitle('');
       $systemTemplate->setComment('');
       $systemTemplate->setImage('');
       $systemTemplate->setContent('');*/
     // Create social network relations
     $repo = $manager->getRepository('ChamiloCoreBundle:UserFriendRelationType');
     $userFriendRelationType = $repo->find(1);
     if (empty($userFriendRelationType)) {
         $userFriendRelationType = new UserFriendRelationType();
         $userFriendRelationType->setId(1);
         $userFriendRelationType->setTitle('SocialUnknow');
         $manager->persist($userFriendRelationType);
     }
     $userFriendRelationType = $repo->find(2);
     if (empty($userFriendRelationType)) {
         $userFriendRelationType = new UserFriendRelationType();
         $userFriendRelationType->setId(2);
         $userFriendRelationType->setTitle('SocialParent');
         $manager->persist($userFriendRelationType);
     }
     $userFriendRelationType = $repo->find(3);
     if (empty($userFriendRelationType)) {
         $userFriendRelationType = new UserFriendRelationType();
         $userFriendRelationType->setId(3);
         $userFriendRelationType->setTitle('SocialFriend');
         $manager->persist($userFriendRelationType);
     }
     $userFriendRelationType = $repo->find(4);
     if (empty($userFriendRelationType)) {
         $userFriendRelationType = new UserFriendRelationType();
         $userFriendRelationType->setId(4);
         $userFriendRelationType->setTitle('SocialGoodFriend');
         $manager->persist($userFriendRelationType);
     }
     $userFriendRelationType = $repo->find(5);
     if (empty($userFriendRelationType)) {
         $userFriendRelationType = new UserFriendRelationType();
         $userFriendRelationType->setId(5);
         $userFriendRelationType->setTitle('SocialEnemy');
         $manager->persist($userFriendRelationType);
     }
     $userFriendRelationType = $repo->find(6);
     if (empty($userFriendRelationType)) {
         $userFriendRelationType = new UserFriendRelationType();
         $userFriendRelationType->setId(6);
         $userFriendRelationType->setTitle('SocialDeleted');
         $manager->persist($userFriendRelationType);
     }
     // Create default skills
     $repo = $manager->getRepository('ChamiloCoreBundle:Skill');
     $skills = $repo->findAll();
     if (empty($skills)) {
         $skill = new Skill();
         $skill->setName('Root');
         $skill->setStatus(Skill::STATUS_ENABLED);
         $skill->setDescription(' ');
         $skill->setShortCode('root');
         $skill->setIcon(' ');
         $skill->setAccessUrlId($accessUrlId);
         $manager->persist($skill);
         $skillRelSkill = new SkillRelSkill();
         $skillRelSkill->setId(1);
         $skillRelSkill->setSkillId(1);
         $skillRelSkill->setParentId(0);
         $skillRelSkill->setRelationType(0);
         $skillRelSkill->setLevel(0);
         $manager->persist($skillRelSkill);
     }
     $repo = $manager->getRepository('ChamiloCoreBundle:CourseType');
     $items = $repo->findAll();
     if (empty($items)) {
         $courseType = new CourseType();
         $courseType->setName('All Tools');
         $manager->persist($courseType);
         $courseType = new CourseType();
         $courseType->setName('Entry exam');
         $manager->persist($courseType);
     }
     // Branch
     $repo = $manager->getRepository('ChamiloCoreBundle:BranchSync');
     $items = $repo->findAll();
     if (empty($items)) {
         $branch = new BranchSync();
         $branch->setAccessUrlId($accessUrlId);
         $branch->setBranchName('Local');
         $branch->setBranchIp('127.0.0.1');
         $manager->persist($branch);
         $branchTransactionStatus = new BranchTransactionStatus();
         $branchTransactionStatus->setTitle('To be executed');
         $manager->persist($branchTransactionStatus);
         $branchTransactionStatus = new BranchTransactionStatus();
         $branchTransactionStatus->setTitle('Executed success');
         $manager->persist($branchTransactionStatus);
         $branchTransactionStatus = new BranchTransactionStatus();
         $branchTransactionStatus->setTitle('Execution deprecated');
         $manager->persist($branchTransactionStatus);
         $branchTransactionStatus = new BranchTransactionStatus();
         $branchTransactionStatus->setTitle('Execution failed');
         $manager->persist($branchTransactionStatus);
     }
     // Tools
     // Tool chain contains all tools (services with tag "chamilo_course.tool" )
     $toolChain = $this->container->get('chamilo_course.tool_chain');
     $toolChain->createTools($manager);
     // Fill the language table
     $languages = Intl::getLocaleBundle()->getLocaleNames('en');
     // @todo use this iso languages just for now
     $availableIsoCode = ['en', 'es', 'fr', 'nl', 'ru', 'de'];
     foreach ($languages as $code => $languageName) {
         if (!in_array($code, $availableIsoCode)) {
             continue;
         }
         \Locale::setDefault($code);
         $localeName = Intl::getLocaleBundle()->getLocaleName($code);
         $lang = new Language();
         $lang->setAvailable(1)->setIsocode($code)->setOriginalName($localeName)->setEnglishName($languageName);
         $manager->persist($lang);
     }
     $manager->flush();
 }
예제 #4
0
 /**
  * @param AccessUrl $url
  *
  * @return $this
  */
 public function setCurrentUrl(AccessUrl $url)
 {
     $urlList = $this->getUrls();
     /** @var AccessUrlRelCourse $item */
     foreach ($urlList as $item) {
         if ($item->getUrl()->getId() == $url->getId()) {
             $this->currentUrl = $url;
             break;
         }
     }
     return $this;
 }
예제 #5
0
 /**
  * @param ObjectManager $manager
  */
 public function load(ObjectManager $manager)
 {
     /** @var HttpKernelInterface $kernel */
     $kernel = $this->container->get('kernel');
     $courseCategory = new CourseCategory();
     $courseCategory->setName('Language skills');
     $courseCategory->setCode('LANG');
     $courseCategory->setTreePos(1);
     $courseCategory->setAuthCatChild('TRUE');
     $courseCategory->setAuthCourseChild('TRUE');
     $manager->persist($courseCategory);
     $courseCategory = new CourseCategory();
     $courseCategory->setName('PC Skills');
     $courseCategory->setCode('PC');
     $courseCategory->setTreePos(2);
     $courseCategory->setAuthCatChild('TRUE');
     $courseCategory->setAuthCourseChild('TRUE');
     $manager->persist($courseCategory);
     $courseCategory = new CourseCategory();
     $courseCategory->setName('Projects');
     $courseCategory->setCode('PROJ');
     $courseCategory->setTreePos(3);
     $courseCategory->setAuthCatChild('TRUE');
     $courseCategory->setAuthCourseChild('TRUE');
     $manager->persist($courseCategory);
     $courseField = new CourseField();
     $courseField->setFieldType(13);
     $courseField->setFieldVariable('special_course');
     $courseField->setFieldDisplayText('Special course');
     $courseField->setFieldDefaultValue('Yes');
     $courseField->setFieldVisible(1);
     $courseField->setFieldChangeable(1);
     $manager->persist($courseField);
     /*
         Saving available languages depending in
         the ChamiloCoreBundle/Resources/translations folder
     */
     $languages = Intl::getLocaleBundle()->getLocaleNames('en');
     // Getting po files inside the path
     $translationPath = $kernel->locateResource('@ChamiloCoreBundle/Resources/translations');
     $finder = new Finder();
     $finder->files()->in($translationPath);
     $avoidIsoCodeList = array('AvanzuAdminTheme.en.po');
     $availableIsoCode = array();
     foreach ($finder as $file) {
         $fileName = $file->getRelativePathname();
         if (in_array($fileName, $avoidIsoCodeList)) {
             continue;
         }
         $isoCodeInFolder = str_replace(array('all.', '.po'), '', $fileName);
         $availableIsoCode[] = $isoCodeInFolder;
     }
     foreach ($languages as $code => $languageName) {
         if (!in_array($code, $availableIsoCode)) {
             continue;
         }
         \Locale::setDefault($code);
         $localeName = Intl::getLocaleBundle()->getLocaleName($code);
         $lang = new Language();
         $lang->setAvailable(1);
         $lang->setIsocode($code);
         $lang->setOriginalName($localeName);
         $lang->setEnglishName($languageName);
         $manager->persist($lang);
     }
     $adminUser = $this->getUserManager()->findUserByUsername('admin');
     // Ids used
     $adminUserId = $adminUser->getId();
     $accessUrlId = 1;
     $accessUrl = new AccessUrl();
     $accessUrl->setUrl('http://localhost/');
     $accessUrl->setActive(1);
     $accessUrl->setDescription(' ');
     $accessUrl->setCreatedBy($adminUserId);
     $manager->persist($accessUrl);
     $this->setReference('access_url', $accessUrl);
     $accessUrlRelUser = new AccessUrlRelUser();
     $accessUrlRelUser->setUserId($adminUserId);
     $accessUrlRelUser->setAccessUrlId($accessUrlId);
     $manager->persist($accessUrlRelUser);
     /*$systemTemplate = new SystemTemplate();
       $systemTemplate->setTitle('');
       $systemTemplate->setComment('');
       $systemTemplate->setImage('');
       $systemTemplate->setContent('');*/
     $userFriendRelationType = new UserFriendRelationType();
     $userFriendRelationType->setId(1);
     $userFriendRelationType->setTitle('SocialUnknow');
     $manager->persist($userFriendRelationType);
     $userFriendRelationType = new UserFriendRelationType();
     $userFriendRelationType->setId(2);
     $userFriendRelationType->setTitle('SocialParent');
     $manager->persist($userFriendRelationType);
     $userFriendRelationType = new UserFriendRelationType();
     $userFriendRelationType->setId(3);
     $userFriendRelationType->setTitle('SocialFriend');
     $manager->persist($userFriendRelationType);
     $userFriendRelationType = new UserFriendRelationType();
     $userFriendRelationType->setId(4);
     $userFriendRelationType->setTitle('SocialGoodFriend');
     $manager->persist($userFriendRelationType);
     $userFriendRelationType = new UserFriendRelationType();
     $userFriendRelationType->setId(5);
     $userFriendRelationType->setTitle('SocialEnemy');
     $manager->persist($userFriendRelationType);
     $userFriendRelationType = new UserFriendRelationType();
     $userFriendRelationType->setId(6);
     $userFriendRelationType->setTitle('SocialDeleted');
     $manager->persist($userFriendRelationType);
     $skill = new Skill();
     $skill->setName('Root');
     $skill->setDescription(' ');
     $skill->setShortCode('root');
     $skill->setIcon(' ');
     $skill->setAccessUrlId($accessUrlId);
     $manager->persist($skill);
     $skillRelSkill = new SkillRelSkill();
     $skillRelSkill->setId(1);
     $skillRelSkill->setSkillId(1);
     $skillRelSkill->setParentId(0);
     $skillRelSkill->setRelationType(0);
     $skillRelSkill->setLevel(0);
     $manager->persist($skillRelSkill);
     $courseType = new CourseType();
     $courseType->setName('All Tools');
     $manager->persist($courseType);
     $courseType = new CourseType();
     $courseType->setName('Entry exam');
     $manager->persist($courseType);
     $branch = new BranchSync();
     $branch->setAccessUrlId($accessUrlId);
     $branch->setBranchName('Local');
     $branch->setBranchIp('127.0.0.1');
     $manager->persist($branch);
     $branchTransactionStatus = new BranchTransactionStatus();
     $branchTransactionStatus->setTitle('To be executed');
     $manager->persist($branchTransactionStatus);
     $branchTransactionStatus = new BranchTransactionStatus();
     $branchTransactionStatus->setTitle('Executed success');
     $manager->persist($branchTransactionStatus);
     $branchTransactionStatus = new BranchTransactionStatus();
     $branchTransactionStatus->setTitle('Execution deprecated');
     $manager->persist($branchTransactionStatus);
     $branchTransactionStatus = new BranchTransactionStatus();
     $branchTransactionStatus->setTitle('Execution failed');
     $manager->persist($branchTransactionStatus);
     $toolChain = $this->container->get('chamilo_course.tool_chain');
     $toolChain->createTools($manager);
     /*
             $tool = new Tool();
             $tool->setName('agenda');
             $manager->persist($tool);
     
             $tool = new Tool();
             $tool->setName('announcements');
             $manager->persist($tool);
     
             $tool = new Tool();
             $tool->setName('exercise');
             $manager->persist($tool);
     
             $tool = new Tool();
             $tool->setName('document');
             $manager->persist($tool);
     
             $tool = new Tool();
             $tool->setName('link');
             $manager->persist($tool);
     
             $tool = new Tool();
             $tool->setName('forum');
             $manager->persist($tool);
     
             $tool = new Tool();
             $tool->setName('glossary');
             $manager->persist($tool);*/
     $manager->flush();
 }