\ModuleCore

Summary

Methods
Properties
Constants
__construct()
install()
checkCompliancy()
updateTranslationsAfterInstall()
updateModuleTranslations()
initUpgradeModule()
runUpgradeModule()
upgradeModuleVersion()
needUpgrade()
getUpgradeStatus()
uninstall()
enableByName()
enable()
enableDevice()
disableDevice()
disableByName()
disable()
displayFlags()
registerHook()
unregisterHook()
unregisterExceptions()
registerExceptions()
editExceptions()
getModuleNameFromClass()
getInstanceByName()
getInstanceById()
configXmlStringFormat()
getModuleName()
getModulesOnDisk()
getModulesDirOnDisk()
getNonNativeModuleList()
getNativeModuleList()
getModulesInstalled()
isModuleTrusted()
generateTrustedXml()
checkModuleFromAddonsApi()
hookExec()
hookExecPayment()
preCall()
getPaypalIgnore()
getPaymentModules()
findTranslation()
l()
updatePosition()
cleanPositions()
displayError()
displayConfirmation()
getExceptionsStatic()
getExceptions()
isInstalled()
isEnabledForShopContext()
isEnabled()
isRegisteredInHook()
display()
getTemplatePath()
isCached()
isHookableOn()
getPermission()
getPermissionStatic()
getAuthorizedModules()
getModuleIdByName()
getErrors()
getConfirmations()
getLocalPath()
getPathUri()
getPosition()
adminDisplayWarning()
installOverrides()
uninstallOverrides()
addOverride()
removeOverride()
$id
$version
$database_version
$registered_version
$ps_versions_compliancy
$dependencies
$name
$displayName
$description
$author
$author_uri
$module_key
$description_full
$additional_description
$compatibility
$nb_rates
$avg_rate
$badges
$need_instance
$tab
$active
$trusted
$warning
$enable_device
$limited_countries
$controllers
$classInModule
$allow_push
$push_time_limit
$hosted_modules_blacklist
CACHE_FILE_MODULES_LIST
CACHE_FILE_TAB_MODULES_LIST
CACHE_FILE_ALL_COUNTRY_MODULES_LIST
CACHE_FILE_DEFAULT_COUNTRY_MODULES_LIST
CACHE_FILE_CUSTOMER_MODULES_LIST
CACHE_FILE_MUST_HAVE_MODULES_LIST
CACHE_FILE_TRUSTED_MODULES_LIST
CACHE_FILE_UNTRUSTED_MODULES_LIST
setUpgradeMessage()
loadUpgradeVersionList()
useTooMuchMemory()
_isTemplateOverloadedStatic()
_isTemplateOverloaded()
getCacheId()
getCurrentSubTemplate()
resetCurrentSubTemplate()
_getApplicableTemplateDir()
_clearCache()
_generateConfigXml()
adminDisplayInformation()
$_lang
$_path
$local_path
$_errors
$_confirmations
$table
$identifier
$modules_cache
$_INSTANCE
$_generate_config_xml_mode
$l_cache
$cache_permissions
$context
$smarty
$current_subtemplate
$update_translations_after_install
N/A
installControllers()
No private properties found
N/A

Constants

CACHE_FILE_MODULES_LIST

CACHE_FILE_MODULES_LIST

CACHE_FILE_TAB_MODULES_LIST

CACHE_FILE_TAB_MODULES_LIST

CACHE_FILE_ALL_COUNTRY_MODULES_LIST

CACHE_FILE_ALL_COUNTRY_MODULES_LIST

CACHE_FILE_DEFAULT_COUNTRY_MODULES_LIST

CACHE_FILE_DEFAULT_COUNTRY_MODULES_LIST

CACHE_FILE_CUSTOMER_MODULES_LIST

CACHE_FILE_CUSTOMER_MODULES_LIST

CACHE_FILE_MUST_HAVE_MODULES_LIST

CACHE_FILE_MUST_HAVE_MODULES_LIST

CACHE_FILE_TRUSTED_MODULES_LIST

CACHE_FILE_TRUSTED_MODULES_LIST

CACHE_FILE_UNTRUSTED_MODULES_LIST

CACHE_FILE_UNTRUSTED_MODULES_LIST

Properties

$id

$id : integer

Type

integer — Module ID

$version

$version : float

Type

float — Version

$database_version

$database_version : 

Type

$registered_version

$registered_version : string

Type

string — Registered Version in database

$ps_versions_compliancy

$ps_versions_compliancy : array

Type

array — filled with known compliant PS versions

$dependencies

$dependencies : array

Type

array — filled with modules needed for install

$name

$name : string

Type

string — Unique name

$displayName

$displayName : string

Type

string — Human name

$description

$description : string

Type

string — A little description of the module

$author

$author : string

Type

string — author of the module

$author_uri

$author_uri : string

Type

string — URI author of the module

$module_key

$module_key : string

Type

string — Module key provided by addons.prestashop.com

$description_full

$description_full : 

Type

$additional_description

$additional_description : 

Type

$compatibility

$compatibility : 

Type

$nb_rates

$nb_rates : 

Type

$avg_rate

$avg_rate : 

Type

$badges

$badges : 

Type

$need_instance

$need_instance : integer

Type

integer — need_instance

$tab

$tab : string

Type

string — Admin tab corresponding to the module

$active

$active : boolean

Type

boolean — Status

$trusted

$trusted : boolean

Type

boolean — Is the module certified by addons.prestashop.com

$warning

$warning : string

Type

string — Fill it if the module is installed but not yet set up

$enable_device

$enable_device : 

Type

$limited_countries

$limited_countries : array

Type

array — to store the limited country

$controllers

$controllers : array

Type

array — names of the controllers

$classInModule

$classInModule : array

Type

array — used by AdminTab to determine which lang file to use (admin.php or module lang file)

$allow_push

$allow_push : \allow

Type

\allow — push

$push_time_limit

$push_time_limit : 

Type

$hosted_modules_blacklist

$hosted_modules_blacklist : 

Type

$_lang

$_lang : array

Type

array — current language translations

$_path

$_path : string

Type

string — Module web path (eg. '/shop/modules/modulename/')

$local_path

$local_path : string

Type

string — Module local path (eg. '/home/prestashop/modules/modulename/')

$_errors

$_errors : \protected

Type

\protected — array filled with module errors

$_confirmations

$_confirmations : \protected

Type

\protected — array filled with module success

$table

$table : \protected

Type

\protected — string main table used for modules installed

$identifier

$identifier : \protected

Type

\protected — string identifier of the main table

$modules_cache

$modules_cache : \protected

Type

\protected — array cache filled with modules informations

$_INSTANCE

$_INSTANCE : \protected

Type

\protected — array cache filled with modules instances

$_generate_config_xml_mode

$_generate_config_xml_mode : \protected

Type

\protected — boolean filled with config xml generation mode

$l_cache

$l_cache : \protected

Type

\protected — array filled with cache translations

$cache_permissions

$cache_permissions : \protected

Type

\protected — array filled with cache permissions (modules / employee profiles)

$context

$context : \Context

Type

\Context

$smarty

$smarty : \Smarty_Data

Type

\Smarty_Data

$current_subtemplate

$current_subtemplate : \currentSmartySubTemplate

Type

\currentSmartySubTemplate

$update_translations_after_install

$update_translations_after_install : 

Type

Methods

__construct()

__construct(string  $name = null, \Context  $context = null) 

Constructor

Parameters

string $name

Module unique name

\Context $context

install()

install() 

Insert module into datable

checkCompliancy()

checkCompliancy() 

updateTranslationsAfterInstall()

updateTranslationsAfterInstall(  $update = true) 

Parameters

$update

updateModuleTranslations()

updateModuleTranslations() 

initUpgradeModule()

initUpgradeModule(  $module) : boolean

Init the upgrade module

Parameters

$module

Returns

boolean

runUpgradeModule()

runUpgradeModule() : array

Run the upgrade for a given module name and version

Returns

array

upgradeModuleVersion()

upgradeModuleVersion(  $name,   $version) : boolean

Upgrade the registered version to a new one

Parameters

$name
$version

Returns

boolean

needUpgrade()

needUpgrade(  $module) : boolean

Check if a module need to be upgraded.

This method modify the module_cache adding an upgrade list file

Parameters

$module

Returns

boolean

getUpgradeStatus()

getUpgradeStatus(  $module_name) : boolean

Return the status of the upgraded module

Parameters

$module_name

Returns

boolean

uninstall()

uninstall() : boolean

Delete module from datable

Returns

boolean —

result

enableByName()

enableByName(array|string  $name) : true

This function enable module $name. If an $name is an array, this will enable all of them

Parameters

array|string $name

Returns

true —

if succeed

enable()

enable(boolean  $forceAll = false) 

Activate current module.

Parameters

boolean $forceAll

If true, enable module for all shop

enableDevice()

enableDevice(  $device) 

Parameters

$device

disableDevice()

disableDevice(  $device) 

Parameters

$device

disableByName()

disableByName(array|string  $name) : true

This function disable module $name. If an $name is an array, this will disable all of them

Parameters

array|string $name

Returns

true —

if succeed

disable()

disable(boolean  $forceAll = false) 

Desactivate current module.

Parameters

boolean $forceAll

If true, disable module for all shop

displayFlags()

displayFlags(array  $languages, integer  $default_language, string  $ids, string  $id, boolean  $return = false, boolean  $use_vars_instead_of_ids = false) 

Display flags in forms for translations

Parameters

array $languages

All languages available

integer $default_language

Default language id

string $ids

Multilingual div ids in form

string $id

Current div id]

boolean $return

define the return way : false for a display, true for a return

boolean $use_vars_instead_of_ids

use an js vars instead of ids seperate by "¤"

registerHook()

registerHook(string  $hook_name, array  $shop_list = null) : boolean

Connect module to a hook

Parameters

string $hook_name

Hook name

array $shop_list

List of shop linked to the hook (if null, link hook to all shops)

Returns

boolean —

result

unregisterHook()

unregisterHook(  $hook_id, array  $shop_list = null) : boolean

Unregister module from hook

Parameters

$hook_id
array $shop_list

List of shop

Returns

boolean —

result

unregisterExceptions()

unregisterExceptions(  $hook_id, array  $shop_list = null) : boolean

Unregister exceptions linked to module

Parameters

$hook_id
array $shop_list

List of shop

Returns

boolean —

result

registerExceptions()

registerExceptions(integer  $id_hook, array  $excepts, array  $shop_list = null) : boolean

Add exceptions for module->Hook

Parameters

integer $id_hook

Hook id

array $excepts

List of file name

array $shop_list

List of shop

Returns

boolean —

result

editExceptions()

editExceptions(  $id_hook, array  $excepts) : boolean

Edit exceptions for module->Hook

Parameters

$id_hook
array $excepts

List of shopID and file name

Returns

boolean —

result

getModuleNameFromClass()

getModuleNameFromClass(mixed  $currentClass) : boolean|string

This function is used to determine the module name of an AdminTab which belongs to a module, in order to keep translation related to a module in its directory (instead of $_LANGADM)

Parameters

mixed $currentClass

the

Returns

boolean|string —

if the class belongs to a module, will return the module name. Otherwise, return false.

getInstanceByName()

getInstanceByName(string  $module_name) : \Module

Return an instance of the specified module

Parameters

string $module_name

Module name

Returns

\Module

getInstanceById()

getInstanceById(integer  $id_module) : \Module

Return an instance of the specified module

Parameters

integer $id_module

Module ID

Returns

\Module —

instance

configXmlStringFormat()

configXmlStringFormat(  $string) 

Parameters

$string

getModuleName()

getModuleName(  $module) 

Parameters

$module

getModulesOnDisk()

getModulesOnDisk(boolean  $useConfig = false,   $loggedOnAddons = false,   $id_employee = false) : array

Return available modules

Parameters

boolean $useConfig

in order to use config.xml file in module dir

$loggedOnAddons
$id_employee

Returns

array —

Modules

getModulesDirOnDisk()

getModulesDirOnDisk() : array

Return modules directory list

Returns

array —

Modules Directory List

getNonNativeModuleList()

getNonNativeModuleList() : array

Return non native module

Returns

array —

Modules

getNativeModuleList()

getNativeModuleList() 

getModulesInstalled()

getModulesInstalled(integer  $position) : array

Return installed modules

Parameters

integer $position

Take only positionnables modules

Returns

array —

Modules

isModuleTrusted()

isModuleTrusted(  $module_name) : integer

Return if the module is provided by addons.prestashop.com or not

Parameters

$module_name

Returns

integer

generateTrustedXml()

generateTrustedXml() 

Generate XML files for trusted and untrusted modules

checkModuleFromAddonsApi()

checkModuleFromAddonsApi(  $module_name) : boolean

Create the Addons API call from the module name only

Parameters

$module_name

Returns

boolean —

Returns if the module is trusted by addons.prestashop.com

hookExec()

hookExec(string  $hook_name, array  $hookArgs = array(),   $id_module = null) : string

Execute modules for specified hook

Parameters

string $hook_name

Hook Name

array $hookArgs

Parameters for the functions

$id_module

Returns

string —

modules output

hookExecPayment()

hookExecPayment() 

preCall()

preCall(  $module_name) 

Parameters

$module_name

getPaypalIgnore()

getPaypalIgnore() 

getPaymentModules()

getPaymentModules() : array

Returns the list of the payment module associated to the current customer

Returns

array —

module informations

findTranslation()

findTranslation(  $name,   $string,   $source) 

Parameters

$name
$string
$source

l()

l(string  $string, boolean|string  $specific = false) : string

Get translation for a given module text

Note: $specific parameter is mandatory for library files. Otherwise, translation key will not match for Module library when module is loaded with eval() Module::getModulesOnDisk()

Parameters

string $string

String to translate

boolean|string $specific

filename to use in translation key

Returns

string —

Translation

updatePosition()

updatePosition(  $id_hook,   $way,   $position = null) 

Parameters

$id_hook
$way
$position

cleanPositions()

cleanPositions(  $id_hook,   $shop_list = null) 

Parameters

$id_hook
$shop_list

displayError()

displayError(  $error) 

Parameters

$error

displayConfirmation()

displayConfirmation(  $string) 

Parameters

$string

getExceptionsStatic()

getExceptionsStatic(  $id_module,   $id_hook,   $dispatch = false) 

Parameters

$id_module
$id_hook
$dispatch

getExceptions()

getExceptions(  $id_hook,   $dispatch = false) 

Parameters

$id_hook
$dispatch

isInstalled()

isInstalled(  $module_name) 

Parameters

$module_name

isEnabledForShopContext()

isEnabledForShopContext() 

isEnabled()

isEnabled(  $module_name) 

Parameters

$module_name

isRegisteredInHook()

isRegisteredInHook(  $hook) 

Parameters

$hook

display()

display(  $file,   $template,   $cacheId = null,   $compileId = null) 

Parameters

$file
$template
$cacheId
$compileId

getTemplatePath()

getTemplatePath(string  $template) : string

Get realpath of a template of current module (check if template is overriden too)

Parameters

string $template

Returns

string

isCached()

isCached(  $template,   $cacheId = null,   $compileId = null) 

Parameters

$template
$cacheId
$compileId

isHookableOn()

isHookableOn(string  $hook_name) : boolean

Check if the module is transplantable on the hook in parameter

Parameters

string $hook_name

Returns

boolean —

if module can be transplanted on hook

getPermission()

getPermission(array  $variable, object  $employee = null) : boolean

Check employee permission for module

Parameters

array $variable

(action)

object $employee

Returns

boolean —

if module can be transplanted on hook

getPermissionStatic()

getPermissionStatic(integer  $id_module, array  $variable, object  $employee = null) : boolean

Check employee permission for module (static method)

Parameters

integer $id_module
array $variable

(action)

object $employee

Returns

boolean —

if module can be transplanted on hook

getAuthorizedModules()

getAuthorizedModules(  $group_id) 

Get Unauthorized modules for a client group

Parameters

$group_id

getModuleIdByName()

getModuleIdByName(  $name) : integer

Get id module by name

Parameters

$name

Returns

integer —

id

getErrors()

getErrors() : array

Get module errors

Returns

array —

errors

getConfirmations()

getConfirmations() : array

Get module messages confirmation

Returns

array —

conf

getLocalPath()

getLocalPath() : string

Get local path for module

Returns

string

getPathUri()

getPathUri() : string

Get uri path for module

Returns

string

getPosition()

getPosition(  $id_hook) 

Parameters

$id_hook

adminDisplayWarning()

adminDisplayWarning(string  $msg) 

add a warning message to display at the top of the admin page

Parameters

string $msg

installOverrides()

installOverrides() : boolean

Install overrides files for the module

Returns

boolean

uninstallOverrides()

uninstallOverrides() : boolean

Uninstall overrides files for the module

Returns

boolean

addOverride()

addOverride(string  $classname) : boolean

Add all methods in a module override to the override class

Parameters

string $classname

Returns

boolean

removeOverride()

removeOverride(string  $classname) : boolean

Remove all methods in a module override from the override class

Parameters

string $classname

Returns

boolean

setUpgradeMessage()

setUpgradeMessage(  $upgrade_detail) 

Set errors, warning or success message of a module upgrade

Parameters

$upgrade_detail

loadUpgradeVersionList()

loadUpgradeVersionList(  $module_name,   $module_version,   $registered_version) : boolean

Load the available list of upgrade of a specified module with an associated version

Parameters

$module_name
$module_version
$registered_version

Returns

boolean —

to know directly if any files have been found

useTooMuchMemory()

useTooMuchMemory() 

_isTemplateOverloadedStatic()

_isTemplateOverloadedStatic(  $module_name,   $template) 

Parameters

$module_name
$template

_isTemplateOverloaded()

_isTemplateOverloaded(  $template) 

Parameters

$template

getCacheId()

getCacheId(  $name = null) 

Parameters

$name

getCurrentSubTemplate()

getCurrentSubTemplate(  $template,   $cache_id = null,   $compile_id = null) 

Parameters

$template
$cache_id
$compile_id

resetCurrentSubTemplate()

resetCurrentSubTemplate(  $template,   $cache_id,   $compile_id) 

Parameters

$template
$cache_id
$compile_id

_getApplicableTemplateDir()

_getApplicableTemplateDir(  $template) 

Parameters

$template

_clearCache()

_clearCache(  $template,   $cache_id = null,   $compile_id = null) 

Parameters

$template
$cache_id
$compile_id

_generateConfigXml()

_generateConfigXml() 

adminDisplayInformation()

adminDisplayInformation(string  $msg) 

add a info message to display at the top of the admin page

Parameters

string $msg

installControllers()

installControllers() : boolean

Install module's controllers using public property $controllers

Returns

boolean