[
MAINHACK
]
Mail Test
BC
Config Scan
HOME
Create...
New File
New Folder
Viewing / Editing File: Timeline.php
<?php /** -------------------------------------------------------------------------------- * This controller manages all the business logic for timeline * * @package Grow CRM * @author NextLoop *----------------------------------------------------------------------------------*/ namespace App\Http\Controllers; use App\Http\Controllers\Controller; use App\Http\Responses\Timeline\IndexResponse; use App\Http\Responses\Timeline\UserActivityResponse; use App\Permissions\ProjectPermissions; use App\Repositories\ClientRepository; use App\Repositories\EventRepository; use App\Repositories\ProjectRepository; class Timeline extends Controller { /** * The events repository instance. */ protected $eventrepo; /** * The project permission instance. */ protected $projectpermissions; /** * The client permission instance. */ protected $clientrepo; /** * The project repository instance. */ protected $projectrepo; public function __construct( EventRepository $eventrepo, ProjectPermissions $projectpermissions, ClientRepository $clientrepo, ProjectRepository $projectrepo ) { //parent parent::__construct(); //authenticated $this->middleware('auth'); $this->eventrepo = $eventrepo; $this->projectpermissions = $projectpermissions; $this->clientrepo = $clientrepo; $this->projectrepo = $projectrepo; } /** * show a list of timeline events * @return \Illuminate\Http\Response */ public function projectTimeline() { //basic settings $page = []; //filter request()->merge([ 'eventresource_type' => request('timelineresource_type'), 'eventresource_id' => request('timelineresource_id'), ]); //get events $events = $this->eventrepo->search([ 'pagination' => config('settings.limits.pagination_project_timeline'), 'filter' => 'timeline_visible', ]); //process events $events = $this->processEvents($events); //reponse payload $payload = [ 'page' => $this->pageSettings(), 'events' => $events, 'count' => $events->total(), 'replace_actions_nav' => '', ]; //response return new IndexResponse($payload); } /** * show a list of timeline events * @return \Illuminate\Http\Response */ public function clientTimeline() { //basic settings $page = []; //filter request()->merge([ 'eventresource_type' => request('timelineresource_type'), 'eventresource_id' => request('timelineresource_id'), ]); //get events $events = $this->eventrepo->search([ 'pagination' => config('settings.limits.pagination_project_timeline'), 'filter' => 'timeline_visible', ]); //process events $events = $this->processEvents($events); //reponse payload $payload = [ 'page' => $this->pageSettings(), 'events' => $events, 'count' => $events->total(), 'replace_actions_nav' => '', ]; //get clent resource if (request('request_source') == 'client' && request()->filled('timelineclient_id')) { //get the client (full format) $clients = $this->clientrepo->search(request('timelineclient_id')); if ($client = $clients->first()) { $payload['replace_actions_nav'] = 'client'; $payload['client'] = $client; } } //response return new IndexResponse($payload); } /** * Users activity feed (timeline feed) * * @param string $id users unique_id * @return UserActivityResponse */ public function user($id) { //filter by user's creator id request()->merge([ 'event_creatorid' => $id, ]); //get timeline events for this user $events = $this->eventrepo->search('', ['stats' => 'count-events']); //default settings $page = $this->pageSettings('timeline'); //payload $payload = [ 'page' => $page, 'events' => $events, 'count' => $events->total(), ]; //response return new UserActivityResponse($payload); } /** * [sanity] * Additional processing of the time line as follows: * - Do not show clients [task] related events, if the project settings do now allos * * @return object */ private function processEvents($events = '') { if ($events instanceof \Illuminate\Pagination\LengthAwarePaginator) { foreach ($events as $key => $event) { //hide [task events] for clients as per project settings if ($event->event_parent_type == 'task' && auth()->user()->is_client) { if (!$this->projectpermissions->check('tasks-view', $event->eventresource_id)) { $events->forget($key); } } //hide event as per user role [tickets] if ($event->event_item == 'ticket' && auth()->user()->role->role_tickets == 0) { $events->forget($key); } //hide event as per user role [invoices] if ($event->event_item == 'invoice' && auth()->user()->role->role_invoices == 0) { $events->forget($key); } //hide event as per user role [payments] if ($event->event_item == 'payment' && auth()->user()->role->role_invoices == 0) { $events->forget($key); } } return $events; } } /** * basic page setting for this section of the app * @param string $section page section (optional) * @param array $data any other data (optional) * @return array */ private function pageSettings($section = '', $data = []) { //common settings $page = [ ]; //return return $page; } }
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.81 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