Esempio n. 1
0
 /**
  * Deletes the course set and all associated data.
  */
 public function delete()
 {
     // Delete institute associations.
     $stmt = DBManager::get()->prepare("DELETE FROM `courseset_institute`\n            WHERE `set_id`=?");
     $stmt->execute(array($this->id));
     // Delete course associations.
     $stmt = DBManager::get()->prepare("DELETE FROM `seminar_courseset`\n            WHERE `set_id`=?");
     $stmt->execute(array($this->id));
     // Delete all rules...
     foreach ($this->rules as $rule) {
         $rule->delete();
     }
     // ... and their association to the current course set.
     $stmt = DBManager::get()->prepare("DELETE FROM `courseset_rule`\n            WHERE `set_id`=?");
     $stmt->execute(array($this->id));
     // Delete associations to user lists.
     $stmt = DBManager::get()->prepare("DELETE FROM `courseset_factorlist`\n            WHERE `set_id`=?");
     $stmt->execute(array($this->id));
     // Delete course set data.
     $stmt = DBManager::get()->prepare("DELETE FROM `coursesets`\n            WHERE `set_id`=?");
     $stmt->execute(array($this->id));
     /*
      * Delete waiting lists
      */
     foreach ($this->courses as $id => $assigned) {
         AdmissionApplication::deleteBySQL("status='awaiting' AND seminar_id=?", array($id));
     }
     //Delete priorities
     AdmissionPriority::unsetAllPriorities($this->getId());
 }
Esempio n. 2
0
 function getNumWaiting()
 {
     return AdmissionApplication::countBySql("seminar_id = ? AND status = 'awaiting'", array($this->id));
 }
Esempio n. 3
0
 /**
  * Store a comment for this user
  * @param String $user_id
  * @throws AccessDeniedException
  */
 public function set_comment_action($user_id = null)
 {
     // Security Check
     if (!$this->is_tutor) {
         throw new AccessDeniedException('Sie haben leider keine ausreichende Berechtigung, um auf diesen Bereich von Stud.IP zuzugreifen.');
     }
     CSRFProtection::verifyUnsafeRequest();
     $course_member = CourseMember::find(array($this->course_id, $user_id));
     if (!$course_member) {
         $course_member = AdmissionApplication::find(array($user_id, $this->course_id));
     }
     if (!Request::submitted('save') || is_null($course_member)) {
         throw new Trails_Exception(400);
     }
     $course_member->comment = Request::get('comment');
     if ($course_member->store() !== false) {
         PageLayout::postMessage(MessageBox::success(_('Bemerkung wurde erfolgreich gespeichert.')));
     } else {
         PageLayout::postMessage(MessageBox::error(_('Bemerkung konnte nicht erfolgreich gespeichert werden.')));
     }
     $this->redirect('course/members/index');
 }
Esempio n. 4
0
 /**
  * adds user with given id on waitinglist
  *
  * @param string $user_id
  * @param string $which_end 'last' or 'first'
  * @return integer 1 if successfull
  */
 public function addToWaitlist($user_id, $which_end = 'last')
 {
     if (AdmissionApplication::exists(array($user_id, $this->id)) || CourseMember::find(array($this->id, $user_id))) {
         return false;
     }
     switch ($which_end) {
         // Append users to waitlist end.
         case 'last':
             $maxpos = DBManager::get()->fetchColumn("SELECT MAX(`position`)
                 FROM `admission_seminar_user`
                 WHERE `seminar_id`=?
                     AND `status`='awaiting'", array($this->id));
             $waitpos = $maxpos+1;
             break;
         // Prepend users to waitlist start.
         case 'first':
         default:
             // Move all others on the waitlist up by the number of people to add.
             DBManager::get()->execute("UPDATE `admission_seminar_user`
                     SET `position`=`position`+1
                     WHERE `seminar_id`=?
                         AND `status`='awaiting'", array($this->id));
             $waitpos = 1;
     }
     $new_admission_member = new AdmissionApplication();
     $new_admission_member->user_id = $user_id;
     $new_admission_member->position = $waitpos;
     $new_admission_member->status = 'awaiting';
     $new_admission_member->seminar_id = $this->id;
     if ($new_admission_member->store()) {
         StudipLog::log('SEM_USER_ADD', $this->id, $user_id, 'awaiting', 'Auf Warteliste gesetzt, Position: ' . $waitpos);
         $this->course->resetRelation('admission_applicants');
         return 1;
     }
     return false;
 }
Esempio n. 5
0
 /**
  * Notify users that they couldn't get a seat but are now on the waiting
  * list for a given course.
  *
  * @param Array  $user_list Users to be notified
  * @param Course $course    The course without waiting list
  * @param int    $prio      User's priority for the given course.
  */
 private function addUsersToWaitlist($user_list, $course, $prio = null)
 {
     $maxpos = $course->admission_applicants->findBy('status', 'awaiting')->orderBy('position desc')->val('position');
     foreach ($user_list as $chosen_one) {
         $maxpos++;
         $new_admission_member = new AdmissionApplication();
         $new_admission_member->user_id = $chosen_one;
         $new_admission_member->position = $maxpos;
         $new_admission_member->status = 'awaiting';
         $course->admission_applicants[] = $new_admission_member;
         if ($new_admission_member->store()) {
             setTempLanguage($chosen_one);
             $message_title = sprintf(_('Teilnahme an der Veranstaltung %s'), $course->name);
             $message_body = sprintf(_('Sie wurden leider im Losverfahren der Veranstaltung **%s** __nicht__ ausgelost. Sie wurden jedoch auf Position %s auf die Warteliste gesetzt. Das System wird Sie automatisch eintragen und benachrichtigen, sobald ein Platz für Sie frei wird.'), $course->name, $maxpos);
             if ($prio) {
                 $message_body .= "\n" . sprintf(_("Sie hatten für diese Veranstaltung die Priorität %s gewählt."), $prio[$chosen_one]);
             }
             messaging::sendSystemMessage($chosen_one, $message_title, $message_body);
             restoreLanguage();
             StudipLog::log('SEM_USER_ADD', $course->id, $chosen_one, 'awaiting', 'Auf Warteliste gelost, Position: ' . $maxpos);
         }
     }
 }