├── README ├── cake.bat ├── config ├── config.php ├── routes.php └── schema │ └── spark_plug.sql ├── controllers ├── components │ ├── authsome.php │ └── empty ├── errors_controller.php ├── user_group_permissions_controller.php ├── user_groups_controller.php └── users_controller.php ├── locale ├── default.pot └── esp │ └── LC_MESSAGES │ └── spark_plug.po ├── models ├── behaviors │ └── membership.php ├── company.php ├── login_token.php ├── user.php ├── user_group.php └── user_group_permission.php ├── spark_plug_app_controller.php ├── spark_plug_app_model.php ├── tests ├── cases │ ├── behaviors │ │ └── empty │ ├── components │ │ └── empty │ ├── controllers │ │ └── empty │ ├── helpers │ │ └── empty │ └── models │ │ ├── user.test.php │ │ └── user_group.test.php ├── fixtures │ ├── company_fixture.php │ ├── login_token_fixture.php │ ├── user_fixture.php │ ├── user_group_fixture.php │ └── user_group_permission_fixture.php └── groups │ └── empty ├── vendors └── phpmailer │ ├── class.phpmailer.php │ ├── class.smtp.php │ └── phpmailer_doc.html ├── views ├── elements │ └── layout │ │ ├── control_panel │ │ └── icon.ctp │ │ ├── email │ │ └── text │ │ │ └── default.thtml │ │ ├── footer.ctp │ │ ├── header.ctp │ │ ├── help_section.ctp │ │ ├── logged_in_menu.default.ctp │ │ └── rightcol.ctp ├── errors │ └── unauthorized.ctp ├── helpers │ ├── empty │ └── trans.php ├── layouts │ └── sparkwufoodefault.ctp ├── user_group_permissions │ ├── add.ctp │ ├── edit.ctp │ └── index.ctp └── users │ ├── activate_password.ctp │ ├── add.ctp │ ├── change_password.ctp │ ├── dashboard.ctp │ ├── edit.ctp │ ├── forgot_password.ctp │ ├── index.ctp │ ├── login.ctp │ └── register.ctp └── webroot ├── css ├── spark.css └── wufoo │ ├── form.css │ ├── structure.css │ └── theme.css └── js └── wufoo.js /README: -------------------------------------------------------------------------------- 1 | ------------------------------------------------------ 2 | | SparkPlug is a simple auth-acl plugin for cakephp1.3 | 3 | ------------------------------------------------------ 4 | 5 | Default user created = admin 6 | Default password = 1234 7 | 8 | INSTALLATION 9 | ------------ 10 | 11 | 1. Download the latest version or use git to keep the plugin up to date 12 | 13 | cd yourapp/app/plugins 14 | git clone git://github.com/jedt/spark_plug.git 15 | 16 | 2. Schema import (use your favorite sql tool to import the schema) 17 | 18 | /app/plugins/spark_plug/config/schema/spark_plug.sql 19 | 20 | 3. Import config files 21 | 22 | 3.1 open /app/config/core.php and paste on the last line 23 | 24 | include_once(ROOT.'/app/plugins/spark_plug/config/config.php'); 25 | 26 | 3.2 open /app/config/routes.php and paste on the last line 27 | 28 | include_once(ROOT.'/app/plugins/spark_plug/config/routes.php'); 29 | 30 | 4. Include callback in your AppController class 31 | 32 | open or create the file /app/app_controller.php and paste or edit the file. It should look like this 33 | 34 | 37 | array('model' => 'User')); 38 | var $uses = array('SparkPlug.UserGroup'); 39 | 40 | function beforeFilter() 41 | { 42 | parent::beforeFilter(); 43 | SparkPlugIt($this); 44 | } 45 | } 46 | ?> 47 | 48 | 5. Adjust plugin configuration 49 | 50 | Change /app/plugins/spark_plug/config/config.php (parameters are explained there) to suit your needs. 51 | 52 | 6. {OPTIONAL} Do you want your permission rules filtered ? 53 | 54 | cd yourapp/app/plugins 55 | git clone http://github.com/josegonzalez/cakephp-filter-plugin.git filter 56 | 57 | then modify in your app_controller components variable this line 58 | 59 | var $components = array ('Session', 'Filter.Filter', 'SparkPlug.Authsome' => 60 | array('model' => 'User')); 61 | 62 | (note 'Filter.Filter' component added) 63 | 64 | 7. {OPTIONAL} Do you want facebook users to access your app ? 65 | 66 | cd yourapp/app/plugins 67 | git clone http://github.com/webtechnick/CakePHP-Facebook-Plugin.git facebook 68 | 69 | then modify in your app_controller components variable this line 70 | 71 | var $components = array ('Session', 'Facebook.Connect', 'SparkPlug.Authsome' => 72 | array('model' => 'User')); 73 | 74 | (note 'Facebook.Connect' component added) 75 | 76 | then copy the file 77 | yourapp/app/plugins/facebook/facebook.php.example into yourapp/config/facebook.php 78 | 79 | then edit file yourapp/config/facebook.php 80 | and put your facebook app keys 81 | 82 | Yes, you have to login previously to your facebook account and then create a new application, using fb developers api 83 | You will first need to update your facebook application with the connect url of your application's url. This is done on 84 | the facebook application settings. http://www.facebook.com/developers/apps.php) 85 | 86 | ROADMAP 87 | ------- 88 | 89 | 90 | 91 | TODO 92 | ---- 93 | 94 | please check github page (github.com/jedt/spark_plug.git) -------------------------------------------------------------------------------- /cake.bat: -------------------------------------------------------------------------------- 1 | ..\..\..\..\..\php\php.exe ..\..\..\cake\console\cake.php i18n -------------------------------------------------------------------------------- /config/config.php: -------------------------------------------------------------------------------- 1 | 'Spark Plug Cakephp Plugin')); 4 | 5 | 6 | Configure::write('UserPermissions',array( 7 | 'controllers/Posts/index', 8 | 'controllers/Posts/edit', 9 | 'controllers/Websites' 10 | )); 11 | 12 | Configure::write('rootURL','127.0.0.1/spark'); 13 | Configure::write('httpRootURL','http://127.0.0.1/spark'); 14 | Configure::write('projectName','Spark Plug Cakephp Plugin'); 15 | Configure::write('logged-in-menu','logged_in_menu'); 16 | Configure::write('front_end_layout','sparkwufoodefault'); 17 | Configure::write('dashboard_layout','sparkwufoodefault'); 18 | 19 | Configure::write('SparkPlug.open_registration', true); 20 | Configure::write('SparkPlug.default_groupid_for_registration', 2); // id of the group used to register new users via users/register 21 | Configure::write('SparkPlug.register_defaults.optin', false); 22 | Configure::write('SparkPlug.register_defaults.agreement', false); 23 | 24 | // if the user tries to login with his facebook account and he has not any associated spark user, a new user will be created and linked with his facebook email 25 | Configure::write('SparkPlug.auto_register_facebook_accounts', true); 26 | Configure::write('SparkPlug.default_group_for_new_facebook_accounts', 2); 27 | 28 | Configure::write('SparkPlug.redirectOriginAfterLogin', true); // used to redirect after login to the page that triggered the login action 29 | Configure::write('SparkPlug.loginRedirect', '/users/dashboard'); // default url to login to (used also by the facebook autologin feature) 30 | Configure::write('SparkPlug.registerRedirect', false); 31 | Configure::write('SparkPlug.registerAutoLogin', false); 32 | Configure::write('SparkPlug.administrator.from_name', 'Administrator'); 33 | Configure::write('SparkPlug.administrator.email', 'noreply@pleasenoreply.com'); 34 | Configure::write('SparkPlug.hash.method', 'md5'); // use sha1 to be compatible with passwords generated by Cake's Auth Component 35 | Configure::write('SparkPlug.hash.salt', false); // use true to be compatible with passwords generated by Cake's Auth Component 36 | Configure::write('SparkPlug.allow.login_as_user', false); 37 | 38 | // creating a specific cache config for rules 39 | Cache::config('SparkPlug', array( 40 | 'engine' => 'File', 41 | 'duration'=> '+3 months', 42 | 'path' => CACHE, 43 | 'prefix' => 'SparkPlug_' 44 | )); 45 | 46 | 47 | /** 48 | * Main entry point to the plugin. This should be called from the app_controller beforeFilter OR 49 | * from the beforeFilter of the controllers you wish to protect 50 | * @param $controller 51 | * @return unknown_type 52 | */ 53 | function SparkPlugIt(&$controller) 54 | { 55 | $pageRedirect = $controller->Session->read('permission_error_redirect'); 56 | $controller->Session->delete('permission_error_redirect'); 57 | 58 | //TODO: Check why is this model used 59 | $controller->company_id = $controller->Session->read('Company.id'); 60 | 61 | // check if the controller $uses = null to bind the required models before continue. This corrects issue 62 | if (!is_array($controller->uses) || !in_array('SparkPlug.UserGroup', $controller->uses)){ 63 | //debug ('binding SparkPlug.UserGroup model'); 64 | //code from http://www.pseudocoder.com/archives/one-more-tip-for-speeding-up-cakephp-apps 65 | //the loadModel way 66 | $controller->loadModel('SparkPlug.UserGroup'); 67 | //end of code from http://www.pseudocoder.com/archives/one-more-tip-for-speeding-up-cakephp-apps 68 | } 69 | 70 | if (empty($pageRedirect)) 71 | { 72 | $actionUrl = $controller->params['url']['url']; 73 | if ($actionUrl != 'users/login'){ 74 | $controller->Session->write('SparkPlug.OriginAfterLogin', '/'.$actionUrl); 75 | } 76 | 77 | // if (isset($controller->params['slug'])) 78 | // $website = $controller->Website->find('Website.subdomain = "'.$controller->params['slug'].'"'); 79 | // else 80 | // $website = null; 81 | // 82 | // if (!$website) 83 | // { 84 | $user = $controller->Authsome->get(); 85 | if (!$user) 86 | { 87 | //anonymous? 88 | if (!$controller->UserGroup->isGuestAccess($actionUrl)) 89 | { 90 | $controller->Session->write('permission_error_redirect','/users/login'); 91 | $controller->Session->setFlash('Please login to view this page.'); 92 | 93 | $controller->redirect('/users/login'); 94 | } 95 | } 96 | else 97 | { 98 | if (!$controller->UserGroup->isUserGroupAccess($user['User']['user_group_id'],$actionUrl)) 99 | { 100 | $controller->Session->write('permission_error_redirect','/users/login'); 101 | $controller->Session->setFlash('Sorry, You don\'t have permission to view this page. '.$user['User']['user_group_id'].':('.$actionUrl.')'); 102 | 103 | //$controller->redirect(Configure::read('SparkPlug.loginRedirect')); 104 | $controller->redirect('/errors/unauthorized'); 105 | } 106 | } 107 | // } 108 | } 109 | } 110 | ?> -------------------------------------------------------------------------------- /config/routes.php: -------------------------------------------------------------------------------- 1 | 'spark_plug', 'controller' => 'users')); 3 | Router::connect('/dashboard', array('plugin' => 'spark_plug', 'controller' => 'users', 'action'=>'dashboard')); 4 | Router::connect('/users/dashboard', array('plugin' => 'spark_plug', 'controller' => 'users', 'action'=>'dashboard')); 5 | Router::connect('/user_groups/:action', array('plugin' => 'spark_plug', 'controller'=>'user_groups')); 6 | Router::connect('/user_group_permissions/:action/*', array('plugin' => 'spark_plug', 'controller'=>'user_group_permissions')); 7 | // Router::connect('/init', array('plugin' => 'spark_plug', 'controller' => 'user_groups','action'=>'build_acl')); 8 | Router::connect('/register', array('plugin' => 'spark_plug', 'controller' => 'users', 'action' => 'register')); 9 | Router::connect('/users/register', array('plugin' => 'spark_plug', 'controller' => 'users', 'action' => 'register')); 10 | 11 | Router::connect('/login', array('plugin' => 'spark_plug', 'controller' => 'users', 'action' => 'login')); 12 | Router::connect('/users/login', array('plugin' => 'spark_plug', 'controller' => 'users', 'action' => 'login')); 13 | Router::connect('/logout', array('plugin' => 'spark_plug', 'controller' => 'users', 'action' => 'logout')); 14 | Router::connect('/users/logout', array('plugin' => 'spark_plug', 'controller' => 'users', 'action' => 'logout')); 15 | 16 | Router::connect('/users/forgotPassword', array('plugin' => 'spark_plug', 'controller' => 'users', 'action' => 'forgotPassword')); 17 | 18 | Router::connect('/errors/unauthorized', array('plugin' => 'spark_plug', 'controller' => 'errors', 'action' => 'unauthorized')); 19 | 20 | ?> 21 | -------------------------------------------------------------------------------- /config/schema/spark_plug.sql: -------------------------------------------------------------------------------- 1 | -- phpMyAdmin SQL Dump 2 | -- version 3.2.0.1 3 | -- http://www.phpmyadmin.net 4 | -- 5 | -- Host: localhost 6 | -- Generation Time: Feb 02, 2010 at 01:21 PM 7 | -- Server version: 5.0.51 8 | -- PHP Version: 5.2.5 9 | 10 | SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO"; 11 | 12 | 13 | /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; 14 | /*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; 15 | /*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; 16 | /*!40101 SET NAMES utf8 */; 17 | 18 | -- 19 | -- Database: `sparky` 20 | -- 21 | 22 | -- -------------------------------------------------------- 23 | 24 | -- 25 | -- Table structure for table `companies` 26 | -- 27 | 28 | CREATE TABLE IF NOT EXISTS `companies` ( 29 | `id` int(11) NOT NULL auto_increment, 30 | `user_id` int(11) default NULL, 31 | `name` varchar(255) default NULL, 32 | `paypal_email` varchar(255) default NULL, 33 | `email` varchar(255) default NULL, 34 | `time_zone_id` varchar(255) default NULL, 35 | PRIMARY KEY (`id`) 36 | ) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=100 ; 37 | 38 | -- -------------------------------------------------------- 39 | 40 | -- 41 | -- Table structure for table `login_tokens` 42 | -- 43 | 44 | CREATE TABLE IF NOT EXISTS `login_tokens` ( 45 | `id` int(11) NOT NULL auto_increment, 46 | `user_id` int(11) NOT NULL, 47 | `token` char(32) NOT NULL, 48 | `duration` varchar(32) NOT NULL, 49 | `used` tinyint(1) NOT NULL default '0', 50 | `created` datetime NOT NULL, 51 | `expires` datetime NOT NULL, 52 | PRIMARY KEY (`id`) 53 | ) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=100 ; 54 | 55 | -- -------------------------------------------------------- 56 | 57 | -- 58 | -- Table structure for table `users` 59 | -- 60 | 61 | CREATE TABLE IF NOT EXISTS `users` ( 62 | `id` int(11) NOT NULL auto_increment, 63 | `user_group_id` int(11) unsigned default NULL, 64 | `username` varchar(25) default NULL, 65 | `password` varchar(255) default NULL, 66 | `email` varchar(255) default NULL, 67 | `phone` varchar(255) default NULL, 68 | `active` tinyint (1) default 1, 69 | `first_name` varchar(255) default NULL, 70 | `last_name` varchar(255) default NULL, 71 | `country` varchar(5) default NULL, 72 | `city` varchar(255) default NULL, 73 | `state` varchar(255) default NULL, 74 | `zip_code` varchar(255) NOT NULL, 75 | `external_auth_id` varchar(255) default NULL, 76 | `created` datetime default NULL, 77 | `modified` datetime default NULL, 78 | PRIMARY KEY (`id`), 79 | KEY `user` (`username`), 80 | KEY `mail` (`email`), 81 | KEY `users_FKIndex1` (`user_group_id`) 82 | ) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=100 ; 83 | 84 | -- 85 | -- Dumping data for table `users` 86 | -- 87 | 88 | INSERT INTO `users` (`id`, `user_group_id`, `username`, `password`, `email`, `phone`, `active`, `first_name`, `last_name`, `country`, `city`, `state`, `zip_code`, `created`, `modified`) VALUES 89 | (1, 1, 'admin', '81dc9bdb52d04dc20036dbd8313ed055', '', '', '1', '', '', '', '', '', '', '2009-11-17 22:22:33', '2009-11-17 22:22:33'); 90 | 91 | -- -------------------------------------------------------- 92 | 93 | -- 94 | -- Table structure for table `user_groups` 95 | -- 96 | 97 | CREATE TABLE IF NOT EXISTS `user_groups` ( 98 | `id` int(11) NOT NULL auto_increment, 99 | `name` varchar(255) default NULL, 100 | `rank` int(11) default NULL, 101 | PRIMARY KEY (`id`) 102 | ) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=100 ; 103 | 104 | -- 105 | -- Dumping data for table `user_groups` 106 | -- 107 | 108 | INSERT INTO `user_groups` (`id`, `name`, `rank`) VALUES 109 | (1, 'Admin', 1), 110 | (2, 'User', 2), 111 | (3, 'Guest', 10); 112 | 113 | -- -------------------------------------------------------- 114 | 115 | -- 116 | -- Table structure for table `user_group_permissions` 117 | -- 118 | 119 | CREATE TABLE IF NOT EXISTS `user_group_permissions` ( 120 | `id` int(10) unsigned NOT NULL auto_increment, 121 | `user_group_id` int(10) unsigned NOT NULL, 122 | `plugin` varchar(255) NOT NULL, 123 | `controller` varchar(255) NOT NULL, 124 | `action` varchar(255) NOT NULL, 125 | `allowed` tinyint(1) unsigned NOT NULL default '1', 126 | PRIMARY KEY (`id`) 127 | ) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=100 ; 128 | 129 | -- 130 | -- Dumping data for table `user_group_permissions` 131 | -- 132 | 133 | INSERT INTO `user_group_permissions` (`id`, `user_group_id`, `plugin`, `controller`, `action`, `allowed`) VALUES 134 | (1, 3, 'spark_plug', 'users', 'register', 1), 135 | (2, 3, 'spark_plug', 'users', 'login', 1), 136 | (3, 3, 'spark_plug', 'users', 'logout', 1), 137 | (4, 3, 'spark_plug', 'users', 'forgot_password', 1), 138 | (5, 3, 'spark_plug', 'users', 'activate_password', 1), 139 | (6, 2, 'spark_plug', 'users', 'dashboard', 1), 140 | (7, 1, 'spark_plug', 'users', '*', 1), 141 | (8, 3, 'spark_plug', 'users', 'forgotPassword', 1), 142 | (9, 1, 'spark_plug', 'user_group_permissions', '*', 1), 143 | (10, 3, 'spark_plug', 'errors', '*', 1) 144 | -------------------------------------------------------------------------------- /controllers/components/authsome.php: -------------------------------------------------------------------------------- 1 | 'User', 32 | 'configureKey' => null, 33 | 'sessionKey' => null, 34 | 'cookieKey' => null, 35 | ); 36 | 37 | private $__userModel; 38 | 39 | public function initialize($controller, $settings = array()) { 40 | Authsome::instance($this); 41 | $this->settings = Set::merge($this->settings, $settings); 42 | 43 | // Use the model name as the key everywhere by default 44 | $keys = array('configure', 'session', 'cookie'); 45 | foreach ($keys as $prefix) { 46 | $key = $prefix.'Key'; 47 | if (empty($this->settings[$key])) { 48 | $this->settings[$key] = $this->settings['model']; 49 | } 50 | } 51 | } 52 | public function check($access=null) 53 | { 54 | $user = $this->__getActiveUser(); 55 | 56 | $userModel = $this->__getUserModel(); 57 | return $userModel->UserGroup->isUserGroupAccess($user['User']['user_group_id'],$access); 58 | } 59 | public function get($field = null) { 60 | $user = $this->__getActiveUser(); 61 | 62 | if (empty($field)) { 63 | return $user; 64 | } 65 | 66 | if (strpos($field, '.') === false) { 67 | if (in_array($field, array_keys($user))) { 68 | return $user[$field]; 69 | } 70 | $field = $this->settings['model'].'.'.$field; 71 | } 72 | 73 | return Set::extract($user, $field); 74 | } 75 | 76 | public function login($type = 'credentials', $credentials = null) { 77 | $userModel = $this->__getUserModel(); 78 | 79 | $args = func_get_args(); 80 | if (!method_exists($userModel, 'authsomeLogin')) { 81 | throw new Exception( 82 | $userModel->alias.'::authsomeLogin() is not implemented!' 83 | ); 84 | } 85 | 86 | if (!is_string($type) && is_null($credentials)) { 87 | $credentials = $type; 88 | $type = 'credentials'; 89 | } 90 | 91 | $user = $userModel->authsomeLogin($type, $credentials); 92 | 93 | Configure::write($this->settings['configureKey'], $user); 94 | $this->Session->write($this->settings['sessionKey'], $user); 95 | return $user; 96 | } 97 | 98 | public function logout() { 99 | Configure::write($this->settings['configureKey'], array()); 100 | $this->Session->write($this->settings['sessionKey'], array()); 101 | $this->Cookie->write($this->settings['cookieKey'], ''); 102 | 103 | return true; 104 | } 105 | 106 | public function persist($duration = '2 weeks') { 107 | $userModel = $this->__getUserModel(); 108 | 109 | if (!method_exists($userModel, 'authsomePersist')) { 110 | throw new Exception( 111 | $userModel->alias.'::authsomePersist() is not implemented!' 112 | ); 113 | } 114 | 115 | $token = $userModel->authsomePersist(Authsome::get(), $duration); 116 | $token = $token.':'.$duration; 117 | 118 | return $this->Cookie->write( 119 | $this->settings['cookieKey'], 120 | $token, 121 | true, // encrypt = true 122 | $duration 123 | ); 124 | } 125 | 126 | public function hash($password) { 127 | return Authsome::hash($password); 128 | } 129 | 130 | private function __getUserModel() { 131 | if ($this->__userModel) { 132 | return $this->__userModel; 133 | } 134 | 135 | return $this->__userModel = ClassRegistry::init( 136 | $this->settings['model'] 137 | ); 138 | } 139 | 140 | private function __getActiveUser() { 141 | $user = Configure::read($this->settings['configureKey']); 142 | if (!empty($user)) { 143 | return $user; 144 | } 145 | 146 | $this->__useSession() || 147 | $this->__useCookieToken() || 148 | $this->__useGuestAccount(); 149 | 150 | $user = Configure::read($this->settings['configureKey']); 151 | if (is_null($user)) { 152 | throw new Exception( 153 | 'Unable to initilize user' 154 | ); 155 | } 156 | 157 | return $user; 158 | } 159 | 160 | private function __useSession() { 161 | $user = $this->Session->read($this->settings['sessionKey']); 162 | if (!$user) { 163 | return false; 164 | } 165 | 166 | Configure::write($this->settings['configureKey'], $user); 167 | return true; 168 | } 169 | 170 | private function __useCookieToken() { 171 | $token = $this->Cookie->read($this->settings['cookieKey']); 172 | if (!$token) { 173 | return false; 174 | } 175 | 176 | // Extract the duration appendix from the token 177 | $tokenParts = split(':', $token); 178 | $duration = array_pop($tokenParts); 179 | $token = join(':', $tokenParts); 180 | 181 | $user = $this->login('cookie', compact('token', 'duration')); 182 | 183 | // Delete the cookie once its been used 184 | $this->Cookie->del($this->settings['cookieKey']); 185 | 186 | if (!$user) { 187 | return; 188 | } 189 | 190 | $this->persist($duration); 191 | 192 | return (bool)$user; 193 | } 194 | 195 | private function __useGuestAccount() { 196 | return $this->login('guest'); 197 | } 198 | } 199 | 200 | // Static Authsomeness 201 | class Authsome{ 202 | static function instance($setInstance = null) { 203 | static $instance; 204 | 205 | if ($setInstance) { 206 | $instance = $setInstance; 207 | } 208 | 209 | if (!$instance) { 210 | throw new Exception( 211 | 'AuthsomeComponent not initialized properly!' 212 | ); 213 | } 214 | 215 | return $instance; 216 | } 217 | 218 | public static function check($access=null) 219 | { 220 | return self::instance()->check($access); 221 | } 222 | public static function get($field = null) { 223 | return self::instance()->get($field); 224 | } 225 | 226 | public static function login($type = 'credentials', $credentials = null) { 227 | return self::instance()->login($type, $credentials); 228 | } 229 | 230 | public static function logout() { 231 | return self::instance()->logout(); 232 | } 233 | 234 | public static function persist($duration = '2 weeks') { 235 | return self::instance()->persist($duration); 236 | } 237 | 238 | public static function hash($password, $method = 'md5', $salt = false) { 239 | return Security::hash($password, $method, $salt); 240 | } 241 | } 242 | ?> -------------------------------------------------------------------------------- /controllers/components/empty: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jedt/spark_plug/062b5bbb1c6b2b2fbc7360b5a28221f1d7f9a22d/controllers/components/empty -------------------------------------------------------------------------------- /controllers/errors_controller.php: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /controllers/user_group_permissions_controller.php: -------------------------------------------------------------------------------- 1 | layout = Configure::read('dashboard_layout'); 9 | $userGroups = $this->UserGroup->find('list'); 10 | $this->set('userGroups',$userGroups); 11 | } 12 | 13 | function edit($id=null) 14 | { 15 | $this->layout = Configure::read('dashboard_layout'); 16 | $userGroups = $this->UserGroup->find('list'); 17 | 18 | $this->set('userGroups',$userGroups); 19 | 20 | if (!empty($this->data)) 21 | { 22 | if ($this->UserGroupPermission->save($this->data)) 23 | { 24 | $this->Session->setFlash('User Group Permission is saved. Rules cache optimized.'); 25 | $this->redirect('/user_group_permissions/index'); 26 | } 27 | } 28 | else 29 | { 30 | $this->data = $this->UserGroupPermission->read(null,$id); 31 | } 32 | } 33 | 34 | function index() 35 | { 36 | 37 | $this->layout = Configure::read('dashboard_layout'); 38 | 39 | //check for filter plugin available 40 | if (array_key_exists('Filter.Filter', $this->components)){ 41 | $this->helpers[] = 'Filter.Filter'; 42 | $this->paginate = array_merge_recursive($this->paginate, $this->Filter->paginate); 43 | $this->set('filterEnabled', true); 44 | } else { 45 | $this->set('filterEnabled', false); 46 | } 47 | 48 | $permissions = $this->paginate('UserGroupPermission'); 49 | $this->set('permissions', $permissions); 50 | } 51 | 52 | /** 53 | * Delete the user group permission. 54 | * @author cdburgess 55 | * 56 | * @param id The User Group Permission id to be deleted. 57 | */ 58 | function delete($id = NULL) { 59 | if (!$id) { 60 | $this->Session->setFlash(__('Invalid id for user group permission.', true)); 61 | $this->redirect(array('controller' => 'user_group_permissions', 'action'=>'index')); 62 | } 63 | if ($this->UserGroupPermission->delete($id)) { 64 | $this->Session->setFlash(__('User Group Permission deleted', true)); 65 | $this->redirect(array('controller' => 'user_group_permissions', 'action'=>'index')); 66 | } 67 | $this->Session->setFlash(__('User Group Permission was not deleted', true)); 68 | $this->redirect(array('controller' => 'user_group_permissions', 'action' => 'index')); 69 | } 70 | } 71 | ?> -------------------------------------------------------------------------------- /controllers/user_groups_controller.php: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /controllers/users_controller.php: -------------------------------------------------------------------------------- 1 | "1"); 8 | var $uses = array('SparkPlug.User'); 9 | 10 | function beforeFilter(){ 11 | parent::beforeFilter(); 12 | $this->layout = Configure::read('dashboard_layout'); 13 | //check for facebook connect plugin available 14 | if (array_key_exists('Facebook.Connect', $this->components)){ 15 | $this->helpers[] = 'Facebook.Facebook'; 16 | $this->Session->write('SparkPlug.facebookEnabled', true); 17 | } else { 18 | $this->Session->write('SparkPlug.facebookEnabled', false); 19 | } 20 | } 21 | 22 | function index() 23 | { 24 | $users = $this->paginate('User'); 25 | $this->set('users',$users); 26 | } 27 | 28 | function edit($id=null) 29 | { 30 | $userGroups = $this->User->UserGroup->find('list'); 31 | $this->set('userGroups',$userGroups); 32 | 33 | if (!empty($this->data)) 34 | { 35 | if ($this->User->save($this->data)) 36 | { 37 | $this->Session->setFlash('User is saved.'); 38 | $this->redirect('/users/index'); 39 | } 40 | } 41 | else 42 | { 43 | $this->data = $this->User->read(null,$id); 44 | } 45 | } 46 | 47 | function delete($id) 48 | { 49 | $this->User->delete($id); 50 | $this->Session->setFlash('User was deleted.'); 51 | $this->redirect('/users/index'); 52 | } 53 | 54 | function logout() 55 | { 56 | $this->Authsome->logout(); 57 | $this->Session->setFlash('You are now logged out.'); 58 | $this->Session->write('SparkPlug.Users.loggedInByFacebook', false); 59 | $this->redirect('/'); 60 | } 61 | function dashboard() 62 | { 63 | } 64 | 65 | /** 66 | * 67 | * Used to allow non registered users to create an account 68 | */ 69 | function register() 70 | { 71 | $this->layout = Configure::read('front_end_layout'); 72 | $user = $this->Authsome->get(); 73 | if ($user) 74 | { 75 | $this->Session->setFlash('You are logged in, please logout to register a new account'); 76 | $this->redirect(Configure::read('SparkPlug.loginRedirect')); 77 | } 78 | else 79 | { 80 | if(!Configure::read('SparkPlug.open_registration')) { 81 | $this->Session->setFlash('Please contact an administrator to setup an account'); 82 | $this->redirect('/users/login'); 83 | return; 84 | } 85 | 86 | if ($this->data) 87 | { 88 | $this->data['User']['user_group_id'] = Configure::read('SparkPlug.default_groupid_for_registration'); 89 | if ($this->User->save($this->data)) 90 | { 91 | $registerAutoLogin = Configure::read('SparkPlug.registerAutoLogin'); 92 | if($registerAutoLogin) { 93 | $user = $this->User->read(null,$this->User->id); 94 | $this->Session->write("User",$user); 95 | $this->Session->write("User.id",$user["User"]["id"]); 96 | $this->Session->write("UserGroup.id",$user["UserGroup"]["id"]); 97 | $this->Session->write("UserGroup.name",$user["UserGroup"]["name"]); 98 | $this->Session->write('Company.id',$user['Company']['id']); 99 | $this->tinymce_filemanager_init(); 100 | } 101 | 102 | $registerRedirect = Configure::read('SparkPlug.registerRedirect'); 103 | if(!empty($registerRedirect)) { 104 | $this->redirect($registerRedirect); 105 | } 106 | $this->flash("Thank you for joining. Please check your email for instructions.","login"); 107 | } else { 108 | $this->data['User']['password'] = null; 109 | $this->data['User']['confirm_password'] = null; 110 | } 111 | } else { 112 | $this->data['User']['optin'] = Configure::read('SparkPlug.register_defaults.optin'); 113 | $this->data['User']['agreement'] = Configure::read('SparkPlug.register_defaults.agreement'); 114 | } 115 | } 116 | } 117 | 118 | 119 | /** 120 | * 121 | * Used by the system admin to create a new user 122 | */ 123 | function add(){ 124 | $this->layout = Configure::read('front_end_layout'); 125 | 126 | if ($this->data) 127 | { 128 | if ($this->User->save($this->data)) 129 | { 130 | $this->Session->setFlash("User {$this->data['User']['username']} saved correctly."); 131 | $this->data = array(); 132 | } else { 133 | } 134 | } else { 135 | $this->data = array(); 136 | } 137 | } 138 | 139 | function activate_password() 140 | { 141 | $this->layout = Configure::read('front_end_layout'); 142 | if ($this->data) 143 | { 144 | if (!empty($this->data['User']['ident']) && !empty($this->data['User']['activate'])) 145 | { 146 | $this->set('ident',$this->data['User']['ident']); 147 | $this->set('activate',$this->data['User']['activate']); 148 | 149 | $return = $this->User->activatePassword($this->data); 150 | if ($return) 151 | { 152 | $this->flash('New password is saved.',Configure::read('httpRootUrl').'/users/login'); 153 | } 154 | else 155 | { 156 | $this->flash('Sorry password could not be saved. Please check your email and click the password reset link again.',Configure::read('httpRootUrl').'/users/login'); 157 | } 158 | } 159 | } 160 | else 161 | { 162 | if (isset($_GET['ident']) && isset($_GET['activate'])) 163 | { 164 | $this->set('ident',$_GET['ident']); 165 | $this->set('activate',$_GET['activate']); 166 | } 167 | } 168 | } 169 | function change_password() 170 | { 171 | if (isset($this->data['User']['id']) && $this->data['User']['id'] == $this->Session->read('User.id') ) 172 | { 173 | if ($this->User->changePassword($this->data)) 174 | { 175 | $this->flash('Password has changed.',Configure::read('httpRootUrl').'/users/dashboard'); 176 | } 177 | } 178 | else 179 | { 180 | $userID = $this->Session->read('User.id'); 181 | $this->data = $this->User->read(null,$userID); 182 | $this->data['User']['password']=''; 183 | } 184 | } 185 | function login_as_user($id) 186 | { 187 | if(Configure::read('SparkPlug.allow.login_as_user')==false) return; 188 | $this->force_login_as_user($id); 189 | } 190 | 191 | function force_login_as_user($id){ 192 | $user = $this->User->read(null,$id); 193 | $this->Session->write("User",$user); 194 | $this->Session->write("User.id",$user["User"]["id"]); 195 | $this->Session->write("UserGroup.id",$user["UserGroup"]["id"]); 196 | $this->Session->write("UserGroup.name",$user["UserGroup"]["name"]); 197 | $this->Session->write('Company.id',$user['Company']['id']); 198 | //debug($user); 199 | $this->tinymce_filemanager_init(); 200 | $this->redirect(Configure::read('SparkPlug.loginRedirect')); 201 | } 202 | 203 | function tinymce_filemanager_init() { 204 | @$_SESSION['isLoggedIn'] = true; 205 | @$_SESSION['filemanager.filesystem.path'] = ROOT . DS . APP_DIR . DS. WEBROOT_DIR . DS .'files'.DS.'attachments'; 206 | @$_SESSION['filemanager.filesystem.rootpath'] = ROOT . DS . APP_DIR . DS. WEBROOT_DIR . DS .'files'.DS.'attachments'; 207 | } 208 | 209 | 210 | function login() 211 | { 212 | $this->layout = Configure::read('front_end_layout'); 213 | 214 | if (isset($_GET["ident"])) 215 | { 216 | if ($this->User->activateAccount($_GET)) 217 | { 218 | $this->flash("Thank you. Your account is now active.",Configure::read('httpRootUrl').'/users/login'); 219 | } else { 220 | $this->flash("Sorry. There were problems in your account activation.",Configure::read('httpRootUrl').'/users/login'); 221 | } 222 | } 223 | else 224 | { 225 | //check for facebook connect plugin available 226 | if ($this->Session->read('SparkPlug.facebookEnabled')){ 227 | // check if there is a facebook account logged in and there is no user logged in 228 | if($this->Connect->me && !$this->Authsome->get()){ 229 | // check if there is an user linked to this facebook account 230 | $conds = array('external_auth_id' => 'facebook_' . $this->Connect->me['id']); 231 | $fbuser = $this->User->find($conds); 232 | 233 | // if user exists, do login with it 234 | if($fbuser){ 235 | //debug('user exists. login'); 236 | $this->Session->write('SparkPlug.Users.loggedInByFacebook', true); 237 | $this->force_login_as_user($fbuser['User']['id']); 238 | 239 | } else { 240 | //debug('user does not exist. create'); 241 | // if the user does not exist, create the user using his email as login and do login 242 | $newUser = array(); 243 | $newUser['User']['username'] = $this->Connect->me['id']; 244 | $newUser['User']['password'] = md5( uniqid() ); 245 | $newUser['User']['email'] = $this->Connect->me['email']; 246 | $newUser['User']['user_group_id'] = Configure::read('SparkPlug.default_group_for_new_facebook_accounts'); 247 | $newUser['User']['external_auth_id'] = 'facebook_' . $this->Connect->me['id']; 248 | if ($this->User->save($newUser['User'])){ 249 | $this->Session->setFlash('New user created and linked with your facebook account'); 250 | $this->Session->write('SparkPlug.Users.loggedInByFacebook', true); 251 | $this->force_login_as_user($this->User->getLastInsertId()); 252 | } else { 253 | $this->Session->setFlash('There was an error creating the new user'); 254 | } 255 | } 256 | 257 | ///debug($this->Connect->me); 258 | } 259 | } 260 | 261 | if (empty($this->data)) { 262 | return; 263 | } 264 | 265 | /* if (!empty(Authsome::get()){ 266 | $this->Session->setFlash('Already logged in, logout first'); 267 | return; 268 | } 269 | */ 270 | $user = Authsome::login($this->data['User']); 271 | 272 | if (!$user) { 273 | $this->Session->setFlash('Unknown user or wrong password'); 274 | return; 275 | } 276 | 277 | $remember = (!empty($this->data['User']['remember'])); 278 | if ($remember) 279 | { 280 | Authsome::persist('2 weeks'); 281 | } 282 | 283 | $this->Session->write("User",$user); 284 | $this->Session->write("User.id",$user["User"]["id"]); 285 | $this->Session->write("UserGroup.id",$user["UserGroup"]["id"]); 286 | $this->Session->write("UserGroup.name",$user["UserGroup"]["name"]); 287 | $this->Session->write('Company.id',$user['Company']['id']); 288 | 289 | // let's redirect to the page that triggered the login attempt 290 | $originAfterLogin = $this->Session->read('SparkPlug.OriginAfterLogin'); 291 | $this->tinymce_filemanager_init(); 292 | if (Configure::read('SparkPlug.redirectOriginAfterLogin') && $originAfterLogin != null) { 293 | $this->redirect($originAfterLogin); 294 | } else { 295 | // redirect to default location 296 | $this->redirect(Configure::read('SparkPlug.loginRedirect')); 297 | } 298 | } 299 | } 300 | 301 | function forgotPassword() 302 | { 303 | $this->layout = Configure::read('front_end_layout'); 304 | if ($this->data) 305 | { 306 | $email = $this->data["User"]["email"]; 307 | if ($this->User->forgotPassword($email)) 308 | { 309 | $this->flash("Please check your email for instructions on resetting your password.","login",'success'); 310 | } else { 311 | $this->flash("Your email is invalid or not registered.","login",'error'); 312 | } 313 | } 314 | } 315 | } 316 | ?> 317 | -------------------------------------------------------------------------------- /locale/default.pot: -------------------------------------------------------------------------------- 1 | # LANGUAGE translation of CakePHP Application 2 | # Copyright YEAR NAME 3 | # 4 | #, fuzzy 5 | msgid "" 6 | msgstr "" 7 | "Project-Id-Version: PROJECT VERSION\n" 8 | "POT-Creation-Date: 2010-05-29 20:02+0100\n" 9 | "PO-Revision-Date: YYYY-mm-DD HH:MM+ZZZZ\n" 10 | "Last-Translator: NAME \n" 11 | "Language-Team: LANGUAGE \n" 12 | "MIME-Version: 1.0\n" 13 | "Content-Type: text/plain; charset=utf-8\n" 14 | "Content-Transfer-Encoding: 8bit\n" 15 | "Plural-Forms: nplurals=INTEGER; plural=EXPRESSION;\n" 16 | 17 | #: \views\elements\layout\header.ctp:5 18 | msgid "Login" 19 | msgstr "" 20 | 21 | #: \views\elements\layout\header.ctp:6 22 | msgid "Register" 23 | msgstr "" 24 | 25 | #: \views\elements\layout\header.ctp:9 26 | msgid "User Management" 27 | msgstr "" 28 | 29 | #: \views\elements\layout\header.ctp:17 30 | #: \views\elements\layout\logged_in_menu.default.ctp:6 31 | msgid "Home" 32 | msgstr "" 33 | 34 | #: \views\elements\layout\logged_in_menu.default.ctp:9 35 | #: \views\users\dashboard.ctp:11 36 | msgid "Change Password" 37 | msgstr "" 38 | 39 | #: \views\elements\layout\logged_in_menu.default.ctp:12 40 | msgid "Disconnect" 41 | msgstr "" 42 | 43 | #: \views\user_group_permissions\index.ctp:1 44 | msgid "New User Group Permission" 45 | msgstr "" 46 | 47 | #: \views\user_group_permissions\index.ctp:12 48 | #: \views\users\index.ctp:15 49 | msgid "Actions" 50 | msgstr "" 51 | 52 | #: \views\user_group_permissions\index.ctp:39 53 | #: \views\users\index.ctp:51 54 | msgid "Edit" 55 | msgstr "" 56 | 57 | #: \views\user_group_permissions\index.ctp:40 58 | #: \views\users\index.ctp:52 59 | msgid "Delete" 60 | msgstr "" 61 | 62 | #: \views\user_group_permissions\index.ctp:40 63 | #: \views\users\index.ctp:52 64 | msgid "Are you sure you want to delete # %s?" 65 | msgstr "" 66 | 67 | #: \views\user_group_permissions\index.ctp:48 68 | #: \views\users\index.ctp:60 69 | msgid "previous" 70 | msgstr "" 71 | 72 | #: \views\user_group_permissions\index.ctp:50 73 | #: \views\users\index.ctp:62 74 | msgid "next" 75 | msgstr "" 76 | 77 | #: \views\users\dashboard.ctp:1 78 | msgid "Welcome" 79 | msgstr "" 80 | 81 | #: \views\users\dashboard.ctp:2 82 | msgid "Please select below" 83 | msgstr "" 84 | 85 | #: \views\users\dashboard.ctp:5 86 | msgid "Manage Users" 87 | msgstr "" 88 | 89 | #: \views\users\dashboard.ctp:8 90 | msgid "Manage Permissions" 91 | msgstr "" 92 | 93 | #: \views\users\dashboard.ctp:12 94 | msgid "Logout" 95 | msgstr "" 96 | 97 | #: \views\users\login.ctp:1 98 | msgid "Login your username and password" 99 | msgstr "" 100 | 101 | #: \views\users\login.ctp:3 102 | msgid "username" 103 | msgstr "" 104 | 105 | #: \views\users\login.ctp:4 106 | msgid "password" 107 | msgstr "" 108 | 109 | #: \views\users\login.ctp:5 110 | msgid "Remember me for 2 weeks" 111 | msgstr "" 112 | 113 | #: \views\users\login.ctp:6 114 | msgid "Submit" 115 | msgstr "" 116 | 117 | #: \views\users\login.ctp:9 118 | msgid "Not registered yet?" 119 | msgstr "" 120 | 121 | #: \views\users\login.ctp:9 122 | msgid "Click Here" 123 | msgstr "" 124 | 125 | #: \views\users\login.ctp:11 126 | msgid "Forgot your password?" 127 | msgstr "" 128 | 129 | -------------------------------------------------------------------------------- /locale/esp/LC_MESSAGES/spark_plug.po: -------------------------------------------------------------------------------- 1 | # LANGUAGE translation of CakePHP Application 2 | # Copyright YEAR NAME 3 | # 4 | msgid "" 5 | msgstr "" 6 | "Project-Id-Version: PROJECT VERSION\n" 7 | "POT-Creation-Date: 2010-05-29 20:02+0100\n" 8 | "PO-Revision-Date: 2010-05-29 20:02-0000\n" 9 | "Last-Translator: Steinkel \n" 10 | "Language-Team: \n" 11 | "MIME-Version: 1.0\n" 12 | "Content-Type: text/plain; charset=UTF-8\n" 13 | "Content-Transfer-Encoding: 8bit\n" 14 | "X-Poedit-Language: Spanish\n" 15 | "X-Poedit-Country: SPAIN\n" 16 | 17 | #: \views\elements\layout\header.ctp:5 18 | #, fuzzy 19 | msgid "Login" 20 | msgstr "Nombre de usuario" 21 | 22 | #: \views\elements\layout\header.ctp:6 23 | #, fuzzy 24 | msgid "Register" 25 | msgstr "Registrarse" 26 | 27 | #: \views\elements\layout\header.ctp:9 28 | msgid "User Management" 29 | msgstr "Administrar usuarios" 30 | 31 | #: \views\elements\layout\header.ctp:17 32 | #: \views\elements\layout\logged_in_menu.default.ctp:6 33 | #, fuzzy 34 | msgid "Home" 35 | msgstr "Inicio" 36 | 37 | #: \views\elements\layout\logged_in_menu.default.ctp:9 38 | #: \views\users\dashboard.ctp:11 39 | msgid "Change Password" 40 | msgstr "Cambiar contraseña" 41 | 42 | #: \views\elements\layout\logged_in_menu.default.ctp:12 43 | msgid "Disconnect" 44 | msgstr "Cerrar sesión" 45 | 46 | #: \views\user_group_permissions\index.ctp:1 47 | msgid "New User Group Permission" 48 | msgstr "Nuevo Permiso" 49 | 50 | #: \views\user_group_permissions\index.ctp:12 51 | #: \views\users\index.ctp:15 52 | msgid "Actions" 53 | msgstr "Acciones" 54 | 55 | #: \views\user_group_permissions\index.ctp:39 56 | #: \views\users\index.ctp:51 57 | msgid "Edit" 58 | msgstr "Editar" 59 | 60 | #: \views\user_group_permissions\index.ctp:40 61 | #: \views\users\index.ctp:52 62 | msgid "Delete" 63 | msgstr "Borrar" 64 | 65 | #: \views\user_group_permissions\index.ctp:40 66 | #: \views\users\index.ctp:52 67 | msgid "Are you sure you want to delete # %s?" 68 | msgstr "Seguro que quieres borrar # %s ?" 69 | 70 | #: \views\user_group_permissions\index.ctp:48 71 | #: \views\users\index.ctp:60 72 | msgid "previous" 73 | msgstr "anterior" 74 | 75 | #: \views\user_group_permissions\index.ctp:50 76 | #: \views\users\index.ctp:62 77 | msgid "next" 78 | msgstr "siguiente" 79 | 80 | #: \views\users\dashboard.ctp:1 81 | msgid "Welcome" 82 | msgstr "Bienvenido" 83 | 84 | #: \views\users\dashboard.ctp:2 85 | msgid "Please select below" 86 | msgstr "Elije opción" 87 | 88 | #: \views\users\dashboard.ctp:5 89 | msgid "Manage Users" 90 | msgstr "Administrar Usuarios" 91 | 92 | #: \views\users\dashboard.ctp:8 93 | msgid "Manage Permissions" 94 | msgstr "Administrar Permisos" 95 | 96 | #: \views\users\dashboard.ctp:12 97 | msgid "Logout" 98 | msgstr "Desconectar" 99 | 100 | #: \views\users\login.ctp:1 101 | msgid "Login your username and password" 102 | msgstr "Introduzca su nombre de usuario y contraseña" 103 | 104 | #: \views\users\login.ctp:3 105 | #, fuzzy 106 | msgid "username" 107 | msgstr "Nombre de usuario" 108 | 109 | #: \views\users\login.ctp:4 110 | #, fuzzy 111 | msgid "password" 112 | msgstr "Contraseña" 113 | 114 | #: \views\users\login.ctp:5 115 | msgid "Remember me for 2 weeks" 116 | msgstr "Recordar mi contraseña durante 2 semanas" 117 | 118 | #: \views\users\login.ctp:6 119 | #, fuzzy 120 | msgid "Submit" 121 | msgstr "Enviar" 122 | 123 | #: \views\users\login.ctp:9 124 | msgid "Not registered yet?" 125 | msgstr "¿ No se ha registrado todavía ?" 126 | 127 | #: \views\users\login.ctp:9 128 | msgid "Click Here" 129 | msgstr "Haga click aquí" 130 | 131 | #: \views\users\login.ctp:11 132 | msgid "Forgot your password?" 133 | msgstr "¿ Olvidaste tu contraseña ?" 134 | 135 | msgid "This field cannot be left blank" 136 | msgstr "Por favor, introduzca algún valor en este campo" 137 | 138 | msgid "User Registration" 139 | msgstr "Registro de Usuario" 140 | 141 | msgid "confirm password" 142 | msgstr "Contraseña (de nuevo)" 143 | 144 | msgid "Already registered ?" 145 | msgstr "¿ Ya tiene cuenta de usuario ?" 146 | 147 | msgid "Login Here" 148 | msgstr "Acceda al sistema aquí" 149 | 150 | -------------------------------------------------------------------------------- /models/behaviors/membership.php: -------------------------------------------------------------------------------- 1 | 'class.phpmailer.php')); 3 | class MembershipBehavior extends ModelBehavior 4 | { 5 | var $settings = array(); 6 | var $uploader = null; 7 | function setup(&$Model, $settings) 8 | { 9 | if (!isset($this->settings[$Model->alias])) 10 | { 11 | $this->settings[$Model->alias] = array( 12 | 'option1_key' => 'option1_default_value' 13 | ); 14 | } 15 | $this->settings[$Model->alias] = array_merge( 16 | $this->settings[$Model->alias], (array)$settings); 17 | } 18 | 19 | function getActivationKey(&$Model,$password) 20 | { 21 | $salt = Configure::read ( "Security.salt" ); 22 | return md5(Authsome::hash($password, Configure::read('SparkPlug.hash.method'), Configure::read('SparkPlug.hash.salt')).$salt); 23 | } 24 | function sendRegistrationEmail(&$Model) 25 | { 26 | $mail = new phpmailer(); 27 | $mail->AddAddress($Model->data['User']['email'],$Model->data['User']['username']); 28 | $mail->Subject = $Model->getEmailSubjectNew(); 29 | $message = $Model->getEmailBodyNew(); 30 | 31 | $activate_key = $this->getActivationKey($Model,$Model->data['User']['password']); 32 | 33 | $id = $Model->getLastInsertID(); 34 | $Model->updateAll(array('password'=>"'".Authsome::hash($Model->data['User']['password'], Configure::read('SparkPlug.hash.method'), Configure::read('SparkPlug.hash.salt'))."'"),'User.id = '.$id); 35 | 36 | $id = $Model->getLastInsertID(); 37 | 38 | $link = Router::url("/users/login?ident=$id&activate=$activate_key",true); 39 | 40 | $message = str_replace('{$link}', $link , $message); 41 | 42 | $mail->Body = $message; 43 | 44 | $mail->FromName = Configure::read('SparkPlug.administrator.from_name'); 45 | $mail->From = Configure::read('SparkPlug.administrator.email'); 46 | 47 | $Model->lastRegisteredUser = array('id'=>$id,'activate_key'=>$activate_key); 48 | 49 | if ($Model->useDbConfig!='test_suite') 50 | $mail->Send(); 51 | } 52 | 53 | function activateAccount(&$Model,$getVars) 54 | { 55 | $id = $getVars["ident"]; 56 | $activateKey = $getVars["activate"]; 57 | 58 | $user = $Model->read(null,$id); 59 | if (!empty($user)) 60 | { 61 | $active = $user['User']['active']; 62 | if (empty($active) || $active=='N') 63 | { 64 | $password = $user['User']['password']; 65 | $salt = Configure::read ( "Security.salt" ); 66 | $theKey = md5 ( $password . $salt ); 67 | if ($activateKey==$theKey) 68 | { 69 | //set active and hash password 70 | $Model->updateAll(array('active'=>'1'),'User.id = '.$id); 71 | $output = array('success'=>true,'message'=>'Thank you. Your account is now active.'); 72 | return $output; 73 | } 74 | } 75 | else 76 | { 77 | //user is already activated. 78 | return true; 79 | } 80 | } 81 | else 82 | { 83 | //activation link doesn't exist; 84 | return false; 85 | } 86 | 87 | } 88 | function forgotPassword(&$Model,$email) 89 | { 90 | $user = $Model->find("User.email = '".$email."'"); 91 | if ($user) 92 | { 93 | $id = $user['User']['id']; 94 | 95 | $mail = new phpmailer(); 96 | $mail->AddAddress($user['User']['email'],$user['User']['username']); 97 | 98 | $mail->FromName = Configure::read('SparkPlug.administrator.from_name'); 99 | $mail->From = Configure::read('SparkPlug.administrator.email'); 100 | $mail->Subject = 'Password Reset'; 101 | 102 | $password = $user['User']['password']; 103 | 104 | $salt = Configure::read ( "Security.salt" ); 105 | $activate_key = md5($password.$salt ); 106 | 107 | $link = Router::url ( "/users/activate_password?ident=$id&activate=$activate_key", true ); 108 | 109 | $mail->Body = "Dear ".$user['User']['username'].", 110 | 111 | Kindly click the link below: 112 | ".$link." 113 | 114 | Then set your password. 115 | 116 | Regards, 117 | Site Admin"; 118 | if ($Model->useDbConfig!='test_suite') 119 | $mail->Send(); 120 | 121 | $Model->lastResetPassword = array('id'=>$id,'password'=>$password); 122 | 123 | return true; 124 | } 125 | else 126 | { 127 | return false; 128 | } 129 | } 130 | function changePassword($Model,$data) 131 | { 132 | $Model->set($data); 133 | $valid = $Model->validates(); 134 | if ($valid) 135 | { 136 | $Model->updateAll(array('password'=>"'".Authsome::hash($data['User']['password'], Configure::read('SparkPlug.hash.method'), Configure::read('SparkPlug.hash.salt'))."'"),"User.id = '".$data['User']['id']."'"); 137 | return true; 138 | } 139 | else 140 | { 141 | return false; 142 | } 143 | } 144 | function activatePassword($Model,$data) 145 | { 146 | $user = $Model->read(null,$data['User']['ident']); 147 | if ($user) 148 | { 149 | $password = $user['User']['password']; 150 | $salt = Configure::read ( "Security.salt" ); 151 | $thekey = md5($password.$salt); 152 | 153 | if ($thekey==$data['User']['activate']) 154 | { 155 | $user['User']['password'] = $data['User']['password']; 156 | $user['User']['confirm_password'] = $data['User']['confirm_password']; 157 | if ($Model->save($user)) 158 | { 159 | $Model->updateAll(array('password'=>"'".Authsome::hash($user['User']['password'], Configure::read('SparkPlug.hash.method'), Configure::read('SparkPlug.hash.salt'))."'"),"User.id = '".$data['User']['ident']."'"); 160 | return true; 161 | } 162 | else 163 | { 164 | return false; 165 | } 166 | } 167 | else 168 | { 169 | return false; 170 | } 171 | } 172 | else 173 | { 174 | return false; 175 | } 176 | } 177 | } 178 | ?> -------------------------------------------------------------------------------- /models/company.php: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /models/login_token.php: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /models/user.php: -------------------------------------------------------------------------------- 1 | array('option1'=>'value')); 7 | var $belongsTo = array('SparkPlug.UserGroup'); 8 | 9 | var $hasOne = array('SparkPlug.Company'); 10 | var $hasMany = array('SparkPlug.LoginToken'); 11 | 12 | var $validate = array( 13 | "username" => array( 14 | 'mustUnique'=>array( 15 | 'rule' => array('isUnique'), 16 | 'message' => 'That username is already taken.'), 17 | 'mustBeLonger'=>array( 18 | 'rule' => array('minLength', 3), 19 | 'message'=> 'Username is required and must have a minimum of 3 alphanumeric characters.', 20 | 'last'=>true), 21 | 'mustHaveNoSpecial'=>array( 22 | 'rule' => 'alphaNumericDashUnderscore', 23 | 'message' => 'Username can only be letters, numbers, dash and underscore.'), 24 | ), 25 | 'email'=> array( 26 | 'mustBeEmail'=> array( 27 | // code borrowed from here http://fightingforalostcause.net/misc/2006/compare-email-regex.php 28 | // thanks to James Watts and Francisco Jose Martin Moreno 29 | 'rule' => '/^([\w\!\#$\%\&\'\*\+\-\/\=\?\^\`{\|\}\~]+\.)*[\w\!\#$\%\&\'\*\+\-\/\=\?\^\`{\|\}\~]+@((((([a-z0-9]{1}[a-z0-9\-]{0,62}[a-z0-9]{1})|[a-z])\.)+[a-z]{2,6})|(\d{1,3}\.){3}\d{1,3}(\:\d{1,5})?)$/i', 30 | // end of borrowed code 31 | 'message' => 'Please supply a valid email address.', 32 | 'last'=>true), 33 | 'mustUnique'=>array( 34 | 'rule' =>'isUnique', 35 | 'message' =>'That email is already registered.', 36 | ) 37 | ), 38 | 'confirm_password'=>array( 39 | 'mustBeLonger'=>array( 40 | 'rule' => array('minLength', 4), 41 | 'message'=> 'Your password is too short, please provide 4 characters minimum.', 42 | ), 43 | 'mustMatch'=>array( 44 | 'rule' => array('verifies', 'password'), 45 | 'message' => 'You must fill in the password field and must match with confirm.' 46 | ) 47 | ), 48 | 'captcha'=>array( 49 | 'rule' => 'notEmpty', 50 | 'message' => 'This field cannot be left blank' 51 | ) 52 | ); 53 | 54 | function afterSave($created) 55 | { 56 | if ($created) 57 | { 58 | $companyData['Company']['id'] = null; 59 | $companyData['Company']['user_id'] = $this->getLastInsertID(); 60 | if (isset($this->data['User']['company_name'])) 61 | $companyData['Company']['name'] = $this->data['User']['company_name']; 62 | $this->Company->save($companyData); 63 | $this->sendRegistrationEmail(); 64 | } 65 | } 66 | 67 | function getEmailSubjectNew() 68 | { 69 | return "New Account Registration"; 70 | } 71 | 72 | function getEmailBodyNew() 73 | { 74 | return "Click the link below to register \n {\$link}"; 75 | } 76 | function hashPasswords($data) { 77 | if (!isset($data['User']['confirm_password'])) 78 | { 79 | if (isset($data['User']['password'])) { 80 | $data['User']['password'] = Authsome::hash($data['User']['password'], Configure::read('SparkPlug.hash.method'), Configure::read('SparkPlug.hash.salt')); 81 | return $data; 82 | } 83 | } 84 | return $data; 85 | } 86 | function authsomeLogin($type, $credentials = array()) 87 | { 88 | switch ($type) { 89 | case 'guest': 90 | // You can return any non-null value here, if you don't 91 | // have a guest account, just return an empty array 92 | return array(); 93 | case 'credentials': 94 | $password = Authsome::hash($credentials['password'], Configure::read('SparkPlug.hash.method'), Configure::read('SparkPlug.hash.salt')); 95 | 96 | // This is the logic for validating the login 97 | $conditions = array( 98 | 'User.username' => $credentials['username'], 99 | 'User.password' => $password, 100 | 'User.active' => '1' 101 | ); 102 | break; 103 | case 'cookie': 104 | list($token, $userId) = split(':', $credentials['token']); 105 | $duration = $credentials['duration']; 106 | 107 | $loginToken = $this->LoginToken->find('first', array( 108 | 'conditions' => array( 109 | 'user_id' => $userId, 110 | 'token' => $token, 111 | 'duration' => $duration, 112 | 'used' => false, 113 | 'expires <=' => date('Y-m-d H:i:s', strtotime($duration)), 114 | ), 115 | 'contain' => false 116 | )); 117 | 118 | if (!$loginToken) { 119 | return false; 120 | } 121 | 122 | $loginToken['LoginToken']['used'] = true; 123 | $this->LoginToken->save($loginToken); 124 | 125 | $conditions = array( 126 | 'User.id' => $loginToken['LoginToken']['user_id'] 127 | ); 128 | break; 129 | 130 | default: 131 | return null; 132 | } 133 | 134 | return $this->find('first', compact('conditions')); 135 | } 136 | 137 | function authsomePersist($user, $duration) { 138 | $token = md5(uniqid(mt_rand(), true)); 139 | $userId = $user['User']['id']; 140 | 141 | $this->LoginToken->create(array( 142 | 'user_id' => $userId, 143 | 'token' => $token, 144 | 'duration' => $duration, 145 | 'expires' => date('Y-m-d H:i:s', strtotime($duration)), 146 | )); 147 | $this->LoginToken->save(); 148 | 149 | return "${token}:${userId}"; 150 | } 151 | 152 | } 153 | ?> -------------------------------------------------------------------------------- /models/user_group.php: -------------------------------------------------------------------------------- 1 | getPermissions($userGroupID,$includeGuestPermission); 22 | 23 | //$paths = explode('/',$access); 24 | $actionRequested = Router::parse($access); 25 | //debug($permissions); 26 | //debug($actionRequested); 27 | //$this->log($permissions); 28 | //$this->log($actionRequested); 29 | 30 | foreach($permissions as $perm){ 31 | if ($perm['plugin'] == $actionRequested['plugin'] && 32 | strtoupper($perm['controller']) == strtoupper($actionRequested['controller']) && 33 | ($perm['action'] == '*' || strtoupper($perm['action']) == strtoupper($actionRequested['action']))){ 34 | // authorized 35 | //$this->log("SparkPlug: authorized $access for group id $userGroupID"); 36 | //debug($perm, true); 37 | //die("SparkPlug: authorized $access for group id $userGroupID"); 38 | return true; 39 | } 40 | } 41 | // not authorized 42 | //$this->log("SparkPlug: unauthorized $access for group id $userGroupID"); 43 | //die("SparkPlug: authorized $access for group id $userGroupID"); 44 | 45 | return false; 46 | } 47 | function isGuestAccess($access) 48 | { 49 | return $this->isUserGroupAccess(3, $access, false); 50 | } 51 | 52 | 53 | /** 54 | * Returns an array of permissions for the $userGroupID, it includes the Guest group if $includeGuestPermission 55 | * 56 | * @param $userGroupID 57 | * @param $includeGuestPermission 58 | * @return array of permissions. permissions = array(array('plugin', 'controller', 'action')); 59 | */ 60 | function getPermissions($userGroupID=3,$includeGuestPermission=false) 61 | { 62 | //get public controller actions 63 | $permissions = array(); 64 | 65 | // using the cake cache to store rules 66 | $cacheKey = 'rules_for_group_'.$userGroupID.'_'.$includeGuestPermission; 67 | $actions = Cache::read($cacheKey, 'SparkPlug' ); 68 | if ($actions === false) { 69 | 70 | if ($includeGuestPermission){ 71 | $actions = $this->UserGroupPermission->find('all',array('conditions'=>'(UserGroupPermission.user_group_id = '.$userGroupID.' OR UserGroupPermission.user_group_id = 3) AND UserGroupPermission.allowed = 1')); 72 | } 73 | else { 74 | $actions = $this->UserGroupPermission->find('all',array('conditions'=>'UserGroupPermission.user_group_id = '.$userGroupID.' AND UserGroupPermission.allowed = 1')); 75 | } 76 | Cache::write($cacheKey, $actions, 'SparkPlug'); 77 | } 78 | // else the content is retrieved from the cache 79 | 80 | foreach ($actions as $action) 81 | { 82 | $permissions[] = array('plugin' => $action['UserGroupPermission']['plugin'], 'controller' => $action['UserGroupPermission']['controller'], 'action' => $action['UserGroupPermission']['action']); 83 | } 84 | return $permissions; 85 | } 86 | } 87 | ?> 88 | -------------------------------------------------------------------------------- /models/user_group_permission.php: -------------------------------------------------------------------------------- 1 | 'notEmpty', 10 | 'controller' => 'notEmpty', 11 | 'action' => 'notEmpty' 12 | ); 13 | 14 | function afterSave(){ 15 | $this->__invalidateRulesCache(); 16 | } 17 | 18 | function afterDelete(){ 19 | $this->__invalidateRulesCache(); 20 | } 21 | 22 | /** 23 | * Deletes all the rules cache keys 24 | * @return unknown_type 25 | */ 26 | function __invalidateRulesCache(){ 27 | // clear rule cache 28 | $cacheKeys = array(); 29 | App::import('Model', 'UserGroup'); 30 | $allRules = $this->UserGroup->find('all', array('recursive' => 0)); 31 | foreach($allRules as $r){ 32 | $cacheKeys[] = 'rules_for_group_'.$r['UserGroup']['id'].'_'; 33 | $cacheKeys[] = 'rules_for_group_'.$r['UserGroup']['id'].'_1'; 34 | } 35 | 36 | foreach ($cacheKeys as $k){ 37 | Cache::delete($k, 'SparkPlug'); 38 | } 39 | 40 | } 41 | } 42 | ?> 43 | -------------------------------------------------------------------------------- /spark_plug_app_controller.php: -------------------------------------------------------------------------------- 1 | array( 6 | 'model' => 'User' 7 | ) 8 | ); 9 | 10 | var $helpers = array('SparkPlug.Trans'); 11 | } 12 | ?> -------------------------------------------------------------------------------- /spark_plug_app_model.php: -------------------------------------------------------------------------------- 1 | data[$this->name][$field]); 18 | } 19 | 20 | //Validation message i18n 21 | function invalidate($field, $value = true){ 22 | parent::invalidate($field, $value); 23 | App::import('Helper', 'SparkPlug.Trans'); 24 | $trans = new TransHelper(); 25 | $this->validationErrors[$field] = $trans->__($value); 26 | } 27 | 28 | } 29 | ?> -------------------------------------------------------------------------------- /tests/cases/behaviors/empty: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jedt/spark_plug/062b5bbb1c6b2b2fbc7360b5a28221f1d7f9a22d/tests/cases/behaviors/empty -------------------------------------------------------------------------------- /tests/cases/components/empty: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jedt/spark_plug/062b5bbb1c6b2b2fbc7360b5a28221f1d7f9a22d/tests/cases/components/empty -------------------------------------------------------------------------------- /tests/cases/controllers/empty: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jedt/spark_plug/062b5bbb1c6b2b2fbc7360b5a28221f1d7f9a22d/tests/cases/controllers/empty -------------------------------------------------------------------------------- /tests/cases/helpers/empty: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jedt/spark_plug/062b5bbb1c6b2b2fbc7360b5a28221f1d7f9a22d/tests/cases/helpers/empty -------------------------------------------------------------------------------- /tests/cases/models/user.test.php: -------------------------------------------------------------------------------- 1 | User =& ClassRegistry::init('User'); 14 | } 15 | function testChangePassword() 16 | { 17 | $data['User']['id'] = '1'; 18 | $data['User']['password'] = '1234'; 19 | $data['User']['confirm_password'] = '1234'; 20 | $result = $this->User->changePassword($data); 21 | $this->assertTrue($result); 22 | } 23 | function testChangePasswordError() 24 | { 25 | $data['User']['id'] = '1'; 26 | $data['User']['password'] = '1234'; 27 | $data['User']['confirm_password'] = '1234567'; 28 | $result = $this->User->changePassword($data); 29 | $this->assertFalse($result); 30 | } 31 | function testChangePasswordAndLogin() 32 | { 33 | $data['User']['id'] = '1'; 34 | $data['User']['password'] = 'newpassword1234'; 35 | $data['User']['confirm_password'] = 'newpassword1234'; 36 | $result = $this->User->changePassword($data); 37 | $this->assertTrue($result); 38 | $credentials['username'] = 'sampleuser121'; 39 | $credentials['password'] = 'newpassword1234'; 40 | $user = $this->User->authsomeLogin('credentials',$credentials); 41 | $this->assertTrue($user); 42 | } 43 | function testForgotPassword() 44 | { 45 | $result = $this->User->forgotPassword('fake@mysite.com'); 46 | $this->assertTrue($result); 47 | $this->assertEqual($this->User->lastResetPassword['id'],1); 48 | $this->assertEqual($this->User->lastResetPassword['password'],'e10adc3949ba59abbe56e057f20f883e'); 49 | } 50 | function testForgotPasswordAndLogin() 51 | { 52 | $result = $this->User->forgotPassword('fake@mysite.com'); 53 | $this->assertTrue($result); 54 | $this->assertEqual($this->User->lastResetPassword['id'],1); 55 | $this->assertEqual($this->User->lastResetPassword['password'],'e10adc3949ba59abbe56e057f20f883e'); 56 | 57 | $credentials['username'] = 'sampleuser121'; 58 | $credentials['password'] = '123456'; 59 | $user = $this->User->authsomeLogin('credentials',$credentials); 60 | $this->assertTrue($user); 61 | } 62 | 63 | function testActivateAccountAndLogin() 64 | { 65 | $data['User']['id'] = null; 66 | $data['User']['username'] = 'johnsmith1234'; 67 | $data['User']['password'] = '123456'; 68 | $data['User']['confirm_password'] = '123456'; 69 | $data['User']['email'] = 'jed@bodegasale.com'; 70 | $data['User']['first_name'] = 'John'; 71 | $data['User']['last_name'] = 'Smith'; 72 | $data['User']['user_group_id'] = '2'; 73 | 74 | $result = $this->User->save($data); 75 | $this->assertTrue($result); 76 | 77 | $id = $this->User->getLastInsertID(); 78 | $activate_key = $this->User->getActivationKey($data['User']['password']); 79 | 80 | $getData = array('ident'=>$id,'activate'=>$activate_key); 81 | $this->assertTrue($this->User->activateAccount($getData)); 82 | 83 | $user = $this->User->read(null,$id); 84 | 85 | $credentials['username'] = 'sampleuser121'; 86 | $credentials['password'] = '123456'; 87 | $user = $this->User->authsomeLogin('credentials',$credentials); 88 | $this->assertTrue($user); 89 | $this->assertEqual($user['User']['username'],'sampleuser121'); 90 | } 91 | function testNewRegistration() 92 | { 93 | $data['User']['id'] = null; 94 | $data['User']['username'] = 'johnsmith1234'; 95 | $data['User']['password'] = '123456'; 96 | $data['User']['confirm_password'] = '123456'; 97 | $data['User']['email'] = 'jed@bodegasale.com'; 98 | $data['User']['first_name'] = 'John'; 99 | $data['User']['last_name'] = 'Smith'; 100 | $data['User']['user_group_id'] = '2'; 101 | 102 | $result = $this->User->save($data); 103 | $this->assertTrue($result); 104 | 105 | $record = $this->User->find("User.username = 'johnsmith1234'"); 106 | $this->assertTrue($record); 107 | $this->assertEqual($record['User']['username'],'johnsmith1234'); 108 | $this->assertEqual($record['User']['first_name'],'John'); 109 | } 110 | 111 | function testLogin() 112 | { 113 | $credentials['username'] = 'sampleuser121'; 114 | $credentials['password'] = '123456'; 115 | $user = $this->User->authsomeLogin('credentials',$credentials); 116 | $this->assertTrue($user); 117 | $this->assertEqual($user['User']['username'],'sampleuser121'); 118 | } 119 | 120 | function testLoginFailed() 121 | { 122 | $credentials['username'] = 'sampleuser121'; 123 | $credentials['password'] = '1234'; 124 | $user = $this->User->authsomeLogin('credentials',$credentials); 125 | $this->assertFalse($user); 126 | } 127 | 128 | function testFailedRegistration() 129 | { 130 | $data['User']['id'] = null; 131 | $data['User']['username'] = 'johnsmith1234'; 132 | $data['User']['password'] = ''; 133 | $data['User']['confirm_password'] = ''; 134 | $data['User']['email'] = 'jed@bodegasale.com'; 135 | $data['User']['first_name'] = 'John'; 136 | $data['User']['last_name'] = 'Smith'; 137 | $data['User']['user_group_id'] = '2'; 138 | 139 | $result = $this->User->save($data); 140 | $this->assertFalse($result); 141 | } 142 | 143 | function testNewUserErrorPasswordInvalids() 144 | { 145 | $data['User']['id'] = null; 146 | $data['User']['username'] = 'johnsmith1234'; 147 | $data['User']['password'] = ''; 148 | $data['User']['confirm_password'] = ''; 149 | $data['User']['email'] = 'jed@bodegasale.com'; 150 | $data['User']['first_name'] = 'John'; 151 | $data['User']['last_name'] = 'Smith'; 152 | 153 | $result = $this->User->save($data); 154 | $this->assertFalse($result); 155 | 156 | $data['User']['password'] = '1234'; 157 | $data['User']['confirm_password'] = '123456'; 158 | $result = $this->User->save($data); 159 | $this->assertFalse($result); 160 | } 161 | 162 | function testNewUserErrorUsernameInvalids() 163 | { 164 | //blank username 165 | $data['User']['id'] = null; 166 | $data['User']['username'] = ''; 167 | $data['User']['password'] = '12345678'; 168 | $data['User']['confirm_password'] = '12345678'; 169 | $data['User']['email'] = 'jed@bodegasale.com'; 170 | $data['User']['first_name'] = 'John'; 171 | $data['User']['last_name'] = 'Smith'; 172 | 173 | $result = $this->User->save($data); 174 | $this->assertFalse($result); 175 | 176 | //username with invalid characters 177 | $data['User']['username'] = '12#$%'; 178 | $result = $this->User->save($data); 179 | $this->assertFalse($result); 180 | 181 | //username with short characters 182 | $data['User']['id'] = null; 183 | $data['User']['username'] = 'ab'; 184 | $result = $this->User->save($data); 185 | $this->assertFalse($result); 186 | 187 | //username is duplicate 188 | $data['User']['id'] = null; 189 | $data['User']['username'] = 'sampleuser121'; 190 | $result = $this->User->save($data); 191 | $this->assertFalse($result); 192 | } 193 | 194 | function testNewUserErrorEmailInvalids() 195 | { 196 | //blank email 197 | $data['User']['id'] = null; 198 | $data['User']['username'] = 'johnsmith1234'; 199 | $data['User']['password'] = '12345678'; 200 | $data['User']['confirm_password'] = '12345678'; 201 | $data['User']['email'] = ''; 202 | $data['User']['first_name'] = 'John'; 203 | $data['User']['last_name'] = 'Smith'; 204 | 205 | $result = $this->User->save($data); 206 | $this->assertFalse($result); 207 | 208 | //email with invalid format 209 | $data['User']['email'] = 'jed=mysite.com'; 210 | $result = $this->User->save($data); 211 | $this->assertFalse($result); 212 | 213 | //email duplicate 214 | $data['User']['email'] = 'fake@mysite.com'; 215 | $result = $this->User->save($data); 216 | $this->assertFalse($result); 217 | } 218 | function testActivatePasswordErrorConfirm() 219 | { 220 | $data['User']['ident'] = '1'; 221 | $salt = Configure::read ( "Security.salt" ); 222 | $data['User']['activate'] = md5('e10adc3949ba59abbe56e057f20f883e'.$salt); 223 | $data['User']['password'] = '12345678'; 224 | $data['User']['confirm_password'] = '1234'; 225 | $result = $this->User->activatePassword($data); 226 | $this->assertFalse($result); 227 | } 228 | function testActivatePasswordErrorInvalidKey() 229 | { 230 | $data['User']['ident'] = '1'; 231 | $salt = Configure::read ( "Security.salt" ); 232 | $data['User']['activate'] = md5('easdfasdfasdfsd883e'.$salt); 233 | $data['User']['password'] = '1234'; 234 | $data['User']['confirm_password'] = '1234'; 235 | $result = $this->User->activatePassword($data); 236 | $this->assertFalse($result); 237 | } 238 | } 239 | ?> -------------------------------------------------------------------------------- /tests/cases/models/user_group.test.php: -------------------------------------------------------------------------------- 1 | UserGroup =& ClassRegistry::init('UserGroup'); 14 | } 15 | function testUserGroupNoAccess() 16 | { 17 | $this->assertFalse($this->UserGroup->isGuestAccess('Websites/add')); 18 | } 19 | function testUserGroupWildCardAccess() 20 | { 21 | $this->assertTrue($this->UserGroup->isUserGroupAccess(2,'Pages/add')); 22 | } 23 | function testWildCardGuestAccess() 24 | { 25 | $this->assertTrue($this->UserGroup->isGuestAccess('Pages/add')); 26 | } 27 | function testPermissionWildCardAddWildcard() 28 | { 29 | $newPermission = array('UserGroupPermission'=> 30 | array( 31 | 'user_group_id'=>'2', 32 | 'controller'=>'Posts', 33 | 'action'=>'*' 34 | )); 35 | 36 | $this->assertTrue($this->UserGroup->UserGroupPermission->save($newPermission)); 37 | 38 | 39 | $userPermissions = $this->UserGroup->getPermissions(2); 40 | 41 | $this->assertTrue($userPermissions); 42 | $this->assertEqual($userPermissions[0],'/'); 43 | $this->assertEqual($userPermissions[1],'Websites/*'); 44 | $this->assertEqual($userPermissions[2],'Pages/*'); 45 | $this->assertEqual($userPermissions[3],'Posts/*'); 46 | } 47 | function testPermissionWildCardAddSingleAction() 48 | { 49 | $newPermission = array('UserGroupPermission'=> 50 | array( 51 | 'user_group_id'=>'2', 52 | 'controller'=>'Posts', 53 | 'action'=>'add' 54 | )); 55 | 56 | $this->assertTrue($this->UserGroup->UserGroupPermission->save($newPermission)); 57 | 58 | 59 | $userPermissions = $this->UserGroup->getPermissions(2); 60 | 61 | $this->assertTrue($userPermissions); 62 | $this->assertEqual($userPermissions[0],'/'); 63 | $this->assertEqual($userPermissions[1],'Websites/*'); 64 | $this->assertEqual($userPermissions[2],'Pages/*'); 65 | $this->assertEqual($userPermissions[3],'Posts/add'); 66 | } 67 | function testPermissionWildCardDefault() 68 | { 69 | //must test functionality of access websites/* 70 | $userPermissions = $this->UserGroup->getPermissions(2); 71 | $this->assertTrue($userPermissions); 72 | $this->assertEqual($userPermissions[0],'/'); 73 | $this->assertEqual($userPermissions[1],'Websites/*'); 74 | } 75 | function testPermission() 76 | { 77 | $this->assertTrue($this->UserGroup->isGuestAccess('users/login')); 78 | $this->assertTrue($this->UserGroup->isGuestAccess('Users/register')); 79 | $this->assertTrue($this->UserGroup->isGuestAccess('Users/logout')); 80 | } 81 | 82 | } 83 | ?> -------------------------------------------------------------------------------- /tests/fixtures/company_fixture.php: -------------------------------------------------------------------------------- 1 | 'SparkPlug.Company','records'=>false); 6 | 7 | var $records = array( 8 | array('id'=>'1','user_id'=>'1') 9 | ); 10 | } 11 | ?> -------------------------------------------------------------------------------- /tests/fixtures/login_token_fixture.php: -------------------------------------------------------------------------------- 1 | 'SparkPlug.LoginToken','records'=>false); 6 | } 7 | ?> -------------------------------------------------------------------------------- /tests/fixtures/user_fixture.php: -------------------------------------------------------------------------------- 1 | 'SparkPlug.User','records'=>false); 6 | var $records = array( 7 | array( 8 | 'id'=>1, 9 | 'user_group_id'=>'2', 10 | 'username'=>'sampleuser121', 11 | 'password'=>'e10adc3949ba59abbe56e057f20f883e', 12 | 'first_name'=>'John', 13 | 'last_name'=>'Doe', 14 | 'email'=>'fake@mysite.com', 15 | 'active'=>1), 16 | array('id'=>101, 17 | 'user_group_id'=>'2', 18 | 'username'=>'deletableuser', 19 | 'password'=>'e10adc3949ba59abbe56e057f20f883e', 20 | 'first_name'=>'Peter', 21 | 'last_name'=>'Doe', 22 | 'email'=>'fake2@mysite.com', 23 | 'active'=>1) 24 | ); 25 | } 26 | ?> -------------------------------------------------------------------------------- /tests/fixtures/user_group_fixture.php: -------------------------------------------------------------------------------- 1 | 'SparkPlug.UserGroup','records'=>false); 6 | var $records = array( 7 | array('id'=>'1','name'=>'Admin'), 8 | array('id'=>'2','name'=>'User'), 9 | array('id'=>'3','name'=>'Guest'), 10 | ); 11 | } 12 | ?> -------------------------------------------------------------------------------- /tests/fixtures/user_group_permission_fixture.php: -------------------------------------------------------------------------------- 1 | 'SparkPlug.UserGroupPermission','records'=>false); 6 | 7 | var $records = array( 8 | array( 9 | 'id'=>1, 10 | 'user_group_id'=>3, 11 | 'controller'=>'Users', 12 | 'action'=>'register', 13 | 'allowed'=>1 14 | ), 15 | array( 16 | 'id'=>2, 17 | 'user_group_id'=>3, 18 | 'controller'=>'Users', 19 | 'action'=>'login', 20 | 'allowed'=>1 21 | ), 22 | array( 23 | 'id'=>3, 24 | 'user_group_id'=>3, 25 | 'controller'=>'Users', 26 | 'action'=>'logout', 27 | 'allowed'=>1 28 | ), 29 | array( 30 | 'id'=>4, 31 | 'user_group_id'=>3, 32 | 'controller'=>'Users', 33 | 'action'=>'forgot_password', 34 | 'allowed'=>1 35 | ), 36 | array( 37 | 'id'=>5, 38 | 'user_group_id'=>2, 39 | 'controller'=>'Websites', 40 | 'action'=>'*', 41 | 'allowed'=>1 42 | ), 43 | array( 44 | 'id'=>6, 45 | 'user_group_id'=>3, 46 | 'controller'=>'Pages', 47 | 'action'=>'*', 48 | 'allowed'=>1 49 | ), 50 | array( 51 | 'id'=>7, 52 | 'user_group_id'=>2, 53 | 'controller'=>'Pages', 54 | 'action'=>'*', 55 | 'allowed'=>1 56 | ) 57 | ); 58 | } 59 | ?> -------------------------------------------------------------------------------- /tests/groups/empty: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jedt/spark_plug/062b5bbb1c6b2b2fbc7360b5a28221f1d7f9a22d/tests/groups/empty -------------------------------------------------------------------------------- /vendors/phpmailer/class.smtp.php: -------------------------------------------------------------------------------- 1 | 10 | * Created: 03/26/2001 11 | * 12 | * TODO: 13 | * - Move all the duplicate code to a utility function 14 | * Most of the functions have the first lines of 15 | * code do the same processing. If this can be moved 16 | * into a utility function then it would reduce the 17 | * overall size of the code significantly. 18 | */ 19 | 20 | /* 21 | * STMP is rfc 821 compliant and implements all the rfc 821 SMTP 22 | * commands except TURN which will always return a not implemented 23 | * error. SMTP also provides some utility methods for sending mail 24 | * to an SMTP server. 25 | */ 26 | class SMTP { 27 | var $SMTP_PORT = 25; # the default SMTP PORT 28 | var $CRLF = "\r\n"; # CRLF pair 29 | 30 | var $smtp_conn; # the socket to the server 31 | var $error; # error if any on the last call 32 | var $helo_rply; # the reply the server sent to us for HELO 33 | 34 | var $do_debug; # the level of debug to perform 35 | 36 | /* 37 | * SMTP() 38 | * 39 | * Initialize the class so that the data is in a known state. 40 | */ 41 | function SMTP() { 42 | $this->smtp_conn = 0; 43 | $this->error = null; 44 | $this->helo_rply = null; 45 | 46 | $this->do_debug = 0; 47 | } 48 | 49 | /************************************************************ 50 | * CONNECTION FUNCTIONS * 51 | ***********************************************************/ 52 | 53 | /* 54 | * Connect($host, $port=0, $tval=30) 55 | * 56 | * Connect to the server specified on the port specified. 57 | * If the port is not specified use the default SMTP_PORT. 58 | * If tval is specified then a connection will try and be 59 | * established with the server for that number of seconds. 60 | * If tval is not specified the default is 30 seconds to 61 | * try on the connection. 62 | * 63 | * SMTP CODE SUCCESS: 220 64 | * SMTP CODE FAILURE: 421 65 | */ 66 | function Connect($host,$port=0,$tval=30) { 67 | # set the error val to null so there is no confusion 68 | $this->error = null; 69 | 70 | # make sure we are __not__ connected 71 | if($this->connected()) { 72 | # ok we are connected! what should we do? 73 | # for now we will just give an error saying we 74 | # are already connected 75 | $this->error = 76 | array("error" => "Already connected to a server"); 77 | return false; 78 | } 79 | 80 | if(empty($port)) { 81 | $port = $this->SMTP_PORT; 82 | } 83 | 84 | #connect to the smtp server 85 | $this->smtp_conn = fsockopen($host, # the host of the server 86 | $port, # the port to use 87 | $errno, # error number if any 88 | $errstr, # error message if any 89 | $tval); # give up after ? secs 90 | # verify we connected properly 91 | if(empty($this->smtp_conn)) { 92 | $this->error = array("error" => "Failed to connect to server", 93 | "errno" => $errno, 94 | "errstr" => $errstr); 95 | if($this->do_debug >= 1) { 96 | echo "SMTP -> ERROR: " . $this->error["error"] . 97 | ": $errstr ($errno)" . $this->CRLF; 98 | } 99 | return false; 100 | } 101 | 102 | # sometimes the SMTP server takes a little longer to respond 103 | # so we will give it a longer timeout for the first read 104 | // Windows still does not have support for this timeout function 105 | if(substr(PHP_OS, 0, 3) != "WIN") 106 | socket_set_timeout($this->smtp_conn, 1, 0); 107 | 108 | # get any announcement stuff 109 | $announce = $this->get_lines(); 110 | 111 | # set the timeout of any socket functions at 1/10 of a second 112 | //if(function_exists("socket_set_timeout")) 113 | // socket_set_timeout($this->smtp_conn, 0, 100000); 114 | 115 | if($this->do_debug >= 2) { 116 | echo "SMTP -> FROM SERVER:" . $this->CRLF . $announce; 117 | } 118 | 119 | return true; 120 | } 121 | 122 | /* 123 | * Authenticate() 124 | * 125 | * Performs SMTP authentication. Must be run after running the 126 | * Hello() method. Returns true if successfully authenticated. 127 | */ 128 | function Authenticate($username, $password) { 129 | // Start authentication 130 | fputs($this->smtp_conn,"AUTH LOGIN" . $this->CRLF); 131 | 132 | $rply = $this->get_lines(); 133 | $code = substr($rply,0,3); 134 | 135 | if($code != 334) { 136 | $this->error = 137 | array("error" => "AUTH not accepted from server", 138 | "smtp_code" => $code, 139 | "smtp_msg" => substr($rply,4)); 140 | if($this->do_debug >= 1) { 141 | echo "SMTP -> ERROR: " . $this->error["error"] . 142 | ": " . $rply . $this->CRLF; 143 | } 144 | return false; 145 | } 146 | 147 | // Send encoded username 148 | fputs($this->smtp_conn, base64_encode($username) . $this->CRLF); 149 | 150 | $rply = $this->get_lines(); 151 | $code = substr($rply,0,3); 152 | 153 | if($code != 334) { 154 | $this->error = 155 | array("error" => "Username not accepted from server", 156 | "smtp_code" => $code, 157 | "smtp_msg" => substr($rply,4)); 158 | if($this->do_debug >= 1) { 159 | echo "SMTP -> ERROR: " . $this->error["error"] . 160 | ": " . $rply . $this->CRLF; 161 | } 162 | return false; 163 | } 164 | 165 | // Send encoded password 166 | fputs($this->smtp_conn, base64_encode($password) . $this->CRLF); 167 | 168 | $rply = $this->get_lines(); 169 | $code = substr($rply,0,3); 170 | 171 | if($code != 235) { 172 | $this->error = 173 | array("error" => "Password not accepted from server", 174 | "smtp_code" => $code, 175 | "smtp_msg" => substr($rply,4)); 176 | if($this->do_debug >= 1) { 177 | echo "SMTP -> ERROR: " . $this->error["error"] . 178 | ": " . $rply . $this->CRLF; 179 | } 180 | return false; 181 | } 182 | 183 | return true; 184 | } 185 | 186 | /* 187 | * Connected() 188 | * 189 | * Returns true if connected to a server otherwise false 190 | */ 191 | function Connected() { 192 | if(!empty($this->smtp_conn)) { 193 | $sock_status = socket_get_status($this->smtp_conn); 194 | if($sock_status["eof"]) { 195 | # hmm this is an odd situation... the socket is 196 | # valid but we aren't connected anymore 197 | if($this->do_debug >= 1) { 198 | echo "SMTP -> NOTICE:" . $this->CRLF . 199 | "EOF caught while checking if connected"; 200 | } 201 | $this->Close(); 202 | return false; 203 | } 204 | return true; # everything looks good 205 | } 206 | return false; 207 | } 208 | 209 | /* 210 | * Close() 211 | * 212 | * Closes the socket and cleans up the state of the class. 213 | * It is not considered good to use this function without 214 | * first trying to use QUIT. 215 | */ 216 | function Close() { 217 | $this->error = null; # so there is no confusion 218 | $this->helo_rply = null; 219 | if(!empty($this->smtp_conn)) { 220 | # close the connection and cleanup 221 | fclose($this->smtp_conn); 222 | $this->smtp_conn = 0; 223 | } 224 | } 225 | 226 | 227 | /************************************************************** 228 | * SMTP COMMANDS * 229 | *************************************************************/ 230 | 231 | /* 232 | * Data($msg_data) 233 | * 234 | * Issues a data command and sends the msg_data to the server 235 | * finializing the mail transaction. $msg_data is the message 236 | * that is to be send with the headers. Each header needs to be 237 | * on a single line followed by a with the message headers 238 | * and the message body being seperated by and additional . 239 | * 240 | * Implements rfc 821: DATA 241 | * 242 | * SMTP CODE INTERMEDIATE: 354 243 | * [data] 244 | * . 245 | * SMTP CODE SUCCESS: 250 246 | * SMTP CODE FAILURE: 552,554,451,452 247 | * SMTP CODE FAILURE: 451,554 248 | * SMTP CODE ERROR : 500,501,503,421 249 | */ 250 | function Data($msg_data) { 251 | $this->error = null; # so no confusion is caused 252 | 253 | if(!$this->connected()) { 254 | $this->error = array( 255 | "error" => "Called Data() without being connected"); 256 | return false; 257 | } 258 | 259 | fputs($this->smtp_conn,"DATA" . $this->CRLF); 260 | 261 | $rply = $this->get_lines(); 262 | $code = substr($rply,0,3); 263 | 264 | if($this->do_debug >= 2) { 265 | echo "SMTP -> FROM SERVER:" . $this->CRLF . $rply; 266 | } 267 | 268 | if($code != 354) { 269 | $this->error = 270 | array("error" => "DATA command not accepted from server", 271 | "smtp_code" => $code, 272 | "smtp_msg" => substr($rply,4)); 273 | if($this->do_debug >= 1) { 274 | echo "SMTP -> ERROR: " . $this->error["error"] . 275 | ": " . $rply . $this->CRLF; 276 | } 277 | return false; 278 | } 279 | 280 | # the server is ready to accept data! 281 | # according to rfc 821 we should not send more than 1000 282 | # including the CRLF 283 | # characters on a single line so we will break the data up 284 | # into lines by \r and/or \n then if needed we will break 285 | # each of those into smaller lines to fit within the limit. 286 | # in addition we will be looking for lines that start with 287 | # a period '.' and append and additional period '.' to that 288 | # line. NOTE: this does not count towards are limit. 289 | 290 | # normalize the line breaks so we know the explode works 291 | $msg_data = str_replace("\r\n","\n",$msg_data); 292 | $msg_data = str_replace("\r","\n",$msg_data); 293 | $lines = explode("\n",$msg_data); 294 | 295 | # we need to find a good way to determine is headers are 296 | # in the msg_data or if it is a straight msg body 297 | # currently I'm assuming rfc 822 definitions of msg headers 298 | # and if the first field of the first line (':' sperated) 299 | # does not contain a space then it _should_ be a header 300 | # and we can process all lines before a blank "" line as 301 | # headers. 302 | $field = substr($lines[0],0,strpos($lines[0],":")); 303 | $in_headers = false; 304 | if(!empty($field) && !strstr($field," ")) { 305 | $in_headers = true; 306 | } 307 | 308 | $max_line_length = 998; # used below; set here for ease in change 309 | 310 | while(list(,$line) = @each($lines)) { 311 | $lines_out = null; 312 | if($line == "" && $in_headers) { 313 | $in_headers = false; 314 | } 315 | # ok we need to break this line up into several 316 | # smaller lines 317 | while(strlen($line) > $max_line_length) { 318 | $pos = strrpos(substr($line,0,$max_line_length)," "); 319 | $lines_out[] = substr($line,0,$pos); 320 | $line = substr($line,$pos + 1); 321 | # if we are processing headers we need to 322 | # add a LWSP-char to the front of the new line 323 | # rfc 822 on long msg headers 324 | if($in_headers) { 325 | $line = "\t" . $line; 326 | } 327 | } 328 | $lines_out[] = $line; 329 | 330 | # now send the lines to the server 331 | while(list(,$line_out) = @each($lines_out)) { 332 | if(strlen($line_out) > 0) 333 | { 334 | if(substr($line_out, 0, 1) == ".") { 335 | $line_out = "." . $line_out; 336 | } 337 | } 338 | fputs($this->smtp_conn,$line_out . $this->CRLF); 339 | } 340 | } 341 | 342 | # ok all the message data has been sent so lets get this 343 | # over with aleady 344 | fputs($this->smtp_conn, $this->CRLF . "." . $this->CRLF); 345 | 346 | $rply = $this->get_lines(); 347 | $code = substr($rply,0,3); 348 | 349 | if($this->do_debug >= 2) { 350 | echo "SMTP -> FROM SERVER:" . $this->CRLF . $rply; 351 | } 352 | 353 | if($code != 250) { 354 | $this->error = 355 | array("error" => "DATA not accepted from server", 356 | "smtp_code" => $code, 357 | "smtp_msg" => substr($rply,4)); 358 | if($this->do_debug >= 1) { 359 | echo "SMTP -> ERROR: " . $this->error["error"] . 360 | ": " . $rply . $this->CRLF; 361 | } 362 | return false; 363 | } 364 | return true; 365 | } 366 | 367 | /* 368 | * Expand($name) 369 | * 370 | * Expand takes the name and asks the server to list all the 371 | * people who are members of the _list_. Expand will return 372 | * back and array of the result or false if an error occurs. 373 | * Each value in the array returned has the format of: 374 | * [ ] 375 | * The definition of is defined in rfc 821 376 | * 377 | * Implements rfc 821: EXPN 378 | * 379 | * SMTP CODE SUCCESS: 250 380 | * SMTP CODE FAILURE: 550 381 | * SMTP CODE ERROR : 500,501,502,504,421 382 | */ 383 | function Expand($name) { 384 | $this->error = null; # so no confusion is caused 385 | 386 | if(!$this->connected()) { 387 | $this->error = array( 388 | "error" => "Called Expand() without being connected"); 389 | return false; 390 | } 391 | 392 | fputs($this->smtp_conn,"EXPN " . $name . $this->CRLF); 393 | 394 | $rply = $this->get_lines(); 395 | $code = substr($rply,0,3); 396 | 397 | if($this->do_debug >= 2) { 398 | echo "SMTP -> FROM SERVER:" . $this->CRLF . $rply; 399 | } 400 | 401 | if($code != 250) { 402 | $this->error = 403 | array("error" => "EXPN not accepted from server", 404 | "smtp_code" => $code, 405 | "smtp_msg" => substr($rply,4)); 406 | if($this->do_debug >= 1) { 407 | echo "SMTP -> ERROR: " . $this->error["error"] . 408 | ": " . $rply . $this->CRLF; 409 | } 410 | return false; 411 | } 412 | 413 | # parse the reply and place in our array to return to user 414 | $entries = explode($this->CRLF,$rply); 415 | while(list(,$l) = @each($entries)) { 416 | $list[] = substr($l,4); 417 | } 418 | 419 | return $rval; 420 | } 421 | 422 | /* 423 | * Hello($host="") 424 | * 425 | * Sends the HELO command to the smtp server. 426 | * This makes sure that we and the server are in 427 | * the same known state. 428 | * 429 | * Implements from rfc 821: HELO 430 | * 431 | * SMTP CODE SUCCESS: 250 432 | * SMTP CODE ERROR : 500, 501, 504, 421 433 | */ 434 | function Hello($host="") { 435 | $this->error = null; # so no confusion is caused 436 | 437 | if(!$this->connected()) { 438 | $this->error = array( 439 | "error" => "Called Hello() without being connected"); 440 | return false; 441 | } 442 | 443 | # if a hostname for the HELO wasn't specified determine 444 | # a suitable one to send 445 | if(empty($host)) { 446 | # we need to determine some sort of appopiate default 447 | # to send to the server 448 | $host = "localhost"; 449 | } 450 | 451 | fputs($this->smtp_conn,"HELO " . $host . $this->CRLF); 452 | 453 | $rply = $this->get_lines(); 454 | $code = substr($rply,0,3); 455 | 456 | if($this->do_debug >= 2) { 457 | echo "SMTP -> FROM SERVER: " . $this->CRLF . $rply; 458 | } 459 | 460 | if($code != 250) { 461 | $this->error = 462 | array("error" => "HELO not accepted from server", 463 | "smtp_code" => $code, 464 | "smtp_msg" => substr($rply,4)); 465 | if($this->do_debug >= 1) { 466 | echo "SMTP -> ERROR: " . $this->error["error"] . 467 | ": " . $rply . $this->CRLF; 468 | } 469 | return false; 470 | } 471 | 472 | $this->helo_rply = $rply; 473 | 474 | return true; 475 | } 476 | 477 | /* 478 | * Help($keyword="") 479 | * 480 | * Gets help information on the keyword specified. If the keyword 481 | * is not specified then returns generic help, ussually contianing 482 | * A list of keywords that help is available on. This function 483 | * returns the results back to the user. It is up to the user to 484 | * handle the returned data. If an error occurs then false is 485 | * returned with $this->error set appropiately. 486 | * 487 | * Implements rfc 821: HELP [ ] 488 | * 489 | * SMTP CODE SUCCESS: 211,214 490 | * SMTP CODE ERROR : 500,501,502,504,421 491 | * 492 | */ 493 | function Help($keyword="") { 494 | $this->error = null; # to avoid confusion 495 | 496 | if(!$this->connected()) { 497 | $this->error = array( 498 | "error" => "Called Help() without being connected"); 499 | return false; 500 | } 501 | 502 | $extra = ""; 503 | if(!empty($keyword)) { 504 | $extra = " " . $keyword; 505 | } 506 | 507 | fputs($this->smtp_conn,"HELP" . $extra . $this->CRLF); 508 | 509 | $rply = $this->get_lines(); 510 | $code = substr($rply,0,3); 511 | 512 | if($this->do_debug >= 2) { 513 | echo "SMTP -> FROM SERVER:" . $this->CRLF . $rply; 514 | } 515 | 516 | if($code != 211 && $code != 214) { 517 | $this->error = 518 | array("error" => "HELP not accepted from server", 519 | "smtp_code" => $code, 520 | "smtp_msg" => substr($rply,4)); 521 | if($this->do_debug >= 1) { 522 | echo "SMTP -> ERROR: " . $this->error["error"] . 523 | ": " . $rply . $this->CRLF; 524 | } 525 | return false; 526 | } 527 | 528 | return $rply; 529 | } 530 | 531 | /* 532 | * Mail($from) 533 | * 534 | * Starts a mail transaction from the email address specified in 535 | * $from. Returns true if successful or false otherwise. If True 536 | * the mail transaction is started and then one or more Recipient 537 | * commands may be called followed by a Data command. 538 | * 539 | * Implements rfc 821: MAIL FROM: 540 | * 541 | * SMTP CODE SUCCESS: 250 542 | * SMTP CODE SUCCESS: 552,451,452 543 | * SMTP CODE SUCCESS: 500,501,421 544 | */ 545 | function Mail($from) { 546 | $this->error = null; # so no confusion is caused 547 | 548 | if(!$this->connected()) { 549 | $this->error = array( 550 | "error" => "Called Mail() without being connected"); 551 | return false; 552 | } 553 | 554 | fputs($this->smtp_conn,"MAIL FROM:" . $from . $this->CRLF); 555 | 556 | $rply = $this->get_lines(); 557 | $code = substr($rply,0,3); 558 | 559 | if($this->do_debug >= 2) { 560 | echo "SMTP -> FROM SERVER:" . $this->CRLF . $rply; 561 | } 562 | 563 | if($code != 250) { 564 | $this->error = 565 | array("error" => "MAIL not accepted from server", 566 | "smtp_code" => $code, 567 | "smtp_msg" => substr($rply,4)); 568 | if($this->do_debug >= 1) { 569 | echo "SMTP -> ERROR: " . $this->error["error"] . 570 | ": " . $rply . $this->CRLF; 571 | } 572 | return false; 573 | } 574 | return true; 575 | } 576 | 577 | /* 578 | * Noop() 579 | * 580 | * Sends the command NOOP to the SMTP server. 581 | * 582 | * Implements from rfc 821: NOOP 583 | * 584 | * SMTP CODE SUCCESS: 250 585 | * SMTP CODE ERROR : 500, 421 586 | */ 587 | function Noop() { 588 | $this->error = null; # so no confusion is caused 589 | 590 | if(!$this->connected()) { 591 | $this->error = array( 592 | "error" => "Called Noop() without being connected"); 593 | return false; 594 | } 595 | 596 | fputs($this->smtp_conn,"NOOP" . $this->CRLF); 597 | 598 | $rply = $this->get_lines(); 599 | $code = substr($rply,0,3); 600 | 601 | if($this->do_debug >= 2) { 602 | echo "SMTP -> FROM SERVER:" . $this->CRLF . $rply; 603 | } 604 | 605 | if($code != 250) { 606 | $this->error = 607 | array("error" => "NOOP not accepted from server", 608 | "smtp_code" => $code, 609 | "smtp_msg" => substr($rply,4)); 610 | if($this->do_debug >= 1) { 611 | echo "SMTP -> ERROR: " . $this->error["error"] . 612 | ": " . $rply . $this->CRLF; 613 | } 614 | return false; 615 | } 616 | return true; 617 | } 618 | 619 | /* 620 | * Quit($close_on_error=true) 621 | * 622 | * Sends the quit command to the server and then closes the socket 623 | * if there is no error or the $close_on_error argument is true. 624 | * 625 | * Implements from rfc 821: QUIT 626 | * 627 | * SMTP CODE SUCCESS: 221 628 | * SMTP CODE ERROR : 500 629 | */ 630 | function Quit($close_on_error=true) { 631 | $this->error = null; # so there is no confusion 632 | 633 | if(!$this->connected()) { 634 | $this->error = array( 635 | "error" => "Called Quit() without being connected"); 636 | return false; 637 | } 638 | 639 | # send the quit command to the server 640 | fputs($this->smtp_conn,"quit" . $this->CRLF); 641 | 642 | # get any good-bye messages 643 | $byemsg = $this->get_lines(); 644 | 645 | if($this->do_debug >= 2) { 646 | echo "SMTP -> FROM SERVER:" . $this->CRLF . $byemsg; 647 | } 648 | 649 | $rval = true; 650 | $e = null; 651 | 652 | $code = substr($byemsg,0,3); 653 | if($code != 221) { 654 | # use e as a tmp var cause Close will overwrite $this->error 655 | $e = array("error" => "SMTP server rejected quit command", 656 | "smtp_code" => $code, 657 | "smtp_rply" => substr($byemsg,4)); 658 | $rval = false; 659 | if($this->do_debug >= 1) { 660 | echo "SMTP -> ERROR: " . $e["error"] . ": " . 661 | $byemsg . $this->CRLF; 662 | } 663 | } 664 | 665 | if(empty($e) || $close_on_error) { 666 | $this->Close(); 667 | } 668 | 669 | return $rval; 670 | } 671 | 672 | /* 673 | * Recipient($to) 674 | * 675 | * Sends the command RCPT to the SMTP server with the TO: argument of $to. 676 | * Returns true if the recipient was accepted false if it was rejected. 677 | * 678 | * Implements from rfc 821: RCPT TO: 679 | * 680 | * SMTP CODE SUCCESS: 250,251 681 | * SMTP CODE FAILURE: 550,551,552,553,450,451,452 682 | * SMTP CODE ERROR : 500,501,503,421 683 | */ 684 | function Recipient($to) { 685 | $this->error = null; # so no confusion is caused 686 | 687 | if(!$this->connected()) { 688 | $this->error = array( 689 | "error" => "Called Recipient() without being connected"); 690 | return false; 691 | } 692 | 693 | fputs($this->smtp_conn,"RCPT TO:" . $to . $this->CRLF); 694 | 695 | $rply = $this->get_lines(); 696 | $code = substr($rply,0,3); 697 | 698 | if($this->do_debug >= 2) { 699 | echo "SMTP -> FROM SERVER:" . $this->CRLF . $rply; 700 | } 701 | 702 | if($code != 250 && $code != 251) { 703 | $this->error = 704 | array("error" => "RCPT not accepted from server", 705 | "smtp_code" => $code, 706 | "smtp_msg" => substr($rply,4)); 707 | if($this->do_debug >= 1) { 708 | echo "SMTP -> ERROR: " . $this->error["error"] . 709 | ": " . $rply . $this->CRLF; 710 | } 711 | return false; 712 | } 713 | return true; 714 | } 715 | 716 | /* 717 | * Reset() 718 | * 719 | * Sends the RSET command to abort and transaction that is 720 | * currently in progress. Returns true if successful false 721 | * otherwise. 722 | * 723 | * Implements rfc 821: RSET 724 | * 725 | * SMTP CODE SUCCESS: 250 726 | * SMTP CODE ERROR : 500,501,504,421 727 | */ 728 | function Reset() { 729 | $this->error = null; # so no confusion is caused 730 | 731 | if(!$this->connected()) { 732 | $this->error = array( 733 | "error" => "Called Reset() without being connected"); 734 | return false; 735 | } 736 | 737 | fputs($this->smtp_conn,"RSET" . $this->CRLF); 738 | 739 | $rply = $this->get_lines(); 740 | $code = substr($rply,0,3); 741 | 742 | if($this->do_debug >= 2) { 743 | echo "SMTP -> FROM SERVER:" . $this->CRLF . $rply; 744 | } 745 | 746 | if($code != 250) { 747 | $this->error = 748 | array("error" => "RSET failed", 749 | "smtp_code" => $code, 750 | "smtp_msg" => substr($rply,4)); 751 | if($this->do_debug >= 1) { 752 | echo "SMTP -> ERROR: " . $this->error["error"] . 753 | ": " . $rply . $this->CRLF; 754 | } 755 | return false; 756 | } 757 | 758 | return true; 759 | } 760 | 761 | /* 762 | * Send($from) 763 | * 764 | * Starts a mail transaction from the email address specified in 765 | * $from. Returns true if successful or false otherwise. If True 766 | * the mail transaction is started and then one or more Recipient 767 | * commands may be called followed by a Data command. This command 768 | * will send the message to the users terminal if they are logged 769 | * in. 770 | * 771 | * Implements rfc 821: SEND FROM: 772 | * 773 | * SMTP CODE SUCCESS: 250 774 | * SMTP CODE SUCCESS: 552,451,452 775 | * SMTP CODE SUCCESS: 500,501,502,421 776 | */ 777 | function Send($from) { 778 | $this->error = null; # so no confusion is caused 779 | 780 | if(!$this->connected()) { 781 | $this->error = array( 782 | "error" => "Called Send() without being connected"); 783 | return false; 784 | } 785 | 786 | fputs($this->smtp_conn,"SEND FROM:" . $from . $this->CRLF); 787 | 788 | $rply = $this->get_lines(); 789 | $code = substr($rply,0,3); 790 | 791 | if($this->do_debug >= 2) { 792 | echo "SMTP -> FROM SERVER:" . $this->CRLF . $rply; 793 | } 794 | 795 | if($code != 250) { 796 | $this->error = 797 | array("error" => "SEND not accepted from server", 798 | "smtp_code" => $code, 799 | "smtp_msg" => substr($rply,4)); 800 | if($this->do_debug >= 1) { 801 | echo "SMTP -> ERROR: " . $this->error["error"] . 802 | ": " . $rply . $this->CRLF; 803 | } 804 | return false; 805 | } 806 | return true; 807 | } 808 | 809 | /* 810 | * SendAndMail($from) 811 | * 812 | * Starts a mail transaction from the email address specified in 813 | * $from. Returns true if successful or false otherwise. If True 814 | * the mail transaction is started and then one or more Recipient 815 | * commands may be called followed by a Data command. This command 816 | * will send the message to the users terminal if they are logged 817 | * in and send them an email. 818 | * 819 | * Implements rfc 821: SAML FROM: 820 | * 821 | * SMTP CODE SUCCESS: 250 822 | * SMTP CODE SUCCESS: 552,451,452 823 | * SMTP CODE SUCCESS: 500,501,502,421 824 | */ 825 | function SendAndMail($from) { 826 | $this->error = null; # so no confusion is caused 827 | 828 | if(!$this->connected()) { 829 | $this->error = array( 830 | "error" => "Called SendAndMail() without being connected"); 831 | return false; 832 | } 833 | 834 | fputs($this->smtp_conn,"SAML FROM:" . $from . $this->CRLF); 835 | 836 | $rply = $this->get_lines(); 837 | $code = substr($rply,0,3); 838 | 839 | if($this->do_debug >= 2) { 840 | echo "SMTP -> FROM SERVER:" . $this->CRLF . $rply; 841 | } 842 | 843 | if($code != 250) { 844 | $this->error = 845 | array("error" => "SAML not accepted from server", 846 | "smtp_code" => $code, 847 | "smtp_msg" => substr($rply,4)); 848 | if($this->do_debug >= 1) { 849 | echo "SMTP -> ERROR: " . $this->error["error"] . 850 | ": " . $rply . $this->CRLF; 851 | } 852 | return false; 853 | } 854 | return true; 855 | } 856 | 857 | /* 858 | * SendOrMail($from) 859 | * 860 | * Starts a mail transaction from the email address specified in 861 | * $from. Returns true if successful or false otherwise. If True 862 | * the mail transaction is started and then one or more Recipient 863 | * commands may be called followed by a Data command. This command 864 | * will send the message to the users terminal if they are logged 865 | * in or mail it to them if they are not. 866 | * 867 | * Implements rfc 821: SOML FROM: 868 | * 869 | * SMTP CODE SUCCESS: 250 870 | * SMTP CODE SUCCESS: 552,451,452 871 | * SMTP CODE SUCCESS: 500,501,502,421 872 | */ 873 | function SendOrMail($from) { 874 | $this->error = null; # so no confusion is caused 875 | 876 | if(!$this->connected()) { 877 | $this->error = array( 878 | "error" => "Called SendOrMail() without being connected"); 879 | return false; 880 | } 881 | 882 | fputs($this->smtp_conn,"SOML FROM:" . $from . $this->CRLF); 883 | 884 | $rply = $this->get_lines(); 885 | $code = substr($rply,0,3); 886 | 887 | if($this->do_debug >= 2) { 888 | echo "SMTP -> FROM SERVER:" . $this->CRLF . $rply; 889 | } 890 | 891 | if($code != 250) { 892 | $this->error = 893 | array("error" => "SOML not accepted from server", 894 | "smtp_code" => $code, 895 | "smtp_msg" => substr($rply,4)); 896 | if($this->do_debug >= 1) { 897 | echo "SMTP -> ERROR: " . $this->error["error"] . 898 | ": " . $rply . $this->CRLF; 899 | } 900 | return false; 901 | } 902 | return true; 903 | } 904 | 905 | /* 906 | * Turn() 907 | * 908 | * This is an optional command for SMTP that this class does not 909 | * support. This method is here to make the RFC821 Definition 910 | * complete for this class and __may__ be implimented in the future 911 | * 912 | * Implements from rfc 821: TURN 913 | * 914 | * SMTP CODE SUCCESS: 250 915 | * SMTP CODE FAILURE: 502 916 | * SMTP CODE ERROR : 500, 503 917 | */ 918 | function Turn() { 919 | $this->error = array("error" => "This method, TURN, of the SMTP ". 920 | "is not implemented"); 921 | if($this->do_debug >= 1) { 922 | echo "SMTP -> NOTICE: " . $this->error["error"] . $this->CRLF; 923 | } 924 | return false; 925 | } 926 | 927 | /* 928 | * Verify($name) 929 | * 930 | * Verifies that the name is recognized by the server. 931 | * Returns false if the name could not be verified otherwise 932 | * the response from the server is returned. 933 | * 934 | * Implements rfc 821: VRFY 935 | * 936 | * SMTP CODE SUCCESS: 250,251 937 | * SMTP CODE FAILURE: 550,551,553 938 | * SMTP CODE ERROR : 500,501,502,421 939 | */ 940 | function Verify($name) { 941 | $this->error = null; # so no confusion is caused 942 | 943 | if(!$this->connected()) { 944 | $this->error = array( 945 | "error" => "Called Verify() without being connected"); 946 | return false; 947 | } 948 | 949 | fputs($this->smtp_conn,"VRFY " . $name . $this->CRLF); 950 | 951 | $rply = $this->get_lines(); 952 | $code = substr($rply,0,3); 953 | 954 | if($this->do_debug >= 2) { 955 | echo "SMTP -> FROM SERVER:" . $this->CRLF . $rply; 956 | } 957 | 958 | if($code != 250 && $code != 251) { 959 | $this->error = 960 | array("error" => "VRFY failed on name '$name'", 961 | "smtp_code" => $code, 962 | "smtp_msg" => substr($rply,4)); 963 | if($this->do_debug >= 1) { 964 | echo "SMTP -> ERROR: " . $this->error["error"] . 965 | ": " . $rply . $this->CRLF; 966 | } 967 | return false; 968 | } 969 | return $rply; 970 | } 971 | 972 | /****************************************************************** 973 | * INTERNAL FUNCTIONS * 974 | ******************************************************************/ 975 | 976 | /* 977 | * get_lines() 978 | * 979 | * __internal_use_only__: read in as many lines as possible 980 | * either before eof or socket timeout occurs on the operation. 981 | * With SMTP we can tell if we have more lines to read if the 982 | * 4th character is '-' symbol. If it is a space then we don't 983 | * need to read anything else. 984 | */ 985 | function get_lines() { 986 | $data = ""; 987 | while($str = fgets($this->smtp_conn,515)) { 988 | if($this->do_debug >= 4) { 989 | echo "SMTP -> get_lines(): \$data was \"$data\"" . 990 | $this->CRLF; 991 | echo "SMTP -> get_lines(): \$str is \"$str\"" . 992 | $this->CRLF; 993 | } 994 | $data .= $str; 995 | if($this->do_debug >= 4) { 996 | echo "SMTP -> get_lines(): \$data is \"$data\"" . $this->CRLF; 997 | } 998 | # if the 4th character is a space then we are done reading 999 | # so just break the loop 1000 | if(substr($str,3,1) == " ") { break; } 1001 | } 1002 | return $data; 1003 | } 1004 | 1005 | } 1006 | 1007 | 1008 | ?> -------------------------------------------------------------------------------- /vendors/phpmailer/phpmailer_doc.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | : Class phpmailer 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 29 | 32 | 33 | 34 | 35 | 38 | 41 | 42 | 43 | 45 | 47 | 48 |
30 | 31 |
49 | 50 | 51 |
52 | 53 |

54 | Class phpmailer

55 |
  56 | phpmailer
  57 | 
58 |
59 |
60 |
public class phpmailer
61 | 62 |

63 | phpmailer - PHP email transport class 64 |

65 |


66 | 67 |

68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 78 | 79 | 80 | 82 | 86 | 87 | 88 | 90 | 94 | 95 | 96 | 98 | 102 | 103 | 104 | 106 | 110 | 111 | 112 | 114 | 118 | 119 | 120 | 122 | 126 | 127 | 128 | 130 | 134 | 135 | 136 | 138 | 142 | 143 | 144 | 146 | 150 | 151 | 152 | 154 | 158 | 159 | 160 | 162 | 166 | 167 | 168 | 170 | 174 | 175 | 176 | 178 | 182 | 183 | 184 | 186 | 190 | 191 | 192 | 194 | 198 | 199 | 200 | 202 | 206 | 207 | 208 | 210 | 214 | 215 | 216 | 218 | 222 | 223 | 224 | 226 | 230 | 231 | 232 | 234 | 238 | 239 | 240 | 242 | 246 | 247 | 248 | 250 | 254 | 255 | 256 | 258 | 262 | 263 | 264 | 266 | 270 | 271 | 272 | 274 | 279 | 280 |
77 | Field Summary
81 |  string$AltBody 83 | 84 |
85 |           Sets the text-only body of the message.
89 |  string$Body 91 | 92 |
93 |           Sets the Body of the message.
97 |  string$CharSet 99 | 100 |
101 |           Sets the CharSet of the message.
105 |  string$ConfirmReadingTo 107 | 108 |
109 |           Sets the email address that a reading confirmation will be sent.
113 |  string$ContentType 115 | 116 |
117 |           Sets the Content-type of the message.
121 |  string$Encoding 123 | 124 |
125 |           Sets the Encoding of the message.
129 |  string$ErrorInfo 131 | 132 |
133 |           Holds the most recent mailer error message.
137 |  string$From 139 | 140 |
141 |           Sets the From email address for the message.
145 |  string$FromName 147 | 148 |
149 |           Sets the From name of the message.
153 |  string$Helo 155 | 156 |
157 |           Sets the SMTP HELO of the message.
161 |  string$Host 163 | 164 |
165 |           Sets the SMTP hosts.
169 |  string$LE 171 | 172 |
173 |           Sets the line endings of the message.
177 |  string$Mailer 179 | 180 |
181 |           Method to send mail: ("mail", "sendmail", or "smtp").
185 |  string$Password 187 | 188 |
189 |           Sets SMTP password.
193 |  string$PluginDir 195 | 196 |
197 |           Path to phpmailer plugins.
201 |  int$Port 203 | 204 |
205 |           Sets the default SMTP server port.
209 |  int$Priority 211 | 212 |
213 |           Email priority (1 = High, 3 = Normal, 5 = low).
217 |  string$Sender 219 | 220 |
221 |           Sets the Sender email of the message.
225 |  string$Sendmail 227 | 228 |
229 |           Sets the path of the sendmail program.
233 |  bool$SMTPAuth 235 | 236 |
237 |           Sets SMTP authentication.
241 |  string$Subject 243 | 244 |
245 |           Sets the Subject of the message.
249 |  bool$UseMSMailHeaders 251 | 252 |
253 |           Turns Microsoft mail client headers on and off.
257 |  string$Username 259 | 260 |
261 |           Sets SMTP username.
265 |  string$Version 267 | 268 |
269 |           Holds phpmailer version.
273 |  int$WordWrap 275 | 276 |
277 |           Sets word wrapping on the body of the message to a given number of 278 | characters.
281 |   282 | 283 | 284 | 285 | 286 | 287 | 289 | 290 | 291 | 295 | 296 |
288 | Constructor Summary
phpmailer() 292 | 293 |
294 |            
297 |   298 | 299 | 300 | 301 | 302 | 303 | 305 | 306 | 307 | 309 | 314 | 315 | 316 | 318 | 325 | 326 | 327 | 329 | 334 | 335 | 336 | 338 | 343 | 344 | 345 | 347 | 351 | 352 | 353 | 355 | 363 | 364 | 365 | 367 | 372 | 373 | 374 | 376 | 383 | 384 | 385 | 387 | 391 | 392 | 393 | 395 | 400 | 401 | 402 | 404 | 409 | 410 | 411 | 413 | 417 | 418 | 419 | 421 | 425 | 426 | 427 | 429 | 433 | 434 | 435 | 437 | 441 | 442 | 443 | 445 | 449 | 450 | 451 | 453 | 457 | 458 | 459 | 461 | 465 | 466 | 467 | 469 | 473 | 474 | 475 | 477 | 481 | 482 | 483 | 485 | 489 | 490 | 491 | 493 | 498 | 499 |
304 | Method Summary
308 |  voidAddAddress(var $address, 310 | var $name) 311 | 312 |
313 |           Adds a "To" address.
317 |  boolAddAttachment(var $path, 319 | var $name, 320 | var $encoding, 321 | var $type) 322 | 323 |
324 |           Adds an attachment from a path on the filesystem.
328 |  voidAddBCC(var $address, 330 | var $name) 331 | 332 |
333 |           Adds a "Bcc" address.
337 |  voidAddCC(var $address, 339 | var $name) 340 | 341 |
342 |           Adds a "Cc" address.
346 |  voidAddCustomHeader(var $custom_header) 348 | 349 |
350 |           Adds a custom header.
354 |  boolAddEmbeddedImage(var $path, 356 | var $cid, 357 | var $name, 358 | var $encoding, 359 | var $type) 360 | 361 |
362 |           Adds an embedded attachment.
366 |  voidAddReplyTo(var $address, 368 | var $name) 369 | 370 |
371 |           Adds a "Reply-to" address.
375 |  voidAddStringAttachment(var $string, 377 | var $filename, 378 | var $encoding, 379 | var $type) 380 | 381 |
382 |           Adds a string or binary attachment (non-filesystem) to the list.
386 |  voidClearAddresses() 388 | 389 |
390 |           Clears all recipients assigned in the TO array.
394 |  voidClearAllRecipients() 396 | 397 |
398 |           Clears all recipients assigned in the TO, CC and BCC 399 | array.
403 |  voidClearAttachments() 405 | 406 |
407 |           Clears all previously set filesystem, string, and binary 408 | attachments.
412 |  voidClearBCCs() 414 | 415 |
416 |           Clears all recipients assigned in the BCC array.
420 |  voidClearCCs() 422 | 423 |
424 |           Clears all recipients assigned in the CC array.
428 |  voidClearCustomHeaders() 430 | 431 |
432 |           Clears all custom headers.
436 |  voidClearReplyTos() 438 | 439 |
440 |           Clears all recipients assigned in the ReplyTo array.
444 |  voidIsHTML(var $bool) 446 | 447 |
448 |           Sets message type to HTML.
452 |  voidIsMail() 454 | 455 |
456 |           Sets Mailer to send message using PHP mail() function.
460 |  voidIsQmail() 462 | 463 |
464 |           Sets Mailer to send message using the qmail MTA.
468 |  voidIsSendmail() 470 | 471 |
472 |           Sets Mailer to send message using the $Sendmail program.
476 |  voidIsSMTP() 478 | 479 |
480 |           Sets Mailer to send message using SMTP.
484 |  boolSend() 486 | 487 |
488 |           Creates message and assigns Mailer.
492 |  stringSendToQueue(var $queue_path, 494 | var $send_time) 495 | 496 |
497 |           Sends mail message to an assigned queue directory.
500 |   501 |

502 | 503 | 504 | 505 | 506 | 507 | 508 | 510 | 511 |
509 | Field Detail
512 | 513 |

514 | $Priority

515 |
 516 | public int $Priority
517 |
518 |
Email priority (1 = High, 3 = Normal, 5 = low). Default value is 3.
519 |
520 | 521 |

522 | $CharSet

523 |
 524 | public string $CharSet
525 |
526 |
Sets the CharSet of the message. Default value is "iso-8859-1".
527 |
528 | 529 |

530 | $ContentType

531 |
 532 | public string $ContentType
533 |
534 |
Sets the Content-type of the message. Default value is "text/plain".
535 |
536 | 537 |

538 | $Encoding

539 |
 540 | public string $Encoding
541 |
542 |
Sets the Encoding of the message. Options for this are "8bit" (default), 543 | "7bit", "binary", "base64", and "quoted-printable".
544 |
545 | 546 |

547 | $ErrorInfo

548 |
 549 | public string $ErrorInfo
550 |
551 |
Holds the most recent mailer error message. Default value is "".
552 |
553 | 554 |

555 | $From

556 |
 557 | public string $From
558 |
559 |
Sets the From email address for the message. Default value is "root@localhost".
560 |
561 | 562 |

563 | $FromName

564 |
 565 | public string $FromName
566 |
567 |
Sets the From name of the message. Default value is "Root User".
568 |
569 | 570 |

571 | $Sender

572 |
 573 | public string $Sender
574 |
575 |
Sets the Sender email of the message. If not empty, will be sent via -f to sendmail 576 | or as 'MAIL FROM' in smtp mode. Default value is "".
577 |
578 | 579 |

580 | $Subject

581 |
 582 | public string $Subject
583 |
584 |
Sets the Subject of the message. Default value is "".
585 |
586 | 587 |

588 | $Body

589 |
 590 | public string $Body
591 |
592 |
Sets the Body of the message. This can be either an HTML or text body. 593 | If HTML then run IsHTML(true). Default value is "".
594 |
595 | 596 |

597 | $AltBody

598 |
 599 | public string $AltBody
600 |
601 |
Sets the text-only body of the message. This automatically sets the 602 | email to multipart/alternative. This body can be read by mail 603 | clients that do not have HTML email capability such as mutt. Clients 604 | that can read HTML will view the normal Body. 605 | Default value is "".
606 |
607 | 608 |

609 | $WordWrap

610 |
 611 | public int $WordWrap
612 |
613 |
Sets word wrapping on the body of the message to a given number of 614 | characters. Default value is 0 (off).
615 |
616 | 617 |

618 | $Mailer

619 |
 620 | public string $Mailer
621 |
622 |
Method to send mail: ("mail", "sendmail", or "smtp"). 623 | Default value is "mail".
624 |
625 | 626 |

627 | $Sendmail

628 |
 629 | public string $Sendmail
630 |
631 |
Sets the path of the sendmail program. Default value is 632 | "/usr/sbin/sendmail".
633 |
634 | 635 |

636 | $UseMSMailHeaders

637 |
 638 | public bool $UseMSMailHeaders
639 |
640 |
Turns Microsoft mail client headers on and off. Useful mostly 641 | for older clients. Default value is false (off).
642 |
643 | 644 |

645 | $PluginDir

646 |
 647 | public string $PluginDir
648 |
649 |
Path to phpmailer plugins. This is now only useful if the SMTP class 650 | is in a different directory than the PHP include path. 651 | Default is empty ("").
652 |
653 | 654 |

655 | $Version

656 |
 657 | public string $Version
658 |
659 |
Holds phpmailer version.
660 |
661 | 662 |

663 | $ConfirmReadingTo

664 |
 665 | public string $ConfirmReadingTo
666 |
667 |
Sets the email address that a reading confirmation will be sent. Default value is "".
668 |
669 | 670 |

671 | $LE

672 |
 673 | public string $LE
674 |
675 |
Sets the line endings of the message. Default is "\n";
676 |
677 | 678 |

679 | $Host

680 |
 681 | public string $Host
682 |
683 |
Sets the SMTP hosts. All hosts must be separated by a 684 | semicolon. You can also specify a different port 685 | for each host by using this format: [hostname:port] 686 | (e.g. "smtp1.domain.com:25;smtp2.domain.com"). 687 | Hosts will be tried in order. 688 | Default value is "localhost".
689 |
690 | 691 |

692 | $Port

693 |
 694 | public int $Port
695 |
696 |
Sets the default SMTP server port. Default value is 25.
697 |
698 | 699 |

700 | $Helo

701 |
 702 | public string $Helo
703 |
704 |
Sets the SMTP HELO of the message. 705 | Default value is "localhost.localdomain".
706 |
707 | 708 |

709 | $SMTPAuth

710 |
 711 | public bool $SMTPAuth
712 |
713 |
Sets SMTP authentication. Utilizes the Username and Password variables. 714 | Default value is false (off).
715 |
716 | 717 |

718 | $Username

719 |
 720 | public string $Username
721 |
722 |
Sets SMTP username. Default value is "".
723 |
724 | 725 |

726 | $Password

727 |
 728 | public string $Password
729 |
730 |
Sets SMTP password. Default value is "".
731 | 732 | 733 | 734 | 735 | 736 | 737 | 739 | 740 |
738 | Constructor Detail
741 | 742 |

743 | phpmailer

744 |
 745 | public phpmailer()
746 |
747 |
748 | 749 | 750 | 751 | 752 | 753 | 754 | 756 | 757 |
755 | Method Detail
758 | 759 |

760 | IsHTML

761 |
 762 | public void IsHTML(var $bool)
763 |
764 |
Sets message type to HTML. Returns void.
765 |
766 | 767 |

768 | IsSMTP

769 |
 770 | public void IsSMTP()
771 |
772 |
Sets Mailer to send message using SMTP. 773 | Returns void.
774 |
775 | 776 |

777 | IsMail

778 |
 779 | public void IsMail()
780 |
781 |
Sets Mailer to send message using PHP mail() function. 782 | Returns void.
783 |
784 | 785 |

786 | IsSendmail

787 |
 788 | public void IsSendmail()
789 |
790 |
Sets Mailer to send message using the $Sendmail program. 791 | Returns void.
792 |
793 | 794 |

795 | IsQmail

796 |
 797 | public void IsQmail()
798 |
799 |
Sets Mailer to send message using the qmail MTA. Returns void.
800 |
801 | 802 |

803 | AddAddress

804 |
 805 | public void AddAddress(var $address,
 806 |                        var $name)
807 |
808 |
Adds a "To" address. Returns void.
809 |
Parameters:
$name - Default Value: ""
810 |
811 |
812 |
813 | 814 |

815 | AddCC

816 |
 817 | public void AddCC(var $address,
 818 |                   var $name)
819 |
820 |
Adds a "Cc" address. Note: this function works 821 | with the SMTP mailer on win32, not with the "mail" 822 | mailer. This is a PHP bug that has been submitted 823 | on http: * functions correctly. Returns void.
824 |
Parameters:
$name - Default Value: ""
825 |
826 |
827 |
828 | 829 |

830 | AddBCC

831 |
 832 | public void AddBCC(var $address,
 833 |                    var $name)
834 |
835 |
Adds a "Bcc" address. Note: this function works 836 | with the SMTP mailer on win32, not with the "mail" 837 | mailer. This is a PHP bug that has been submitted 838 | on http: * functions correctly. 839 | Returns void.
840 |
Parameters:
$name - Default Value: ""
841 |
842 |
843 |
844 | 845 |

846 | AddReplyTo

847 |
 848 | public void AddReplyTo(var $address,
 849 |                        var $name)
850 |
851 |
Adds a "Reply-to" address. Returns void.
852 |
Parameters:
$name - Default Value: ""
853 |
854 |
855 |
856 | 857 |

858 | Send

859 |
 860 | public bool Send()
861 |
862 |
Creates message and assigns Mailer. If the message is 863 | not sent successfully then it returns false. Use the ErrorInfo 864 | variable to view description of the error. Returns bool.
865 |
866 | 867 |

868 | SendToQueue

869 |
 870 | public string SendToQueue(var $queue_path,
 871 |                           var $send_time)
872 |
873 |
Sends mail message to an assigned queue directory. Has an optional 874 | sendTime argument. This is used when the user wants the 875 | message to be sent from the queue at a predetermined time. 876 | The data must be a valid timestamp like that returned from 877 | the time() or strtotime() functions. Returns false on failure 878 | or the message file name if success.
879 |
Parameters:
$send_time - Default Value: 0
880 |
881 |
882 |
883 | 884 |

885 | AddAttachment

886 |
 887 | public bool AddAttachment(var $path,
 888 |                           var $name,
 889 |                           var $encoding,
 890 |                           var $type)
891 |
892 |
Adds an attachment from a path on the filesystem. 893 | Checks if attachment is valid and then adds 894 | the attachment to the list. 895 | Returns false if the file could not be found 896 | or accessed.
897 |
Parameters:
$name - Default Value: ""
$encoding - Default Value: "base64"
$type - Default Value: "application/octet-stream"
898 |
899 |
900 |
901 | 902 |

903 | AddStringAttachment

904 |
 905 | public void AddStringAttachment(var $string,
 906 |                                 var $filename,
 907 |                                 var $encoding,
 908 |                                 var $type)
909 |
910 |
Adds a string or binary attachment (non-filesystem) to the list. 911 | This method can be used to attach ascii or binary data, 912 | such as a BLOB record from a database.
913 |
Parameters:
$encoding - Default Value: "base64"
$type - Default Value: "application/octet-stream"
914 |
915 |
916 |
917 | 918 |

919 | AddEmbeddedImage

920 |
 921 | public bool AddEmbeddedImage(var $path,
 922 |                              var $cid,
 923 |                              var $name,
 924 |                              var $encoding,
 925 |                              var $type)
926 |
927 |
Adds an embedded attachment. This can include images, sounds, and 928 | just about any other document.
929 |
Parameters:
cid - this is the Content Id of the attachment. Use this to identify 930 | the Id for accessing the image in an HTML form.
$name - Default Value: ""
$encoding - Default Value: "base64"
$type - Default Value: "application/octet-stream"
931 |
932 |
933 |
934 | 935 |

936 | ClearAddresses

937 |
 938 | public void ClearAddresses()
939 |
940 |
Clears all recipients assigned in the TO array. Returns void.
941 |
942 | 943 |

944 | ClearCCs

945 |
 946 | public void ClearCCs()
947 |
948 |
Clears all recipients assigned in the CC array. Returns void.
949 |
950 | 951 |

952 | ClearBCCs

953 |
 954 | public void ClearBCCs()
955 |
956 |
Clears all recipients assigned in the BCC array. Returns void.
957 |
958 | 959 |

960 | ClearReplyTos

961 |
 962 | public void ClearReplyTos()
963 |
964 |
Clears all recipients assigned in the ReplyTo array. Returns void.
965 |
966 | 967 |

968 | ClearAllRecipients

969 |
 970 | public void ClearAllRecipients()
971 |
972 |
Clears all recipients assigned in the TO, CC and BCC 973 | array. Returns void.
974 |
975 | 976 |

977 | ClearAttachments

978 |
 979 | public void ClearAttachments()
980 |
981 |
Clears all previously set filesystem, string, and binary 982 | attachments. Returns void.
983 |
984 | 985 |

986 | ClearCustomHeaders

987 |
 988 | public void ClearCustomHeaders()
989 |
990 |
Clears all custom headers. Returns void.
991 |
992 | 993 |

994 | AddCustomHeader

995 |
 996 | public void AddCustomHeader(var $custom_header)
997 |
998 |
Adds a custom header. Returns void.
999 | 1000 |
1001 | 1002 | 1003 | 1004 | 1005 | 1006 | 1018 | 1021 | 1022 | 1023 | 1024 | 1027 | 1030 | 1031 | 1032 | 1034 | 1036 | 1037 |
1019 | 1020 |
1038 | 1039 | 1040 |
1041 | 1042 | 1043 | -------------------------------------------------------------------------------- /views/elements/layout/control_panel/icon.ctp: -------------------------------------------------------------------------------- 1 | "; 3 | echo $html->image("$image"); 4 | echo $html->link($title,$url); 5 | echo ""; 6 | ?> -------------------------------------------------------------------------------- /views/elements/layout/email/text/default.thtml: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /views/elements/layout/footer.ctp: -------------------------------------------------------------------------------- 1 |
link($html->image('cake.power.gif'),'http://cakephp.org',array('escape'=>false)); ?>
-------------------------------------------------------------------------------- /views/elements/layout/header.ctp: -------------------------------------------------------------------------------- 1 | 11 | 12 | -------------------------------------------------------------------------------- /views/elements/layout/help_section.ctp: -------------------------------------------------------------------------------- 1 |

Help

2 |

3 | Help is not available now. 4 |

-------------------------------------------------------------------------------- /views/elements/layout/logged_in_menu.default.ctp: -------------------------------------------------------------------------------- 1 | user()): ?> 2 |
3 |
4 |
    5 |
  • 6 | link($trans->__('Home'), "/dashboard"); ?> 7 |
      8 |
    • 9 |
    • link($trans->__("Change Password"), "/users/change_password") ?>
    • 10 | 11 |
    • 12 | link($trans->__("Disconnect"), "/users/logout") ?> 13 |
    • 14 |
    15 |
  • 16 |
17 |
18 |
19 |
20 | 21 | check($auth->user(),"Users/delete")) 23 | //syntax for controller/method check note: must add to permission in initDb 24 | ?> -------------------------------------------------------------------------------- /views/elements/layout/rightcol.ctp: -------------------------------------------------------------------------------- 1 | element("box/start", array("title"=>"Control Panel")) ?> 2 | read("user_id")) 4 | { 5 | echo $this->element("user_control_panel"); 6 | } else { 7 | ?> 8 |
9 |

» Please Sign in:

10 | create("User",array("action"=>"login")); 12 | echo "
"; 13 | echo ""; 14 | echo ""; 15 | echo ""; 16 | echo ""; 17 | echo ""; 18 | echo ""; 19 | echo ""; 20 | echo ""; 21 | echo ""; 22 | echo ""; 23 | echo ""; 24 | echo ""; 25 | echo ""; 26 | echo ""; 27 | echo ""; 28 | echo ""; 29 | echo "
{$form->label("username","Username")} {$form->text("username")}
{$form->label("password","Password")} {$form->password("password")}
{$form->Submit("Log in")}
{$html->link("Register","/users/register")} {$html->link("Forgot Password","/users/forgotPassword")}
"; 30 | echo "
"; 31 | echo $form->end(); 32 | ?> 33 |
34 | 37 | 38 | element("box/end") ?> 39 | -------------------------------------------------------------------------------- /views/errors/unauthorized.ctp: -------------------------------------------------------------------------------- 1 |

__('Unauthorized');?>

-------------------------------------------------------------------------------- /views/helpers/empty: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jedt/spark_plug/062b5bbb1c6b2b2fbc7360b5a28221f1d7f9a22d/views/helpers/empty -------------------------------------------------------------------------------- /views/helpers/trans.php: -------------------------------------------------------------------------------- 1 | 14 | -------------------------------------------------------------------------------- /views/layouts/sparkwufoodefault.ctp: -------------------------------------------------------------------------------- 1 | 2 | Session->read('SparkPlug.facebookEnabled')) { 3 | echo $facebook->html(); 4 | } else { ?> 5 | 6 | 7 | 8 | Html->charset(); ?> 9 | <?php echo $title_for_layout; ?> 10 | Html->meta('icon'); 12 | 13 | //echo $this->Html->css('cake.generic'); 14 | echo $html->script('/spark_plug/js/wufoo.js'); 15 | echo $html->css('/spark_plug/css/wufoo/structure'); 16 | echo $html->css('/spark_plug/css/wufoo/form'); 17 | echo $html->css('/spark_plug/css/wufoo/theme'); 18 | echo $html->css('/spark_plug/css/spark'); 19 | echo $scripts_for_layout; 20 | ?> 21 | 22 | 23 |
24 | 27 |
28 | Session->check('Message.flash')) { 29 | echo '

' . $this->Session->flash() . '

'; 30 | }?> 31 | 32 | 33 |
34 | 40 |
41 | element('sql_dump'); ?> 42 | Session->read('SparkPlug.facebookEnabled')) echo $facebook->init(); ?> 43 | 44 | -------------------------------------------------------------------------------- /views/user_group_permissions/add.ctp: -------------------------------------------------------------------------------- 1 | link('Back to list','/user_group_permissions/index'); ?> 2 |

Add User Group Permission

3 | 4 | create('UserGroupPermission',array('action'=>'edit')); ?> 5 | input('user_group_id',array('type'=>'select','options'=>$userGroups,'empty'=>'')); ?> 6 | input('controller', array('after' => $trans->__('Type here your Controller name, case insensitive'))); ?> 7 | input('action', array('after' => $trans->__('Type here your Action name, case insensitive, and * for all Actions inside the Controller'))); ?> 8 | 9 | input('plugin', array('after' => $trans->__('Leave Plugin field blank if not sure. This is used to set permissions inside your Plugins'))); ?> 10 | 11 | input('alowed',array('type'=>'radio','options'=>array('1'=>'Yes','0'=>'No'), 'default' => '1')); ?> 12 | input('id'); ?> 13 | submit();?> 14 | end();?> 15 | -------------------------------------------------------------------------------- /views/user_group_permissions/edit.ctp: -------------------------------------------------------------------------------- 1 | link('Back to list','/user_group_permissions/index')?> 2 | link('Back to list','/user_group_permissions/index'); ?> 3 | 4 |

Edit User Group Permission

5 | 6 | create('UserGroupPermission',array('action'=>'edit')); ?> 7 | input('user_group_id',array('type'=>'select','options'=>$userGroups,'empty'=>'')); ?> 8 | input('controller'); ?> 9 | input('action'); ?> 10 | input('plugin'); ?> 11 | input('allowed',array('type'=>'radio','options'=>array(1=>'Yes',0=>'No'))); ?> 12 | input('id'); ?> 13 | submit();?> 14 | end();?> 15 | -------------------------------------------------------------------------------- /views/user_group_permissions/index.ctp: -------------------------------------------------------------------------------- 1 | link('Back to dashboard','/users/dashboard'); ?> 2 | | 3 | link(__('New User Group Permission', true), array('action'=>'add')); ?> 4 | 5 |

User Group Permissions

6 |
7 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | form('UserGroupPermission', array(null,null,'plugin','controller','action','allow')); 22 | } 23 | ?> 24 | 32 | > 33 | 34 | 35 | 36 | 37 | 38 | 39 | 42 | 43 | 44 |
sort('id');?>sort('user_group_id');?>sort('plugin');?>sort('controller');?>sort('action');?>sort('allow');?>
link(__('Edit', true), array('action'=>'edit', $permission['UserGroupPermission']['id'])); ?> 40 | link(__('Delete', true), array('action'=>'delete', $permission['UserGroupPermission']['id']), null, sprintf(__('Are you sure you want to delete # %s?', true), $permission['UserGroupPermission']['id'])); ?> 41 |
45 |
46 | 47 |
prev('<< '.__('previous', true), array(), null, array('class'=>'disabled'));?> 48 | | numbers();?> next(__('next', true).' >>', array(), null, array('class'=>'disabled'));?> 49 |
50 | -------------------------------------------------------------------------------- /views/users/activate_password.ctp: -------------------------------------------------------------------------------- 1 |

__('Activate your password'); ?>

2 | create("User", array("action"=>"activate_password")) ?> 3 | input('password', array('label' => $trans->__('password'))); ?> 4 | input('confirm_password',array('type'=>'password', 'label' => $trans->__('confirm password'))); ?> 5 | hidden('ident',array('value'=>$ident)); ?> 6 | hidden('activate',array('value'=>$activate)); ?> 7 | submit($trans->__('Submit')); ?> 8 | end(); ?> -------------------------------------------------------------------------------- /views/users/add.ctp: -------------------------------------------------------------------------------- 1 |
2 |

__("User Add"); ?>

3 |
4 | 5 | create("User",array("action"=>"add", 'class' => 'wufoo page')); ?> 6 |
    7 | 8 |
  • input("username", array('label' => $trans->__('username'), 'class' => 'field text large')) ?>
  • 9 |
  • input("email", array('label' => $trans->__('Email'), 'class' => 'field text large')) ?>
  • 10 | 11 |
  • input("password",array("type"=>"password", 'value' => null, 'label' => $trans->__('password'), 'class' => 'field text large')) ?>
  • 12 |
  • input("confirm_password",array("type"=>"password", 'label' => $trans->__('confirm password'), 'class' => 'field text large')) ?>
  • 13 | 14 |
  • submit($trans->__('Add')); ?>
  • 15 |
16 | hidden("user_group_id",array("value"=>"2")); ?> 17 | hidden("active",array("value"=>"1")); ?> 18 | end(); ?> 19 | 20 |

link($trans->__("Cancel and go back to users"),"/spark_plug/users/index") ?>

21 | -------------------------------------------------------------------------------- /views/users/change_password.ctp: -------------------------------------------------------------------------------- 1 |

__('Change Password'); ?>

2 | create("User",array("action"=>"change_password")) ?> 3 | input('password', array('label' => $trans->__('password'))); ?> 4 | input('confirm_password',array('type'=>'password', 'label' => $trans->__('confirm password'))); ?> 5 | hidden('id'); ?> 6 | submit(); ?> 7 | end(); ?> -------------------------------------------------------------------------------- /views/users/dashboard.ctp: -------------------------------------------------------------------------------- 1 |

__('Welcome'); ?> !

2 |

__('Please select below'); ?>:

3 |
    4 | 5 |
  1. link($trans->__('Manage Users'),'/users/index'); ?>
  2. 6 | 7 | 8 |
  3. link($trans->__('Manage Permissions'),'/user_group_permissions/index'); ?> 9 |
  4. 10 | 11 |
  5. link($trans->__('Change Password'),'/users/change_password'); ?>
  6. 12 | Session->read('SparkPlug.facebookEnabled') && $this->Session->read('SparkPlug.Users.loggedInByFacebook')) { ?> 13 |
  7. logout(array('redirect' => '/users/logout')); ?>
  8. 14 | 15 |
  9. link($trans->__('Logout'),'/users/logout'); ?>
  10. 16 | 17 |
-------------------------------------------------------------------------------- /views/users/edit.ctp: -------------------------------------------------------------------------------- 1 | link('Back to list','/users/index'); ?> | link('Log in as this User','/users/login_as_user/'.$this->data['User']['id']); ?> 2 |

Edit User

3 | create('User',array('action'=>'edit')); ?> 4 | 5 | input('user_group_id',array('type'=>'select','options'=>$userGroups)); ?> 6 | input('username'); ?> 7 | input('email'); ?> 8 | input('phone'); ?> 9 | input('active'); ?> 10 | input('first_name'); ?> 11 | input('last_name'); ?> 12 | input('country'); ?> 13 | input('city'); ?> 14 | input('state'); ?> 15 | input('zip_code'); ?> 16 | input('id'); ?> 17 | submit(); ?> 18 | end(); ?> 19 |
-------------------------------------------------------------------------------- /views/users/forgot_password.ctp: -------------------------------------------------------------------------------- 1 |

__('Password recovery'); ?>

2 |

__('Please enter the e-mail used during registration'); ?>

3 | create("User",array("action"=>"forgotPassword")) ?> 4 | 5 | 6 | 9 | 10 | 11 | 14 | 15 |
7 | text("email",array("size"=>"40")) ?> 8 |
12 |
submit($trans->__('Submit')); ?> 13 |
16 | end(); ?> -------------------------------------------------------------------------------- /views/users/index.ctp: -------------------------------------------------------------------------------- 1 | link($trans->__('Back to dashboard'),'/users/dashboard'); ?> 2 | 3 |

__('Users'); ?>

4 |
5 | link($trans->__('Add new user', true), array('action'=>'add')); ?> 6 |
7 |
8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 28 | > 29 | 32 | 35 | 38 | 41 | 44 | 47 | 50 | 53 | 57 | 58 | 59 |
sort('id');?>sort('user_group_id');?>sort('first_name');?>sort('last_name');?>sort('username');?>sort('email');?>sort('active') ? 'Yes' : 'No';?>sort('created');?>__('Actions');?>
30 | 31 | 33 | 34 | 36 | 37 | 39 | 40 | 42 | 43 | 45 | 46 | 48 | 49 | 51 | 52 | 54 | link($trans->__('Edit', true), array('action'=>'edit', $user['User']['id'])); ?> 55 | link($trans->__('Delete', true), array('action'=>'delete', $user['User']['id']), null, sprintf(__('Are you sure you want to delete # %s?', true), $user['User']['id'])); ?> 56 |
60 |
61 |
62 | link($trans->__('Add new user', true), array('action'=>'add')); ?> 63 |
64 | 65 |
66 | prev('<< '.$trans->__('previous', true), array(), null, array('class'=>'disabled'));?> 67 | | numbers();?> 68 | next($trans->__('next', true).' >>', array(), null, array('class'=>'disabled'));?> 69 |
-------------------------------------------------------------------------------- /views/users/login.ctp: -------------------------------------------------------------------------------- 1 |
2 |

__("Login your username and password"); ?>

3 |
4 | create('User', array('action' => 'login', 'class' => 'wufoo page')); ?> 5 |
    6 | Session->read('SparkPlug.facebookEnabled')) { ?> 7 |
  • login(array('perms' => 'email', 'background' => 'dark')); ?>
  • 8 | 9 |
  • input("username", array('label' => $trans->__('username'), 'class' => 'field text large')) ?>
  • 10 |
  • input("password",array("type"=>"password", 'label' => $trans->__('password'), 'class' => 'field text large')) ?>
  • 11 |
  • input('remember', array('type' => 'checkbox', 'label' => false, 'div' => false)); 12 | echo $form->label('User.remember', $trans->__('Remember me for 2 weeks'), array('class' => 'field checkbox')); ?> 13 |
  • 14 |
  • submit($trans->__('Submit')); ?>
  • 15 |
16 | end(); ?> 17 | 18 |

__('Not registered yet?');?> link($trans->__("Click Here"),"/users/register") ?>

19 | 20 |

link($trans->__("Forgot your password?"), "/users/forgotPassword") ?>

-------------------------------------------------------------------------------- /views/users/register.ctp: -------------------------------------------------------------------------------- 1 |
2 |

__("User Registration"); ?>

3 |
4 | 5 | create("User",array("action"=>"register", 'class' => 'wufoo page')); ?> 6 |
    7 | 8 |
  • input("username", array('label' => $trans->__('username'), 'class' => 'field text large')) ?>
  • 9 |
  • input("email", array('label' => $trans->__('Email'), 'class' => 'field text large')) ?>
  • 10 | 11 |
  • input("password",array("type"=>"password", 'value' => null, 'label' => $trans->__('password'), 'class' => 'field text large')) ?>
  • 12 |
  • input("confirm_password",array("type"=>"password", 'label' => $trans->__('confirm password'), 'class' => 'field text large')) ?>
  • 13 | 14 |
  • submit($trans->__('Register')); ?>
  • 15 |
16 | end(); ?> 17 | 18 |

__('Already registered ?');?> link($trans->__("Login Here"),"/users/login") ?>

19 | -------------------------------------------------------------------------------- /webroot/css/spark.css: -------------------------------------------------------------------------------- 1 | .required { 2 | font-weight: bold; 3 | } 4 | 5 | .error-message { 6 | color: red; 7 | } 8 | .form-error { 9 | color: red; 10 | } -------------------------------------------------------------------------------- /webroot/css/wufoo/form.css: -------------------------------------------------------------------------------- 1 | /* - - - - - - - - - - - - - - - - - - - - - 2 | 3 | Title : Wufoo Form Framework 4 | Author : Infinity Box Inc. 5 | URL : http://wufoo.com 6 | 7 | Last Updated : March 2, 2010 8 | 9 | - - - - - - - - - - - - - - - - - - - - - */ 10 | 11 | .wufoo{ 12 | font-family:"Lucida Grande", Tahoma, Arial, sans-serif; 13 | } 14 | .wufoo li{ 15 | width:64%; 16 | } 17 | 18 | /* ----- INFO ----- */ 19 | 20 | .info{ 21 | display:inline-block; 22 | clear:both; 23 | margin:0 0 5px 0; 24 | padding:0 1% 1.1em 1%; 25 | border-bottom:1px dotted #ccc; 26 | } 27 | .info[class]{ 28 | display:block; 29 | } 30 | .info h2{ 31 | font-weight:normal; 32 | font-size:160%; 33 | margin:0 0 .2em 0; 34 | clear:left; 35 | } 36 | .info div{ 37 | font-size:95%; 38 | line-height:135%; 39 | color:#555; 40 | } 41 | 42 | /* ----- Field Structure ----- */ 43 | 44 | form ul{ 45 | margin:0; 46 | padding:0; 47 | list-style-type:none; 48 | } 49 | * html form ul{ /* IE6 Margin Percent Bug for Halves/Thirds */ 50 | width:99%; 51 | zoom:1; 52 | } 53 | form li{ 54 | margin:0; 55 | padding:6px 1% 9px 1%; 56 | clear:both; 57 | } 58 | form li:after, form li div:after{ 59 | content:"."; 60 | display:block; 61 | height:0; 62 | clear:both; 63 | visibility:hidden; 64 | } 65 | * html form li{height: 1%;margin-bottom:-3px;} 66 | *+html form li{height: 1%;margin-bottom:-3px;} 67 | * html form li div{display:inline-block;} 68 | *+html form li div{display:inline-block;} 69 | 70 | form li div{ 71 | margin:0; 72 | padding:0; 73 | color:#444; 74 | } 75 | form li span{ 76 | margin:0 .3em 0 0; 77 | padding:0; 78 | float:left; 79 | color:#444; 80 | } 81 | 82 | /* ----- Choices Field Structures ----- */ 83 | 84 | form li div span{ 85 | margin:0; 86 | display:block; 87 | width:100%; 88 | float:left; 89 | } 90 | li.twoColumns div span{ 91 | width:48%; 92 | margin:0 5px 0 0; 93 | } 94 | li.threeColumns div span{ 95 | width:30%; 96 | margin:0 5px 0 0; 97 | } 98 | li.notStacked div span{ 99 | width:auto; 100 | margin:0 7px 0 0; 101 | } 102 | 103 | /* ----- Location Field Structures ----- */ 104 | 105 | form li.complex{ 106 | padding-bottom:0; 107 | } 108 | form li.complex div span{ 109 | width:auto; 110 | margin:0 .3em 0 0; 111 | padding-bottom:12px; 112 | } 113 | form li.complex div span.full{ 114 | margin:0; 115 | } 116 | form li.complex div span.left, 117 | form li.complex div span.right{ 118 | margin:0; 119 | width:48%; 120 | } 121 | form li.complex div span.full input, 122 | form li.complex div span.full select, 123 | form li.complex div span.left input, 124 | form li.complex div span.right input, 125 | form li.complex div span.left select, 126 | form li.complex div span.right select{ 127 | width:100%; 128 | } 129 | 130 | /* ----- FLOATS ----- */ 131 | 132 | .left{ 133 | float:left; 134 | } 135 | .right{ 136 | float:right; 137 | } 138 | .clear{ 139 | clear:both !important; 140 | } 141 | 142 | /* ----- TEXT DIRECTION ----- */ 143 | 144 | .rtl .info h2, .rtl .info div, .rtl label.desc, .rtl label.choice, 145 | .rtl div label, .rtl span label, .rtl input.text, 146 | .rtl textarea.textarea, .rtl select.select, .rtl p.instruct, 147 | .rtl .section h3, .rtl .section div, .rtl input.btTxt{ 148 | direction:rtl; 149 | } 150 | 151 | /* ----- LABELS ----- */ 152 | 153 | form li div label, form li span label{ 154 | margin:0; 155 | padding-top:3px; 156 | clear:both; 157 | font-size:85%; 158 | line-height:160%; 159 | color:#444; 160 | display:block; 161 | } 162 | label.desc{ 163 | font-size:95%; 164 | font-weight:bold; 165 | color:#222; 166 | line-height:150%; 167 | margin:0; 168 | padding:0 0 3px 0; 169 | border:none; 170 | display:block; 171 | } 172 | label.choice{ 173 | display:block; 174 | font-size:100%; 175 | line-height:150%; 176 | margin:-17px 0 0 23px; 177 | padding:0 0 5px 0; 178 | color:#222; 179 | width:88%; 180 | } 181 | .safari label.choice{ 182 | margin-top:-16px; 183 | } 184 | form.rightLabel label.desc{ 185 | padding-top:2px; 186 | } 187 | 188 | span.symbol{ 189 | font-size:120%; 190 | line-height:135%; 191 | } 192 | form li .datepicker{ 193 | float:left; 194 | margin:.19em 5px 0 0; 195 | padding:0; 196 | width: 16px; 197 | height: 16px; 198 | cursor:pointer !important; 199 | } 200 | 201 | /* ----- REQUIRED ----- */ 202 | 203 | form span.req{ 204 | display:inline; 205 | float:none; 206 | color:red !important; 207 | font-weight:bold; 208 | margin:0; 209 | padding:0; 210 | } 211 | 212 | /* ----- MIN/MAX COUNT ----- */ 213 | 214 | form li div label var{ 215 | font-weight:bold; 216 | font-style:normal; 217 | } 218 | form li div label .currently{ 219 | display:none; 220 | } 221 | 222 | /* ----- FIELDS ----- */ 223 | 224 | input.text, input.search, input.file, textarea.textarea, select.select{ 225 | font-family:"Lucida Grande", Tahoma, Arial, sans-serif; 226 | font-size:100%; 227 | color:#333; 228 | margin:0; 229 | padding:2px 0; 230 | } 231 | input.text, input.search, textarea.textarea{ 232 | border-top:1px solid #7c7c7c; 233 | border-left:1px solid #c3c3c3; 234 | border-right:1px solid #c3c3c3; 235 | border-bottom:1px solid #ddd; 236 | background:#fff url(../images/fieldbg.gif) repeat-x top; 237 | } 238 | select.select{ 239 | padding:1px 0 0 0; 240 | } 241 | input.search{ 242 | -webkit-border-radius:10px; 243 | -moz-border-radius:10px; 244 | border-radius:10px; 245 | padding-left:6px; 246 | } 247 | input.checkbox, input.radio{ 248 | display:block; 249 | margin:4px 0 0 0; 250 | padding:0; 251 | width:13px; 252 | height:13px; 253 | } 254 | input.other{ 255 | margin:0 0 8px 25px; 256 | } 257 | 258 | .safari select.select{ 259 | font-size:120% !important; 260 | margin:0 0 1px 0; 261 | } 262 | * html select.select{ 263 | margin:1px 0; 264 | } 265 | *+html select.select{ 266 | margin:1px 0; 267 | } 268 | 269 | .center, 270 | form li span.center input.text, form li span.center label, 271 | form li.name span label, 272 | form li.date input.text, form li.date span label, 273 | form li.phone input.text, form li.phone span label, 274 | form li.time input.text, form li.time span label{ 275 | text-align:center; 276 | } 277 | form li.time select.select{ 278 | margin-left:5px; 279 | } 280 | form li.price .right{ 281 | text-align:right; 282 | } 283 | 284 | /* ----- SIZES ----- */ 285 | 286 | .third{ 287 | width:32% !important; 288 | } 289 | .half{ 290 | width:48% !important; 291 | } 292 | .full{ 293 | width:100% !important; 294 | } 295 | 296 | input.small, select.small{ 297 | width:25%; 298 | } 299 | input.medium, select.medium{ 300 | width:50%; 301 | } 302 | input.large, select.large, textarea.textarea{ 303 | width:100%; 304 | } 305 | 306 | .msie select.ieSelectFix{ 307 | width:auto; 308 | } 309 | .msie6 select.ieSelectFix, .msie7 select.ieSelectFix{ 310 | width:100%; 311 | } 312 | .msie select.ieSelectFix.small{ 313 | min-width:25%; 314 | } 315 | .msie select.ieSelectFix.medium{ 316 | min-width:50%; 317 | } 318 | .msie select.ieSelectFix.large{ 319 | width:100%; 320 | } 321 | 322 | 323 | textarea.small{ 324 | height:5.5em; 325 | } 326 | textarea.medium{ 327 | height:10em; 328 | } 329 | textarea.large{ 330 | height:20em; 331 | } 332 | 333 | /* ----- FILES ----- */ 334 | 335 | li.file a{ 336 | color:#222;text-decoration:none; 337 | } 338 | li.file span{ 339 | display:inline;float:none; 340 | } 341 | li.file img{ 342 | display:block;float:left;margin:0 0 0 -10px;padding:5px 5px 7px 5px; 343 | } 344 | li.file .file-size, li.file .file-type{ 345 | color:#666;font-size:85%;text-transform: uppercase; 346 | } 347 | li.file .file-name{ 348 | display:block; 349 | padding:14px 0 0 0; 350 | color:blue; 351 | text-decoration:underline; 352 | } 353 | li.file .file-delete{ 354 | color:red !important;font-size:85%;text-decoration:underline; 355 | } 356 | li.file a:hover .file-name{ 357 | color:green !important; 358 | } 359 | li.file a:hover .file-name{ 360 | color:green !important; 361 | } 362 | 363 | /* ----- LIKERT SCALE ----- */ 364 | 365 | form li.likert{ 366 | margin:0; 367 | padding:6px 1% 5px 1%; 368 | width:auto !important; 369 | clear:both !important; 370 | float:none !important; 371 | } 372 | .likert table{ 373 | margin:0 0 .9em 0; 374 | background:#fff; 375 | width:100%; 376 | border:1px solid #dedede; 377 | border-bottom:none; 378 | } 379 | .likert caption{ 380 | text-align:left; 381 | color:#222; 382 | font-size:95%; 383 | line-height:135%; 384 | padding:5px 0 .5em 0; 385 | } 386 | .likert input{ 387 | padding:0; 388 | margin:2px 0; 389 | } 390 | .likert tbody td label{ 391 | font-size:85%; 392 | display:block; 393 | color:#565656; 394 | } 395 | 396 | /* ----- Top Row ----- */ 397 | 398 | .likert thead td, .likert thead th{ 399 | background-color:#e6e6e6; 400 | } 401 | 402 | /* ----- Right Side ----- */ 403 | 404 | .likert td{ 405 | border-left:1px solid #ccc; 406 | text-align:center; 407 | padding:4px 6px; 408 | } 409 | .likert thead td{ 410 | font-size:85%; 411 | padding:10px 6px; 412 | } 413 | 414 | /* ----- Body ----- */ 415 | 416 | .likert th, .likert td{ 417 | border-bottom:1px solid #dedede; 418 | } 419 | .likert tbody th{ 420 | padding:8px 8px; 421 | text-align:left; 422 | } 423 | .likert tbody th label{ 424 | color:#222; 425 | font-size:95%; 426 | font-weight:bold; 427 | } 428 | 429 | .likert tbody tr.alt td, .likert tbody tr.alt th{ 430 | background-color:#f5f5f5; 431 | } 432 | .likert tbody tr:hover td, .likert tbody tr:hover th{ 433 | background-color:#FFFFCF; 434 | } 435 | 436 | /* ----- Likert Classes ----- */ 437 | 438 | .col1 td{width:30%;} 439 | .col2 td{width:25%;} 440 | .col3 td{width:18%;} 441 | .col4 td{width:14.5%;} 442 | .col5 td{width:12%;} 443 | .col6 td, .col7 td{width:10%;} 444 | .col8 td, .col9 td, .col10 td{width:6.5%;} 445 | .col11{width:6%;} 446 | 447 | .hideNumbers tbody td label{ 448 | display:none; 449 | } 450 | 451 | /* ----- BUTTONS ----- */ 452 | 453 | form li.buttons{ 454 | width:auto !important; 455 | position:relative; 456 | clear:both; 457 | padding:10px 1% 10px 1%; 458 | } 459 | form li.buttons input{ 460 | font-size:100%; 461 | margin-right:5px; 462 | } 463 | input.btTxt{ 464 | padding:0 7px; 465 | width:auto; 466 | overflow:visible; 467 | } 468 | .safari input.btTxt{ 469 | font-size:120%; 470 | } 471 | .buttons .marker{ 472 | position:absolute; 473 | top:0; 474 | right:0; 475 | padding:15px 10px 0 0; 476 | color:#000; 477 | width:auto; 478 | } 479 | button.link{ 480 | display:inline-block; 481 | border:none; 482 | background:none; 483 | color:blue; 484 | text-decoration:underline; 485 | cursor:pointer; 486 | padding:0; 487 | font-size:100%; 488 | } 489 | button.link:hover{ 490 | color:green; 491 | } 492 | 493 | /* ----- LABEL LAYOUT ----- */ 494 | 495 | .leftLabel li, .rightLabel li{ 496 | width:74% !important; 497 | padding-top:9px; 498 | } 499 | .leftLabel label.desc, .rightLabel label.desc{ 500 | float:left; 501 | width:31%; 502 | margin:0 15px 0 0; 503 | } 504 | .rightLabel label.desc{ 505 | text-align:right; 506 | } 507 | .leftLabel li div, .rightLabel li div{ 508 | float:left; 509 | width:65%; 510 | } 511 | .leftLabel .buttons, .rightLabel .buttons{ 512 | padding-left:23%; 513 | } 514 | .leftLabel .buttons div, .rightLabel .buttons div{ 515 | float:none; 516 | margin:0 0 0 20px; 517 | } 518 | 519 | 520 | .leftLabel p.instruct, .rightLabel p.instruct{ 521 | width:28%; 522 | margin-left:5px; 523 | } 524 | .leftLabel .altInstruct .instruct, .rightLabel .altInstruct .instruct{ 525 | margin-left:31% !important; 526 | padding-left:15px; 527 | width:65%; 528 | } 529 | 530 | /* ----- NO INSTRUCTIONS ----- */ 531 | 532 | .noI form li, .altInstruct form li{ 533 | width:auto !important; 534 | } 535 | 536 | /* ----- NO INSTRUCTIONS LABEL LAYOUT ----- */ 537 | 538 | .noI .leftLabel .buttons, .noI .rightLabel .buttons{ 539 | padding-left:31%; 540 | } 541 | .noI .leftLabel .buttons div, .noI .rightLabel .buttons div{ 542 | margin:0 0 0 17px; 543 | } 544 | 545 | /* ----- HALVES AND THIRDS ----- */ 546 | 547 | form li.leftHalf, form li.rightHalf{ 548 | width:47% !important; 549 | } 550 | form li.leftThird, form li.middleThird, form li.rightThird{ 551 | width:30% !important; 552 | } 553 | form li.leftHalf, form li.leftThird{ 554 | clear:left !important; 555 | float:left; 556 | } 557 | form li.middleThird{ 558 | clear:none !important; 559 | float:left; 560 | width:30% !important; 561 | margin-left:2% !important; 562 | } 563 | form li.rightHalf, form li.rightThird{ 564 | clear:none !important; 565 | float:right; 566 | } 567 | li.leftHalf .small, li.rightHalf .small, 568 | li.leftHalf .medium, li.rightHalf .medium, 569 | li.leftThird .small, li.middleThird .small, li.rightThird .small, 570 | li.leftThird .medium, li.middleThird .medium, li.rightThird .medium{ 571 | width:100%; 572 | } 573 | 574 | /* ----- INSTRUCTIONS ----- */ 575 | 576 | 577 | @-webkit-keyframes fade-in-focused { 578 | from { 579 | background-color: transparent; 580 | } 581 | to { 582 | background-color: #fff7c0 !important; 583 | } 584 | } 585 | 586 | form li.focused{ 587 | background-color:#fff7c0; 588 | -webkit-animation-name: fade-in-focused; 589 | -webkit-animation-duration: 0.4s; 590 | -webkit-animation-iteration-count: 1; 591 | } 592 | form li.focused, form li:hover{ 593 | position:relative; /* Makes Instructs z-index stay on top in IE. */ 594 | } 595 | form .instruct{ 596 | position:absolute; 597 | top:0; 598 | left:0; 599 | z-index:1000; 600 | width:45%; 601 | margin:0 0 0 8px; 602 | padding:8px 10px 10px 10px; 603 | border:1px solid #e6e6e6; 604 | background:#f5f5f5; 605 | visibility:hidden; 606 | font-size:105%; 607 | } 608 | form .instruct small{ 609 | line-height:120%; 610 | font-size:80%; 611 | color:#444; 612 | } 613 | form li.focused .instruct, form li:hover .instruct{ 614 | left:100%; /* Prevent scrollbars for IE Instruct fix */ 615 | visibility:visible; 616 | } 617 | 618 | /* ----- ALT INSTRUCTIONS ----- */ 619 | 620 | .altInstruct .instruct, li.leftHalf .instruct, li.rightHalf .instruct, 621 | li.leftThird .instruct, li.middleThird .instruct, li.rightThird .instruct, 622 | .iphone .instruct{ 623 | visibility:visible; 624 | position:static; 625 | margin:0; 626 | padding:6px 0 0 0; 627 | width:100%; 628 | clear:left; 629 | background:none !important; 630 | border:none !important; 631 | font-style:italic; 632 | } 633 | .altInstruct p.complex , li.leftHalf p.complex, li.rightHalf p.complex, 634 | li.leftThird p.complex, li.middleThird p.complex, li.rightThird p.complex, 635 | .iphone p.complex{ 636 | padding:0 0 9px 0; 637 | } 638 | 639 | /* ----- ADVANCED CLASSNAMES ----- */ 640 | 641 | .hideSeconds .seconds, .hideAMPM .ampm{ 642 | display:none; 643 | } 644 | 645 | /* ----- SECTIONS ----- */ 646 | 647 | form li.section{ 648 | clear:both; 649 | margin:0; 650 | padding:7px 0 0 0; 651 | width:auto !important; 652 | position:static; 653 | } 654 | form li.section h3{ 655 | font-weight:normal; 656 | font-size:110%; 657 | line-height:135%; 658 | margin:0 0 3px 0; 659 | width:auto; 660 | padding:12px 1% 0 1%; 661 | border-top:1px dotted #ccc; 662 | } 663 | form li.first{ 664 | padding:0; 665 | } 666 | form li.first h3{ 667 | padding:8px 1% 0 1%; 668 | border-top:none !important; 669 | } 670 | form li.section div{ 671 | display:block; 672 | width:auto; 673 | font-size:85%; 674 | line-height:160%; 675 | margin:0 0 1em 0; 676 | padding:0 1% 0 1%; 677 | } 678 | 679 | /* ----- CAPTCHA ----- */ 680 | 681 | form li.captcha { 682 | width:auto !important; 683 | clear:both; 684 | border-top:1px dotted #ccc; 685 | margin-top:5px; 686 | padding:1.1em 1% 9px 1%; 687 | width:auto !important; 688 | position:static; 689 | } 690 | form li.captcha label.desc{ 691 | width:auto !important; 692 | text-align:left; 693 | margin-bottom:4px; 694 | float:none; 695 | } 696 | #recaptcha_table, #recaptcha_image img{ 697 | width:300px; 698 | } 699 | #recaptcha_widget_div table{ 700 | background:#fff; 701 | } 702 | form li.captcha .noscript iframe{ 703 | border:none; 704 | overflow:hidden; 705 | margin:0; 706 | padding:0; 707 | } 708 | form li.captcha .noscript label.desc{ 709 | display:block !important; 710 | } 711 | form li.captcha .noscript textarea{ 712 | margin-left:12px; 713 | } 714 | 715 | /* ----- PAGINATION ----- */ 716 | 717 | form li.paging-context{ 718 | clear:both; 719 | border-bottom:1px dotted #ccc; 720 | margin:0 0 7px 0; 721 | padding:5px 1% 10px 1%; 722 | width:auto !important; 723 | position:static; 724 | } 725 | .paging-context table{ 726 | width:100%; 727 | } 728 | 729 | .pgStyle1 td{ /* Steps */ 730 | text-align:left; 731 | vertical-align:middle; 732 | } 733 | .pgStyle1 td.c{ 734 | width:22px; 735 | } 736 | .pgStyle1 td.t{ 737 | padding:0 1%; 738 | } 739 | .pgStyle1 var{ 740 | display:block; 741 | float:left; 742 | background:none; 743 | border:1px solid #CCC; 744 | color:#000; 745 | width:20px; 746 | height:20px; 747 | line-height:19px; 748 | text-align:center; 749 | -webkit-box-shadow:rgba(0,0,0,.15) 0px 1px 2px; 750 | -moz-box-shadow:rgba(0,0,0,.15) 0px 1px 2px; 751 | box-shadow:rgba(0,0,0,.15) 0px 1px 2px; 752 | -webkit-border-radius:10px; 753 | -moz-border-radius:10px; 754 | border-radius:10px; 755 | font-size:85%; 756 | font-style:normal; 757 | } 758 | .pgStyle1 .done var{ 759 | background:#ccc; 760 | } 761 | .pgStyle1 .selected var{ 762 | background:#FFF7C0; 763 | color:#000; 764 | border:1px solid #e6dead; 765 | font-weight:bold; 766 | } 767 | .pgStyle1 b{ 768 | font-size:85%; 769 | font-weight:normal; 770 | color:#000; 771 | } 772 | .pgStyle1 .selected b{ 773 | font-weight:bold; 774 | } 775 | 776 | .circle6 td, .circle7 td{ 777 | vertical-align:top; 778 | text-align:center; 779 | } 780 | .nopagelabel td.t{ 781 | display:none; 782 | } 783 | .nopagelabel .pgStyle1 var, .circle6 var, .circle7 var{ 784 | width:24px; 785 | height:24px; 786 | line-height:24px; 787 | -webkit-border-radius:12px; 788 | -moz-border-radius:12px; 789 | border-radius:12px; 790 | font-size:90%; 791 | margin:0 auto 7px auto; 792 | float:none; 793 | } 794 | .nopagelabel .pgStyle1 var{ 795 | margin-bottom:0; 796 | } 797 | .circle6 b, .circle7 b{ 798 | padding:0; 799 | } 800 | 801 | .circle2 td{width:50%;} 802 | .circle3 td{width:33%;} 803 | .circle4 td{width:25%;} 804 | .circle5 td{width:20%;} 805 | .circle6 td{width:16.6%;} 806 | .circle7 td{width:14.2%;} 807 | 808 | .pgStyle2 td{ /* Percentage */ 809 | vertical-align:middle; 810 | height:25px; 811 | border:1px solid #CCC; 812 | position:relative; 813 | -webkit-border-radius:14px; 814 | -moz-border-radius:14px; 815 | border-radius:14px; 816 | -webkit-box-shadow:rgba(0,0,0,.10) 1px 1px 1px; 817 | -moz-box-shadow:rgba(0,0,0,.10) 1px 1px 1px; 818 | box-shadow:rgba(0,0,0,.10) 1px 1px 1px; 819 | padding:2px; 820 | } 821 | .pgStyle2 var{ /* Percentage Bar */ 822 | display:block; 823 | height:26px; 824 | float:left; 825 | background:#FFF7C0; 826 | color:#000; 827 | font-style:normal; 828 | text-align:right; 829 | -webkit-border-radius:12px; 830 | -moz-border-radius:12px; 831 | border-radius:12px; 832 | -webkit-box-shadow:rgba(0,0,0,.15) 1px 0px 0px; 833 | -moz-box-shadow:rgba(0,0,0,.15) 1px 0px 0px; 834 | box-shadow:rgba(0,0,0,.15) 1px 0px 0px; 835 | } 836 | .pgStyle2 var b{/* Percentage # */ 837 | display:block; 838 | float:right; 839 | font-size:100%; 840 | padding:3px 10px 3px 3px; 841 | line-height:19px; 842 | } 843 | .pgStyle2 em{/* Page Title */ 844 | font-size:85%; 845 | font-style:normal; 846 | display:inline-block; 847 | margin:0 0 0 9px; 848 | padding:4px 0; 849 | line-height:18px; 850 | } 851 | .pgStyle2 var em{ 852 | padding:4px 5px 3px 0; 853 | } 854 | .page1 .pgStyle2 var{ 855 | padding-left:7px; 856 | text-align:left; 857 | background:none; 858 | -webkit-box-shadow:none; 859 | -moz-box-shadow:none; 860 | box-shadow:none; 861 | } 862 | .page1 .pgStyle2 b{ 863 | float:none; 864 | padding-right:0px; 865 | } 866 | 867 | .hideMarkers .marker, .nopagelabel .pgStyle1 b, .nopagelabel .pgStyle2 em, .hideSecondary #previousPageButton{ 868 | display:none !important; 869 | } 870 | 871 | /* ----- ERRORS ----- */ 872 | 873 | #errorLi{ 874 | width:99%; 875 | margin:15px auto 5px auto; 876 | background:#fff !important; 877 | border:1px solid red; 878 | text-align:center; 879 | padding:1em 0 1em 0; 880 | -webkit-border-radius:20px; 881 | -moz-border-radius:20px; 882 | border-radius:20px; 883 | } 884 | #errorMsgLbl{ 885 | margin:0 0 5px 0; 886 | padding:0; 887 | font-size:125%; 888 | color:#DF0000 !important; 889 | } 890 | #errorMsg{ 891 | margin:0 0 2px 0; 892 | color:#000 !important; 893 | font-size:100%; 894 | } 895 | #errorMsg strong{ 896 | padding:2px 8px; 897 | background-color: #FFDFDF !important; 898 | color:red !important; 899 | -webkit-border-radius:10px; 900 | -moz-border-radius:10px; 901 | border-radius:10px; 902 | } 903 | form li.error{ 904 | display:block !important; 905 | background-color: #FFDFDF !important; 906 | margin-bottom:3px !important; 907 | } 908 | form li label.error, form li input.error{ 909 | color:#DF0000 !important; 910 | font-weight:bold !important; 911 | } 912 | form li input.error{ 913 | background:#fff !important; 914 | border:2px solid #DF0000 !important; 915 | } 916 | 917 | 918 | form li.error label, form li.error span.symbol{ 919 | color:#000 !important; 920 | } 921 | form li.error label.desc{ 922 | color:#DF0000 !important; 923 | } 924 | form p.error{ 925 | display:none; 926 | margin:0 !important; 927 | padding:7px 0 0 0 !important; 928 | line-height:10px !important; 929 | font-weight:bold; 930 | font-size:11px; 931 | color:#DF0000 !important; 932 | clear:both; 933 | } 934 | form li.error p.error{ 935 | display:block; 936 | } 937 | form li.complex p.error{ 938 | padding:0 0 9px 0 !important; 939 | } -------------------------------------------------------------------------------- /webroot/css/wufoo/structure.css: -------------------------------------------------------------------------------- 1 | /* - - - - - - - - - - - - - - - - - - - - - 2 | 3 | Title : Wufoo Form Structure 4 | Author : Infinity Box Inc. 5 | URL : http://wufoo.com 6 | 7 | - - - - - - - - - - - - - - - - - - - - - */ 8 | 9 | html{ 10 | background:#eee; 11 | } 12 | body{ 13 | margin:17px 0 15px 0; 14 | padding:0; 15 | text-align:center; 16 | font-size:small; 17 | font-family:"Lucida Grande", Tahoma, Arial, Verdana, sans-serif; 18 | } 19 | 20 | #container{ 21 | text-align:left; 22 | background:#fff; 23 | border:1px solid #ccc; 24 | -webkit-box-shadow:rgba(0,0,0,.2) 0px 0px 5px; 25 | -moz-box-shadow:rgba(0,0,0,.2) 0px 0px 5px; 26 | box-shadow:rgba(0,0,0,.2) 0px 0px 5px; 27 | } 28 | #container, #bottom{ 29 | margin:0 auto; 30 | width:640px; 31 | } 32 | #bottom{ 33 | width:650px; 34 | height:10px !important; 35 | margin-bottom:10px; 36 | display:block !important; 37 | } 38 | 39 | form.wufoo{ 40 | margin:20px 14px 0 14px; 41 | padding:0 0 20px 0; 42 | } 43 | 44 | /* ----- LOGO ----- */ 45 | 46 | h1{ 47 | margin:0; 48 | padding:0; 49 | min-height:0; 50 | background-color:#dedede; 51 | text-indent:-9000px; 52 | text-decoration:none; 53 | } 54 | h1 a{ 55 | min-height:40px; 56 | height:40px; 57 | display:block; 58 | background:url(../images/wflogo.png) no-repeat left top; 59 | overflow:hidden; 60 | } 61 | * html h1 a{ 62 | _background-image: none; 63 | _filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src="../images/wflogo.png", sizingMethod="crop"); 64 | } 65 | img, a img{ 66 | border:none; 67 | -ms-interpolation-mode: bicubic; 68 | } 69 | * html #bottom{ 70 | _behavior: url(../images/iepngfix.htc); 71 | } 72 | .hide{ 73 | display:none !important; 74 | } -------------------------------------------------------------------------------- /webroot/css/wufoo/theme.css: -------------------------------------------------------------------------------- 1 | /* - - - URL To Google Fonts - - - */ 2 | 3 | /* - - - Custom Theme - - - */ 4 | 5 | 6 | /* ----- Logo ----- */ 7 | h1 a { 8 | background-image:url('../images/wflogo.png'); 9 | min-height:0; 10 | height:px; 11 | } 12 | * html h1 a {/* IE6 png Support */ 13 | background-image: none; 14 | filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src="../images/wflogo.png", sizingMethod="crop"); 15 | } 16 | 17 | /* ----- Backgrounds ----- */ 18 | html{ 19 | background-image:none; background-color:#FFFFFF; 20 | } 21 | h1{ 22 | background-image:none; background-color:#DEDEDE; 23 | } 24 | #container, html.embed{ 25 | background-color:#FFFFFF; 26 | } 27 | .safari .wufoo input.file{ 28 | background:none; 29 | border:none; 30 | } 31 | @-webkit-keyframes fade-in-focused { 32 | from { 33 | background-color: transparent; 34 | } 35 | to { 36 | background-color: #FFF7C0 !important; 37 | } 38 | } 39 | 40 | .wufoo li.focused{ 41 | background-color:#FFF7C0; 42 | } 43 | .wufoo .instruct{ 44 | background-color:#F5F5F5; 45 | } 46 | 47 | /* ----- Borders ----- */ 48 | #container{ 49 | border:1px solid #CCCCCC; 50 | } 51 | .wufoo .info, .wufoo .paging-context{ 52 | border-bottom:1px dotted #CCCCCC; 53 | } 54 | .wufoo .section h3, .wufoo .captcha, #payment .paging-context{ 55 | border-top:1px dotted #CCCCCC; 56 | } 57 | .wufoo input.text, .wufoo textarea.textarea{ 58 | border:; 59 | } 60 | .wufoo .instruct{ 61 | border:1px solid #E6E6E6; 62 | } 63 | .fixed .info{ 64 | border-bottom:none; 65 | } 66 | 67 | /* ----- Typography ----- */ 68 | .wufoo .info h2{ 69 | font-size:160%; 70 | font-family:inherit; 71 | font-weight:; 72 | font-style:; 73 | color:#000000; 74 | } 75 | .wufoo .info div{ 76 | font-size:95%; 77 | font-family:inherit; 78 | font-weight:; 79 | font-style:; 80 | color:#444444; 81 | } 82 | .wufoo .section h3{ 83 | font-size:110%; 84 | font-family:inherit; 85 | font-weight:; 86 | font-style:; 87 | color:#000000; 88 | } 89 | .wufoo .section div{ 90 | font-size:85%; 91 | font-family:inherit; 92 | font-weight:; 93 | font-style:; 94 | color:#444444; 95 | } 96 | 97 | .wufoo label.desc{ 98 | font-size:95%; 99 | font-family:inherit; 100 | font-weight:; 101 | font-style:; 102 | color:#444444; 103 | } 104 | .wufoo label.choice{ 105 | font-size:100%; 106 | font-family:inherit; 107 | font-weight:; 108 | font-style:; 109 | color:#444444; 110 | } 111 | .wufoo input.text, .wufoo textarea.textarea, .wufoo input.file, .wufoo select.select{ 112 | font-size:100%; 113 | font-family:inherit; 114 | font-weight:; 115 | font-style:; 116 | color:#333333; 117 | } 118 | .wufoo li div, .wufoo li span, .wufoo li div label, .wufoo li span label{ 119 | font-family:inherit; 120 | color:#444444; 121 | } 122 | .safari .wufoo input.file{ /* Webkit */ 123 | font-size:100%; 124 | font-family:inherit; 125 | color:#444444; 126 | } 127 | .wufoo .instruct small{ 128 | font-size:80%; 129 | font-family:inherit; 130 | font-weight:; 131 | font-style:; 132 | color:#444444; 133 | } 134 | 135 | .altInstruct small, li.leftHalf small, li.rightHalf small, 136 | li.leftThird small, li.middleThird small, li.rightThird small, 137 | .iphone small{ 138 | color:#444444 !important; 139 | } 140 | 141 | /* ----- Button Styles ----- */ 142 | 143 | .wufoo input.btTxt{ 144 | font-size:; 145 | font-family:; 146 | font-weight:; 147 | font-style:; 148 | color:; 149 | } 150 | 151 | /* ----- Highlight Styles ----- */ 152 | 153 | .wufoo li.focused label.desc, 154 | .wufoo li.focused div, .wufoo li.focused span, .wufoo li.focused div label, .wufoo li.focused span label, 155 | .safari .wufoo li.focused input.file{ 156 | color:#000000; 157 | } 158 | 159 | /* ----- Confirmation ----- */ 160 | 161 | .confirm h2{ 162 | font-family:inherit; 163 | color:#444444; 164 | } 165 | a.powertiny b, a.powertiny em{ 166 | color:#1a1a1a !important; 167 | } 168 | .embed a.powertiny b, .embed a.powertiny em{ 169 | color:#1a1a1a !important; 170 | } 171 | 172 | /* ----- Pagination ----- */ 173 | 174 | .pgStyle1 var, .pgStyle2 var, .pgStyle2 em, .page1 .pgStyle2 var, .pgStyle1 b, .wufoo .buttons .marker{ 175 | font-family:inherit; 176 | color:#444444; 177 | } 178 | .pgStyle1 var, .pgStyle2 td{ 179 | border:1px solid #cccccc; 180 | } 181 | .pgStyle1 .done var{ 182 | background:#cccccc; 183 | } 184 | 185 | .pgStyle1 .selected var, .pgStyle2 var, .pgStyle2 var em{ 186 | background:#FFF7C0; 187 | color:#000000; 188 | } 189 | .pgStyle1 .selected var{ 190 | border:1px solid #e6dead; 191 | } 192 | 193 | 194 | /* Likert Backgrounds */ 195 | 196 | .likert table{ 197 | background-color:#FFFFFF; 198 | } 199 | .likert thead td, .likert thead th{ 200 | background-color:#e6e6e6; 201 | } 202 | .likert tbody tr.alt td, .likert tbody tr.alt th{ 203 | background-color:#f5f5f5; 204 | } 205 | 206 | /* Likert Borders */ 207 | 208 | .likert table, .likert th, .likert td{ 209 | border-color:#dedede; 210 | } 211 | .likert td{ 212 | border-left:1px solid #cccccc; 213 | } 214 | 215 | /* Likert Typography */ 216 | 217 | .likert caption, .likert thead td, .likert tbody th label{ 218 | color:#444444; 219 | font-family:inherit; 220 | } 221 | .likert tbody td label{ 222 | color:#575757; 223 | font-family:inherit; 224 | } 225 | .likert caption, .likert tbody th label{ 226 | font-size:95%; 227 | } 228 | 229 | /* Likert Hover */ 230 | 231 | .likert tbody tr:hover td, .likert tbody tr:hover th, .likert tbody tr:hover label{ 232 | background-color:#FFF7C0; 233 | color:#000000; 234 | } 235 | .likert tbody tr:hover td{ 236 | border-left:1px solid #ccc69a; 237 | } 238 | 239 | /* ----- Report Styles ----- */ 240 | 241 | .wufoo .wfo_graph h3{ 242 | font-size:95%; 243 | font-family:inherit; 244 | color:#444444; 245 | } 246 | .wfo_txt, .wfo_graph h4{ 247 | color:#444444; 248 | } 249 | .wufoo .footer h4{ 250 | color:#000000; 251 | } 252 | .wufoo .footer span{ 253 | color:#444444; 254 | } 255 | 256 | /* ----- Number Widget ----- */ 257 | 258 | .wfo_number{ 259 | background-color:#f5f5f5; 260 | border-color:#dedede; 261 | } 262 | .wfo_number strong, .wfo_number em{ 263 | color:#000000; 264 | } 265 | 266 | /* ----- Chart Widget Border and Background Colors ----- */ 267 | 268 | #widget, #widget body{ 269 | background:#FFFFFF; 270 | } 271 | .fcNav a.show{ 272 | background-color:#FFFFFF; 273 | border-color:#cccccc; 274 | } 275 | .fc table{ 276 | border-left:1px solid #dedede; 277 | } 278 | .fc thead th, .fc .more th{ 279 | background-color:#dedede !important; 280 | border-right:1px solid #cccccc !important; 281 | } 282 | .fc tbody td, .fc tbody th, .fc tfoot th, .fc tfoot td{ 283 | background-color:#FFFFFF; 284 | border-right:1px solid #cccccc; 285 | border-bottom:1px solid #dedede; 286 | } 287 | .fc tbody tr.alt td, .fc tbody tr.alt th, .fc tbody td.alt{ 288 | background-color:#f5f5f5; 289 | } 290 | 291 | /* ----- Chart Widget Typography Colors ----- */ 292 | 293 | .fc caption, .fcNav, .fcNav a{ 294 | color:#444444; 295 | } 296 | .fc tfoot, 297 | .fc thead th, 298 | .fc tbody th div, 299 | .fc tbody td.count, .fc .cards tbody td a, .fc td.percent var, 300 | .fc .timestamp span{ 301 | color:#000000; 302 | } 303 | .fc .indent .count{ 304 | color:#4b4b4b; 305 | } 306 | .fc .cards tbody td a span{ 307 | color:#7d7d7d; 308 | } 309 | 310 | /* ----- Chart Widget Hover Colors ----- */ 311 | 312 | .fc tbody tr:hover td, .fc tbody tr:hover th, 313 | .fc tfoot tr:hover td, .fc tfoot tr:hover th{ 314 | background-color:#FFF7C0; 315 | } 316 | .fc tbody tr:hover th div, .fc tbody tr:hover td, .fc tbody tr:hover var, 317 | .fc tfoot tr:hover th div, .fc tfoot tr:hover td, .fc tfoot tr:hover var{ 318 | color:#000000; 319 | } 320 | 321 | /* ----- Payment Summary ----- */ 322 | 323 | .invoice thead th, 324 | .invoice tbody th, .invoice tbody td, 325 | .invoice tfoot th, 326 | .invoice .total, 327 | .invoice tfoot .last th, .invoice tfoot .last td, 328 | .invoice tfoot th, .invoice tfoot td{ 329 | border-color:#dedede; 330 | } 331 | .invoice thead th{ 332 | background:#f5f5f5; 333 | } 334 | .invoice th, .invoice td{ 335 | color:#000000; 336 | } 337 | #ppSection, #ccSection{ 338 | border-bottom:1px dotted #CCCCCC; 339 | } 340 | #shipSection, #invoiceSection{ 341 | border-top:1px dotted #CCCCCC; 342 | } 343 | 344 | /* Drop Shadows */ 345 | #bottom{ 346 | visibility:visible; 347 | } 348 | -------------------------------------------------------------------------------- /webroot/js/wufoo.js: -------------------------------------------------------------------------------- 1 | addEvent(window, 'load', initForm); 2 | 3 | var highlight_array = new Array(); 4 | 5 | function initForm(){ 6 | var paymentRedirecting = checkPaypal(); 7 | browserDetect(); 8 | initializeFocus(); 9 | var activeForm = document.getElementsByTagName('form')[0]; 10 | addEvent(activeForm, 'submit', disableSubmitButton); 11 | ifInstructs(); 12 | showRangeCounters(); 13 | checkMechanicalTurk(); 14 | if(!paymentRedirecting) initAutoResize(); 15 | } 16 | 17 | function disableSubmitButton() { 18 | document.getElementById('saveForm').disabled = true; 19 | } 20 | 21 | // for radio and checkboxes, they have to be cleared manually, so they are added to the 22 | // global array highlight_array so we dont have to loop through the dom every time. 23 | function initializeFocus(){ 24 | fields = getElementsByClassName(document, "*", "field"); 25 | for(i = 0; i < fields.length; i++) { 26 | if(fields[i].type == 'radio' || fields[i].type == 'checkbox') { 27 | fields[i].onclick = function(){clearSafariRadios(); addClassName(this.parentNode.parentNode.parentNode, "focused", true)}; 28 | fields[i].onfocus = function(){clearSafariRadios(); addClassName(this.parentNode.parentNode.parentNode, "focused", true)}; 29 | highlight_array.splice(highlight_array.length,0,fields[i]); 30 | } 31 | else if(fields[i].className.match('addr')){ 32 | fields[i].onfocus = function(){clearSafariRadios(); addClassName(this.parentNode.parentNode.parentNode, "focused", true)}; 33 | fields[i].onblur = function(){removeClassName(this.parentNode.parentNode.parentNode, "focused")}; 34 | } 35 | else if(fields[i].className.match('other')){ 36 | fields[i].onfocus = function(){clearSafariRadios(); addClassName(this.parentNode.parentNode.parentNode, "focused", true)}; 37 | } 38 | else { 39 | fields[i].onfocus = function(){clearSafariRadios();addClassName(this.parentNode.parentNode, "focused", true)}; 40 | fields[i].onblur = function(){removeClassName(this.parentNode.parentNode, "focused")}; 41 | } 42 | } 43 | } 44 | 45 | function initAutoResize() { 46 | var key = 'wufooForm'; 47 | if(typeof(__EMBEDKEY) != 'undefined') key = __EMBEDKEY; 48 | if(parent.postMessage) { 49 | parent.postMessage(document.body.offsetHeight+'|'+key, "*"); 50 | } 51 | else createTempCookie(key, document.body.offsetHeight); 52 | } 53 | 54 | function createTempCookie(name, value) 55 | { 56 | var date = new Date(); 57 | date.setTime(date.getTime()+(60*1000)); 58 | var expires = "; expires="+date.toGMTString(); 59 | document.cookie = name+"="+value+expires+"; domain=.wufoo.com; path=/"; 60 | if(readTempCookie(name) != value) { 61 | var script = document.createElement("script"); 62 | script.setAttribute("src", "http://wufoo.com/forms/height.js?action=set&embedKey="+name+"&height="+value+"×tamp = "+ new Date().getTime().toString()); 63 | script.setAttribute("type","text/javascript"); 64 | document.body.appendChild(script); 65 | } 66 | } 67 | 68 | function readTempCookie(name) 69 | { 70 | var nameEQ = name + "="; 71 | var ca = document.cookie.split(';'); 72 | for(var i=0;i < ca.length;i++) 73 | { 74 | var c = ca[i]; 75 | while (c.charAt(0)==' ') c = c.substring(1,c.length); 76 | if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length); 77 | } 78 | return ''; 79 | } 80 | 81 | function clearSafariRadios() { 82 | for(var i = 0; i < highlight_array.length; i++) { 83 | if(highlight_array[i].parentNode) { 84 | removeClassName(highlight_array[i].parentNode.parentNode.parentNode, 'focused'); 85 | } 86 | } 87 | } 88 | 89 | function ifInstructs(){ 90 | var container = document.getElementById('public'); 91 | if(container){ 92 | removeClassName(container,'noI'); 93 | var instructs = getElementsByClassName(document,"*","instruct"); 94 | if(instructs == ''){ 95 | addClassName(container,'noI',true); 96 | } 97 | if(container.offsetWidth <= 450){ 98 | addClassName(container,'altInstruct',true); 99 | } 100 | } 101 | } 102 | 103 | function browserDetect(){ 104 | var detect = navigator.userAgent.toLowerCase(); 105 | var container = document.getElementsByTagName('html'); 106 | if(detect.indexOf('firefox') + 1){ 107 | addClassName(container[0], 'firefox', true); 108 | } 109 | else if(detect.indexOf('chrome') + 1){ 110 | addClassName(container[0], 'chrome', true); 111 | } 112 | else if(detect.indexOf('safari') + 1){ 113 | addClassName(container[0], 'safari', true); 114 | } 115 | } 116 | 117 | function checkPaypal() { 118 | var ret = false; 119 | if(document.getElementById('merchant')) { 120 | ret = true; 121 | if(typeof(__EMBEDKEY) == 'undefined'){ 122 | document.getElementById('merchantMessage').innerHTML = 'Your order is being processed. Please wait a moment while we redirect you to our payment page.'; 123 | document.getElementById('merchantButton').style.display = 'none'; 124 | } 125 | document.getElementById('merchant').submit(); 126 | } 127 | return ret; 128 | } 129 | 130 | function checkMechanicalTurk() { 131 | if(document.getElementById('mechanicalTurk')) { 132 | document.getElementById('merchantMessage').innerHTML = 'Your submission is being processed. You will be redirected shortly.'; 133 | document.getElementById('merchantButton').style.display = 'none'; 134 | document.getElementById('mechanicalTurk').submit(); 135 | } 136 | } 137 | 138 | function showRangeCounters(){ 139 | counters = getElementsByClassName(document, "em", "currently"); 140 | for(i = 0; i < counters.length; i++) { 141 | counters[i].style.display = 'inline'; 142 | } 143 | } 144 | 145 | function validateRange(ColumnId, RangeType) { 146 | if(document.getElementById('rangeUsedMsg'+ColumnId)) { 147 | var field = document.getElementById('Field'+ColumnId); 148 | var msg = document.getElementById('rangeUsedMsg'+ColumnId); 149 | 150 | switch(RangeType) { 151 | case 'character': 152 | msg.innerHTML = field.value.length; 153 | break; 154 | 155 | case 'word': 156 | var val = field.value; 157 | val = val.replace(/\n/g, " "); 158 | var words = val.split(" "); 159 | var used = 0; 160 | for(i =0; i < words.length; i++) { 161 | if(words[i].replace(/\s+$/,"") != "") used++; 162 | } 163 | msg.innerHTML = used; 164 | break; 165 | 166 | case 'digit': 167 | msg.innerHTML = field.value.length; 168 | break; 169 | } 170 | } 171 | } 172 | 173 | /*--------------------------------------------------------------------------*/ 174 | 175 | //http://www.robertnyman.com/2005/11/07/the-ultimate-getelementsbyclassname/ 176 | function getElementsByClassName(oElm, strTagName, strClassName){ 177 | var arrElements = (strTagName == "*" && oElm.all)? oElm.all : oElm.getElementsByTagName(strTagName); 178 | var arrReturnElements = new Array(); 179 | strClassName = strClassName.replace(/\-/g, "\\-"); 180 | var oRegExp = new RegExp("(^|\\s)" + strClassName + "(\\s|$)"); 181 | var oElement; 182 | for(var i=0; i