mirror of
https://gitlab.com/TheGamecraft/c-cms.git
synced 2026-04-21 02:39:10 -04:00
hide event
This commit is contained in:
@@ -37,6 +37,9 @@ class CalendarController extends Controller
|
||||
|
||||
public function indexTable()
|
||||
{
|
||||
return view('admin.schedule.table.index',['events' => \App\Event::allThisYear()->sortBy('date_begin')]);
|
||||
$event = \App\Event::allThisYear()->sortBy('date_begin')->filter(function ($value,$key) {
|
||||
return $value->hidden != 1;
|
||||
});
|
||||
return view('admin.schedule.table.index',['events' => $event]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -100,6 +100,15 @@ class EventController extends Controller
|
||||
$event->use_schedule = 0;
|
||||
}
|
||||
|
||||
if(\request("hidden"))
|
||||
{
|
||||
$event->hidden = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
$event->hidden = 0;
|
||||
}
|
||||
|
||||
$event->calendar_color = \request('calendar_color');
|
||||
$event->calendar_icon = \request('calendar_icon');
|
||||
|
||||
@@ -225,7 +234,15 @@ class EventController extends Controller
|
||||
*/
|
||||
public function edit($id)
|
||||
{
|
||||
return view('admin.schedule.event.edit',['event' => \App\Event::find($id)]);
|
||||
$event = \App\Event::find($id);
|
||||
if ($event->hidden == 1)
|
||||
{
|
||||
if (\Auth::user()->p('instruction_see_hidden_event') != 1)
|
||||
{
|
||||
return redirect('/admin/schedule')->with('error','Modification non authorisé');
|
||||
}
|
||||
}
|
||||
return view('admin.schedule.event.edit',['event' => $event]);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -238,6 +255,13 @@ class EventController extends Controller
|
||||
public function update($id)
|
||||
{
|
||||
$event = Event::findOrFail($id);
|
||||
if ($event->hidden == 1)
|
||||
{
|
||||
if (\Auth::user()->p('instruction_see_hidden_event') != 1)
|
||||
{
|
||||
return redirect('/admin/schedule')->with('error','Modification non authorisé');
|
||||
}
|
||||
}
|
||||
|
||||
// if (\App\GoogleDriveFile::checkConfig())
|
||||
// {
|
||||
@@ -297,6 +321,15 @@ class EventController extends Controller
|
||||
$event->use_schedule = 0;
|
||||
}
|
||||
|
||||
if(\request("hidden"))
|
||||
{
|
||||
$event->hidden = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
$event->hidden = 0;
|
||||
}
|
||||
|
||||
$event->calendar_color = \request('calendar_color');
|
||||
$event->calendar_icon = \request('calendar_icon');
|
||||
|
||||
|
||||
@@ -62,6 +62,14 @@ class EventTypeController extends Controller
|
||||
{
|
||||
$eventType->use_schedule = 0;
|
||||
}
|
||||
if(\request("hidden"))
|
||||
{
|
||||
$eventType->hidden = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
$eventType->hidden = 0;
|
||||
}
|
||||
if ($request->is_mandatory == 'on')
|
||||
{
|
||||
$eventType->is_mandatory = 1;
|
||||
@@ -174,6 +182,14 @@ class EventTypeController extends Controller
|
||||
{
|
||||
$eventType->use_schedule = 0;
|
||||
}
|
||||
if(\request("hidden"))
|
||||
{
|
||||
$eventType->hidden = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
$eventType->hidden = 0;
|
||||
}
|
||||
if ($request->is_mandatory == 'on')
|
||||
{
|
||||
$eventType->is_mandatory = 1;
|
||||
|
||||
@@ -46,11 +46,28 @@ class ScheduleController extends Controller
|
||||
}
|
||||
|
||||
foreach ($allevents as $event) {
|
||||
if(strtotime($event->date_begin) >= $start && strtotime($event->date_begin) <= $end) {
|
||||
array_push($events,$event);
|
||||
if ($event->hidden == 1) {
|
||||
if (\Auth::check())
|
||||
{
|
||||
if (\Auth::user()->p('instruction_see_hidden_event') == 1)
|
||||
{
|
||||
if(strtotime($event->date_begin) >= $start && strtotime($event->date_begin) <= $end) {
|
||||
array_push($events,$event);
|
||||
}
|
||||
else if(strtotime($event->date_end) >= $start && strtotime($event->date_end) <= $end) {
|
||||
array_push($events,$event);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(strtotime($event->date_end) >= $start && strtotime($event->date_end) <= $end) {
|
||||
array_push($events,$event);
|
||||
else
|
||||
{
|
||||
if(strtotime($event->date_begin) >= $start && strtotime($event->date_begin) <= $end) {
|
||||
array_push($events,$event);
|
||||
}
|
||||
else if(strtotime($event->date_end) >= $start && strtotime($event->date_end) <= $end) {
|
||||
array_push($events,$event);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -90,8 +107,16 @@ class ScheduleController extends Controller
|
||||
$icon = $event->calendar_icon;
|
||||
}
|
||||
|
||||
$name = $event->name;
|
||||
|
||||
if ($event->hidden == 1) {
|
||||
$color = $this->hex2rgba($color,0.5);
|
||||
$icon = 'fas fa-eye-slash';
|
||||
$name = 'Caché - '.$name;
|
||||
}
|
||||
|
||||
$myevent = [
|
||||
'title' => $event->name,
|
||||
'title' => $name,
|
||||
'start' => date('c',strtotime($event->date_begin)),
|
||||
'end' => date('c',strtotime($event->date_end)),
|
||||
'color' => $color,
|
||||
@@ -106,6 +131,45 @@ class ScheduleController extends Controller
|
||||
return json_encode($jsonevents);
|
||||
}
|
||||
|
||||
function hex2rgba($color, $opacity = false) {
|
||||
|
||||
$default = 'rgb(0,0,0)';
|
||||
|
||||
//Return default if no color provided
|
||||
if(empty($color))
|
||||
return $default;
|
||||
|
||||
//Sanitize $color if "#" is provided
|
||||
if ($color[0] == '#' ) {
|
||||
$color = substr( $color, 1 );
|
||||
}
|
||||
|
||||
//Check if color has 6 or 3 characters and get values
|
||||
if (strlen($color) == 6) {
|
||||
$hex = array( $color[0] . $color[1], $color[2] . $color[3], $color[4] . $color[5] );
|
||||
} elseif ( strlen( $color ) == 3 ) {
|
||||
$hex = array( $color[0] . $color[0], $color[1] . $color[1], $color[2] . $color[2] );
|
||||
} else {
|
||||
return $default;
|
||||
}
|
||||
|
||||
//Convert hexadec to rgb
|
||||
$rgb = array_map('hexdec', $hex);
|
||||
|
||||
//Check if opacity is set(rgba or rgb)
|
||||
if($opacity){
|
||||
if(abs($opacity) > 1)
|
||||
$opacity = 1.0;
|
||||
$output = 'rgba('.implode(",",$rgb).','.$opacity.')';
|
||||
} else {
|
||||
$output = 'rgb('.implode(",",$rgb).')';
|
||||
}
|
||||
|
||||
//Return rgb(a) color string
|
||||
return $output;
|
||||
}
|
||||
|
||||
|
||||
public function loadModal($id,$db_type)
|
||||
{
|
||||
if($db_type == "event")
|
||||
@@ -216,6 +280,13 @@ class ScheduleController extends Controller
|
||||
public function delete($id)
|
||||
{
|
||||
$event = \App\Event::find($id);
|
||||
if ($event->hidden == 1)
|
||||
{
|
||||
if (\Auth::user()->p('instruction_see_hidden_event') != 1)
|
||||
{
|
||||
abort(403);
|
||||
}
|
||||
}
|
||||
foreach ($event->courses as $course)
|
||||
{
|
||||
$course->delete();
|
||||
|
||||
Reference in New Issue
Block a user