'ID', 'user_id' => 'User', 'device_id' => 'DeviceID', 'ip_address' => 'IPAddress', 'location' => 'Location', 'deleted' => 'Deleted', ]; return $variable_function_map; } /** * @return bool|mixed */ function getUser() { return $this->getGenericDataValue( 'user_id' ); } /** * @param string $value UUID * @return bool */ function setUser( $value ) { $value = TTUUID::castUUID( $value ); return $this->setGenericDataValue( 'user_id', $value ); } /** * @return string */ function getDeviceID() { return $this->getGenericDataValue( 'device_id' ); } /** * @param $value * @return bool */ function setDeviceID( $value ) { $value = trim( $value ); return $this->setGenericDataValue( 'device_id', $value ); } /** * @return string */ function getDeviceUserAgent() { return $this->getGenericDataValue( 'device_user_agent' ); } /** * @param $value * @return bool */ function setDeviceUserAgent( $value ) { $value = trim( $value ); return $this->setGenericDataValue( 'device_user_agent', $value ); } /** * @return string */ function getIPAddress() { return $this->getGenericDataValue( 'ip_address' ); } /** * @param $value * @return bool */ function setIPAddress( $value ) { $value = trim( $value ); if ( empty( $value ) == true ) { $value = Misc::getRemoteIPAddress(); } return $this->setGenericDataValue( 'ip_address', $value ); } /** * @return string */ function getLocation() { return $this->getGenericDataValue( 'location' ); } /** * @param $value * @return bool */ function setLocation( $value ) { $value = trim( $value ); return $this->setGenericDataValue( 'location', $value ); } /** * @param bool $ignore_warning * @return bool */ function Validate( $ignore_warning = true ) { // // BELOW: Validation code moved from set*() functions. // $ulf = TTnew( 'UserListFactory' ); /** @var UserListFactory $ulf */ $this->Validator->isResultSetWithRows( 'user_id', $ulf->getByID( $this->getUser() ), TTi18n::gettext( 'Invalid Employee' ) ); return true; } /** * @param $data * @return bool */ function setObjectFromArray( $data ) { if ( is_array( $data ) ) { $variable_function_map = $this->getVariableToFunctionMap(); foreach ( $variable_function_map as $key => $function ) { if ( isset( $data[$key] ) ) { $function = 'set' . $function; switch ( $key ) { default: if ( method_exists( $this, $function ) ) { $this->$function( $data[$key] ); } break; } } } $this->setCreatedAndUpdatedColumns( $data ); return true; } return false; } /** * @param null $include_columns * @return array */ function getObjectAsArray( $include_columns = null ) { $data = []; $variable_function_map = $this->getVariableToFunctionMap(); if ( is_array( $variable_function_map ) ) { foreach ( $variable_function_map as $variable => $function_stub ) { if ( $include_columns == null || ( isset( $include_columns[$variable] ) && $include_columns[$variable] == true ) ) { $function = 'get' . $function_stub; switch ( $variable ) { default: if ( method_exists( $this, $function ) ) { $data[$variable] = $this->$function(); } break; } } } $this->getCreatedAndUpdatedColumns( $data, $include_columns ); } return $data; } }