public function add_member_action() { CSRFProtection::verifyRequest(); $mp = MultiPersonSearch::load('settings_add_deputy'); $msg = array('error' => array(), 'success' => array()); foreach ($mp->getAddedUsers() as $_user_id) { if (isDeputy($_user_id, $this->user->user_id)) { $msg['error'][] = sprintf(_('%s ist bereits als Vertretung eingetragen.'), get_fullname($_user_id, 'full')); } else { if ($_user_id == $this->user->user_id) { $msg['error'][] = _('Sie können sich nicht als Ihre eigene Vertretung eintragen!'); } else { if (!addDeputy($_user_id, $this->user->user_id)) { $msg['error'][] = _('Fehler beim Eintragen der Vertretung!'); } else { $msg['success'][] = sprintf(_('%s wurde als Vertretung eingetragen.'), get_fullname($_user_id, 'full')); } } } } // only show an error messagebox once. if (!empty($msg['error'])) { PageLayout::postMessage(MessageBox::error(_('Die gewünschte Operation konnte nicht ausgeführt werden.'), $msg['error'])); } if (!empty($msg['success'])) { PageLayout::postMessage(MessageBox::success(_('Die gewünschten Personen wurden als Ihre Vertretung eingetragen!'), $msg['success'])); } $this->redirect('settings/deputies/index'); }
/** * Main action to display contacts */ function index_action($filter = null) { // Check if we need to add contacts $mps = MultiPersonSearch::load('contacts'); $imported = 0; foreach ($mps->getAddedUsers() as $userId) { $user_to_add = User::find($userId); if ($user_to_add) { $new_contact = array('owner_id' => User::findCurrent()->id, 'user_id' => $user_to_add->id); if ($filter && $this->group) { $new_contact['group_assignments'][] = array('statusgruppe_id' => $this->group->id, 'user_id' => $user_to_add->id); } $imported += (bool) Contact::import($new_contact)->store(); } } if ($imported) { PageLayout::postMessage(MessageBox::success(sprintf(_("%s Kontakte wurden hinzugefügt."), $imported))); } $mps->clearSession(); // write filter to local $this->filter = $filter; // Deal with navigation Navigation::activateItem('community/contacts'); // Edit CSS for quicknavigation PageLayout::addStyle('div.letterlist span {color: #c3c8cc;}'); if ($filter) { $selected = $this->group; $contacts = SimpleCollection::createFromArray(User::findMany($selected->members->pluck('user_id'))); } else { $contacts = User::findCurrent()->contacts; } $this->allContacts = $contacts; // Retrive first letter and store in that contactgroup $this->contacts = array(); foreach ($contacts as $contact) { $this->contacts[strtoupper(SimpleCollection::translitLatin1($contact->nachname[0]))][] = $contact; } // Humans are a lot better with sorted results ksort($this->contacts); $this->contacts = array_map(function ($g) { return SimpleCollection::createFromArray($g)->orderBy('nachname, vorname'); }, $this->contacts); // Init sidebar $this->initSidebar($filter); // Init person search $mps = MultiPersonSearch::get('contacts')->setTitle(_('Kontakte hinzufügen'))->setDefaultSelectedUser($this->allContacts->pluck('user_id'))->setExecuteURL($this->url_for('contact/index/' . $filter))->setSearchObject(new StandardSearch('user_id')); // Set default title $this->title = _('Alle Kontakte'); // If we have a group if ($selected) { // Set title of Table $this->title = $selected->name; // Set title of multipersonsearch $mps->setTitle(sprintf(_('Kontakte zu %s hinzufügen'), $selected->name)); $mps->addQuickfilter(_('Kontakte'), User::findCurrent()->contacts->pluck('user_id')); } // Render multiperson search $this->multiPerson = $mps->render(); }
/** * 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')))); }
/** * Landing page for mulitpersonsearch, adds the selected users to the * user list. * @param $userlistId string ID of the userlist to edit */ public function add_members_action($userlistId) { $mp = MultiPersonSearch::load("add_userlist_member_" . $userlistId); $users = $mp->getDefaultSelectedUsersIDs(); $oldsize = count($users); foreach ($mp->getAddedUsers() as $u) { $users[] = $u; } $newsize = count($users); $this->flash['users'] = $users; PageLayout::postInfo(sprintf(ngettext('Eine Person wurde der Liste hinzugefügt.', '%u Personen wurden der Liste hinzugefügt, die Liste ist aber noch nicht gespeichert.', $newsize - $oldsize), $newsize - $oldsize)); $this->redirect($this->url_for('admission/userlist/configure', $userlistId)); }
$('#factor-slider').css('width', 150); $('#factor').val(factor); $('#factor').css('display', 'none'); $('#factordiv').prepend('<span id="factorval">'+factor+'</span>'); }); </script> </div> <br/> <table class="default"> <caption> <?php echo _('Personen'); ?> <span class="actions"> <?php echo MultiPersonSearch::get('add_userlist_member_' . $userlist_id)->setTitle(_('Personen zur Liste hinzufügen'))->setSearchObject($userSearch)->setDefaultSelectedUser(array_map(function ($u) { return $u->id; }, $users))->setDataDialogStatus(Request::isXhr())->setJSFunctionOnSubmit(Request::isXhr() ? 'jQuery(this).closest(".ui-dialog-content").dialog("close");' : false)->setExecuteURL($controller->url_for('admission/userlist/add_members', $userlist_id))->render(); ?> </span> </caption> <thead> <tr> <th></th> <th><?php echo _('Name'); ?> </th> <th class="actions"><?php echo _('Aktion'); ?>
?> <? endif; ?> <? endif; ?> <a data-dialog="size=auto" title="<?php echo _('Gruppe ändern'); ?> " href="<?php echo $controller->url_for("admin/statusgroups/editGroup/{$group->id}"); ?> "> <?php echo Icon::create('edit', 'clickable', ['title' => _('Gruppe ändern')])->asImg(); ?> </a> <?php echo MultiPersonSearch::get("add_statusgroup" . $group->id)->setLinkText()->setDefaultSelectedUser($group->members->pluck('user_id'))->setTitle(_('MitgliederInnen hinzufügen'))->setExecuteURL($controller->url_for("admin/statusgroups/memberAdd/{$group->id}"))->setSearchObject($searchType)->addQuickfilter(_("aktuelle Einrichtung"), $membersOfInstitute)->render(); ?> <a data-dialog="size=auto" title="<?php echo _('Gruppe löschen'); ?> " href="<?php echo $controller->url_for("admin/statusgroups/deleteGroup/{$group->id}"); ?> "> <?php echo Icon::create('trash', 'clickable', ['title' => _('Gruppe löschen')])->asImg(); ?> </a> <a data-dialog="size=auto" title="<?php echo _('Gruppe alphabetisch sortieren'); ?>
public function add_member_action($course_id, $status = 'dozent') { // load MultiPersonSearch object $mp = MultiPersonSearch::load("add_member_" . $status . $course_id); $fail = false; switch ($status) { case 'tutor': $func = 'addTutor'; break; case 'deputy': $func = 'addDeputy'; break; default: $func = 'addTeacher'; break; } foreach ($mp->getAddedUsers() as $a) { $result = $this->{$func}($a, $course_id); if ($result !== false) { PageLayout::postMessage($result); } else { $fail = true; } } // only show an error messagebox once. if ($fail === true) { PageLayout::postMessage(MessageBox::error(_('Die gewünschte Operation konnte nicht ausgeführt werden.'))); } $this->flash['open'] = "bd_personal"; $redirect = Request::get('from') ?: 'course/basicdata/view/' . $course_id; $this->redirect($this->url_for($redirect)); }
public function add_users_action($range_id = null) { $this->range_id = $range_id ?: $this->range_id; $this->calendar = new SingleCalendar($this->range_id); if (Request::isXhr()) { $added_users = Request::optionArray('added_users'); } else { $mps = MultiPersonSearch::load('calendar-manage_access'); $added_users = $mps->getAddedUsers(); $mps->clearSession(); } $added = 0; foreach ($added_users as $user_id) { $user_to_add = User::find($user_id); if ($user_to_add) { $calendar_user = new CalendarUser(array($this->calendar->getRangeId(), $user_to_add->id)); if ($calendar_user->isNew()) { $calendar_user->permission = Calendar::PERMISSION_READABLE; $added += $calendar_user->store(); } } } if ($added) { PageLayout::postMessage(MessageBox::success(sprintf(ngettext('Eine Person wurde mit der Berechtigung zum Lesen des Kalenders hinzugefügt.', '%s Personen wurden mit der Berechtigung zum Lesen des Kalenders hinzugefügt.', $added), $added))); } if (Request::isXhr()) { $this->response->add_header('X-Dialog-Close', 1); $this->response->set_status(200); $this->render_nothing(); } else { $this->redirect($this->url_for('calendar/single/manage_access/' . $this->calendar->getRangeId())); } }
/** * Returns all courses matching set criteria. * * @param Array $params Additional parameters * @return Array of courses */ private function getCourses($params = array()) { // Init if ($GLOBALS['user']->cfg->MY_INSTITUTES_DEFAULT === "all") { $inst = new SimpleCollection($this->insts); $inst->filter(function ($a) use(&$inst_ids) { $inst_ids[] = $a->Institut_id; }); } else { $institut = new Institute($GLOBALS['user']->cfg->MY_INSTITUTES_DEFAULT); $inst_ids[] = $GLOBALS['user']->cfg->MY_INSTITUTES_DEFAULT; if ($institut->isFaculty()) { foreach ($institut->sub_institutes->pluck("Institut_id") as $institut_id) { $inst_ids[] = $institut_id; } } } $filter = AdminCourseFilter::get(true); $filter->where("sem_classes.studygroup_mode = '0'"); if (is_object($this->semester)) { $filter->filterBySemester($this->semester->getId()); } if ($params['typeFilter'] && $params['typeFilter'] !== "all") { list($class_filter, $type_filter) = explode('_', $params['typeFilter']); if (!$type_filter && !empty($GLOBALS['SEM_CLASS'][$class_filter])) { $type_filter = array_keys($GLOBALS['SEM_CLASS'][$class_filter]->getSemTypes()); } $filter->filterByType($type_filter); } if ($GLOBALS['user']->cfg->ADMIN_COURSES_SEARCHTEXT) { $filter->filterBySearchString($GLOBALS['user']->cfg->ADMIN_COURSES_SEARCHTEXT); } if ($GLOBALS['user']->cfg->ADMIN_COURSES_TEACHERFILTER && $GLOBALS['user']->cfg->ADMIN_COURSES_TEACHERFILTER !== "all") { $filter->filterByDozent($GLOBALS['user']->cfg->ADMIN_COURSES_TEACHERFILTER); } $filter->filterByInstitute($inst_ids); if ($params['sortby'] === "status") { $filter->orderBy(sprintf('sem_classes.name %s, sem_types.name %s, VeranstaltungsNummer', $params['sortFlag'], $params['sortFlag'], $params['sortFlag']), $params['sortFlag']); } elseif ($params['sortby'] === 'completion') { $filter->orderBy('is_complete', $params['sortFlag']); } elseif ($params['sortby']) { $filter->orderBy($params['sortby'], $params['sortFlag']); } $filter->storeSettings(); $this->count_courses = $filter->countCourses(); if ($this->count_courses && $this->count_courses <= $filter->max_show_courses) { $courses = $filter->getCourses(); } else { return array(); } if (in_array('contents', $params['view_filter'])) { $sem_types = SemType::getTypes(); $modules = new Modules(); } $seminars = array_map('reset', $courses); if (!empty($seminars)) { foreach ($seminars as $seminar_id => $seminar) { $dozenten = $this->getTeacher($seminar_id); $seminars[$seminar_id]['dozenten'] = $dozenten; if (in_array('teachers', $params['view_filter'])) { if (SeminarCategories::getByTypeId($seminar['status'])->only_inst_user) { $search_template = "user_inst_not_already_in_sem"; } else { $search_template = "user_not_already_in_sem"; } $sem_helper = new Seminar(Course::buildExisting($seminar)); $dozentUserSearch = new PermissionSearch($search_template, sprintf(_("%s suchen"), get_title_for_status('dozent', 1, $seminar['status'])), "user_id", array('permission' => 'dozent', 'seminar_id' => $this->course_id, 'sem_perm' => 'dozent', 'institute' => $sem_helper->getInstitutes())); $seminars[$seminar_id]['teacher_search'] = MultiPersonSearch::get("add_member_dozent" . $seminar_id)->setTitle(_('Mehrere Lehrende hinzufügen'))->setSearchObject($dozentUserSearch)->setDefaultSelectedUser(array_keys($dozenten))->setDataDialogStatus(Request::isXhr())->setExecuteURL(URLHelper::getLink('dispatch.php/course/basicdata/add_member/' . $seminar_id, array('from' => 'admin/courses'))); } if (in_array('contents', $params['view_filter'])) { $seminars[$seminar_id]['sem_class'] = $sem_types[$seminar['status']]->getClass(); $seminars[$seminar_id]['modules'] = $modules->getLocalModules($seminar_id, 'sem', $seminar['modules'], $seminar['status']); $seminars[$seminar_id]['navigation'] = MyRealmModel::getAdditionalNavigations($seminar_id, $seminars[$seminar_id], $seminars[$seminar_id]['sem_class'], $GLOBALS['user']->id); } if ($this->selected_action == 17) { $seminars[$seminar_id]['admission_locked'] = false; if ($seminar['course_set']) { $set = new CourseSet($seminar['course_set']); if (!is_null($set) && $set->hasAdmissionRule('LockedAdmission')) { $seminars[$seminar_id]['admission_locked'] = 'locked'; } else { $seminars[$seminar_id]['admission_locked'] = 'disable'; } unset($set); } } } } return $seminars; }
private function createSidebar($filtered_members) { $sidebar = Sidebar::get(); $sem = Seminar::GetInstance($this->course_id); if ($this->is_tutor) { $widget = new ActionsWidget(); $url = URLHelper::getLink('dispatch.php/messages/write', array('course_id' => $this->course_id, 'default_subject' => $this->subject, 'filter' => 'all', 'emailrequest' => 1)); $widget->addLink(_('Nachricht an alle (Rundmail)'), $url, Icon::create('inbox', 'clickable'), array('data-dialog' => "buttons")); if ($this->is_dozent) { if (!$this->dozent_is_locked) { $sem_institutes = $sem->getInstitutes(); if (SeminarCategories::getByTypeId($sem->status)->only_inst_user) { $search_template = "user_inst"; } else { $search_template = "user"; } // create new search for dozent $searchtype = new PermissionSearch($search_template, sprintf(_("%s suchen"), get_title_for_status('dozent', 1, $sem->status)), "user_id", array('permission' => 'dozent', 'exclude_user' => array(), 'institute' => $sem_institutes)); // quickfilter: dozents of institut $sql = "SELECT user_id FROM user_inst WHERE Institut_id = ? AND inst_perms = 'dozent'"; $db = DBManager::get(); $statement = $db->prepare($sql, array(PDO::FETCH_NUM)); $statement->execute(array(Seminar::getInstance($this->course_id)->getInstitutId())); $membersOfInstitute = $statement->fetchAll(PDO::FETCH_COLUMN, 0); // add "add dozent" to infobox $mp = MultiPersonSearch::get('add_dozent' . $this->course_id)->setLinkText(sprintf(_('Neue/n %s eintragen'), $this->status_groups['dozent']))->setDefaultSelectedUser($filtered_members['dozent']->pluck('user_id'))->setLinkIconPath("")->setTitle(sprintf(_('Neue/n %s eintragen'), $this->status_groups['dozent']))->setExecuteURL(URLHelper::getLink('dispatch.php/course/members/execute_multipersonsearch_dozent'))->setSearchObject($searchtype)->addQuickfilter(sprintf(_('%s der Einrichtung'), $this->status_groups['dozent']), $membersOfInstitute)->setNavigationItem('/course/members/view')->render(); $element = LinkElement::fromHTML($mp, Icon::create('community+add', 'clickable')); $widget->addElement($element); } if (!$this->tutor_is_locked) { $sem_institutes = $sem->getInstitutes(); if (SeminarCategories::getByTypeId($sem->status)->only_inst_user) { $search_template = 'user_inst'; } else { $search_template = 'user'; } // create new search for tutor $searchType = new PermissionSearch($search_template, sprintf(_('%s suchen'), get_title_for_status('tutor', 1, $sem->status)), 'user_id', array('permission' => array('dozent', 'tutor'), 'exclude_user' => array(), 'institute' => $sem_institutes)); // quickfilter: tutors of institut $sql = "SELECT user_id FROM user_inst WHERE Institut_id = ? AND inst_perms = 'tutor'"; $db = DBManager::get(); $statement = $db->prepare($sql, array(PDO::FETCH_NUM)); $statement->execute(array(Seminar::getInstance($this->course_id)->getInstitutId())); $membersOfInstitute = $statement->fetchAll(PDO::FETCH_COLUMN, 0); // add "add tutor" to infobox $mp = MultiPersonSearch::get("add_tutor" . $this->course_id)->setLinkText(sprintf(_('Neue/n %s eintragen'), $this->status_groups['tutor']))->setDefaultSelectedUser($filtered_members['tutor']->pluck('user_id'))->setLinkIconPath("")->setTitle(sprintf(_('Neue/n %s eintragen'), $this->status_groups['tutor']))->setExecuteURL(URLHelper::getLink('dispatch.php/course/members/execute_multipersonsearch_tutor'))->setSearchObject($searchType)->addQuickfilter(sprintf(_('%s der Einrichtung'), $this->status_groups['tutor']), $membersOfInstitute)->setNavigationItem('/course/members/view')->render(); $element = LinkElement::fromHTML($mp, Icon::create('community+add', 'clickable')); $widget->addElement($element); } } if (!$this->is_locked) { // create new search for members $searchType = new SQLSearch("SELECT auth_user_md5.user_id, CONCAT(" . $GLOBALS['_fullname_sql']['full'] . ", \" (\", auth_user_md5.username, \")\") as fullname " . "FROM auth_user_md5 " . "LEFT JOIN user_info ON (user_info.user_id = auth_user_md5.user_id) " . "WHERE (CONCAT(auth_user_md5.Vorname, \" \", auth_user_md5.Nachname) LIKE :input " . "OR CONCAT(auth_user_md5.Nachname, \" \", auth_user_md5.Vorname) LIKE :input " . "OR auth_user_md5.username LIKE :input) " . "AND auth_user_md5.perms IN ('autor', 'tutor', 'dozent') " . " AND auth_user_md5.visible <> 'never' " . "ORDER BY Vorname, Nachname", _("Teilnehmer suchen"), "username"); // quickfilter: tutors of institut $sql = "SELECT user_id FROM user_inst WHERE Institut_id = ? AND inst_perms = 'autor'"; $db = DBManager::get(); $statement = $db->prepare($sql, array(PDO::FETCH_NUM)); $statement->execute(array(Seminar::getInstance($this->course_id)->getInstitutId())); $membersOfInstitute = $statement->fetchAll(PDO::FETCH_COLUMN, 0); // add "add autor" to infobox $mp = MultiPersonSearch::get("add_autor" . $this->course_id)->setLinkText(sprintf(_('Neue/n %s eintragen'), $this->status_groups['autor']))->setDefaultSelectedUser($filtered_members['autor']->pluck('user_id'))->setLinkIconPath("")->setTitle(sprintf(_('Neue/n %s eintragen'), $this->status_groups['autor']))->setExecuteURL(URLHelper::getLink('dispatch.php/course/members/execute_multipersonsearch_autor'))->setSearchObject($searchType)->addQuickfilter(sprintf(_('%s der Einrichtung'), $this->status_groups['autor']), $membersOfInstitute)->setNavigationItem('/course/members/view')->render(); $element = LinkElement::fromHTML($mp, Icon::create('community+add', 'clickable')); $widget->addElement($element); // add "add person to waitlist" to sidebar if ($sem->isAdmissionEnabled() && !$sem->admission_disable_waitlist && (!$sem->getFreeSeats() || $sem->admission_disable_waitlist_move)) { $ignore = array_merge($filtered_members['dozent']->pluck('user_id'), $filtered_members['tutor']->pluck('user_id'), $filtered_members['autor']->pluck('user_id'), $filtered_members['user']->pluck('user_id'), $filtered_members['awaiting']->pluck('user_id')); $mp = MultiPersonSearch::get('add_waitlist' . $this->course_id)->setLinkText(_('Neue/n Person auf Warteliste eintragen'))->setDefaultSelectedUser($ignore)->setLinkIconPath('')->setTitle(_('Neue/n Person auf Warteliste eintragen'))->setExecuteURL(URLHelper::getLink('dispatch.php/course/members/execute_multipersonsearch_waitlist'))->setSearchObject($searchType)->addQuickfilter(_('Mitglieder der Einrichtung'), $membersOfInstitute)->setNavigationItem('/course/members/view')->render(); $element = LinkElement::fromHTML($mp, Icon::create('community+add', 'clickable')); $widget->addElement($element); } } $widget->addLink(_('Teilnehmerliste importieren'), $this->url_for('course/members/import_autorlist'), Icon::create('community+add', 'clickable')); $sidebar->addWidget($widget); if (Config::get()->EXPORT_ENABLE) { include_once $GLOBALS['PATH_EXPORT'] . '/export_linking_func.inc.php'; $widget = new ExportWidget(); // create csv-export link $csvExport = export_link($this->course_id, "person", sprintf('%s %s', htmlReady($this->status_groups['autor']), htmlReady($this->course_title)), 'csv', 'csv-teiln', '', _('Teilnehmendenliste als csv-Dokument exportieren'), 'passthrough'); $widget->addLink(_('Teilnehmendenliste als CSV-Dokument exportieren'), $this->parseHref($csvExport), Icon::create('file-office', 'clickable')); // create csv-export link $rtfExport = export_link($this->course_id, "person", sprintf('%s %s', htmlReady($this->status_groups['autor']), htmlReady($this->course_title)), 'rtf', 'rtf-teiln', '', _('Teilnehmendenliste als rtf-Dokument exportieren'), 'passthrough'); $widget->addLink(_('Teilnehmendenliste als rtf-Dokument exportieren'), $this->parseHref($rtfExport), Icon::create('file-text', 'clickable')); if (count($this->awaiting) > 0) { $awaiting_rtf = export_link($this->course_id, "person", sprintf('%s %s', _("Warteliste"), htmlReady($this->course_title)), "rtf", "rtf-warteliste", $this->waiting_type, _("Warteliste als Textdokument (.rtf) exportieren"), 'passthrough'); $widget->addLink(_('Warteliste als rtf-Dokument exportieren'), $this->parseHref($awaiting_rtf), Icon::create('file-office+export', 'clickable')); $awaiting_csv = export_link($this->course_id, "person", sprintf('%s %s', _("Warteliste"), htmlReady($this->course_title)), "csv", "csv-warteliste", $this->waiting_type, _("Warteliste als Tabellendokument (.csv) exportieren"), 'passthrough'); $widget->addLink(_('Warteliste als csv-Dokument exportieren'), $this->parseHref($awaiting_csv), Icon::create('file-text+export', 'clickable')); } $sidebar->addWidget($widget); } } else { if ($this->is_autor || $this->is_user) { // Visibility preferences if (!$this->my_visibility['iam_visible']) { $text = _('Sie sind für andere Teilnehmenden auf der Teilnehmendenliste nicht sichtbar.'); $icon = Icon::create('visibility-visible', 'clickable'); $modus = 'make_visible'; $link_text = _('Klicken Sie hier, um sichtbar zu werden.'); } else { $text = _('Sie sind für andere Teilnehmenden auf der Teilnehmendenliste sichtbar.'); $icon = Icon::create('visibility-invisible', 'clickable'); $modus = 'make_invisible'; $link_text = _('Klicken Sie hier, um unsichtbar zu werden.'); } $actions = new ActionsWidget(); $actions->addLink($link_text, $this->url_for('course/members/change_visibility', $modus, $this->my_visibility['visible_mode']), $icon, array('title' => $text)); $sidebar->addWidget($actions); } } }
public function edit_action($range_id = null, $event_id = null) { $this->range_id = $range_id ?: $this->range_id; // get group and the calendars of the members // the first calendar is the calendar of the actual user $this->calendar = new SingleCalendar($GLOBALS['user']->id); $group = $this->getGroup($this->calendar); if ($group) { $calendar_owners = CalendarUser::getOwners($GLOBALS['user']->id, Calendar::PERMISSION_WRITABLE)->pluck('owner_id'); $members = $group->members->pluck('user_id'); $user_id = Request::option('user_id'); $this->attendee_ids = array_intersect($calendar_owners, $members); $this->attendee_ids[] = $GLOBALS['user']->id; if ($user_id && in_array($user_id, $this->attendee_ids)) { $this->attendee_ids = array($user_id); } } $this->event = $this->calendar->getEvent($event_id); if ($this->event->isNew()) { $this->event = $this->calendar->getNewEvent(); if (Request::get('isdayevent')) { $this->event->setStart(mktime(0, 0, 0, date('n', $this->atime), date('j', $this->atime), date('Y', $this->atime))); $this->event->setEnd(mktime(23, 59, 59, date('n', $this->atime), date('j', $this->atime), date('Y', $this->atime))); } else { $this->event->setStart($this->atime); $this->event->setEnd($this->atime + 3600); } $this->event->setAuthorId($GLOBALS['user']->id); $this->event->setEditorId($GLOBALS['user']->id); $this->event->setAccessibility('PRIVATE'); if ($this->attendee_ids) { foreach ($this->attendee_ids as $attendee_id) { $attendee_event = clone $this->event; $attendee_event->range_id = $attendee_id; $this->attendees[] = $attendee_event; } } if (!Request::isXhr()) { PageLayout::setTitle($this->getTitle($this->calendar, _('Neuer Termin'))); } } else { // open read only events and course events not as form // show information in dialog instead if (!$this->event->havePermission(Event::PERMISSION_WRITABLE) || $this->event instanceof CourseEvent) { $this->redirect($this->url_for('calendar/single/event/' . implode('/', array($this->range_id, $this->event->event_id)))); return null; } $this->attendees = $this->event->getAttendees(); if (!Request::isXhr()) { PageLayout::setTitle($this->getTitle($this->calendar, _('Termin bearbeiten'))); } } if (get_config('CALENDAR_GROUP_ENABLE') && $this->calendar->getRange() == Calendar::RANGE_USER) { $search_obj = new SQLSearch("SELECT auth_user_md5.user_id, {$GLOBALS['_fullname_sql']['full_rev']} as fullname, username, perms " . "FROM calendar_user " . "LEFT JOIN auth_user_md5 ON calendar_user.owner_id = auth_user_md5.user_id " . "LEFT JOIN user_info ON (auth_user_md5.user_id = user_info.user_id) " . 'WHERE calendar_user.user_id = ' . DBManager::get()->quote($GLOBALS['user']->id) . ' AND calendar_user.permission > ' . Event::PERMISSION_READABLE . ' AND (username LIKE :input OR Vorname LIKE :input ' . "OR CONCAT(Vorname,' ',Nachname) LIKE :input " . "OR CONCAT(Nachname,' ',Vorname) LIKE :input " . "OR Nachname LIKE :input OR {$GLOBALS['_fullname_sql']['full_rev']} LIKE :input " . ") ORDER BY fullname ASC", _('Person suchen'), 'user_id'); $this->quick_search = QuickSearch::get('user_id', $search_obj)->fireJSFunctionOnSelect('STUDIP.Messages.add_adressee'); // $default_selected_user = array($this->calendar->getRangeId()); $this->mps = MultiPersonSearch::get('add_adressees')->setLinkText(_('Mehrere Teilnehmer hinzufügen'))->setTitle(_('Mehrere Teilnehmer hinzufügen'))->setExecuteURL($this->url_for($this->base . 'edit'))->setJSFunctionOnSubmit('STUDIP.Messages.add_adressees')->setSearchObject($search_obj); $owners = SimpleORMapCollection::createFromArray(CalendarUser::findByUser_id($this->calendar->getRangeId()))->pluck('owner_id'); foreach (Calendar::getGroups($GLOBALS['user']->id) as $group) { $this->mps->addQuickfilter($group->name, $group->members->filter(function ($member) use($owners) { if (in_array($member->user_id, $owners)) { return $member; } })->pluck('user_id')); } } $stored = false; if (Request::submitted('store')) { $stored = $this->storeEventData($this->event, $this->calendar); } if ($stored !== false) { // switch back to group context $this->range_id = $group->getId(); if ($stored === 0) { if (Request::isXhr()) { header('X-Dialog-Close: 1'); exit; } else { PageLayout::postMessage(MessageBox::success(_('Der Termin wurde nicht geändert.'))); $this->relocate('calendar/group/' . $this->last_view, array('atime' => $this->atime)); } } else { PageLayout::postMessage(MessageBox::success(_('Der Termin wurde gespeichert.'))); $this->relocate('calendar/group/' . $this->last_view, array('atime' => $this->atime)); } } else { $this->createSidebar('edit', $this->calendar); $this->createSidebarFilter(); $this->render_template('calendar/single/edit', $this->layout); } }
/** * Action which is used for handling all submits for no-JavaScript * users: * * searching, * * adding a person, * * removing a person, * * selcting a quickfilter, * * aborting, * * saving. * * This needs to be done in one single action to provider a similar * usability for no-JavaScript users as for JavaScript users. */ public function no_js_form_action() { if (!empty($_POST)) { CSRFProtection::verifyUnsafeRequest(); } $this->name = Request::get("name"); $mp = MultiPersonSearch::load($this->name); $this->selectableUsers = array(); $this->selectedUsers = array(); $this->search = Request::get("freesearch"); $this->additionHTML = $mp->getAdditionHTML(); $previousSelectableUsers = unserialize(studip_utf8decode(Request::get('search_persons_selectable_hidden'))); $previousSelectedUsers = unserialize(studip_utf8decode(Request::get('search_persons_selected_hidden'))); // restore quickfilter $this->quickfilterIDs = $mp->getQuickfilterIds(); foreach ($this->quickfilterIDs as $title => $array) { $this->quickfilter[] = $title; } // abort if (Request::submitted('abort')) { $this->redirect($_SESSION['multipersonsearch'][$this->name]['pageURL']); } elseif (Request::submitted('submit_search')) { // evaluate search $this->selectedUsers = User::findMany($previousSelectedUsers); $searchterm = Request::get('freesearch'); $searchObject = $mp->getSearchObject(); $result = array_map(function ($r) { return $r['user_id']; }, $searchObject->getResults($searchterm, array(), 50)); $this->selectableUsers = User::findMany($result); // remove already selected users foreach ($this->selectableUsers as $key => $user) { if (in_array($user->id, $previousSelectedUsers) || in_array($user->id, $mp->getDefaultSelectedUsersIDs())) { unset($this->selectableUsers[$key]); $this->alreadyMemberUsers[$key] = $user; } } } elseif (Request::submitted('submit_search_preset')) { $this->selectedUsers = User::findMany($previousSelectedUsers); $this->selectableUsers = User::findMany($this->quickfilterIDs[Request::get('search_preset')]); // remove already selected users foreach ($this->selectableUsers as $key => $user) { if (in_array($user->id, $previousSelectedUsers) || in_array($user->id, $mp->getDefaultSelectedUsersIDs())) { unset($this->selectableUsers[$key]); } } } elseif (Request::submitted('search_persons_add')) { // add users foreach (Request::optionArray('search_persons_selectable') as $userID) { if (($key = array_search($userID, $previousSelectableUsers)) !== false) { unset($previousSelectableUsers[$key]); } $previousSelectedUsers[] = $userID; } $this->selectedUsers = User::findMany($previousSelectedUsers); $this->selectableUsers = User::findMany($previousSelectableUsers); } elseif (Request::submitted('search_persons_remove')) { // remove users foreach (Request::optionArray('search_persons_selected') as $userID) { if (($key = array_search($userID, $previousSelectedUsers)) !== false) { unset($previousSelectedUsers[$key]); } $previousSelectableUsers[] = $userID; } $this->selectedUsers = User::findMany($previousSelectedUsers); $this->selectableUsers = User::findMany($previousSelectableUsers); } elseif (Request::submitted('save')) { // find added users $addedUsers = array(); $defaultSelectedUsersIDs = $searchObject = $mp->getDefaultSelectedUsersIDs(); foreach ($previousSelectedUsers as $selected) { if (!in_array($selected, $defaultSelectedUsersIDs)) { $addedUsers[] = $selected; } } // find removed users $removedUsers = array(); foreach ($defaultSelectedUsersIDs as $default) { if (!in_array($default, $previousSelectedUsers)) { $removedUsers[] = $default; } } $_SESSION['multipersonsearch'][$this->name]['selected'] = $previousSelectedUsers; $_SESSION['multipersonsearch'][$this->name]['added'] = $addedUsers; $_SESSION['multipersonsearch'][$this->name]['removed'] = $removedUsers; // redirect to action which handles the form data $this->redirect($mp->getExecuteURL()); } else { // get selected and selectable users from SESSION $this->defaultSelectableUsersIDs = $mp->getDefaultSelectableUsersIDs(); $this->defaultSelectedUsersIDs = $mp->getDefaultSelectedUsersIDs(); $this->selectableUsers = User::findMany($this->defaultSelectableUsersIDs); $this->selectedUsers = array(); } // save selected/selectable users in hidden form fields $this->selectableUsers = new SimpleCollection($this->selectableUsers); $this->selectableUsers->orderBy("nachname asc, vorname asc"); $this->selectableUsersHidden = $this->selectableUsers->pluck('id'); $this->selectedUsers = new SimpleCollection($this->selectedUsers); $this->selectedUsers->orderBy("nachname asc, vorname asc"); $this->selectedUsersHidden = $this->selectedUsers->pluck('id'); $this->selectableUsers->orderBy('nachname, vorname'); $this->selectedUsers->orderBy('nachname, vorname'); // set layout data $this->set_layout($GLOBALS['template_factory']->open('layouts/base')); $this->title = $mp->getTitle(); $this->description = $mp->getDescription(); $this->pageURL = $mp->getPageURL(); if ($mp->getNavigationItem() != "") { Navigation::activateItem($mp->getNavigationItem()); } }
/** * */ protected function getMultiPersonSearch($role_id) { // Multiperson search $query = "SELECT aum.user_id,\n {$GLOBALS['_fullname_sql']['full_rev']} AS fullname,\n username, perms\n FROM auth_user_md5 AS aum\n LEFT JOIN user_info AS ui ON (aum.user_id = ui.user_id)\n LEFT JOIN roles_user AS ru ON (aum.user_id = ru.userid AND ru.roleid = {$role_id})\n WHERE ru.userid IS NULL\n AND (username LIKE :input\n OR Vorname LIKE :input\n OR Nachname LIKE :input\n OR CONCAT(Vorname, ' ', Nachname) LIKE :input\n OR CONCAT(Nachname, ' ', Vorname) LIKE :input\n OR {$GLOBALS['_fullname_sql']['full_rev']} LIKE :input)\n ORDER BY fullname ASC"; $url = URLHelper::getURL('dispatch.php/admin/role/add_user/' . $role_id . '/bulk'); return MultiPersonSearch::get('add_role_users')->setLinkText(_('Personen hinzufügen'))->setTitle(_('Personen zur Rolle hinzufügen'))->setExecuteURL($url)->setSearchObject(new SQLSearch($query, _('Nutzer suchen'), 'user_id')); }
/** * Action to add multiple members to a group. * * @param string group id */ public function memberAdd_action($group_id = null) { $mp = MultiPersonSearch::load("add_statusgroup" . $group_id); $this->group = new Statusgruppen($group_id); $countAdded = 0; foreach ($mp->getAddedUsers() as $a) { if (!$this->group->isMember(new User($a))) { $new_user = new StatusgruppeUser(array($group_id, $a)); $new_user->store(); $this->type['after_user_add']($a); $countAdded++; } } if ($countAdded > 0) { $message = sprintf(ngettext('Es wurde eine Person hinzugefügt.', 'Es wurden %u MitgliederInnen hinzugefügt.', $countAdded), $countAdded); PageLayout::postMessage(MessageBox::success($message)); } $this->redirect('admin/statusgroups'); }
<? endforeach ?> <? endif ?> </tbody> </table> <? endif ?> <!-- Tutoren --> <table class="default"> <caption> <?php echo htmlReady($tutor_title); ?> <? if ($perm_dozent && !$tutor_is_locked): ?> <span class="actions"> <?php echo MultiPersonSearch::get('add_member_tutor' . $course_id)->setTitle(_('Mehrere TutorInnen hinzufügen'))->setSearchObject($tutorUserSearch)->setDefaultSelectedUser(array_merge(array_keys($dozenten), array_keys($tutoren)))->setDataDialogStatus(Request::isXhr())->setJSFunctionOnSubmit(Request::isXhr() ? 'jQuery(this).closest(".ui-dialog-content").dialog("close");' : false)->setExecuteURL($controller->url_for('course/basicdata/add_member/' . $course_id . '/tutor'))->addQuickfilter(sprintf(_('%s der Einrichtung'), get_title_for_status('dozent', 2)), $lecturersOfInstitute)->addQuickfilter(sprintf(_('%s der Einrichtung'), get_title_for_status('tutor', 2)), $tutorsOfInstitute)->render(); ?> </span> <? endif; ?> </caption> <thead> <tr> <th></th> <th><?php echo _('Name'); ?> </th> <th><?php echo _('Funktion'); ?> </th>
<? # Lifter010: TODO ?> <? $roles_pos = 1; if (!isset($all_roles)) $all_roles = $roles; if (is_array($roles)) foreach ($roles as $id => $role) : $topic_class = 'table_header_bold'; if ($edit_role == $id) $topic_class = 'red_gradient'; // get dialog URLHelper::setBaseURL($GLOBALS['ABSOLUTE_URI_STUDIP']); $mp = MultiPersonSearch::get("contacts_statusgroup_" . $id) ->setLinkText("") ->setDefaultSelectedUser(array_keys(getPersonsForRole($id))) ->setTitle(_('Personen eintragen')) ->setExecuteURL(URLHelper::getLink("admin_statusgruppe.php")) ->setSearchObject($search_obj) ->addQuickfilter(_("Veranstaltungsteilnehmende"), $quickfilter_sem) ->addQuickfilter(_("MitarbeiterInnen"), $quickfilter_inst) ->addQuickfilter(_("Personen ohne Gruppe"), $quickfilter_sem_no_group) ->render(); ?> <a name="<?php echo $id; ?> " ></a> <table class="default" cellspacing="0" cellpadding="0" border="0"> <tr> <th></th>
/** * restores a MultiPersonSearch object. * * @param string name of the object * * @return MultiPersonSearch */ public static function load($name) { $mp = new MultiPersonSearch($name); $mp->restoreFromSession(); return $mp; }
<span class="visual"> <?php echo htmlReady($user['fullname']); ?> </span> <a class="remove_adressee"><?php echo Icon::create('trash', 'clickable')->asImg(['class' => "text-bottom"]); ?> </a> </li> <? endforeach ?> </ul> <?php echo QuickSearch::get("user_id", new StandardSearch("user_id"))->fireJSFunctionOnSelect("STUDIP.Messages.add_adressee")->withButton()->render(); $search_obj = new SQLSearch("SELECT auth_user_md5.user_id, {$GLOBALS['_fullname_sql']['full_rev']} as fullname, username, perms " . "FROM auth_user_md5 " . "LEFT JOIN user_info ON (auth_user_md5.user_id = user_info.user_id) " . "WHERE " . "username LIKE :input OR Vorname LIKE :input " . "OR CONCAT(Vorname,' ',Nachname) LIKE :input " . "OR CONCAT(Nachname,' ',Vorname) LIKE :input " . "OR CONCAT(Nachname,', ',Vorname) LIKE :input " . "OR Nachname LIKE :input OR " . "OR Vorname LIKE :input" . " ORDER BY fullname ASC", _("Nutzer suchen"), "user_id"); $mps = MultiPersonSearch::get("add_adressees")->setLinkText(_('Mehrere Adressaten hinzufügen'))->setTitle(_('Mehrere Adressaten hinzufügen'))->setExecuteURL(URLHelper::getURL("dispatch.php/messages/write"))->setJSFunctionOnSubmit("STUDIP.Messages.add_adressees")->setSearchObject($search_obj); foreach (Statusgruppen::findContactGroups() as $group) { $mps->addQuickfilter($group['name'], $group->members->pluck('user_id')); } echo $mps->render(); ?> <script> STUDIP.MultiPersonSearch.init(); </script> </div> <div> <label> <h4><?php echo _("Betreff"); ?> </h4>
function addToStatusgroup($range_id, $statusgruppe_id, $workgroup_mode) { $mp = MultiPersonSearch::load("contacts_statusgroup_" . $statusgruppe_id); if (count($mp->getAddedUsers()) !== 0) { foreach ($mp->getAddedUsers() as $m) { $quickfilters = $mp->getQuickfilterIds(); if (in_array($m, $quickfilters[_("Veranstaltungsteilnehmende")])) { InsertPersonStatusgruppe ($m, $statusgruppe_id, false); } elseif (in_array($m, $quickfilters[_("Mitarbeiter/-innen")])) { $writedone = InsertPersonStatusgruppe ($m, $statusgruppe_id, false); if ($writedone) { if ($workgroup_mode == TRUE) { $globalperms = get_global_perm($m); if ($globalperms == "tutor" || $globalperms == "dozent") { insert_seminar_user($range_id, $m, "tutor"); } else { insert_seminar_user($range_id, $m, "autor"); } } else { insert_seminar_user($range_id, $m, "autor"); } } checkExternDefaultForUser($m); } else { $writedone = InsertPersonStatusgruppe ($m, $statusgruppe_id, false); if ($writedone) { if ($workgroup_mode == TRUE) { $globalperms = get_global_perm($m); if ($globalperms == "tutor" || $globalperms == "dozent") { insert_seminar_user($range_id, $m, "tutor"); } else { insert_seminar_user($range_id, $m, "autor"); } } else { insert_seminar_user($range_id, $m, "autor"); } } } } } $mp->clearSession(); }