diff --git a/include/class.dept.php b/include/class.dept.php
index 8bd575116a421dba88b82dd236243829aeadfc32..bf82b76526b7ce77abbdcdbaa213c939207ca4ad 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 d8a64689168de48014011bf46c45e029056efdea..6bb67898f7a94f7b6f95c547b646241aa45c2699 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 5f97775930f25da87f80261cc20b66cdad947b8f..4ee15ecca38404efcd943fcd984d6b3d335854b6 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 0630a0fe514d391c90af98bd47fe06c7c3871422..26ffcc703a144981c1142987d9eb50f6ff233b06 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 ab10cd99442fa640bd36a6a329b6cc27e18f1b7f..33b5c830407f1b56fb1ef8eff47657e1296bb97a 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 b9fb218d5d343693307b34020928fbfc5164494a..275ef78c26b88c7dc306e18753c7196b2b8cf51d 100644
--- a/include/class.ticket.php
+++ b/include/class.ticket.php
@@ -892,7 +892,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();
@@ -972,7 +972,7 @@ class Ticket{
                 $email=$cfg->getDefaultEmail();
             
             if($email) {
-                $email->send($this->getEMail(),$subj,$body);
+                $email->send($this->getEmail(),$subj,$body);
             }
         }
 
@@ -1015,12 +1015,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 21eac469162af3d2cc9652d8e8255f230ee18460..0000000000000000000000000000000000000000
--- 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 5a82ee39bf264a821de957a779c0a73087f78bd9..7bcac1cb03e257feb855fbf0436769b8b3a3650e 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 d7063c749ce92c04cddc36f20902b88181ab51d4..3deccb941222f8d771eb120ea90ab7e27557203c 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 17819867e69a458517e7c312075c07ffe3eeb06c..5951b87c0b0788767b34c98d1a7290a7c1debcdd 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 ecef00ba4325e18339b4f733d82a34b38466b950..430b51f4835bbf7038941109621774b409485b2e 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 bd28d19dea8368b395122beeb861045205d7ddff..0560b4a4d6268961220dad69de5d7b73617afec2 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 fa32ec2795d1ab1635fa126ab639a5d1259f3258..521cee9bf9e9eb7446420c26c4e0ab03a1c3ad69 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 805b7ec20706c7cbbfa1bb2dd331068aa3bc8154..71b702a0676cff5f6824c933fc458882fff9e991 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 4f2d695b09304c4dcd5fc850e32ede734c514bbf..2fd2b8857494c64c061524a5bd294e4433299ee4 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 65d34d7b9bfb0b10acd983bfe41e5671932d3060..8d5f221177051e484fcaff4457c5f9f60bffbc99 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 91f74501661cda00d97aada035b28559a9961d41..6f8cce2c41a1e6acd8f4810b3cdc7e643a9a4471 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 fb8a48d268a7705d5eb3a49b4076a6dcdb3b0b17..b5534bdde77a12ffe88a8f2362046c5d2e64fce2 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 87921a63cb18aad7a2c73ab73ab5a2c7fb3d8acd..afb574f5f3cea7ff161dc34e90c05fa77f955b51 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 15b9b6610916c203cdf25e902228dd8d5281ba5a..ed5e3638a8d0528908584ddfad5320d885a38e4d 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 58d4f28dcdf77cbe3fa184e8a4979982b01de0fe..b0a7c4efef46bfa5ce923ac251beb101c3125293 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 ad9f808bcfd6afedfabec510dda920ca2abaae0a..c0fdcd34010266a802bbffdd3f31c741c36f0b9a 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 27ffde9bdacac59c2687b30b5046dde4255b1537..b3d58c777517753e02b41d1aaa703ed6e5500c01 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 d956d011dff2c15ad87c7e023f69303a87034353..054d592a7555f8d16f436f9cc5c9c66a91b6f27b 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 91d896d639d688813389ed0582ecd800beb2a842..70db620e84d83dc66a53cf6c08e1d97ea2b31f24 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 5dea61f69b8ccaeaec3b84411185fbe4a26da886..b8997b6a34be75b697624384e0e39006c5c16feb 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 8883397f51fe86c6b46c5207a099ad33ec50ec31..ddfa1e6dfb716240f1d1fce6b12bcd43112e974e 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 aa41b1bbf4a00a6143bb8bd0961d8a8ab4a801b0..b01e3387ff28da3e2f8e419b4e728293fe851254 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 482dd429c3738faea83e49df05a09c8dd391a7e2..cb43e905e4ef0914b09067dd753f7bf67a39498b 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 7f8c409decba5de347d3cac28b848ce3ad78fa44..51b06ce2d1fa51344dbef35258a72cc68ddbf60b 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 1aa6dc4ed0554692b67449970caf0d799673f709..ab3a2f58d4a88e94ea4d08653b853352d37be680 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 15881945e369c2fa541163008b3c9f4c9ce2352f..ac5c09a744879021e7286f116dc91e18a26df95f 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 7f82f656f12cafe984de35ff205eb62bfef2b1a7..f60e3b010ec7efe053fd1a73df1cefe9366b9daa 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/topic.inc.php b/include/staff/topic.inc.php
index 6504c5443200a4a3bd82624fec18c27c0ff3ea24..f0f895409d99ebd2c39c4013572b1ee455887090 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 044d74644785f32a0f79bae76e6c4309fd473b2a..48dc9ec4aea9a5ab7c427cacc30b17c8005944b5 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 8b3da09e6e6fbd55eeb81f9a93f9216fb6fe183e..5f6f5e7633422251ca7bbf8960f69461a8afbc35 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 1ef580a5746e7666c7aebf4f72e364acb30456ea..b56d05c6d07b28b2536127abe9a5b3be6330cb69 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 bddf874cf976f4a170b3782330b7fdc3b8a87732..7a4dfb9e3a596fcc480894c60ecf2bede2304181 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()) {
     //Check for disabled staff or group!
     if(!$thisstaff->isactive() || !$thisstaff->isGroupActive()) {
         staffLoginPage('Access Denied. Contact Admin');
diff --git a/scp/tickets.php b/scp/tickets.php
index c881381e0d9ff9613b1e26e1df6c410157df664b..567c3f69755525aca1146ce8433a44e2485c6fc3 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/inc/class.upgrader.php b/setup/inc/class.upgrader.php
index c82ae721f7d4c28cb451ada9a5ba6f753e983149..9e208426fcd9288c9108d847c598ca5112dc6d35 100644
--- a/setup/inc/class.upgrader.php
+++ b/setup/inc/class.upgrader.php
@@ -201,7 +201,7 @@ class Upgrader extends SetupWizard {
         
             
             //clear previous patch info - 
-            unset($_SESSION['ost_upgrader'][$this->getSHash()]);
+            unset($_SESSION['ost_upgrader'][$this->getShash()]);
 
             //Load up post-upgrade tasks.... if any.
             $phash = substr(basename($patch), 0, 17);
@@ -241,7 +241,7 @@ class Upgrader extends SetupWizard {
     /************* TASKS **********************/
     function cleanup($tId=0) {
 
-        $file=$this->getSQLDir().$this->getSHash().'-cleanup.sql';
+        $file=$this->getSQLDir().$this->getShash().'-cleanup.sql';
         if(!file_exists($file)) //No cleanup script.
             return 0;
 
diff --git a/setup/p.php b/setup/p.php
index ebc4128b3455ac4063425bb9802abc856ff2c0e9..babeebb866f198e7fc78516a34133164d72a9b47 100644
--- a/setup/p.php
+++ b/setup/p.php
@@ -19,7 +19,7 @@ function staffLoginPage($msg) {
 }
 
 require '../scp/staff.inc.php';
-if(!$thisstaff or !$thisstaff->isadmin()) {
+if(!$thisstaff or !$thisstaff->isAdmin()) {
     staffLoginPage('Admin Access Required!');
     exit;
 }
@@ -34,8 +34,8 @@ require_once INC_DIR.'class.upgrader.php';
 $upgrader = new Upgrader($cfg->getSchemaSignature(), TABLE_PREFIX, SQL_DIR);
 
 //Just report the next action on the first call.
-if(!$_SESSION['ost_upgrader'][$upgrader->getSHash()]['progress']) {
-    $_SESSION['ost_upgrader'][$upgrader->getSHash()]['progress'] = $upgrader->getNextAction();
+if(!$_SESSION['ost_upgrader'][$upgrader->getShash()]['progress']) {
+    $_SESSION['ost_upgrader'][$upgrader->getShash()]['progress'] = $upgrader->getNextAction();
     Http::response(200, $upgrader->getNextAction());
     exit;
 }
diff --git a/setup/test/lint.php b/setup/test/lint.php
index c25f7acec092a0a17e0dcf295173cc742b480329..4566c495a247874f538fc043cd777185e17d509c 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";
+}
 ?>
diff --git a/setup/upgrade.php b/setup/upgrade.php
index 324c467efd72d887b7592af33f6ba201c6f26e22..0406383707cfe245fd11aae9323ee1422d6d679e 100644
--- a/setup/upgrade.php
+++ b/setup/upgrade.php
@@ -22,7 +22,7 @@ function staffLoginPage($msg) {
 }
 
 require '../scp/staff.inc.php';
-if(!$thisstaff or !$thisstaff->isadmin()) {
+if(!$thisstaff or !$thisstaff->isAdmin()) {
     staffLoginPage('Admin Access Required!');
     exit;
 }