/** * Saves an edited stack/cycle. * * @param String $cycle_id Id of the edited cycle to be saved. */ private function saveEditedStack($cycle_id = '') { $persons = Request::getArray('related_persons'); $action = Request::get('related_persons_action'); $groups = Request::getArray('related_groups'); $group_action = Request::get('related_groups_action'); $teacher_changed = false; $groups_changed = false; foreach ($_SESSION['_checked_dates'] as $singledate_id) { $singledate = CourseDate::find($singledate_id); if (!isset($singledate)) { $singledate = CourseExDate::find($singledate_id); } $singledates[] = $singledate; } // Update related persons if (in_array($action, words('add delete'))) { foreach ($singledates as $key => $singledate) { $dozenten = User::findDozentenByTermin_id($singledate->termin_id); $dozenten_new = $dozenten; if ($singledate->range_id === $this->course->id) { foreach ($persons as $user_id) { $is_in_list = false; foreach ($dozenten as $user_key => $user) { if ($user->user_id == $user_id) { $is_in_list = $user_key; } } if ($is_in_list === false && $action === 'add') { $dozenten_new[] = User::find($user_id); $teacher_changed = true; } else { if ($is_in_list !== false && $action === 'delete') { unset($dozenten_new[$is_in_list]); $teacher_changed = true; } } } } $singledates[$key]->dozenten = $dozenten_new; } } if ($teacher_changed) { $this->course->createMessage(_('Zuständige Personen für die Termine wurden geändert.')); } if (in_array($group_action, words('add delete'))) { foreach ($singledates as $key => $singledate) { $groups_db = Statusgruppen::findByTermin_id($singledate->termin_id); $groups_new = $groups_db; if ($singledate->range_id === $this->course->id) { foreach ($groups as $statusgruppe_id) { $is_in_list = false; foreach ($groups_db as $group_key => $group) { if ($statusgruppe_id == $group->statusgruppe_id) { $is_in_list = $group_key; } } if ($is_in_list === false && $group_action === 'add') { $groups_new[] = Statusgruppen::find($statusgruppe_id); $groups_changed = true; } elseif ($is_in_list !== false && $group_action === 'delete') { unset($groups_new[$is_in_list]); $groups_changed = true; } } } $singledates[$key]->statusgruppen = $groups_new; } } if ($groups_changed) { $this->course->createMessage(_('Zugewiesene Gruppen für die Termine wurden geändert.')); } foreach ($singledates as $key => $singledate) { if (Request::option('action') == 'room') { $singledate->raum = ''; ResourceAssignment::deleteBySQL('assign_user_id = :termin', array(':termin' => $singledate->termin_id)); $resObj = new ResourceObject($room_id); $room = new ResourceAssignment(); $room->assign_user_id = $singledate->termin_id; $room->resource_id = Request::get('room'); $room->begin = $singledate->date; $room->end = $singledate->end_time; $room->repeat_end = $singledate->end_time; $room->store(); } elseif (Request::option('action') == 'freetext') { ResourceAssignment::deleteBySQL('assign_user_id = :termin', array(':termin' => $singledate->termin_id)); $singledates[$key]->raum = Request::get('freeRoomText'); $this->course->createMessage(sprintf(_('Der Termin %s wurde geändert, etwaige ' . 'Raumbuchungen wurden entfernt und stattdessen der angegebene Freitext' . ' eingetragen!'), '<b>' . $singledate->getFullname() . '</b>')); } elseif (Request::option('action') == 'noroom') { ResourceAssignment::deleteBySQL('assign_user_id = :termin', array(':termin' => $singledate->termin_id)); $singledates[$key]->raum = ''; } } foreach ($singledates as $singledate) { $singledate->store(); } }
function vcard_action($group = null) { // Set constants for export $charset = 'utf-8'; $filename = _('Kontakte'); // Set layout $this->set_layout(null); // If we got an array of user if (Request::submitted('user')) { $user = User::findManyByUsername(Request::getArray('user')); } // If we got a group if ($group) { $user = User::findMany(Statusgruppen::find($group)->members->pluck('user_id')); } // Fallback to all contacts if we got nothing if (!$user) { $user = User::findCurrent()->contacts; } header("Content-type: text/x-vCard;charset=" . $charset); //application/octet-stream MIME header("Content-disposition: attachment; filename=" . $filename . ".vcf"); header("Pragma: private"); $this->vCard = vCard::export($user); }
/** * * * @param SingleCalendar The calendar of the group owner. * @return Statusgruppen The found group. * @throws AccessDeniedException If the group does not exists or the owner * of the calendar is not the owner of the group. */ private function getGroup($calendar) { $group = Statusgruppen::find($this->range_id); if (!$group) { throw new AccessDeniedException(); } // is the user the owner of this group if ($group->range_id != $calendar->getRangeId()) { // not the owner... throw new AccessDeniedException(); } return $group; }
private function requireContactGroup($group_id) { $group = \Statusgruppen::find($group_id); if (!$group) { $this->notFound(); } if ($group->range_id !== $GLOBALS['user']->id) { $this->error(401); } return $group; }
public function manage_access_action($range_id = null) { $this->range_id = $range_id ?: $this->range_id; $this->calendar = new SingleCalendar($this->range_id); $all_calendar_users = CalendarUser::getUsers($this->calendar->getRangeId()); $this->filter_groups = Statusgruppen::findByRange_id($this->calendar->getRangeId()); $this->users = array(); $this->group_filter_selected = Request::option('group_filter', 'list'); if ($this->group_filter_selected != 'list') { $contact_group = Statusgruppen::find($this->group_filter_selected); $calendar_users = array(); foreach ($contact_group->members as $member) { $calendar_users[] = new CalendarUser(array($this->calendar->getRangeId(), $member->user_id)); } $this->calendar_users = SimpleORMapCollection::createFromArray($calendar_users); } else { $this->group_filter_selected = 'list'; $this->calendar_users = $all_calendar_users; } $this->own_perms = array(); foreach ($this->calendar_users as $calendar_user) { $other_user = CalendarUser::find(array($calendar_user->user_id, $this->calendar->getRangeId())); if ($other_user) { $this->own_perms[$calendar_user->user_id] = $other_user->permission; } else { $this->own_perms[$calendar_user->user_id] = Calendar::PERMISSION_FORBIDDEN; } $this->users[strtoupper(SimpleCollection::translitLatin1($calendar_user->nachname[0]))][] = $calendar_user; } ksort($this->users); $this->users = array_map(function ($g) { return SimpleCollection::createFromArray($g)->orderBy('nachname, vorname'); }, $this->users); $this->mps = MultiPersonSearch::get('calendar-manage_access')->setTitle(_('Personhinzufügen'))->setLinkText(_('Person hinzufügen'))->setDefaultSelectedUser($all_calendar_users->pluck('user_id'))->setJSFunctionOnSubmit('STUDIP.CalendarDialog.closeMps')->setExecuteURL($this->url_for('calendar/single/add_users/' . $this->calendar->getRangeId()))->setSearchObject(new StandardSearch('user_id')); PageLayout::setTitle($this->getTitle($this->calendar, _('Kalender freigeben'))); $this->createSidebar('manage_access', $this->calendar); $this->createSidebarFilter(); }
/** * Lets the user compose a message and send it. */ public function write_action() { PageLayout::setTitle(_("Neue Nachricht schreiben")); //collect possible default adressees $this->to = array(); $this->default_message = new Message(); if (Request::username("rec_uname")) { $user = new MessageUser(); $user->setData(array('user_id' => get_userid(Request::username("rec_uname")), 'snd_rec' => "rec")); $this->default_message->receivers[] = $user; } if (Request::getArray("rec_uname")) { foreach (Request::usernameArray("rec_uname") as $username) { $user = new MessageUser(); $user->setData(array('user_id' => get_userid($username), 'snd_rec' => "rec")); $this->default_message->receivers[] = $user; } } if (Request::option("group_id")) { $this->default_message->receivers = array(); $group = Statusgruppen::find(Request::option("group_id")); if ($group['range_id'] === $GLOBALS['user']->id || $GLOBALS['perm']->have_studip_perm("autor", $group['range_id'])) { foreach ($group->members as $member) { $user = new MessageUser(); $user->setData(array('user_id' => $member['user_id'], 'snd_rec' => "rec")); $this->default_message->receivers[] = $user; } } } if (Request::get('inst_id') && $GLOBALS['perm']->have_perm('admin')) { $query = "SELECT user_id FROM user_inst WHERE Institut_id = ? AND inst_perms != 'user'"; $this->default_message->receivers = DBManager::get()->fetchAll($query, array(Request::option('inst_id')), 'MessageUser::build'); } if (Request::get("filter") && Request::option("course_id")) { $course = new Course(Request::option('course_id')); if ($GLOBALS['perm']->have_studip_perm("tutor", Request::option('course_id')) || $course->getSemClass()['studygroup_mode']) { $this->default_message->receivers = array(); if (Request::get("filter") === 'claiming') { $cs = CourseSet::getSetForCourse(Request::option("course_id")); if (is_object($cs) && !$cs->hasAlgorithmRun()) { foreach (AdmissionPriority::getPrioritiesByCourse($cs->getId(), Request::option("course_id")) as $user_id => $p) { $this->default_message->receivers[] = MessageUser::build(array('user_id' => $user_id, 'snd_rec' => 'rec')); } } } else { $params = array(Request::option('course_id'), Request::option('who')); switch (Request::get("filter")) { case 'send_sms_to_all': $query = "SELECT b.user_id,'rec' as snd_rec FROM seminar_user a, auth_user_md5 b WHERE a.Seminar_id = ? AND a.user_id = b.user_id AND a.status = ? ORDER BY Nachname, Vorname"; break; case 'all': $query = "SELECT user_id,'rec' as snd_rec FROM seminar_user LEFT JOIN auth_user_md5 USING(user_id) WHERE Seminar_id = ? ORDER BY Nachname, Vorname"; break; case 'prelim': $query = "SELECT user_id,'rec' as snd_rec FROM admission_seminar_user LEFT JOIN auth_user_md5 USING(user_id) WHERE seminar_id = ? AND status='accepted' ORDER BY Nachname, Vorname"; break; case 'awaiting': $query = "SELECT user_id,'rec' as snd_rec FROM admission_seminar_user LEFT JOIN auth_user_md5 USING(user_id) WHERE seminar_id = ? AND status='awaiting' ORDER BY Nachname, Vorname"; break; case 'inst_status': $query = "SELECT b.user_id,'rec' as snd_rec FROM user_inst a, auth_user_md5 b WHERE a.Institut_id = ? AND a.user_id = b.user_id AND a.inst_perms = ? ORDER BY Nachname, Vorname"; break; } $this->default_message->receivers = DBManager::get()->fetchAll($query, $params, 'MessageUser::build'); } } } if (Request::option('prof_id') && Request::option('deg_id') && $GLOBALS['perm']->have_perm('root')) { $query = "SELECT DISTINCT user_id,'rec' as snd_rec\n FROM user_studiengang\n WHERE studiengang_id = ? AND abschluss_id = ?"; $this->default_message->receivers = DBManager::get()->fetchAll($query, array(Request::option('prof_id'), Request::option('deg_id')), 'MessageUser::build'); } if (Request::option('sd_id') && $GLOBALS['perm']->have_perm('root')) { $query = "SELECT DISTINCT user_id,'rec' as snd_rec\n FROM user_studiengang\n WHERE abschluss_id = ?"; $this->default_message->receivers = DBManager::get()->fetchAll($query, array(Request::option('sd_id')), 'MessageUser::build'); } if (Request::option('sp_id') && $GLOBALS['perm']->have_perm('root')) { $query = "SELECT DISTINCT user_id,'rec' as snd_rec\n FROM user_studiengang\n WHERE studiengang_id = ?"; $this->default_message->receivers = DBManager::get()->fetchAll($query, array(Request::option('sp_id')), 'MessageUser::build'); } if (!$this->default_message->receivers->count() && is_array($_SESSION['sms_data']['p_rec'])) { $this->default_message->receivers = DBManager::get()->fetchAll("SELECT user_id,'rec' as snd_rec FROM auth_user_md5 WHERE username IN(?) ORDER BY Nachname,Vorname", array($_SESSION['sms_data']['p_rec']), 'MessageUser::build'); unset($_SESSION['sms_data']); } if (Request::option("answer_to")) { $this->default_message->receivers = array(); $old_message = new Message(Request::option("answer_to")); if (!$old_message->permissionToRead()) { throw new AccessDeniedException("Message is not for you."); } if (!Request::get('forward')) { if (Request::option("quote") === $old_message->getId()) { if (Studip\Markup::isHtml($old_message['message'])) { $this->default_message['message'] = "<div>[quote]\n" . $old_message['message'] . "\n[/quote]</div>"; } else { $this->default_message['message'] = "[quote]\n" . $old_message['message'] . "\n[/quote]"; } } $this->default_message['subject'] = substr($old_message['subject'], 0, 4) === "RE: " ? $old_message['subject'] : "RE: " . $old_message['subject']; $user = new MessageUser(); $user->setData(array('user_id' => $old_message['autor_id'], 'snd_rec' => "rec")); $this->default_message->receivers[] = $user; $this->answer_to = $old_message->id; } else { $messagesubject = 'FWD: ' . $old_message['subject']; $message = _("-_-_ Weitergeleitete Nachricht _-_-"); $message .= "\n" . _("Betreff") . ": " . $old_message['subject']; $message .= "\n" . _("Datum") . ": " . strftime('%x %X', $old_message['mkdate']); $message .= "\n" . _("Von") . ": " . get_fullname($old_message['autor_id']); $num_recipients = $old_message->getNumRecipients(); if ($GLOBALS['user']->id == $old_message->autor_id) { $message .= "\n" . _("An") . ": " . ($num_recipients == 1 ? _('Eine Person') : sprintf(_('%s Personen'), $num_recipients)); } else { $message .= "\n" . _("An") . ": " . $GLOBALS['user']->getFullname() . ($num_recipients > 1 ? ' ' . sprintf(_('(und %d weitere)'), $num_recipients) : ''); } $message .= "\n\n"; if (Studip\Markup::isHtml($old_message['message'])) { $message = '<div>' . htmlReady($message, false, true) . '</div>' . $old_message['message']; } else { $message .= $old_message['message']; } if (count($old_message->attachments)) { Request::set('message_id', $old_message->getNewId()); foreach ($old_message->attachments as $attachment) { $attachment->range_id = 'provisional'; $attachment->seminar_id = $GLOBALS['user']->id; $attachment->autor_host = $_SERVER['REMOTE_ADDR']; $attachment->user_id = $GLOBALS['user']->id; $attachment->description = Request::option('message_id'); $new_attachment = $attachment->toArray(array('range_id', 'user_id', 'seminar_id', 'name', 'description', 'filename', 'filesize')); $new_attachment = StudipDocument::createWithFile(get_upload_file_path($attachment->getId()), $new_attachment); $this->default_attachments[] = array('icon' => GetFileIcon(getFileExtension($new_attachment['filename']))->asImg(['class' => "text-bottom"]), 'name' => $new_attachment['filename'], 'document_id' => $new_attachment->id, 'size' => relsize($new_attachment['filesize'], false)); } } $this->default_message['subject'] = $messagesubject; $this->default_message['message'] = $message; } } if (Request::get("default_body")) { $this->default_message['message'] = Request::get("default_body"); } if (Request::get("default_subject")) { $this->default_message['subject'] = Request::get("default_subject"); } $settings = UserConfig::get($GLOBALS['user']->id)->MESSAGING_SETTINGS; $this->mailforwarding = Request::get('emailrequest') ? true : $settings['request_mail_forward']; if (trim($settings['sms_sig'])) { if (Studip\Markup::isHtml($this->default_message['message']) || Studip\Markup::isHtml($settings['sms_sig'])) { if (!Studip\Markup::isHtml($this->default_message['message'])) { $this->default_message['message'] = '<div>' . nl2br($this->default_message['message']) . '</div>'; } $this->default_message['message'] .= '<br><br>--<br>'; if (Studip\Markup::isHtml($settings['sms_sig'])) { $this->default_message['message'] .= $settings['sms_sig']; } else { $this->default_message['message'] .= formatReady($settings['sms_sig']); } } else { $this->default_message['message'] .= "\n\n--\n" . $settings['sms_sig']; } } NotificationCenter::postNotification("DefaultMessageForComposerCreated", $this->default_message); }
function kontakt ($module, $row, $separate = FALSE) { $attr_table = $module->config->getAttributes("Contact", "table"); $attr_tr = $module->config->getAttributes("Contact", "table"); $attr_td = $module->config->getAttributes("Contact", "td"); $attr_fonttitle = $module->config->getAttributes("Contact", "fonttitle"); $attr_fontcontent = $module->config->getAttributes("Contact", "fontcontent"); $out = "<table$attr_table>\n"; if (!$separate) { $out .= "<tr$attr_tr>"; $out .= "<td colspan=\"2\"$attr_td>"; $out .= "<font$attr_fonttitle>"; if ($headline = $module->config->getValue("Contact", "headline")) $out .= "$headline</font>\n"; else $out .= "</font>\n"; $out .= "<font$attr_fontcontent>"; if (!$module->config->getValue("Contact", "hidepersname")) $out .= "<br><br>" . htmlReady($row['fullname'], TRUE) . "\n"; if ($module->config->getValue('Contact', 'showinstgroup')) { $allgroups = GetAllStatusgruppen($module->config->range_id, $row['user_id']); array_walk($allgroups, function(&$v, $k, $user_id) { $s = Statusgruppen::find($k); $v['role']->name = htmlReady($s->getGenderedName($user_id)); }, $row['user_id']); if ($gruppen = GetRoleNames($allgroups)) $out .= "<br>" . htmlReady(join(", ", array_values($gruppen))); } // display name of institution (as link) if ($row['Name']) { $br_out = ""; if ($module->config->getValue("Contact", "hideinstname") != '1') { if ($module->config->getValue("Contact", "hideinstname") == 'link' && $row['url']) { $url = htmlReady(trim($row['url'])); if (!stristr($url, "http://")) $url = "http://$url"; $out .= "<br><br><a href=\"$url\" target=\"_blank\">"; $out .= htmlReady($row['Name'], TRUE) . "</a><br>"; } else $out .= "<br><br>" . htmlReady($row['Name'], TRUE) . "<br>"; } if ($module->config->getValue("Contact", "adradd")) $out .= "<br>" . $module->config->getValue("Contact", "adradd"); } $out .= "<br>"; if ($row['Strasse']) { $out .= "<br>" . htmlReady($row['Strasse'], TRUE); if($row['Plz']) $out .= "<br>" . htmlReady($row['Plz'], TRUE); } $out .= "<br><br></font></td></tr>\n"; } $order = $module->config->getValue("Contact", "order"); $visible = $module->config->getValue("Contact", "visible"); $alias_contact = $module->config->getValue("Contact", "aliases"); foreach ($order as $position) { $data_field = $module->data_fields["contact"][$position]; if (!$visible[$position] || !$row[$data_field]) continue; switch ($data_field) { case 'Email' : if ($separate || !$module->config->getValue('Contact', 'separatelinks')) { $email_address = get_visible_email($row['user_id']); $out .= "<tr$attr_tr>"; $out .= "<td$attr_td>"; $out .= "<font$attr_fonttitle>"; $out .= $alias_contact[$position] . "</font></td>"; $out .= "<td$attr_td>"; $out .= "<font$attr_fontcontent>"; $mail = trim(htmlReady($email_address)); $out .= "<a href=\"mailto:$mail\">$mail</a>"; } break; case 'Home' : if (($separate || !$module->config->getValue('Contact', 'separatelinks')) && true�|| Visibility::verify('homepage', $row['user_id'])) { $out .= "<tr$attr_tr>"; $out .= "<td$attr_td>"; $out .= "<font$attr_fonttitle>"; $out .= $alias_contact[$position] . "</font></td>"; $out .= "<td$attr_td>"; $out .= "<font$attr_fontcontent>"; $out .= formatLinks($row['Home']); } break; default: if (!$separate) { $out .= "<tr$attr_tr>"; $out .= "<td$attr_td>"; $out .= "<font$attr_fonttitle>"; $out .= $alias_contact[$position] . "</font></td>"; $out .= "<td$attr_td>"; $out .= "<font$attr_fontcontent>"; $out .= htmlReady($row[$data_field], TRUE); } } if ($row[$data_field]) $out .= "</font></td></tr>\n"; } $out .= "</table>\n"; return $out; }