From cd4b4faa6cb16e0d6c6fa28add868c4a291d6660 Mon Sep 17 00:00:00 2001
From: Jared Hancock <gravydish@gmail.com>
Date: Fri, 20 Apr 2012 22:49:39 -0500
Subject: [PATCH] Add lint test for (calls to) undefined functions

And correct several undefined function errors from several source files. So
while function names in PHP are considered case-insensitive, it still makes
sense to use consistent camel casing for both defining and calling methods.
The lint test searches the code base for method calls, and then searches the
code base again looking for a function definition matching the name of the
function invoked. It's not failsafe, because it doesn't detect the class
from which the method should belong, so it's likely to have false negatives.
Furthermore, it won't work well for PHP 5 where several classes are built
into PHP (and aren't searchable in the osTicket code base).

Remove the include/staff/api.inc.php as it no longer appears to be used (and
contains references to undefined methods).
---
 include/class.dept.php             |  16 ++++
 include/class.knowledgebase.php    |   2 +
 include/class.mailfetch.php        |   2 +-
 include/class.staff.php            |   4 +-
 include/class.sys.php              |   2 +-
 include/class.ticket.php           |  10 +-
 include/staff/api.inc.php          | 147 -----------------------------
 include/staff/apikey.inc.php       |   2 +-
 include/staff/apikeys.inc.php      |   2 +-
 include/staff/attachment.inc.php   |   2 +-
 include/staff/banlist.inc.php      |   2 +-
 include/staff/banrule.inc.php      |   2 +-
 include/staff/department.inc.php   |   2 +-
 include/staff/departments.inc.php  |   2 +-
 include/staff/email.inc.php        |   2 +-
 include/staff/emails.inc.php       |   2 +-
 include/staff/filter.inc.php       |   2 +-
 include/staff/filters.inc.php      |   2 +-
 include/staff/group.inc.php        |   2 +-
 include/staff/groups.inc.php       |   2 +-
 include/staff/header.inc.php       |   2 +-
 include/staff/helptopic.inc.php    |   2 +-
 include/staff/helptopics.inc.php   |   2 +-
 include/staff/preference.inc.php   |   2 +-
 include/staff/slaplan.inc.php      |   2 +-
 include/staff/slaplans.inc.php     |   2 +-
 include/staff/staff.inc.php        |   2 +-
 include/staff/staffmembers.inc.php |   2 +-
 include/staff/syslogs.inc.php      |   2 +-
 include/staff/team.inc.php         |   2 +-
 include/staff/teams.inc.php        |   2 +-
 include/staff/template.inc.php     |   2 +-
 include/staff/templates.inc.php    |   2 +-
 include/staff/tickets.inc.php      |   2 +-
 include/staff/topic.inc.php        |   2 +-
 login.php                          |   2 +-
 scp/admin.inc.php                  |   2 +-
 scp/banlist.php                    |   4 +-
 scp/staff.inc.php                  |   2 +-
 scp/tickets.php                    |  16 ++--
 setup/test/lint.php                |  49 +++++++++-
 41 files changed, 113 insertions(+), 201 deletions(-)
 delete mode 100644 include/staff/api.inc.php

diff --git a/include/class.dept.php b/include/class.dept.php
index 8bd575116..bf82b7652 100644
--- a/include/class.dept.php
+++ b/include/class.dept.php
@@ -47,6 +47,7 @@ class Dept {
         $this->id=$this->ht['dept_id'];
         $this->email=$this->sla=$this->manager=null;
         $this->getEmail(); //Auto load email struct.
+        $this->members=array();
 
         return true;
     }
@@ -88,6 +89,21 @@ class Dept {
         return $this->getNumStaff();
     }
 
+    function getAvailableMembers(){
+
+        if(!$this->members && $this->getNumStaff()){
+            $sql='SELECT m.staff_id FROM '.STAFF_TABLE.' m '
+                .'WHERE m.dept_id='.db_input($this->getId())
+                .' AND s.staff_id IS NOT NULL '
+                .'ORDER BY s.lastname, s.firstname';
+            if(($res=db_query($sql)) && db_num_rows($res)){
+                while(list($id)=db_fetch_row($res))
+                    if($staff= Staff::lookup($id) && $staff->isAvailable())
+                        $this->members[]= $staff;
+            }
+        }
+        return $this->members;
+    }
 
     function getSLAId(){
         return $this->ht['sla_id'];
diff --git a/include/class.knowledgebase.php b/include/class.knowledgebase.php
index d8a646891..6bb67898f 100644
--- a/include/class.knowledgebase.php
+++ b/include/class.knowledgebase.php
@@ -55,9 +55,11 @@ class Knowledgebase {
     function publish() { $this->published = true; }
     function unpublish() { $this->published = false; }
     function setPublished($val) { $this->published = !!$val; }
+    function setEnabled($val) { $this->enabled = !!$val; }
     function setTitle($title) { $this->title = $title; }
     function setKeywords($words) { $this->keywords = $words; }
     function setAnswer($text) { $this->answer = $text; }
+    function setDepartment($id) { $this->department = $id; }
 
     /* -------------> Validation and Clean methods <------------ */
     function validate(&$errors, $what=null) {
diff --git a/include/class.mailfetch.php b/include/class.mailfetch.php
index 5f9777593..4ee15ecca 100644
--- a/include/class.mailfetch.php
+++ b/include/class.mailfetch.php
@@ -242,7 +242,7 @@ class MailFetcher {
     function getBody($mid) {
         
         $body ='';
-        if(!($body = $this->getpart($mid,'TEXT/PLAIN',$this->charset))) {
+        if(!($body = $this->getPart($mid,'TEXT/PLAIN',$this->charset))) {
             if(($body = $this->getPart($mid,'TEXT/HTML',$this->charset))) {
                 //Convert tags of interest before we striptags
                 $body=str_replace("</DIV><DIV>", "\n", $body);
diff --git a/include/class.staff.php b/include/class.staff.php
index d3b2584e9..04887968f 100644
--- a/include/class.staff.php
+++ b/include/class.staff.php
@@ -220,7 +220,7 @@ class Staff {
         return $this->showAssignedOnly();
     }
   
-    function isadmin() {
+    function isAdmin() {
         return ($this->ht['isadmin']);
     }
 
@@ -261,7 +261,7 @@ class Staff {
     }
   
     function canManageTickets() {
-        return ($this->isadmin() 
+        return ($this->isAdmin() 
                  || $this->canDeleteTickets() 
                     || $this->canCloseTickets());
     }
diff --git a/include/class.sys.php b/include/class.sys.php
index ab10cd994..33b5c8304 100644
--- a/include/class.sys.php
+++ b/include/class.sys.php
@@ -96,7 +96,7 @@ class Sys {
     function purgeLogs(){
         global $cfg;
 
-        if($cfg && ($gp=$cfg->getLogGraceperiod()) && is_numeric($gp)) {
+        if($cfg && ($gp=$cfg->getLogGracePeriod()) && is_numeric($gp)) {
             $sql='DELETE  FROM '.SYSLOG_TABLE.' WHERE DATE_ADD(created, INTERVAL '.$gp.' MONTH)<=NOW()';
             db_query($sql);
         }
diff --git a/include/class.ticket.php b/include/class.ticket.php
index 8eca918fb..7d1436141 100644
--- a/include/class.ticket.php
+++ b/include/class.ticket.php
@@ -873,7 +873,7 @@ class Ticket{
         $msg=sprintf('Max open tickets (%d) reached  for %s ', $cfg->getMaxOpenTickets(), $this->getEmail());
         sys::log(LOG_WARNING, 'Max. Open Tickets Limit ('.$this->getEmail().')', $msg);
 
-        if(!$sendNotice || !$cfg->sendOverlimitNotice()) return true;
+        if(!$sendNotice || !$cfg->sendOverLimitNotice()) return true;
 
         //Send notice to user.
         $dept = $this->getDept();
@@ -953,7 +953,7 @@ class Ticket{
                 $email=$cfg->getDefaultEmail();
             
             if($email) {
-                $email->send($this->getEMail(),$subj,$body);
+                $email->send($this->getEmail(),$subj,$body);
             }
         }
 
@@ -996,12 +996,12 @@ class Ticket{
             $recipients=array();
             //Assigned staff or team... if any
             // Assigning a ticket to a team when already assigned to staff disables alerts to the team (!))
-            if($cfg->alertStaffONAssign() && $this->getStaffId())
+            if($cfg->alertStaffONAssignment() && $this->getStaffId())
                 $recipients[]=$this->getStaff();
             elseif($this->getTeamId() && ($team=$this->getTeam())) {
-                if($cfg->alertTeamMembersOnAssignment() && ($members=$team->getMembers()))
+                if($cfg->alertTeamMembersONAssignment() && ($members=$team->getMembers()))
                     $recipients+=$members;
-                elseif($cfg->alertTeamLeadOnAssignment() && ($lead=$team->getTeamLead()))
+                elseif($cfg->alertTeamLeadONAssignment() && ($lead=$team->getTeamLead()))
                     $recipients[]=$lead;
             }
             //Send the alerts.
diff --git a/include/staff/api.inc.php b/include/staff/api.inc.php
deleted file mode 100644
index 21eac4691..000000000
--- a/include/staff/api.inc.php
+++ /dev/null
@@ -1,147 +0,0 @@
-<?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">&nbsp;</th>
-	        <th>API Key</th>
-            <th width="10" nowrap>Active</th>
-            <th width="100" nowrap>&nbsp;&nbsp;IP Address</th>
-	        <th width="150" nowrap>&nbsp;&nbsp;
-                <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>&nbsp;<?php echo $row['apikey']; ?></td>
-                <td><?php echo $row['isactive']?'<b>Yes</b>':'No'; ?></td>
-                <td>&nbsp;<?php echo $row['ipaddr']; ?></td>
-                <td>&nbsp;<?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>&nbsp;&nbsp;<a href="admin.php?t=templates">Index list</a></td></tr>
-        <?php
-        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){ ?>
-            &nbsp;&nbsp;
-                <input class="button" type="submit" name="disable" value="Disable"
-                     onClick='return confirm("Are you sure you want to DISABLE selected keys?");'>
-            <?php } ?>
-            &nbsp;&nbsp;
-            <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.&nbsp;&nbsp;<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">*&nbsp;</font>&nbsp;&nbsp;
-     &nbsp;&nbsp; <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">*&nbsp;<?php echo $errors['phrase']; ?></font>&nbsp;&nbsp;
-     &nbsp;&nbsp; <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/apikey.inc.php b/include/staff/apikey.inc.php
index 5a82ee39b..7bcac1cb0 100644
--- a/include/staff/apikey.inc.php
+++ b/include/staff/apikey.inc.php
@@ -1,5 +1,5 @@
 <?php
-if(!defined('OSTADMININC') || !$thisstaff || !$thisstaff->isadmin()) die('Access Denied');
+if(!defined('OSTADMININC') || !$thisstaff || !$thisstaff->isAdmin()) die('Access Denied');
 $info=array();
 $qstr='';
 if($api && $_REQUEST['a']!='add'){
diff --git a/include/staff/apikeys.inc.php b/include/staff/apikeys.inc.php
index d7063c749..3deccb941 100644
--- a/include/staff/apikeys.inc.php
+++ b/include/staff/apikeys.inc.php
@@ -1,5 +1,5 @@
 <?php
-if(!defined('OSTADMININC') || !$thisstaff->isadmin()) die('Access Denied');
+if(!defined('OSTADMININC') || !$thisstaff->isAdmin()) die('Access Denied');
 
 $qstr='';
 $sql='SELECT * FROM '.API_KEY_TABLE.' WHERE 1';
diff --git a/include/staff/attachment.inc.php b/include/staff/attachment.inc.php
index 17819867e..5951b87c0 100644
--- a/include/staff/attachment.inc.php
+++ b/include/staff/attachment.inc.php
@@ -1,5 +1,5 @@
 <?php
-if(!defined('OSTADMININC') || !$thisstaff->isadmin()) die('Access Denied');
+if(!defined('OSTADMININC') || !$thisstaff->isAdmin()) die('Access Denied');
 //Get the config info.
 $config=($errors && $_POST)?Format::input($_POST):$cfg->getConfig();
 ?>
diff --git a/include/staff/banlist.inc.php b/include/staff/banlist.inc.php
index ecef00ba4..430b51f48 100644
--- a/include/staff/banlist.inc.php
+++ b/include/staff/banlist.inc.php
@@ -1,5 +1,5 @@
 <?php
-if(!defined('OSTADMININC') || !$thisstaff || !$thisstaff->isadmin() || !$filter) die('Access Denied');
+if(!defined('OSTADMININC') || !$thisstaff || !$thisstaff->isAdmin() || !$filter) die('Access Denied');
 
 $qstr='';
 $select='SELECT rule.* ';
diff --git a/include/staff/banrule.inc.php b/include/staff/banrule.inc.php
index bd28d19de..0560b4a4d 100644
--- a/include/staff/banrule.inc.php
+++ b/include/staff/banrule.inc.php
@@ -1,5 +1,5 @@
 <?php
-if(!defined('OSTADMININC') || !$thisstaff || !$thisstaff->isadmin()) die('Access Denied');
+if(!defined('OSTADMININC') || !$thisstaff || !$thisstaff->isAdmin()) die('Access Denied');
 
 $info=array();
 $qstr='';
diff --git a/include/staff/department.inc.php b/include/staff/department.inc.php
index fa32ec279..521cee9bf 100644
--- a/include/staff/department.inc.php
+++ b/include/staff/department.inc.php
@@ -1,5 +1,5 @@
 <?php
-if(!defined('OSTADMININC') || !$thisstaff || !$thisstaff->isadmin()) die('Access Denied');
+if(!defined('OSTADMININC') || !$thisstaff || !$thisstaff->isAdmin()) die('Access Denied');
 $info=array();
 $qstr='';
 if($dept && $_REQUEST['a']!='add'){
diff --git a/include/staff/departments.inc.php b/include/staff/departments.inc.php
index 805b7ec20..71b702a06 100644
--- a/include/staff/departments.inc.php
+++ b/include/staff/departments.inc.php
@@ -1,5 +1,5 @@
 <?php
-if(!defined('OSTADMININC') || !$thisstaff->isadmin()) die('Access Denied');
+if(!defined('OSTADMININC') || !$thisstaff->isAdmin()) die('Access Denied');
 
 $qstr='';
 $sql='SELECT dept.dept_id,dept_name,email.email_id,email.email,email.name as email_name,ispublic,count(staff.staff_id) as users '.
diff --git a/include/staff/email.inc.php b/include/staff/email.inc.php
index 4f2d695b0..2fd2b8857 100644
--- a/include/staff/email.inc.php
+++ b/include/staff/email.inc.php
@@ -1,5 +1,5 @@
 <?php
-if(!defined('OSTADMININC') || !$thisstaff || !$thisstaff->isadmin()) die('Access Denied');
+if(!defined('OSTADMININC') || !$thisstaff || !$thisstaff->isAdmin()) die('Access Denied');
 $info=array();
 $qstr='';
 if($email && $_REQUEST['a']!='add'){
diff --git a/include/staff/emails.inc.php b/include/staff/emails.inc.php
index 65d34d7b9..8d5f22117 100644
--- a/include/staff/emails.inc.php
+++ b/include/staff/emails.inc.php
@@ -1,5 +1,5 @@
 <?php
-if(!defined('OSTADMININC') || !$thisstaff->isadmin()) die('Access Denied');
+if(!defined('OSTADMININC') || !$thisstaff->isAdmin()) die('Access Denied');
 
 $qstr='';
 $sql='SELECT email.*,dept.dept_name as department,priority_desc as priority '.
diff --git a/include/staff/filter.inc.php b/include/staff/filter.inc.php
index 91f745016..6f8cce2c4 100644
--- a/include/staff/filter.inc.php
+++ b/include/staff/filter.inc.php
@@ -1,5 +1,5 @@
 <?php
-if(!defined('OSTADMININC') || !$thisstaff || !$thisstaff->isadmin()) die('Access Denied');
+if(!defined('OSTADMININC') || !$thisstaff || !$thisstaff->isAdmin()) die('Access Denied');
 
 $matches=array('name'=>"Sender's Name",'email'=>"Sender's Email",'subject'=>'Email Subject','body'=>'Email Body/Text','header'=>'Email Header');
 $match_types=array('equal'=>'Equal','not_equal'=>'Not Equal','contains'=>'Contains','dn_contain'=>'Does Not Contain');
diff --git a/include/staff/filters.inc.php b/include/staff/filters.inc.php
index fb8a48d26..b5534bdde 100644
--- a/include/staff/filters.inc.php
+++ b/include/staff/filters.inc.php
@@ -1,5 +1,5 @@
 <?php
-if(!defined('OSTADMININC') || !$thisstaff->isadmin()) die('Access Denied');
+if(!defined('OSTADMININC') || !$thisstaff->isAdmin()) die('Access Denied');
 
 $qstr='';
 $sql='SELECT filter.*,count(rule.id) as rules '.
diff --git a/include/staff/group.inc.php b/include/staff/group.inc.php
index 87921a63c..afb574f5f 100644
--- a/include/staff/group.inc.php
+++ b/include/staff/group.inc.php
@@ -1,5 +1,5 @@
 <?php
-if(!defined('OSTADMININC') || !$thisstaff || !$thisstaff->isadmin()) die('Access Denied');
+if(!defined('OSTADMININC') || !$thisstaff || !$thisstaff->isAdmin()) die('Access Denied');
 $info=array();
 $qstr='';
 if($group && $_REQUEST['a']!='add'){
diff --git a/include/staff/groups.inc.php b/include/staff/groups.inc.php
index 15b9b6610..ed5e3638a 100644
--- a/include/staff/groups.inc.php
+++ b/include/staff/groups.inc.php
@@ -1,5 +1,5 @@
 <?php
-if(!defined('OSTADMININC') || !$thisstaff || !$thisstaff->isadmin()) die('Access Denied');
+if(!defined('OSTADMININC') || !$thisstaff || !$thisstaff->isAdmin()) die('Access Denied');
 
 $qstr='';
 
diff --git a/include/staff/header.inc.php b/include/staff/header.inc.php
index 58d4f28dc..b0a7c4efe 100644
--- a/include/staff/header.inc.php
+++ b/include/staff/header.inc.php
@@ -26,7 +26,7 @@
 <div id="container">
     <div id="header">
         <a href="index.php" id="logo">osTicket - Customer Support System</a>
-        <p id="info">Welcome back, <strong><?php echo $thisstaff->getUsername(); ?></strong>
+        <p id="info">Welcome back, <strong><?php echo $thisstaff->getUserName(); ?></strong>
            <?php
             if($thisstaff->isAdmin() && !defined('ADMINPAGE')) { ?>
             | <a href="admin.php">Admin Panel</a>
diff --git a/include/staff/helptopic.inc.php b/include/staff/helptopic.inc.php
index ad9f808bc..c0fdcd340 100644
--- a/include/staff/helptopic.inc.php
+++ b/include/staff/helptopic.inc.php
@@ -1,5 +1,5 @@
 <?php
-if(!defined('OSTADMININC') || !$thisstaff || !$thisstaff->isadmin()) die('Access Denied');
+if(!defined('OSTADMININC') || !$thisstaff || !$thisstaff->isAdmin()) die('Access Denied');
 $info=array();
 $qstr='';
 if($topic && $_REQUEST['a']!='add'){
diff --git a/include/staff/helptopics.inc.php b/include/staff/helptopics.inc.php
index 27ffde9bd..b3d58c777 100644
--- a/include/staff/helptopics.inc.php
+++ b/include/staff/helptopics.inc.php
@@ -1,5 +1,5 @@
 <?php
-if(!defined('OSTADMININC') || !$thisstaff->isadmin()) die('Access Denied');
+if(!defined('OSTADMININC') || !$thisstaff->isAdmin()) die('Access Denied');
 
 $qstr='';
 $sql='SELECT topic.*,dept.dept_name as department,priority_desc as priority '.
diff --git a/include/staff/preference.inc.php b/include/staff/preference.inc.php
index d956d011d..054d592a7 100644
--- a/include/staff/preference.inc.php
+++ b/include/staff/preference.inc.php
@@ -1,5 +1,5 @@
 <?php
-if(!defined('OSTADMININC') || !$thisstaff->isadmin()) die('Access Denied');
+if(!defined('OSTADMININC') || !$thisstaff->isAdmin()) die('Access Denied');
 
 //Get the config info.
 $config=($errors && $_POST)?Format::input($_POST):Format::htmlchars($cfg->getConfig());
diff --git a/include/staff/slaplan.inc.php b/include/staff/slaplan.inc.php
index 91d896d63..70db620e8 100644
--- a/include/staff/slaplan.inc.php
+++ b/include/staff/slaplan.inc.php
@@ -1,5 +1,5 @@
 <?php
-if(!defined('OSTADMININC') || !$thisstaff || !$thisstaff->isadmin()) die('Access Denied');
+if(!defined('OSTADMININC') || !$thisstaff || !$thisstaff->isAdmin()) die('Access Denied');
 $info=array();
 $qstr='';
 if($sla && $_REQUEST['a']!='add'){
diff --git a/include/staff/slaplans.inc.php b/include/staff/slaplans.inc.php
index 5dea61f69..b8997b6a3 100644
--- a/include/staff/slaplans.inc.php
+++ b/include/staff/slaplans.inc.php
@@ -1,5 +1,5 @@
 <?php
-if(!defined('OSTADMININC') || !$thisstaff->isadmin()) die('Access Denied');
+if(!defined('OSTADMININC') || !$thisstaff->isAdmin()) die('Access Denied');
 
 $qstr='';
 $sql='SELECT * FROM '.SLA_TABLE.' sla WHERE 1';
diff --git a/include/staff/staff.inc.php b/include/staff/staff.inc.php
index 8883397f5..ddfa1e6df 100644
--- a/include/staff/staff.inc.php
+++ b/include/staff/staff.inc.php
@@ -1,5 +1,5 @@
 <?php
-if(!defined('OSTADMININC') || !$thisstaff || !$thisstaff->isadmin()) die('Access Denied');
+if(!defined('OSTADMININC') || !$thisstaff || !$thisstaff->isAdmin()) die('Access Denied');
 
 $info=array();
 $qstr='';
diff --git a/include/staff/staffmembers.inc.php b/include/staff/staffmembers.inc.php
index aa41b1bbf..b01e3387f 100644
--- a/include/staff/staffmembers.inc.php
+++ b/include/staff/staffmembers.inc.php
@@ -1,5 +1,5 @@
 <?php
-if(!defined('OSTADMININC') || !$thisstaff || !$thisstaff->isadmin()) die('Access Denied');
+if(!defined('OSTADMININC') || !$thisstaff || !$thisstaff->isAdmin()) die('Access Denied');
 $qstr='';
 $select='SELECT staff.*,CONCAT_WS(" ",firstname,lastname) as name, grp.group_name, dept.dept_name as dept,count(m.team_id) as teams ';
 $from='FROM '.STAFF_TABLE.' staff '.
diff --git a/include/staff/syslogs.inc.php b/include/staff/syslogs.inc.php
index 482dd429c..cb43e905e 100644
--- a/include/staff/syslogs.inc.php
+++ b/include/staff/syslogs.inc.php
@@ -1,5 +1,5 @@
 <?php
-if(!defined('OSTADMININC') || !$thisstaff || !$thisstaff->isadmin()) die('Access Denied');
+if(!defined('OSTADMININC') || !$thisstaff || !$thisstaff->isAdmin()) die('Access Denied');
 
 $qstr='';
 if($_REQUEST['type']) {
diff --git a/include/staff/team.inc.php b/include/staff/team.inc.php
index 7f8c409de..51b06ce2d 100644
--- a/include/staff/team.inc.php
+++ b/include/staff/team.inc.php
@@ -1,5 +1,5 @@
 <?php
-if(!defined('OSTADMININC') || !$thisstaff || !$thisstaff->isadmin()) die('Access Denied');
+if(!defined('OSTADMININC') || !$thisstaff || !$thisstaff->isAdmin()) die('Access Denied');
 $info=array();
 $qstr='';
 if($team && $_REQUEST['a']!='add'){
diff --git a/include/staff/teams.inc.php b/include/staff/teams.inc.php
index 1aa6dc4ed..ab3a2f58d 100644
--- a/include/staff/teams.inc.php
+++ b/include/staff/teams.inc.php
@@ -1,5 +1,5 @@
 <?php
-if(!defined('OSTADMININC') || !$thisstaff || !$thisstaff->isadmin()) die('Access Denied');
+if(!defined('OSTADMININC') || !$thisstaff || !$thisstaff->isAdmin()) die('Access Denied');
 
 $qstr='';
 $sql='SELECT team.*,count(m.staff_id) as members,CONCAT_WS(" ",lead.firstname,lead.lastname) as team_lead '.
diff --git a/include/staff/template.inc.php b/include/staff/template.inc.php
index 15881945e..ac5c09a74 100644
--- a/include/staff/template.inc.php
+++ b/include/staff/template.inc.php
@@ -1,5 +1,5 @@
 <?php
-if(!defined('OSTADMININC') || !$thisstaff || !$thisstaff->isadmin()) die('Access Denied');
+if(!defined('OSTADMININC') || !$thisstaff || !$thisstaff->isAdmin()) die('Access Denied');
 
 $info=array();
 $qstr='';
diff --git a/include/staff/templates.inc.php b/include/staff/templates.inc.php
index 7f82f656f..f60e3b010 100644
--- a/include/staff/templates.inc.php
+++ b/include/staff/templates.inc.php
@@ -1,5 +1,5 @@
 <?php
-if(!defined('OSTADMININC') || !$thisstaff->isadmin()) die('Access Denied');
+if(!defined('OSTADMININC') || !$thisstaff->isAdmin()) die('Access Denied');
 
 $qstr='';
 $sql='SELECT tpl.*,count(dept.tpl_id) as depts '.
diff --git a/include/staff/tickets.inc.php b/include/staff/tickets.inc.php
index 67d270c3f..26ed3772a 100644
--- a/include/staff/tickets.inc.php
+++ b/include/staff/tickets.inc.php
@@ -141,7 +141,7 @@ if($search):
         $qstr.='&dept='.urlencode($_REQUEST['dept']);
     }
     //Teams
-    if($_REQUEST['team'] && ($thisuser->isadmin() || in_array($_REQUEST['team'],$thisuser->getTeams()))) {
+    if($_REQUEST['team'] && ($thisuser->isAdmin() || in_array($_REQUEST['team'],$thisuser->getTeams()))) {
         $qwhere.=' AND ticket.team_id='.db_input($_REQUEST['team']);
         $qstr.='&team='.urlencode($_REQUEST['team']);
     }
diff --git a/include/staff/topic.inc.php b/include/staff/topic.inc.php
index 6504c5443..f0f895409 100644
--- a/include/staff/topic.inc.php
+++ b/include/staff/topic.inc.php
@@ -1,5 +1,5 @@
 <?php
-if(!defined('OSTADMININC') || !$thisstaff->isadmin()) die('Access Denied');
+if(!defined('OSTADMININC') || !$thisstaff->isAdmin()) die('Access Denied');
 
 $info=($_POST && $errors)?Format::input($_POST):array(); //Re-use the post info on error...savekeyboards.org
 if($topic && $_REQUEST['a']!='new'){
diff --git a/login.php b/login.php
index 044d74644..48dc9ec4a 100644
--- a/login.php
+++ b/login.php
@@ -45,7 +45,7 @@ if($_POST && (!empty($_POST['lemail']) && !empty($_POST['lticket']))):
         //At this point we know the ticket is valid.
         //TODO: 1) Check how old the ticket is...3 months max?? 2) Must be the latest 5 tickets?? 
         //Check the email given.
-        if($ticket->getId() && strcasecmp($ticket->getEMail(),$email)==0){
+        if($ticket->getId() && strcasecmp($ticket->getEmail(),$email)==0){
             //valid match...create session goodies for the client.
             $user = new ClientSession($email,$ticket->getId());
             $_SESSION['_client']=array(); //clear.
diff --git a/scp/admin.inc.php b/scp/admin.inc.php
index a580fa698..1bef7ea77 100644
--- a/scp/admin.inc.php
+++ b/scp/admin.inc.php
@@ -15,7 +15,7 @@
 **********************************************************************/
 require('staff.inc.php');
 //Make sure config is loaded and the staff is set and of admin type
-if(!$cfg or !$thisstaff or !$thisstaff->isadmin()){
+if(!$cfg or !$thisstaff or !$thisstaff->isAdmin()){
     header('Location: index.php');
     require('index.php'); // just in case!
     exit;
diff --git a/scp/banlist.php b/scp/banlist.php
index 1ef580a57..b56d05c6d 100644
--- a/scp/banlist.php
+++ b/scp/banlist.php
@@ -68,7 +68,7 @@ if($_POST && !$errors && $filter){
             }else{
                 $count=count($_POST['ids']);
                 if($_POST['enable']){
-                    $sql='UPDATE '.EMAIL_FILTER_RULE_TABLE.' SET isactive=1 WHERE filter_id='.db_input($filter->getID()).
+                    $sql='UPDATE '.EMAIL_FILTER_RULE_TABLE.' SET isactive=1 WHERE filter_id='.db_input($filter->getId()).
                          ' AND id IN ('.implode(',',$_POST['ids']).')';
                     if(db_query($sql) && ($num=db_affected_rows())){
                         if($num==$count)
@@ -79,7 +79,7 @@ if($_POST && !$errors && $filter){
                         $errors['err']='Unable to enable selected emails';
                     }
                 }elseif($_POST['disable']){
-                    $sql='UPDATE '.EMAIL_FILTER_RULE_TABLE.' SET isactive=0  WHERE filter_id='.db_input($filter->getID()).
+                    $sql='UPDATE '.EMAIL_FILTER_RULE_TABLE.' SET isactive=0  WHERE filter_id='.db_input($filter->getId()).
                          ' AND id IN ('.implode(',',$_POST['ids']).')';
                     if(db_query($sql) && ($num=db_affected_rows())) {
                         if($num==$count)
diff --git a/scp/staff.inc.php b/scp/staff.inc.php
index b3ee30a4e..b1161856d 100644
--- a/scp/staff.inc.php
+++ b/scp/staff.inc.php
@@ -63,7 +63,7 @@ if(!$thisstaff || !is_object($thisstaff) || !$thisstaff->getId() || !$thisstaff-
     exit;
 }
 //2) if not super admin..check system status and group status
-if(!$thisstaff->isadmin()){
+if(!$thisstaff->isAdmin()){
     //Staff are not allowed to login in offline mode!!
     if($cfg->isHelpDeskOffline()){
         staffLoginPage('System Offline');
diff --git a/scp/tickets.php b/scp/tickets.php
index c881381e0..567c3f697 100644
--- a/scp/tickets.php
+++ b/scp/tickets.php
@@ -55,7 +55,7 @@ if($_POST && !$errors):
             if(!$errors['err'] && EmailFilter::isBanned($ticket->getEmail()))
                 $errors['err']='Email is in banlist. Must be removed to reply.';
 
-            $wasOpen =($ticket->isopen());
+            $wasOpen =($ticket->isOpen());
             //If no error...do the do.
             if(!$errors && ($respId=$ticket->postReply($_POST,$_FILES['attachments'],$errors))) {
                 $msg='Reply posted successfully';
@@ -189,7 +189,7 @@ if($_POST && !$errors):
                     }
                     break;
                 case 'close':
-                    if(!$thisstaff->isadmin() && !$thisstaff->canCloseTickets()){
+                    if(!$thisstaff->isAdmin() && !$thisstaff->canCloseTickets()){
                         $errors['err']='Perm. Denied. You are not allowed to close tickets.';
                     }else{
                         if($ticket->close()){
@@ -204,7 +204,7 @@ if($_POST && !$errors):
                     break;
                 case 'reopen':
                     //if they can close...then assume they can reopen.
-                    if(!$thisstaff->isadmin() && !$thisstaff->canCloseTickets()){
+                    if(!$thisstaff->isAdmin() && !$thisstaff->canCloseTickets()){
                         $errors['err']='Perm. Denied. You are not allowed to reopen tickets.';
                     }else{
                         if($ticket->reopen()){
@@ -233,7 +233,7 @@ if($_POST && !$errors):
                     break;
                 case 'overdue':
                     //Mark the ticket as overdue
-                    if(!$thisstaff->isadmin() && !$thisstaff->isManager()){
+                    if(!$thisstaff->isAdmin() && !$thisstaff->isManager()){
                         $errors['err']='Perm. Denied. You are not allowed to flag tickets overdue';
                     }else{
                         if($ticket->markOverdue()){
@@ -252,7 +252,7 @@ if($_POST && !$errors):
                     }
                     break;
                 case 'banemail':
-                    if(!$thisstaff->isadmin() && !$thisstaff->canManageBanList()){
+                    if(!$thisstaff->isAdmin() && !$thisstaff->canBanEmails()){
                         $errors['err']='Perm. Denied. You are not allowed to ban emails';
                     }elseif(Banlist::add($ticket->getEmail(),$thisstaff->getName())){
                         $msg='Email ('.$ticket->getEmail().') added to banlist';
@@ -266,7 +266,7 @@ if($_POST && !$errors):
                     }
                     break;
                 case 'unbanemail':
-                    if(!$thisstaff->isadmin() && !$thisstaff->canManageBanList()){
+                    if(!$thisstaff->isAdmin() && !$thisstaff->canBanEmails()){
                         $errors['err']='Perm. Denied. You are not allowed to remove emails from banlist.';
                     }elseif(Banlist::remove($ticket->getEmail())){
                         $msg='Email removed from banlist';
@@ -275,7 +275,7 @@ if($_POST && !$errors):
                     }
                     break;
                 case 'delete': // Dude what are you trying to hide? bad customer support??
-                    if(!$thisstaff->isadmin() && !$thisstaff->canDeleteTickets()){
+                    if(!$thisstaff->isAdmin() && !$thisstaff->canDeleteTickets()){
                         $errors['err']='Perm. Denied. You are not allowed to DELETE tickets!!';
                     }else{
                         if($ticket->delete()){
@@ -339,7 +339,7 @@ if($_POST && !$errors):
                         $note='Ticket flagged as overdue by '.$thisstaff->getName();
                         foreach($_POST['tids'] as $k=>$v) {
                             $t = new Ticket($v);
-                            if($t && !$t->isoverdue())
+                            if($t && !$t->isOverdue())
                                 if($t->markOverdue()) { 
                                     $i++;
                                     $t->logActivity('Ticket Marked Overdue',$note,false,'System');
diff --git a/setup/test/lint.php b/setup/test/lint.php
index c25f7acec..4566c495a 100644
--- a/setup/test/lint.php
+++ b/setup/test/lint.php
@@ -9,7 +9,7 @@ function get_osticket_root_path() {
         if (file_exists($start . '/main.inc.php')) break;
         $start .= '/..';
     }
-    return $start;
+    return realpath($start);
 }
 
 $root = get_osticket_root_path();
@@ -17,8 +17,7 @@ $root = get_osticket_root_path();
 # Check PHP syntax across all php files
 function glob_recursive($pattern, $flags = 0) {
     $files = glob($pattern, $flags);
-    foreach (glob(dirname($pattern).'/*', GLOB_ONLYDIR|GLOB_NOSORT) 
-            as $dir) {
+    foreach (glob(dirname($pattern).'/*', GLOB_ONLYDIR|GLOB_NOSORT) as $dir) {
         $files = array_merge($files, 
             glob_recursive($dir.'/'.basename($pattern), $flags));
     }
@@ -26,7 +25,7 @@ function glob_recursive($pattern, $flags = 0) {
 }
 echo "PHP Syntax Errors: ";
 ob_start();
-$scripts=glob_recursive("$root/*/*.php");
+$scripts=glob_recursive("$root/*.php");
 $exit=0;
 $syntax_errors="";
 foreach ($scripts as $s) {
@@ -63,4 +62,46 @@ if (strlen($lint_errors)) {
 } else {
     echo "\n";
 }
+
+function find_function_calls($scripts) {
+    $calls=array();
+    foreach ($scripts as $s) {
+        $lines = explode("\n", file_get_contents($s));
+        $lineno=0;
+        foreach (explode("\n", file_get_contents($s)) as $line) {
+            $lineno++; $matches=array();
+            preg_match_all('/-[>]([a-zA-Z0-9]*)\(/', $line, $matches,
+                PREG_SET_ORDER);
+            foreach ($matches as $m) {
+                $calls[] = array($s, $lineno, $line, $m[1]);
+            }
+        }
+    }
+    return $calls;
+}
+
+$php_script_content='';
+foreach ($scripts as $s) {
+    $php_script_content .= file_get_contents($s);
+}
+echo "Access to undefined object methods: ";
+ob_start();
+foreach (find_function_calls($scripts) as $call) {
+    list($file, $no, $line, $func) = $call;
+    if (!preg_match('/^\s*(\/\*[^*]*\*\/)?'."\s*function\s+&?\s*$func\\(/m", 
+            $php_script_content)) {
+        print "$func: Definitely undefined, from $file:$no\n";
+    }
+}
+$undef_func_errors = ob_get_clean();
+
+if (strlen($undef_func_errors)) {
+    $undef_func_errors=str_replace("$root/", '', $undef_func_errors);
+    echo "FAIL\n";
+    echo "-------------------------------------------------------\n";
+    echo "$undef_func_errors";
+    exit();
+} else {
+    echo "\n";
+}
 ?>
-- 
GitLab