Skip to content

Latest commit

 

History

History
2068 lines (1015 loc) · 43.2 KB

class.CustomerCore.md

File metadata and controls

2068 lines (1015 loc) · 43.2 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

$birthday

public string $birthday = null

$date_add

public string $date_add

$date_upd

public string $date_upd

$days

public mixed $days

$deleted

public boolean $deleted

$email

public string $email

$fieldsRequired

protected mixed $fieldsRequired = array('lastname', 'passwd', 'firstname', 'email')

$fieldsSize

protected mixed $fieldsSize = array('lastname' => 32, 'passwd' => 32, 'firstname' => 32, 'email' => 128, 'note' => 65000)

$fieldsValidate

protected mixed $fieldsValidate = array('secure_key' => 'isMd5', 'lastname' => 'isName', 'firstname' => 'isName', 'email' => 'isEmail', 'passwd' => 'isPasswd', 'id_gender' => 'isUnsignedId', 'birthday' => 'isBirthDate', 'newsletter' => 'isBool', 'optin' => 'isBool', 'active' => 'isBool', 'note' => 'isCleanHtml', 'is_guest' => 'isBool', 'id_shop' => 'isUnsignedId', 'id_group_shop' => 'isUnsignedId')

$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

$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_shop

public mixed $id_shop

$identifier

protected mixed $identifier = 'id_customer'

$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

$months

public mixed $months

$newsletter

public boolean $newsletter

$newsletter_date_add

public string $newsletter_date_add

$note

public string $note

$optin

public boolean $optin

$passwd

public integer $passwd

$secure_key

public string $secure_key

$table

protected mixed $table = 'customer'

$tables

protected mixed $tables = array('customer')

$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')))

$years

public mixed $years

$_cache

protected mixed $_cache = array()

$fieldsRequiredDatabase

protected \fieldsRequiredDatabase $fieldsRequiredDatabase = null

$fieldsRequiredLang

protected array $fieldsRequiredLang = array()

$fieldsSizeLang

protected array $fieldsSizeLang = array()

$fieldsValidateLang

protected array $fieldsValidateLang = array()

$id_lang

protected integer $id_lang = null

$image_dir

protected string $image_dir = null

$image_format

protected string $image_format = 'jpg'

$langMultiShop

protected mixed $langMultiShop = false

Methods

__construct

mixed ObjectModelCore::__construct(integer $id, integer $id_lang, $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 mixed

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

mixed ObjectModelCore::deleteSelection($selection)

Delete several objects from database

return boolean Deletion result

Arguments

  • $selection mixed

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($id_entity, $table)

Specify if an ObjectModel is already in database

Arguments

  • $id_entity mixed - entity id
  • $table 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

getFields

mixed CustomerCore::getFields()

getFieldsRequiredDatabase

mixed ObjectModelCore::getFieldsRequiredDatabase($all)

Arguments

  • $all mixed

getFieldsValidateLang

array ObjectModelCore::getFieldsValidateLang()

Get list of fields related to language to validate

getGroups

mixed CustomerCore::getGroups()

getGroupsStatic

mixed CustomerCore::getGroupsStatic($id_customer)

Arguments

  • $id_customer mixed

getIdentifier

string ObjectModelCore::getIdentifier()

Get object identifier name

getLastCart

mixed CustomerCore::getLastCart()

getLastConnections

mixed CustomerCore::getLastConnections()

getStats

array CustomerCore::getStats()

Return several useful statistics about customer

getTranslationsFields

mixed ObjectModelCore::getTranslationsFields(array $fieldsArray)

Prepare multilingual fields for database insertion

Arguments

  • $fieldsArray array - Multilingual fields to prepare return array Prepared fields for database insertion

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

mixed ObjectModelCore::save($nullValues, $autodate)

Save current object to database (add or update)

return boolean Insertion result

Arguments

  • $nullValues mixed
  • $autodate mixed

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

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

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

validateFields

mixed ObjectModelCore::validateFields($die, $errorReturn)

Check for fields validity before database interaction

Arguments

  • $die mixed
  • $errorReturn mixed

validateFieldsLang

mixed ObjectModelCore::validateFieldsLang($die, $errorReturn)

Check for multilingual fields validity before database interaction

Arguments

  • $die mixed
  • $errorReturn mixed