Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • alexander.vorwerk/studip
  • hochschule-wismar/stud-ip
  • tleilax/studip
  • marcus/studip
  • manschwa/studip
  • eberhardt/studip
  • uol/studip
  • pluta/studip
  • thienel/extern-uni-b
  • studip/studip
  • strohm/studip
  • uni-osnabrueck/studip
  • FloB/studip
  • universit-t-rostock/studip
  • Robinyyy/studip
  • jakob.diel/studip
  • HyperSpeeed/studip
  • ann/studip
  • nod3zer0/stud-ip-siple-saml-php-plugin
19 results
Show changes
Showing
with 436 additions and 294 deletions
......@@ -59,7 +59,6 @@ class NewsController extends StudipController
* Widget controller to produce the formally known show_votes()
*
* @param String $range_id range id of the news to get displayed
* @return array() Array of votes
*/
public function display_action($range_id)
{
......@@ -73,14 +72,29 @@ class NewsController extends StudipController
return $this->render_nothing();
}
// Store visit if user opened comments
if (Request::bool('comments') && Request::submitted('contentbox_open')) {
object_set_visit(Request::option('contentbox_open'), 'news');
}
// Check if user wrote a comment
if (Request::submitted('accept') && trim(Request::get('comment_content')) && Request::isPost()) {
CSRFProtection::verifySecurityToken();
StudipComment::create([
'object_id' => Request::get('comsubmit'),
$news_id = Request::get('comsubmit');
$comment = StudipComment::create([
'object_id' => $news_id,
'user_id' => $GLOBALS['user']->id,
'content' => trim(Request::get('comment_content'))
]);
$url = URLHelper::getURL(Request::url() . "#newscomment-{$comment->id}", [
'contentbox_open' => $news_id,
'comments' => true,
]);
$this->redirect($url);
return;
}
// Check if user wants to remove a announcement
......@@ -671,7 +685,6 @@ class NewsController extends StudipController
LEFT JOIN semester_courses ON (semester_courses.course_id = seminar_user.Seminar_id)
WHERE seminar_user.user_id = :user_id
AND seminar_user.status IN('tutor', 'dozent')
AND seminare.start_time <= :start
AND (semester_courses.semester_id = :semester_id OR semester_courses.semester_id IS NULL)
";
if (Config::get()->DEPUTIES_ENABLE) {
......@@ -681,13 +694,11 @@ class NewsController extends StudipController
LEFT JOIN seminare ON (deputies.range_id=seminare.Seminar_id)
LEFT JOIN semester_courses ON (semester_courses.course_id = deputies.range_id)
WHERE deputies.user_id = :user_id
AND seminare.start_time <= :start
AND (semester_courses.semester_id = :semester_id OR semester_courses.semester_id IS NULL)";
}
$query .= " ORDER BY sem_name ASC";
$statement = DBManager::get()->prepare($query);
$statement->bindValue(':user_id', $GLOBALS['user']->id);
$statement->bindValue(':start', $current_semester->beginn);
$statement->bindValue(':semester_id', $current_semester->semester_id);
$statement->execute();
$seminars = $statement->fetchAll(PDO::FETCH_ASSOC);
......@@ -706,7 +717,6 @@ class NewsController extends StudipController
LEFT JOIN semester_courses ON (semester_courses.course_id = seminar_user.Seminar_id)
WHERE seminar_user.user_id = :user_id
AND seminar_user.status IN('tutor', 'dozent')
AND seminare.start_time <= :start
AND (semester_courses.semester_id = :semester_id OR semester_courses.semester_id IS NULL)";
if (Config::get()->DEPUTIES_ENABLE) {
$query .= " UNION SELECT CONCAT(seminare.Name, ' ["._("Vertretung")."]') AS sem_name, seminare.Seminar_id,
......@@ -715,13 +725,11 @@ class NewsController extends StudipController
LEFT JOIN seminare ON (deputies.range_id=seminare.Seminar_id)
LEFT JOIN semester_courses ON (semester_courses.course_id = deputies.range_id)
WHERE deputies.user_id = :user_id
AND seminare.start_time <= :start
AND (semester_courses.semester_id = :semester_id OR semester_courses.semester_id IS NULL)";
}
$query .= " ORDER BY sem_name ASC";
$statement = DBManager::get()->prepare($query);
$statement->bindValue(':user_id', $GLOBALS['user']->id);
$statement->bindValue(':start', $next_semester->beginn);
$statement->bindValue(':semester_id', $next_semester->semester_id);
$statement->execute();
$seminars = $statement->fetchAll(PDO::FETCH_ASSOC);
......
......@@ -31,7 +31,6 @@ class NotificationsController extends AuthenticatedController
//PageLayout::setHelpKeyword('Basis.InteraktionWhosOnline');
PageLayout::setTitle(_('Persönliche Benachrichtigungen'));
Navigation::activateItem('/messaging');
SkipLinks::addIndex(_('Wer ist online?'), 'layout_content', 100);
}
/**
......
......@@ -126,6 +126,9 @@ class Oer_AddfileController extends AuthenticatedController
//The folder is not a top folder. We can use its name directly.
$this->to_folder_name = $this->to_folder_type->name;
}
if (Request::isAjax()) {
$this->response->add_header('X-Dialog-Execute', 'STUDIP.OER.initSearch');
}
}
/**
......
......@@ -89,24 +89,17 @@ class Oer_EndpointsController extends StudipController
protected function refreshHost($url)
{
$host = OERHost::findOneByUrl($url);
if (!$host) {
return;
}
$host_data = file_get_contents($url."fetch_public_host_key");
if ($host_data) {
$host_data = json_decode($host_data, true);
if ($host_data) {
$host = OERHost::findOneByUrl($url);
if (!$host) {
$host = OERHost::findOneByPublic_key($host_data['public_key']);
}
if (!$host) {
$host = new OERHost();
}
$host['name'] = $host_data['name'];
$host['url'] = Request::get("from");
$host['public_key'] = $host_data['public_key'];
$host['last_updated'] = time();
if ($host->isNew()) {
$host['active'] = Config::get()->LERNMARKTPLATZ_ACTIVATE_NEW_HOSTS ? 1 : 0;
}
$host->store();
}
}
......
......@@ -28,7 +28,6 @@ class OnlineController extends AuthenticatedController
PageLayout::setHelpKeyword('Basis.InteraktionWhosOnline');
PageLayout::setTitle(_('Wer ist online?'));
Navigation::activateItem('/community/online');
SkipLinks::addIndex(_('Wer ist online?'), 'layout_content', 100);
$this->settings = $GLOBALS['user']->cfg->MESSAGING_SETTINGS;
......
......@@ -27,7 +27,6 @@ class ProfileController extends AuthenticatedController
Navigation::activateItem('/profile/index');
URLHelper::addLinkParam('username', Request::username('username'));
PageLayout::setHelpKeyword('Basis.Homepage');
SkipLinks::addIndex(_('Benutzerprofil'), 'user_profile', 100);
$this->user = User::findCurrent(); // current logged in user
$this->perm = $GLOBALS['perm']; // perms of current logged in user
......@@ -117,7 +116,7 @@ class ProfileController extends AuthenticatedController
$show_admin = ($this->perm->have_perm('autor') && $this->user->user_id == $this->current_user->user_id)
|| (Deputy::isEditActivated() && Deputy::isDeputy($this->user->user_id, $this->current_user->user_id, true));
if (Visibility::verify('news', $this->current_user->user_id) || $show_admin) {
$response = $this->relay('news/display/' . $this->current_user->user_id);
$response = $this->relayWithRedirect('news/display/' . $this->current_user->user_id);
$this->news = $response->body;
}
......
......@@ -254,7 +254,7 @@ class ProfileModulesController extends AuthenticatedController
$state = (bool) $state;
if ($state != $manager->isPluginActivatedForUser($item, $this->user->id)
&& $manager->setPluginActivated($item, $this->user->id, $state, 'user'))
&& $manager->setPluginActivatedForUser($item, $this->user->id, $state))
{
return [$state, $this->plugins[$item]->getPluginName()];
}
......
......@@ -59,28 +59,9 @@ class PublicCoursesController extends AuthenticatedController
$seminars = $statement->fetchGrouped(PDO::FETCH_ASSOC);
$seminars = $this->get_seminar_navigations($seminars);
$seminars = $this->get_plugin_navigations($seminars);
$this->seminars = $seminars;
}
/**
* Loads all possible standard plugins for the given seminars and adds
* a navigation entry for each one.
*
* @param array $seminars List of seminars
* @return array Extended list of seminars
*/
protected function get_plugin_navigations($seminars)
{
foreach ($seminars as $id => $seminar) {
foreach (PluginEngine::getPlugins('StandardPlugin', $id) as $plugin) {
$seminars[$id]['navigations'][] = $plugin->getIconNavigation($id, time(), $GLOBALS['user']->id);
}
}
return $seminars;
}
/**
* Adds all navigation entries for each passed seminar.
*
......@@ -95,11 +76,29 @@ class PublicCoursesController extends AuthenticatedController
foreach ($seminars as $id => $seminar) {
$seminar['navigations'] = [];
foreach (words('forum files news scm schedule wiki vote') as $key) {
$seminar['navigations'][$key] = false;
$seminar['tools'] = new SimpleCollection(ToolActivation::findByrange_id($id));
foreach (MyRealmModel::getDefaultModules() as $plugin_id => $plugin) {
// Go to next module if current module is not available and not voting-module
if ($plugin !== 'vote' && !$seminar['tools']->findOneBy('plugin_id', $plugin_id)) {
$seminar['navigations'][get_class($plugin)] = null;
continue;
}
if (!Config::get()->VOTE_ENABLE && $plugin_id === 'vote') {
continue;
}
if ($plugin === 'vote') {
$seminar['navigations'][$plugin] = false;
} else if ($tool = $seminar['tools']->findOneBy('plugin_id', $plugin_id)) {
if ($tool->getVisibilityPermission() === 'nobody') {
$seminar['navigations'][get_class($plugin)] = false;
} else {
$seminar['navigations'][get_class($plugin)] = null;
}
}
}
$seminars[$id] = $seminar;
}
......@@ -115,9 +114,11 @@ class PublicCoursesController extends AuthenticatedController
$statement = DBManager::get()->prepare($query);
$statement->execute([$seminar_ids]);
while ($row = $statement->fetch(PDO::FETCH_ASSOC)) {
$nav = new Navigation('files', 'dispatch.php/course/files/index');
$nav->setImage(Icon::create('files', 'inactive', ["title" => sprintf(_('%s Dokumente'),$row['count'])]));
$seminars[$row['range_id']]['navigations']['files'] = $nav;
if (isset($seminars[$row['range_id']]['navigations']['CoreDocuments'])) {
$nav = new Navigation('files', 'dispatch.php/course/files/index');
$nav->setImage(Icon::create('files', Icon::ROLE_CLICKABLE, ["title" => sprintf(_('%s Dokumente'), $row['count'])]));
$seminars[$row['range_id']]['navigations']['CoreDocuments'] = $nav;
}
}
// News
......@@ -130,9 +131,11 @@ class PublicCoursesController extends AuthenticatedController
$statement = DBManager::get()->prepare($query);
$statement->execute([$seminar_ids]);
while ($row = $statement->fetch(PDO::FETCH_ASSOC)) {
$nav = new Navigation('news', '');
$nav->setImage(Icon::create('news', 'inactive', ["title" => sprintf(_('%s Ankündigungen'),$row['count'])]));
$seminars[$row['range_id']]['navigations']['news'] = $nav;
if (isset($seminars[$row['range_id']]['navigations']['CoreOverview'])) {
$nav = new Navigation('news', '');
$nav->setImage(Icon::create('news', Icon::ROLE_CLICKABLE, ["title" => sprintf(_('%s Ankündigungen'),$row['count'])]));
$seminars[$row['range_id']]['navigations']['CoreOverview'] = $nav;
}
}
// Information
......@@ -143,9 +146,11 @@ class PublicCoursesController extends AuthenticatedController
$statement = DBManager::get()->prepare($query);
$statement->execute([$seminar_ids]);
while ($row = $statement->fetch(PDO::FETCH_ASSOC)) {
$nav = new Navigation('scm', 'dispatch.php/course/scm');
$nav->setImage(Icon::create('infopage', 'inactive', ["title" => sprintf(_('%s Einträge'),$row['count'])]));
$seminars[$row['range_id']]['navigations']['scm'] = $nav;
if (isset($seminars[$row['range_id']]['navigations']['CoreScm'])) {
$nav = new Navigation('scm', 'dispatch.php/course/scm');
$nav->setImage(Icon::create('infopage', Icon::ROLE_CLICKABLE, ["title" => sprintf(_('%s Einträge'), $row['count'])]));
$seminars[$row['range_id']]['navigations']['CoreScm'] = $nav;
}
}
// Appointments
......@@ -156,9 +161,11 @@ class PublicCoursesController extends AuthenticatedController
$statement = DBManager::get()->prepare($query);
$statement->execute([$seminar_ids]);
while ($row = $statement->fetch(PDO::FETCH_ASSOC)) {
$nav = new Navigation('schedule', 'dispatch.php/course/dates');
$nav->setImage(Icon::create('schedule', 'inactive', ["title" => sprintf(_('%s Termine'),$row['count'])]));
$seminars[$row['range_id']]['navigations']['schedule'] = $nav;
if (isset($seminars[$row['range_id']]['navigations']['CoreSchedule'])) {
$nav = new Navigation('schedule', 'dispatch.php/course/dates');
$nav->setImage(Icon::create('schedule', Icon::ROLE_CLICKABLE, ["title" => sprintf(_('%s Termine'), $row['count'])]));
$seminars[$row['range_id']]['navigations']['CoreSchedule'] = $nav;
}
}
// Wiki
......@@ -170,9 +177,11 @@ class PublicCoursesController extends AuthenticatedController
$statement = DBManager::get()->prepare($query);
$statement->execute([$seminar_ids]);
while ($row = $statement->fetch(PDO::FETCH_ASSOC)) {
$nav = new Navigation('wiki', 'wiki.php');
$nav->setImage(Icon::create('wiki', 'inactive', ["title" => sprintf(_('%s WikiSeiten'),$row['count'])]));
$seminars[$row['range_id']]['navigations']['wiki'] = $nav;
if (isset($seminars[$row['range_id']]['navigations']['CoreWiki'])) {
$nav = new Navigation('wiki', 'wiki.php');
$nav->setImage(Icon::create('wiki', Icon::ROLE_CLICKABLE, ["title" => sprintf(_('%s WikiSeiten'), $row['count'])]));
$seminars[$row['range_id']]['navigations']['CoreWiki'] = $nav;
}
}
}
......@@ -187,12 +196,29 @@ class PublicCoursesController extends AuthenticatedController
$statement = DBManager::get()->prepare($query);
$statement->execute([$seminar_ids]);
while ($row = $statement->fetch(PDO::FETCH_ASSOC)) {
$nav = new Navigation('vote', '#vote');
$nav->setImage(Icon::create('vote', 'inactive', ["title" => sprintf(_('%s Umfrage(n)'),$row['count'])]));
$seminars[$row['range_id']]['navigations']['vote'] = $nav;
if (isset($seminars[$row['range_id']]['navigations']['vote'])) {
$nav = new Navigation('vote', '#vote');
$nav->setImage(Icon::create('vote', Icon::ROLE_CLICKABLE, ["title" => sprintf(_('%s Umfrage(n)'), $row['count'])]));
$seminars[$row['range_id']]['navigations']['vote'] = $nav;
}
}
}
foreach ($seminars as $id => $seminar) {
foreach ($seminar['tools'] as $tool) {
$module = $tool->getStudipModule();
if (!$module || in_array(get_class($module), ['CoreAdmin', 'CoreStudygroupAdmin', 'CoreWiki', 'CoreSchedule', 'CoreScm', 'CoreOverview', 'CoreDocuments'])) {
continue;
}
if ($tool->getVisibilityPermission() === 'nobody') {
$seminar['navigations'][get_class($module)] = $module->getIconNavigation($id, time(), 'nobody');
} else {
$seminar['navigations'][get_class($module)] = null;
}
}
$seminars[$id] = $seminar;
}
return $seminars;
}
}
......@@ -622,7 +622,7 @@ class QuestionnaireController extends AuthenticatedController
if ($one->isStopped() && $one->resultsVisible()) {
$stopped_visible++;
}
if ($one->isStopped() && (!$one->resultsVisible() || !Request::get("questionnaire_showall"))) {
if (($one->isStopped() || !$one->isViewable()) && (!$one->resultsVisible() || !Request::get("questionnaire_showall"))) {
unset($this->questionnaire_data[$i]);
continue;
}
......@@ -710,9 +710,9 @@ class QuestionnaireController extends AuthenticatedController
//Search courses matching the search criteria:
$sql = 'start_time = :semester_begin ';
$sql = 'LEFT JOIN semester_courses ON (semester_courses.course_id = seminare.Seminar_id) WHERE (semester_courses.semester_id = :semester_id OR semester_courses.semester_id IS NULL) ';
$sql_array = [
'semester_begin' => $this->semester->beginn
'semester_id' => $this->semester->id
];
if ($this->institute) {
......
......@@ -304,23 +304,32 @@ class Resources_ExportController extends AuthenticatedController
foreach ($resources as $resource) {
//Retrieve the bookings in the specified time range:
$bookings = ResourceBooking::findByResourceAndTimeRanges(
$resource,
$intervals = ResourceBookingInterval::findBySql(
'resource_id = :resource_id AND begin < :end AND end > :begin ORDER BY begin, end',
[
[
'begin' => $this->begin->getTimestamp(),
'end' => $this->end->getTimestamp()
]
],
[0, 1, 2, 3]
'resource_id' => $resource->id,
'begin' => $this->begin->getTimestamp(),
'end' => $this->end->getTimestamp()
]
);
//Prepare data for export:
foreach ($bookings as $booking) {
foreach ($intervals as $interval) {
$booking = $interval->booking;
if (!$booking instanceof ResourceBooking) {
continue;
}
$description = $booking->description;
if (!$booking->isSimpleBooking()) {
$course = $booking->assigned_course_date->course;
if ($course instanceof Course) {
$description = $course->getFullName();
}
}
$booking_data[] = [
date('d.m.Y H:i', $booking->begin),
date('d.m.Y H:i', $booking->end),
date('d.m.Y H:i', ($interval->begin + $booking->preparation_time)),
date('d.m.Y H:i', $interval->end),
sprintf(
_('%u min.'),
intval($booking->preparation_time / 60)
......@@ -339,7 +348,7 @@ class Resources_ExportController extends AuthenticatedController
)
)
),
$booking->description,
$description,
$booking->booking_user ? $booking->booking_user->getFullName() : '',
implode(', ', $booking->getAssignedUsers()),
$booking->internal_comment
......
......@@ -132,7 +132,7 @@ class Resources_LocationController extends AuthenticatedController
if (!ResourceManager::userHasGlobalPermission(User::findCurrent(), 'admin')) {
throw new AccessDeniedException();
}
$this->next_action = Request::get('next_action');
$this->categories = ResourceCategory::findByClass_name('Location');
......@@ -171,21 +171,25 @@ class Resources_LocationController extends AuthenticatedController
$this->category_id = Request::get('category_id');
$this->name = '';
$this->description = '';
$this->latitude = '0.0';
$this->longitude = '0.0';
$this->altitude = '0.0';
$this->latitude = '';
$this->longitude = '';
$this->altitude = '';
$this->sort_position = '';
if ($mode == 'edit') {
//Set data from the location object:
$this->name = $this->location->name;
$this->description = $this->location->description;
$position_data = ResourceManager::getPositionArray(
$this->location->getPropertyObject('geo_coordinates')
);
$this->latitude = $position_data[0];
$this->longitude = $position_data[1];
$this->altitude = $position_data[2];
$geo_coordinates = $this->location->getPropertyObject('geo_coordinates');
if ($geo_coordinates) {
$position_data = ResourceManager::getPositionArray(
$this->location->getPropertyObject('geo_coordinates')
);
$this->latitude = $position_data[0];
$this->longitude = $position_data[1];
$this->altitude = $position_data[2];
}
$this->sort_position = $this->location->sort_position;
}
}
......@@ -233,7 +237,6 @@ class Resources_LocationController extends AuthenticatedController
$this->altitude = Request::float('geo_coordinates_altitude');
$this->osm_link = Request::get('geo_coordinates_osm_link');
$this->property_data = Request::getArray('properties');
if ($GLOBALS['perm']->have_perm('root')) {
$this->sort_position = Request::get('sort_position');
}
......@@ -262,22 +265,30 @@ class Resources_LocationController extends AuthenticatedController
}
//data conversion:
$user = User::findCurrent();
$position_string = '';
if ($this->latitude >= 0.0) {
if ($this->latitude > 0.0) {
$position_string .= '+';
$position_string .= number_format($this->latitude, 7);
}
$position_string .= number_format($this->latitude, 7);
if ($this->longitude >= 0.0) {
if ($this->longitude > 0.0) {
$position_string .= '+';
$position_string .= number_format($this->longitude, 7);
}
$position_string .= number_format($this->longitude, 7);
if ($this->altitude >= 0.0) {
if ($this->altitude > 0.0) {
$position_string .= '+';
$position_string .= number_format($this->altitude, 7);
}
if ($position_string) {
$position_string .= 'CRSWGS_84/';
if ($this->location->isPropertyEditable('geo_coordinates', $user)) {
$this->location->geo_coordinates = $position_string;
} elseif ($this->location->geo_coordinates !== $position_string) {
$unchanged_properties[] = $this->location->getPropertyObject('geo_coordinates');
}
}
$position_string .= number_format($this->altitude, 7) . 'CRSWGS_84/';
//store data:
if ($mode == 'add') {
......@@ -290,7 +301,7 @@ class Resources_LocationController extends AuthenticatedController
if ($GLOBALS['perm']->have_perm('root')) {
$this->location->sort_position = $this->sort_position;
}
if ($this->location->isDirty()) {
$successfully_stored = $this->location->store();
} else {
......@@ -301,15 +312,8 @@ class Resources_LocationController extends AuthenticatedController
$this->location->sort_position = $this->sort_position;
}
$user = User::findCurrent();
$unchanged_properties = [];
if ($this->location->isPropertyEditable('geo_coordinates', $user)) {
$this->location->geo_coordinates = $position_string;
} elseif ($this->location->geo_coordinates != $position_string) {
$unchanged_properties[] = $this->location->getPropertyObject('geo_coordinates');
}
$failed_properties = $this->location->setPropertiesById(
$this->property_data,
$user
......
......@@ -48,7 +48,7 @@ class Resources_MessagesController extends AuthenticatedController
$this->clipboards = Clipboard::getClipboardsForUser(
$GLOBALS['user']->id,
'Room'
['Room']
);
//STUB
......
......@@ -48,7 +48,7 @@ class Resources_PrintController extends AuthenticatedController
)
);
if (!$this->resource->userHasPermission($current_user, 'user')) {
if (!$this->resource->userHasPermission($current_user)) {
throw new AccessDeniedException();
}
......@@ -61,13 +61,13 @@ class Resources_PrintController extends AuthenticatedController
$views = new ViewsWidget();
if ($GLOBALS['user']->id && ($GLOBALS['user']->id != 'nobody')) {
if ($this->resource->userHasPermission($current_user, 'user')) {
if ($this->resource->userHasPermission($current_user)) {
$views->addLink(
_('Standard Zeitfenster'),
URLHelper::getURL(
'dispatch.php/resources/print/individual_booking_plan/' . $this->resource->id,
$this->individual_booking_planURL(
$this->resource->id,
[
'defaultDate' => Request::get('defaultDate', date('Y-m-d'))
'defaultDate' => Request::get('defaultDate', date('Y-m-d', $this->timestamp))
]
),
null,
......@@ -76,11 +76,11 @@ class Resources_PrintController extends AuthenticatedController
$views->addLink(
_('Ganztägiges Zeitfenster'),
URLHelper::getURL(
'dispatch.php/resources/print/individual_booking_plan/' . $this->resource->id,
$this->individual_booking_planURL(
$this->resource->id,
[
'allday' => true,
'defaultDate' => Request::get('defaultDate', date('Y-m-d'))
'defaultDate' => Request::get('defaultDate', date('Y-m-d', $this->timestamp))
]
),
null,
......
......@@ -148,7 +148,7 @@ class Resources_ResourceController extends AuthenticatedController
protected function getPermissionUserSearch()
{
return QuickSearch::get(
'searched_user_id', new StandardSearch('user_id'));
'searched_user_id', new PermissionSearch('user'));
}
......@@ -1016,7 +1016,6 @@ class Resources_ResourceController extends AuthenticatedController
//Get the list of temporary permissions for the user-IDs in the list:
$user_permissions = Request::getArray('permissions');
//var_dump($user_permissions);die();
$processed_permissions = 0;
$errors = [];
......
......@@ -67,10 +67,7 @@ class Resources_RoomController extends AuthenticatedController
$user,
'autor'
);
$current_user_is_resource_user = $this->room->userHasPermission(
$user,
'user'
);
$current_user_is_resource_user = $this->room->userHasPermission($user);
$sidebar = Sidebar::get();
$actions = new ActionsWidget();
......@@ -167,6 +164,12 @@ class Resources_RoomController extends AuthenticatedController
$this->grouped_properties = $this->room->getGroupedProperties(
$this->room->getRequiredPropertyNames()
);
if ($this->room->building) {
$this->geo_coordinates_object = $this->room->building->getPropertyObject('geo_coordinates');
} else {
$this->geo_coordinates_object = null;
}
}
......@@ -289,6 +292,7 @@ class Resources_RoomController extends AuthenticatedController
$this->name = Request::get('name');
$this->description = Request::get('description');
$this->requestable = Request::int('requestable');
$this->lockable = Request::int('lockable', 0);
$this->room_type = Request::get('room_type');
$this->seats = Request::int('seats');
$this->booking_plan_is_public = Request::get('booking_plan_is_public');
......@@ -363,6 +367,7 @@ class Resources_RoomController extends AuthenticatedController
$this->room->name = $this->name;
$this->room->description = $this->description;
$this->room->requestable = strval($this->requestable);
$this->room->lockable = $this->lockable;
if ($GLOBALS['perm']->have_perm('root')) {
$this->room->sort_position = $this->sort_position;
}
......@@ -458,6 +463,7 @@ class Resources_RoomController extends AuthenticatedController
$this->name = $this->room->name;
$this->description = $this->room->description;
$this->requestable = '1';
$this->lockable = 1;
$this->room_type = $this->room->room_type;
$this->seats = $this->room->seats;
$this->booking_plan_is_public = (bool)$this->room->booking_plan_is_public;
......
......@@ -297,7 +297,7 @@ class Resources_RoomPlanningController extends AuthenticatedController
. $this->resource->id
),
Icon::create('add')
)->asDialog("size=auto");
)->asDialog('size=auto');
}
if ($this->resource->userHasPermission($current_user)) {
$actions->addLink(
......@@ -312,10 +312,14 @@ class Resources_RoomPlanningController extends AuthenticatedController
'dispatch.php/resources/print/individual_booking_plan/'
. $this->resource->id,
[
'timestamp' => $week_timestamp
'timestamp' => $week_timestamp,
'defaultDate' => date('Y-m-d', $week_timestamp)
]
),
Icon::create('print')
Icon::create('print'),
[
'class' => 'resource-bookings-actions'
]
);
}
$actions->addLink(
......@@ -323,16 +327,18 @@ class Resources_RoomPlanningController extends AuthenticatedController
URLHelper::getURL(
'dispatch.php/resources/export/resource_bookings/' . $this->resource->id,
[
'timestamp' => $week_timestamp
'timestamp' => $week_timestamp,
'defaultDate' => date('Y-m-d', $week_timestamp)
]
),
Icon::create('file-excel'),
[
'data-dialog' => 'size=auto',
'id' => 'export-resource-bookings-action'
'class' => 'resource-bookings-actions'
]
);
}
if($GLOBALS['perm']->have_perm('admin')) {
if ($this->resource instanceof Room) {
$actions->addLink(
_('Raumeigenschaften anzeigen'),
......@@ -450,6 +456,22 @@ class Resources_RoomPlanningController extends AuthenticatedController
}
$this->rooms = RoomManager::getUserRooms($current_user);
//For the semester selector:
if (Request::get('semester_id')) {
$this->semester = Semester::find(Request::get('semester_id'));
if (!$this->semester) {
PageLayout::postError(
_('Das ausgewählte Semester wurde nicht in der Datenbank gefunden!')
);
return;
}
} else {
$this->semester = Semester::findCurrent();
}
$this->current_semester_id = $this->semester->id;
URLHelper::addLinkParam('semester_id', $this->semester->id);
if (Navigation::hasItem('/resources/planning/semester_plan')) {
Navigation::activateItem('/resources/planning/semester_plan');
}
......@@ -457,7 +479,8 @@ class Resources_RoomPlanningController extends AuthenticatedController
$new_resource_id = Request::get('new_resource_id');
if ($new_resource_id) {
$this->redirect(
'resources/room_planning/semester_plan/' . $new_resource_id
'resources/room_planning/semester_plan/' . $new_resource_id,
['semester_id' => $this->semester->id]
);
}
......@@ -489,18 +512,14 @@ class Resources_RoomPlanningController extends AuthenticatedController
$this->resource->getFullName()
)
);
$this->current_semester_id = Request::get('semester_id');
if ($this->current_semester_id) {
URLHelper::addLinkParam('semester_id', $this->semester_id);
} else {
$this->current_semester_id = Semester::findCurrent()->id;
}
if (Request::isDialog()) {
$this->dialog_semesters = array_reverse(Semester::getAll());
$this->plan_link = URLHelper::getLink(
'dispatch.php/resources/room_planning/semester_plan/' . $this->resource->id,
[
'allday' => Request::get('allday', false)
'allday' => Request::get('allday', false),
'semester_id' => $this->semester->id
]
);
}
......@@ -557,17 +576,6 @@ class Resources_RoomPlanningController extends AuthenticatedController
//Build sidebar:
$sidebar = Sidebar::get();
$this->semester = Semester::findCurrent();
//For the semester selector:
if (Request::submitted('semester_id')) {
$this->semester = Semester::find(Request::get('semester_id'));
if (!$this->semester) {
PageLayout::postError(
_('Das ausgewählte Semester wurde nicht in der Datenbank gefunden!')
);
return;
}
}
$this->fullcalendar_studip_urls = [];
if ($this->user_has_booking_permissions) {
......@@ -580,7 +588,7 @@ class Resources_RoomPlanningController extends AuthenticatedController
if ($this->rooms) {
$room_select = new SelectWidget(
_('Anderen Raum wählen'),
'',
URLHelper::getURL('', ['semester_id' => $this->semester->id]),
'new_resource_id'
);
$options = [];
......@@ -590,7 +598,7 @@ class Resources_RoomPlanningController extends AuthenticatedController
$room_select->setOptions($options, $this->resource->id);
$sidebar->addWidget($room_select);
}
if ($this->resource->userHasPermission($current_user, 'user')) {
if ($this->resource->userHasPermission($current_user)) {
$views = new ViewsWidget();
$views->setTitle(_('Zeitfenster'));
$views->addLink(
......@@ -598,7 +606,8 @@ class Resources_RoomPlanningController extends AuthenticatedController
URLHelper::getURL(
'dispatch.php/resources/room_planning/semester_plan/' . $this->resource->id,
[
'allday' => null
'allday' => null,
'semester_id' => $this->semester->id
]
),
null,
......@@ -611,6 +620,7 @@ class Resources_RoomPlanningController extends AuthenticatedController
'dispatch.php/resources/room_planning/semester_plan/' . $this->resource->id,
[
'allday' => true,
'semester_id' => $this->semester->id
]
),
null,
......@@ -661,6 +671,7 @@ class Resources_RoomPlanningController extends AuthenticatedController
'resources/room_planning/semester_plan/' . $this->resource->id,
[
'display_single_bookings' => '1',
'semester_id' => $this->semester->id
]
),
......@@ -668,6 +679,7 @@ class Resources_RoomPlanningController extends AuthenticatedController
'resources/room_planning/semester_plan/' . $this->resource->id,
[
'display_single_bookings' => null,
'semester_id' => $this->semester->id
]
),
[]
......@@ -679,7 +691,8 @@ class Resources_RoomPlanningController extends AuthenticatedController
URLHelper::getURL(
'dispatch.php/resources/room_planning/semester_plan/' . $this->resource->id,
[
'allday' => Request::get('allday', false)
'allday' => Request::get('allday', false),
'semester_id' => $this->semester->id
]
)
);
......@@ -699,7 +712,7 @@ class Resources_RoomPlanningController extends AuthenticatedController
_('Anderen Raum wählen'),
URLHelper::getURL(
'dispatch.php/resources/room_planning/semester_plan',
[],
['semester_id' => $this->semester->id],
true
),
Icon::create('refresh')
......
......@@ -58,11 +58,9 @@ class Resources_SearchController extends AuthenticatedController
$sidebar->addWidget($resource_tree_widget);
$this->current_user = User::findCurrent();
if (ResourceManager::userHasGlobalPermission($this->current_user)) {
$room_clipboard_widget = new RoomClipboardWidget();
$sidebar->addWidget($room_clipboard_widget);
$this->clipboard_widget_id = $room_clipboard_widget->getClipboardWidgetId();
}
$room_clipboard_widget = new RoomClipboardWidget();
$sidebar->addWidget($room_clipboard_widget);
$this->clipboard_widget_id = $room_clipboard_widget->getClipboardWidgetId();
$this->tree_selected_resource = Request::get('tree_selected_resource');
......@@ -95,6 +93,21 @@ class Resources_SearchController extends AuthenticatedController
}
PageLayout::postMessage($message);
}
$this->booking_plan_action_params = [];
if ($this->form_submitted) {
//Check if the time range criteria has been set.
//If so, set the begin date as parameter for the
//booking plan action URL.
$criteria = $room_search_widget->getSelectedCriteria();
if (isset($criteria['special__time_range']) && $criteria['special__time_range']) {
$begin = $criteria['special__time_range']['range']['begin'];
if ($begin instanceof DateTime) {
$this->booking_plan_action_params['defaultDate'] = $begin->format('Y-m-d');
}
}
}
}
}
}
......@@ -55,9 +55,7 @@ class Resources_StatisticsController extends AuthenticatedController
WHERE
rb.booking_type IN ( :types )
AND
(rbi.begin BETWEEN :begin AND :end)
OR
(rbi.end BETWEEN :begin AND :end);"
rbi.begin < :end AND rbi.end > :begin"
);
$sum_stmt->execute(
......
......@@ -1197,11 +1197,7 @@ class RoomManagement_PlanningController extends AuthenticatedController
ON resource_booking_intervals.booking_id = rb.id
WHERE rb.internal_comment <> ''
AND rb.resource_id IN ( :room_ids )
AND (
resource_booking_intervals.begin BETWEEN :begin AND :end
OR
resource_booking_intervals.end BETWEEN :begin AND :end
)
AND resource_booking_intervals.begin < :end AND resource_booking_intervals.end > :begin
ORDER BY resource_booking_intervals.begin ASC, resource_booking_intervals.end ASC",
[
'room_ids' => $this->room_ids,
......