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:
@@ -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