Пример #1
0
 public function doStateE($line)
 {
     ////echo "// Estat 6<br />";
     ////echo "EL que hi ha a line: ".bin2hex($line)."<br>";
     $course = Doctrine_Query::create()->select('a.id')->from('Assignatura a')->where('a.carrera_curs_id = ?', $this->courseyear->getId())->andWhere('a.nom = ?', $line)->fetchOne();
     if ($course) {
         $this->logger->debug("Found course " . $line . " in database, id is " . $course->getId());
     } else {
         ////echo $line."<br />";
         $this->logger->debug("Course " . $line . " doesn't exist, creating.");
         $course = new Assignatura();
         $course->setNom($line);
         $course->setCarreraCurs($this->courseyear);
         $course->save();
     }
     $this->getCurrentBlock()->setAssignatura($course);
     $this->getCurrentBlock()->setDefaultType();
     $this->getCurrentBlock()->saveSessions();
     return;
 }
 /**
  * Afegeix assignatures a un grup ja existent
  * @param string [$slug] slug assignatura
  */
 public function afegirAssignatures($slug)
 {
     try {
         $grup = Grup::bySlug($slug);
     } catch (ModelNotFoundException $e) {
         return Redirect::route('grups.meus');
     }
     $moderador = $grup->estudiant;
     //Comprovar que sigui el moderador de l'assignatura i el grup estigui actiu
     if (Auth::user()->getEmail() == $moderador->getEmail() && $grup->getActiu()) {
         if (Input::has('assignatura')) {
             $a_assignatures = array();
             $assignatures = Input::get('assignatura');
             $a_noms = array();
             $noms = Input::get('nom');
             $a_cognoms = array();
             $cognoms = Input::get('cognoms');
             foreach ($assignatures as $key => $value) {
                 $a_assignatures[] = $value;
             }
             foreach ($noms as $key => $value) {
                 $a_noms[] = $value;
             }
             foreach ($cognoms as $key => $value) {
                 $a_cognoms[] = $value;
             }
             for ($i = 0; $i < count($a_noms); $i++) {
                 if ($a_assignatures[$i] != "") {
                     $ass = new Assignatura();
                     $nom_ass = $a_assignatures[$i];
                     $nom_ass = strip_tags($nom_ass);
                     $nom_ass = trim($nom_ass);
                     $ass->nom_assignatura = $nom_ass;
                     $nom_prof_ass = $a_noms[$i];
                     $nom_prof_ass = strip_tags($nom_prof_ass);
                     $nom_prof_ass = trim($nom_prof_ass);
                     $ass->nom_professor = $nom_prof_ass;
                     $cognoms_prof_ass = $a_cognoms[$i];
                     $cognoms_prof_ass = strip_tags($cognoms_prof_ass);
                     $cognoms_prof_ass = trim($cognoms_prof_ass);
                     $ass->cognoms_professor = $cognoms_prof_ass;
                     $ass->grup_id_grup = $grup->getID();
                     $ass->slug_assignatura = uniqid();
                     $ass->save();
                 }
             }
             return Redirect::route('grups.meus');
         }
         $this->layout->title = 'Workshome - Añadir asignaturas';
         $this->layout->description = 'Añadir asignaturas a tu grupo';
         $this->layout->content = View::make('assignatura/afegir');
     } else {
         return Redirect::route('grups.meus');
     }
 }