hPreference.php

The hPreference.php helper in Osclass offers an extensive set of functions to retrieve and manage system preferences. These functions cover configuration settings such as comment behavior, user registration, image upload options, and more. They also include helpers for subdomain settings and generic functions to get, set, or delete preferences. This documentation is organized into sections for general preferences, subdomain helpers, and private utility functions.

Functions Description

General Preferences Functions

  • osc_time_cookie() – Gets the cookie’s life.
  • osc_comments_enabled() – Returns true if comments are enabled; otherwise, false.
  • osc_comments_per_page() – Returns the number of comments to display per page.
  • osc_timezone() – Retrieves the timezone setting.
  • osc_reg_user_post_comments() – Returns true if only registered users are allowed to post comments.
  • osc_reg_user_can_contact() – Returns true if only registered users are allowed to contact the seller.
  • osc_users_enabled() – Returns true if user functionality is enabled.
  • osc_user_registration_enabled() – Returns true if user registration is enabled.
  • osc_user_validation_enabled() – Returns true if user validation is enabled.
  • osc_logged_user_item_validation() – Returns true if validation is required for items posted by logged-in users.
  • osc_moderate_comments() – Returns the threshold number of comments before auto-moderation is triggered.
  • osc_notify_new_comment() – Returns true if admin notifications for new comments are enabled.
  • osc_notify_new_comment_user() – Returns true if user notifications for new comments are enabled.
  • osc_rewrite_enabled() – Returns true if friendly URLs are enabled.
  • osc_mod_rewrite_loaded() – Returns true if mod_rewrite is loaded (note: on CGI mode, mod_rewrite may not be detected).
  • osc_keep_original_image() – Returns true if original images should be kept after processing.
  • osc_auto_cron() – Returns true if the autocron feature is enabled.
  • osc_recaptcha_items_enabled() – Returns true if reCAPTCHA is enabled for items.
  • osc_items_wait_time() – Returns the number of seconds a user must wait before posting another item (0 indicates no waiting).
  • osc_moderate_items() – Returns the number of items required to trigger auto-moderation.
  • osc_can_deactivate_items() – Returns true if the user is allowed to deactivate their listing.
  • osc_reg_user_post() – Returns true if only registered users can post new items; otherwise, anyone can post.
  • osc_price_enabled_at_items() – Returns true if the price field is enabled in the item submission form.
  • osc_images_enabled_at_items() – Returns true if the image upload feature is enabled in the item submission form.
  • osc_max_images_per_item() – Returns the maximum number of images allowed per item (0 indicates unlimited).
  • osc_notify_contact_friends() – Returns true if admin notifications are sent when a "send-a-friend" message is submitted.
  • osc_notify_contact_item() – Returns true if admin notifications are sent when a contact message is submitted.
  • osc_item_attachment() – Returns true if item attachments are enabled.
  • osc_contact_attachment() – Returns true if contact attachments are enabled.
  • osc_notify_new_item() – Returns true if admin notifications for new items are enabled.
  • osc_notify_new_user() – Returns true if admin notifications for new user registrations are enabled.
  • osc_mailserver_auth() – Returns true if the mail server requires authentication.
  • osc_mailserver_pop() – Returns true if the mail server requires POP authentication.
  • osc_default_order_field_at_search() – Returns the default order field for search results.
  • osc_default_order_type_at_search() – Returns the default order type for search results.
  • osc_default_show_as_at_search() – Returns the default display mode for search results.
  • osc_max_results_per_page_at_search() – Returns the maximum number of search results per page.
  • osc_default_results_per_page_at_search() – Returns the default number of search results per page.
  • osc_max_latest_items() – Returns the maximum number of latest items.
  • osc_save_latest_searches() – Returns true if saving the latest searches is enabled.
  • osc_purge_latest_searches() – Purges the latest searches (functionality details may vary).
  • osc_item_spam_delay() – Returns the delay in seconds between item posts to prevent spam.
  • osc_comment_spam_delay() – Returns the delay in seconds between comment posts to prevent spam.
  • osc_selectable_parent_categories() – Returns true if selecting parent categories is enabled.
  • osc_max_latest_items_at_home() – Returns the maximum number of latest items displayed on the home page.
  • osc_get_preference($key, $section = 'osclass') – Retrieves a preference value based on its key and section.
  • osc_set_preference($key, $value = '', $section = 'osclass', $type = 'STRING') – Inserts or updates a preference with the specified key, value, section, and type.
  • osc_delete_preference($key = '', $section = 'osclass') – Deletes a preference based on its key and section.
  • osc_reset_preferences() – Reloads preferences.
  • osc_is_watermark_text() – Returns true if watermarking with text is enabled.
  • osc_is_watermark_image() – Returns true if watermarking with an image is enabled.
  • osc_watermark_text_color() – Returns the watermark text color.
  • osc_watermark_text() – Returns the watermark text.
  • osc_watermark_place() – Returns the watermark placement.

Helpers for Subdomains

  • osc_subdomain_type() – Returns the type of subdomain. When subdomains are disabled, it returns an empty string. Possible values include category, user, country, region, or city.
  • osc_subdomain_host() – Returns the subdomain host as defined in Settings > Advanced. This should be in base domain format (e.g., if your site is hosted at https://yourdomain.com, the subdomain host is yourdomain.com, allowing for subdomains like *.yourdomain.com).
  • osc_subdomain_landing_enabled() – Returns true if the top-domain page is converted to a subdomains landing page.
  • osc_subdomain_redirect_enabled() – Returns true if automatic redirection to subdomains is enabled (only applicable for country-based subdomains).
  • osc_subdomain_restricted_ids() – Returns a list of restricted country IDs, limiting access to specific subdomains based on the visitor's country.

Private Functions

  • getBoolPreference($key, $section = 'osclass') – Retrieves a preference as a boolean.
  • getPreference($key, $section = 'osclass') – Retrieves a preference as a string.