Bagaimana Mengimprovisasi Halaman SysLog di Sistem osTicket v1.6 RC5
Dalam artikel ini kita akan melihat bagaimana melakukan improvisasi pada fitur yang terdapat di Halaman SysLog yang dapat Anda akses dari Panel Admin -> Dashboard dari Sistem osTicket Anda. Kondisi saat ini adalah: (1) Fitur paginasi (membagi record per halaman) memang muncul di bagian bawah dari tabel, tapi fitur ini tidak berfungsi ketika Anda mengklik pada tautan Next atau halaman berikutnya, (2) Belum ada label yang bertuliskan informasi “Menampilkan x – y dari z” di sebelah atas tabel, (3) Anda tidak dapat langsung menentukan maksimal record yang ditampilkan dalam satu halaman pada form pencarian, dan: (4) Anda tidak dapat menghapus satu atau beberapa record syslog secara manual dan hanya tergantung kepada penghapusan otomatis yang durasi waktunya bisa ditentukan dari bagian Setting di Panel Admin. Jadi, saya membuat modifikasi bagaimana supaya fitur-fitur tadi berfungsi sebagaimana mestinya.
- Buka file\include\staff\syslogs.inc.php, cari kode ini:
70
$pagelimit=30;
ganti dengan kode berikut:
70 71 72 73 74 75 76
// Begin of modified by Masino Sinaga, September 15, 2009 if($_GET['limit']){ $qstr.='&limit='.urlencode($_GET['limit']); } $pagelimit=$_GET['limit']?$_GET['limit']:5; $page=($_GET['p'] && is_numeric($_GET['p']))?$_GET['p']:1; // End of modified by Masino Sinaga, September 15, 2009
Cari kode ini:
86
$showing=db_num_rows($resp)?$pageNav->showing():"";
ganti dengan kode berikut:
86
$showing=db_num_rows($result)?$pageNav->showing():"";
Cari kode ini:
107 108 109
<option value="Debug" <?=($type=='Debug')?'selected="selected"':''?>>Debug</option> </select>
Ganti dengan kode berikut:
107 108 109 110 111 112 113 114 115 116 117 118 119 120 121
<option value="Debug" <?=($type=='Debug')?'selected="selected"':''?>>Debug</option> </select> Limit: <select name='limit'> <?php for ($x = 5; $x <= 50; $x += 5) { ?> <option value="<?=$x?>" <?=($pagelimit==$x )?'selected':''?>><?=$x?></option> <?php } ?> </select>
Cari kode ini:
129 130
<form action="tickets.php" method="POST" name='tickets' onSubmit="return checkbox_checker(this,1,0);"> <input type="hidden" name="a" value="mass_process" >
ganti dengan kode berikut:
129 130 131
<form action="admin.php?t=syslog" method="POST" name='syslog' onSubmit="return checkbox_checker(this,1,0);"> <input type='hidden' name='t' value='syslog'> <input type="hidden" name="do" value="mass_process" >
Cari kode ini:
134 135
<table width="100%" border="0" cellspacing=0 cellpadding=2 class="logs" align="center"> <tr><th><?=$title?></th></tr>
ganti dengan kode berikut:
134 135
<table width="100%" border="0" cellspacing=0 cellpadding=2 class="logs" align="center"> <b><?=$showing?> <?=$results_type?></b> <tr><th> </th><th><?=$title?></th></tr>
Cari kode ini:
144
<tr class="<?=$class?> " id="<?=$row['log_id']?>">
ganti dengan kode berikut:
144 145 146 147 148
<tr class="<?=$class?> " id="<?=$row['log_id']?>"> <td width=7px> <input type="checkbox" name="ids[]" value="<?=$row['log_id']?>" <?=$sel?'checked':''?> onClick="highLight(this.value,this.checked);"> </td>
Cari kode ini:
172 173 174 175
if($num>0){ ?> <tr><td style="padding-left:20px">page:<?=$pageNav->getPageLinks()?></td></tr> <?} ?>ganti dengan kode berikut:
172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196
if($num>0){ ?> <tr><td style="padding-left:20px">page:<?=$pageNav->getPageLinks()?></td></tr> <?} ?> <? if(db_num_rows($result)>0): //Show options.. ?> <tr> <td style="padding-left:20px"> Select: <a href="#" onclick="return select_all(document.forms['syslog'],true)">All</a> <a href="#" onclick="return reset_all(document.forms['syslog'])">None</a> <a href="#" onclick="return toogle_all(document.forms['syslog'],true)">Toggle</a> </td> </tr> <tr> <td align="center"> <input class="button" type="submit" name="delete" value="Delete Selected Log Record" onClick=' return confirm("Are you sure you want to DELETE selected log record?");'> </td> </tr> <? endif; ?> -
Buka file \include\class.sys.php, cari kode ini:
97 98 99 100 101 102 103 104 105
function purgeLogs(){ global $cfg; if($cfg && ($gp=$cfg->getLogGraceperiod()) && is_numeric($gp)) { $sql='DELETE FROM '.SYSLOG_TABLE.' WHERE DATE_ADD(created, INTERVAL '.$gp.' MONTH)<=NOW()'; db_query($sql); } }
di bawah baris terakhir dari kode tadi, tambahkan kode berikut:
107 108 109 110 111 112 113 114 115 116 117
// Begin of MOD SysLog, added by Masino Sinaga, September 15, 2009 function deleteSysLog($id) { global $cfg; $sql='DELETE FROM '.SYSLOG_TABLE.' WHERE log_id='.db_input($id).' LIMIT 1'; if(db_query($sql) && ($num=db_affected_rows())){ // DO SOME HOUSE CLEANING..should be taken care already...but doesn't hurt to make sure. return $num; } return 0; } // End of MOD SysLog, added by Masino Sinaga, September 15, 2009
-
Buka file \scp\admin.php, cari kode ini:
228 229 230 231 232 233 234 235 236
}else{ $errors['err']='Unknown command'; } } break; default: $errors['err']='Unknown topic action!'; } break;
ganti dengan kode berikut:
228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268
}else{ $errors['err']='Unknown command'; } } break; default: $errors['err']='Unknown topic action!'; } break; case 'syslog': require_once(INCLUDE_DIR.'class.sys.php'); $do=strtolower($_POST['do']); switch($do){ case 'mass_process': if(!$_POST['ids'] || !is_array($_POST['ids'])) { $errors['err']='You must select at least one email to process'; }else{ $count=count($_POST['ids']); $ids=implode(',',$_POST['ids']); $sql='SELECT count(log_id) FROM '.SYSLOG_TABLE.' WHERE log_id IN ('.$ids.')'; list($sys)=db_fetch_row(db_query($sql)); if($sys<0){ $errors['err']='One or more of the selected syslog has/have been removed by another admin.'; }elseif($_POST['delete']){ $i=0; foreach($_POST['ids'] as $k=>$v) { if(Sys::deleteSysLog($v)) $i++; } if($i>0){ $msg="$i of $count selected syslog(s) deleted"; }else{ $errors['err']='Unable to delete selected syslog(s).'; } }else{ $errors['err']='Unknown command'; } } break; } break;
Gambar: http://www.osticket.com/forums/showthread.php?t=2749.
Cetak Artikel Ini



Hey Masino,
Just wanted to mention that this is a great MOD but I’ve run into a problem. I’ve been trying to locate the problem but so far have been unsuccessful. When trying to delete a syslog entry it goes to the admin.php?t=syslog page but its the blank white page we all fear. Can you shed any light on this? Can you replicate the issue?
Thanks
Make sure that “short open tag” is enabled in your PHP setting, since some of the code above using the mixed
<?and
<?php.
Yup, its on. I’ve got several MODs myself that all use both <? and <?php
Thanks for the response. Any other ideas? Otherwise I spose I'll just repaste everything in again on my test server and hope something was goofed up the first time around.
Make sure you have followed all steps above correctly. Re-check the modification you made, and make sure there is no missing-syntax, since this usually causes the blank page.