示例#1
0
 public function create($request)
 {
     $req = $request->getParameters();
     $response = new ViewResponse('assist/ticket');
     if (trim($req['bug']) != '') {
         if (Session::isActive()) {
             $user_id = Session::get()->id;
         } else {
             if (trim($req['email']) != '') {
                 $user_id = $req['email'];
             } else {
                 $user_id = 0;
             }
         }
         if (!empty(Ticket::find('all', ['conditions' => ['ip = ? AND timestamp < ' . (Utils::tps() + 60), $_SERVER['REMOTE_ADDR']]]))) {
             $r = $this->index($request);
             $r->addMessage(ViewMessage::error('Trop d\'envois avec la même IP en une minute, réssayez plus tard.'));
             return $r;
         }
         $ticket = Ticket::create(array('user_id' => $user_id, 'description' => $req['bug'], 'timestamp' => time(), 'ip' => $_SERVER['REMOTE_ADDR']));
         StaffNotification::createNotif('ticket', $user_id, null, $ticket->id);
         $ticket_id = $ticket->id;
         $response->addMessage(ViewMessage::success('Envoyé ! Vous serez notifié de l\'avancement par E-Mail ou Message Privé (Ticket #' . $ticket_id . ')'));
         /*$username = (Session::isActive()) ? Session::get()->username : '******';
         		$notif = new PushoverNotification();
         		$notif->setMessage('Nouveau ticket de '.$username);
         		$notif->setReceiver('all');
         		$notif->setExtraParameter('url', 'http://dreamvids.fr'.WEBROOT.'admin/tickets');
         		$notif->send();*/
     } else {
         $response->addMessage(ViewMessage::error('Merci de nous décrire votre problème.'));
     }
     return $response;
 }
示例#2
0
 public function index($request)
 {
     $data['storage_server'] = ['local_server', 'stor1'];
     $data['tickets'] = Ticket::getSize(Session::get());
     $data['all_tickets'] = Ticket::getSize();
     $data['news'] = News::getLastNews();
     $data['notifs'] = StaffNotification::getInternStaffNotifications();
     $data['team'] = User::getTeam();
     $data['is_notif_enabled'] = StaffNotification::isEnabled(Session::get());
     return new ViewResponse('admin/dashboard/index', $data);
 }
示例#3
0
 public function create($request)
 {
     $params = $request->getParameters();
     $data = ['success' => false];
     $user = Session::get();
     if ($params['title'] != '' && $params['content'] != '') {
         $new = News::create(['user_id' => $user->id, 'title' => $params['title'], 'content' => $params['content'], 'icon' => $params['icon'], 'level' => $params['level'], 'timestamp' => Utils::tps()]);
         StaffNotification::createNotif('news', Session::get()->id);
         $data['success'] = is_object($new);
     }
     return new JsonResponse($data);
 }
 public function create($request)
 {
     $params = $request->getParameters();
     $params['force_push'] = Session::get()->isAdmin() ? $params['force_push'] : 0;
     if (isset($params['type'])) {
         switch ($params['type']) {
             case 'private':
                 StaffNotification::createNotif('private', Session::get()->id, $params['to'], $params['content'], $params['level'], 'team_or_more', $params['force_push']);
                 return new JsonResponse(['success' => true]);
                 break;
             case 'broadcast':
                 StaffNotification::createNotif('broadcast', Session::get()->id, null, $params['content'], $params['level'], 'team_or_more', $params['force_push']);
                 return new JsonResponse(['success' => true]);
                 break;
         }
     } else {
         $notif = new PushBulletNotification('Dreamvids', "Test de notification !", [Session::get()->details->push_bullet_email]);
         $notif->send();
     }
 }
示例#5
0
 public function update($id, $request)
 {
     $config = new Config(CONFIG . 'app.json');
     $config->parseFile();
     $data = $request->getParameters();
     if (isset($data['userRankSubmit'])) {
         if (User::exists($id)) {
             $user = User::find($id);
             $data['ranks'][$config->getValue('rankAdmin')] = ['Administrateur', 'danger'];
             $data['ranks'][$config->getValue('rankModo')] = ['Modérateur', 'warning'];
             $data['ranks'][$config->getValue('rankTeam')] = ['Equipe', 'success'];
             $data['ranks'][$config->getValue('rankContributor')] = ['Contributeur', 'info'];
             $data['ranks'][$config->getValue('rankUser')] = ['Utilisateur', 'primary'];
             $user->rank = $data['rank'];
             $user->save();
             StaffNotification::createNotif('rank', $user->id, Session::get()->id, $user->rank, $data['ranks'][$user->rank][1], 'admin');
             $data['user'] = $user;
             $r = new ViewResponse("admin/settings/edit_user", $data);
             $r->addMessage(ViewMessage::success($user->username . " désormais {$data['ranks'][$user->rank][0]}"));
             return $r;
         }
     }
 }
示例#6
0
文件: video.php 项目: agiza/DreamVids
 public function suspend($userId)
 {
     $visibility = Config::getValue_('vid_visibility_suspended');
     $this->visibility = $visibility;
     $this->flagged = 1;
     $this->save();
     StaffNotification::createNotif('suspend_video', $userId, null, $this->id, 'danger', 'modo_or_more');
     ModoAction::create(array('id' => ModoAction::generateId(6), 'user_id' => $userId, 'type' => 'suspend', 'target' => $this->id, 'timestamp' => Utils::tps()));
 }
示例#7
0
 public static function createNotif($type, $id_one = null, $id_two = null, $value = null, $level = '', $viewers = 'team_or_more', $force_push = false)
 {
     $staff_notif = StaffNotification::create(['type' => $type, 'id_one' => $id_one, 'id_two' => $id_two, 'value' => $value, 'viewers' => $viewers, 'level' => $level, 'timestamp' => Utils::tps()]);
     $emails = [];
     $title = 'DreamVids';
     $sub_title = '';
     $is_link = !is_null($staff_notif->getLink());
     $link_url = "http://" . @$_SERVER['HTTP_HOST'] . WEBROOT . $staff_notif->getLink();
     foreach (User::getTeam() as $user) {
         $content = $staff_notif->getContent();
         if (Utils::getRankArray($user)[$viewers] && (self::isEnabled($user) || $force_push)) {
             if (!is_null($user->details->push_bullet_email) && $user->details->push_bullet_email != '') {
                 switch ($type) {
                     case 'ticket_level_change':
                         $ticket = $staff_notif->getAssociatedValue('Ticket');
                         $sub_title = 'Tickets';
                         if (in_array($ticket->ticket_levels_id, $user->getAssignedLevelsIds()) || $user->isAdmin()) {
                             $emails[] = $user->details->push_bullet_email;
                         }
                         break;
                     case 'ticket':
                         $sub_title = 'Tickets';
                         $emails[] = $user->details->push_bullet_email;
                         break;
                     case 'news':
                         $sub_title = 'News';
                         $emails[] = $user->details->push_bullet_email;
                         break;
                     case 'private':
                         $sub_title = "Message privé";
                         $content = $staff_notif->value;
                         if ($staff_notif->id_two == $user->id) {
                             $emails[] = $user->details->push_bullet_email;
                         }
                         break;
                     case 'private':
                         $sub_title = "Message";
                         $content = $staff_notif->value;
                         $emails[] = $user->details->push_bullet_email;
                         break;
                     default:
                         $emails[] = $user->details->push_bullet_email;
                         break;
                 }
             }
         }
     }
     $notif = new PushBulletNotification($title . ($sub_title != '' ? ' - ' . $sub_title : ''), $content, $emails, $is_link, $link_url);
     $notif->send();
 }
示例#8
0
 public function update($id, $request)
 {
     $param = $request->getParameters();
     $ticket = Ticket::find($id);
     if (isset($param['new']) && $param['new']) {
         $level = TicketLevels::create(['label' => $param['label']]);
         $ticket->ticket_levels_id = $level->id;
     } else {
         $ticket->ticket_levels_id = $param['level_id'];
     }
     $ticket->save();
     StaffNotification::createNotif('ticket_level_change', Session::get()->id, null, $ticket->id);
     $r = $this->index($request);
     $r->addMessage(ViewMessage::success("Modification effectuée"));
     return $r;
 }