static function findLatestPages($course_id) { $query = "SELECT\n range_id,\n keyword,\n MAX(version) as version\n FROM wiki\n WHERE range_id = ?\n GROUP BY keyword\n ORDER BY keyword ASC"; $st = DBManager::get()->prepare($query); $st->execute(array($course_id)); $ids = $st->fetchAll(PDO::FETCH_NUM); $pages = new SimpleORMapCollection(); $pages->setClassName(__CLASS__); foreach ($ids as $id) { $pages[] = self::find($id); } return $pages; }
function getTabNavigation($course_id) { if (TRUE) { $temp = ScmTabEntry::findByRange_id($course_id, 'ORDER BY position ASC'); if ($temp) { $scms = SimpleORMapCollection::createFromArray($temp); $navigation = new Navigation($scms->first()->tab_name ?: _('Informationen')); $navigation->setImage('icons/16/white/infopage.png'); $navigation->setActiveImage('icons/16/black/infopage.png'); foreach ($scms as $scm) { $scm_link = PluginEngine::getLink($this, array(), 'show/' . $scm->id); $nav = new Navigation($scm['tab_name'], $scm_link); $nav->setImage('icons/16/white/infopage.png'); $nav->setActiveImage('icons/16/black/infopage.png'); Navigation::addItem('course/scmTabs' . $scm->id, $nav); } return null; //array('scm' => $navigation); } else { $scm = new ScmTabEntry($id); $scm->tab_name = 'Infoseite'; $scm->user_id = $GLOBALS['user']->id; $scm->range_id = $GLOBALS['SessSemName'][1]; $scm->store(); $scm_link = PluginEngine::getLink($this, array(), 'show/' . $scm->id); $nav = new Navigation($scm->tab_name, $scm_link); $nav->setImage('icons/16/white/infopage.png'); $nav->setActiveImage('icons/16/black/infopage.png'); Navigation::addItem('course/scmTabs' . $scm->id, $nav); return null; } } else { return null; } }
/** * creates a collection from an array of objects * all objects should be of the same type * * @throws InvalidArgumentException if first entry is not SimpleOrMap * @param array $data array with SimpleORMap objects * @param bool $strict check every element for correct type and unique pk * @return SimpleORMapCollection */ public static function createFromArray(array $data, $strict = true) { $ret = new SimpleORMapCollection(); if (count($data)) { $first = current($data); if ($first instanceof SimpleORMap) { $ret->setClassName(get_class($first)); if ($strict) { foreach ($data as $one) { $ret[] = $one; } } else { $ret->exchangeArray($data); } } else { throw new InvalidArgumentException('This collection only accepts objects derived from SimpleORMap', self::WRONG_OBJECT_TYPE); } } return $ret; }
public static function getOwners($user_id, $permission = null) { $permission_array = array(Calendar::PERMISSION_READABLE, Calendar::PERMISSION_WRITABLE); if (!$permission) { $permission = $permission_array; } else { if (!in_array($permission, $permission_array)) { throw new InvalidArgumentException('Calendar permission must be of type PERMISSION_READABLE or PERMISSION_WRITABLE.'); } else { $permission = array($permission); } } return SimpleORMapCollection::createFromArray(CalendarUser::findBySQL('user_id = ? AND permission IN(?)', array($user_id, $permission))); }
/** * Returns all CourseMarkedEvents in the given time range for the given range_id. * * @param string $user_id Id of Stud.IP object from type user, course, inst * @param DateTime $start The start date time. * @param DateTime $end The end date time. * @return SimpleORMapCollection Collection of found CourseMarkedEvents. */ public static function getEventsByInterval($user_id, DateTime $start, dateTime $end) { $stmt = DBManager::get()->prepare('SELECT DISTINCT termine.* FROM schedule_seminare ' . 'INNER JOIN termine ON schedule_seminare.seminar_id = range_id ' . 'LEFT JOIN seminar_user ON seminar_user.seminar_id = range_id AND seminar_user.user_id= :user_id ' . 'WHERE schedule_seminare.user_id = :user_id AND schedule_seminare.visible = 1 ' . 'AND seminar_user.seminar_id IS NULL AND date BETWEEN :start AND :end ' . 'ORDER BY date ASC'); $stmt->execute(array(':user_id' => $user_id, ':start' => $start->getTimestamp(), ':end' => $end->getTimestamp())); $event_collection = array(); foreach ($stmt->fetchAll(PDO::FETCH_ASSOC) as $row) { $event = new CourseMarkedEvent(); $event->setData($row); $event->setNew(false); $event_collection[] = $event; } $event_collection = SimpleORMapCollection::createFromArray($event_collection, false); $event_collection->setClassName('Event'); return $event_collection; }
function getTabNavigation($course_id) { if (get_config('SCM_ENABLE')) { $temp = StudipScmEntry::findByRange_id($course_id, 'ORDER BY position ASC'); $scms = SimpleORMapCollection::createFromArray($temp); $navigation = new Navigation($scms->first()->tab_name ?: _('Informationen')); $navigation->setImage(Icon::create('infopage', 'info_alt')); $navigation->setActiveImage(Icon::create('infopage', 'info')); foreach ($scms as $scm) { $scm_link = 'dispatch.php/course/scm/' . $scm->id; $nav = new Navigation($scm['tab_name'], $scm_link); $navigation->addSubNavigation($scm->id, $nav); } return array('scm' => $navigation); } else { return null; } }
/** * Returns all CourseEvents in the given time range for the given range_id. * * @param string $user_id Id of Stud.IP object from type user, course, inst * @param DateTime $start The start date time. * @param DateTime $end The end date time. * @return SimpleORMapCollection Collection of found CourseEvents. */ public static function getEventsByInterval($user_id, DateTime $start, dateTime $end) { $stmt = DBManager::get()->prepare('SELECT termine.* FROM seminar_user ' . 'INNER JOIN termine ON seminar_id = range_id ' . 'WHERE user_id = :user_id ' . 'AND date BETWEEN :start AND :end ' . "AND (IFNULL(metadate_id, '') = '' " . 'OR metadate_id NOT IN ( ' . 'SELECT metadate_id FROM schedule_seminare ' . 'WHERE user_id = :user_id AND visible = 0) ) ' . 'ORDER BY date ASC'); $stmt->execute(array(':user_id' => $user_id, ':start' => $start->getTimestamp(), ':end' => $end->getTimestamp())); $event_collection = array(); foreach ($stmt->fetchAll(PDO::FETCH_ASSOC) as $row) { $event = new CourseEvent(); $event->setData($row); $event->setNew(false); // related persons (dozenten) or groups if (self::checkRelated($event, $user_id)) { $event_collection[] = $event; } } $event_collection = SimpleORMapCollection::createFromArray($event_collection, false); $event_collection->setClassName('Event'); return $event_collection; }
/** * Delete a group */ public function deleteGroup_action($group_id) { $this->check('edit'); $this->group = new Statusgruppen($group_id); if (Request::submitted('confirm')) { CSRFProtection::verifySecurityToken(); // move all subgroups to the parent $children = SimpleORMapCollection::createFromArray($this->group->children); $children->setValue('range_id', $this->group->range_id); $children->store(); //remove users $this->group->removeAllUsers(); //goodbye group $this->group->delete(); $this->redirect('admin/statusgroups/index'); } }
/** * Sets the filters for the log view. * Filters are stored in the session. */ public function filter_action() { $filter = array_filter(Request::optionArray('filter')); $conditions = array(); if (!empty($filter['status'])) { $conditions[] = ($filter['status'] === 'passed') ? "exception = 'N;'" : "exception != 'N;'"; } if (!empty($filter['schedule_id'])) { $conditions[] = "schedule_id = " . DBManager::get()->quote($filter['schedule_id']); } if (!empty($filter['task_id'])) { $temp = CronjobSchedule::findByTask_id($filter['task_id']); $temp = SimpleORMapCollection::createFromArray($temp); $schedule_ids = $temp->pluck('schedule_id') ?: null; $conditions[] = "schedule_id IN (" . DBManager::get()->quote($schedule_ids). ")"; } $_SESSION['cronlog-filter'] = array( 'where' => implode(" AND " , $conditions) ?: '1', 'values' => $filter, ); $this->redirect('admin/cronjobs/logs'); }
private static function folder($user_id, $sndrec, $folder, $unread = null) { $temp = \MessageUser::findBySQL('user_id = ? AND snd_rec = ? AND deleted = 0', array($user_id, $sndrec)); $messages = \SimpleORMapCollection::createFromArray($temp); if ($unread !== null) { $messages = $messages->filter(function ($message) use($unread) { return $message->readed == ($unread ? 0 : 1); }); } return $messages->pluck('message_id'); }
/** * Edits or creates a page. * * @param mixed $id Id of the page to edit; a new page will be created if * this parameter is omitted. */ public function edit_action($id = null) { if (Request::submitted('submit')) { CSRFProtection::verifyUnsafeRequest(); $scm = new StudipScmEntry($id); $scm->tab_name = Request::get('tab_name_template') ?: Request::get('tab_name'); $scm->content = Studip\Markup::purifyHtml(Request::get('content')); $scm->user_id = $GLOBALS['user']->id; $scm->range_id = $GLOBALS['SessSemName'][1]; if ($scm->isNew()) { $temp = StudipScmEntry::findByRange_id($GLOBALS['SessSemName'][1], 'ORDER BY position ASC'); $scms = SimpleORMapCollection::createFromArray($temp); $max = max($scms->pluck('position')); $scm->position = $max + 1; } if ($scm->store() !== false) { $message = MessageBox::success(_('Die Änderungen wurden übernommen.')); PageLayout::postMessage($message); } $this->redirect('course/scm/' . $scm->id); } $this->scm = new StudipScmEntry($id); $this->set_title(_('Informationsseite bearbeiten') . ': ' . $this->scm->tab_name); Navigation::activateItem('/course/scm/' . $this->scm->id); }
/** * Returns all events of given class names between start and end. * Returns events of all types if no class names are given. * * @param array|null $class_names The names of classes that implements Event. * @param int $start The start date time. * @param int $end The end date time. * @return \SingleCalendar This calendar object. * @throws InvalidArgumentException */ public function getEvents($class_names = null, $start = null, $end = null) { $start = !is_null($start) ? $start : $this->start; $end = !is_null($end) ? $end : $this->end; if (!is_array($class_names)) { $class_names = array('CalendarEvent', 'CourseEvent', 'CourseCancelledEvent', 'CourseMarkedEvent'); } $events = $this->events->getArrayCopy(); foreach ($class_names as $type) { if (in_array('Event', class_implements($type))) { $events = array_merge($events, $type::getEventsByInterval($this->range_object->getId(), new DateTime('@' . $start), new DateTime('@' . $end))->getArrayCopy()); } else { throw new InvalidArgumentException(sprintf('Class %s does not implements Event.', $type)); } } $this->events = SimpleORMapCollection::createFromArray($events, false); $this->events->setClassName('Event'); return $this; }
/** * show institute basicdata page * * @param mixed $i_id Optional institute id * @throws AccessDeniedException */ public function index_action($i_id = false) { PageLayout::setTitle(_('Verwaltung der Grunddaten')); Navigation::activateItem('/admin/institute/details'); //get ID from an open Institut $i_view = $i_id ?: Request::option('i_view', $GLOBALS['SessSemName'][1]); if (!$i_view) { require_once 'lib/admin_search.inc.php'; // This search just died a little inside, so it should be safe to // continue here but we nevertheless return just to be sure return; } elseif ($i_view === 'new') { closeObject(); } // allow only inst-admin and root to view / edit if ($i_view && !$GLOBALS['perm']->have_studip_perm('admin', $i_view) && $i_view !== 'new') { throw new AccessDeniedException(); } //Change header_line if open object $header_line = getHeaderLine($i_view); if ($header_line) { PageLayout::setTitle($header_line . ' - ' . PageLayout::getTitle()); } if (Request::get('i_trykill')) { $message = _('Sind Sie sicher, dass Sie diese Einrichtung löschen wollen?'); $post['i_kill'] = 1; $post['studipticket'] = get_ticket(); $this->question = createQuestion2($message, $post, array(), $this->url_for('institute/basicdata/delete/' . $i_view)); } $lockrule = LockRules::getObjectRule($i_view); if ($lockrule->description && LockRules::CheckLockRulePermission($i_view, $lockrule['permission'])) { PageLayout::postMessage(MessageBox::info(formatLinks($lockrule->description))); } // Load institute data $institute = new Institute($i_view === 'new' ? null : $i_view); //add the free administrable datafields $datafields = array(); $localEntries = DataFieldEntry::getDataFieldEntries($institute->id, 'inst'); if ($localEntries) { $invalidEntries = $this->flash['invalid_entries'] ?: array(); foreach ($localEntries as $entry) { if (!$entry->isVisible()) { continue; } $color = '#000000'; if (in_array($entry->getId(), $invalidEntries)) { $color = '#ff0000'; } $datafields[] = array('color' => $color, 'title' => $entry->getName(), 'value' => $GLOBALS['perm']->have_perm($entry->isEditable()) && !LockRules::Check($institute['Institut_id'], $entry->getId()) ? $entry->getHTML('datafields') : $entry->getDisplayValue()); } } // Read faculties if neccessary if (count($institute->sub_institutes) === 0) { if ($GLOBALS['perm']->have_perm('root')) { $this->faculties = Institute::findBySQL('Institut_id = fakultaets_id ORDER BY Name ASC', array($i_view)); } else { $temp = User::find($GLOBALS['user']->id)->institute_memberships->findBy('inst_perms', 'admin')->pluck('institute'); $institutes = SimpleORMapCollection::createFromArray($temp); $faculties = $institutes->filter(function ($institute) { return $institute->is_fak; }); $this->faculties = $faculties; } } // Indicates whether the current user is allowed to delete the institute $this->may_delete = $i_view !== 'new' && !(count($institute->home_courses) || count($institute->sub_institutes)) && ($GLOBALS['perm']->have_perm('root') || $GLOBALS['perm']->is_fak_admin() && get_config('INST_FAK_ADMIN_PERMS') == 'all'); if (!$this->may_delete) { //Set infotext for disabled delete-button $reason_txt = _('Löschen nicht möglich.'); if (count($institute->home_courses) > 0) { $reason_txt .= ' '; $reason_txt .= sprintf(ngettext('Es ist eine Veranstaltung zugeordnet.', 'Es sind %u Veranstaltungen zugeordnet.', count($institute->home_courses)), count($institute->home_courses)); } if (count($institute->sub_institutes) > 0) { $reason_txt .= ' '; $reason_txt .= sprintf(ngettext('Es ist eine Einrichtung zugeordnet.', 'Es sind %u Einrichtungen zugeordnet.', count($institute->sub_institutes)), count($institute->sub_institutes)); } } // Indicates whether the current user is allowed to change the faculty $this->may_edit_faculty = $GLOBALS['perm']->is_fak_admin() && !LockRules::Check($institute['Institut_id'], 'fakultaets_id') && ($GLOBALS['perm']->have_studip_perm('admin', $institute['fakultaets_id']) || $i_view === 'new'); // Prepare template $this->institute = $institute; $this->i_view = $i_view; $this->datafields = $datafields; $this->reason_txt = $reason_txt; }
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(); }
/** * Stores the given values to the given course. * * @param Course $course the course to store values for * @param Array $values values to set * @return Course The course object with updated values. */ public function storeValues($course, $values) { // We only need our own stored values here. $values = $values[__CLASS__]; $course->study_areas = SimpleORMapCollection::createFromArray(StudipStudyArea::findMany($values['studyareas'])); if ($course->store()) { return $course; } else { return false; } }
/** * Retrieves all contact groups (statusgruppen) owned by the given user * where at least one member has granted access to his calender for the user. * * @param string $user_id User id of the owner. * @return type */ public static function getGroups($user_id) { $groups = array(); $calendar_owners = CalendarUser::getOwners($user_id)->pluck('owner_id'); $sg_groups = SimpleORMapCollection::createFromArray(Statusgruppen::findByRange_id($user_id))->orderBy('position')->pluck('statusgruppe_id'); if (sizeof($calendar_owners)) { $sg_users = StatusgruppeUser::findBySQL('statusgruppe_id IN(?) AND user_id IN(?)', array($sg_groups, $calendar_owners)); foreach ($sg_users as $sg_user) { $groups[$sg_user->group->id] = $sg_user->group; } } return $groups; }
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); } }
/** * Finds all users by given search string. Searches for the users id, * part of the name or the username. * * @param type $needle The needle to search for. * @return array */ public static function searchUser($needle) { $result = array(); $users = User::findBySQL("Nachname LIKE CONCAT('%', :needle, '%')\n OR Vorname LIKE CONCAT('%', :needle, '%')\n OR CONCAT(Nachname, ', ', Vorname) LIKE CONCAT('%', :needle, '%')\n OR CONCAT(Vorname, ' ', Nachname) LIKE CONCAT('%', :needle, '%')\n OR username LIKE CONCAT('%', :needle, '%')", array(':needle' => $needle)); foreach ($users as $user) { $name = sprintf('%s (%s)', my_substr($user->getFullname(), 0, 20), $user->username); $result[] = array($user->getId(), $name); } // search for deleted users // // The name of the user is part of info field, // old id (still in DB) is in affected column. // // The log action "USER_DEL" was removed from the list of initially // registered log actions in the past. // Search for the user if it is still in database. If not, the search // for deleted users is not possible. $log_action_deleted_user = SimpleORMapCollection::createFromArray(LogAction::findByName('USER_DEL'))->first(); if ($log_action_deleted_user) { $log_events_deleted_user = LogEvent::findBySQL("action_id = ? AND info LIKE CONCAT('%', ?, '%')", array($log_action_deleted_user->getId(), $needle)); foreach ($log_events_deleted_user as $log_event) { $name = sprintf('%s (%s)', $log_event->info, _('gelöscht')); $result[] = array($log_event->affected_range_id, $name); } } return $result; }
/** * Returns all CalendarEvents in the given time range for the given range_id. * * @param string $range_id Id of Stud.IP object from type user, course, inst * @param DateTime $start The start date time. * @param DateTime $end The end date time. * @return SimpleORMapCollection Collection of found CalendarEvents. */ public static function getEventsByInterval($range_id, DateTime $start, DateTime $end) { $stmt = DBManager::get()->prepare('SELECT * FROM calendar_event ' . 'INNER JOIN event_data USING(event_id) ' . 'WHERE range_id = :range_id ' . 'AND (start BETWEEN :start AND :end OR ' . "(start <= :end AND (expire + end - start) >= :start AND rtype != 'SINGLE') " . 'OR (:start BETWEEN start AND end)) ' . 'ORDER BY start ASC'); $stmt->execute(array(':range_id' => $range_id, ':start' => $start->getTimestamp(), ':end' => $end->getTimestamp())); $i = 0; $event_collection = array(); foreach ($stmt->fetchAll(PDO::FETCH_ASSOC) as $row) { $event_collection[$i] = new CalendarEvent(); $event_collection[$i]->setData($row); $event_collection[$i]->setNew(false); $event = new EventData(); $event->setData($row); $event->setNew(false); $event_collection[$i]->event = $event; $i++; } $event_collection = SimpleORMapCollection::createFromArray($event_collection, false); $event_collection->setClassName('Event'); return $event_collection; }
/** * Sends an internal mail with the provided subject and message to all * users with a global permission of "root". * * @param String $subject The subject of the message * @param String $message The message itself */ private function sendMailToRoots($subject, $message) { $temp = User::findByPerms('root'); $roots = SimpleORMapCollection::createFromArray($temp)->pluck('username'); $msging = new messaging(); $msging->insert_message($message, $roots, '____%system%____', null, null, null, null, $subject, false, 'high'); }
private function findMembershipsByUserId($user_id, $semester) { $memberships = \SimpleORMapCollection::createFromArray(\CourseMember::findBySQL('user_id = ? ORDER BY mkdate ASC', array($user_id))); // filter by semester if ($semester) { $memberships = $memberships->filter(function ($m) use($semester) { $course = $m->course; return $course->start_time == $semester->beginn || $course->start_time <= $semester->beginn && ($course->duration_time == -1 || $semester->beginn <= $course->end_time); }); } return $memberships; }
public function assign() { if ($this->course->study_areas) { foreach ($this->course->study_areas as $area) { $assigned[] = $area->sem_tree_id; } foreach (array_keys(Request::getArray('assign')) as $new) { if (!in_array($new, $assigned)) { $assigned[] = $new; } } } $this->course->study_areas = SimpleORMapCollection::createFromArray(StudipStudyArea::findMany($assigned)); try { $msg = null; $this->course->store(); } catch (UnexpectedValueException $e) { $msg = $e->getMessage(); } return $msg; }