In tutorials 5 and 6 i made an assumption that if zend_auth object is null then user is a guest, i.e. not logged in. This is fine for small applications. It also raises PHP notice message. For those who do not want any messages or need more refined controlled over guest permissions there is a need to have a proper role created for guest. So we take advantage of Zend_Registry and create a global variable for role that takes Zend_Auth’s role variable if user is logged in or default variable value ‘guest’ if otherwise.
View the episode
P.S. I had a real hard time uploading this video and I am still not sure if it came out correctly. It suppose to be 48 minutes long. Please report if its broken.
P.P.S By request, here’s the SQL for the database. Its very small so i’ll just include it here:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
-- phpMyAdmin SQL Dump -- version 3.2.0 -- http://www.phpmyadmin.net -- -- Host: localhost -- Generation Time: Aug 14, 2009 at 11:42 AM -- Server version: 5.1.37 -- PHP Version: 5.2.10 SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO"; /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; /*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; /*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; /*!40101 SET NAMES utf8 */; -- -- Database: `zftutorial` -- -- -------------------------------------------------------- -- -- Table structure for table `books` -- CREATE TABLE IF NOT EXISTS `books` ( `id` int(11) NOT NULL AUTO_INCREMENT, `title` varchar(50) COLLATE latin1_general_ci NOT NULL, `author` varchar(100) COLLATE latin1_general_ci NOT NULL, PRIMARY KEY (`id`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_general_ci AUTO_INCREMENT=5 ; -- -- Dumping data for table `books` -- INSERT INTO `books` (`id`, `title`, `author`) VALUES (1, 'Core PHP Programming', 'Leon Atkinson'), (2, 'Programming in Python 3', 'Mark Summerfield '), (3, 'Core Java', 'Cay S. Horstmann and Gary Cornell'), (4, 'AJAX and PHP: Building Responsive Web Applications', 'Bogdan Brinzarea, Cristian Darie, Filip Chereches-Tosa, Mihai Bucica '); -- -------------------------------------------------------- -- -- Table structure for table `users` -- CREATE TABLE IF NOT EXISTS `users` ( `id` int(11) NOT NULL AUTO_INCREMENT, `username` varchar(50) COLLATE latin1_general_ci NOT NULL, `password` varchar(50) COLLATE latin1_general_ci NOT NULL, `role` varchar(50) COLLATE latin1_general_ci NOT NULL, PRIMARY KEY (`id`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_general_ci AUTO_INCREMENT=3 ; -- -- Dumping data for table `users` -- INSERT INTO `users` (`id`, `username`, `password`, `role`) VALUES (1, 'john', 'pass1', 'users'), (2, 'rob', 'pass2', 'admins'); |
| < Prev | Next > |
|---|
