diff --git a/include/class.dept.php b/include/class.dept.php
index d9d4c63093620fe086cb4762c7b6b360177db595..cea549872b13bba5d4b1867eb4b9ad687b987244 100644
--- a/include/class.dept.php
+++ b/include/class.dept.php
@@ -246,6 +246,16 @@ class Dept {
         return ($this->getManagerId() && $this->getManagerId()==$staff);
     }
 
+    function isMember($staff) {
+
+        if (is_object($staff))
+            $staff = $staff->getId();
+
+        // Members are indexed by ID
+        $members = $this->getMembers();
+
+        return ($members && isset($members[$staff]));
+    }
 
     function isPublic() {
          return ($this->ht['ispublic']);
diff --git a/include/class.ticket.php b/include/class.ticket.php
index 148f4f7d91e1e1896ec65279da7a20790211f2a0..1740b10b0a5abdb4c6f3a5eb1af45ed4c99bb3cc 100644
--- a/include/class.ticket.php
+++ b/include/class.ticket.php
@@ -1559,11 +1559,21 @@ class Ticket {
         if($this->isClosed()) $this->reopen();
 
         $this->reload();
+        $dept = $this->getDept();
 
         // Set SLA of the new department
         if(!$this->getSLAId() || $this->getSLA()->isTransient())
             $this->selectSLAId();
 
+        // Make sure the new department allows assignment to the
+        // currently assigned agent (if any)
+        if ($this->isAssigned()
+                && ($staff=$this->getStaff())
+                && $dept->assignMembersOnly()
+                && !$dept->isMember($staff)) {
+            $this->setStaffId(0);
+        }
+
         /*** log the transfer comments as internal note - with alerts disabled - ***/
         $title=sprintf(_S('Ticket transferred from %1$s to %2$s'),
             $currentDept, $this->getDeptName());
@@ -1573,7 +1583,7 @@ class Ticket {
         $this->logEvent('transferred');
 
         //Send out alerts if enabled AND requested
-        if(!$alert || !$cfg->alertONTransfer() || !($dept=$this->getDept()))
+        if (!$alert || !$cfg->alertONTransfer())
             return true; //no alerts!!
 
          if (($email = $dept->getAlertEmail())
@@ -1616,6 +1626,21 @@ class Ticket {
          return true;
     }
 
+    function claim() {
+        global $thisstaff;
+
+        if (!$thisstaff || !$this->isOpen() || $this->isAssigned())
+            return false;
+
+        $dept = $this->getDept();
+        if ($dept->assignMembersOnly() && !$dept->isMember($thisstaff))
+            return false;
+
+        $comments = sprintf(_S('Ticket claimed by %s'), $thisstaff->getName());
+
+        return $this->assignToStaff($thisstaff->getId(), $comments, false);
+    }
+
     function assignToStaff($staff, $note, $alert=true) {
 
         if(!is_object($staff) && !($staff=Staff::lookup($staff)))
@@ -1933,6 +1958,7 @@ class Ticket {
                 && $vars['reply_status_id'] != $this->getStatusId())
             $this->setStatus($vars['reply_status_id']);
 
+        // Claim on response bypasses the department assignment restrictions
         if($thisstaff && $this->isOpen() && !$this->getStaffId()
                 && $cfg->autoClaimTickets())
             $this->setStaffId($thisstaff->getId()); //direct assignment;
diff --git a/include/staff/ticket-view.inc.php b/include/staff/ticket-view.inc.php
index e3e93f736b8bf815dcf4567902876550360d01a8..c2608d4b7dc0367f781c6c324d9bff5469a583e3 100644
--- a/include/staff/ticket-view.inc.php
+++ b/include/staff/ticket-view.inc.php
@@ -76,7 +76,10 @@ if($ticket->isOverdue())
                     echo __('Edit'); ?></a>
             <?php
             }
-            if ($ticket->isOpen() && !$ticket->isAssigned() && $thisstaff->canAssignTickets()) {?>
+            if ($ticket->isOpen()
+                    && !$ticket->isAssigned()
+                    && $thisstaff->canAssignTickets()
+                    && $ticket->getDept()->isMember($thisstaff)) {?>
                 <a id="ticket-claim" class="action-button pull-right confirm-action" href="#claim"><i class="icon-user"></i> <?php
                     echo __('Claim'); ?></a>
 
@@ -803,7 +806,9 @@ print $note_form->getField('attachments')->render();
                     <select id="assignId" name="assignId">
                         <option value="0" selected="selected">&mdash; <?php echo __('Select an Agent OR a Team');?> &mdash;</option>
                         <?php
-                        if($ticket->isOpen() && !$ticket->isAssigned())
+                        if ($ticket->isOpen()
+                                && !$ticket->isAssigned()
+                                && $ticket->getDept()->isMember($thisstaff))
                             echo sprintf('<option value="%d">'.__('Claim Ticket (comments optional)').'</option>', $thisstaff->getId());
 
                         $sid=$tid=0;
diff --git a/scp/tickets.php b/scp/tickets.php
index 33300cb44131eaa48136d958f1160478fa20bd28..ce6418048300bfbad9b3e9715ed74449cc739552 100644
--- a/scp/tickets.php
+++ b/scp/tickets.php
@@ -147,12 +147,21 @@ if($_POST && !$errors):
 
                  $id = preg_replace("/[^0-9]/", "",$_POST['assignId']);
                  $claim = (is_numeric($_POST['assignId']) && $_POST['assignId']==$thisstaff->getId());
+                 $dept = $ticket->getDept();
 
-                 if(!$_POST['assignId'] || !$id)
+                 if (!$_POST['assignId'] || !$id)
                      $errors['assignId'] = __('Select assignee');
-                 elseif($_POST['assignId'][0]!='s' && $_POST['assignId'][0]!='t' && !$claim)
-                     $errors['assignId']=__('Invalid assignee ID - get technical support');
-                 elseif($ticket->isAssigned()) {
+                 elseif ($_POST['assignId'][0]!='s' && $_POST['assignId'][0]!='t' && !$claim)
+                     $errors['assignId']= sprintf('%s - %s',
+                             __('Invalid assignee '),
+                             __('get technical support'));
+                 elseif ($_POST['assignId'][0]!='s'
+                         && $dept->assignMembersOnly()
+                         && !$dept->isMember($id)) {
+                     $errors['assignId'] = sprintf('%s. %s',
+                             __('Invalid assignee'),
+                             __('Must be department member'));
+                 } elseif($ticket->isAssigned()) {
                      if($_POST['assignId'][0]=='s' && $id==$ticket->getStaffId())
                          $errors['assignId']=__('Ticket already assigned to the agent.');
                      elseif($_POST['assignId'][0]=='t' && $id==$ticket->getTeamId())
@@ -246,7 +255,7 @@ if($_POST && !$errors):
                         $errors['err'] = __('Only open tickets can be assigned');
                     } elseif($ticket->isAssigned()) {
                         $errors['err'] = sprintf(__('Ticket is already assigned to %s'),$ticket->getAssigned());
-                    } elseif($ticket->assignToStaff($thisstaff->getId(), (sprintf(__('Ticket claimed by %s'),$thisstaff->getName())), false)) {
+                    } elseif ($ticket->claim()) {
                         $msg = __('Ticket is now assigned to you!');
                     } else {
                         $errors['err'] = __('Problems assigning the ticket. Try again');