
Implementing ACL In Cakephp 2.1 and Upper Versions
Hello friends! Time and again the idea of using ACL to designate specific permissions for specific groups have dreaded most of us. This happens because of the ambiguous behaviour shown by ACL at times. Well, the behaviour we perceive as ambiguous is due to limited understanding of the process involved in its implementation. Today, while implementing the ACL second time I still had to verify everything closely to resolve the errors associated with permissions. Having said that, I decided to split the ACL implementation into steps. Let’s start :- Step 1: The first and foremost requirement without which the ACL implementation would be futile is not using auth. Therefore, presence of auth component in our application will always be a…

How to use Amazon S3 services in Cakephp
Amazon S3 is an online storage service that provides simple web service interface to store and retrieve data. This space has to be purchased. This article covers uploading and deleting the files from Amazon S3 through Cakephp 2.2.2 Component. You can extend this component as per your requirement. You can understand the usage of this component with the below mentioned steps: 1) Put AWS SDK in /app/Controller/Component folder. You can download the aws attached with this article, or you can download it as zip from http://docs.aws.amazon.com/aws-sdk-php/guide/latest/installation.html 2) Put AwsComponent.php file in /app/Controller/Component folder. 3) Configure your component in constructor of the component as : $this->s3 = S3Client::factory(array( ‘key’ => YOUR_API_KEY, ‘secret’ => YOUR_API_SECRET, ‘region’ => ‘eu-west-1’, )); 4) Load component in…

Cakephp helper to cut the long text without cutting the word
Step 1 : Create a helper file limit_text.php in app.views/helpers/ Note: The same function can be use in other than cakephp <?php class LimitTextHelper extends AppHelper{ public function trimText ($text=null,$length=8,$showDots=true,$cutFirstWord=true ) { $textArr = explode(‘ ‘,$text); if($showDots){ $dotString = ‘…’; }else{ $dotString = ”; } if($length==0){ echo ucfirst($text); }else{ if(!$cutFirstWord && strlen($textArr[0])>$length ){ echo ucfirst($textArr[0]).$dotString; }elseif(strlen($textArr[0])>$length){ echo ucfirst(substr($textArr[0],0,$length)).$dotString; }else{ if(strlen($text)>$length){ $newText = substr($text,0,$length); $newText = substr($newText,0,strrpos($newText,” “)); echo ucfirst($newText).$dotString; }else{ echo ucfirst($text); } } } }//eof } ?> Step 2: Include the helper in the controller Like: var $helpers = array(‘Html’,’Javascript’, ‘Ajax’,’Session’,’LimitText’); Step 3:Now in views // 3rd param = false if don’t want dots at the end , 4th is set false when a string has one word only…

Facebook Connect (Graph API) in cake php
To implement Facebook connect using graph API you need to follow the steps 1) Extract the facebook_core_files.zip file and put all of them in vendors folder of cake php 2) In your apps controller include this code at the top of the file App::import(‘Vendor’, ‘facebook’, array(‘file’ => ‘facebook.php’)); 3) in your apps controller add this function ( before filter ) function beforeFilter() { //facebook application $user = null; //facebook user uid $userInfo = null; // Create our Application instance. $facebook = new Facebook(array( ‘appId’ => YOURAPPID, ‘secret’ => YOURSECRET )); //Facebook Authentication part $user = $facebook->getUser(); if ($user) { try { // Proceed knowing you have a logged in user who’s authenticated. $fql = “select name,current_location,email,sex,verified,pic_square from user where uid=”…

Cakephp not working on Ubuntu – Error 404 not found
If you are facing problems with Cakephp not working on Ubuntu after all googling and doing all other things, please try this one: Open Places->Computer->File System->etc->apache2->sites-available In this folder open file name ‘default‘ In this file search for <Directory /var/www/> Options Indexes FollowSymLinks MultiViews AllowOverride none Order allow,deny allow from all </Directory> and replace it with <Directory /var/www/> Options Indexes FollowSymLinks MultiViews AllowOverride all Order allow,deny allow from all </Directory> You will find your cakephp working very fine now. Hope this will help. Thanks

Cakephp – Logable behaviour
This behavior is created to easily let you (the developer) log users activities that relates to database modifications (ie, add, edit and delete). If you just want to see what your users are doing or need to be able to say “That is not a bug, I can see from my log that you deleted the post yesterday.” and don’t want to spend more time that it takes to do “var $actsAs = array(‘Logable’);” then this behavior is for you.