Skip to content

Latest commit

 

History

History
2359 lines (1160 loc) · 51.1 KB

class.CustomerCore.md

File metadata and controls

2359 lines (1160 loc) · 51.1 KB

Class CustomerCore

Contents

Properties

Methods

Properties

$_customerHasAddress

protected mixed $_customerHasAddress = array()

$_customer_groups

protected mixed $_customer_groups = array()

$_defaultGroupId

protected mixed $_defaultGroupId = array()

$active

public boolean $active = true

$ape

public string $ape

$birthday

public string $birthday = null

$company

public string $company

$date_add

public string $date_add

$date_upd

public string $date_upd

$days

public mixed $days

$definition

public mixed $definition = array('table' => 'customer', 'primary' => 'id_customer', 'fields' => array('secure_key' => array('type' => self::TYPE_STRING, 'validate' => 'isMd5'), 'lastname' => array('type' => self::TYPE_STRING, 'validate' => 'isName', 'required' => true, 'size' => 32), 'firstname' => array('type' => self::TYPE_STRING, 'validate' => 'isName', 'required' => true, 'size' => 32), 'email' => array('type' => self::TYPE_STRING, 'validate' => 'isEmail', 'required' => true, 'size' => 128), 'passwd' => array('type' => self::TYPE_STRING, 'validate' => 'isPasswd', 'required' => true, 'size' => 32), 'last_passwd_gen' => array('type' => self::TYPE_STRING), 'id_gender' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId'), 'birthday' => array('type' => self::TYPE_DATE, 'validate' => 'isBirthDate'), 'newsletter' => array('type' => self::TYPE_BOOL, 'validate' => 'isBool'), 'newsletter_date_add' => array('type' => self::TYPE_DATE), 'ip_registration_newsletter' => array('type' => self::TYPE_STRING), 'optin' => array('type' => self::TYPE_BOOL, 'validate' => 'isBool'), 'website' => array('type' => self::TYPE_STRING, 'validate' => 'isUrl'), 'company' => array('type' => self::TYPE_STRING, 'validate' => 'isName'), 'siret' => array('type' => self::TYPE_STRING, 'validate' => 'isSiret'), 'ape' => array('type' => self::TYPE_STRING, 'validate' => 'isApe'), 'outstanding_allow_amount' => array('type' => self::TYPE_INT, 'validate' => 'isFloat'), 'show_public_prices' => array('type' => self::TYPE_BOOL, 'validate' => 'isBool'), 'id_risk' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedInt'), 'max_payment_days' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedInt'), 'active' => array('type' => self::TYPE_BOOL, 'validate' => 'isBool'), 'deleted' => array('type' => self::TYPE_BOOL, 'validate' => 'isBool'), 'note' => array('type' => self::TYPE_STRING, 'validate' => 'isCleanHtml', 'size' => 65000), 'is_guest' => array('type' => self::TYPE_BOOL, 'validate' => 'isBool'), 'id_shop' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId'), 'id_group_shop' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId'), 'id_default_group' => array('type' => self::TYPE_INT), 'date_add' => array('type' => self::TYPE_DATE, 'validate' => 'isDate'), 'date_upd' => array('type' => self::TYPE_DATE, 'validate' => 'isDate')))

$deleted

public boolean $deleted

$email

public string $email

$firstname

public string $firstname

$geoloc_id_country

public integer $geoloc_id_country

$geoloc_id_state

public integer $geoloc_id_state

$geoloc_postcode

public string $geoloc_postcode

$groupBox

public mixed $groupBox

$id

public mixed $id

$id_default_group

public integer $id_default_group = _PS_DEFAULT_CUSTOMER_GROUP_

$id_gender

public integer $id_gender

$id_group_shop

public mixed $id_group_shop

$id_guest

public integer $id_guest

$id_risk

public integer $id_risk

$id_shop

public mixed $id_shop

$ip_registration_newsletter

public string $ip_registration_newsletter

$is_guest

public boolean $is_guest

$last_passwd_gen

public \datetime $last_passwd_gen

$lastname

public string $lastname

$logged

public boolean $logged

$max_payment_days

public integer $max_payment_days

$months

public mixed $months

$newsletter

public boolean $newsletter

$newsletter_date_add

public string $newsletter_date_add

$note

public string $note

$optin

public boolean $optin

$outstanding_allow_amount

public float $outstanding_allow_amount

$passwd

public integer $passwd

$secure_key

public string $secure_key

$show_public_prices

public integer $show_public_prices

$siret

public string $siret

$webserviceParameters

protected mixed $webserviceParameters = array('fields' => array('id_default_group' => array('xlink_resource' => 'groups'), 'newsletter_date_add' => array(), 'ip_registration_newsletter' => array(), 'last_passwd_gen' => array('setter' => null), 'secure_key' => array('setter' => null), 'deleted' => array(), 'passwd' => array('setter' => 'setWsPasswd')))

$website

public string $website

$years

public mixed $years

$def

protected array $def

$fieldsRequired

protected mixed $fieldsRequired = array()

$fieldsRequiredDatabase

protected mixed $fieldsRequiredDatabase = null

$fieldsRequiredLang

protected mixed $fieldsRequiredLang = array()

$fieldsSize

protected mixed $fieldsSize = array()

$fieldsSizeLang

protected mixed $fieldsSizeLang = array()

$fieldsValidate

protected mixed $fieldsValidate = array()

$fieldsValidateLang

protected mixed $fieldsValidateLang = array()

$id_lang

protected integer $id_lang = null

$identifier

protected mixed $identifier

$image_dir

protected string $image_dir = null

$image_format

protected string $image_format = 'jpg'

$table

protected mixed $table

$tables

protected mixed $tables = array()

Methods

__construct

mixed ObjectModelCore::__construct(integer $id, integer $id_lang, integer $id_shop)

Build object

Arguments

  • $id integer - Existing object id in order to load object (optional)
  • $id_lang integer - Required if object is multilingual (optional)
  • $id_shop integer - ID shop for objects with multishop on langs

add

mixed CustomerCore::add($autodate, $null_values)

Arguments

  • $autodate mixed
  • $null_values mixed

addFieldsRequiredDatabase

mixed ObjectModelCore::addFieldsRequiredDatabase($fields)

Arguments

  • $fields mixed

addGroups

mixed CustomerCore::addGroups($groups)

Arguments

  • $groups mixed

associateTo

boolean ObjectModelCore::associateTo(integer|array $id_shops, string $type)

This function associate an item to its context

Arguments

  • $id_shops integer|array
  • $type string

checkPassword

boolean CustomerCore::checkPassword($id_customer, string $passwd)

Check if customer password is the right one

Arguments

  • $id_customer mixed
  • $passwd string - Password

cleanGroups

mixed CustomerCore::cleanGroups()

clearCache

mixed ObjectModelCore::clearCache($all)

Arguments

  • $all mixed

customerExists

\Customer CustomerCore::customerExists(string $email, $return_id, $ignore_guest, \Shop $shop)

Check if e-mail is already registered in database

Arguments

  • $email string - e-mail
  • $return_id mixed - boolean
  • $ignore_guest mixed - boolean, to exclude guest customer
  • $shop Shop

customerHasAddress

boolean CustomerCore::customerHasAddress(integer $id_customer, integer $id_address)

Check if an address is owned by a customer

Arguments

  • $id_customer integer - Customer ID
  • $id_address integer - Address ID

customerIdExists

mixed CustomerCore::customerIdExists($id_customer)

Arguments

  • $id_customer mixed

customerIdExistsStatic

mixed CustomerCore::customerIdExistsStatic($id_customer)

Arguments

  • $id_customer mixed

delete

mixed CustomerCore::delete()

deleteImage

boolean ObjectModelCore::deleteImage()

Delete images associated with the object

deleteSelection

boolean ObjectModelCore::deleteSelection(array $selection)

Delete several objects from database

Arguments

  • $selection array

displayFieldName

mixed ObjectModelCore::displayFieldName($field, $className, $htmlentities, \Context $context)

Arguments

  • $field mixed
  • $className mixed
  • $htmlentities mixed
  • $context Context

duplicateShops

mixed ObjectModelCore::duplicateShops($id)

Arguments

  • $id mixed

existsInDatabase

boolean ObjectModelCore::existsInDatabase(integer $id_entity, string $table)

Specify if an ObjectModel is already in database

Arguments

  • $id_entity integer
  • $table string

formatFields

array ObjectModelCore::formatFields(integer $id_lang)

Arguments

  • $id_lang integer - If this parameter is given, only take lang fields

formatValue

mixed ObjectModelCore::formatValue(mixed $value, integer $type, $with_quotes)

Format a data

Arguments

  • $value mixed
  • $type integer
  • $with_quotes mixed

getAddresses

array CustomerCore::getAddresses(integer $id_lang)

Return customer addresses

Arguments

  • $id_lang integer - Language ID

getAddressesTotalById

integer CustomerCore::getAddressesTotalById(integer $id_customer)

Count the number of addresses for a customer

Arguments

  • $id_customer integer - Customer ID

getBoughtProducts

mixed CustomerCore::getBoughtProducts()

getByEmail

\Customer CustomerCore::getByEmail(string $email, string $passwd, \Shop $shop)

Return customer instance from its e-mail (optionnaly check password)

Arguments

  • $email string - e-mail
  • $passwd string - Password is also checked if specified
  • $shop Shop

getCurrentCountry

mixed CustomerCore::getCurrentCountry($id_customer, \Cart $cart)

Arguments

  • $id_customer mixed
  • $cart Cart

getCustomers

array CustomerCore::getCustomers(\Shop $shop)

Return customers list

Arguments

getDefaultGroupId

mixed CustomerCore::getDefaultGroupId($id_customer)

Arguments

  • $id_customer mixed

getDefinition

mixed ObjectModelCore::getDefinition($class, $field)

Arguments

  • $class mixed
  • $field mixed

getEntity

mixed ObjectModelCore::getEntity($entity)

Arguments

  • $entity mixed

getFields

array ObjectModelCore::getFields()

Prepare fields for ObjectModel class (add, update) All fields are verified (pSQL, intval.

..)

getFieldsLang

array ObjectModelCore::getFieldsLang()

Prepare multilang fields

getFieldsRequiredDatabase

mixed ObjectModelCore::getFieldsRequiredDatabase($all)

Arguments

  • $all mixed

getGroups

mixed CustomerCore::getGroups()

getGroupsStatic

mixed CustomerCore::getGroupsStatic($id_customer)

Arguments

  • $id_customer mixed

getLastCart

mixed CustomerCore::getLastCart()

getLastConnections

mixed CustomerCore::getLastConnections()

getOutstanding

mixed CustomerCore::getOutstanding()

getStats

array CustomerCore::getStats()

Return several useful statistics about customer

getTranslationsFields

mixed ObjectModelCore::getTranslationsFields($fieldsArray)

Arguments

  • $fieldsArray mixed

getValidationRules

array ObjectModelCore::getValidationRules(string $className)

Returns object validation rules (fields validity)

Arguments

  • $className string - Child class name for static use (optional)

getWebserviceObjectList

mixed ObjectModelCore::getWebserviceObjectList($sql_join, $sql_filter, $sql_sort, $sql_limit)

Arguments

  • $sql_join mixed
  • $sql_filter mixed
  • $sql_sort mixed
  • $sql_limit mixed

getWebserviceParameters

mixed ObjectModelCore::getWebserviceParameters($wsParamsAttributeName)

Arguments

  • $wsParamsAttributeName mixed

hydrate

mixed ObjectModelCore::hydrate(array $data, integer $id_lang)

Fill an object with given data. Data must be an array with this syntax: array(objProperty => value, objProperty2 => value, etc.)

Arguments

  • $data array
  • $id_lang integer

hydrateCollection

array ObjectModelCore::hydrateCollection(string $class, array $datas, integer $id_lang)

Fill (hydrate) a list of objects in order to get a collection of these objects

Arguments

  • $class string - Class of objects to hydrate
  • $datas array - List of data (multi-dimensional array)
  • $id_lang integer

isAssociatedToGroupShop

boolean ObjectModelCore::isAssociatedToGroupShop(integer $id_group_shop)

Check if current object is associated to a group shop

Arguments

  • $id_group_shop integer

isAssociatedToShop

boolean ObjectModelCore::isAssociatedToShop(integer $id_shop)

Check if current object is associated to a shop

Arguments

  • $id_shop integer

isBanned

boolean CustomerCore::isBanned($id_customer)

Check id the customer is active or not

Arguments

  • $id_customer mixed

isCurrentlyUsed

boolean ObjectModelCore::isCurrentlyUsed(string $table, boolean $has_active_column)

This method is allow to know if a entity is currently used

Arguments

  • $table string - name of table linked to entity
  • $has_active_column boolean - true if the table has an active column

isGuest

mixed CustomerCore::isGuest()

isLangMultishop

mixed ObjectModelCore::isLangMultishop()

isLogged

boolean CustomerCore::isLogged(boolean $with_guest)

Check customer informations and return customer validity

Arguments

  • $with_guest boolean

isUsed

mixed CustomerCore::isUsed()

logout

mixed CustomerCore::logout()

Logout

makeTranslationFields

mixed ObjectModelCore::makeTranslationFields($fields, $fieldsArray, $id_language)

Arguments

  • $fields mixed
  • $fieldsArray mixed
  • $id_language mixed

mylogout

mixed CustomerCore::mylogout()

Soft logout, delete everything links to the customer but leave there affiliate's informations

resetAddressCache

mixed CustomerCore::resetAddressCache($id_customer)

Arguments

  • $id_customer mixed

save

boolean ObjectModelCore::save(boolean $null_values, boolean $autodate)

Save current object to database (add or update)

Arguments

  • $null_values boolean
  • $autodate boolean

searchByIp

mixed CustomerCore::searchByIp(string $ip)

Search for customers by ip address

Arguments

  • $ip string - Searched string

searchByName

array CustomerCore::searchByName(string $query, \Shop $shop)

Light back office search for customers

Arguments

  • $query string - Searched string
  • $shop Shop

setDefinitionRetrocompatibility

mixed ObjectModelCore::setDefinitionRetrocompatibility()

Retrocompatibility for classes without $definition static Remove this in 1.6 !

setWsPasswd

mixed CustomerCore::setWsPasswd($passwd)

Arguments

  • $passwd mixed

toggleStatus

mixed CustomerCore::toggleStatus()

transformToCustomer

mixed CustomerCore::transformToCustomer($id_lang, $password)

Arguments

  • $id_lang mixed
  • $password mixed

update

mixed CustomerCore::update($nullValues)

Arguments

  • $nullValues mixed

updateGroup

mixed CustomerCore::updateGroup(array $list)

Update customer groups associated to the object

Arguments

  • $list array - groups

validateControler

mixed ObjectModelCore::validateControler($htmlentities)

TODO: refactor rename all calls to this to validateController

Arguments

  • $htmlentities mixed

validateController

mixed ObjectModelCore::validateController($htmlentities)

Arguments

  • $htmlentities mixed

validateField

boolean|string ObjectModelCore::validateField(string $field, mixed $value, integer $id_lang)

Validate a single field

Arguments

  • $field string - Field name
  • $value mixed - Field value
  • $id_lang integer

validateFields

boolean|string ObjectModelCore::validateFields(boolean $die, boolean $error_return)

Check for fields validity before database interaction

Arguments

  • $die boolean
  • $error_return boolean

validateFieldsLang

boolean|string ObjectModelCore::validateFieldsLang(boolean $die, boolean $error_return)

Check for multilingual fields validity before database interaction

Arguments

  • $die boolean
  • $error_return boolean