diff --git a/include/staff/api.inc.php b/include/staff/api.inc.php index 7463ad0956cbfbb02d2e4d3faa82cfa0cd6da35e..21eac469162af3d2cc9652d8e8255f230ee18460 100644 --- a/include/staff/api.inc.php +++ b/include/staff/api.inc.php @@ -1,146 +1,147 @@ -<?php -if(!defined('OSTADMININC') || !$thisstaff->isadmin()) die('Access Denied'); - - -$info['phrase']=($errors && $_POST['phrase'])?Format::htmlchars($_POST['phrase']):$cfg->getAPIPassphrase(); -$select='SELECT * '; -$from='FROM '.API_KEY_TABLE; -$where=''; -$sortOptions=array('date'=>'created','ip'=>'ipaddr'); -$orderWays=array('DESC'=>'DESC','ASC'=>'ASC'); -//Sorting options... -if($_REQUEST['sort']) { - $order_column =$sortOptions[$_REQUEST['sort']]; -} - -if($_REQUEST['order']) { - $order=$orderWays[$_REQUEST['order']]; -} -$order_column=$order_column?$order_column:'ipaddr'; -$order=$order?$order:'ASC'; -$order_by=" ORDER BY $order_column $order "; - -$total=db_count('SELECT count(*) '.$from.' '.$where); -$pagelimit=1000;//No limit. -$page=($_GET['p'] && is_numeric($_GET['p']))?$_GET['p']:1; -$pageNav=new Pagenate($total,$page,$pagelimit); -$pageNav->setURL('admin.php',$qstr.'&sort='.urlencode($_REQUEST['sort']).'&order='.urlencode($_REQUEST['order'])); -$query="$select $from $where $order_by"; -//echo $query; -$result = db_query($query); -$showing=db_num_rows($result)?$pageNav->showing():''; -$negorder=$order=='DESC'?'ASC':'DESC'; //Negate the sorting.. -$deletable=0; -?> -<div class="msg">API Keys</div> -<hr> -<div><b><?php echo $showing; ?></b></div> - <table width="100%" border="0" cellspacing=1 cellpadding=2> - <form action="admin.php?t=api" method="POST" name="api" onSubmit="return checkbox_checker(document.forms['api'],1,0);"> - <input type=hidden name='t' value='api'> - <input type=hidden name='do' value='mass_process'> - <tr><td> - <table border="0" cellspacing=0 cellpadding=2 class="dtable" align="center" width="100%"> - <tr> - <th width="7px"> </th> - <th>API Key</th> - <th width="10" nowrap>Active</th> - <th width="100" nowrap> IP Address</th> - <th width="150" nowrap> - <a href="admin.php?t=api&sort=date&order=<?php echo $negorder; ?><?php echo $qstr; ?>" title="Sort By Create Date <?php echo $negorder; ?>">Created</a></th> - </tr> +<?php +if(!defined('OSTADMININC') || !$thisstaff->isadmin()) die('Access Denied'); + + +$info['phrase']=($errors && $_POST['phrase'])?Format::htmlchars($_POST['phrase']):$cfg->getAPIPassphrase(); +$select='SELECT * '; +$from='FROM '.API_KEY_TABLE; +$where=''; +$sortOptions=array('date'=>'created','ip'=>'ipaddr'); +$orderWays=array('DESC'=>'DESC','ASC'=>'ASC'); +//Sorting options... +if($_REQUEST['sort']) { + $order_column =$sortOptions[$_REQUEST['sort']]; +} + +if($_REQUEST['order']) { + $order=$orderWays[$_REQUEST['order']]; +} +$order_column=$order_column?$order_column:'ipaddr'; +$order=$order?$order:'ASC'; +$order_by=" ORDER BY $order_column $order "; + +$total=db_count('SELECT count(*) '.$from.' '.$where); +$pagelimit=1000;//No limit. TODO: Add limit. +$page=($_GET['p'] && is_numeric($_GET['p']))?$_GET['p']:1; +$pageNav=new Pagenate($total,$page,$pagelimit); +$pageNav->setURL('admin.php',$qstr.'&sort='.urlencode($_REQUEST['sort']).'&order='.urlencode($_REQUEST['order'])); +$query="$select $from $where $order_by"; +//echo $query; +$result = db_query($query); +$showing=db_num_rows($result)?$pageNav->showing():''; +$negorder=$order=='DESC'?'ASC':'DESC'; //Negate the sorting.. +$deletable=0; +?> +<div class="msg">API Keys</div> +<hr> +<div><b><?php echo $showing; ?></b></div> + <table width="100%" border="0" cellspacing=1 cellpadding=2> + <form action="admin.php?t=api" method="POST" name="api" onSubmit="return checkbox_checker(document.forms['api'],1,0);"> + <input type=hidden name='t' value='api'> + <input type=hidden name='do' value='mass_process'> + <tr><td> + <table border="0" cellspacing=0 cellpadding=2 class="dtable" align="center" width="100%"> + <tr> + <th width="7px"> </th> + <th>API Key</th> + <th width="10" nowrap>Active</th> + <th width="100" nowrap> IP Address</th> + <th width="150" nowrap> + <a href="admin.php?t=api&sort=date&order=<?php echo $negorder; ?><?php echo $qstr; ?>" title="Sort By Create Date <?php echo $negorder; ?>">Created</a></th> + </tr> <?php - $class = 'row1'; - $total=0; - $active=$inactive=0; - $sids=($errors && is_array($_POST['ids']))?$_POST['ids']:null; - if($result && db_num_rows($result)): - $dtpl=$cfg->getDefaultTemplateId(); - while ($row = db_fetch_array($result)) { - $sel=false; - $disabled=''; - if($row['isactive']) - $active++; - else - $inactive++; - - if($sids && in_array($row['id'],$sids)){ - $class="$class highlight"; - $sel=true; - } - ?> - <tr class="<?php echo $class; ?>" id="<?php echo $row['id']; ?>"> - <td width=7px> - <input type="checkbox" name="ids[]" value="<?php echo $row['id']; ?>" <?php echo $sel?'checked':''; ?> - onClick="highLight(this.value,this.checked);"> - <td> <?php echo $row['apikey']; ?></td> - <td><?php echo $row['isactive']?'<b>Yes</b>':'No'; ?></td> - <td> <?php echo $row['ipaddr']; ?></td> - <td> <?php echo Format::db_datetime($row['created']); ?></td> - </tr> + $class = 'row1'; + $total=0; + $active=$inactive=0; + $sids=($errors && is_array($_POST['ids']))?$_POST['ids']:null; + if($result && db_num_rows($result)): + $dtpl=$cfg->getDefaultTemplateId(); + while ($row = db_fetch_array($result)) { + $sel=false; + $disabled=''; + if($row['isactive']) + $active++; + else + $inactive++; + + if($sids && in_array($row['id'],$sids)){ + $class="$class highlight"; + $sel=true; + } + ?> + <tr class="<?php echo $class; ?>" id="<?php echo $row['id']; ?>"> + <td width=7px> + <input type="checkbox" name="ids[]" value="<?php echo $row['id']; ?>" <?php echo $sel?'checked':''; ?> + onClick="highLight(this.value,this.checked);"> + <td> <?php echo $row['apikey']; ?></td> + <td><?php echo $row['isactive']?'<b>Yes</b>':'No'; ?></td> + <td> <?php echo $row['ipaddr']; ?></td> + <td> <?php echo Format::db_datetime($row['created']); ?></td> + </tr> <?php - $class = ($class =='row2') ?'row1':'row2'; - } //end of while. - else: //nothin' found!! ?> - <tr class="<?php echo $class; ?>"><td colspan=5><b>Query returned 0 results</b> <a href="admin.php?t=templates">Index list</a></td></tr> + $class = ($class =='row2') ?'row1':'row2'; + } //end of while. + else: //nothin' found!! ?> + <tr class="<?php echo $class; ?>"><td colspan=5><b>Query returned 0 results</b> <a href="admin.php?t=templates">Index list</a></td></tr> <?php - endif; ?> - - </table> - </td></tr> + endif; ?> + + </table> + </td></tr> <?php - if(db_num_rows($result)>0): //Show options.. - ?> - <tr> - <td align="center"> - <?php - if($inactive) { ?> - <input class="button" type="submit" name="enable" value="Enable" - onClick='return confirm("Are you sure you want to ENABLE selected keys?");'> - <?php - } - if($active){ ?> - - <input class="button" type="submit" name="disable" value="Disable" - onClick='return confirm("Are you sure you want to DISABLE selected keys?");'> - <?php } ?> - - <input class="button" type="submit" name="delete" value="Delete" - onClick='return confirm("Are you sure you want to DELETE selected keys?");'> - </td> - </tr> + if(db_num_rows($result)>0): //Show options.. + ?> + <tr> + <td align="center"> + <?php + if($inactive) { ?> + <input class="button" type="submit" name="enable" value="Enable" + onClick='return confirm("Are you sure you want to ENABLE selected keys?");'> + <?php + } + if($active){ ?> + + <input class="button" type="submit" name="disable" value="Disable" + onClick='return confirm("Are you sure you want to DISABLE selected keys?");'> + <?php } ?> + + <input class="button" type="submit" name="delete" value="Delete" + onClick='return confirm("Are you sure you want to DELETE selected keys?");'> + </td> + </tr> <?php - endif; - ?> - </form> - </table> - <br/> - <div class="msg">Add New IP</div> - <hr> - <div> - Add a new IP address. <font class="error"><?php echo $errors['ip']; ?></font> - <form action="admin.php?t=api" method="POST" > - <input type=hidden name='t' value='api'> - <input type=hidden name='do' value='add'> - New IP: - <input name="ip" size=30 value="<?php echo ($errors['ip'])?Format::htmlchars($_REQUEST['ip']):''; ?>" /> - <font class="error">* </font> - <input class="button" type="submit" name="add" value="Add"> - </form> - </div> - <br/> - <div class="msg">API Passphrase</div> - <hr> - <div> - Passphrase must be at least 3 words. Required to generate the api keys.<br/> - <form action="admin.php?t=api" method="POST" > - <input type=hidden name='t' value='api'> - <input type=hidden name='do' value='update_phrase'> - Phrase: - <input name="phrase" size=50 value="<?php echo Format::htmlchars($info['phrase']); ?>" /> - <font class="error">* <?php echo $errors['phrase']; ?></font> - <input class="button" type="submit" name="update" value="Submit"> - </form> - <br/><br/> - <div><i>Please note that changing the passprase does NOT invalidate existing keys. To regerate a key you need to delete and readd it.</i></div> - </div> + endif; + ?> + </form> + </table> + <br/> + <div class="msg">Add New IP</div> + <hr> + <div> + Add a new IP address. <font class="error"><?php echo $errors['ip']; ?></font> + <form action="admin.php?t=api" method="POST" > + <input type=hidden name='t' value='api'> + <input type=hidden name='do' value='add'> + New IP: + <input name="ip" size=30 value="<?php echo ($errors['ip'])?Format::htmlchars($_REQUEST['ip']):''; ?>" /> + <font class="error">* </font> + <input class="button" type="submit" name="add" value="Add"> + </form> + </div> + <br/> + <div class="msg">API Passphrase</div> + <hr> + <div> + Passphrase must be at least 3 words. Required to generate the api keys.<br/> + <form action="admin.php?t=api" method="POST" > + <input type=hidden name='t' value='api'> + <input type=hidden name='do' value='update_phrase'> + Phrase: + <input name="phrase" size=50 value="<?php echo Format::htmlchars($info['phrase']); ?>" /> + <font class="error">* <?php echo $errors['phrase']; ?></font> + <input class="button" type="submit" name="update" value="Submit"> + </form> + <br/><br/> + <div><i>Please note that changing the passprase does NOT invalidate existing keys. To regerate a key you need to delete and readd it.</i></div> + </div> + diff --git a/include/staff/apikeys.inc.php b/include/staff/apikeys.inc.php index 26468089d56016c34e8dfd1dfefc972f33854b29..d7063c749ce92c04cddc36f20902b88181ab51d4 100644 --- a/include/staff/apikeys.inc.php +++ b/include/staff/apikeys.inc.php @@ -25,10 +25,8 @@ $$x=' class="'.strtolower($order).'" '; $order_by="$order_column $order "; $total=db_count('SELECT count(*) FROM '.API_KEY_TABLE.' '); -$pagelimit=$thisstaff->getPageLimit(); -$pagelimit=$pagelimit?$pagelimit:PAGE_LIMIT; //true default...if all fails. $page=($_GET['p'] && is_numeric($_GET['p']))?$_GET['p']:1; -$pageNav=new Pagenate($total,$page,$pagelimit); +$pageNav=new Pagenate($total,$page,PAGE_LIMIT); $pageNav->setURL('apikeys.php',$qstr.'&sort='.urlencode($_REQUEST['sort']).'&order='.urlencode($_REQUEST['order'])); //Ok..lets roll...create the actual query $qstr.='&order='.($order=='DESC'?'ASC':'DESC'); diff --git a/include/staff/banlist.inc.php b/include/staff/banlist.inc.php index 5978964273ed573ca42fa817ed7eaf348ae143cb..ecef00ba4325e18339b4f733d82a34b38466b950 100644 --- a/include/staff/banlist.inc.php +++ b/include/staff/banlist.inc.php @@ -41,10 +41,8 @@ $$x=' class="'.strtolower($order).'" '; $order_by="$order_column $order "; $total=db_count('SELECT count(DISTINCT rule.id) '.$from.' '.$where); -$pagelimit=$thisstaff->getPageLimit(); -$pagelimit=$pagelimit?$pagelimit:PAGE_LIMIT; //true default...if all fails. $page=($_GET['p'] && is_numeric($_GET['p']))?$_GET['p']:1; -$pageNav=new Pagenate($total,$page,$pagelimit); +$pageNav=new Pagenate($total, $page, PAGE_LIMIT); $pageNav->setURL('banlist.php',$qstr.'&sort='.urlencode($_REQUEST['sort']).'&order='.urlencode($_REQUEST['order'])); $qstr.='&order='.($order=='DESC'?'ASC':'DESC'); $query="$select $from $where ORDER BY $order_by LIMIT ".$pageNav->getStart().",".$pageNav->getLimit(); diff --git a/include/staff/cannedreplies.inc.php b/include/staff/cannedreplies.inc.php index db44a79f3cc9470cdbdbd0746bd589a5bc16b44f..601e27d37f49646b4043b57a717abb64cb626b96 100644 --- a/include/staff/cannedreplies.inc.php +++ b/include/staff/cannedreplies.inc.php @@ -33,10 +33,8 @@ $$x=' class="'.strtolower($order).'" '; $order_by="$order_column $order "; $total=db_count('SELECT count(*) FROM '.CANNED_TABLE.' canned '); -$pagelimit=$thisstaff->getPageLimit(); -$pagelimit=$pagelimit?$pagelimit:PAGE_LIMIT; //true default...if all fails. $page=($_GET['p'] && is_numeric($_GET['p']))?$_GET['p']:1; -$pageNav=new Pagenate($total,$page,$pagelimit); +$pageNav=new Pagenate($total, $page, PAGE_LIMIT); $pageNav->setURL('canned.php',$qstr.'&sort='.urlencode($_REQUEST['sort']).'&order='.urlencode($_REQUEST['order'])); //Ok..lets roll...create the actual query $qstr.='&order='.($order=='DESC'?'ASC':'DESC'); diff --git a/include/staff/categories.inc.php b/include/staff/categories.inc.php index bba679898b0c5b8891486faa657eb73114f50f1f..a437338c20a156550487faf891324e2a16406562 100644 --- a/include/staff/categories.inc.php +++ b/include/staff/categories.inc.php @@ -28,10 +28,8 @@ $$x=' class="'.strtolower($order).'" '; $order_by="$order_column $order "; $total=db_count('SELECT count(*) FROM '.FAQ_CATEGORY_TABLE.' cat '); -$pagelimit=$thisstaff->getPageLimit(); -$pagelimit=$pagelimit?$pagelimit:PAGE_LIMIT; //true default...if all fails. $page=($_GET['p'] && is_numeric($_GET['p']))?$_GET['p']:1; -$pageNav=new Pagenate($total,$page,$pagelimit); +$pageNav=new Pagenate($total, $page, PAGE_LIMIT); $pageNav->setURL('categories.php',$qstr.'&sort='.urlencode($_REQUEST['sort']).'&order='.urlencode($_REQUEST['order'])); $qstr.='&order='.($order=='DESC'?'ASC':'DESC'); $query="$sql GROUP BY cat.category_id ORDER BY $order_by LIMIT ".$pageNav->getStart().",".$pageNav->getLimit(); diff --git a/include/staff/directory.inc.php b/include/staff/directory.inc.php index b687d811f2a8993c7eb8753fadb4efe5fe7668ad..c9d11a3d4bf1d8921b3261fc80d3e9a6a73616ae 100644 --- a/include/staff/directory.inc.php +++ b/include/staff/directory.inc.php @@ -52,10 +52,8 @@ $$x=' class="'.strtolower($order).'" '; $order_by="$order_column $order "; $total=db_count('SELECT count(DISTINCT staff.staff_id) '.$from.' '.$where); -$pagelimit=$thisstaff->getPageLimit(); -$pagelimit=$pagelimit?$pagelimit:PAGE_LIMIT; //true default...if all fails. $page=($_GET['p'] && is_numeric($_GET['p']))?$_GET['p']:1; -$pageNav=new Pagenate($total,$page,$pagelimit); +$pageNav=new Pagenate($total, $page, PAGE_LIMIT); $pageNav->setURL('directory.php',$qstr.'&sort='.urlencode($_REQUEST['sort']).'&order='.urlencode($_REQUEST['order'])); //Ok..lets roll...create the actual query $qstr.='&order='.($order=='DESC'?'ASC':'DESC'); diff --git a/include/staff/emails.inc.php b/include/staff/emails.inc.php index 44e277b468ad9879edb7fe528b7ba960e0762858..65d34d7b9bfb0b10acd983bfe41e5671932d3060 100644 --- a/include/staff/emails.inc.php +++ b/include/staff/emails.inc.php @@ -29,10 +29,8 @@ $$x=' class="'.strtolower($order).'" '; $order_by="$order_column $order "; $total=db_count('SELECT count(*) FROM '.EMAIL_TABLE.' email '); -$pagelimit=$thisstaff->getPageLimit(); -$pagelimit=$pagelimit?$pagelimit:PAGE_LIMIT; //true default...if all fails. $page=($_GET['p'] && is_numeric($_GET['p']))?$_GET['p']:1; -$pageNav=new Pagenate($total,$page,$pagelimit); +$pageNav=new Pagenate($total, $page, PAGE_LIMIT); $pageNav->setURL('emails.php',$qstr.'&sort='.urlencode($_REQUEST['sort']).'&order='.urlencode($_REQUEST['order'])); //Ok..lets roll...create the actual query $qstr.='&order='.($order=='DESC'?'ASC':'DESC'); diff --git a/include/staff/filters.inc.php b/include/staff/filters.inc.php index 4b9d6f31eb0e04f995ef7ffafde66a6a84bdb618..fb8a48d268a7705d5eb3a49b4076a6dcdb3b0b17 100644 --- a/include/staff/filters.inc.php +++ b/include/staff/filters.inc.php @@ -29,10 +29,8 @@ $$x=' class="'.strtolower($order).'" '; $order_by="$order_column $order "; $total=db_count('SELECT count(*) FROM '.EMAIL_FILTER_TABLE.' filter '); -$pagelimit=$thisstaff->getPageLimit(); -$pagelimit=$pagelimit?$pagelimit:PAGE_LIMIT; //true default...if all fails. $page=($_GET['p'] && is_numeric($_GET['p']))?$_GET['p']:1; -$pageNav=new Pagenate($total,$page,$pagelimit); +$pageNav=new Pagenate($total, $page, PAGE_LIMIT); $pageNav->setURL('filters.php',$qstr.'&sort='.urlencode($_REQUEST['sort']).'&order='.urlencode($_REQUEST['order'])); //Ok..lets roll...create the actual query $qstr.='&order='.($order=='DESC'?'ASC':'DESC'); diff --git a/include/staff/helptopics.inc.php b/include/staff/helptopics.inc.php index 51a7666889f562676910351c69edcf8e10f96b91..27ffde9bdacac59c2687b30b5046dde4255b1537 100644 --- a/include/staff/helptopics.inc.php +++ b/include/staff/helptopics.inc.php @@ -30,10 +30,8 @@ $$x=' class="'.strtolower($order).'" '; $order_by="$order_column $order "; $total=db_count('SELECT count(*) FROM '.TOPIC_TABLE.' topic '); -$pagelimit=$thisstaff->getPageLimit(); -$pagelimit=$pagelimit?$pagelimit:PAGE_LIMIT; //true default...if all fails. $page=($_GET['p'] && is_numeric($_GET['p']))?$_GET['p']:1; -$pageNav=new Pagenate($total,$page,$pagelimit); +$pageNav=new Pagenate($total, $page, PAGE_LIMIT); $pageNav->setURL('helptopics.php',$qstr.'&sort='.urlencode($_REQUEST['sort']).'&order='.urlencode($_REQUEST['order'])); //Ok..lets roll...create the actual query $qstr.='&order='.($order=='DESC'?'ASC':'DESC'); diff --git a/include/staff/settings-general.inc.php b/include/staff/settings-general.inc.php index ff5e058b1e36bdb2a7b51282201c9b5c3e633412..2e1e347bef5c45eab3826c2b263a59149cb32fc4 100644 --- a/include/staff/settings-general.inc.php +++ b/include/staff/settings-general.inc.php @@ -1,196 +1,197 @@ -<form action="settings.php?t=general" method="post" id="save"> -<input type="hidden" name="t" value="general" > -<table class="form_table settings_table" width="940" border="0" cellspacing="0" cellpadding="2"> - <thead> - <tr> - <th colspan="2"> - <h4>General Settings</h4> - <em>Offline mode will disable client interface and only allow admins to login to Staff Control Panel</em> - </th> - </tr> - </thead> - <tbody> - - <tr> - <td width="220" class="required">Helpdesk Status:</td> - <td> - <input type="radio" name="isonline" value="1" <?php echo $config['isonline']?'checked="checked"':''; ?> /><b>Online</b> (Active) - <input type="radio" name="isonline" value="0" <?php echo !$config['isonline']?'checked="checked"':''; ?> /><b>Offline</b> (Disabled) - <font class="error"> <?php echo $config['isoffline']?'osTicket offline':''; ?></font> - </td> - </tr> - <tr> - <td width="220" class="required">Helpdesk URL:</td> - <td> - <input type="text" size="40" name="helpdesk_url" value="<?php echo $config['helpdesk_url']; ?>"> - <font class="error">* <?php echo $errors['helpdesk_url']; ?></font></td> - </tr> - <tr> - <td width="220" class="required">Helpdesk Name/Title:</td> - <td><input type="text" size="40" name="helpdesk_title" value="<?php echo $config['helpdesk_title']; ?>"> - <font class="error">* <?php echo $errors['helpdesk_title']; ?></font></td> - </tr> - <tr> - <td width="220" class="required">Default Department:</td> - <td> - <select name="default_dept_id"> - <option value="">— Select Default Department —</option> +<form action="settings.php?t=general" method="post" id="save"> +<input type="hidden" name="t" value="general" > +<table class="form_table settings_table" width="940" border="0" cellspacing="0" cellpadding="2"> + <thead> + <tr> + <th colspan="2"> + <h4>General Settings</h4> + <em>Offline mode will disable client interface and only allow admins to login to Staff Control Panel</em> + </th> + </tr> + </thead> + <tbody> + + <tr> + <td width="220" class="required">Helpdesk Status:</td> + <td> + <input type="radio" name="isonline" value="1" <?php echo $config['isonline']?'checked="checked"':''; ?> /><b>Online</b> (Active) + <input type="radio" name="isonline" value="0" <?php echo !$config['isonline']?'checked="checked"':''; ?> /><b>Offline</b> (Disabled) + <font class="error"> <?php echo $config['isoffline']?'osTicket offline':''; ?></font> + </td> + </tr> + <tr> + <td width="220" class="required">Helpdesk URL:</td> + <td> + <input type="text" size="40" name="helpdesk_url" value="<?php echo $config['helpdesk_url']; ?>"> + <font class="error">* <?php echo $errors['helpdesk_url']; ?></font></td> + </tr> + <tr> + <td width="220" class="required">Helpdesk Name/Title:</td> + <td><input type="text" size="40" name="helpdesk_title" value="<?php echo $config['helpdesk_title']; ?>"> + <font class="error">* <?php echo $errors['helpdesk_title']; ?></font></td> + </tr> + <tr> + <td width="220" class="required">Default Department:</td> + <td> + <select name="default_dept_id"> + <option value="">— Select Default Department —</option> <?php - $sql='SELECT dept_id,dept_name FROM '.DEPT_TABLE.' WHERE ispublic=1'; - if(($res=db_query($sql)) && db_num_rows($res)){ - while (list($id,$name) = db_fetch_row($res)){ - $selected = ($config['default_dept_id']==$id)?'selected="selected"':''; ?> - <option value="<?php echo $id; ?>"<?php echo $selected; ?>><?php echo $name; ?> Dept</option> + $sql='SELECT dept_id,dept_name FROM '.DEPT_TABLE.' WHERE ispublic=1'; + if(($res=db_query($sql)) && db_num_rows($res)){ + while (list($id,$name) = db_fetch_row($res)){ + $selected = ($config['default_dept_id']==$id)?'selected="selected"':''; ?> + <option value="<?php echo $id; ?>"<?php echo $selected; ?>><?php echo $name; ?> Dept</option> <?php - } - } ?> - </select> <font class="error">* <?php echo $errors['default_dept_id']; ?></font> - </td> - </tr> - <tr> - <td width="220" class="required">Default Email Templates:</td> - <td> - <select name="default_template_id"> - <option value="">— Select Default Template —</option> + } + } ?> + </select> <font class="error">* <?php echo $errors['default_dept_id']; ?></font> + </td> + </tr> + <tr> + <td width="220" class="required">Default Email Templates:</td> + <td> + <select name="default_template_id"> + <option value="">— Select Default Template —</option> <?php - $sql='SELECT tpl_id,name FROM '.EMAIL_TEMPLATE_TABLE.' WHERE isactive=1 AND cfg_id='.db_input($cfg->getId()).' ORDER BY name'; - if(($res=db_query($sql)) && db_num_rows($res)){ - while (list($id,$name) = db_fetch_row($res)){ - $selected = ($config['default_template_id']==$id)?'selected="selected"':''; ?> - <option value="<?php echo $id; ?>"<?php echo $selected; ?>><?php echo $name; ?></option> + $sql='SELECT tpl_id,name FROM '.EMAIL_TEMPLATE_TABLE.' WHERE isactive=1 AND cfg_id='.db_input($cfg->getId()).' ORDER BY name'; + if(($res=db_query($sql)) && db_num_rows($res)){ + while (list($id,$name) = db_fetch_row($res)){ + $selected = ($config['default_template_id']==$id)?'selected="selected"':''; ?> + <option value="<?php echo $id; ?>"<?php echo $selected; ?>><?php echo $name; ?></option> <?php - } - } ?> - </select> <font class="error">* <?php echo $errors['default_template_id']; ?></font> - </td> - </tr> - - <tr><td>Default Page Size:</td> - <td> - <select name="max_page_size"> + } + } ?> + </select> <font class="error">* <?php echo $errors['default_template_id']; ?></font> + </td> + </tr> + + <tr><td>Default Page Size:</td> + <td> + <select name="max_page_size"> <?php - $pagelimit=$config['max_page_size']; - for ($i = 5; $i <= 50; $i += 5) { - ?> - <option <?php echo $config['max_page_size']==$i?'selected="selected"':''; ?> value="<?php echo $i; ?>"><?php echo $i; ?></option> + $pagelimit=$config['max_page_size']; + for ($i = 5; $i <= 50; $i += 5) { + ?> + <option <?php echo $config['max_page_size']==$i?'selected="selected"':''; ?> value="<?php echo $i; ?>"><?php echo $i; ?></option> <?php - } ?> - </select> - </td> - </tr> - <tr> - <td>Default Log Level:</td> - <td> - <select name="log_level"> - <option value=0 <?php echo $config['log_level'] == 0 ? 'selected="selected"':''; ?>>None (Disable Logger)</option> - <option value=3 <?php echo $config['log_level'] == 3 ? 'selected="selected"':''; ?>> DEBUG</option> - <option value=2 <?php echo $config['log_level'] == 2 ? 'selected="selected"':''; ?>> WARN</option> - <option value=1 <?php echo $config['log_level'] == 1 ? 'selected="selected"':''; ?>> ERROR</option> - </select> - <font class="error"> <?php echo $errors['log_level']; ?></font> - </td> - </tr> - <tr> - <td>Purge Logs:</td> - <td> - <select name="log_graceperiod"> - <option value=0 selected>Never Purge Logs</option> + } ?> + </select> + </td> + </tr> + <tr> + <td>Default Log Level:</td> + <td> + <select name="log_level"> + <option value=0 <?php echo $config['log_level'] == 0 ? 'selected="selected"':''; ?>>None (Disable Logger)</option> + <option value=3 <?php echo $config['log_level'] == 3 ? 'selected="selected"':''; ?>> DEBUG</option> + <option value=2 <?php echo $config['log_level'] == 2 ? 'selected="selected"':''; ?>> WARN</option> + <option value=1 <?php echo $config['log_level'] == 1 ? 'selected="selected"':''; ?>> ERROR</option> + </select> + <font class="error"> <?php echo $errors['log_level']; ?></font> + </td> + </tr> + <tr> + <td>Purge Logs:</td> + <td> + <select name="log_graceperiod"> + <option value=0 selected>Never Purge Logs</option> <?php - for ($i = 1; $i <=12; $i++) { - ?> - <option <?php echo $config['log_graceperiod']==$i?'selected="selected"':''; ?> value="<?php echo $i; ?>"> - After <?php echo $i; ?> <?php echo ($i>1)?'Months':'Month'; ?></option> + for ($i = 1; $i <=12; $i++) { + ?> + <option <?php echo $config['log_graceperiod']==$i?'selected="selected"':''; ?> value="<?php echo $i; ?>"> + After <?php echo $i; ?> <?php echo ($i>1)?'Months':'Month'; ?></option> <?php - } ?> - </select> - </td> - </tr> - <tr><td>Password Reset Policy:</th> - <td> - <select name="passwd_reset_period"> - <option value="0"> — None —</option> - <?php - for ($i = 1; $i <= 12; $i++) { - echo sprintf('<option value="%d" %s>%s%s</option>', - $i,(($config['passwd_reset_period']==$i)?'selected="selected"':''),$i>1?"Every $i ":'',$i>1?' Months':'Monthly'); - } - ?> - </select> - <font class="error"> <?php echo $errors['passwd_reset_period']; ?></font> - </td> - </tr> - <tr><td>Staff Excessive Logins:</td> - <td> - <select name="staff_max_logins"> - <?php - for ($i = 1; $i <= 10; $i++) { - echo sprintf('<option value="%d" %s>%d</option>',$i,(($config['staff_max_logins']==$i)?'selected="selected"':''),$i); - } - ?> - </select> failed login attempt(s) allowed before a - <select name="staff_login_timeout"> - <?php - for ($i = 1; $i <= 10; $i++) { - echo sprintf('<option value="%d" %s>%d</option>',$i,(($config['staff_login_timeout']==$i)?'selected="selected"':''),$i); - } - ?> - </select> minute lock-out is enforced. - </td> - </tr> - <tr><td>Staff Session Timeout:</td> - <td> - <input type="text" name="staff_session_timeout" size=6 value="<?php echo $config['staff_session_timeout']; ?>"> - Maximum idle time in minutes before a staff member must log in again (enter 0 to disable). - </td> - </tr> - <tr><td>Bind Staff Session to IP:</td> - <td> - <input type="checkbox" name="staff_ip_binding" <?php echo $config['staff_ip_binding']?'checked="checked"':''; ?>> - <em>(binds staff session to originating IP address upon login)</em> - </td> - </tr> - <tr><td>Client Excessive Logins:</td> - <td> - <select name="client_max_logins"> - <?php - for ($i = 1; $i <= 10; $i++) { - echo sprintf('<option value="%d" %s>%d</option>',$i,(($config['client_max_logins']==$i)?'selected="selected"':''),$i); - } - - ?> - </select> failed login attempt(s) allowed before a - <select name="client_login_timeout"> - <?php - for ($i = 1; $i <= 10; $i++) { - echo sprintf('<option value="%d" %s>%d</option>',$i,(($config['client_login_timeout']==$i)?'selected="selected"':''),$i); - } - ?> - </select> minute lock-out is enforced. - </td> - </tr> - - <tr><td>Client Session Timeout:</td> - <td> - <input type="text" name="client_session_timeout" size=6 value="<?php echo $config['client_session_timeout']; ?>"> - Maximum idle time in minutes before a client must log in again (enter 0 to disable). - </td> - </tr> - <tr><td>Clickable URLs:</td> - <td> - <input type="checkbox" name="clickable_urls" <?php echo $config['clickable_urls']?'checked="checked"':''; ?>> - <em>(converts URLs in messages to clickable links)</em> - </td> - </tr> - <tr><td>Enable Auto Cron:</td> - <td> - <input type="checkbox" name="enable_auto_cron" <?php echo $config['enable_auto_cron']?'checked="checked"':''; ?>> - <em>(executes cron jobs based on staff activity - not recommended)</em> - </td> - </tr> - </tbody> -</table> -<p style="padding-left:250px;"> - <input class="button" type="submit" name="submit" value="Save Changes"> - <input class="button" type="reset" name="reset" value="Reset Changes"> -</p> -</form> + } ?> + </select> + </td> + </tr> + <tr><td>Password Reset Policy:</th> + <td> + <select name="passwd_reset_period"> + <option value="0"> — None —</option> + <?php + for ($i = 1; $i <= 12; $i++) { + echo sprintf('<option value="%d" %s>%s%s</option>', + $i,(($config['passwd_reset_period']==$i)?'selected="selected"':''),$i>1?"Every $i ":'',$i>1?' Months':'Monthly'); + } + ?> + </select> + <font class="error"> <?php echo $errors['passwd_reset_period']; ?></font> + </td> + </tr> + <tr><td>Staff Excessive Logins:</td> + <td> + <select name="staff_max_logins"> + <?php + for ($i = 1; $i <= 10; $i++) { + echo sprintf('<option value="%d" %s>%d</option>',$i,(($config['staff_max_logins']==$i)?'selected="selected"':''),$i); + } + ?> + </select> failed login attempt(s) allowed before a + <select name="staff_login_timeout"> + <?php + for ($i = 1; $i <= 10; $i++) { + echo sprintf('<option value="%d" %s>%d</option>',$i,(($config['staff_login_timeout']==$i)?'selected="selected"':''),$i); + } + ?> + </select> minute lock-out is enforced. + </td> + </tr> + <tr><td>Staff Session Timeout:</td> + <td> + <input type="text" name="staff_session_timeout" size=6 value="<?php echo $config['staff_session_timeout']; ?>"> + Maximum idle time in minutes before a staff member must log in again (enter 0 to disable). + </td> + </tr> + <tr><td>Bind Staff Session to IP:</td> + <td> + <input type="checkbox" name="staff_ip_binding" <?php echo $config['staff_ip_binding']?'checked="checked"':''; ?>> + <em>(binds staff session to originating IP address upon login)</em> + </td> + </tr> + <tr><td>Client Excessive Logins:</td> + <td> + <select name="client_max_logins"> + <?php + for ($i = 1; $i <= 10; $i++) { + echo sprintf('<option value="%d" %s>%d</option>',$i,(($config['client_max_logins']==$i)?'selected="selected"':''),$i); + } + + ?> + </select> failed login attempt(s) allowed before a + <select name="client_login_timeout"> + <?php + for ($i = 1; $i <= 10; $i++) { + echo sprintf('<option value="%d" %s>%d</option>',$i,(($config['client_login_timeout']==$i)?'selected="selected"':''),$i); + } + ?> + </select> minute lock-out is enforced. + </td> + </tr> + + <tr><td>Client Session Timeout:</td> + <td> + <input type="text" name="client_session_timeout" size=6 value="<?php echo $config['client_session_timeout']; ?>"> + Maximum idle time in minutes before a client must log in again (enter 0 to disable). + </td> + </tr> + <tr><td>Clickable URLs:</td> + <td> + <input type="checkbox" name="clickable_urls" <?php echo $config['clickable_urls']?'checked="checked"':''; ?>> + <em>(converts URLs in messages to clickable links)</em> + </td> + </tr> + <tr><td>Enable Auto Cron:</td> + <td> + <input type="checkbox" name="enable_auto_cron" <?php echo $config['enable_auto_cron']?'checked="checked"':''; ?>> + <em>(executes cron jobs based on staff activity - not recommended)</em> + </td> + </tr> + </tbody> +</table> +<p style="padding-left:250px;"> + <input class="button" type="submit" name="submit" value="Save Changes"> + <input class="button" type="reset" name="reset" value="Reset Changes"> +</p> +</form> + diff --git a/include/staff/slaplans.inc.php b/include/staff/slaplans.inc.php index 4ebb46b334e4e2a15b3f63f163824c03accbca29..5dea61f69b8ccaeaec3b84411185fbe4a26da886 100644 --- a/include/staff/slaplans.inc.php +++ b/include/staff/slaplans.inc.php @@ -25,10 +25,8 @@ $$x=' class="'.strtolower($order).'" '; $order_by="$order_column $order "; $total=db_count('SELECT count(*) FROM '.SLA_TABLE.' sla '); -$pagelimit=$thisstaff->getPageLimit(); -$pagelimit=$pagelimit?$pagelimit:PAGE_LIMIT; //true default...if all fails. $page=($_GET['p'] && is_numeric($_GET['p']))?$_GET['p']:1; -$pageNav=new Pagenate($total,$page,$pagelimit); +$pageNav=new Pagenate($total, $page, PAGE_LIMIT); $pageNav->setURL('slas.php',$qstr.'&sort='.urlencode($_REQUEST['sort']).'&order='.urlencode($_REQUEST['order'])); //Ok..lets roll...create the actual query $qstr.='&order='.($order=='DESC'?'ASC':'DESC'); diff --git a/include/staff/staffmembers.inc.php b/include/staff/staffmembers.inc.php index be8497b97c5030009cac3ff099dd8fadffa00ace..aa41b1bbf4a00a6143bb8bd0961d8a8ab4a801b0 100644 --- a/include/staff/staffmembers.inc.php +++ b/include/staff/staffmembers.inc.php @@ -46,10 +46,8 @@ $$x=' class="'.strtolower($order).'" '; $order_by="$order_column $order "; $total=db_count('SELECT count(DISTINCT staff.staff_id) '.$from.' '.$where); -$pagelimit=$thisstaff->getPageLimit(); -$pagelimit=$pagelimit?$pagelimit:PAGE_LIMIT; //true default...if all fails. $page=($_GET['p'] && is_numeric($_GET['p']))?$_GET['p']:1; -$pageNav=new Pagenate($total,$page,$pagelimit); +$pageNav=new Pagenate($total,$page,PAGE_LIMIT); $pageNav->setURL('staff.php',$qstr.'&sort='.urlencode($_REQUEST['sort']).'&order='.urlencode($_REQUEST['order'])); //Ok..lets roll...create the actual query $qstr.='&order='.($order=='DESC'?'ASC':'DESC'); diff --git a/include/staff/syslogs.inc.php b/include/staff/syslogs.inc.php index 1cec6aff3f253876a77c11d961ca87cba5b3c91f..482dd429c3738faea83e49df05a09c8dd391a7e2 100644 --- a/include/staff/syslogs.inc.php +++ b/include/staff/syslogs.inc.php @@ -71,9 +71,7 @@ $qfrom=' FROM '.SYSLOG_TABLE.' log '; $total=db_count("SELECT count(*) $qfrom $qwhere"); $page = ($_GET['p'] && is_numeric($_GET['p']))?$_GET['p']:1; //pagenate -$pagelimit=$thisstaff->getPageLimit(); -$pagelimit=$pagelimit?$pagelimit:PAGE_LIMIT; //true default...if all fails. -$pageNav=new Pagenate($total,$page,$pagelimit); +$pageNav=new Pagenate($total, $page, PAGE_LIMIT); $pageNav->setURL('syslogs.php',$qstr); $qstr.='&order='.($order=='DESC'?'ASC':'DESC'); $query="$qselect $qfrom $qwhere ORDER BY $order_by LIMIT ".$pageNav->getStart().",".$pageNav->getLimit(); diff --git a/include/staff/templates.inc.php b/include/staff/templates.inc.php index 8ce8ca8546ed5932fa5788aec5430400b68e6210..7f82f656f12cafe984de35ff205eb62bfef2b1a7 100644 --- a/include/staff/templates.inc.php +++ b/include/staff/templates.inc.php @@ -28,10 +28,8 @@ $$x=' class="'.strtolower($order).'" '; $order_by="$order_column $order "; $total=db_count('SELECT count(*) FROM '.EMAIL_TEMPLATE_TABLE.' tpl '); -$pagelimit=$thisstaff->getPageLimit(); -$pagelimit=$pagelimit?$pagelimit:PAGE_LIMIT; //true default...if all fails. $page=($_GET['p'] && is_numeric($_GET['p']))?$_GET['p']:1; -$pageNav=new Pagenate($total,$page,$pagelimit); +$pageNav=new Pagenate($total, $page, PAGE_LIMIT); $pageNav->setURL('templates.php',$qstr.'&sort='.urlencode($_REQUEST['sort']).'&order='.urlencode($_REQUEST['order'])); //Ok..lets roll...create the actual query $qstr.='&order='.($order=='DESC'?'ASC':'DESC'); diff --git a/include/staff/tickets.inc.php b/include/staff/tickets.inc.php index dad492a18f83dd64ed22f94de6a662de5e46ae45..ea3a59ced3f99ae51ac4e83855433f6d84395ea0 100644 --- a/include/staff/tickets.inc.php +++ b/include/staff/tickets.inc.php @@ -200,6 +200,7 @@ $qselect ='SELECT DISTINCT ticket.ticket_id,lock_id,ticketID,ticket.dept_id,tick $qfrom=' FROM '.TICKET_TABLE.' ticket '. ' LEFT JOIN '.DEPT_TABLE.' dept ON ticket.dept_id=dept.dept_id '; +$sjoin=''; if($search && $deep_search) { $sjoin=' LEFT JOIN '.TICKET_MESSAGE_TABLE.' message ON (ticket.ticket_id=message.ticket_id )' .' LEFT JOIN '.TICKET_RESPONSE_TABLE.' response ON (ticket.ticket_id=response.ticket_id )' @@ -210,7 +211,7 @@ $qgroup=' GROUP BY ticket.ticket_id'; //get ticket count based on the query so far.. $total=db_count("SELECT count(DISTINCT ticket.ticket_id) $qfrom $sjoin $qwhere"); //pagenate -$pagelimit=($_GET['limit'] && is_numeric($_GET['limit']))?$_GET['limit']:$thisstaff->getPageLimit(); +$pagelimit=($_GET['limit'] && is_numeric($_GET['limit']))?$_GET['limit']:PAGE_LIMIT; $page=($_GET['p'] && is_numeric($_GET['p']))?$_GET['p']:1; $pageNav=new Pagenate($total,$page,$pagelimit); $pageNav->setURL('tickets.php',$qstr.'&sort='.urlencode($_REQUEST['sort']).'&order='.urlencode($_REQUEST['order'])); diff --git a/main.inc.php b/main.inc.php index 6fd211ed3b4505f825dc8869e92e8186d92c1e68..53314c1ba469595a63f30a8e7584e3a10c250ae5 100644 --- a/main.inc.php +++ b/main.inc.php @@ -102,9 +102,6 @@ #CURRENT EXECUTING SCRIPT. define('THISPAGE',Misc::currentURL()); - #pagenation default - define('PAGE_LIMIT',20); - # This is to support old installations. with no secret salt. if(!defined('SECRET_SALT')) define('SECRET_SALT',md5(TABLE_PREFIX.ADMIN_EMAIL)); @@ -164,10 +161,7 @@ $ferror='Unable to connect to the database'; }elseif(!($cfg=Sys::getConfig())){ $ferror='Unable to load config info from DB. Get tech support.'; - }elseif(!ini_get('short_open_tag')) { - $ferror='Short open tag disabled! - osTicket requires it turned ON.'; } - if($ferror){ //Fatal error Sys::alertAdmin('osTicket Fatal Error',$ferror); //try alerting admin. die("<b>Fatal Error:</b> Contact system administrator."); //Generic error. @@ -175,6 +169,11 @@ } //Init $cfg->init(); + + //System defaults we might want to make global// + #pagenation default - user can overwrite it! + define('DEFAULT_PAGE_LIMIT',$cfg->getPageSize()?$cfg->getPageSize():25); + //Start session handler! $session=osTicketSession::start(SESSION_TTL); // start_session //Set default timezone...staff will overwrite it. diff --git a/scp/staff.inc.php b/scp/staff.inc.php index 3c0d328809cbc94b37e9a2fee074ce6dabb08a97..b3ee30a4ec3a555c2fd8c3c86ed6e72b2c6517ca 100644 --- a/scp/staff.inc.php +++ b/scp/staff.inc.php @@ -79,11 +79,14 @@ if(!$thisstaff->isadmin()){ //Keep the session activity alive $thisstaff->refreshSession(); + +/******* SET STAFF DEFAULTS **********/ //Set staff's timezone offset. $_SESSION['TZ_OFFSET']=$thisstaff->getTZoffset(); $_SESSION['daylight']=$thisstaff->observeDaylight(); define('AUTO_REFRESH_RATE',$thisstaff->getRefreshRate()*60); +define('PAGE_LIMIT',$thisstaff->getPageLimit()?$thisstaff->getPageLimit():DEFAULT_PAGE_LIMIT); //Clear some vars. we use in all pages. $errors=array(); diff --git a/setup/inc/class.setup.php b/setup/inc/class.setup.php index c4d986c655ad6041591f879f7e4c077ef24ec6b7..c6bf7b6751c9e80236d3cbfe143a37c6d52cf6c5 100644 --- a/setup/inc/class.setup.php +++ b/setup/inc/class.setup.php @@ -303,7 +303,7 @@ class Installer extends SetupWizard { if(!$this->errors) { //Create admin user. $sql='INSERT INTO '.PREFIX.'staff SET created=NOW() ' - .', isactive=1, isadmin=1, group_id=1, dept_id=1, timezone_id=8 ' + .', isactive=1, isadmin=1, group_id=1, dept_id=1, timezone_id=8, max_page_size=25 ' .', email='.db_input($_POST['admin_email']) .', firstname='.db_input($vars['fname']) .', lastname='.db_input($vars['lname'])