Skip to content

icms_data_notification_Handler

Raimondas Rimkevičius edited this page Mar 9, 2020 · 1 revision
Notice: Wiki was automatic generated from project sources as project API documentation. Do not edit manually!

icms_data_notification_Handler

Notification handler class.

This class is responsible for providing data access mechanisms to the data source of notification class objects.

  • Class name: icms_data_notification_Handler
  • Namespace:
  • Parent class: icms_ipf_Handler

Properties

$_loadedItems

protected array $_loadedItems = array()

Loaded items cache

  • Visibility: protected
  • This property is static.

$cached_fields

protected mixed $cached_fields = array()
  • Visibility: protected
  • This property is static.

$_itemname

public string $_itemname

The name of the IPF object

  • Visibility: public

$table

public string $table

Name of the table use to store objects linked with this handler

Note that the name of the table needs to be free of the database prefix. For example "smartsection_categories"

  • Visibility: public

$keyName

public string $keyName

Name of the table key that uniquely identify each object

For example : "categoryid"

  • Visibility: public

$className

public string $className

Name of the class derived from object and which this handler is handling

Note that this string needs to be lowercase

For example : "smartsectioncategory"

  • Visibility: public

$identifierName

public string $identifierName

Name of the field which properly identify the object

For example : "name" (this will be the category's name)

  • Visibility: public

$summaryName

public string $summaryName

Name of the field which will be use as a summary for the object

For example : "summary"

  • Visibility: public

$_page

public string $_page

Page name use to basically manage and display the object

This page needs to be the same in user side and admin side

For example category.php - we will deduct smartsection/category.php as well as smartsection/admin/category.php

  • Visibility: public

$_modulePath

public string $_modulePath

Full path of the module using this object

ICMS_URL . "/modules/smartsection/"

  • Visibility: public

$_moduleUrl

public string $_moduleUrl

Module URL

  • Visibility: public

$_moduleName

public string $_moduleName

The name of the module for the object

  • Visibility: public

$uploadEnabled

public bool $uploadEnabled = \false

Is upload enabled?

  • Visibility: public

$_uploadUrl

public string $_uploadUrl

Upload URL

  • Visibility: public

$_uploadPath

public string $_uploadPath

Upload Path

  • Visibility: public

$_allowedMimeTypes

public array $_allowedMimeTypes = []

Allowed mimetypes

  • Visibility: public

$_maxFileSize

public int $_maxFileSize = 1000000

Max allowed file size for upload

  • Visibility: public

$_maxWidth

public int $_maxWidth = 500

Max allowed width for file upload

  • Visibility: public

$_maxHeight

public int $_maxHeight = 500

Max file height for upload

  • Visibility: public

$highlightFields

public array $highlightFields = array()

What fields to highlight?

  • Visibility: public

$visibleColumns

public array $visibleColumns = array()

What columns should be viisble.

Empty array means all.

  • Visibility: public

$eventArray

public array $eventArray = array()

Array containing the events name and functions

  • Visibility: public

$permissionsArray

public array $permissionsArray = array()

Array containing the permissions that this handler will manage on the objects

  • Visibility: public

$generalSQL

public string $generalSQL

Some SQL that will be used as base for all operations for this handler

  • Visibility: public

$_eventHooks

public array $_eventHooks = array()

Events hooks

  • Visibility: public

$_disabledEvents

public array $_disabledEvents = array()

Disabled events

  • Visibility: public

$debugMode

public bool $debugMode = \false

Is debug mode?

  • Visibility: public

$db

public \icms_db_legacy_Database $db

holds referenced

  • Visibility: public

Methods

__construct

mixed icms_core_ObjectHandler::__construct(\icms_db_legacy_Database db)

called from child classes only

Arguments

  • db icms_db_legacy_Database - <p>reference to db</p>

getNotification

mixed icms_data_notification_Handler::getNotification(int module_id, string category, int item_id, string event, int user_id)

Change a value in multiple notifications

  • Visibility: public

Arguments

  • module_id int - <p>module ID to get notification for</p>
  • category string - <p>category to get notification for</p>
  • item_id int - <p>item ID to get notification for</p>
  • event string - <p>module ID to get notification for</p>
  • user_id int - <p>user ID to get notification for</p>

isSubscribed

mixed icms_data_notification_Handler::isSubscribed(string category, int item_id, string event, int module_id, int user_id)

Determine if a user is subscribed to a particular event in a particular module.

  • Visibility: public

Arguments

  • category string - <p>Category of notification event</p>
  • item_id int - <p>Item ID of notification event</p>
  • event string - <p>Event</p>
  • module_id int - <p>ID of module (default current module)</p>
  • user_id int - <p>ID of user (default current user) return int 0 if not subscribe; non-zero if subscribed (boolean... sort of)</p>

subscribe

mixed icms_data_notification_Handler::subscribe(string category, int item_id, mixed events, int mode, int module_id, int user_id)

Subscribe for notification for an event(s)

  • Visibility: public

Arguments

  • category string - <p>category of notification</p>
  • item_id int - <p>ID of the item</p>
  • events mixed - <p>event string or array of events</p>
  • mode int - <p>force a particular notification mode (e.g. once_only) (default to current user preference)</p>
  • module_id int - <p>ID of the module (default to current module)</p>
  • user_id int - <p>ID of the user (default to current user)</p>

getByUser

\icms_data_notification_Object[] icms_data_notification_Handler::getByUser(int user_id)

Get a list of notifications by user ID

  • Visibility: public

Arguments

  • user_id int - <p>ID of the user</p>

getSubscribedEvents

\icms_data_notification_Object[] icms_data_notification_Handler::getSubscribedEvents(string category, int item_id, int module_id, int user_id)

Get a list of notification events for the current item/mod/user

  • Visibility: public

Arguments

  • category string - <p>category for the subscribed events</p>
  • item_id int - <p>ID of the subscribed items</p>
  • module_id int - <p>ID of the module of the subscribed items</p>
  • user_id int - <p>ID of the user of the subscribed items</p>

getByItemId

\icms_data_notification_Object[] icms_data_notification_Handler::getByItemId(int module_id, int item_id, string order, string status)

Retrieve items by their ID

  • Visibility: public

Arguments

  • module_id int - <p>Module ID</p>
  • item_id int - <p>Item ID</p>
  • order string - <p>Sort order</p>
  • status string - <p>status</p>

triggerEvents

mixed icms_data_notification_Handler::triggerEvents(mixed category, mixed item_id, mixed events, mixed extra_tags, mixed user_list, mixed module_id, mixed omit_user_id)
  • Visibility: public

Arguments

  • category mixed
  • item_id mixed
  • events mixed
  • extra_tags mixed
  • user_list mixed
  • module_id mixed
  • omit_user_id mixed

triggerEvent

mixed icms_data_notification_Handler::triggerEvent(string category, int item_id, string event, array extra_tags, array user_list, int module_id, int omit_user_id)

Send notifications to users

  • Visibility: public

Arguments

  • category string - <p>notification category</p>
  • item_id int - <p>ID of the item</p>
  • event string - <p>notification event</p>
  • extra_tags array - <p>array of substitutions for template to be merged with the one from function..</p>
  • user_list array - <p>only notify the selected users</p>
  • module_id int - <p>ID of the module</p>
  • omit_user_id int - <p>ID of the user to omit from notifications. (default to current user). set to 0 for all users to receive notification.</p>

unsubscribeByUser

bool icms_data_notification_Handler::unsubscribeByUser(int user_id)

Delete all notifications for one user

  • Visibility: public

Arguments

  • user_id int - <p>ID of the user</p>

unsubscribe

bool icms_data_notification_Handler::unsubscribe(string category, int item_id, mixed events, int module_id, int user_id)

Unsubscribe notifications for an event(s).

  • Visibility: public

Arguments

  • category string - <p>category of the events</p>
  • item_id int - <p>ID of the item</p>
  • events mixed - <p>event string or array of events</p>
  • module_id int - <p>ID of the module (default current module)</p>
  • user_id int - <p>UID of the user (default current user)</p>

unsubscribeByModule

bool icms_data_notification_Handler::unsubscribeByModule(int module_id)

Delete all notifications for a particular module

  • Visibility: public

Arguments

  • module_id int - <p>ID of the module</p>

unsubscribeByItem

bool icms_data_notification_Handler::unsubscribeByItem(int module_id, string category, int item_id)

Delete all subscriptions for a particular item.

  • Visibility: public

Arguments

  • module_id int - <p>ID of the module to which item belongs</p>
  • category string - <p>Notification category of the item</p>
  • item_id int - <p>ID of the item</p>

doLoginMaintenance

mixed icms_data_notification_Handler::doLoginMaintenance(int user_id)

Perform notification maintenance activites at login time.

In particular, any notifications for the newly logged-in user with mode XOOPS_NOTIFICATION_MODE_WAITFORLOGIN are switched to mode XOOPS_NOTIFICATION_MODE_SENDONCETHENWAIT.

  • Visibility: public

Arguments

  • user_id int - <p>ID of the user being logged in</p>

updateByField

bool icms_data_notification_Handler::updateByField(mixed notification, string field_name, mixed field_value)

Update

  • Visibility: public

Arguments

  • notification mixed
  • field_name string - <p>Name of the field</p>
  • field_value mixed - <p>Value to write</p>

isEnabled

bool icms_data_notification_Handler::isEnabled(string style, int module_id)

Determine if notification is enabled for the selected module.

  • Visibility: public
  • This method is static.

Arguments

  • style string - <p>Subscription style: 'block' or 'inline'</p>
  • module_id int - <p>ID of the module (default current module)</p>

categoryInfo

mixed icms_data_notification_Handler::categoryInfo(mixed category_name, int module_id)

Get an associative array of info for a particular notification category in the selected module. If no category is selected, return an array of info for all categories.

  • Visibility: public
  • This method is static.

Arguments

  • category_name mixed
  • module_id int - <p>ID of the module (default current module)</p>

commentCategoryInfo

mixed icms_data_notification_Handler::commentCategoryInfo(int module_id)

Get associative array of info for the category to which comment events belong.

  • Visibility: public
  • This method is static.

Arguments

  • module_id int - <p>ID of the module (default current module)</p>

categoryEvents

mixed icms_data_notification_Handler::categoryEvents(string category_name, bool enabled_only, int module_id)

Get an array of info for all events (each event has associative array) in the selected category of the selected module.

  • Visibility: public
  • This method is static.

Arguments

  • category_name string - <p>Category name</p>
  • enabled_only bool - <p>If true, return only enabled events</p>
  • module_id int - <p>ID of the module (default current module)</p>

eventEnabled

bool icms_data_notification_Handler::eventEnabled(array category, array event, object module)

Determine whether a particular notification event is enabled.

Depends on module config options.

  • Visibility: public
  • This method is static.

Arguments

  • category array - <p>Category info array</p>
  • event array - <p>Event info array</p>
  • module object - <p>Module</p>

eventInfo

mixed icms_data_notification_Handler::eventInfo(string category_name, string event_name, int module_id)

Get associative array of info for the selected event in the selected category (for the selected module).

  • Visibility: public
  • This method is static.

Arguments

  • category_name string - <p>Notification category</p>
  • event_name string - <p>Notification event</p>
  • module_id int - <p>ID of the module (default current module)</p>

subscribableCategoryInfo

mixed icms_data_notification_Handler::subscribableCategoryInfo(int module_id)

Get an array of associative info arrays for subscribable categories for the selected module.

  • Visibility: public
  • This method is static.

Arguments

  • module_id int - <p>ID of the module</p>

generateConfig

mixed icms_data_notification_Handler::generateConfig(array category, array event, string type)

Generate module config info for a particular category, event pair.

The selectable config options are given names depending on the category and event names, and the text depends on the category and event titles. These are pieced together in this function in case we wish to alter the syntax.

  • Visibility: public
  • This method is static.

Arguments

  • category array - <p>Array of category info</p>
  • event array - <p>Array of event info</p>
  • type string - <p>The particular name to generate return string</p>

addEventHook

mixed icms_ipf_Handler::addEventHook(\str event, \str method)

Arguments

  • event str
  • method str

addPermission

mixed icms_ipf_Handler::addPermission(string perm_name, string caption, string description)

Add a permission that this handler will manage for its objects

Example : $this->addPermission('view', _AM_SSHOP_CAT_PERM_READ, _AM_SSHOP_CAT_PERM_READ_DSC);

Arguments

  • perm_name string - <p>name of the permission</p>
  • caption string - <p>caption of the control that will be displayed in the form</p>
  • description string - <p>description of the control that will be displayed in the form</p>

setGrantedObjectsCriteria

mixed icms_ipf_Handler::setGrantedObjectsCriteria(\obj criteria, \str perm_name)

Arguments

  • criteria obj
  • perm_name str

getCalculatedInfo

array icms_ipf_Handler::getCalculatedInfo(array field_func, \icms_db_criteria_Element criteria, bool debug)

Runs precalculated info

Arguments

getObjectsD

array icms_ipf_Handler::getObjectsD(\icms_db_criteria_Element criteria, bool id_as_key, bool as_object, mixed sql)

retrieve objects with debug mode - so will show the query

Arguments

  • criteria icms_db_criteria_Element - <p>Criteria conditions to be met</p>
  • id_as_key bool - <p>use the ID as key for the array?</p>
  • as_object bool - <p>return an array of objects?</p>
  • sql mixed

getObjects

array icms_ipf_Handler::getObjects(\icms_db_criteria_Element criteria, bool id_as_key, bool as_object, mixed sql, mixed debug)

retrieve objects from the database

Arguments

  • criteria icms_db_criteria_Element - <p>Criteria conditions to be met</p>
  • id_as_key bool - <p>use the ID as key for the array?</p>
  • as_object bool - <p>return an array of objects?</p>
  • sql mixed
  • debug mixed

getFields

string icms_ipf_Handler::getFields(bool getcurrent, bool forSQL)

Gets all fields for SQL

Arguments

  • getcurrent bool - <p>Get current fields</p>
  • forSQL bool - <p>Returns fields result as for SQL</p>

convertResultSet

array icms_ipf_Handler::convertResultSet(object result, bool id_as_key, bool as_object)

Convert a database resultset to a returnable array

Arguments

  • result object - <p>database resultset</p>
  • id_as_key bool - <ul> <li>should NOT be used with joint keys</li> </ul>
  • as_object bool

convertResultSet_RAWWithKey

mixed icms_ipf_Handler::convertResultSet_RAWWithKey(mixed result, mixed key)

Arguments

  • result mixed
  • key mixed

convertResultSet_RAW

mixed icms_ipf_Handler::convertResultSet_RAW(mixed result)

Arguments

  • result mixed

convertResultSet_ObjectWithKey

mixed icms_ipf_Handler::convertResultSet_ObjectWithKey(mixed result, mixed key, mixed as_object)

Arguments

  • result mixed
  • key mixed
  • as_object mixed

getSkipKeys

array icms_ipf_Handler::getSkipKeys()

Get array with keys for skipping

getImageUrl

mixed icms_ipf_Handler::getImageUrl()

getImagePath

mixed icms_ipf_Handler::getImagePath()

convertResultSet_Object

mixed icms_ipf_Handler::convertResultSet_Object(mixed result, mixed as_object)

Arguments

  • result mixed
  • as_object mixed

getD

\icms_ipf_Object|bool icms_ipf_Handler::getD(string|float|int id, bool as_object)

retrieve object

Arguments

  • id string|float|int - <p>ID of the object - or array of ids for joint keys. Joint keys MUST be given in the same order as in the constructor</p>
  • as_object bool - <p>whether to return an object or an array</p>

get

mixed icms_core_ObjectHandler::get(int int_id)

gets a value object

Arguments

  • int_id int

create

mixed icms_core_ObjectHandler::create()

creates a new object

getListD

array icms_ipf_Handler::getListD(object criteria, int limit, int start)

Arguments

  • criteria object
  • limit int
  • start int

getList

array icms_ipf_Handler::getList(\icms_db_criteria_Element criteria, int limit, int start, mixed debug)

Retrieve a list of objects as arrays - DON'T USE WITH JOINT KEYS

Arguments

  • criteria icms_db_criteria_Element - <p>Criteria conditions to be met</p>
  • limit int - <p>Max number of objects to fetch</p>
  • start int - <p>Which record to start at</p>
  • debug mixed

getCustomList

array icms_ipf_Handler::getCustomList(string keyName, string keyValue, \icms_db_criteria_Element criteria, int limit, int start, bool debug)

Retrieve a list of objects as arrays - DON'T USE WITH JOINT KEYS

Arguments

  • keyName string - <p>Key name</p>
  • keyValue string - <p>Key value</p>
  • criteria icms_db_criteria_Element - <p>Criteria conditions to be met</p>
  • limit int - <p>Max number of objects to fetch</p>
  • start int - <p>Which record to start at</p>
  • debug bool - <p>Debug mode?</p>

getIdentifierName

mixed icms_ipf_Handler::getIdentifierName(bool withprefix)

Arguments

  • withprefix bool

insertD

mixed icms_ipf_Handler::insertD(\obj obj, bool force, bool checkObject, bool debug)

Arguments

  • obj obj
  • force bool
  • checkObject bool
  • debug bool

save

bool icms_ipf_Handler::save(mixed obj_instances, bool force)

Saves one or many items

Arguments

  • obj_instances mixed
  • force bool - <p>Force saving?</p>

executeEvent

mixed icms_ipf_Handler::executeEvent(string event, mixed executeEventObj)

Execute the function associated with an event This method will check if the function is available

Arguments

  • event string - <p>name of the event</p>
  • executeEventObj mixed

generateInsertSQL

string icms_ipf_Handler::generateInsertSQL(mixed data)

Generate insert SQL by data

Arguments

  • data mixed

generateUpdateSQL

string|null icms_ipf_Handler::generateUpdateSQL(mixed data)

Generates update SQL

Arguments

  • data mixed

insert

mixed icms_core_ObjectHandler::insert(object object)

insert/update object

Arguments

  • object object

getObjectsAsArray

mixed icms_ipf_Handler::getObjectsAsArray(\arr arrayObjects)

Arguments

  • arrayObjects arr

doFastChange

array icms_ipf_Handler::doFastChange(mixed id, string field, \numeric value, string math_func, bool force, bool debug)

Execute fast change with data

Arguments

  • id mixed
  • field string
  • value numeric
  • math_func string
  • force bool
  • debug bool

query

array icms_ipf_Handler::query(string sql, \icms_db_criteria_Element criteria, bool force, bool debug)

query the database with the constructed $criteria object

Arguments

  • sql string - <p>The SQL Query</p>
  • criteria icms_db_criteria_Element - <p>Criteria conditions to be met</p>
  • force bool - <p>Force the query?</p>
  • debug bool - <p>Turn Debug on?</p>

getCount

int icms_ipf_Handler::getCount(\icms_db_criteria_Element criteria)

count objects matching a condition

Arguments

disableEvent

mixed icms_ipf_Handler::disableEvent(\arr|\str event)

Arguments

  • event arr|str

getIdsFromObjectsAsArray

mixed icms_ipf_Handler::getIdsFromObjectsAsArray(array objectsAsArray)

Build an array containing all the ids of an array of objects as array

Arguments

  • objectsAsArray array - <p>array of icms_ipf_Object</p>

updateAll

bool icms_ipf_Handler::updateAll(string fieldname, string fieldvalue, \icms_db_criteria_Element criteria, mixed force)

Change a value for objects with a certain criteria

Arguments

  • fieldname string - <p>Name of the field</p>
  • fieldvalue string - <p>Value to write</p>
  • criteria icms_db_criteria_Element - <p>Criteria</p>
  • force mixed

deleteAll

bool icms_ipf_Handler::deleteAll(\icms_db_criteria_Element criteria, bool quick)

delete all objects meeting the conditions

Arguments

  • criteria icms_db_criteria_Element - <p>Criteria with conditions to meet</p>
  • quick bool - <p>Do not load object on deletion?</p>

delete

mixed icms_core_ObjectHandler::delete(object object)

delete object from database

Arguments

  • object object

deleteGrantedPermissions

bool icms_ipf_Handler::deleteGrantedPermissions(object obj)

delete granted permssions for an object

Arguments

  • obj object - <p>optional</p>

getPermissions

mixed icms_ipf_Handler::getPermissions()

Accessor for the permissions array property

getModuleInfo

mixed icms_ipf_Handler::getModuleInfo()

getModuleConfig

mixed icms_ipf_Handler::getModuleConfig()

getModuleItemString

mixed icms_ipf_Handler::getModuleItemString()

updateCounter

mixed icms_ipf_Handler::updateCounter(object)

Arguments

  • object mixed

enableUpload

mixed icms_ipf_Handler::enableUpload(\unknown_type allowedMimeTypes, \unknown_type maxFileSize, \unknown_type maxWidth, \unknown_type maxHeight)

Arguments

  • allowedMimeTypes unknown_type
  • maxFileSize unknown_type
  • maxWidth unknown_type
  • maxHeight unknown_type
Clone this wiki locally