function resource_message_action($resource_id) { $r_perms = new ResourceObjectPerms($resource_id, $GLOBALS['user']->id); if (!$r_perms->havePerm('admin')) { throw new AccessDeniedException(); } $this->resource = new ResourceObject($resource_id); $title = sprintf(_("Nutzer von %s benachrichtigen"), htmlReady($this->resource->getName())); $form_fields['start_day'] = array('type' => 'text', 'size' => '10', 'required' => true, 'caption' => _("Belegungen berücksichtigen von")); $form_fields['start_day']['attributes'] = array('onMouseOver' => 'jQuery(this).datepicker();this.blur();', 'onChange' => '$(this).closest("form").submit();'); $form_fields['start_day']['default_value'] = strftime('%x'); $form_fields['end_day'] = array('type' => 'text', 'size' => '10', 'required' => true, 'caption' => _("Belegungen berücksichtigen bis")); $form_fields['end_day']['attributes'] = array('onMouseOver' => 'jQuery(this).datepicker();this.blur();', 'onChange' => '$(this).closest("form").submit();'); $form_fields['end_day']['default_value'] = strftime('%x', strtotime('+6 months')); $form_fields['subject'] = array('type' => 'text', 'size' => '200', 'attributes' => array('style' => 'width:100%'), 'required' => true, 'caption' => _("Betreff")); $form_fields['subject']['default_value'] = $this->resource->getName(); $form_fields['message'] = array('caption' => _("Nachricht"), 'type' => 'textarea', 'required' => true, 'attributes' => array('rows' => 4, 'style' => 'width:100%')); $form_buttons['save_close'] = array('caption' => _('OK'), 'info' => _("Benachrichtigung verschicken und Dialog schließen")); $form = new StudipForm($form_fields, $form_buttons, 'resource_message', false); $start_time = strtotime($form->getFormFieldValue('start_day')); $end_time = strtotime($form->getFormFieldValue('end_day')); $assign_events = new AssignEventList($start_time, $end_time, $resource_id, '', '', TRUE, 'all'); $rec = array(); while ($event = $assign_events->nextEvent()) { if ($owner_type = $event->getOwnerType()) { if ($owner_type == 'date') { $seminar = new Seminar(Seminar::GetSemIdByDateId($event->getAssignUserId())); foreach ($seminar->getMembers('dozent') as $dozent) { $rec[$dozent['username']][] = strftime('%x %R', $event->begin) . ' - ' . strftime('%R', $event->end) . ' ' . $seminar->getName(); } } else { $rec[get_username($event->getAssignUserId())][] = strftime('%x %R', $event->begin) . ' - ' . strftime('%R', $event->end); } } } if ($form->isSended() && count($rec) && $form->getFormFieldValue('message')) { $messaging = new Messaging(); $ok = $messaging->insert_message($form->getFormFieldValue('message'), array_keys($rec), $GLOBALS['user']->id, null, null, null, '', $form->getFormFieldValue('subject'), true); PageLayout::postMessage(MessageBox::success(sprintf(_("Die Nachricht wurde an %s Nutzer verschickt"), $ok))); return $this->redirect(URLHelper::getUrl('resources.php?view=resources')); } if (!count($rec)) { PageLayout::postMessage(MessageBox::error(sprintf(_("Im Zeitraum %s - %s wurden keine Belegungen gefunden!"), strftime('%x', $start_time), strftime('%x', $end_time)))); $this->no_receiver = true; } else { $submessage = array(); foreach ($rec as $username => $slots) { $submessage[] = get_fullname_from_uname($username, 'full_rev_username', true) . ' ' . sprintf(_('(%s Belegungen)'), count($slots)); } PageLayout::postMessage(MessageBox::info(sprintf(_("Benachrichtigung an %s Nutzer verschicken"), count($rec)), $submessage, true)); } $this->form = $form; $this->response->add_header('X-Title', $title); }
/** * invites members to a studygroup. */ function execute_invite_action($id) { // Security Check global $perm; if (!$perm->have_studip_perm('tutor', $id)) { $this->redirect(URLHelper::getURL('seminar_main.php?auswahl=' . $id)); exit; } // load MultiPersonSearch object $mp = MultiPersonSearch::load("studygroup_invite_" . $id); $fail = false; $count = 0; $addedUsers = ""; foreach ($mp->getAddedUsers() as $receiver) { // save invite in database StudygroupModel::inviteMember($receiver, $id); // send invite message to user $msg = new Messaging(); $sem = new Seminar($id); $message = sprintf(_("%s möchte Sie auf die Studiengruppe %s aufmerksam machen. Klicken Sie auf den untenstehenden Link, um direkt zur Studiengruppe zu gelangen.\n\n %s"), get_fullname(), $sem->name, URLHelper::getlink("dispatch.php/course/studygroup/details/" . $id, array('cid' => NULL))); $subject = _("Sie wurden in eine Studiengruppe eingeladen"); $msg->insert_message($message, get_username($receiver), '', '', '', '', '', $subject); if ($count > 0) { $addedUsers .= ", "; } $addedUsers .= get_fullname($receiver, 'full', true); $count++; } if ($count == 1) { $this->flash['success'] = sprintf(_("%s wurde in die Studiengruppe eingeladen."), $addedUsers); } else { if ($count >= 1) { $this->flash['success'] = sprintf(_("%s wurden in die Studiengruppe eingeladen."), $addedUsers); } } $this->redirect($this->url_for('course/studygroup/members/' . $id, array('view' => Request::get('view')))); }
/** * If a new user applies, an application note to all moderators and founders * of a studygroup will be automatically sent while calling this function. * The note contains the user's name and a direct link to the member page of the studygroup. * * @param string $sem_id id of a seminar / studygroup * @param strimg $user_id id of the applicant * * @return int number of recipients */ function applicationNotice($sem_id, $user_id) { $sem = new Seminar($sem_id); $dozenten = $sem->getMembers(); $tutors = $sem->getMembers('tutor'); $recipients = array(); $msging = new Messaging(); foreach (array_merge($dozenten, $tutors) as $uid => $user) { $recipients[] = $user['username']; } if (studip_strlen($sem->getName()) > 32) { //cut subject if to long $subject = sprintf(_("[Studiengruppe: %s...]"), studip_substr($sem->getName(), 0, 30)); } else { $subject = sprintf(_("[Studiengruppe: %s]"), $sem->getName()); } if (StudygroupModel::isInvited($user_id, $sem_id)) { $subject .= " " . _("Einladung akzeptiert"); $message = sprintf(_("%s hat die Einladung zur Studiengruppe %s akzeptiert. Klicken Sie auf den untenstehenden Link, um direkt zur Studiengruppe zu gelangen.\n\n [Direkt zur Studiengruppe]%s"), get_fullname($user_id), $sem->getName(), URLHelper::getlink($GLOBALS['ABSOLUTE_URI_STUDIP'] . "dispatch.php/course/studygroup/members/" . $sem->id, array('cid' => $sem->id))); } else { $subject .= " " . _("Neuer Mitgliedsantrag"); $message = sprintf(_("%s möchte der Studiengruppe %s beitreten. Klicken Sie auf den untenstehenden Link, um direkt zur Studiengruppe zu gelangen.\n\n [Direkt zur Studiengruppe]%s"), get_fullname($user_id), $sem->getName(), URLHelper::getlink($GLOBALS['ABSOLUTE_URI_STUDIP'] . "dispatch.php/course/studygroup/members/" . $sem->id, array('cid' => $sem->id))); } return $msging->insert_message($message, $recipients, "____%system%____", '', '', '', '', $subject); }