public static function add_notice($message, $end, $start = null, $type = 'good', $viewBy = null)
 {
     if (!$start) {
         $start = SS_Datetime::now()->getValue();
     } else {
         $start = date('Y-m-d H:i:s', strtotime($start));
     }
     $end = date('Y-m-d H:i:s', strtotime($end));
     $notice = TimedNotice::create(array('Message' => $message, 'StartTime' => $start, 'EndTime' => $end, 'CanViewType' => 'LoggedInUsers', 'MessageType' => $type));
     if ($viewBy instanceof Group) {
         $notice->CanViewType = 'OnlyTheseUsers';
     }
     $notice->write();
     if ($viewBy instanceof Group) {
         $notice->ViewerGroups()->add($viewBy);
     }
     return $notice;
 }
 public function snooze()
 {
     if (!Permission::check('TIMEDNOTICE_EDIT')) {
         return;
     }
     $id = (int) $this->request->postVar('ID');
     $increase = (int) $this->request->postVar('plus');
     if ($id) {
         $notice = TimedNotice::get()->byID($id);
         if ($notice && $notice->ID) {
             if ($increase > 0) {
                 $notice->StartTime = time() + $increase * 60;
                 $notice->EndTime = strtotime($notice->EndTime) + $increase * 60;
             } else {
                 $notice->EndTime = time() + $increase;
             }
             $notice->write();
             return $increase;
         }
     }
     return 0;
 }