Apply fixes from StyleCI

This commit is contained in:
Manish Verma
2016-12-13 13:14:54 +00:00
committed by StyleCI Bot
parent 857d3004eb
commit 88f3df2180
161 changed files with 4729 additions and 3879 deletions

View File

@@ -7,5 +7,5 @@ use App\BaseModel;
class Assign_team_agent extends BaseModel
{
protected $table = 'team_assign_agent';
protected $fillable = ['id', 'team_id', 'agent_id','updated_at', 'created_at'];
protected $fillable = ['id', 'team_id', 'agent_id', 'updated_at', 'created_at'];
}

View File

@@ -12,22 +12,27 @@ class Organization extends BaseModel
/* Define the fillable fields */
protected $fillable = ['id', 'name', 'phone', 'website', 'address', 'head', 'internal_notes'];
public function userRelation(){
public function userRelation()
{
$related = "App\Model\helpdesk\Agent_panel\User_org";
return $this->hasMany($related,'org_id');
return $this->hasMany($related, 'org_id');
}
public function getUserIds(){
public function getUserIds()
{
$user_relations = $this->userRelation()->lists('user_id')->toArray();
return $user_relations;
}
public function users(){
public function users()
{
$user = new \App\User();
$user_ids = $this->getUserIds();
$users = $user->whereIn('id',$user_ids);
$users = $user->whereIn('id', $user_ids);
return $users;
}
}

View File

@@ -13,10 +13,11 @@ class User_org extends BaseModel
/* define fillable fields */
protected $fillable = ['id', 'org_id', 'user_id'];
public function setOrgIdAttribute($value){
if($value==""){
public function setOrgIdAttribute($value)
{
if ($value == '') {
$this->attributes['org_id'] = null;
}else{
} else {
$this->attributes['org_id'] = $value;
}
}

View File

@@ -14,53 +14,61 @@ class Emails extends BaseModel
'fetching_status', 'move_to_folder', 'delete_email', 'do_nothing',
'sending_status', 'authentication', 'header_spoofing', 'imap_config',
];
public function getCurrentDrive(){
$drive = $this->attributes['sending_protocol'];
public function getCurrentDrive()
{
$drive = $this->attributes['sending_protocol'];
$mailServices = new \App\Model\MailJob\MailService();
$id = "";
$mailService = $mailServices->where('short_name',$drive)->first();
if($mailService){
$id = '';
$mailService = $mailServices->where('short_name', $drive)->first();
if ($mailService) {
$id = $mailService->id;
}
return $id;
}
public function getExtraField($key){
$value = "";
public function getExtraField($key)
{
$value = '';
$id = $this->attributes['id'];
$services = new \App\Model\MailJob\FaveoMail();
$service = $services->where('email_id',$id)->where('key',$key)->first();
if($service){
$service = $services->where('email_id', $id)->where('key', $key)->first();
if ($service) {
$value = $service->value;
}
return $value;
}
public function extraFieldRelation(){
public function extraFieldRelation()
{
$related = "App\Model\MailJob\FaveoMail";
return $this->hasMany($related,'email_id');
return $this->hasMany($related, 'email_id');
}
public function deleteExtraFields(){
public function deleteExtraFields()
{
$fields = $this->extraFieldRelation()->get();
if($fields->count()>0){
foreach ($fields as $field){
if ($fields->count() > 0) {
foreach ($fields as $field) {
$field->delete();
}
}
}
public function getPasswordAttribute($value){
if($value){
public function getPasswordAttribute($value)
{
if ($value) {
return \Crypt::decrypt($value);
}
return $value;
}
public function delete() {
public function delete()
{
$this->deleteExtraFields();
parent::delete();
}

View File

@@ -7,28 +7,30 @@ use Illuminate\Database\Eloquent\Model;
class Filter extends Model
{
protected $table = 'filters';
protected $fillable = ['ticket_id','key','value'];
public function getLabelTitle($ticketid){
$filter = $this->where('ticket_id',$ticketid)->where('key','label')->first();
$output = [];
if($filter && $filter->value){
$labelids = explode(',', $filter->value);
$labels = new Label();
$label = $labels->whereIn('title',$labelids)->get();
if($label->count()>0){
foreach($label as $key=>$l){
$output[$key] = $l->titleWithColor();
}
}
}
return $output;
protected $fillable = ['ticket_id', 'key', 'value'];
public function getLabelTitle($ticketid)
{
$filter = $this->where('ticket_id', $ticketid)->where('key', 'label')->first();
$output = [];
if ($filter && $filter->value) {
$labelids = explode(',', $filter->value);
$labels = new Label();
$label = $labels->whereIn('title', $labelids)->get();
if ($label->count() > 0) {
foreach ($label as $key=>$l) {
$output[$key] = $l->titleWithColor();
}
}
}
return $output;
}
public function getTagsByTicketId($ticketid)
{
$filter = $this->where('key', 'tag')->where('ticket_id', $ticketid)->lists('value')->toArray();
return $filter;
}
public function getTagsByTicketId($ticketid){
$filter = $this->where('key','tag')->where('ticket_id',$ticketid)->lists('value')->toArray();
return $filter;
}
}

View File

@@ -5,33 +5,37 @@ namespace App\Model\helpdesk\Filters;
use Illuminate\Database\Eloquent\Model;
use Lang;
class Label extends Model {
class Label extends Model
{
protected $table = 'labels';
protected $fillable = ['title', 'color', 'order', 'status'];
public function titleWithColor() {
public function titleWithColor()
{
$title = $this->title;
$color = $this->color;
if ($title && $color) {
return "<span class='label' style='background-color:" . $color . "; color: #FFF;'>" . $title . "</span>";
return "<span class='label' style='background-color:".$color."; color: #FFF;'>".$title.'</span>';
} else {
return "--";
return '--';
}
}
public function status() {
public function status()
{
$status = $this->status;
$output = Lang::get('lang.disabled');
if ($status == 1) {
$output = Lang::get('lang.enabled');
}
return $output;
}
public function isChecked($ticketid) {
public function isChecked($ticketid)
{
$title = $this->attributes['title'];
$output = "";
$output = '';
$filters = new Filter();
$filter = $filters
->where('ticket_id', $ticketid)
@@ -39,24 +43,26 @@ class Label extends Model {
->where('value', $title)
->first();
if ($filter && $filter->value) {
$output = "checked";
$output = 'checked';
}
return $output;
}
public function assignedLabels($ticketid) {
$output = "";
public function assignedLabels($ticketid)
{
$output = '';
$filters = new Filter();
$filter = $filters->where('ticket_id', $ticketid)->where('key', 'label')->select('value')->get();
if (count($filter) > 0) {
foreach ($filter as $fil) {
$label = $this->where('title',$fil->value)->select('title','color')->first();
if($label){
$output .="&nbsp;&nbsp;".$label->titleWithColor()."&nbsp;&nbsp;";
$label = $this->where('title', $fil->value)->select('title', 'color')->first();
if ($label) {
$output .= '&nbsp;&nbsp;'.$label->titleWithColor().'&nbsp;&nbsp;';
}
}
}
return $output;
}
}

View File

@@ -7,7 +7,5 @@ use Illuminate\Database\Eloquent\Model;
class Tag extends Model
{
protected $table = 'tags';
protected $fillable = ['name','description'];
protected $fillable = ['name', 'description'];
}

View File

@@ -6,22 +6,17 @@ use Illuminate\Database\Eloquent\Model;
class FieldValue extends Model
{
protected $table = "field_values";
protected $fillable = ['field_id','child_id','field_key','field_value'];
public function childId(){
$childid = "";
protected $table = 'field_values';
protected $fillable = ['field_id', 'child_id', 'field_key', 'field_value'];
public function childId()
{
$childid = '';
$child = $this->attributes['child_id'];
if($child){
if ($child) {
$childid = $this->attributes['child_id'];
}
return $childid;
}
}
}

View File

@@ -4,8 +4,8 @@ namespace App\Model\helpdesk\Form;
use App\BaseModel;
class Fields extends BaseModel {
class Fields extends BaseModel
{
protected $table = 'custom_form_fields';
/**
@@ -15,44 +15,55 @@ class Fields extends BaseModel {
*/
protected $fillable = ['forms_id', 'label', 'name', 'type', 'value', 'required'];
public function valueRelation() {
public function valueRelation()
{
$related = "App\Model\helpdesk\Form\FieldValue";
return $this->hasMany($related, 'field_id');
}
public function values() {
public function values()
{
$value = $this->valueRelation();
return $value;
}
public function valuesAsString(){
$string = "";
public function valuesAsString()
{
$string = '';
$values = $this->values()->lists('field_value')->toArray();
if(count($values)>0){
if (count($values) > 0) {
$string = implode(',', $values);
}
return $string;
}
public function requiredFieldForCheck(){
public function requiredFieldForCheck()
{
$check = false;
$required = $this->attributes['required'];
if($required==='1'){
$check = true;
}
return $check;
}
public function nonRequiredFieldForCheck(){
$check = false;
$required = $this->attributes['required'];
if($required!=='1'){
if ($required === '1') {
$check = true;
}
return $check;
}
public function deleteValues() {
public function nonRequiredFieldForCheck()
{
$check = false;
$required = $this->attributes['required'];
if ($required !== '1') {
$check = true;
}
return $check;
}
public function deleteValues()
{
$values = $this->values()->get();
if ($values->count() > 0) {
foreach ($values as $value) {
@@ -61,9 +72,9 @@ class Fields extends BaseModel {
}
}
public function delete() {
public function delete()
{
$this->deleteValues();
parent::delete();
}
}

View File

@@ -14,50 +14,59 @@ class Forms extends BaseModel
* @var array
*/
protected $fillable = ['formname'];
public function fieldRelation(){
public function fieldRelation()
{
$related = "App\Model\helpdesk\Form\Fields";
return $this->hasMany($related);
}
public function fields(){
public function fields()
{
$relation = $this->fieldRelation()->get();
return $relation;
return $relation;
}
public function fieldsDelete(){
public function fieldsDelete()
{
$fields = $this->fields();
if($fields->count()>0){
foreach($fields as $field){
if ($fields->count() > 0) {
foreach ($fields as $field) {
$field->delete();
}
}
}
public function formValueRelation(){
public function formValueRelation()
{
$related = "App\Model\helpdesk\Form\FieldValue";
return $this->hasMany($related,'child_id');
return $this->hasMany($related, 'child_id');
}
public function formValueChild(){
public function formValueChild()
{
$childs = $this->formValueRelation()->get();
return $childs;
}
public function deleteFormChild(){
public function deleteFormChild()
{
$childs = $this->formValueChild();
if($childs->count()>0){
foreach ($childs as $child){
$child->child_id = NULL;
if ($childs->count() > 0) {
foreach ($childs as $child) {
$child->child_id = null;
$child->save();
}
}
}
public function delete() {
public function delete()
{
$this->fieldsDelete();
parent::delete();
}
}

View File

@@ -12,10 +12,12 @@ class Help_topic extends BaseModel
'sla_plan', 'thank_page', 'ticket_num_format', 'internal_notes', 'status', 'type', 'auto_assign',
'auto_response',
];
public function department(){
public function department()
{
$related = 'App\Model\helpdesk\Agent\Department';
$foreignKey = 'department';
return $this->belongsTo($related, $foreignKey);
}
}

View File

@@ -11,44 +11,53 @@ class Notification extends BaseModel
'model_id', 'userid_created', 'type_id',
];
public function type(){
public function type()
{
$related = 'App\Model\helpdesk\Notification\NotificationType';
$id = 'type_id';
return $this->belongsTo($related,$id);
return $this->belongsTo($related, $id);
}
public function model(){
public function model()
{
$related = 'App\Model\helpdesk\Ticket\Tickets';
$id = 'model_id';
return $this->belongsTo($related,$id);
return $this->belongsTo($related, $id);
}
public function userNotification(){
public function userNotification()
{
$related = 'App\Model\helpdesk\Notification\UserNotification';
$foreignKey = 'notification_id';
return $this->hasMany($related, $foreignKey);
}
public function deleteUserNotification(){
public function deleteUserNotification()
{
$user_notifications = $this->userNotification;
if(count($user_notifications)>0){
foreach($user_notifications as $noti){
if (count($user_notifications) > 0) {
foreach ($user_notifications as $noti) {
$noti->delete();
}
}
}
public function dummyDelete(){
$user_notifications = UserNotification::get();
if(count($user_notifications)>0){
foreach($user_notifications as $noti){
public function dummyDelete()
{
$user_notifications = UserNotification::get();
if (count($user_notifications) > 0) {
foreach ($user_notifications as $noti) {
$noti->delete();
}
}
}
public function delete() {
public function delete()
{
$this->deleteUserNotification();
// $this->dummyDelete();
parent::delete();

View File

@@ -11,19 +11,23 @@ class UserNotification extends BaseModel
'notification_id', 'user_id', 'is_read',
];
public function notification(){
public function notification()
{
$related = 'App\Model\helpdesk\Notification\Notification';
$id = 'notification_id';
return $this->belongsTo($related,$id);
return $this->belongsTo($related, $id);
}
public function users(){
public function users()
{
$related = 'App\User';
$id = 'user_id';
return $this->belongsTo($related,$id);
return $this->belongsTo($related, $id);
}
// public function delete() {
// //$this->notification()->delete();
// parent::delete();

View File

@@ -10,23 +10,28 @@ class CommonSettings extends BaseModel
protected $fillable = [
'status', 'option_name', 'option_value', 'optional_field', 'created_at', 'updated_at',
];
public function getStatus($option_name){
$status ="";
$schema = $this->where('option_name',$option_name)->first();
if($schema){
public function getStatus($option_name)
{
$status = '';
$schema = $this->where('option_name', $option_name)->first();
if ($schema) {
$status = $schema->status;
}
return $status;
return $status;
}
public function getOptionValue($option,$field=''){
$schema = $this->where('option_name',$option);
if($field!=""){
$schema = $schema->where('optional_field',$field);
return $schema->first();
}
$value = $schema->get();
return $value;
public function getOptionValue($option, $field = '')
{
$schema = $this->where('option_name', $option);
if ($field != '') {
$schema = $schema->where('optional_field', $field);
return $schema->first();
}
$value = $schema->get();
return $value;
}
}

View File

@@ -14,4 +14,4 @@ class Followup extends BaseModel
'id', 'name', 'status', 'condition', 'created_at', 'updated_at',
];
}
}

View File

@@ -4,54 +4,58 @@ namespace App\Model\helpdesk\Settings;
use Illuminate\Database\Eloquent\Model;
class SocialMedia extends Model {
protected $table = "social_media";
class SocialMedia extends Model
{
protected $table = 'social_media';
protected $fillable = [
'provider',
'key',
'value',
];
public function getvalueByKey($provider, $key="",$login=true) {
$social = "";
if ($key == 'redirect'&& $login==true) {
$social = url('social/login/' . $provider);
public function getvalueByKey($provider, $key = '', $login = true)
{
$social = '';
if ($key == 'redirect' && $login == true) {
$social = url('social/login/'.$provider);
}
if($key!=="" && $key !== 'redirect'){
if ($key !== '' && $key !== 'redirect') {
$social = $this->where('provider', $provider)->where('key', $key)->first();
}elseif($key !== 'redirect'){
$social = $this->where('provider', $provider)->lists('value','key')->toArray();
} elseif ($key !== 'redirect') {
$social = $this->where('provider', $provider)->lists('value', 'key')->toArray();
}
if (is_object($social)) {
$social = $social->value;
}
return $social;
}
public function checkActive($provider) {
$check = "";
public function checkActive($provider)
{
$check = '';
$social = $this->where('provider', $provider)->where('key', 'status')->first();
if ($social) {
$value = $social->value;
if ($value === '1') {
$check = true;
}
}
}
return $check;
}
public function checkInactive($provider) {
$check = "";
public function checkInactive($provider)
{
$check = '';
$social = $this->where('provider', $provider)->where('key', 'status')->first();
if ($social) {
$value = $social->value;
if ($value === '0') {
$check = true;
}
}
}
return $check;
}
}

View File

@@ -4,39 +4,43 @@ namespace App\Model\helpdesk\Ticket;
use App\BaseModel;
class Ticket_Form_Data extends BaseModel {
class Ticket_Form_Data extends BaseModel
{
protected $table = 'ticket_form_data';
protected $fillable = ['id', 'ticket_id', 'title', 'content', 'created_at', 'updated_at'];
public function getFieldKeyLabel() {
public function getFieldKeyLabel()
{
$value = $this->attributes['title'];
$fields = new \App\Model\helpdesk\Form\Fields();
$field = $fields->where('name', $value)->first();
if ($field) {
$value = $field->label;
}
return $value;
}
public function isHidden(){
public function isHidden()
{
$check = false;
$value = $this->attributes['title'];
$fields = new \App\Model\helpdesk\Form\Fields();
$field = $fields->where('name', $value)->first();
if ($field && $field->type=='hidden') {
if ($field && $field->type == 'hidden') {
$check = true;
}
return $check;
}
public function getHidden(){
public function getHidden()
{
$value = $this->attributes['title'];
$fields = new \App\Model\helpdesk\Form\Fields();
$field = $fields->where('name', $value)->first();
if ($field && $field->type=='hidden') {
if ($field && $field->type == 'hidden') {
return $field->label;
}
}
}

View File

@@ -6,10 +6,10 @@ use App\BaseModel;
class Ticket_Priority extends BaseModel
{
protected $primaryKey = 'priority_id';
protected $primaryKey = 'priority_id';
public $timestamps = false;
protected $table = 'ticket_priority';
protected $fillable = [
'priority_id', 'priority', 'status','user_priority_status','priority_desc', 'priority_color', 'priority_urgency', 'ispublic','created_at', 'updated_at',
'priority_id', 'priority', 'status', 'user_priority_status', 'priority_desc', 'priority_color', 'priority_urgency', 'ispublic', 'created_at', 'updated_at',
];
}

View File

@@ -3,21 +3,23 @@
namespace App\Model\helpdesk\Ticket;
//use App\BaseModel;
use Illuminate\Database\Eloquent\Model;
use File;
use Illuminate\Database\Eloquent\Model;
class Ticket_Thread extends Model {
class Ticket_Thread extends Model
{
protected $table = 'ticket_thread';
protected $fillable = [
'id', 'ticket_id', 'staff_id', 'user_id', 'thread_type', 'poster', 'source', 'is_internal', 'title', 'body', 'format', 'ip_address', 'created_at', 'updated_at',
];
public function attach() {
public function attach()
{
return $this->hasMany('App\Model\helpdesk\Ticket\Ticket_attachments', 'thread_id');
}
public function delete() {
public function delete()
{
$this->attach()->delete();
parent::delete();
}
@@ -26,20 +28,23 @@ class Ticket_Thread extends Model {
// $this->attributes['title'] = str_replace('"', "'", $value);
// }
public function getTitleAttribute($value) {
public function getTitleAttribute($value)
{
return str_replace('"', "'", $value);
}
public function thread($content) {
// $porufi = $this->purify($content);
public function thread($content)
{
// $porufi = $this->purify($content);
// dd($content,$porufi);
//return $content;
return $this->purify($content);
}
public function purifyOld($value) {
require_once base_path('vendor' . DIRECTORY_SEPARATOR . 'htmlpurifier' . DIRECTORY_SEPARATOR . 'library' . DIRECTORY_SEPARATOR . 'HTMLPurifier.auto.php');
$path = base_path('vendor' . DIRECTORY_SEPARATOR . 'htmlpurifier' . DIRECTORY_SEPARATOR . 'library' . DIRECTORY_SEPARATOR . 'HTMLPurifier' . DIRECTORY_SEPARATOR . 'DefinitionCache' . DIRECTORY_SEPARATOR . 'Serializer');
public function purifyOld($value)
{
require_once base_path('vendor'.DIRECTORY_SEPARATOR.'htmlpurifier'.DIRECTORY_SEPARATOR.'library'.DIRECTORY_SEPARATOR.'HTMLPurifier.auto.php');
$path = base_path('vendor'.DIRECTORY_SEPARATOR.'htmlpurifier'.DIRECTORY_SEPARATOR.'library'.DIRECTORY_SEPARATOR.'HTMLPurifier'.DIRECTORY_SEPARATOR.'DefinitionCache'.DIRECTORY_SEPARATOR.'Serializer');
if (!File::exists($path)) {
File::makeDirectory($path, $mode = 0777, true, true);
}
@@ -51,27 +56,32 @@ class Ticket_Thread extends Model {
if ($value != strip_tags($value)) {
$value = $purifier->purify($value);
}
return $value;
}
public function purify() {
public function purify()
{
$value = $this->attributes['body'];
$str = str_replace("'", '"', $value);
$html = preg_replace('#<script(.*?)>(.*?)</script>#is', '', $str);
$string = trim(preg_replace('/\s+/', ' ', $html));
$content = $this->inlineAttachment($string);
return $content;
}
public function setTitleAttribute($value) {
if ($value == "") {
public function setTitleAttribute($value)
{
if ($value == '') {
$this->attributes['title'] = 'No available';
} else {
$this->attributes['title'] = $value;
}
}
public function removeScript($html) {
public function removeScript($html)
{
$doc = new \DOMDocument();
// load the HTML string we want to strip
@@ -89,50 +99,58 @@ class Ticket_Thread extends Model {
// get the HTML string back
$no_script_html_string = $doc->saveHTML();
return $no_script_html_string;
}
public function firstContent() {
public function firstContent()
{
$poster = $this->attributes['poster'];
if ($poster == 'client') {
return 'yes';
}
return 'no';
}
public function inlineAttachment($body) {
public function inlineAttachment($body)
{
$attachments = $this->attach;
if ($attachments->count() > 0) {
if ($attachments->count() > 0) {
foreach ($attachments as $key => $attach) {
if($attach->poster=="INLINE" || $attach->poster=="inline"){
if ($attach->poster == 'INLINE' || $attach->poster == 'inline') {
$search = $attach->name;
$replace = "data:$attach->type;base64," . $attach->file;
$replace = "data:$attach->type;base64,".$attach->file;
$b = str_replace($search, $replace, $body);
$body = $b;
}
}
}
return $body;
}
public function getSubject(){
public function getSubject()
{
$subject = $this->attributes['title'];
$array = imap_mime_header_decode($subject);
$title = "";
if(is_array($array) && count($array)>0){
foreach($array as $text){
$title = '';
if (is_array($array) && count($array) > 0) {
foreach ($array as $text) {
$title .= $text->text;
}
return wordwrap($title, 70, "<br>\n");
}
return wordwrap($subject, 70, "<br>\n");
}
public function user(){
public function user()
{
$related = 'App\User';
$foreignKey = 'user_id';
return $this->belongsTo($related, $foreignKey);
}
}

View File

@@ -3,21 +3,23 @@
namespace App\Model\helpdesk\Ticket;
//use App\BaseModel;
use Illuminate\Database\Eloquent\Model;
use File;
use Illuminate\Database\Eloquent\Model;
class Ticket_Thread extends Model {
class Ticket_ThreadOld extends Model
{
protected $table = 'ticket_thread';
protected $fillable = [
'id', 'ticket_id', 'staff_id', 'user_id', 'thread_type', 'poster', 'source', 'is_internal', 'title', 'body', 'format', 'ip_address', 'created_at', 'updated_at',
];
public function attach() {
public function attach()
{
return $this->hasMany('App\Model\helpdesk\Ticket\Ticket_attachments', 'thread_id');
}
public function delete() {
public function delete()
{
$this->attach()->delete();
parent::delete();
}
@@ -26,20 +28,23 @@ class Ticket_Thread extends Model {
// $this->attributes['title'] = str_replace('"', "'", $value);
// }
public function getTitleAttribute($value) {
public function getTitleAttribute($value)
{
return str_replace('"', "'", $value);
}
public function thread($content) {
// $porufi = $this->purify($content);
public function thread($content)
{
// $porufi = $this->purify($content);
// dd($content,$porufi);
//return $content;
return $this->purify($content);
}
public function purifyOld($value) {
require_once base_path('vendor' . DIRECTORY_SEPARATOR . 'htmlpurifier' . DIRECTORY_SEPARATOR . 'library' . DIRECTORY_SEPARATOR . 'HTMLPurifier.auto.php');
$path = base_path('vendor' . DIRECTORY_SEPARATOR . 'htmlpurifier' . DIRECTORY_SEPARATOR . 'library' . DIRECTORY_SEPARATOR . 'HTMLPurifier' . DIRECTORY_SEPARATOR . 'DefinitionCache' . DIRECTORY_SEPARATOR . 'Serializer');
public function purifyOld($value)
{
require_once base_path('vendor'.DIRECTORY_SEPARATOR.'htmlpurifier'.DIRECTORY_SEPARATOR.'library'.DIRECTORY_SEPARATOR.'HTMLPurifier.auto.php');
$path = base_path('vendor'.DIRECTORY_SEPARATOR.'htmlpurifier'.DIRECTORY_SEPARATOR.'library'.DIRECTORY_SEPARATOR.'HTMLPurifier'.DIRECTORY_SEPARATOR.'DefinitionCache'.DIRECTORY_SEPARATOR.'Serializer');
if (!File::exists($path)) {
File::makeDirectory($path, $mode = 0777, true, true);
}
@@ -51,27 +56,32 @@ class Ticket_Thread extends Model {
if ($value != strip_tags($value)) {
$value = $purifier->purify($value);
}
return $value;
}
public function purify() {
public function purify()
{
$value = $this->attributes['body'];
$str = str_replace("'", '"', $value);
$html = preg_replace('#<script(.*?)>(.*?)</script>#is', '', $str);
$string = trim(preg_replace('/\s+/', ' ', $html));
$content = $this->inlineAttachment($string);
return $content;
}
public function setTitleAttribute($value) {
if ($value == "") {
public function setTitleAttribute($value)
{
if ($value == '') {
$this->attributes['title'] = 'No available';
} else {
$this->attributes['title'] = $value;
}
}
public function removeScript($html) {
public function removeScript($html)
{
$doc = new \DOMDocument();
// load the HTML string we want to strip
@@ -89,43 +99,53 @@ class Ticket_Thread extends Model {
// get the HTML string back
$no_script_html_string = $doc->saveHTML();
return $no_script_html_string;
}
public function firstContent() {
public function firstContent()
{
$poster = $this->attributes['poster'];
if ($poster == 'client') {
return 'yes';
}
return 'no';
}
public function inlineAttachment($body) {
public function inlineAttachment($body)
{
if ($this->attach()->where('poster', 'INLINE')->get()->count() > 0) {
$search = $this->attach()->where('poster', 'INLINE')->lists('name')->toArray();
foreach ($this->attach()->where('poster', 'INLINE')->get() as $key => $attach) {
$replace[$key] = "data:$attach->type;base64," . $attach->file;
$replace[$key] = "data:$attach->type;base64,".$attach->file;
}
$body = str_replace($search, $replace, $body);
}
return $body;
}
public function getSubject(){
public function getSubject()
{
$subject = $this->attributes['title'];
$array = imap_mime_header_decode($subject);
$title = "";
if(is_array($array) && count($array)>0){
foreach($array as $text){
$title = '';
if (is_array($array) && count($array) > 0) {
foreach ($array as $text) {
$title .= $text->text;
}
return wordwrap($title, 70, "<br>\n");
}
return wordwrap($subject, 70, "<br>\n");
}
public function labels($ticketid){
$label = new \App\Model\helpdesk\Filters\Label();
public function labels($ticketid)
{
$label = new \App\Model\helpdesk\Filters\Label();
return $label->assignedLabels($ticketid);
}
}

View File

@@ -4,14 +4,15 @@ namespace App\Model\helpdesk\Ticket;
use Illuminate\Database\Eloquent\Model;
class Ticket_attachments extends Model {
class Ticket_attachments extends Model
{
protected $table = 'ticket_attachment';
protected $fillable = [
'id', 'thread_id', 'name', 'size', 'type', 'file', 'data', 'poster', 'updated_at', 'created_at',
];
public function setFileAttribute($value) {
public function setFileAttribute($value)
{
if ($value) {
$this->attributes['file'] = base64_encode($value);
} else {
@@ -19,42 +20,43 @@ class Ticket_attachments extends Model {
}
}
public function getFileAttribute($value) {
public function getFileAttribute($value)
{
$drive = $this->driver;
$name = $this->name;
$root = $this->path;
if (($drive=="database" || !$drive) && $value && base64_decode($value, true) === false) {
if (($drive == 'database' || !$drive) && $value && base64_decode($value, true) === false) {
$value = base64_encode($value);
}
if($drive && $drive!=="database"){
if ($drive && $drive !== 'database') {
$storage = new \App\FaveoStorage\Controllers\StorageController();
$content = $storage->getFile($drive, $name);
$value = base64_encode($content);
}
return $value;
}
public function getFile() {
public function getFile()
{
$size = $this->size;
$drive = $this->driver;
$name = $this->name;
$root = $this->path;
$units = array('B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB');
$units = ['B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'];
$power = $size > 0 ? floor(log($size, 1024)) : 0;
$value = number_format($size / pow(1024, $power), 2, '.', ',') . ' ' . $units[$power];
$value = number_format($size / pow(1024, $power), 2, '.', ',').' '.$units[$power];
if ($this->poster == 'ATTACHMENT') {
if (mime($this->type) == "image") {
if (mime($this->type) == 'image') {
$var = '<a href="'.\URL::route('image', ['image_id' => $this->id]).'" target="_blank"><img style="max-width:200px;height:133px;" src="data:image/jpg;base64,'.$this->file.'"/></a>';
$var = '<a href="' . \URL::route('image', array('image_id' => $this->id)) . '" target="_blank"><img style="max-width:200px;height:133px;" src="data:image/jpg;base64,' . $this->file . '"/></a>';
return '<li style="background-color:#f4f4f4;"><span class="mailbox-attachment-icon has-img">' . $var . '</span><div class="mailbox-attachment-info"><b style="word-wrap: break-word;">' . $this->name . '</b><br/><p>' . $value . '</p></div></li>';
return '<li style="background-color:#f4f4f4;"><span class="mailbox-attachment-icon has-img">'.$var.'</span><div class="mailbox-attachment-info"><b style="word-wrap: break-word;">'.$this->name.'</b><br/><p>'.$value.'</p></div></li>';
} else {
//$var = '<a href="' . URL::route('image', array('image_id' => $attachment->id)) . '" target="_blank"><img style="max-width:200px;height:133px;" src="data:'.$attachment->type.';base64,' . base64_encode($data) . '"/></a>';
$var = '<a style="max-width:200px;height:133px;color:#666;" href="' . \URL::route('image', array('image_id' => $this->id)) . '" target="_blank"><span class="mailbox-attachment-icon" style="background-color:#fff; font-size:18px;">' . strtoupper(str_limit($this->type,15)) . '</span><div class="mailbox-attachment-info"><span ><b style="word-wrap: break-word;">' . $this->name . '</b><br/><p>' . $value . '</p></span></div></a>';
return '<li style="background-color:#f4f4f4;">' . $var . '</li>';
$var = '<a style="max-width:200px;height:133px;color:#666;" href="'.\URL::route('image', ['image_id' => $this->id]).'" target="_blank"><span class="mailbox-attachment-icon" style="background-color:#fff; font-size:18px;">'.strtoupper(str_limit($this->type, 15)).'</span><div class="mailbox-attachment-info"><span ><b style="word-wrap: break-word;">'.$this->name.'</b><br/><p>'.$value.'</p></span></div></a>';
return '<li style="background-color:#f4f4f4;">'.$var.'</li>';
}
}
}
}

View File

@@ -9,6 +9,6 @@ class Ticket_source extends BaseModel
public $timestamps = false;
protected $table = 'ticket_source';
protected $fillable = [
'name', 'value','css_class',
'name', 'value', 'css_class',
];
}

View File

@@ -4,8 +4,8 @@ namespace App\Model\helpdesk\Ticket;
use App\BaseModel;
class Tickets extends BaseModel {
class Tickets extends BaseModel
{
protected $table = 'tickets';
protected $fillable = ['id', 'ticket_number', 'num_sequence', 'user_id', 'priority_id', 'sla', 'help_topic_id', 'max_open_ticket', 'captcha', 'status', 'lock_by', 'lock_at', 'source', 'isoverdue', 'reopened', 'isanswered', 'is_deleted', 'closed', 'is_transfer', 'transfer_at', 'reopened_at', 'duedate', 'closed_at', 'last_message_at', 'last_response_at', 'created_at', 'updated_at', 'assigned_to'];
@@ -13,62 +13,76 @@ class Tickets extends BaseModel {
// return $this->hasMany('App\Model\helpdesk\Ticket\Ticket_attachments',);
//
// }
public function thread() {
public function thread()
{
return $this->hasMany('App\Model\helpdesk\Ticket\Ticket_Thread', 'ticket_id');
}
public function collaborator() {
public function collaborator()
{
return $this->hasMany('App\Model\helpdesk\Ticket\Ticket_Collaborator', 'ticket_id');
}
public function helptopic(){
public function helptopic()
{
$related = 'App\Model\helpdesk\Manage\Help_topic';
$foreignKey = 'help_topic_id';
return $this->belongsTo($related, $foreignKey);
}
public function formdata() {
public function formdata()
{
return $this->hasMany('App\Model\helpdesk\Ticket\Ticket_Form_Data', 'ticket_id');
}
public function extraFields() {
public function extraFields()
{
$id = $this->attributes['id'];
$ticket_form_datas = \App\Model\helpdesk\Ticket\Ticket_Form_Data::where('ticket_id', '=', $id)->get();
return $ticket_form_datas;
}
public function source() {
public function source()
{
$source_id = $this->attributes['source'];
$sources = new Ticket_source();
$source = $sources->find($source_id);
return $source;
}
public function sourceCss() {
$css = "fa fa-comment";
public function sourceCss()
{
$css = 'fa fa-comment';
$source = $this->source();
if ($source) {
$css = $source->css_class;
}
return $css;
}
public function delete() {
public function delete()
{
$this->thread()->delete();
$this->collaborator()->delete();
$this->formdata()->delete();
parent::delete();
}
public function setAssignedToAttribute($value) {
public function setAssignedToAttribute($value)
{
if (!$value) {
$this->attributes['assigned_to'] = null;
}else{
$this->attributes['assigned_to'] = $value;
} else {
$this->attributes['assigned_to'] = $value;
}
}
public function getAssignedTo() {
public function getAssignedTo()
{
$agentid = $this->attributes['assigned_to'];
if ($agentid) {
$users = new \App\User();
@@ -78,11 +92,12 @@ class Tickets extends BaseModel {
}
}
}
public function user(){
public function user()
{
$related = "App\User";
$foreignKey = "user_id";
$foreignKey = 'user_id';
return $this->belongsTo($related, $foreignKey);
}
}

View File

@@ -5,7 +5,7 @@ namespace App\Model\helpdesk\Utility;
use App\BaseModel;
class Limit_Login extends BaseModel
{
protected $table = 'login_attempts';
{
protected $table = 'login_attempts';
protected $fillable = ['User', 'IP', 'Attempts', 'LastLogin', 'created_at', 'updated_at'];
}