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

@@ -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);
}
}