Example #1
0
    /**
     * return all fields from SeminarCycleDate and old style
     * metadata_dates, combined with info about rooms
     *
     * @return array
     */
    function toArray()
    {
        $ret = $this->cycle_date->toArray();
        foreach($this->alias as $a => $o) {
            $ret[$a] = $this->cycle_date->$o;
        }
        $ret['assigned_rooms'] = $this->getPredominantRoom();
        $ret['freetext_rooms'] = $this->getFreetextPredominantRoom();
        $ret['tostring']       = $this->toString();
        $ret['tostring_short'] = $this->toString(true);

        $ret['start_minute'] = leadingZero($ret['start_minute']);
        $ret['end_minute'] = leadingZero($ret['end_minute']);
        return $ret;
    }
Example #2
0
        $decline_message = Request::get('decline_message');
        if ($semObj->seminar_number) {
            $message = sprintf(_("ABGELEHNTE RAUMANFRAGE: Ihre Raumanfrage zur Veranstaltung %s (%s) wurde abgelehnt.") . "\n\n" .
                _("Nachricht des Raumadministrators:") . "\n" . $decline_message, $semObj->getName(), $semObj->seminar_number);
        } else {
            $message = sprintf(_("ABGELEHNTE RAUMANFRAGE: Ihre Raumanfrage zur Veranstaltung %s wurde abgelehnt.") . "\n\n" .
                _("Nachricht des Raumadministrators:") . "\n" . $decline_message, $semObj->getName());
        }

        if ($reqObj->getTerminId()) {
            $termin = new SingleDate($reqObj->getTerminId());
            $message .= "\n\n". _("Betroffener Termin:") . "\n" . $termin->toString();
        }

        if ($reqObj->getMetadateId()) {
            $cycle = SeminarCycleDate::find($reqObj->getMetadateId());
            $message .= "\n\n". _("Betroffene Zeit:") . "\n" . $cycle->toString('full');
        }
        // fetch the names of the lecutrers to display them in the message
        foreach($semObj->getMembers('dozent') as $dozenten){
            $title[] = $dozenten['Nachname'];
        }
        if($semObj->seminar_number) $title[] = $semObj->seminar_number;
        $title[] = mila($semObj->getName(),30);

        $reqObj->setReplyComment($decline_message);
        $reqObj->store();
        foreach ($users as $userid) {
            setTempLanguage($userid);
            $messaging->insert_message($message, get_username($userid), $user->id, FALSE, FALSE, FALSE, FALSE,
                _("Raumanfrage abgelehnt:") .' '. implode(', ', $title), TRUE, 'high');
Example #3
0
 public function getTypeExplained()
 {
     $ret = '';
     if ($this->termin_id) {
         $ret = _("Einzeltermin der Veranstaltung");
         if (get_object_type($this->termin_id, array('date'))) {
             $termin = new SingleDate($this->termin_id);
             $ret .= chr(10) . '(' . $termin->toString() . ')';
         }
     } elseif ($this->metadate_id) {
         $ret = _("alle Termine einer regelmäßigen Zeit");
         if ($cycle = SeminarCycleDate::find($this->metadate_id)) {
             $ret .= chr(10) . ' (' . $cycle->toString('full') . ')';
         }
     } elseif ($this->seminar_id) {
         $ret = _("alle regelmäßigen und unregelmäßigen Termine der Veranstaltung");
         if (get_object_type($this->seminar_id, array('sem'))) {
             $course = new Seminar($this->seminar_id);
             $ret .= chr(10) . ' (' . $course->getDatesExport(array('short' => true, 'shrink' => true)) . ')';
         }
     } else {
         $ret = _("Kein Typ zugewiesen");
     }
     return $ret;
 }
Example #4
0
 /**
  * create a new room requests
  */
 public function new_action()
 {
     $options = array();
     $this->url_params = array();
     if (Request::get('origin') !== null) {
         $this->url_params['origin'] = Request::get('origin');
     }
     if (!RoomRequest::existsByCourse($this->course_id)) {
         $options[] = array('value' => 'course', 'name' => _('alle regelmäßigen und unregelmäßigen Termine der Veranstaltung'));
     }
     foreach (SeminarCycleDate::findBySeminar($this->course_id) as $cycle) {
         if (!RoomRequest::existsByCycle($cycle->getId())) {
             $name = _("alle Termine einer regelmäßigen Zeit");
             $name .= ' (' . $cycle->toString('full') . ')';
             $options[] = array('value' => 'cycle_' . $cycle->getId(), 'name' => $name);
         }
     }
     foreach (SeminarDB::getSingleDates($this->course_id) as $date) {
         if (!RoomRequest::existsByDate($date['termin_id'])) {
             $name = _("Einzeltermin der Veranstaltung");
             $termin = new SingleDate($date['termin_id']);
             $name .= ' (' . $termin->toString() . ')';
             $options[] = array('value' => 'date_' . $date['termin_id'], 'name' => $name);
         }
     }
     $this->options = $options;
     Helpbar::get()->addPlainText(_('Information'), _('Hier können Sie festlegen, welche Art von Raumanfrage Sie erstellen möchten.'));
 }
Example #5
0
 /**
  * Sets the start semester for the given course.
  *
  * @param String $course_id Id of the course
  */
 public function setSemester_action($course_id)
 {
     $current_semester = Semester::findCurrent();
     $start_semester = Semester::find(Request::get('startSemester'));
     if (Request::int('endSemester') != -1) {
         $end_semester = Semester::find(Request::get('endSemester'));
     } else {
         $end_semester = -1;
     }
     $course = Seminar::GetInstance($course_id);
     if ($start_semester == $end_semester) {
         $end_semester = 0;
     }
     if ($end_semester != 0 && $end_semester != -1 && $start_semester->beginn >= $end_semester->beginn) {
         PageLayout::postMessage(MessageBox::error(_('Das Startsemester liegt nach dem Endsemester!')));
     } else {
         $course->setStartSemester($start_semester->beginn);
         if ($end_semester != -1) {
             $course->setEndSemester($end_semester->beginn);
         } else {
             $course->setEndSemester($end_semester);
         }
         //$course->removeAndUpdateSingleDates();
         // If the new duration includes the current semester, we set the semester-chooser to the current semester
         if ($current_semester->beginn >= $course->getStartSemester() && $current_semester->beginn <= $course->getEndSemesterVorlesEnde()) {
             $course->setFilter($current_semester->beginn);
         } else {
             // otherwise we set it to the first semester
             $course->setFilter($course->getStartSemester());
         }
     }
     $course->store();
     SeminarCycleDate::removeOutRangedSingleDates($course->getStartSemester(), $course->getEndSemesterVorlesEnde(), $course->id);
     $cycles = SeminarCycleDate::findBySeminar_id($course->seminar_id);
     foreach ($cycles as $cycle) {
         $new_dates = $cycle->createTerminSlots($start_semester->beginn);
         foreach ($new_dates as $semester_id => $dates) {
             foreach ($dates['dates'] as $date) {
                 $date->store();
             }
         }
     }
     $messages = $course->getStackedMessages();
     foreach ($messages as $type => $msg) {
         PageLayout::postMessage(MessageBox::$type($msg['title'], $msg['details']));
     }
     if (Request::submitted('save_close')) {
         $this->relocate(str_replace('_', '/', Request::get('origin')), array('cid' => $course_id));
     } else {
         $this->redirect($this->url_for('course/timesrooms/index', array('cid' => $course_id)));
     }
 }
 /**
  * Import and update the dates
  */
 public function afterUpdate(SimpleORMap $object, $line)
 {
     $weekdays = array('so' => 0, 'su' => 0, 'mo' => 1, 'di' => 2, 'die' => 2, 'tue' => 2, 'mi' => 3, 'we' => 3, 'do' => 4, 'thu' => 4, 'fr' => 5, 'fri' => 5, 'sa' => 6);
     $zeiten = $line['zeit'];
     $zeiten = preg_split("/\\s*,\\s*/", $zeiten, null, PREG_SPLIT_NO_EMPTY);
     $singledates = array();
     $metadates = array();
     $import_type_dates = "karlsruhe_coursedates_import_" . $object->getId();
     $import_type_metadates = "karlsruhe_coursemetadates_import_" . $object->getId();
     foreach ($zeiten as $zeit) {
         if (!is_numeric(trim($zeit[0]))) {
             preg_match("/(\\w+) (\\d+):(\\d+)\\s*-\\s*(\\d+):(\\d+)/", $zeit, $matches);
             $day = strtolower($matches[1]);
             if (isset($weekdays[$day])) {
                 $statement = DBManager::get()->prepare("\n                        SELECT metadate_id \n                        FROM seminar_cycle_dates \n                        WHERE seminar_id = :course_id\n                            AND start_time = :start_time\n                            AND end_time = :end_time\n                            AND weekday = :weekday\n                    ");
                 $statement->execute(array('course_id' => $object->getId(), 'start_time' => $matches[2] . ":" . $matches[3] . ":00", 'end_time' => $matches[4] . ":" . $matches[5] . ":00", 'weekday' => $weekdays[$day]));
                 $found = false;
                 foreach ($statement->fetchAll(PDO::FETCH_COLUMN) as $cycle_id) {
                     if (FleximportMappedItem::findbyItemId($cycle_id, $import_type_metadates)) {
                         $found = $cycle_id;
                         break;
                     }
                 }
                 if (!$found) {
                     /*$semester = $object->end_semester;
                       $cycle = new SeminarCycleDate(); //Does not work yet
                       $cycle['seminar_id'] = $object->getId();
                       $cycle->start_hour = $matches[2];
                       $cycle->start_minute = $matches[3];
                       $cycle->end_hour = $matches[4];
                       $cycle->end_minute = $matches[5];
                       $cycle['weekday'] = $weekdays[$day];
                       $cycle['week_offset'] = 0;
                       $cycle['end_offset'] = floor(($semester->ende - $semester->beginn) / (7*24*60*60)) - 2;
                       $cycle['cycle'] = 0; //wöchentlich
                       $cycle->store();
                       $cycle_id = $cycle->getId();*/
                     $seminar = new Seminar($object->getId());
                     $cycle_id = $seminar->addCycle(array('day' => $weekdays[$day], 'start_stunde' => $matches[2], 'start_minute' => $matches[3], 'end_stunde' => $matches[4], 'end_minute' => $matches[5], 'week_offset' => 0, 'startWeek' => 0, 'turnus' => 0));
                     $mapped = new FleximportMappedItem();
                     $mapped['table_id'] = $import_type_metadates;
                     $mapped['item_id'] = $cycle_id;
                     $mapped->store();
                     $metadates[] = $cycle_id;
                 } else {
                     $seminar = new Seminar($object->getId());
                     $seminar->editCycle(array('cycle_id' => $found, 'day' => $weekdays[$day], 'start_stunde' => $matches[2], 'start_minute' => $matches[3], 'end_stunde' => $matches[4], 'end_minute' => $matches[5], 'week_offset' => 0, 'startWeek' => 0, 'turnus' => 0));
                     /*$semester = $object->end_semester;
                       $cycle = new SeminarCycleDate($found);
                       $cycle['seminar_id'] = $object->getId();
                       $cycle->start_hour = $matches[2];
                       $cycle->start_minute = $matches[3];
                       $cycle->end_hour = $matches[4];
                       $cycle->end_minute = $matches[5];
                       $cycle['weekday'] = $weekdays[$day];
                       $cycle['cycle'] = 0; //wöchentlich
                       $cycle['week_offset'] = 0;
                       $cycle['end_offset'] = floor(($semester->ende - $semester->beginn) / (7*24*60*60)) - 2;
                       $cycle->store();*/
                     $metadates[] = $found;
                 }
             }
         } else {
             //$zeit = explode("-", $zeit);
             preg_match("/(\\d{4}-\\d{1,2}-\\d{1,2}\\s+\\d{1,2}:\\d{1,2})\\s*-\\s(\\d{4}-\\d{1,2}-\\d{1,2}\\s+\\d{1,2}:\\d{1,2})/", $zeit, $matches);
             $begin = strtotime($matches[1]);
             $end = strtotime($matches[2]);
             $found = false;
             $dates = CourseDate::findBySQL("range_id = :course_id AND date = :begin AND end_time = :end", array('course_id' => $object->getId(), 'begin' => $begin, 'end' => $end));
             foreach ($dates as $date) {
                 if (FleximportMappedItem::findbyItemId($date->getId(), $import_type_dates)) {
                     $found = true;
                     $singledates[] = $date->getId();
                     break;
                 }
             }
             if (!$found) {
                 $date = new CourseDate();
                 $date['range_id'] = $object->getId();
                 $date['date'] = $begin;
                 $date['end_time'] = $end;
                 $date->store();
                 $mapped = new FleximportMappedItem();
                 $mapped['table_id'] = $import_type_dates;
                 $mapped['item_id'] = $date->getId();
                 $mapped->store();
                 $singledates[] = $date->getId();
             }
         }
     }
     $items = FleximportMappedItem::findBySQL("table_id = :table_id AND item_id NOT IN (:ids)", array('table_id' => $import_type_dates, 'ids' => $singledates ?: ""));
     foreach ($items as $item) {
         $date = new CourseDate($item['item_id']);
         $date->delete();
         $item->delete();
     }
     $items = FleximportMappedItem::findBySQL("table_id = :table_id AND item_id NOT IN (:ids)", array('table_id' => $import_type_metadates, 'ids' => $metadates ?: ""));
     foreach ($items as $item) {
         $cycle = new SeminarCycleDate($item['item_id']);
         $cycle->delete();
     }
 }
Example #7
0
    /**
     *  Deletes the current seminar
     *
     * @return void       returns success-message if seminar could be deleted
     *                    otherwise an  error-message
     */

    public function delete()
    {
        $s_id = $this->id;

        // Delete that Seminar.

        // Alle Benutzer aus dem Seminar rauswerfen.
        $query = "DELETE FROM seminar_user WHERE Seminar_id = ?";
        $statement = DBManager::get()->prepare($query);
        $statement->execute(array($s_id));
        if (($db_ar = $statement->rowCount()) > 0) {
            $this->createMessage(sprintf(_("%s Teilnehmende und Lehrende archiviert."), $db_ar));
        }

        // Alle Benutzer aus Wartelisten rauswerfen
        $query = "DELETE FROM admission_seminar_user WHERE seminar_id = ?";
        $statement = DBManager::get()->prepare($query);
        $statement->execute(array($s_id));

        // Alle beteiligten Institute rauswerfen
        $query = "DELETE FROM seminar_inst WHERE Seminar_id = ?";
        $statement = DBManager::get()->prepare($query);
        $statement->execute(array($s_id));
        if (($db_ar = $statement->rowCount()) > 0) {
            $this->createMessage(sprintf(_("%s Zuordnungen zu Einrichtungen archiviert."), $db_ar));
        }

        // user aus den Statusgruppen rauswerfen
        $count = DeleteAllStatusgruppen($s_id);
        if ($count > 0) {
            $this->createMessage(_("Einträge aus Funktionen / Gruppen gelöscht."));
        }

        // Alle Eintraege aus dem Vorlesungsverzeichnis rauswerfen
        $db_ar = StudipSemTree::DeleteSemEntries(null, $s_id);
        if ($db_ar > 0) {
            $this->createMessage(sprintf(_("%s Zuordnungen zu Bereichen archiviert."), $db_ar));
        }

        // Alle Termine mit allem was dranhaengt zu diesem Seminar loeschen.
        if (($db_ar = SingleDateDB::deleteAllDates($s_id)) > 0) {
            $this->createMessage(sprintf(_("%s Veranstaltungstermine archiviert."), $db_ar));
        }

        //Themen
        IssueDB::deleteAllIssues($s_id);

        //Cycles
        SeminarCycleDate::deleteBySQL('seminar_id = ' . DBManager::get()->quote($s_id));

        // Alle weiteren Postings zu diesem Seminar in den Forums-Modulen löschen
        foreach (PluginEngine::getPlugins('ForumModule') as $plugin) {
            $plugin->deleteContents($s_id);  // delete content irrespective of plugin-activation in the seminar

            if ($plugin->isActivated($s_id)) {   // only show a message, if the plugin is activated, to not confuse the user
                $this->createMessage(sprintf(_('Einträge in %s archiviert.'), $plugin->getPluginName()));
            }
        }


        // Alle Dokumente zu diesem Seminar loeschen.
        if (($db_ar = delete_all_documents($s_id)) > 0) {
            $this->createMessage(sprintf(_("%s Dokumente und Ordner archiviert."), $db_ar));
        }

        // Freie Seite zu diesem Seminar löschen
        $query = "DELETE FROM scm WHERE range_id = ?";
        $statement = DBManager::get()->prepare($query);
        $statement->execute(array($s_id));
        if (($db_ar = $statement->rowCount()) > 0) {
            $this->createMessage(_("Freie Seite der Veranstaltung archiviert."));
        }

        // delete literatur
        $del_lit = StudipLitList::DeleteListsByRange($s_id);
        if ($del_lit) {
            $this->createMessage(sprintf(_("%s Literaturlisten archiviert."),$del_lit['list']));
        }

        // Alle News-Verweise auf dieses Seminar löschen
        if ( ($db_ar = StudipNews::DeleteNewsRanges($s_id)) ) {
            $this->createMessage(sprintf(_("%s Ankündigungen gelöscht."), $db_ar));
        }
        //delete entry in news_rss_range
        StudipNews::UnsetRssId($s_id);

        //kill the datafields
        DataFieldEntry::removeAll($s_id);

        //kill all wiki-pages
        $query = "DELETE FROM wiki WHERE range_id = ?";
        $statement = DBManager::get()->prepare($query);
        $statement->execute(array($s_id));
        if (($db_wiki = $statement->rowCount()) > 0) {
            $this->createMessage(sprintf(_("%s Wiki-Seiten archiviert."), $db_wiki));
        }

        $query = "DELETE FROM wiki_links WHERE range_id = ?";
        $statement = DBManager::get()->prepare($query);
        $statement->execute(array($s_id));

        $query = "DELETE FROM wiki_locks WHERE range_id = ?";
        $statement = DBManager::get()->prepare($query);
        $statement->execute(array($s_id));

        // kill all the ressources that are assigned to the Veranstaltung (and all the linked or subordinated stuff!)
        if (Config::get()->RESOURCES_ENABLE) {
            $killAssign = new DeleteResourcesUser($s_id);
            $killAssign->delete();
            if ($rr = RoomRequest::existsByCourse($s_id)) {
                RoomRequest::find($rr)->delete();
            }
        }

        // kill virtual seminar-entries in calendar
        $query = "DELETE FROM schedule_seminare WHERE seminar_id = ?";
        $statement = DBManager::get()->prepare($query);
        $statement->execute(array($s_id));

        if(get_config('ELEARNING_INTERFACE_ENABLE')){
            global $connected_cms;
            $del_cms = 0;
            $cms_types = ObjectConnections::GetConnectedSystems($s_id);
            if(count($cms_types)){
                foreach($cms_types as $system){
                    ELearningUtils::loadClass($system);
                    $del_cms += $connected_cms[$system]->deleteConnectedModules($s_id);
                }
                $this->createMessage(sprintf(_("%s Verknüpfungen zu externen Systemen gelöscht."), $del_cms ));
            }
        }

        //kill the object_user_vists for this seminar
        object_kill_visits(null, $s_id);

        // Logging...
        $query = "SELECT CONCAT(seminare.VeranstaltungsNummer, ' ', seminare.name, '(', semester_data.name, ')')
                  FROM seminare
                  LEFT JOIN semester_data ON (seminare.start_time = semester_data.beginn)
                  WHERE seminare.Seminar_id='$s_id'";
        $statement = DBManager::get()->prepare($query);
        $statement->execute(array($s_id));
        $semlogname = $statement->fetchColumn() ?: sprintf('unknown sem_id: %s', $s_id);

        StudipLog::log("SEM_ARCHIVE",$s_id,NULL,$semlogname);
        // ...logged

        // delete deputies if necessary
        deleteAllDeputies($s_id);

        UserDomain::removeUserDomainsForSeminar($s_id);

        AutoInsert::deleteSeminar($s_id);

        //Anmeldeset Zordnung entfernen
        $cs = $this->getCourseSet();
        if ($cs) {
            CourseSet::removeCourseFromSet($cs->getId(), $this->getId());
            $cs->load();
            if (!count($cs->getCourses())
                && $cs->isGlobal()
                && $cs->getUserid() != '') {
                $cs->delete();
            }
        }
        AdmissionPriority::unsetAllPrioritiesForCourse($this->getId());
        // und das Seminar loeschen.
        $this->course->delete();
        $this->restore();
        return true;
    }
Example #8
0
 /**
  * load all cycledates from database
  */
 function restore()
 {
     $this->cycles = array();
     foreach (SeminarCycleDate::findBySeminar($this->seminar_id) as $c) {
         $this->cycles[$c->getId()] = new CycleData($c);
     }
 }
Example #9
0
 /**
  * Stores this cycle.
  * @return int number of changed rows
  */
 public function store()
 {
     $cycle = parent::findByMetadate_id($this->metadate_id);
     //create new entry in seminare_cycle_date
     if (!$cycle) {
         $result = parent::store();
         if ($result) {
             $new_dates = $this->createTerminSlots();
             foreach ($new_dates as $semester_dates) {
                 foreach ($semester_dates['dates'] as $date) {
                     $result += $date->store();
                 }
             }
             StudipLog::log('SEM_ADD_CYCLE', $this->seminar_id, NULL, $this->toString());
             return $result;
         }
         return 0;
     }
     //change existing cycledate, changes also corresponding single dates
     $old_cycle = SeminarCycleDate::find($this->metadate_id);
     if (!parent::store()) {
         return false;
     }
     if (mktime($this->start_time) >= mktime($old_cycle->start_time) && mktime($this->end_time) <= mktime($old_cycle->end_time) && $this->weekday == $old_cycle->weekday && $this->end_offset == $old_cycle->end_offset) {
         $update_count = 0;
         foreach ($this->getAllDates() as $date) {
             $tos = $date->date;
             $toe = $date->end_time;
             //Update future dates
             if ($toe > time()) {
                 $date->date = mktime(date('G', strtotime($this->start_time)), date('i', strtotime($this->start_time)), 0, date('m', $tos), date('d', $tos), date('Y', $tos));
                 $date->end_time = mktime(date('G', strtotime($this->end_time)), date('i', strtotime($this->end_time)), 0, date('m', $toe), date('d', $toe), date('Y', $toe));
             }
             if ($date->isDirty()) {
                 $date->store();
                 $update_count++;
             }
         }
         StudipLog::log('SEM_CHANGE_CYCLE', $this->seminar_id, NULL, $old_cycle->toString() . ' -> ' . $this->toString());
         return $update_count;
     }
     //collect topics for existing future dates (CourseDate)
     $topics = array();
     foreach ($this->getAllDates() as $date) {
         if ($date->end_time >= time()) {
             $topics_tmp = CourseTopic::findByTermin_id($date->termin_id);
             if (!empty($topics_tmp)) {
                 $topics[] = $topics_tmp;
             }
             //uncomment below
             $date->delete();
         }
     }
     $new_dates = $this->createTerminSlots(time());
     $topic_count = 0;
     $update_count = 0;
     foreach ($new_dates as $semester_dates) {
         foreach ($semester_dates['dates'] as $date) {
             if ($date instanceof CourseDate) {
                 if (isset($topics[$topic_count])) {
                     $date->topics = $topics[$topic_count];
                     $topic_count++;
                 }
             }
             $date->store();
             $update_count++;
         }
     }
     StudipLog::log('SEM_CHANGE_CYCLE', $this->seminar_id, NULL, $old_cycle->toString() . ' -> ' . $this->toString());
     return $update_count;
 }