idx
int64
0
60.3k
question
stringlengths
101
6.21k
target
stringlengths
7
803
54,700
protected function getListBookmark ( ) { $ conditions = $ this -> query_filter ; $ conditions [ 'user_id' ] = $ this -> uid ; $ conditions [ 'limit' ] = $ this -> data_limit ; return ( array ) $ this -> bookmark -> getList ( $ conditions ) ; }
Returns an array of bookmarks
54,701
public function listReportPayment ( ) { $ this -> setTitleListReportPayment ( ) ; $ this -> setBreadcrumbListReportPayment ( ) ; $ this -> setFilterListReportPayment ( ) ; $ this -> setPagerListReportPayment ( ) ; $ this -> setData ( 'methods' , ( array ) $ this -> getListReportPayment ( ) ) ; $ this -> outputListReportPayment ( ) ; }
Displays the payment methods overview page
54,702
protected function updateNumPages ( ) { $ this -> pages = ( $ this -> limit == 0 ) ? 0 : ( int ) ceil ( $ this -> total / $ this -> limit ) ; return $ this ; }
Updates the current number of pages
54,703
public function getPages ( ) { $ pages = array ( ) ; if ( $ this -> pages <= 1 ) { return array ( ) ; } if ( $ this -> pages <= $ this -> limit_pages ) { for ( $ i = 1 ; $ i <= $ this -> pages ; $ i ++ ) { $ pages [ ] = $ this -> createPage ( $ i , $ i == $ this -> current ) ; } return $ pages ; } $ num_adjacents = ( int ) floor ( ( $ this -> limit_pages - 3 ) / 2 ) ; if ( $ this -> current + $ num_adjacents > $ this -> pages ) { $ sliding_start = $ this -> pages - $ this -> limit_pages + 2 ; } else { $ sliding_start = $ this -> current - $ num_adjacents ; } if ( $ sliding_start < 2 ) { $ sliding_start = 2 ; } $ sliding_end = $ sliding_start + $ this -> limit_pages - 3 ; if ( $ sliding_end >= $ this -> pages ) { $ sliding_end = $ this -> pages - 1 ; } $ pages [ ] = $ this -> createPage ( 1 , $ this -> current == 1 ) ; if ( $ sliding_start > 2 ) { $ pages [ ] = $ this -> createPageEllipsis ( ) ; } for ( $ i = $ sliding_start ; $ i <= $ sliding_end ; $ i ++ ) { $ pages [ ] = $ this -> createPage ( $ i , $ i == $ this -> current ) ; } if ( $ sliding_end < $ this -> pages - 1 ) { $ pages [ ] = $ this -> createPageEllipsis ( ) ; } $ pages [ ] = $ this -> createPage ( $ this -> pages , $ this -> current == $ this -> pages ) ; return $ pages ; }
Get an array of paginated page data
54,704
public function getCurrentPageLastItem ( ) { $ first = $ this -> getCurrentPageFirstItem ( ) ; if ( empty ( $ first ) ) { return 0 ; } $ last = $ first + $ this -> limit - 1 ; if ( $ last > $ this -> total ) { return $ this -> total ; } return $ last ; }
Returns the last item for the current page
54,705
public function getCurrentPageFirstItem ( ) { $ first = ( $ this -> current - 1 ) * $ this -> limit ; if ( $ first > $ this -> total ) { return 0 ; } return $ first ; }
Returns the first item for the current page
54,706
public function build ( array $ data = array ( ) ) { $ data += array ( 'page' => 1 , 'limit' => 0 , 'total' => 0 , 'mini' => false , 'max_pages' => 10 , 'query' => array ( ) ) ; $ this -> setPage ( $ data [ 'page' ] ) -> setPerPage ( $ data [ 'limit' ] ) -> setTotal ( $ data [ 'total' ] ) -> setMaxPages ( $ data [ 'max_pages' ] ) -> setUrlPattern ( '?' . urldecode ( http_build_query ( $ data [ 'query' ] ) ) ) ; return $ this ; }
Set up pager from an array of parameters
54,707
public function editSettings ( ) { $ this -> setTitleEditSettings ( ) ; $ this -> setBreadcrumbEditSettings ( ) ; $ this -> setData ( 'settings' , $ this -> getSettings ( ) ) ; $ this -> setData ( 'timezones' , gplcart_timezones ( ) ) ; $ this -> submitEditSettings ( ) ; $ this -> outputEditSettings ( ) ; }
Displays the edit settings page
54,708
protected function validateEditSettings ( ) { $ this -> setSubmitted ( 'settings' ) ; if ( ! $ this -> getSubmitted ( 'cron_key' ) ) { $ this -> setSubmitted ( 'cron_key' , gplcart_string_random ( ) ) ; } return ! $ this -> hasErrors ( ) ; }
Validates submitted settings
54,709
public function get ( $ code ) { $ result = null ; $ this -> hook -> attach ( 'language.get.before' , $ code , $ result , $ this ) ; if ( isset ( $ result ) ) { return ( array ) $ result ; } $ list = $ this -> getList ( ) ; $ result = isset ( $ list [ $ code ] ) ? $ list [ $ code ] : array ( ) ; $ this -> hook -> attach ( 'language.get.after' , $ code , $ result , $ this ) ; return ( array ) $ result ; }
Returns a language
54,710
public function getIso ( $ code = null ) { $ data = ( array ) gplcart_config_get ( GC_FILE_CONFIG_LANGUAGE ) ; if ( isset ( $ code ) ) { return isset ( $ data [ $ code ] ) ? ( array ) $ data [ $ code ] : array ( ) ; } return $ data ; }
Returns an array of common languages with their English and native names
54,711
public static function tag ( $ tag , $ text = '' , array $ attributes = NULL ) { $ autoClose = array ( 'input' , 'br' , 'hr' , 'img' , 'col' , 'area' , 'base' , 'link' , 'meta' , 'frame' , 'param' ) ; return "<$tag" . self :: attributes ( $ attributes ) . ( in_array ( $ tag , $ autoClose ) ? ' />' : ">$text</$tag>" ) ; }
Create an HTML tag
54,712
public static function select ( $ name , array $ options , $ selected = NULL , array $ attributes = NULL ) { $ h = '' ; foreach ( $ options as $ k => $ v ) { $ a = array ( 'value' => $ k ) ; if ( $ selected AND in_array ( $ k , ( array ) $ selected ) ) { $ a [ 'selected' ] = 'selected' ; } $ h .= self :: tag ( 'option' , $ v , $ a ) ; } if ( ! $ attributes ) { $ attributes = array ( ) ; } return self :: tag ( 'select' , $ h , $ attributes + array ( 'name' => $ name ) ) ; }
Auto creates a form select dropdown from the options given .
54,713
public function editUserRegister ( ) { $ this -> controlAccessUserRegister ( ) ; $ this -> setTitleEditUserRegister ( ) ; $ this -> setBreadcrumbEditUserRegister ( ) ; $ this -> submitUserRegister ( ) ; $ this -> setData ( 'password_limit' , $ this -> user -> getPasswordLength ( ) ) ; $ this -> outputEditUserRegister ( ) ; }
Displays the user registration page
54,714
protected function validateUserRegister ( ) { $ this -> setSubmitted ( 'user' , null , false ) ; $ this -> filterSubmitted ( array ( 'email' , 'password' , 'name' ) ) ; $ this -> setSubmitted ( 'store_id' , $ this -> store_id ) ; $ this -> validateComponent ( 'user' ) ; return ! $ this -> hasErrors ( ) ; }
Validates an array of submitted data during registration
54,715
public function cart ( array & $ submitted , array $ options = array ( ) ) { $ this -> options = $ options ; $ this -> submitted = & $ submitted ; $ this -> validateCart ( ) ; $ this -> validateStoreId ( ) ; $ this -> validateProductCart ( ) ; $ this -> validateSkuCart ( ) ; $ this -> validateUserCartId ( ) ; $ this -> validateOrderCart ( ) ; $ this -> validateQuantityCart ( ) ; $ this -> validateOptionsCart ( ) ; $ this -> validateLimitCart ( ) ; $ this -> validateData ( ) ; $ this -> unsetSubmitted ( 'update' ) ; return $ this -> getResult ( ) ; }
Performs full cart data validation
54,716
protected function validateCart ( ) { $ id = $ this -> getUpdatingId ( ) ; if ( $ id === false ) { return null ; } $ data = $ this -> cart -> get ( $ id ) ; if ( empty ( $ data ) ) { $ this -> setErrorUnavailable ( 'update' , $ this -> translation -> text ( 'Cart' ) ) ; return false ; } $ this -> setUpdating ( $ data ) ; return true ; }
Validates a cart item to be updated
54,717
protected function validateSkuCart ( ) { if ( $ this -> isError ( 'store_id' ) ) { return null ; } $ field = 'sku' ; $ value = $ this -> getSubmitted ( $ field ) ; if ( ! isset ( $ value ) ) { return null ; } $ label = $ this -> translation -> text ( 'SKU' ) ; if ( empty ( $ value ) ) { $ this -> setErrorRequired ( $ field , $ label ) ; return false ; } $ store_id = $ this -> getSubmitted ( 'store_id' ) ; $ product = $ this -> product -> getBySku ( $ value , $ store_id ) ; if ( empty ( $ product [ 'product_id' ] ) ) { $ this -> setErrorUnavailable ( $ field , $ label ) ; return false ; } $ this -> setSubmitted ( 'product' , $ product ) ; return true ; }
Validates a cart item SKU
54,718
protected function validateOrderCart ( ) { $ field = 'order_id' ; $ value = $ this -> getSubmitted ( $ field ) ; if ( empty ( $ value ) ) { return null ; } $ label = $ this -> translation -> text ( 'Order' ) ; if ( ! is_numeric ( $ value ) ) { $ this -> setErrorNumeric ( $ field , $ label ) ; return false ; } $ order = $ this -> order -> get ( $ value ) ; if ( empty ( $ order [ 'order_id' ] ) ) { $ this -> setErrorUnavailable ( $ field , $ label ) ; return false ; } return true ; }
Validates an order ID
54,719
protected function validateQuantityCart ( ) { $ field = 'quantity' ; if ( $ this -> isExcluded ( $ field ) ) { return null ; } $ value = $ this -> getSubmitted ( $ field ) ; if ( ! isset ( $ value ) ) { if ( $ this -> isUpdating ( ) ) { return null ; } $ value = 1 ; } $ label = $ this -> translation -> text ( 'Quantity' ) ; if ( ! is_numeric ( $ value ) ) { $ this -> setErrorNumeric ( $ field , $ label ) ; return false ; } if ( strlen ( $ value ) > 2 ) { $ this -> setErrorLengthRange ( $ field , $ label , 1 , 2 ) ; return false ; } return true ; }
Validates cart item quantity
54,720
protected function validateLimitCart ( ) { if ( $ this -> isError ( ) ) { return null ; } $ admin = $ this -> getSubmitted ( 'admin' ) ; $ product = $ this -> getSubmitted ( 'product' ) ; if ( ! empty ( $ admin ) || empty ( $ product ) ) { return null ; } $ sku = $ this -> getSubmitted ( 'sku' ) ; $ user_id = $ this -> getSubmitted ( 'user_id' ) ; $ store_id = $ this -> getSubmitted ( 'store_id' ) ; $ quantity = $ this -> getSubmitted ( 'quantity' ) ; $ increment = $ this -> getSubmitted ( 'increment' , true ) ; $ stock = $ this -> getSubmitted ( 'stock' , $ product [ 'stock' ] ) ; $ expected_quantity_sku = $ quantity ; $ existing_quantity = $ this -> cart -> getQuantity ( array ( 'user_id' => $ user_id , 'store_id' => $ store_id ) ) ; if ( ! empty ( $ increment ) && isset ( $ existing_quantity [ 'sku' ] [ $ sku ] ) ) { $ expected_quantity_sku += $ existing_quantity [ 'sku' ] [ $ sku ] ; } if ( $ product [ 'subtract' ] && $ expected_quantity_sku > $ stock ) { $ error = $ this -> translation -> text ( 'Too low stock level' ) ; $ this -> setError ( 'quantity' , $ error ) ; return false ; } $ limit_sku = $ this -> cart -> getLimits ( 'sku' ) ; $ limit_item = $ this -> cart -> getLimits ( 'item' ) ; if ( ! empty ( $ limit_item ) && ! isset ( $ existing_quantity [ 'sku' ] [ $ sku ] ) && count ( $ existing_quantity [ 'sku' ] ) >= $ limit_item ) { $ error = $ this -> translation -> text ( 'Please no more than @num items' , array ( '@num' => $ limit_item ) ) ; $ this -> setError ( 'quantity' , $ error ) ; return false ; } if ( ! empty ( $ limit_sku ) && $ expected_quantity_sku > $ limit_sku ) { $ error = $ this -> translation -> text ( 'Please no more than @num items per SKU' , array ( '@num' => $ limit_sku ) ) ; $ this -> setError ( 'quantity' , $ error ) ; return false ; } return true ; }
Validates cart limits
54,721
protected function validateOptionsCart ( ) { $ product = $ this -> getSubmitted ( 'product' ) ; if ( empty ( $ product ) || $ this -> isError ( ) ) { return null ; } $ options = array_filter ( ( array ) $ this -> getSubmitted ( 'options' ) ) ; if ( empty ( $ options ) ) { $ this -> setSubmitted ( 'options' , array ( ) ) ; $ this -> setSubmitted ( 'sku' , $ product [ 'sku' ] ) ; $ this -> setSubmitted ( 'stock' , $ product [ 'stock' ] ) ; return true ; } $ combination_id = $ this -> sku -> getCombinationId ( $ options , $ product [ 'product_id' ] ) ; if ( empty ( $ product [ 'combination' ] [ $ combination_id ] [ 'status' ] ) ) { $ error = $ this -> translation -> text ( 'Invalid combination' ) ; $ this -> setError ( 'options' , $ error ) ; return false ; } $ this -> setSubmitted ( 'options' , $ options ) ; $ this -> setSubmitted ( 'combination_id' , $ combination_id ) ; $ this -> setSubmitted ( 'sku' , $ product [ 'combination' ] [ $ combination_id ] [ 'sku' ] ) ; $ this -> setSubmitted ( 'stock' , $ product [ 'combination' ] [ $ combination_id ] [ 'stock' ] ) ; return true ; }
Validates products cart options
54,722
public function address ( array & $ submitted , array $ options = array ( ) ) { $ this -> options = $ options ; $ this -> submitted = & $ submitted ; $ this -> validateAddress ( ) ; $ this -> validateCountryAddress ( ) ; $ this -> validateStateAddress ( ) ; $ this -> validateCityAddress ( ) ; $ this -> validateTypeAddress ( ) ; $ this -> validateFieldsAddress ( ) ; $ this -> validateUserIdAddress ( ) ; $ this -> validateData ( ) ; $ this -> unsetSubmitted ( 'update' ) ; return $ this -> getResult ( ) ; }
Performs full address data validation
54,723
protected function validateAddress ( ) { $ id = $ this -> getUpdatingId ( ) ; if ( $ id === false ) { return null ; } $ data = $ this -> address -> get ( $ id ) ; if ( empty ( $ data ) ) { $ this -> setErrorUnavailable ( 'update' , $ this -> translation -> text ( 'Address' ) ) ; return false ; } $ this -> setUpdating ( $ data ) ; return true ; }
Validates an address to be updated
54,724
protected function validateUserIdAddress ( ) { $ field = 'user_id' ; if ( $ this -> isExcluded ( $ field ) ) { return null ; } $ value = $ this -> getSubmitted ( $ field ) ; if ( $ this -> isUpdating ( ) && ! isset ( $ value ) ) { $ this -> unsetSubmitted ( $ field ) ; return null ; } $ label = $ this -> translation -> text ( 'User' ) ; if ( empty ( $ value ) || mb_strlen ( $ value ) > 255 ) { $ this -> setErrorLengthRange ( $ field , $ label ) ; return false ; } if ( ! is_numeric ( $ value ) ) { return true ; } $ user = $ this -> user -> get ( $ value ) ; if ( empty ( $ user ) ) { $ this -> setErrorUnavailable ( $ field , $ label ) ; return false ; } return true ; }
Validates a user Id
54,725
protected function validateStateAddress ( ) { $ field = 'state_id' ; $ value = $ this -> getSubmitted ( $ field ) ; if ( ! isset ( $ value ) ) { $ this -> unsetSubmitted ( $ field ) ; return null ; } $ label = $ this -> translation -> text ( 'Country state' ) ; $ format = $ this -> getCountryFormatAddress ( ) ; if ( empty ( $ value ) && ! empty ( $ format [ 'state_id' ] [ 'required' ] ) ) { $ this -> setErrorRequired ( $ field , $ label ) ; return false ; } if ( ! is_numeric ( $ value ) ) { $ this -> setErrorNumeric ( $ field , $ label ) ; return false ; } if ( empty ( $ value ) ) { return true ; } $ state = $ this -> state -> get ( $ value ) ; if ( empty ( $ state ) ) { $ this -> setErrorUnavailable ( $ field , $ label ) ; return false ; } return true ; }
Validates a country state
54,726
protected function validateCityAddress ( ) { $ field = 'city_id' ; if ( $ this -> isExcluded ( $ field ) || $ this -> isError ( 'country' ) ) { return null ; } $ value = $ this -> getSubmitted ( $ field ) ; if ( $ this -> isUpdating ( ) && ! isset ( $ value ) ) { $ this -> unsetSubmitted ( $ field ) ; return null ; } $ label = $ this -> translation -> text ( 'City' ) ; $ format = $ this -> getCountryFormatAddress ( ) ; if ( empty ( $ value ) && ! empty ( $ format [ 'city_id' ] [ 'required' ] ) ) { $ this -> setErrorRequired ( $ field , $ label ) ; return false ; } if ( is_numeric ( $ value ) ) { if ( $ this -> city -> get ( $ value ) ) { return true ; } $ this -> setErrorUnavailable ( $ field , $ label ) ; return false ; } if ( empty ( $ value ) ) { return true ; } if ( mb_strlen ( $ value ) > 255 ) { $ this -> setErrorLengthRange ( $ field , $ label ) ; return false ; } $ country = $ this -> getSubmitted ( 'country' ) ; $ state_id = $ this -> getSubmitted ( 'state_id' ) ; if ( empty ( $ country ) || empty ( $ state_id ) ) { return true ; } $ conditions = array ( 'name' => $ value , 'country' => $ country , 'state_id' => $ state_id ) ; foreach ( ( array ) $ this -> city -> getList ( $ conditions ) as $ city ) { if ( strcasecmp ( $ city [ 'name' ] , $ value ) === 0 ) { $ this -> setSubmitted ( $ field , $ city [ 'city_id' ] ) ; break ; } } return true ; }
Validates a city
54,727
protected function validateTypeAddress ( ) { $ field = 'type' ; $ value = $ this -> getSubmitted ( $ field ) ; if ( ! isset ( $ value ) ) { $ this -> unsetSubmitted ( $ field ) ; return null ; } if ( ! in_array ( $ value , $ this -> address -> getTypes ( ) ) ) { $ this -> setErrorUnavailable ( $ field , $ this -> translation -> text ( 'Type' ) ) ; return false ; } return true ; }
Validates an address type
54,728
protected function validateFieldsAddress ( ) { $ this -> validateFieldAddress ( 'address_1' ) ; $ this -> validateFieldAddress ( 'address_2' ) ; $ this -> validateFieldAddress ( 'phone' ) ; $ this -> validateFieldAddress ( 'middle_name' ) ; $ this -> validateFieldAddress ( 'last_name' ) ; $ this -> validateFieldAddress ( 'first_name' ) ; $ this -> validateFieldAddress ( 'postcode' ) ; $ this -> validateFieldAddress ( 'company' ) ; $ this -> validateFieldAddress ( 'fax' ) ; }
Validates address fields
54,729
protected function validateFieldAddress ( $ field ) { if ( $ this -> isExcluded ( $ field ) || $ this -> isError ( 'country' ) ) { return null ; } $ value = $ this -> getSubmitted ( $ field ) ; if ( $ this -> isUpdating ( ) && ! isset ( $ value ) ) { $ this -> unsetSubmitted ( $ field ) ; return null ; } $ format = $ this -> getCountryFormatAddress ( ) ; if ( empty ( $ format [ $ field ] [ 'required' ] ) ) { return null ; } if ( ! isset ( $ value ) || $ value === '' || mb_strlen ( $ value ) > 255 ) { $ this -> setErrorLengthRange ( $ field , $ format [ $ field ] [ 'name' ] , 1 , 255 ) ; return false ; } return true ; }
Validates an address field associated with the country format
54,730
protected function getCountryFormatAddress ( ) { $ updating = $ this -> getUpdating ( ) ; if ( isset ( $ updating [ 'country_format' ] ) ) { return $ updating [ 'country_format' ] ; } $ field = 'country' ; $ code = $ this -> getSubmitted ( $ field ) ; if ( ! isset ( $ code ) ) { return $ this -> country -> getDefaultFormat ( ) ; } $ country = $ this -> country -> get ( $ code ) ; if ( empty ( $ country [ 'format' ] ) ) { $ this -> setErrorUnavailable ( $ field , $ this -> translation -> text ( 'Country' ) ) ; return array ( ) ; } return $ country [ 'format' ] ; }
Returns the current country format
54,731
public function indexPage ( $ page_id ) { $ this -> setPage ( $ page_id ) ; $ this -> setTitleIndexPage ( ) ; $ this -> setBreadcrumbIndexPage ( ) ; $ this -> setHtmlFilterIndexPage ( ) ; $ this -> setMetaIndexPage ( ) ; $ this -> setData ( 'page' , $ this -> data_page ) ; $ this -> setDataImagesIndexPage ( ) ; $ this -> outputIndexPage ( ) ; }
Displays a page
54,732
protected function setPage ( $ page_id ) { $ this -> data_page = $ this -> page -> get ( $ page_id ) ; if ( empty ( $ this -> data_page ) ) { $ this -> outputHttpStatus ( 404 ) ; } $ this -> controlAccessPage ( ) ; $ this -> preparePage ( $ this -> data_page ) ; }
Sets a page data
54,733
protected function controlAccessPage ( ) { if ( empty ( $ this -> data_page [ 'status' ] ) && ! $ this -> access ( 'page' ) ) { $ this -> outputHttpStatus ( 403 ) ; } if ( $ this -> data_page [ 'store_id' ] != $ this -> store_id ) { $ this -> outputHttpStatus ( 404 ) ; } }
Controls access to the page
54,734
protected function setDataImagesIndexPage ( ) { $ options = array ( 'imagestyle' => $ this -> configTheme ( 'image_style_page' , 5 ) ) ; $ this -> setItemThumb ( $ this -> data_page , $ this -> image , $ options ) ; $ this -> setData ( 'images' , $ this -> render ( 'page/images' , array ( 'page' => $ this -> data_page ) ) ) ; }
Sets the rendered images on the page
54,735
public function login ( array $ data , $ check_password = true ) { $ result = array ( ) ; $ this -> hook -> attach ( 'user.login.before' , $ data , $ check_password , $ result , $ this ) ; if ( ! empty ( $ result ) ) { return ( array ) $ result ; } if ( empty ( $ data [ 'email' ] ) ) { return $ this -> getResultErrorLogin ( ) ; } $ user = $ this -> user -> getByEmail ( $ data [ 'email' ] ) ; if ( empty ( $ user [ 'status' ] ) ) { return $ this -> getResultErrorLogin ( ) ; } if ( $ check_password && ( ! isset ( $ data [ 'password' ] ) || ! $ this -> user -> passwordMatches ( $ data [ 'password' ] , $ user ) ) ) { return $ this -> getResultErrorLogin ( ) ; } $ this -> session -> regenerate ( true ) ; $ this -> session -> set ( 'user' , $ user ) ; $ result = $ this -> getResultLogin ( $ user ) ; $ this -> hook -> attach ( 'user.login.after' , $ data , $ check_password , $ result , $ this ) ; return ( array ) $ result ; }
Logs in a user
54,736
public function logout ( ) { $ result = array ( ) ; $ user = $ this -> user -> get ( $ this -> user -> getId ( ) ) ; $ this -> hook -> attach ( 'user.logout.before' , $ user , $ result , $ this ) ; if ( ! empty ( $ result ) ) { return ( array ) $ result ; } $ this -> session -> delete ( ) ; $ result = $ this -> getResultLogOut ( $ user ) ; $ this -> hook -> attach ( 'user.logout.after' , $ user , $ result , $ this ) ; return ( array ) $ result ; }
Logs out the current user
54,737
public function resetPassword ( array $ data ) { $ result = array ( ) ; $ this -> hook -> attach ( 'user.reset.password.before' , $ data , $ result , $ this ) ; if ( ! empty ( $ result ) ) { return ( array ) $ result ; } if ( empty ( $ data [ 'user' ] [ 'user_id' ] ) ) { return $ this -> getResultError ( ) ; } if ( isset ( $ data [ 'password' ] ) ) { $ result = $ this -> resetPasswordFinish ( $ data ) ; } else { $ result = $ this -> resetPasswordStart ( $ data ) ; } $ this -> session -> regenerate ( true ) ; $ this -> hook -> attach ( 'user.reset.password.after' , $ data , $ result , $ this ) ; return ( array ) $ result ; }
Performs reset password operation
54,738
protected function resetPasswordStart ( array $ data ) { $ data [ 'user' ] [ 'data' ] [ 'reset_password' ] = array ( 'token' => gplcart_string_random ( ) , 'expires' => GC_TIME + $ this -> user -> getResetPasswordLifespan ( ) , ) ; $ this -> user -> update ( $ data [ 'user' ] [ 'user_id' ] , array ( 'data' => $ data [ 'user' ] [ 'data' ] ) ) ; $ this -> mail -> set ( 'user_reset_password' , array ( $ data [ 'user' ] ) ) ; return $ this -> getResultResetPasswordStart ( ) ; }
Start the password reset operation
54,739
protected function resetPasswordFinish ( array $ data ) { $ data [ 'user' ] [ 'password' ] = $ data [ 'password' ] ; unset ( $ data [ 'user' ] [ 'data' ] [ 'reset_password' ] ) ; $ this -> user -> update ( $ data [ 'user' ] [ 'user_id' ] , $ data [ 'user' ] ) ; $ this -> mail -> set ( 'user_changed_password' , array ( $ data [ 'user' ] ) ) ; return $ this -> getResultResetPasswordFinish ( ) ; }
Finish the password reset operation
54,740
public function emailRegistration ( array $ data ) { if ( $ this -> config -> get ( 'user_registration_email_customer' , true ) ) { $ this -> mail -> set ( 'user_registered_customer' , array ( $ data ) ) ; } if ( $ this -> config -> get ( 'user_registration_email_admin' , true ) ) { $ this -> mail -> set ( 'user_registered_admin' , array ( $ data ) ) ; } }
Sends e - mails on registration event
54,741
protected function getLoginRedirect ( array $ user ) { $ redirect = "account/{$user['user_id']}" ; if ( ! empty ( $ user [ 'role_redirect' ] ) ) { $ redirect = $ user [ 'role_redirect' ] ; } if ( $ this -> user -> isSuperadmin ( $ user [ 'user_id' ] ) ) { $ redirect = 'admin' ; } return $ redirect ; }
Returns a redirect path for the user
54,742
public function init ( $ file = GC_FILE_CONFIG_COMPILED ) { $ this -> initialized = false ; $ this -> setErrorHandlers ( ) ; if ( is_file ( $ file ) ) { $ this -> setConfig ( $ file ) ; $ this -> setErrorLevel ( ) ; $ this -> setKey ( ) ; $ this -> setLogger ( ) ; date_default_timezone_set ( $ this -> get ( 'timezone' , 'Europe/London' ) ) ; $ this -> initialized = true ; } return $ this -> initialized ; }
Initialize the system configuration
54,743
protected function setErrorLevel ( ) { switch ( $ this -> get ( 'error_level' , 2 ) ) { case 0 : error_reporting ( 0 ) ; break ; case 1 : error_reporting ( E_ERROR | E_WARNING | E_PARSE | E_NOTICE ) ; break ; case 2 : error_reporting ( E_ALL ) ; break ; } }
Set PHP error reporting level
54,744
protected function setErrorHandlers ( ) { register_shutdown_function ( array ( $ this -> logger , 'shutdownHandler' ) ) ; set_exception_handler ( array ( $ this -> logger , 'exceptionHandler' ) ) ; set_error_handler ( array ( $ this -> logger , 'errorHandler' ) , error_reporting ( ) ) ; }
Sets PHP error handlers
54,745
public function setConfig ( $ config ) { if ( is_array ( $ config ) ) { $ this -> config = $ config ; } else { $ this -> config = ( array ) gplcart_config_get ( ( string ) $ config ) ; $ this -> setDb ( $ this -> config [ 'database' ] ) ; $ this -> config = array_merge ( $ this -> config , $ this -> select ( ) ) ; } }
Set array of configuration options
54,746
public function setKey ( $ key = null ) { if ( empty ( $ key ) ) { $ key = $ this -> get ( 'private_key' ) ; if ( empty ( $ key ) ) { $ key = gplcart_string_random ( ) ; $ this -> set ( 'private_key' , $ key ) ; } } else { $ this -> set ( 'private_key' , $ key ) ; } return $ this -> key = $ key ; }
Sets the private key
54,747
public function get ( $ key = null , $ default = null ) { if ( ! isset ( $ key ) ) { return $ this -> config ; } if ( array_key_exists ( $ key , $ this -> config ) ) { return $ this -> config [ $ key ] ; } return $ default ; }
Returns a value from an array of configuration options
54,748
public function set ( $ key , $ value ) { if ( ! $ this -> db -> isInitialized ( ) || empty ( $ key ) || ! isset ( $ value ) ) { return false ; } $ this -> reset ( $ key ) ; $ serialized = 0 ; if ( is_array ( $ value ) ) { $ value = serialize ( $ value ) ; $ serialized = 1 ; } $ values = array ( 'id' => $ key , 'value' => $ value , 'created' => GC_TIME , 'serialized' => $ serialized ) ; $ this -> db -> insert ( 'settings' , $ values ) ; return true ; }
Saves a configuration value in the database
54,749
public function select ( $ name = null , $ default = null ) { if ( ! $ this -> db -> isInitialized ( ) ) { return isset ( $ name ) ? $ default : array ( ) ; } $ conditions = array ( ) ; $ sql = 'SELECT * FROM settings' ; if ( isset ( $ name ) ) { $ conditions [ ] = $ name ; $ sql .= ' WHERE id=? LIMIT 0,1' ; } $ settings = array ( ) ; foreach ( $ this -> db -> fetchAll ( $ sql , $ conditions ) as $ result ) { if ( ! empty ( $ result [ 'serialized' ] ) ) { $ result [ 'value' ] = unserialize ( $ result [ 'value' ] ) ; } $ settings [ $ result [ 'id' ] ] = $ result [ 'value' ] ; } return isset ( $ name ) ? reset ( $ settings ) : $ settings ; }
Select all or a single setting from the database
54,750
public function get ( $ key ) { $ parts = explode ( '.' , $ key ) ; $ offset = $ this -> config ; foreach ( $ parts as $ part ) { if ( ! isset ( $ offset [ $ part ] ) ) return null ; $ offset = $ offset [ $ part ] ; } return $ offset ; }
Get configuration by key
54,751
public function checkoutComplete ( $ order_id ) { $ this -> setOrderCheckoutComplete ( $ order_id ) ; $ this -> controlAccessCheckoutComplete ( ) ; $ this -> setTitleCheckoutComplete ( ) ; $ this -> setBreadcrumbCheckoutComplete ( ) ; $ this -> setData ( 'message' , $ this -> getMessageCheckoutComplete ( ) ) ; $ this -> setDataTemplatesCheckoutComplete ( ) ; $ this -> hook -> attach ( 'order.complete.page' , $ this -> data_order , $ this -> order , $ this ) ; $ this -> outputCheckoutComplete ( ) ; }
Page callback Displays the checkout complete page
54,752
protected function prepareOrderCheckoutComplete ( array & $ order ) { $ this -> setItemTotalFormatted ( $ order , $ this -> price ) ; $ this -> setItemTotalFormattedNumber ( $ order , $ this -> price ) ; }
Prepare the order data
54,753
protected function controlAccessCheckoutComplete ( ) { if ( empty ( $ this -> data_order [ 'user_id' ] ) || $ this -> data_order [ 'user_id' ] !== $ this -> cart_uid ) { $ this -> outputHttpStatus ( 403 ) ; } if ( ! $ this -> order -> isPending ( $ this -> data_order ) ) { $ this -> outputHttpStatus ( 403 ) ; } }
Controls access to the checkout complete page
54,754
public function listAddress ( ) { $ this -> actionListAddress ( ) ; $ this -> setTitleListAddress ( ) ; $ this -> setBreadcrumbListAddress ( ) ; $ this -> setFilterListAddress ( ) ; $ this -> setPagerlListAddress ( ) ; $ this -> setData ( 'addresses' , $ this -> getListAddress ( ) ) ; $ this -> outputListAddress ( ) ; }
Page callback Displays the address overview page
54,755
protected function getListAddress ( ) { $ conditions = $ this -> query_filter ; $ conditions [ 'limit' ] = $ this -> data_limit ; $ addresses = ( array ) $ this -> address -> getList ( $ conditions ) ; $ this -> prepareListAddress ( $ addresses ) ; return $ addresses ; }
Returns an array of addresses using pager limits and the URL query conditions
54,756
protected function prepareListAddress ( array & $ addresses ) { foreach ( $ addresses as & $ address ) { $ address [ 'translated' ] = $ this -> address -> getTranslated ( $ address , true ) ; } }
Prepares an array of addresses
54,757
public function listAlias ( ) { $ this -> actionListAlias ( ) ; $ this -> setTitleListAlias ( ) ; $ this -> setBreadcrumbListAlias ( ) ; $ this -> setFilterListAlias ( ) ; $ this -> setPagerListAlias ( ) ; $ this -> setData ( 'aliases' , $ this -> getListAlias ( ) ) ; $ this -> setData ( 'handlers' , $ this -> alias -> getHandlers ( ) ) ; $ this -> outputListAlias ( ) ; }
Page callback Displays the alias overview page
54,758
protected function getListAlias ( ) { $ conditions = $ this -> query_filter ; $ conditions [ 'limit' ] = $ this -> data_limit ; return ( array ) $ this -> alias -> getList ( $ conditions ) ; }
Returns an array of aliases using the pager limits and conditions from the URL query
54,759
public function store ( array & $ submitted , array $ options ) { $ this -> options = $ options ; $ this -> submitted = & $ submitted ; $ this -> validateStore ( ) ; $ this -> validateBool ( 'status' ) ; $ this -> validateDomainStore ( ) ; $ this -> validateBasepathStore ( ) ; $ this -> validateName ( ) ; $ this -> validateDataStore ( ) ; $ this -> validateImagesStore ( ) ; $ this -> validateDefaultStore ( ) ; $ this -> unsetSubmitted ( 'update' ) ; return $ this -> getResult ( ) ; }
Performs store data validation
54,760
protected function validateStore ( ) { $ id = $ this -> getUpdatingId ( ) ; if ( $ id === false ) { return null ; } $ data = $ this -> store -> get ( $ id ) ; if ( empty ( $ data ) ) { $ this -> setErrorUnavailable ( 'update' , $ this -> translation -> text ( 'Store' ) ) ; return false ; } $ this -> setUpdating ( $ data ) ; $ this -> setSubmitted ( 'default' , $ this -> store -> isDefault ( $ data [ 'store_id' ] ) ) ; return true ; }
Validates a store to be updated
54,761
protected function validateDomainStore ( ) { $ field = 'domain' ; if ( $ this -> isExcluded ( $ field ) ) { return null ; } $ value = $ this -> getSubmitted ( $ field ) ; if ( $ this -> isUpdating ( ) && ! isset ( $ value ) ) { $ this -> unsetSubmitted ( $ field ) ; return null ; } if ( $ this -> getSubmitted ( 'default' ) ) { $ this -> unsetSubmitted ( 'domain' ) ; return null ; } $ label = $ this -> translation -> text ( 'Domain' ) ; if ( empty ( $ value ) ) { $ this -> setErrorRequired ( $ field , $ label ) ; } $ updating = $ this -> getUpdating ( ) ; if ( isset ( $ updating [ 'domain' ] ) && $ updating [ 'domain' ] === $ value ) { return true ; } $ existing = $ this -> store -> get ( $ value ) ; if ( ! empty ( $ existing ) ) { $ this -> setErrorExists ( $ field , $ label ) ; return false ; } return true ; }
Validates a domain
54,762
protected function validateBasepathStore ( ) { $ field = 'basepath' ; if ( $ this -> isExcluded ( $ field ) || $ this -> isError ( 'domain' ) ) { return null ; } $ value = $ this -> getSubmitted ( $ field ) ; if ( $ this -> isUpdating ( ) && ! isset ( $ value ) ) { $ this -> unsetSubmitted ( $ field ) ; return null ; } if ( $ this -> getSubmitted ( 'default' ) ) { $ this -> unsetSubmitted ( $ field ) ; return null ; } $ updating = $ this -> getUpdating ( ) ; if ( isset ( $ updating [ 'basepath' ] ) && $ updating [ 'basepath' ] === $ value && $ updating [ 'domain' ] === $ this -> getSubmitted ( 'domain' ) ) { return true ; } if ( preg_match ( '/^[a-z0-9-]{0,50}$/' , $ value ) !== 1 ) { $ this -> setErrorInvalid ( $ field , $ this -> translation -> text ( 'Path' ) ) ; return false ; } return true ; }
Validates a store base path
54,763
protected function validateDataStore ( ) { $ field = 'data' ; if ( $ this -> isExcluded ( $ field ) ) { return null ; } $ value = $ this -> getSubmitted ( $ field ) ; if ( $ this -> isUpdating ( ) ) { if ( ! isset ( $ value ) ) { $ this -> unsetSubmitted ( $ field ) ; return null ; } } else if ( empty ( $ value ) ) { $ value = $ this -> store -> getConfig ( null , $ this -> store -> getDefault ( ) ) ; unset ( $ value [ 'title' ] , $ value [ 'meta_title' ] ) ; } if ( ! is_array ( $ value ) ) { $ this -> setErrorInvalid ( $ field , $ this -> translation -> text ( 'Settings' ) ) ; return false ; } $ this -> setSubmitted ( 'data' , $ value ) ; $ this -> validateDataTitleStore ( ) ; $ this -> validateDataEmailStore ( ) ; $ this -> validateDataMapStore ( ) ; $ this -> validateDataMetaTitleStore ( ) ; $ this -> validateDataMetaDescriptionStore ( ) ; $ this -> validateDataTranslationStore ( ) ; $ this -> validateDataThemeStore ( ) ; return ! $ this -> isError ( ) ; }
Validate data field
54,764
protected function validateDataEmailStore ( ) { $ field = 'data.email' ; $ value = $ this -> getSubmitted ( $ field ) ; $ label = $ this -> translation -> text ( 'E-mail' ) ; if ( empty ( $ value ) ) { $ this -> setErrorRequired ( $ field , $ label ) ; return false ; } if ( ! is_array ( $ value ) ) { $ this -> setErrorInvalid ( $ field , $ label ) ; return false ; } $ filtered = array_filter ( $ value , function ( $ email ) { return filter_var ( $ email , FILTER_VALIDATE_EMAIL ) ; } ) ; if ( count ( $ value ) != count ( $ filtered ) ) { $ this -> setErrorInvalid ( $ field , $ label ) ; return false ; } return true ; }
Validates E - mails
54,765
protected function validateDataMapStore ( ) { $ field = 'data.map' ; $ value = $ this -> getSubmitted ( $ field ) ; if ( empty ( $ value ) ) { return null ; } $ label = $ this -> translation -> text ( 'Map' ) ; if ( ! is_array ( $ value ) || count ( $ value ) != 2 ) { $ this -> setErrorInvalid ( $ field , $ label ) ; return false ; } if ( count ( $ value ) != count ( array_filter ( $ value , 'is_numeric' ) ) ) { $ this -> setErrorInvalid ( $ field , $ label ) ; return false ; } return true ; }
Validates map coordinates
54,766
protected function validateDataMetaTitleStore ( ) { $ field = 'data.meta_title' ; $ value = $ this -> getSubmitted ( $ field ) ; if ( empty ( $ value ) && ! $ this -> isError ( 'name' ) ) { $ this -> setSubmitted ( $ field , $ this -> getSubmitted ( 'name' ) ) ; } $ options = $ this -> options ; $ this -> options += array ( 'parents' => 'data' ) ; $ result = $ this -> validateMetaTitle ( ) ; $ this -> options = $ options ; return $ result ; }
Validates meta_title field
54,767
protected function validateDataMetaDescriptionStore ( ) { $ options = $ this -> options ; $ this -> options += array ( 'parents' => 'data' ) ; $ result = $ this -> validateMetaDescription ( ) ; $ this -> options = $ options ; return $ result ; }
Validates meta_description field
54,768
protected function validateDataTranslationStore ( ) { $ options = $ this -> options ; $ this -> options += array ( 'parents' => 'data' ) ; $ result = $ this -> validateTranslation ( ) ; $ this -> options = $ options ; return $ result ; }
Validates translatable fields
54,769
protected function validateDataThemeStore ( ) { $ field = 'data.theme' ; $ value = $ this -> getSubmitted ( $ field ) ; $ module = $ this -> module -> get ( $ value ) ; if ( isset ( $ module [ 'type' ] ) && $ module [ 'type' ] === 'theme' && ! empty ( $ module [ 'status' ] ) ) { return true ; } $ this -> setErrorUnavailable ( $ field , $ this -> translation -> text ( 'Theme' ) ) ; return false ; }
Validates theme module IDs
54,770
protected function validateImagesStore ( ) { if ( $ this -> isError ( ) ) { return null ; } $ error = false ; foreach ( array ( 'logo' , 'favicon' ) as $ field ) { if ( $ this -> getSubmitted ( "delete_$field" ) ) { $ this -> setSubmitted ( "data.$field" , '' ) ; } $ file = $ this -> request -> file ( $ field ) ; if ( empty ( $ file ) ) { continue ; } $ result = $ this -> file_transfer -> upload ( $ file , null , 'image/upload/store' ) ; if ( $ result !== true ) { $ error = true ; $ this -> setError ( $ field , ( string ) $ result ) ; continue ; } $ this -> setSubmitted ( "data.$field" , $ this -> file_transfer -> getTransferred ( true ) ) ; } return empty ( $ error ) ; }
Validates uploaded favicon
54,771
protected function validateDefaultStore ( ) { $ id = $ this -> getUpdatingId ( ) ; if ( ! empty ( $ id ) && $ this -> store -> isDefault ( $ id ) ) { $ this -> unsetSubmitted ( 'domain' ) ; $ this -> unsetSubmitted ( 'basepath' ) ; } }
Validates default store
54,772
public function getItems ( array $ conditions = array ( ) ) { $ list = $ this -> getList ( $ conditions ) ; if ( empty ( $ list ) ) { return array ( ) ; } $ handler_id = null ; $ items = array ( ) ; foreach ( ( array ) $ list as $ item ) { $ handler_id = $ item [ 'type' ] ; $ items [ $ item [ 'entity_id' ] ] = $ item ; } $ handlers = $ this -> collection -> getHandlers ( ) ; $ entity_conditions = array ( 'status' => isset ( $ conditions [ 'status' ] ) ? $ conditions [ 'status' ] : null , $ handlers [ $ handler_id ] [ 'entity' ] . '_id' => array_keys ( $ items ) ) ; $ entities = $ this -> getListEntities ( $ handler_id , $ entity_conditions ) ; if ( empty ( $ entities ) ) { return array ( ) ; } foreach ( $ entities as $ entity_id => & $ entity ) { if ( isset ( $ items [ $ entity_id ] ) ) { $ entity [ 'weight' ] = $ items [ $ entity_id ] [ 'weight' ] ; $ entity [ 'collection_item' ] = $ items [ $ entity_id ] ; $ entity [ 'collection_handler' ] = $ handlers [ $ handler_id ] ; } } gplcart_array_sort ( $ entities ) ; return $ entities ; }
Returns an array of collection item entities
54,773
public function getItem ( array $ conditions = array ( ) ) { $ list = $ this -> getItems ( $ conditions ) ; if ( empty ( $ list ) ) { return $ list ; } return reset ( $ list ) ; }
Returns a single entity item
54,774
public function getListEntities ( $ collection_id , array $ arguments ) { try { $ handlers = $ this -> collection -> getHandlers ( ) ; return Handler :: call ( $ handlers , $ collection_id , 'list' , array ( $ arguments ) ) ; } catch ( Exception $ ex ) { trigger_error ( $ ex -> getMessage ( ) ) ; return array ( ) ; } }
Returns an array of entities for the given collection ID
54,775
public function getNextWeight ( $ collection_id ) { $ sql = 'SELECT MAX(weight) FROM collection_item WHERE collection_id=?' ; $ weight = ( int ) $ this -> db -> fetchColumn ( $ sql , array ( $ collection_id ) ) ; return ++ $ weight ; }
Returns the next possible weight for a collection item
54,776
public function get ( $ imagestyle_id ) { $ result = null ; $ this -> hook -> attach ( 'image.style.get.before' , $ imagestyle_id , $ result , $ this ) ; if ( isset ( $ result ) ) { return ( array ) $ result ; } $ imagestyles = $ this -> getList ( ) ; $ result = isset ( $ imagestyles [ $ imagestyle_id ] ) ? $ imagestyles [ $ imagestyle_id ] : array ( ) ; $ this -> hook -> attach ( 'image.style.get.after' , $ imagestyle_id , $ result , $ this ) ; return ( array ) $ result ; }
Loads an image style
54,777
public function getActions ( $ imagestyle_id ) { $ styles = $ this -> getList ( ) ; if ( empty ( $ styles [ $ imagestyle_id ] [ 'actions' ] ) ) { return array ( ) ; } $ actions = $ styles [ $ imagestyle_id ] [ 'actions' ] ; gplcart_array_sort ( $ actions ) ; return $ actions ; }
Returns an array of image style actions
54,778
public function getActionHandlers ( ) { $ handlers = & gplcart_static ( 'image.style.action.handlers' ) ; if ( isset ( $ handlers ) ) { return ( array ) $ handlers ; } $ handlers = ( array ) gplcart_config_get ( GC_FILE_CONFIG_IMAGE_ACTION ) ; $ this -> hook -> attach ( 'image.style.action.handlers' , $ handlers , $ this ) ; return ( array ) $ handlers ; }
Returns an array of image style action handlers
54,779
public function getActionHandler ( $ action_id ) { $ handlers = $ this -> getActionHandlers ( ) ; return empty ( $ handlers [ $ action_id ] ) ? array ( ) : $ handlers [ $ action_id ] ; }
Returns a single image action handler
54,780
public function applyAction ( & $ source , & $ target , $ handler , & $ action ) { $ result = null ; $ this -> hook -> attach ( 'image.style.apply.before' , $ source , $ target , $ handler , $ action , $ result ) ; if ( isset ( $ result ) ) { return $ result ; } try { $ callback = Handler :: get ( $ handler , null , 'process' ) ; $ result = call_user_func_array ( $ callback , array ( & $ source , & $ target , & $ action ) ) ; } catch ( Exception $ ex ) { $ result = $ ex -> getMessage ( ) ; } $ this -> hook -> attach ( 'image.style.apply.after' , $ source , $ target , $ handler , $ action , $ result ) ; return $ result ; }
Apply a single action to an image file
54,781
public function applyActions ( array $ actions , $ source , $ target ) { $ applied = 0 ; foreach ( $ actions as $ action_id => $ data ) { $ handler = $ this -> getActionHandler ( $ action_id ) ; if ( empty ( $ handler ) ) { continue ; } $ result = $ this -> applyAction ( $ source , $ target , $ handler , $ data ) ; if ( $ result === true ) { $ applied ++ ; } } return $ applied ; }
Apply an array of actions
54,782
public function clearCache ( $ imagestyle_id = null ) { $ result = null ; $ this -> hook -> attach ( 'image.style.clear.cache.before' , $ imagestyle_id , $ result , $ this ) ; if ( isset ( $ result ) ) { return ( bool ) $ result ; } $ result = gplcart_file_delete_recursive ( $ this -> getDirectory ( $ imagestyle_id ) ) ; $ this -> hook -> attach ( 'image.style.clear.cache.after' , $ imagestyle_id , $ result , $ this ) ; return ( bool ) $ result ; }
Removes cached files for all or a certain image style
54,783
public function zip ( $ file ) { if ( ! function_exists ( 'zip_open' ) ) { return false ; } $ zip = zip_open ( $ file ) ; if ( is_resource ( $ zip ) ) { zip_close ( $ zip ) ; return true ; } return false ; }
Whether the file is a ZIP file
54,784
protected function addAnAddress ( $ kind , $ address , $ name = '' ) { if ( ! preg_match ( '/^(to|cc|bcc|Reply-To)$/' , $ kind ) ) { $ this -> setError ( $ this -> lang ( 'Invalid recipient array' ) . ': ' . $ kind ) ; $ this -> edebug ( $ this -> lang ( 'Invalid recipient array' ) . ': ' . $ kind ) ; if ( $ this -> exceptions ) { throw new Mail \ MailerException ( 'Invalid recipient array: ' . $ kind ) ; } return false ; } $ address = trim ( $ address ) ; $ name = trim ( preg_replace ( '/[\r\n]+/' , '' , $ name ) ) ; if ( ! $ this -> validateAddress ( $ address ) ) { $ this -> setError ( $ this -> lang ( 'invalid_address' ) . ': ' . $ address ) ; $ this -> edebug ( $ this -> lang ( 'invalid_address' ) . ': ' . $ address ) ; if ( $ this -> exceptions ) { throw new Mail \ MailerException ( $ this -> lang ( 'invalid_address' ) . ': ' . $ address ) ; } return false ; } if ( $ kind != 'Reply-To' ) { if ( ! isset ( $ this -> all_recipients [ strtolower ( $ address ) ] ) ) { array_push ( $ this -> $ kind , array ( $ address , $ name ) ) ; $ this -> all_recipients [ strtolower ( $ address ) ] = true ; return true ; } } else { if ( ! array_key_exists ( strtolower ( $ address ) , $ this -> ReplyTo ) ) { $ this -> ReplyTo [ strtolower ( $ address ) ] = array ( $ address , $ name ) ; return true ; } } return false ; }
Add an address to one of the recipient arrays . Addresses that have been added already return false but do not throw exceptions
54,785
public function getSMTPInstance ( ) { if ( ! is_object ( $ this -> smtp ) ) { $ this -> smtp = new Mail \ Smtp ( ) ; } return $ this -> smtp ; }
Get an instance to use for SMTP operations . Override this function to load your own SMTP implementation
54,786
public function addrFormat ( $ addr ) { if ( empty ( $ addr [ 1 ] ) ) { return $ this -> secureHeader ( $ addr [ 0 ] ) ; } else { return $ this -> encodeHeader ( $ this -> secureHeader ( $ addr [ 1 ] ) , 'phrase' ) . ' <' . $ this -> secureHeader ( $ addr [ 0 ] ) . '>' ; } }
Format an address for use in a message header .
54,787
public function encodeHeader ( $ str , $ position = 'text' ) { $ matchcount = 0 ; switch ( strtolower ( $ position ) ) { case 'phrase' : if ( ! preg_match ( '/[\200-\377]/' , $ str ) ) { $ encoded = addcslashes ( $ str , "\0..\37\177\\\"" ) ; if ( ( $ str == $ encoded ) && ! preg_match ( '/[^A-Za-z0-9!#$%&\'*+\/=?^_`{|}~ -]/' , $ str ) ) { return ( $ encoded ) ; } else { return ( "\"$encoded\"" ) ; } } $ matchcount = preg_match_all ( '/[^\040\041\043-\133\135-\176]/' , $ str , $ matches ) ; break ; case 'comment' : $ matchcount = preg_match_all ( '/[()"]/' , $ str , $ matches ) ; case 'text' : default : $ matchcount += preg_match_all ( '/[\000-\010\013\014\016-\037\177-\377]/' , $ str , $ matches ) ; break ; } if ( $ matchcount == 0 ) { return ( $ str ) ; } $ maxlen = 75 - 7 - strlen ( $ this -> CharSet ) ; if ( $ matchcount > strlen ( $ str ) / 3 ) { $ encoding = 'B' ; if ( function_exists ( 'mb_strlen' ) && $ this -> hasMultiBytes ( $ str ) ) { $ encoded = $ this -> base64EncodeWrapMB ( $ str , "\n" ) ; } else { $ encoded = base64_encode ( $ str ) ; $ maxlen -= $ maxlen % 4 ; $ encoded = trim ( chunk_split ( $ encoded , $ maxlen , "\n" ) ) ; } } else { $ encoding = 'Q' ; $ encoded = $ this -> encodeQ ( $ str , $ position ) ; $ encoded = $ this -> wrapText ( $ encoded , $ maxlen , true ) ; $ encoded = str_replace ( '=' . self :: CRLF , "\n" , trim ( $ encoded ) ) ; } $ encoded = preg_replace ( '/^(.*)$/m' , ' =?' . $ this -> CharSet . "?$encoding?\\1?=" , $ encoded ) ; $ encoded = trim ( str_replace ( "\n" , $ this -> LE , $ encoded ) ) ; return $ encoded ; }
Encode a header string optimally . Picks shortest of Q B quoted - printable or none .
54,788
public function hasMultiBytes ( $ str ) { if ( function_exists ( 'mb_strlen' ) ) { return ( strlen ( $ str ) > mb_strlen ( $ str , $ this -> CharSet ) ) ; } else { return false ; } }
Check if a string contains multi - byte characters .
54,789
public function base64EncodeWrapMB ( $ str , $ linebreak = null ) { $ start = '=?' . $ this -> CharSet . '?B?' ; $ end = '?=' ; $ encoded = '' ; if ( $ linebreak === null ) { $ linebreak = $ this -> LE ; } $ mb_length = mb_strlen ( $ str , $ this -> CharSet ) ; $ length = 75 - strlen ( $ start ) - strlen ( $ end ) ; $ ratio = $ mb_length / strlen ( $ str ) ; $ avgLength = floor ( $ length * $ ratio * .75 ) ; for ( $ i = 0 ; $ i < $ mb_length ; $ i += $ offset ) { $ lookBack = 0 ; do { $ offset = $ avgLength - $ lookBack ; $ chunk = mb_substr ( $ str , $ i , $ offset , $ this -> CharSet ) ; $ chunk = base64_encode ( $ chunk ) ; $ lookBack ++ ; } while ( strlen ( $ chunk ) > $ length ) ; $ encoded .= $ chunk . $ linebreak ; } $ encoded = substr ( $ encoded , 0 , - strlen ( $ linebreak ) ) ; return $ encoded ; }
Encode and wrap long multibyte strings for mail headers without breaking lines within a character . Adapted from a function by paravoid
54,790
public function clearCCs ( ) { foreach ( $ this -> cc as $ cc ) { unset ( $ this -> all_recipients [ strtolower ( $ cc [ 0 ] ) ] ) ; } $ this -> cc = array ( ) ; }
Clear all CC recipients .
54,791
protected function serverHostname ( ) { $ result = 'localhost.localdomain' ; if ( ! empty ( $ this -> Hostname ) ) { $ result = $ this -> Hostname ; } elseif ( isset ( $ _SERVER ) and array_key_exists ( 'SERVER_NAME' , $ _SERVER ) and ! empty ( $ _SERVER [ 'SERVER_NAME' ] ) ) { $ result = $ _SERVER [ 'SERVER_NAME' ] ; } elseif ( function_exists ( 'gethostname' ) && gethostname ( ) !== false ) { $ result = gethostname ( ) ; } elseif ( php_uname ( 'n' ) !== false ) { $ result = php_uname ( 'n' ) ; } return $ result ; }
Get the server hostname . Returns localhost . localdomain if unknown .
54,792
public function DKIM_BodyC ( $ body ) { if ( $ body == '' ) { return "\r\n" ; } $ body = str_replace ( "\r\n" , "\n" , $ body ) ; $ body = str_replace ( "\n" , "\r\n" , $ body ) ; while ( substr ( $ body , strlen ( $ body ) - 4 , 4 ) == "\r\n\r\n" ) { $ body = substr ( $ body , 0 , strlen ( $ body ) - 2 ) ; } return $ body ; }
Generate a DKIM canonicalization body .
54,793
public function get ( $ key , $ default = null ) { if ( ! GC_CLI && isset ( $ _SESSION ) ) { $ value = gplcart_array_get ( $ _SESSION , $ key ) ; } return isset ( $ value ) ? $ value : $ default ; }
Returns a session data
54,794
public function set ( $ key , $ value = null ) { if ( ! GC_CLI && isset ( $ _SESSION ) ) { gplcart_array_set ( $ _SESSION , $ key , $ value ) ; return true ; } return false ; }
Set a session data
54,795
public function delete ( $ key = null ) { if ( ! $ this -> isInitialized ( ) ) { return false ; } if ( ! isset ( $ key ) ) { session_unset ( ) ; if ( ! session_destroy ( ) ) { throw new RuntimeException ( 'Failed to delete the session' ) ; } return true ; } gplcart_array_unset ( $ _SESSION , $ key ) ; return true ; }
Deletes a data from the session
54,796
public function setMessage ( $ message , $ type = 'info' , $ key = 'messages' ) { if ( $ message !== '' ) { $ messages = ( array ) $ this -> get ( "$key.$type" , array ( ) ) ; if ( ! in_array ( $ message , $ messages ) ) { $ messages [ ] = $ message ; $ this -> set ( "$key.$type" , $ messages ) ; } } }
Sets a message to be displayed to the user
54,797
public function getMessage ( $ type = null , $ key = 'messages' ) { if ( isset ( $ type ) ) { $ key .= ".$type" ; } $ message = $ this -> get ( $ key , array ( ) ) ; $ this -> delete ( $ key ) ; return $ message ; }
Returns messages from the session
54,798
public function city ( array & $ submitted , array $ options = array ( ) ) { $ this -> options = $ options ; $ this -> submitted = & $ submitted ; $ this -> validateCity ( ) ; $ this -> validateBool ( 'status' ) ; $ this -> validateName ( ) ; $ this -> validateStateCity ( ) ; $ this -> validateZoneCity ( ) ; $ this -> validateCountryCity ( ) ; $ this -> unsetSubmitted ( 'update' ) ; return $ this -> getResult ( ) ; }
Performs full city data validation
54,799
protected function validateCity ( ) { $ id = $ this -> getUpdatingId ( ) ; if ( $ id === false ) { return null ; } $ data = $ this -> city -> get ( $ id ) ; if ( empty ( $ data ) ) { $ this -> setErrorUnavailable ( 'update' , $ this -> translation -> text ( 'City' ) ) ; return false ; } $ this -> setUpdating ( $ data ) ; return true ; }
Validates a city to be updated