/**
  * Update an existing employee
  * PUT /api/employee/:netID
  *
  * Fields to be updated should be provided in the body of the request
  *
  * Returns a model of the updated employee
  */
 public function put($params)
 {
     $this->requireAuthentication();
     if (count($params['url']) < 3) {
         $this->error("No netID provided", 400);
     }
     $netID = $params['url'][2];
     $employeeAcc = new \TMT\accessor\Employee();
     $model = $employeeAcc->get($netID);
     $allow_self_update = array("phone", "email");
     $require_permission = false;
     foreach ($params['request'] as $key => $value) {
         if (property_exists($model, $key)) {
             switch ($key) {
                 case "area":
                     if (!$this->isSuperuser()) {
                         $this->error($message, 403);
                         exit;
                     }
                     $model->area = $value;
                     break;
                 case "netID":
                     // Never update a netID
                     continue;
                     break;
                 case "position":
                     // Positions should only be updated from the default area
                     if ($model->area == $this->user['area']) {
                         $model->{$key} = $value;
                     }
                     break;
                 default:
                     if (!in_array($key, $allow_self_update)) {
                         $require_permission = true;
                     }
                     $model->{$key} = $value;
             }
         }
     }
     if ($require_permission) {
         $this->forcePermission("update", "1450ff35-82a7-45ed-adcf-ffa254ebafa2");
     }
     $employeeAcc->save($model);
     $this->respond($model);
 }
 /**
  * @covers ::getByArea
  */
 public function testGetByArea()
 {
     $accessor = new \TMT\accessor\Employee();
     $employee = $accessor->get('inserted');
     $employee->area = 2;
     $accessor->save($employee);
     $employees = $accessor->getByArea(2);
     $this->assertEquals(3, count($employees));
     $employees = $accessor->getByArea(4);
     $this->assertEquals(0, count($employees));
     $employee = $accessor->get('inserted');
     $employee->active = 0;
     $accessor->save($employee);
     $employees = $accessor->getByArea(2, true, 0);
     $this->assertEquals(2, count($employees));
     $employee = $accessor->get('inserted');
     $employee->active = -1;
     $accessor->save($employee);
     $employees = $accessor->getByArea(2, true, -1);
     $this->assertEquals(1, count($employees));
     $this->assertEquals('inserted', $employees[0]->netID);
     $employees = $accessor->getByArea(array(1, 2));
     $this->assertEquals(4, count($employees));
     $employees = $accessor->getByArea(array(1, 2), true, 1);
     $this->assertEquals(2, count($employees));
 }