コード例 #1
0
 public function delete($id)
 {
     RecentActivities::createActivity("Blocked IP " . Blocking::where('id', $id)->pluck('ip_address') . " deleted by User ID:" . Auth::user()->id . " User Name:" . Auth::user()->name);
     Blocking::where('id', $id)->delete();
     Session::flash('success_msg', trans('msgs.ip_deleted_success'));
     return Redirect::to('/blocking/all');
 }
コード例 #2
0
 public function delete($user_id)
 {
     $tickets = Tickets::where('customer_id', $user_id)->get();
     //Delete tickets
     foreach ($tickets as $ticket) {
         TicketAttachments::where('thread_id', $ticket->id)->delete();
         MessageThread::where('id', $ticket->thread_id)->delete();
         ThreadMessages::where('thread_id', $ticket->thread_id)->delete();
     }
     Tickets::where('customer_id', $user_id)->delete();
     //Delete Chat and Conversations
     $online_users = OnlineUsers::where('user_id', $user_id)->get();
     foreach ($online_users as $online_user) {
         MessageThread::where('id', $online_user->thread_id)->delete();
         ThreadMessages::where('thread_id', $online_user->thread_id)->delete();
     }
     OnlineUsers::where('user_id', $user_id)->delete();
     $closed_conversations = ClosedConversations::where('user_id', $user_id)->get();
     foreach ($closed_conversations as $closed_conversation) {
         MessageThread::where('id', $closed_conversation->thread_id)->delete();
         ThreadMessages::where('thread_id', $closed_conversation->thread_id)->delete();
     }
     ClosedConversations::where('user_id', $user_id)->delete();
     UsersGroups::where('user_id', $user_id)->delete();
     CompanyCustomers::where("customer_id", $user_id)->delete();
     User::where("id", $user_id)->delete();
     RecentActivities::createActivity("Customer deleted by User ID:" . Auth::user()->id . " User Name:" . Auth::user()->name);
     Session::flash('success_msg', trans('msgs.customer_deleted_success'));
     return Redirect::to('/customers/all');
 }
コード例 #3
0
 static function createActivity($message)
 {
     $recent = new RecentActivities();
     $recent->message = $message;
     $recent->save();
 }
コード例 #4
0
ファイル: User.php プロジェクト: rayku/rayku
 public function getRecentHistory($limit = 10)
 {
     $recentActivities = new RecentActivities();
     $recentActivities->setLimit($limit);
     $rssContext = sfContext::getInstance()->getModuleName() == 'profile' ? 'profile' : null;
     return $recentActivities->fetchForUser($this, $rssContext);
 }
コード例 #5
0
 public function deleteConversation($thread_id)
 {
     ThreadMessages::where('thread_id', $thread_id)->delete();
     MessageThread::where('id', $thread_id)->delete();
     ThreadGeoInfo::where('thread_id', $thread_id)->delete();
     ClosedConversations::where('thread_id', $thread_id)->delete();
     RecentActivities::createActivity("Conversation deleted by User ID:" . Auth::user()->id . " User Name:" . Auth::user()->name);
     Session::flash('success_msg', trans('msgs.conversation_deleted_success'));
     return Redirect::to('/conversations/closed');
 }
コード例 #6
0
 public function delete($company_id)
 {
     $departments = Department::where('company_id', $company_id)->get();
     if (Config::get('site-config.is_demo') && $company_id == 1) {
         Session::flash('error_msg', 'Demo : Feature is disabled');
         return Redirect::to('/dashboard');
     }
     foreach ($departments as $department) {
         if (!empty($department)) {
             $tickets = Tickets::where('department_id', $department->id)->get();
             //Delete tickets
             foreach ($tickets as $ticket) {
                 TicketAttachments::where('thread_id', $ticket->id)->delete();
                 MessageThread::where('id', $ticket->thread_id)->delete();
                 ThreadMessages::where('thread_id', $ticket->thread_id)->delete();
             }
             Tickets::where('department_id', $department->id)->delete();
             //Delete Chat and Conversations
             $online_users = OnlineUsers::where('department_id', $department->id)->get();
             foreach ($online_users as $online_user) {
                 MessageThread::where('id', $online_user->thread_id)->delete();
                 ThreadMessages::where('thread_id', $online_user->thread_id)->delete();
             }
             OnlineUsers::where('department_id', $department->id)->delete();
             $closed_conversations = ClosedConversations::where('department_id', $department->id)->get();
             foreach ($closed_conversations as $closed_conversation) {
                 MessageThread::where('id', $closed_conversation->thread_id)->delete();
                 ThreadMessages::where('thread_id', $closed_conversation->thread_id)->delete();
             }
             ClosedConversations::where('department_id', $department->id)->delete();
             $operators = OperatorsDepartment::where('department_id', $department->id)->lists('user_id');
             if (sizeof($operators) > 0) {
                 User::whereIn('id', $operators)->delete();
                 UsersGroups::whereIn('user_id', $operators)->delete();
             }
             OperatorsDepartment::where('department_id', $department->id)->delete();
             $department_admin = DepartmentAdmins::where('department_id', $department->id)->first();
             if (!empty($department_admin)) {
                 UsersGroups::where('user_id', $department_admin->user_id)->delete();
                 User::where("id", $department_admin->user_id)->delete();
                 CompanyDepartmentAdmins::where("user_id", $department_admin->user_id)->delete();
                 CannedMessages::where('operator_id', $operators)->delete();
             }
         }
         DepartmentAdmins::where('department_id', $department->id)->delete();
         Department::where('id', $department->id)->delete();
     }
     $company = Company::where('id', $company_id)->first();
     RecentActivities::createActivity("Company <a href='/companies/all'>" . $company->name . "</a> deleted by User Name " . Auth::user()->name . " User ID " . Auth::user()->id);
     Company::where('id', $company_id)->delete();
     Session::flash('success_msg', trans('msgs.company_deleted_success'));
     return Redirect::to('/companies/all');
 }
コード例 #7
0
 public function delete($thread_id)
 {
     Tickets::where('thread_id', $thread_id)->delete();
     TicketAttachments::where('thread_id', $thread_id)->delete();
     MessageThread::where('id', $thread_id)->delete();
     ThreadMessages::where('thread_id', $thread_id)->delete();
     ThreadGeoInfo::where('thread_id', $thread_id)->delete();
     RecentActivities::createActivity("Ticket deleted by User ID:" . Auth::user()->id . " User Name:" . Auth::user()->name);
     Session::flash('success_msg', trans('msgs.ticket_deleted_success'));
     return Redirect::to('/tickets/all');
 }
コード例 #8
0
 function allActivities()
 {
     $activities = RecentActivities::orderBy('id', 'desc')->get();
     return View::make('activities.all', ['activities' => $activities]);
 }
コード例 #9
0
 public function masterRefresh()
 {
     if (Input::get('company_id', 0) > 0 && Input::get('department_id', 0) > 0) {
         $online_users = OnlineUsers::where('company_id', Input::get('company_id'))->where('department_id', Input::get('department_id'))->orderBy('id', 'desc')->get();
     } else {
         $online_users = OnlineUsers::orderBy('id', 'desc')->get();
     }
     $conversations_arr = [];
     foreach ($online_users as $online) {
         if (sizeof(User::where('id', $online->user_id)->get()) > 0) {
             $online->user = User::find($online->user_id);
             if ($online->operator_id > 0) {
                 $online->operator = User::find($online->operator_id);
             }
             $single_conversation = [];
             $single_conversation[] = $online->user->name;
             $single_conversation[] = $online->user->email;
             if (!isset($online->operator)) {
                 $single_conversation[] = '<td><a href="/conversations/accept/' . $online->thread_id . '" class="btn btn-success btn-sm"> <i class="icon-checkmark4"></i> ' . trans('msgs.accept') . ' </a></td>';
                 $conversations_arr[] = $single_conversation;
             }
             if (isset($online->operator) && $online->operator->id == Auth::user()->id) {
                 $single_conversation[] = '<td><a href="/conversations/accept/' . $online->thread_id . '" class="btn btn-success btn-sm"> <i class="icon-checkmark4"></i> ' . trans('msgs.reply') . ' </a></td>';
                 $conversations_arr[] = $single_conversation;
             }
         }
     }
     $activities_arr = [];
     if (Utils::isAdmin(Auth::user()->id)) {
         $all_activities = RecentActivities::orderBy('id', 'desc')->limit(10)->get();
         foreach ($all_activities as $activity) {
             $single_activity = [];
             $single_activity[] = $activity->message;
             $activities_arr[] = $single_activity;
         }
     }
     return json_encode(['onlineChats' => $conversations_arr, 'recentActivities' => $activities_arr]);
 }
コード例 #10
0
 public function delete($admin_id)
 {
     $department_admin = DepartmentAdmins::where("user_id", $admin_id)->first();
     if (Config::get('site-config.is_demo') && $admin_id == 2) {
         Session::flash('error_msg', 'Demo : Feature is disabled');
         return Redirect::to('/dashboard');
     }
     if (!empty($department_admin)) {
         $department = Department::where('id', $department_admin->department_id)->first();
         if (!empty($department)) {
             $company = Company::where('id', $department->company_id)->first();
             //Change all conversations , tickets , threads , thread_messages operator_id
             OnlineUsers::where('operator_id', $admin_id)->update(['operator_id' => $company->user_id]);
             ClosedConversations::where('operator_id', $admin_id)->update(['operator_id' => $company->user_id]);
             MessageThread::where('operator_id', $admin_id)->update(['operator_id' => $company->user_id]);
             Tickets::where('operator_id', $admin_id)->update(['operator_id' => $company->user_id]);
             ThreadMessages::where('sender_id', $admin_id)->update(['sender_id' => $company->user_id]);
         }
     }
     CompanyDepartmentAdmins::where("user_id", $admin_id)->delete();
     DepartmentAdmins::where('user_id', $admin_id)->delete();
     UsersGroups::where('user_id', $admin_id)->delete();
     User::where('id', $admin_id)->delete();
     RecentActivities::createActivity("Department admin deleted by User ID:" . Auth::user()->id . " User Name:" . Auth::user()->name);
     Session::flash('success_msg', trans('msgs.department_admin_deleted_success'));
     return Redirect::to('/departments/admins/all');
 }
コード例 #11
0
 public function end()
 {
     if (!Input::has('thread_id')) {
         return "";
     }
     $online_user = OnlineUsers::where('thread_id', Input::get('thread_id'))->first();
     $closed_conversation = new ClosedConversations();
     $closed_conversation->user_id = $online_user->user_id;
     $closed_conversation->thread_id = $online_user->thread_id;
     $closed_conversation->operator_id = $online_user->operator_id > 0 ? $online_user->operator_id : 0;
     $closed_conversation->company_id = $online_user->company_id;
     $closed_conversation->department_id = $online_user->department_id;
     $closed_conversation->requested_on = $online_user->requested_on;
     $closed_conversation->started_on = $online_user->started_on > 0 ? $online_user->started_on : \Carbon\Carbon::now();
     $closed_conversation->token = $online_user->token;
     $closed_conversation->ended_on = \Carbon\Carbon::now();
     $closed_conversation->save();
     RecentActivities::createActivity("Chat Conversation closed <a href='/conversations/read/" . $closed_conversation->id . "'>ID:" . $closed_conversation->id . "</a> by User ID:" . Auth::user()->id . " User Name:" . Auth::user()->name);
     OnlineUsers::where('thread_id', Input::get('thread_id'))->delete();
 }
コード例 #12
0
 public function setTickets()
 {
     $values = ['should_send_email_ticket_status_change' => Input::has('should_send_email_ticket_status_change'), 'should_send_email_ticket_reply' => Input::has('should_send_email_ticket_reply'), 'convert_chat_ticket_no_operators' => Input::has('convert_chat_ticket_no_operators')];
     Settings::where('key', 'tickets')->update(['value' => json_encode($values)]);
     RecentActivities::createActivity("Tickets settings changed by User ID:" . Auth::user()->id . " User Name:" . Auth::user()->name);
     Session::flash('success_msg', trans('msgs.tickets_settings_updated'));
     return Redirect::to('/settings/all#tab-tickets');
 }
コード例 #13
0
 public function delete($user_id)
 {
     $operators_department = OperatorsDepartment::where("user_id", $user_id)->first();
     if (!empty($operators_department)) {
         $department_admin = DepartmentAdmins::where('department_id', $operators_department->department_id)->first();
         if (!empty($department_admin)) {
             //Change all conversations , tickets , threads , thread_messages operator_id
             OnlineUsers::where('operator_id', $user_id)->update(['operator_id' => $department_admin->user_id]);
             ClosedConversations::where('operator_id', $user_id)->update(['operator_id' => $department_admin->user_id]);
             MessageThread::where('operator_id', $user_id)->update(['operator_id' => $department_admin->user_id]);
             Tickets::where('operator_id', $user_id)->update(['operator_id' => $department_admin->user_id]);
             ThreadMessages::where('sender_id', $user_id)->update(['sender_id' => $department_admin->user_id]);
         }
     }
     RecentActivities::createActivity("User " . User::where('id', $user_id)->pluck('name') . " deleted by User ID:" . Auth::user()->id . " User Name:" . Auth::user()->name);
     User::find($user_id)->delete();
     OperatorsDepartment::where("user_id", $user_id)->delete();
     CannedMessages::where('operator_id', $user_id)->delete();
     UsersGroups::where('user_id', $user_id)->delete();
     Session::flash('success_msg', trans('msgs.operator_deleted_success'));
     return Redirect::to('/operators/all');
 }