function getUserIdentifiers($station_id)
 {
     Debug::Text('Getting User Identifiers for Station ID: ' . $station_id, __FILE__, __LINE__, __METHOD__, 10);
     if ($station_id == '') {
         return FALSE;
     }
     //Gets all users allowed to punch in/out from this station
     $slf = new StationListFactory();
     $slf->getByStationID($station_id);
     if ($slf->getRecordCount() > 0) {
         $s_obj = $slf->getCurrent();
         $company_id = $s_obj->getCompany();
         if ($company_id != FALSE) {
             $uilf = new UserIdentificationListFactory();
             if (version_compare($this->getClientVersion(), '3.0.0', '>=')) {
                 $uilf->getByCompanyIdAndTypeId($company_id, array(10, 25, 30, 40));
                 //iButtons, LIBFP Fingerprints, Barcodes, Proximity Cards
             } else {
                 $uilf->getByCompanyIdAndTypeId($company_id, array(10, 20, 30, 40));
                 //iButtons, Griaule Fingerprints Barcodes, Proximity Cards
             }
             if ($uilf->getRecordCount() > 0) {
                 $x = 0;
                 foreach ($uilf as $ui_obj) {
                     $identification_list["'{$x}'"] = array('user_id' => (int) $ui_obj->getUser(), 'type_id' => (int) $ui_obj->getType(), 'number' => (int) $ui_obj->getNumber(), 'value' => $ui_obj->getValue());
                     $x++;
                 }
                 if (isset($identification_list)) {
                     return $identification_list;
                 }
             }
         }
     }
     return FALSE;
 }
コード例 #2
0
 function checkIButton($id)
 {
     $uilf = new UserIdentificationListFactory();
     $uilf->getByTypeIdAndValue(10, $id);
     if ($uilf->getRecordCount() > 0) {
         foreach ($uilf as $ui_obj) {
             if (is_object($ui_obj->getUserObject()) and $ui_obj->getUserObject()->getStatus() == 10) {
                 $this->setObject($ui_obj->getUser());
                 return TRUE;
             }
         }
     }
     /*
     		//Use UserFactory to set name.
     		$ulf = new UserListFactory();
     
     		$ulf->getByIButtonIdAndStatus($id, 10 );
     
     		foreach ($ulf as $user) {
     			if ( $user->checkIButton($id) ) {
     				$this->setObject( $user->getID() );
     
     				return TRUE;
     			} else {
     				return FALSE;
     			}
     		}
     */
     return FALSE;
 }
コード例 #3
0
 function enroll($user_id, $id, $type = 'iButton', $number = 0, $extra_value = NULL)
 {
     Debug::text('Client Version: ' . $this->getClientVersion() . ' User ID : ' . $user_id . ' ID: ' . substr($id, 0, 100) . ' Type: ' . $type . ' Number: ' . $number, __FILE__, __LINE__, __METHOD__, 10);
     $user_id = trim($user_id);
     $id = trim($id);
     $type = strtolower($type);
     $number = trim($number);
     $ulf = new UserListFactory();
     if (version_compare($this->getClientVersion(), '2.7.0', '<')) {
         Debug::text('aVersion: ' . $this->getClientVersion(), __FILE__, __LINE__, __METHOD__, 10);
         //Fingerprints can send $id=NULL to clear an enrollment.
         if (strpos($type, 'finger_print') === FALSE and $id == '') {
             Debug::text('ID is not valid: ' . $id, __FILE__, __LINE__, __METHOD__, 10);
             return FALSE;
         }
         //Check to make sure the logged in user has edit_advance permissions
         if ($this->getPermissionObject()->Check('user', 'enroll') or $this->getPermissionObject()->Check('user', 'enroll_child')) {
             Debug::text('User : '******' has Enroll permission', __FILE__, __LINE__, __METHOD__, 10);
             switch ($type) {
                 case 'finger_print_1':
                 case 'finger_print_2':
                 case 'finger_print_3':
                 case 'finger_print_4':
                     $enroll_user_obj = $ulf->getByIdAndCompanyId($user_id, $this->getUserObject()->getCompany());
                     if ($enroll_user_obj->getRecordCount() == 1) {
                         Debug::text('Enroller User ID : ' . $user_id . ' FOUND', __FILE__, __LINE__, __METHOD__, 10);
                         $enroll_user_obj = $enroll_user_obj->getCurrent();
                         switch ($type) {
                             case 'finger_print_1':
                                 $number = 10;
                                 break;
                             case 'finger_print_2':
                                 $number = 20;
                                 break;
                             case 'finger_print_3':
                                 $number = 30;
                                 break;
                             case 'finger_print_4':
                                 $number = 40;
                                 break;
                         }
                         $uilf = new UserIdentificationListFactory();
                         $uilf->getByUserIdAndTypeIdAndNumber($enroll_user_obj->getID(), 20, $number);
                         if ($uilf->getRecordCount() > 0) {
                             $uif = $uilf->getCurrent();
                         } else {
                             $uif = new UserIdentificationFactory();
                         }
                         if ($id == '' and $uilf->getRecordCount() > 0) {
                             Debug::text('Deleting Fingerprint...', __FILE__, __LINE__, __METHOD__, 10);
                             $uif->setDeleted(TRUE);
                             if ($uif->isValid()) {
                                 if ($uif->save()) {
                                     return TRUE;
                                 }
                             }
                         } elseif ($id != '') {
                             $uif->setUser($enroll_user_obj->getId());
                             $uif->setType(20);
                             //Griaule
                             $uif->setNumber($number);
                             $uif->setValue($id);
                             if ($uif->isValid()) {
                                 if ($uif->save()) {
                                     return TRUE;
                                 }
                             }
                         }
                         Debug::text('Enroll User Object not valid : ' . $user_id, __FILE__, __LINE__, __METHOD__, 10);
                     } else {
                         Debug::text('User ID : ' . $user_id . ' NOT FOUND', __FILE__, __LINE__, __METHOD__, 10);
                     }
                     break;
                 case 'ibutton':
                     //Remove ibutton from current user.
                     $uilf = new UserIdentificationListFactory();
                     $uilf->getByCompanyIdAndTypeIdAndValue($this->getUserObject()->getCompany(), 10, $id);
                     if ($uilf->getRecordCount() > 0) {
                         foreach ($uilf as $ui_obj) {
                             Debug::text('Removing iButton ID from User: '******'Didnt find current user with iButton assigned...', __FILE__, __LINE__, __METHOD__, 10);
                     }
                     $enroll_user_obj = $ulf->getByIdAndCompanyId($user_id, $this->getUserObject()->getCompany());
                     if ($enroll_user_obj->getRecordCount() == 1) {
                         Debug::text('Enroller User ID : ' . $user_id . ' FOUND', __FILE__, __LINE__, __METHOD__, 10);
                         $enroll_user_obj = $enroll_user_obj->getCurrent();
                         $uilf = new UserIdentificationListFactory();
                         $uilf->getByUserIdAndTypeIdAndNumber($enroll_user_obj->getID(), 10, 0);
                         if ($uilf->getRecordCount() > 0) {
                             $uif = $uilf->getCurrent();
                         } else {
                             $uif = new UserIdentificationFactory();
                         }
                         $uif->setUser($enroll_user_obj->getId());
                         $uif->setType(10);
                         //iButton
                         $uif->setNumber(0);
                         $uif->setValue($id);
                         if ($uif->isValid()) {
                             if ($uif->save()) {
                                 return TRUE;
                             }
                         }
                         Debug::text('Enroll User Object not valid : ' . $user_id, __FILE__, __LINE__, __METHOD__, 10);
                     } else {
                         Debug::text('User ID : ' . $user_id . ' NOT FOUND', __FILE__, __LINE__, __METHOD__, 10);
                     }
                     /*
                     $ulf->getByCompanyIDAndIButtonId( $this->getUserObject()->getCompany(), $id );
                     if ( $ulf->getRecordCount() > 0 ) {
                     	$old_user_obj = $ulf->getCurrent();
                     
                     	Debug::text('Removing iButton ID from User: '******'Didnt find current user with iButton assigned...', __FILE__, __LINE__, __METHOD__, 10);
                     }
                     
                     //$enroll_user_obj = $ulf->getByUserNameAndCompanyId( $user_name, $this->getUserObject()->getCompany() );
                     $enroll_user_obj = $ulf->getByIdAndCompanyId( $user_id, $this->getUserObject()->getCompany() );
                     
                     if ( $enroll_user_obj->getRecordCount() == 1 ) {
                     	Debug::text('Enroller User ID : '. $user_id .' FOUND', __FILE__, __LINE__, __METHOD__, 10);
                     
                     	$enroll_user_obj = $enroll_user_obj->getCurrent();
                     
                     	//Update ibutton id.
                     	$enroll_user_obj->setIButtonID( $id );
                     	if ( $enroll_user_obj->isValid() ) {
                     		if ( $enroll_user_obj->save() ) {
                     			return TRUE;
                     		}
                     	}
                     
                     	Debug::text('Enroll User Object not valid : '. $user_id, __FILE__, __LINE__, __METHOD__, 10);
                     } else {
                     	Debug::text('User ID : '. $user_id .' NOT FOUND', __FILE__, __LINE__, __METHOD__, 10);
                     }
                     */
                     break;
             }
         } else {
             Debug::text('User : '******' DOES NOT HAVE edit advance permission', __FILE__, __LINE__, __METHOD__, 10);
         }
     } else {
         //This code path needs to handle re-enrolling iButtons, proximity cards, etc... for a different employees.
         Debug::text('bVersion: ' . $this->getClientVersion(), __FILE__, __LINE__, __METHOD__, 10);
         $ulf->getByIdAndCompanyId($user_id, $this->getUserObject()->getCompany());
         if ($ulf->getRecordCount() == 1) {
             Debug::text('Enroller User ID : ' . $user_id . ' FOUND', __FILE__, __LINE__, __METHOD__, 10);
             //Checking to see if value is enrolled for a different user first.
             $uilf = new UserIdentificationListFactory();
             $uilf->getByCompanyIdAndTypeIdAndValue($this->getUserObject()->getCompany(), $type, $id);
             if ($uilf->getRecordCount() > 0) {
                 foreach ($uilf as $ui_obj) {
                     Debug::text('Removing enolled value from User: '******'Didnt find current user with enrolled value assigned...', __FILE__, __LINE__, __METHOD__, 10);
             }
             $enroll_user_obj = $ulf->getCurrent();
             $uilf = new UserIdentificationListFactory();
             $uilf->getByUserIdAndTypeIdAndNumber($enroll_user_obj->getID(), $type, $number);
             if ($uilf->getRecordCount() > 0) {
                 $uif = $uilf->getCurrent();
             } else {
                 $uif = new UserIdentificationFactory();
             }
             if ($id == '' and $uilf->getRecordCount() > 0) {
                 Debug::text('Deleting User Identification...', __FILE__, __LINE__, __METHOD__, 10);
                 $uif->setDeleted(TRUE);
                 if ($uif->isValid()) {
                     if ($uif->save()) {
                         return TRUE;
                     }
                 }
             } elseif ($id != '') {
                 Debug::text('Adding/Modifying User Identification...', __FILE__, __LINE__, __METHOD__, 10);
                 $uif->setUser($enroll_user_obj->getId());
                 $uif->setType($type);
                 $uif->setNumber($number);
                 $uif->setValue($id);
                 //Primarily used to store raw fingerprint images during enroll.
                 if ($extra_value != '') {
                     $uif->setExtraValue($extra_value);
                 }
                 if ($uif->isValid()) {
                     if ($uif->save()) {
                         return TRUE;
                     }
                 }
             }
             Debug::text('Enroll User Object not valid : ' . $user_id, __FILE__, __LINE__, __METHOD__, 10);
         } else {
             Debug::text('User ID : ' . $user_id . ' NOT FOUND', __FILE__, __LINE__, __METHOD__, 10);
         }
     }
     return FALSE;
 }
コード例 #4
0
 function checkRFID($id)
 {
     $id = trim($id);
     $uilf = new UserIdentificationListFactory();
     $uilf->getByUserIdAndTypeIdAndValue($this->getId(), 40, $id);
     if ($uilf->getRecordCount() == 1) {
         return TRUE;
     }
     /*
     		//Use employee ID for now.
     		if ( $id == $this->getRFID() ) {
     			return TRUE;
     		}
     */
     return FALSE;
 }