Documentation
- Does UserCake have a admin backend
- These database interactions don't look familiar
- Help I can't find the num_rows function
- What are email templates
- Can I disable email activation
- How do I setup UserCake
- How does UserCake handle security
- How do I protect member pages
- How do I protect pages based on group
- Where can I view your license
- Fatal mail error help!
- How do I create new error messages
- How do I add dynamic content to error message / language strings
- How can I loop through an error array
Does UserCake have a admin backend?
No. UserCake is merly a foundation to start building your application.
These database interactions don't look familiar
UserCake uses phpBB's DBAL or Database Abstraction layer to support multiple dbms's. phpBB's DBAL Wiki.
Help I can't find the num_rows function
Sadly phpBB's DBAL doesn't have a callable num rows function. You can instead call;
returns_result($Sql);
Which will return how many rows a given query returns.
What are email templates?
Email templates are text files which have hooks / tags in them that can get replaced.
These hooks then get replaced with your dynamic content.
You can specify default hooks in settings.php
$default_hooks = array("#WEBSITENAME#","#WEBSITEURL#","#DATE#");
You can specify dynamic hooks at run time when constructing a new userCakeMail instance, see forgot password, or register.php for examples.
Can I disable email activation?
Yes, although I don't recommend it. To disable it, in settings.php change the email activation flag to false. New users will become instantly active.
$emailActivation = false;
How do I setup UserCake?
Download the zip or rar and view ReadMe.txt.
1. Before proceeding please open up models/settings.php
2. Create a database on your server / web hosting package.
3. Fill out the connection details in settings.php
4. UserCake supports mysql and mysqli via phpBB's DBAL layer, UserCake defaults to mysql, to change it to mysqli change variable $dbtype to "mysqli".
5. You can setup the database manually or use the installer. If you wish to setup the database manually look inside the install folder and you will find sql.txt which contains the sql.
To use the installer visit http://yourdomain.com/install/ in your browser. UserCake will attempt to build the database for you. After completion delete the install folder.
How does UserCake handle security?
UserCake uses salt along with a SHA1 hash. The salt is 25 characters in length. This can be increased to 32 characters. Locate the generateHash function in functions/general-funcs.php to modify.
How do I protect member pages?
Calling
isUserLoggedIn();
On pages will perform a quick lookup in the database to ensure the user is still active in case there condition alters after being logged in. If this is found to be the case the user is forced to logout.
How do I protect member pages based on group.
Calling
isGroupMember($id)
On a user object will return true or false if the user is a member of a group. Based on group id. By default all users are a standard user.
On pages will perform a quick lookup in the database to ensure the user is still active in case there condition alters after being logged in. If this is found to be the case the user is forced to logout.
Where can I view your license?
UserCake is fully opensource free for both personal and commercial works.
Fatal mail error help!
Note - The below information is only valid for V1.1 and above of usercake
V1.1 of usercake has more clear error messages. In settings.php turn on $debug_mode = true. Attempt to call the mail class again and it will display a clearer error message. By default email activation is set to true in V1.1
Note - The below information is only valid for V1 of usercake
This can be caused in two areas. However more commonly it's due to the fact UserCake's template builder cannot gain access to the template files. It also could be that the server will not allow you to use the mail function, or there is an existing mail issue on the server. It's unlikely to be the latter.
Steps to working out if user cake is unable to access the mail-templates directory.
Go to models/classes/new_mail.php
Find
if(!$this->contents || empty($this->contents))
{
return false;
}
Replace with
{
die("Unable to open mail template dir, or mail template is empty");
return false;
}
Now try and register a new user account. If you see that error then you know UserCake is having problems either accessing the mail templates or the template file is empty.
Due to the variety of hosting environments you may need to change the path accordingly.
In models/settings.php locate
$mail_templates_dir = "mail-templates/";
You may need to use document root instead of this structure although it will depend on how you have user cake setup.
Creating a PHP file and running
$root = getenv("DOCUMENT_ROOT");
echo $root;
Will provide you with the document root path, try appending this with YOUR-USER-CAKE-DIR/models/mail-templates/
How do I create new error messages?
You need to open the relevant language file. Language files can be found in the lang folder inside models.
Looking at a the current language file you can see the associative arrays. You will need to add new "Key" and array item string for the message. You can then get that error message by using the lang() function.
Of course this is optional.
How do I add dynamic content to error message / language strings?
You can add dynamic content to error messages at run time by placing markers inside your language string.
You can then call the lang() function with the optional parameter of an array to replace the markers.
Produces
How can I loop through an error array?
As of 1.4 the function errorBlock() was added. It will foreach and echo out an arrays content, in our case error messages.
$args = array(1,2,4,5,6);
errorBlock($args);
Produces
- 1
- 2
- 3