# BackendPro User Guide Version 0.3.1

Search User Guide

# Preferences

BackendPro instead of using configuration files to store settings, it stores settings in a database table. The main advantage of this is it means simple interfaces can be used to update the values without having to go into the file system.

Many different data types can be stored using the preference table but two I will bring attention to a few:

- `Boolean` : You can store boolean values in the database, but store them as 1 or 0 instead. The reason for doing this is it means simple if statements can be used on the values instead of having to perform string evaluation if the value was instead stored as TRUE or FALSE.
- `Arrays` : There may be a time when you want an array to be stored as a setting. This is fine, the system should detect that the variable is an array and will serialize it. Upon fetching the setting it will then unserialize it for your use.
- `Long Text` : Want to store a very large paragraph as a preference, thats fine since the table is implemented with a column type Text so no trimming will occur.

## Fetch Setting

Fetch a setting value:

`$this->preference->item('name')`

## Default Settings

The BackendPro system comes with many settings already setup. Below is a description of each, what it does and its default value. Please do not change these preference values directly in the database table, use the preference forms provided.

Preference | Default Value | Options | Description
--- | --- | --- | ---
site_name | BackendPro | None | This is the name of your website. Using this preference means you can quickly change branding throughout your site.
webmaster_name | Webmaster | None | This is the the name you the webmaster to be called by.
webmaster_email | webmaster@localhost | None | This is the email used to send emails to the systems webmaster.
maintenance_mode | 0 | 1/0 (boolean) | If set to 1 this will lock the website down for maintenance, otherwise it will be open.
maintenance_message | ... | None | Message to display to users when the website is locked down
page_debug | 0 | 1/0 (boolean) | If set to 1 this will display page debug infomation provided by $this->output->enable_profiler().
keep_error_logs_for | 30 | None | Number of days to keep error logs for
default_user_group | 1 | User Group ID | The user group ID to assign all new users to.
allow_user_registration | 1 | 1/0 (boolean) | If set to 1 it will allow users to register an account with the website, otherwise an admin must create all new accounts.
allow_user_profiles | 0 | 1/0 (boolean) | If set to 1 it will allow custom user profiles to be used on the system, otherwise it will not.
activation_method | email | email/admin/none | What action must be taken to activate newly created accounts.
account_activation_time | 7 | None | Number of days before a new account must be activated.
autologin_period | 30 | None | Number of days a user stays logged in, if they select 'Remember Me' upon login
use_registration_captcha | 0 | 1/0 (boolean) | If set to 1 a captcha form is used upon registration
use_login_captcha | 0 | 1/0 (boolean) | If set to 1 a captcha form is used upon login
min_password_length | 8 | None | Minium number of characters a password must be
automated_from_email | noreply@backendpro.co.uk | None | This is the email used, when any system emails are sent to the user. E.g. activation emails
automated_from_name | BackendPro | None | This is the name used, when any system emails are sent to the user. E.g. activation emails
email_protocol | smtp | smtp/mail/sendmail | Email protocol used to send system emails.
email_mailpath | /usr/sbin/sendmail | None | Path to the sendmail application (only needed if the sendmail protocol is selected)
smtp_host |  | None | SMTP host used to send emails (only needed if the smtp protocol is selected)
smtp_user |  | None | SMTP username used to send emails (only needed if the smtp protocol is selected)
smtp_pass |  | None | SMTP password used to send emails (only needed if the smtp protocol is selected)
smtp_port | 25 | None | SMTP post used to send emails (only needed if the smtp protocol is selected)
smtp_timeout | 5 | None | SMTP timeout(seconds) used to send emails (only needed if the smtp protocol is selected)
email_wordwrap | 1 | 1/0 (boolean) | If set to 1 emails will be wordwrapped
email_wrapchars | 76 | None | Number of characters to wrap emails at
email_mailtype | text | text/html | Email format to send emails as
email_charset | utf-8 | None | Charset used to send emails as
bcc_batch_mode | 0 | 1/0 (boolean) | If set to 1 emails will be sent is batches. This can be usefull for sendming thousands of emails and not flooding the server.
bcc_batch_size | 200 | None | Number of batch emails to send at once, 200 should be a good value

## Adding your own preferences

To add your own preference all you need to do is add a new row in the `be_preferences` table in the database. Assign it a default value and your done. If you would however like to create a form to manage the setting, please see below.

## Preference Form Creation

Not only can you manage the default system settings using the preference form. But you can also create settings and a form for your own preferences by using the Preference Form Class.

If you would like to see an example of a controller implementing a preference form have a look at the file system/application/controllers/admin/settings.php.