Exemplo n.º 1
0
 /**
  * This action remove a user from course
  * @param $course_id
  */
 public function decline_action($course_id, $waiting = null)
 {
     $current_seminar = Seminar::getInstance($course_id);
     $ticket_check = Seminar_Session::check_ticket(Request::option('studipticket'));
     if (LockRules::Check($course_id, 'participants')) {
         $lockdata = LockRules::getObjectRule($course_id);
         PageLayout::postMessage(MessageBox::error(sprintf(_("Sie können sich nicht von der Veranstaltung <b>%s</b> abmelden."), htmlReady($current_seminar->name))));
         if ($lockdata['description']) {
             PageLayout::postMessage(MessageBox::info(formatLinks($lockdata['description'])));
         }
         $this->redirect('my_courses/index');
         return;
     }
     if (Request::option('cmd') == 'back') {
         $this->redirect('my_courses/index');
         return;
     }
     if (Request::option('cmd') != 'kill' && Request::option('cmd') != 'kill_admission') {
         if ($current_seminar->admission_binding && Request::get('cmd') != 'suppose_to_kill_admission' && !LockRules::Check($current_seminar->getId(), 'participants')) {
             PageLayout::postMessage(MessageBox::error(sprintf(_("Die Veranstaltung <b>%s</b> ist als <b>bindend</b> angelegt.\n                    Wenn Sie sich abmelden wollen, müssen Sie sich an die Lehrende der Veranstaltung wenden."), htmlReady($current_seminar->name))));
             $this->redirect('my_courses/index');
             return;
         }
         if (Request::get('cmd') == 'suppose_to_kill') {
             // check course admission
             list(, $admission_end_time) = @array_values($current_seminar->getAdmissionTimeFrame());
             $admission_enabled = $current_seminar->isAdmissionEnabled();
             $admission_locked = $current_seminar->isAdmissionLocked();
             if ($admission_enabled || $admission_locked || (int) $current_seminar->admission_prelim == 1) {
                 $message = sprintf(_('Wollen Sie sich von der teilnahmebeschränkten Veranstaltung "%s" wirklich abmelden? Sie verlieren damit die Berechtigung für die Veranstaltung und müssen sich ggf. neu anmelden!'), $current_seminar->name);
             } else {
                 if (isset($admission_end_time) && $admission_end_time < time()) {
                     $message = sprintf(_('Wollen Sie sich von der teilnahmebeschränkten Veranstaltung "%s" wirklich abmelden? Der Anmeldzeitraum ist abgelaufen und Sie können sich nicht wieder anmelden!'), $current_seminar->name);
                 } else {
                     $message = sprintf(_('Wollen Sie sich von der Veranstaltung "%s" wirklich abmelden?'), $current_seminar->name);
                 }
             }
             $this->flash['cmd'] = 'kill';
         } else {
             if (admission_seminar_user_get_position($GLOBALS['user']->id, $course_id) === false) {
                 $message = sprintf(_('Wollen Sie sich von der Anmeldeliste der Veranstaltung "%s" wirklich abmelden?'), $current_seminar->name);
             } else {
                 $message = sprintf(_('Wollen Sie sich von der Warteliste der Veranstaltung "%s" wirklich abmelden? Sie verlieren damit die bereits erreichte Position und müssen sich ggf. neu anmelden!'), $current_seminar->name);
             }
             $this->flash['cmd'] = 'kill_admission';
         }
         $this->flash['decline_course'] = true;
         $this->flash['course_id'] = $course_id;
         $this->flash['message'] = $message;
         $this->flash['studipticket'] = Seminar_Session::get_ticket();
         $this->redirect('my_courses/index');
         return;
     } else {
         if (!LockRules::Check($course_id, 'participants') && $ticket_check && Request::option('cmd') != 'back' && Request::get('cmd') != 'kill_admission') {
             $query = "DELETE FROM seminar_user WHERE user_id = ? AND Seminar_id = ?";
             $statement = DBManager::get()->prepare($query);
             $statement->execute(array($GLOBALS['user']->id, $course_id));
             if ($statement->rowCount() == 0) {
                 PageLayout::postMessage(MessageBox::error(_('In der ausgewählten Veranstaltung wurde die gesuchten Personen nicht gefunden und konnte daher nicht ausgetragen werden.')));
             } else {
                 // LOGGING
                 StudipLog::log('SEM_USER_DEL', $course_id, $GLOBALS['user']->id, 'Hat sich selbst ausgetragen');
                 // enable others to do something after the user has been deleted
                 NotificationCenter::postNotification('UserDidLeaveCourse', $course_id, $GLOBALS['user']->id);
                 // Delete from statusgroups
                 RemovePersonStatusgruppeComplete(get_username(), $course_id);
                 // Are successor available
                 update_admission($course_id);
                 PageLayout::postMessage(MessageBox::success(sprintf(_("Erfolgreich von Veranstaltung <b>%s</b> abgemeldet."), htmlReady($current_seminar->name))));
             }
         } else {
             // LOGGING
             StudipLog::log('SEM_USER_DEL', $course_id, $GLOBALS['user']->id, 'Hat sich selbst aus der Warteliste ausgetragen');
             if ($current_seminar->isAdmissionEnabled()) {
                 $prio_delete = AdmissionPriority::unsetPriority($current_seminar->getCourseSet()->getId(), $GLOBALS['user']->id, $course_id);
             }
             $query = "DELETE FROM admission_seminar_user WHERE user_id = ? AND seminar_id = ?";
             $statement = DBManager::get()->prepare($query);
             $statement->execute(array($GLOBALS['user']->id, $course_id));
             if ($statement->rowCount() || $prio_delete) {
                 //Warteliste neu sortieren
                 renumber_admission($course_id);
                 //Pruefen, ob es Nachruecker gibt
                 update_admission($course_id);
                 PageLayout::postMessage(MessageBox::success(sprintf(_("Der Eintrag in der Anmelde- bzw. Warteliste der Veranstaltung <b>%s</b> wurde aufgehoben.\n                    Wenn Sie an der Veranstaltung teilnehmen wollen, müssen Sie sich erneut bewerben."), htmlReady($current_seminar->name))));
             }
         }
         $this->redirect('my_courses/index');
         return;
     }
 }
Exemplo n.º 2
0
 /**
  * adds user with given id as preliminary member to course
  *
  * @param string $user_id
  * @return integer 1 if successfull
  */
 public function addPreliminaryMember($user_id, $comment = '')
 {
     $new_admission_member = new AdmissionApplication();
     $new_admission_member->user_id = $user_id;
     $new_admission_member->position = 0;
     $new_admission_member->status = 'accepted';
     $new_admission_member->comment = $comment;
     $this->course->admission_applicants[] = $new_admission_member;
     $ok = $new_admission_member->store();
     if ($ok && $this->isStudygroup()) {
         StudygroupModel::applicationNotice($this->getId(), $user_id);
     }
     $cs = $this->getCourseSet();
     if ($cs) {
         $prio_delete = AdmissionPriority::unsetPriority($cs->getId(), $user_id, $this->getId());
     }
     // LOGGING
     StudipLog::log('SEM_USER_ADD', $this->getId(), $user_id, 'accepted', 'Vorläufig akzeptiert');
     return $ok;
 }
Exemplo n.º 3
0
 /**
  * Prioritize courses.
  */
 function claim_action()
 {
     CSRFProtection::verifyUnsafeRequest();
     $user_id = $GLOBALS['user']->id;
     $courseset = CourseSet::getSetForCourse($this->course_id);
     if ($courseset->isSeatDistributionEnabled() && !count($courseset->checkAdmission($user_id, $this->course_id))) {
         if ($limit = $courseset->getAdmissionRule('LimitedAdmission')) {
             $admission_user_limit = Request::int('admission_user_limit');
             if ($admission_user_limit && $admission_user_limit <= $limit->getMaxNumber()) {
                 $limit->setCustomMaxNumber($user_id, $admission_user_limit);
             }
             $admission_prio = Request::getArray('admission_prio');
             $max_prio = max($admission_prio);
             $admission_prio = array_map(function ($a) use(&$max_prio) {
                 return $a > 0 ? $a : ++$max_prio;
             }, $admission_prio);
             if (count(array_unique($admission_prio)) != count(Request::getArray('admission_prio'))) {
                 PageLayout::postMessage(MessageBox::info(_("Sie dürfen jede Priorität nur einmal auswählen. Überprüfen Sie bitte Ihre Auswahl!")));
             }
             $old_prio_count = AdmissionPriority::unsetAllPrioritiesForUser($courseset->getId(), $user_id);
             if ($order_up = key(Request::getArray('admission_prio_order_up'))) {
                 $prio_to_move = $admission_prio[$order_up];
                 $change_with = array_search($prio_to_move - 1, $admission_prio);
                 $admission_prio[$order_up] = $prio_to_move - 1;
                 $admission_prio[$change_with] = $prio_to_move;
             }
             if ($order_down = key(Request::getArray('admission_prio_order_down'))) {
                 $prio_to_move = $admission_prio[$order_down];
                 $change_with = array_search($prio_to_move + 1, $admission_prio);
                 $admission_prio[$order_down] = $prio_to_move + 1;
                 $admission_prio[$change_with] = $prio_to_move;
             }
             if ($delete = key(Request::getArray('admission_prio_delete'))) {
                 unset($admission_prio[$delete]);
                 $changed = 1;
                 $admission_prio = array_map(function ($a) {
                     static $c = 1;
                     return $c++;
                 }, $admission_prio);
             }
             foreach ($admission_prio as $course_id => $p) {
                 $changed += AdmissionPriority::setPriority($courseset->getId(), $user_id, $course_id, $p);
             }
             if ($changed || $old_prio_count && !count($admission_prio)) {
                 if (count(AdmissionPriority::getPrioritiesByUser($courseset->getId(), $user_id))) {
                     PageLayout::postMessage(MessageBox::success(_("Ihre Priorisierung wurde gespeichert.")));
                 } else {
                     PageLayout::postMessage(MessageBox::success(_("Ihre Anmeldung zur Platzvergabe wurde zurückgezogen.")));
                 }
             }
         } else {
             if (Request::int('courseset_claimed')) {
                 if (AdmissionPriority::setPriority($courseset->getId(), $user_id, $this->course_id, 1)) {
                     PageLayout::postMessage(MessageBox::success(_("Ihre Anmeldung zur Platzvergabe wurde gespeichert.")));
                 }
             } else {
                 if (AdmissionPriority::unsetPriority($courseset->getId(), $user_id, $this->course_id)) {
                     PageLayout::postMessage(MessageBox::success(_("Ihre Anmeldung zur Platzvergabe wurde zurückgezogen.")));
                 }
             }
         }
     }
     $this->redirect($this->url_for('/apply/' . $this->course_id));
 }
Exemplo n.º 4
0
/**
 * Insert a user into a seminar with optional log-message and contingent
 *
 * @param string   $seminar_id
 * @param string   $user_id
 * @param string   $status       status of user in the seminar (user, autor, tutor, dozent)
 * @param boolean  $copy_studycourse  if true, the studycourse is copied from admission_seminar_user
 *                                    to seminar_user. Overrides the $contingent-parameter
 * @param string   $contingent   optional studiengang_id, if no id is given, no contingent is considered
 * @param string   $log_message  optional log-message. if no log-message is given a default one is used
 * @return void
 */
function insert_seminar_user($seminar_id, $user_id, $status, $copy_studycourse = false, $contingent = false, $log_message = false) {
    // get the seminar-object
    $sem = Seminar::GetInstance($seminar_id);

    $admission_status = '';
    $admission_comment = '';
    $mkdate = time();

    $stmt = DBManager::get()->prepare("SELECT * FROM admission_seminar_user
            WHERE seminar_id = ? AND user_id = ?");
    $stmt->execute(array($seminar_id, $user_id));
    if ($data = $stmt->fetch(PDO::FETCH_ASSOC)) {
        // copy the studycourse from admission_seminar_user
        if ($copy_studycourse && $data['studiengang_id']) {
            $contingent = $data['studiengang_id'];
        }
        $admission_status = $data['status'];
        $admission_comment = ($data['comment'] == NULL) ? '' : $data['comment'];
        $mkdate = $data['mkdate'];
    }

    // check if there are places left in the submitted contingent (if any)
    //ignore if preliminary
    if ($admission_status != 'accepted' && $contingent && $sem->isAdmissionEnabled() && !$sem->getFreeAdmissionSeats($contingent)) {
        return false;
    }

    // get coloured group as used on meine_seminare
    $colour_group = $sem->getDefaultGroup();

    // LOGGING
    // if no log message is submitted use a default one
    if (!$log_message) {
        $log_message = 'Wurde in die Veranstaltung eingetragen, admission_status: '. $admission_status . ' Kontingent: ' . $contingent;
    }
    log_event('SEM_USER_ADD', $seminar_id, $user_id, $status, $log_message);

    // actually insert the user into the seminar
    $stmt = DBManager::get()->prepare('INSERT IGNORE INTO seminar_user
        (Seminar_id, user_id, status, comment, gruppe, mkdate)
        VALUES (?, ?, ?, ?, ?, ?)');
    $stmt->execute(array($seminar_id, $user_id, $status, $admission_comment, $colour_group, $mkdate));

    NotificationCenter::postNotification('UserDidEnterCourse', $seminar_id, $user_id);

    if ($admission_status) {
        // delete the entries, user is now in the seminar
        $stmt = DBManager::get()->prepare('DELETE FROM admission_seminar_user
            WHERE user_id = ? AND seminar_id = ?');
        $stmt->execute(array($user_id, $seminar_id));

        //renumber the waiting/accepted/lot list, a user was deleted from it
        renumber_admission($seminar_id);
    }
    $cs = $sem->getCourseSet();
    if ($cs) {
        $prio_delete = AdmissionPriority::unsetPriority($cs->getId(), $user_id, $sem->getId());
    }

    removeScheduleEntriesMarkedAsVirtual($user_id, $seminar_id);

    // reload the seminar, the contingents have changed
    $sem->restore();

    return true;
}
Exemplo n.º 5
0
 public function cancelAdmissionSubscription($users, $status)
 {
     $messaging = new messaging();
     $query = "DELETE FROM admission_seminar_user WHERE seminar_id = ? AND user_id = ? AND status = ?";
     $db = DBManager::get()->prepare($query);
     $cs = Seminar::GetInstance($this->course_id)->getCourseSet();
     foreach ($users as $user_id) {
         $temp_user = UserModel::getUser($user_id);
         if ($cs) {
             $prio_delete = AdmissionPriority::unsetPriority($cs->getId(), $user_id, $this->course_id);
         }
         $db->execute(array($this->course_id, $user_id, $status));
         if ($db->rowCount() > 0 || $prio_delete) {
             setTempLanguage($user_id);
             if ($status !== 'accepted') {
                 $message = sprintf(_("Sie wurden von %s oder Admin von der Warteliste der Veranstaltung **%s** gestrichen und sind damit __nicht__ zugelassen worden."), get_title_for_status('dozent', 1), $this->course_title);
             } else {
                 $message = sprintf(_("Sie wurden von %s oder Admin aus der Veranstaltung **%s** gestrichen und sind damit __nicht__ zugelassen worden."), get_title_for_status('dozent', 1), $this->course_title);
             }
             restoreLanguage();
             $messaging->insert_message($message, $temp_user['username'], '____%system%____', FALSE, FALSE, '1', FALSE, sprintf('%s %s', _('Systemnachricht:'), _("nicht zugelassen in Veranstaltung")), TRUE);
             log_event('SEM_USER_DEL', $this->course_id, $user_id, 'Wurde aus der Veranstaltung rausgeworfen');
             $msgs[] = $temp_user['Vorname'] . ' ' . $temp_user['Nachname'];
         }
     }
     return $msgs;
 }