Site Tools


Hotfix release available: 2024-02-06a "Kaos". upgrade now! [55.1] (what's this?)
New release available: 2024-02-06 "Kaos". upgrade now! [55] (what's this?)
Hotfix release available: 2023-04-04a "Jack Jackrum". upgrade now! [54.1] (what's this?)
New release available: 2023-04-04 "Jack Jackrum". upgrade now! [54] (what's this?)
Hotfix release available: 2022-07-31b "Igor". upgrade now! [53.1] (what's this?)
Hotfix release available: 2022-07-31a "Igor". upgrade now! [53] (what's this?)
New release available: 2022-07-31 "Igor". upgrade now! [52.2] (what's this?)
New release candidate 2 available: rc2022-06-26 "Igor". upgrade now! [52.1] (what's this?)
New release candidate available: 2022-06-26 "Igor". upgrade now! [52] (what's this?)
Hotfix release available: 2020-07-29a "Hogfather". upgrade now! [51.4] (what's this?)
internal:dev_w:e1_common_functions

Functions in exp_sp_core.inc

Function NameArgument(s)Description
formatAmount()$amount, $includePostFixSymbol, $currencyCode, $languageCode, $decimals, $dec_point, $thousands_sepFormats an amount string to specified format prefixing and optionally postfixing the currency prefix and postfix symbols respectively. Default values of the various arguments are as follows: $includePostFixSymbol = false, $currencyCode = 'cre_sys_crn_usd', $languageCode = 'cre_sys_lng_eng', $decimals = 2, $dec_point = '.', $thousands_sep = ','
getEntityIdFromNodeId()$nodeIdMaps node id ($nodeId) to entity id from table slt_node_learning_activity. Returns the entity id.
formatDuration()$durationInMinFormats duration ($durationInMin) specified in minutes to hours and minutes. e.g. 61 ⇒ “1 hour 1 minute”.
now() Returns current date and time in the same format as was returned by MySQL now(). e.g. 2011-08-05 17:20:50.
dateTimeStrToUSShort()$dateTimeString, $year4(boolean), $showTime(boolean), $time24(boolean), $showSeconds(boolean)Converts date/datetime to US short date/datetime notation e.g. Converts 2011-09-19 13:30:00 to 09/19/2011 13:30 when $year4 = true, $showTime = true, $time24= true, $showSeconds == false. $time24 = true will turn time to show in 24hrs format. $time24 = false will turn time to show in 12hrs am/pm format. $year4 = true will show year in 4 digit format. $year4 = false will show year in two digit format. Use $showTime = true/false to show/hide time. Use $showSeconds = true/false to show/hide seconds. This function also accepts UNIX timestamps in $dateTimeString. Prefix UNIX timestamp with @. e.g. '@1309943773'
convertDBDateToDBDatetime()$date_field, $date_field_endFunction to convert DB date $date_field (date only) to DB datetime format. When $date_field_end is 1 time 23:59:59 is added. Otherwise, time 00:00:00 is added.
subStringBtwTwoStrings()$string, $precedeString, $succeedStringReturns the first substring from a $string which is preceded by $precedeString and succeeded by $succeedString in the string. Returns FALSE (boolean) if either $precedeString or $succeedString is not present in the $string. If $precedeString is null or null string, assumes start of string. If $succeedString is null or null string, assumes end of string.
getProfileItemIdFromCode()$itemCodeGiven an item code ($itemCode), returns the item's id from slt_profile_list_items table. Assumes only 1 record would be present matching the item code in slt_profile_list_items. Return null if a record for item code does not exist.
getProfileSettingsColumn()$entityType, $entityId, $colNameFetch profile settings in a column ($colName) of slt_entity_profile_mapping table for an entity specified by its type ($entityType) and id ($entityId)
getCountries() Fetch countries list (country code and name) from slt_country table.
getDeliveryTypeList() Fetch active class delivery types (code and name) from slt_profile_list_items table.
getProfileListItemName()$itemCode, $languageCodeReplaces MySQL DB stored function slf_get_profile_list_name(). Returns the profile list item name for the profile list item code ($itemCode) from slt_profile_list_items table. If not specified, $languageCode detaults to 'cre_sys_lng_eng'
getCCAuthCode()$orderIdReturns a credit card purchase AuthCode for a confirmed order ($orderId). Replaces MySQL DB stored function slf_get_cc_authcode().
getPaymentMethodName()$lnrOrderType, $returnTypeBased on $returnType ('name' or 'code') returns profile name or profile code for learner order type string ($lnrOrderType - 'check', 'po', 'credit', 'bank_transfer', 'other', 'Zero Cost'). Replaces MySQL DB stored function slf_get_paymentmethod_name().
getPaymentStatusName()$paymentStatus, $returnTypeBased on $returnType ('name' or 'code') returns profile name or profile code for payment status string ($paymentStatus - 'completed', 'pending', 'payment_received', 'canceled'). Replaces MySQL DB stored function slf_get_paymentstatus_name().
convertNullValToNullStr()$stringReturns a null string if $string is null, otherwise returns $string.
getCurrencyDetails()$currencyCode, $languageCodeFetches currency_prefix, currency_postfix, name and id for $currencyCode from slt_profile_list_items table. $languageCode defaults to 'cre_sys_lng_eng'
getColumnNameForProfileField()$categoryName, $profileFieldNameReplaces MySQL function slf_profileconfig_col_sel(). Returns column name for the $profileFieldName.
getLocationDetails()$locationId, $fieldsFetches specified column values ($fields) of a location from slt_location table.
getPersonDetails()$personId, $fieldsFetches specified details ($fields) of a person from slt_person table.
getOrganizationDetails()$organizationId, $fieldsFetches specified details ($fields) of an organization from slt_organization table.
addFilterForLoggedInUserRole()$selectStmt, $aliasEntityProfileMappingTableAdds to the SQL query ($selectStmt, passed by reference) the condition to filter records by the logged in user's profile.
descController()$keyword, $cStringReturn Short and Long Description ($cString) truncated to the number of characters required; the number of characters required is determined from the $keyword which currently can be 'MOST VIEWED' or 'FEATURED COURSES' or 'NEW COURSES'.
titleController()$keyword, $cStringReturns Title ($cString) truncated to the number of characters required; the number of characters required is determined from the $keyword which currently can be 'MOST VIEWED' or 'FEATURED COURSES' or 'NEW COURSES'.

Functions in exp_sp_learning.inc

Function NameArgument(s)Description
enrollmentExistsCheck()$personId, $objectId, $objectTypeReplaces MySQL DB stored function slf_exists_check()
getEnrollmentRegistrationStatus()$personId, $classIdGet a person's ($personId) current enrollment registration status to a class ($classId) from slt_enrollment. Ignores records with cancelled statuses: lrn_crs_reg_can, lrn_crs_reg_rsc.
courseConflictCheck()$personId, $courseId, $objectId, $objectTypeReplaces MySQL DB stored function slf_course_conflict_check(). Checks whether the user has already enrolled to another class of the same course. Considers business rule for allowing multiple enrollments in the same course.
getCountOtherRegisteredClassesOfCourse()$personId, $courseId, $classId Returns a count of registered classes ('lrn_crs_reg_cnf', 'lrn_crs_reg_rsv', 'lrn_crs_reg_wtl', 'lrn_crs_reg_ppm') of a course ($courseId) by a person ($personId) other than the specified class ($classId)
enrollmentsConflictCheck()$personId, $objectId, $objectTypeReplaces MySQL DB stored function slf_conflict_check(). Checks whether the class ($objectId) of type 'Class' ($objectType) timings are conflicting with timings of any of the classes that the person ($personId) has already enrolled
getDateSpanOfClass()$classIdReturns MIN(start_date) and MAX(end_date) for a class assuming multiple sessions are allowed in a class. Currently a class can have only one session, so MIN (start_date) and MAX(end_date) is same as the class start and end dates respectively (stored in slt_course_class_session table.)
getClassEnrollmentCountForRegistrationStatuses()$courseId, $classId, $regStatusesListReturns count of enrollment records for a class ($courseId, $classId) from slt_enrollment table matching the registration statuses ($regStatusesList array). e.g. $regStatusesList = array('lrn_crs_reg_cnf', 'lrn_crs_reg_ppm', 'lrn_crs_reg_rsv');
getClassMaxCapacity()$courseId, $classIdReturns the max seat capacity of a class from slt_course_class_session table.
waitListCheck()$courseId, $classIdReplaces MySQL DB stored function slf_waitlist_check(). Returns 0 if class max capacity is not exceeded or there is no max capacity restriction. Else, returns the waitlist number of the new enrollment.
getClassWaitlistCapacity()$courseId, $classIdReturns the waitlist capacity of a class from slt_course_class_session table.
getWaitListAvailable()$courseId, $classIdReplaces MySQL DB stored function slf_get_waitlist_available().
getClassDeliveryType()$classId, $returnTypeBased on the $returnType ('Long' or 'Short') return the long or short name for the class' ($classId) delivery type. Replaces MySQL DB stored function slf_get_delivery_type().
insertNotification()$notificationType, $objectId1, $objectId2, $userId, $updateUserIdInserts notification in slt_notification table. Replaces slp_notification_ins().
getAvailableSeats()$classIdGet number of available seats for class $classId.
getSearchAutoComplete() Get results for Search autocomplete.
getLocationAutoComplete() Get results for Location autocomplete.
getFacilityContactEmail()$locationIdFetches facility's (using $locationId) contact e-mail. Code was in slp_notification_ins()
getClassesInOrder()$orderIdFetches all classes in order $orderId that are not in lrn_crs_reg_rsc status.
getUCOrderIdFromOrderId()$orderIdFetches Ubercart order id from slt_order table for an order $orderId.
getClassLaunchUrl()$courseId, $classIdFetches launch URL for a class ($courseId, $classId) from slt_course_content_mapper table.
enrollUserToClass()$userId, $orderId, $userFullName, $courseId, $classId, $forceRegister, $updateUserId, $cartFlagEnrolls a user to a class. Replaces MySQL DB stored procedure slp_enrollmentlnrassignment_ins().
getWaitlistUsersOfClass()$courseId, $classIdFetches all the waitlist users of a class ($courseId, $classId) as an associative array (enrollment_id1 ⇒ user_id1, enrollment_id2 ⇒ user_id2, …)
getClassTitle()$classIdFetches the title of a class ($classId)
isActiveClass()$course_id, $class_id - Returns true only when both the course ($course_id) and class ($class_id) are active (status = lrn_crs_sts_atv). Also, the class must belong to the course.
getLocationIdOfClass()$courseId, $classIdFetches location id of a class from slt_course_class_session_table
insertOrderItem()$orderId, $courseId, $classId, $userId, $programId, $programType, $createdBy, $custom0, $custom1, $custom2, $custom3, $custom4Inserts order item record in slt_order_items table. Replaces MySQL DB stored procedure slp_order_items_ins().
getDeliverTypeImageClass()$deliverytypecodeReturns the image class based on the delivery type code.

Functions in exp_sp_commerce.inc

Function NameArgument(s)Description
getTaxableStates()$country, $deliveryType, $returnTypeBased on $returnType ('State' or 'Country'), returns a comma separated list of either states or non-US and non-CA countries that levy taxes for a $deliveryType. Replaces stored procedure slp_taxable_states_sel().
hasTaxExemption()$organizationId, $profileMapColumnNameGet (Yes/No) whether the organization has exemption from tax?
getCountryVATNumber()$countryCodeFetches a country's VAT number
getProductCodeId()$countryCode, $stateCodeFetches product code id from slt_tax for country and state.
getPriceOfClass()$courseId, $classIdFetches price of a class from slt_course_class.

Functions in exp_sp_administration.inc

Function NameArgument(s)Description
exp_ctools_modal_multi_ajaxonly_forms_display()$formInfoList {type: array ( array ( 'id' ⇒ <form id>, 'title' ⇒ <title to be displayed for the form> ), …)}, $argsList {type: array of strings}exp_ctools_modal_multi_ajaxonly_forms_display() displays 1 or more forms in a ctools modal, each having its own status area below its title. All submit buttons in each form must be ajax enabled, i.e. have #ajax property defined. See exp_sp_administration_organization.module (single form in modal) and exp_sp_administration_usser.module (three forms in modal) to understand how to use this function
internal/dev_w/e1_common_functions.txt · Last modified: 2022/06/14 10:16 (external edit)