*/
//EOF
+require_once ('init.php');
require_once ('config.php');
?>
\ No newline at end of file
* 追加設定
*/
-
-/*
- * パスの設定
- */
-// ベースパス
- Configure::write('Routing.basePath', array('controller' => 'members', 'action' => 'index'));
-
-// ログインパス
- Configure::write('Routing.loginPath', array('controller' => 'members', 'action' => 'login'));
-
/*
* ユーザID/パスワード関連
*/
-// 管理画面ユーザIDの文字数
- Configure::write('User.UserId.Length',
- array('min' => 4, 'max' => 12)
- );
-
-// 管理画面パスワードの文字数
- Configure::write('User.Password.Length',
- array('min' => 6, 'max' => 12)
- );
+// ユーザIDの文字数
+Configure::write('User.UserId.Length',
+ array('min' => 4, 'max' => 12)
+);
-// 一般ユーザIDの文字数
- Configure::write('Member.MemberId.Length',
- array('min' => 4, 'max' => 12)
- );
+// パスワードの文字数
+Configure::write('User.Password.Length',
+ array('min' => 6, 'max' => 12)
+);
-// 一般ユーザパスワードの文字数
- Configure::write('Member.Password.Length',
- array('min' => 6, 'max' => 12)
- );
* Session time out time (in seconds).
* Actual value depends on 'Security.level' setting.
*/
- Configure::write('Session.timeout', '360');
+ Configure::write('Session.timeout', '432'); // 60 * 60 * 12 / 100
/**
* If set to false, sessions are not automatically started.
*/
* CakePHP session IDs are also regenerated between requests if
* 'Security.level' is set to 'high'.
*/
- Configure::write('Security.level', 'high');
+ Configure::write('Security.level', 'medium');
/**
* A random string used in security hashing methods.
*/
--- /dev/null
+<?php
+/**
+ * 動作環境設定(基本、編集不可)
+ */
+
+/*
+ * パスの設定
+ */
+// ベースパス
+Configure::write('Routing.basePath', array('controller' => 'users', 'action' => 'index'));
+Configure::write('Routing.adminBasePath', array('controller' => 'users', 'action' => 'index'));
+
+// ログインパス
+Configure::write('Routing.loginPath', array('controller' => 'users', 'action' => 'login'));
+
+
+/*
+ * ACL:group_idの設定
+ */
+Configure::write('Group.admin', 1);
+Configure::write('Group.subadmin', 2);
+Configure::write('Group.watcher', 3);
+Configure::write('Group.member', 4);
+Configure::write('Group.pre', 5);
+Configure::write('Group.locked', 6);
+Configure::write('Group.deleted', 7);
+Configure::write('Group.banned', 8);
+
*/
// Router::connect('/', array('controller' => 'pages', 'action' => 'display', 'home'));
Router::connect('/', Configure::read('Routing.basePath'));
-
+ Router::connect('/'.Configure::read('Routing.admin'), Configure::read('Routing.adminBasePath'));
/**
* ...and connect the rest of 'Pages' controller's urls.
if (preg_match("/^".str_replace("/", "\/", $this->webroot)."m\//", $_SERVER['REQUEST_URI'])) {
Router::connect('/m/:controller/:action/*', array('prefix' => 'mobile'));
+ Router::connect('/m/:controller/:action/:id', array('prefix' => 'mobile'));
}
?>
+++ /dev/null
-CREATE TABLE members (
- id INTEGER UNSIGNED NOT NULL AUTO_INCREMENT,
- username VARCHAR(40) NOT NULL,
- password VARCHAR(40) NOT NULL,
- nickname VARCHAR(64) NOT NULL,
- uid VARCHAR(40) NOT NULL,
- career VARCHAR(20) NOT NULL,
- useragent VARCHAR(255) NOT NULL,
- created DATETIME NOT NULL,
- modified DATETIME NOT NULL,
- PRIMARY KEY(id),
- INDEX members_login(username, password),
- UNIQUE INDEX members_uid(uid),
- UNIQUE INDEX members_username(username)
-);
+++ /dev/null
-CREATE TABLE notes (
- id INTEGER UNSIGNED NOT NULL AUTO_INCREMENT,
- member_id INTEGER UNSIGNED NOT NULL,
- lat FLOAT NOT NULL,
- lon FLOAT NOT NULL,
- title TEXT NOT NULL,
- body TEXT NOT NULL,
- public_flag VARCHAR(32) NOT NULL DEFAULT 'private',
- created DATETIME NOT NULL,
- modified DATETIME NOT NULL,
- PRIMARY KEY(id),
- INDEX note_member_id(member_id),
- INDEX note_pulic_flag(public_flag, member_id, modified),
- INDEX note_modified(modified, member_id)
-)
-TYPE=InnoDB;
--- /dev/null
+/*!40101 SET NAMES utf8 */;
+
+--
+-- Table structure for table `acos`
+--
+
+DROP TABLE IF EXISTS `acos`;
+CREATE TABLE `acos` (
+ `id` int(10) unsigned NOT NULL auto_increment,
+ `parent_id` int(10) default NULL,
+ `model` varchar(255) default '',
+ `foreign_key` int(10) unsigned default NULL,
+ `alias` varchar(255) default '',
+ `lft` int(10) default NULL,
+ `rght` int(10) default NULL,
+ PRIMARY KEY (`id`),
+ KEY `alias` (`alias`),
+ KEY `lft_rght` (`lft`,`rght`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8;
+
+--
+-- Dumping data for table `acos`
+--
+
+LOCK TABLES `acos` WRITE;
+/*!40000 ALTER TABLE `acos` DISABLE KEYS */;
+INSERT INTO `acos` VALUES
+(1,NULL,'',NULL,'controllers',1,6),
+(2,1,'',NULL,'Users',2,3),
+(3,1,'',NULL,'Groups',4,5),
+(4,NULL,'',NULL,'prefix',7,14),
+(5,4,'',NULL,'admin',8,9),
+(6,4,'',NULL,'pc',10,11),
+(7,4,'',NULL,'m',12,13);
+/*!40000 ALTER TABLE `acos` ENABLE KEYS */;
+UNLOCK TABLES;
+
+--
+-- Table structure for table `aros`
+--
+
+DROP TABLE IF EXISTS `aros`;
+CREATE TABLE `aros` (
+ `id` int(10) unsigned NOT NULL auto_increment,
+ `parent_id` int(10) default NULL,
+ `model` varchar(255) default '',
+ `foreign_key` int(10) unsigned default NULL,
+ `alias` varchar(255) default '',
+ `lft` int(10) default NULL,
+ `rght` int(10) default NULL,
+ PRIMARY KEY (`id`),
+ KEY `model_foreign_key` (`model`,`foreign_key`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8;
+
+--
+-- Dumping data for table `aros`
+--
+
+LOCK TABLES `aros` WRITE;
+/*!40000 ALTER TABLE `aros` DISABLE KEYS */;
+INSERT INTO `aros` VALUES
+(1,NULL,'Group',1,'Group::1',1,4),
+(2,NULL,'Group',2,'Group::2',5,6),
+(3,NULL,'Group',3,'Group::3',7,8),
+(4,NULL,'Group',4,'Group::4',9,10),
+(5,NULL,'Group',5,'Group::5',11,12),
+(6,NULL,'Group',6,'Group::6',13,14),
+(7,NULL,'Group',7,'Group::7',15,16),
+(8,NULL,'Group',8,'Group::8',17,18),
+(9,1,'User',1,'User::1',2,3);
+/*!40000 ALTER TABLE `aros` ENABLE KEYS */;
+UNLOCK TABLES;
+
+--
+-- Table structure for table `aros_acos`
+--
+
+DROP TABLE IF EXISTS `aros_acos`;
+CREATE TABLE `aros_acos` (
+ `id` int(10) unsigned NOT NULL auto_increment,
+ `aro_id` int(10) unsigned NOT NULL,
+ `aco_id` int(10) unsigned NOT NULL,
+ `_create` char(2) NOT NULL default '0',
+ `_read` char(2) NOT NULL default '0',
+ `_update` char(2) NOT NULL default '0',
+ `_delete` char(2) NOT NULL default '0',
+ PRIMARY KEY (`id`),
+ KEY `aro_aco` (`aro_id`,`aco_id`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8;
+
+--
+-- Dumping data for table `aros_acos`
+--
+
+LOCK TABLES `aros_acos` WRITE;
+/*!40000 ALTER TABLE `aros_acos` DISABLE KEYS */;
+INSERT INTO `aros_acos` VALUES
+(1,1,1,'1','1','1','1'),
+(2,1,4,'1','1','1','1'),
+(3,2,1,'1','1','1','1'),
+(4,2,4,'1','1','1','1'),
+(5,2,3,'-1','-1','-1','-1'),
+(6,3,1,'-1','-1','-1','-1'),
+(7,3,4,'1','1','1','1'),
+(8,3,2,'1','1','1','1'),
+(9,3,5,'0','1','0','1'),
+(10,4,4,'1','1','1','1'),
+(11,4,2,'1','1','1','1'),
+(12,4,1,'-1','-1','-1','-1'),
+(13,4,5,'-1','-1','-1','-1'),
+(14,5,1,'-1','-1','-1','-1'),
+(15,5,4,'1','1','1','1'),
+(16,5,5,'-1','-1','-1','-1'),
+(17,5,2,'0','0','1','0'),
+(18,6,1,'-1','-1','-1','-1'),
+(19,7,1,'-1','-1','-1','-1'),
+(20,8,1,'-1','-1','-1','-1');
+/*!40000 ALTER TABLE `aros_acos` ENABLE KEYS */;
+UNLOCK TABLES;
+
+--
+-- Table structure for table `cake_sessions`
+--
+
+DROP TABLE IF EXISTS `cake_sessions`;
+CREATE TABLE `cake_sessions` (
+ `id` varchar(255) NOT NULL default '',
+ `data` text,
+ `expires` int(11) default NULL,
+ PRIMARY KEY (`id`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8;
+
+--
+-- Table structure for table `groups`
+--
+
+DROP TABLE IF EXISTS `groups`;
+CREATE TABLE `groups` (
+ `id` int(10) unsigned NOT NULL auto_increment,
+ `name` varchar(8) default NULL,
+ `parent_id` int(10) unsigned default NULL,
+ PRIMARY KEY (`id`),
+ KEY `groups_parent_id` (`parent_id`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8;
+
+--
+-- Dumping data for table `groups`
+--
+
+LOCK TABLES `groups` WRITE;
+/*!40000 ALTER TABLE `groups` DISABLE KEYS */;
+INSERT INTO `groups` VALUES
+(1,'admin',0),
+(2,'subadmin',0),
+(3,'watcher',0),
+(4,'member',0),
+(5,'pre',0),
+(6,'locked',0),
+(7,'deleted',0),
+(8,'banned',0);
+/*!40000 ALTER TABLE `groups` ENABLE KEYS */;
+UNLOCK TABLES;
+
+--
+-- Table structure for table `users`
+--
+
+DROP TABLE IF EXISTS `users`;
+CREATE TABLE `users` (
+ `id` int(10) unsigned NOT NULL auto_increment,
+ `group_id` int(10) unsigned NOT NULL,
+ `name` varchar(64) NOT NULL,
+ `username` varchar(40) NOT NULL,
+ `password` varchar(40) NOT NULL,
+ `pcmail` blob NOT NULL,
+ `mobile_mail` blob NOT NULL,
+ `useragent` varchar(512) NOT NULL,
+ `host` varchar(64) NOT NULL,
+ `created` datetime NOT NULL,
+ `modified` datetime NOT NULL,
+ PRIMARY KEY (`id`),
+ UNIQUE KEY `users_username` (`username`),
+ KEY `users_login` (`username`,`password`),
+ KEY `users_modefied` (`modified`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8;
+
+
+CREATE TABLE groups (
+ id INTEGER UNSIGNED NOT NULL AUTO_INCREMENT,
+ name VARCHAR(8) NULL,
+ parent_id INTEGER UNSIGNED NULL,
+ PRIMARY KEY(id),
+ INDEX groups_parent_id(parent_id)
+)
+TYPE=InnoDB;
+
CREATE TABLE users (
id INTEGER UNSIGNED NOT NULL AUTO_INCREMENT,
- username VARCHAR(40) NOT NULL default '',
- password VARCHAR(40) NOT NULL default '',
+ group_id INTEGER UNSIGNED NOT NULL,
+ name VARCHAR(64) NOT NULL,
+ username VARCHAR(40) NOT NULL,
+ password VARCHAR(40) NOT NULL,
+ pcmail BLOB NOT NULL,
+ useragent VARCHAR(255) NOT NULL,
+ host VARCHAR(64) NOT NULL,
+ created DATETIME NOT NULL,
+ modified DATETIME NOT NULL,
PRIMARY KEY(id),
- UNIQUE INDEX users_username(username)
-);
+ INDEX users_login(username, password),
+ UNIQUE INDEX users_username(username),
+ INDEX users_modefied(modified)
+)
+TYPE=InnoDB;
// 携帯チェック
$this->agent = &Net_UserAgent_Mobile::factory();
if (!$this->agent->isNonMobile()) {
- Configure::write('mobile', 1);
+ Configure::write('mobileUserAgent', true);
}
class AppController extends Controller
{
+ var $isAdministrator = false;
+ var $isAdmin = false;
+ var $isMobile = false;
+
+ var $components = array(
+ 'AuthPlus',
+ 'Acl',
+ 'Token'
+ );
+
+ /* ACL */
+ // 追加アクション用 crudMap
+ var $actionMapPlus = array();
+
+ // POSTのTokenチェックをしないアクション
+ var $disableTokenActions = array();
+
+ function beforeFilter()
+ {
+ parent::beforeFilter();
+
+ if (isset($this->params['prefix'])) {
+ if ($this->params['prefix'] == Configure::read('Routing.admin')) {
+ $this->isAdmin = true;
+ } elseif ($this->params['prefix'] == 'm') {
+ $this->isMobile = true;
+ }
+ }
+ $this->set('admin', $this->isAdmin);
+
+ if ($this->AuthPlus) {
+ // ACL関連
+ $this->AuthPlus->actionPath = 'controllers/';
+ $this->AuthPlus->authorize = 'crud';
+
+ // 対CRSF:Tokenチェック
+ $this->Token->checkToken();
+
+ // 認証アクション設定
+ if (Configure::read('mobileUserAgent')) {
+ $this->AuthPlus->loginAction = '/m/users/login';
+ $this->AuthPlus->loginRedirect = '/m/users/index';
+ $this->AuthPlus->logoutRedirect = '/m/users/index';
+ } else {
+ $this->AuthPlus->loginAction = '/users/login';
+ $this->AuthPlus->loginRedirect = '/users/index';
+ $this->AuthPlus->logoutRedirect = '/users/to_login';
+ }
+ if ($this->isAdmin) {
+ $this->AuthPlus->loginRedirect = '/admin/users/index';
+ }
+ }
+
+ // refresh設定
+ $this->set('refresh', array('time' => 0, 'url' => ''));
+ }
function beforeRender()
{
parent::beforeRender();
- // 認証済みユーザIDのセット
- $AuthUser = $this->MemberAuth->user();
- if (!$AuthUser) {
- $this->set('uid', 0);
- } else {
- $this->set('uid', $AuthUser[$this->MemberAuth->userModel]['id']);
+ // 認証済みユーザ情報のセット
+ if (isset($this->AuthPlus)) {
+ $this->set('uid', $this->AuthPlus->user('id'));
+ $this->set('gid', $this->AuthPlus->user('group_id'));
+ if (in_array($this->AuthPlus->user('group_id'), array(1,2,3))) {
+ $this->isAdministrator = true;
+ }
+ $this->set('isAdministrator', $this->isAdministrator);
}
}
+ /*
+ * 不正な$this->dataセットを削除
+ */
+ function unsetData($mode, $setting, $skip='')
+ {
+ $fields = $this->{$this->modelClass}->fields;
+ foreach ($fields as $field => $value) {
+ if ($skip && $field == $skip) {
+ continue;
+ }
+ if ($mode == '*' || (isset($value[$mode]) && $value[$mode] === $setting)) {
+ unset($this->data[$this->modelClass][$field]);
+ }
+ }
+
+ }
+
}
// AppControllerを携帯とPCで振り分け
-if (Configure::read('mobile')) {
+if (Configure::read('mobileUserAgent')) {
class ModuleController extends MobileAppController
{
}
$this->redirect($pc_url);
}
- // refresh設定
- $this->set('refresh', array('time' => 0, 'url' => ''));
}
function beforeRender()
--- /dev/null
+<?php
+/*
+ * 認証コンポーネント拡張
+ */
+
+/**
+ * The parent component
+ */
+App::import('Component', 'Auth');
+
+class AuthPlusComponent extends AuthComponent {
+
+/**
+ * The name of the model that represents users which will be authenticated. Defaults to 'User'.
+ *
+ * @var string
+ * @access public
+ */
+ var $userModel = 'User';
+
+ function initialize(&$controller)
+ {
+ // ACL: controllerごとのactionMap設定マージ
+ $this->actionMap = array_merge($this->actionMap, $controller->actionMapPlus);
+ $admin = Configure::read('Routing.admin');
+ if (!empty($admin)) {
+ foreach ($controller->actionMapPlus as $k => $v) {
+ $this->actionMap = array_merge(
+ $this->actionMap,
+ array($admin . '_'. $k => $v)
+ );
+ }
+ }
+
+ parent::initialize($controller);
+
+ // ログイン後リダイレクト設定
+ $this->loginRedirect = $controller->params["url"]["url"];
+ if ("/".$this->loginRedirect == Router::normalize(Configure::read('Routing.loginPath'))) {
+ $this->loginRedirect = Router::normalize(Configure::read('Routing.basePath'));
+ if (Configure::read('mobileUserAgent')) {
+ $this->loginRedirect .= "m/";
+ }
+ }
+ }
+
+ function deleteAuth()
+ {
+ $this->__setDefaults();
+ $this->Session->del($this->sessionKey);
+ $this->_loggedIn = false;
+ return Router::normalize($this->logoutRedirect);
+ }
+
+ function isAuthorized($type = null, $object = null, $user = null) {
+ $valid = parent::isAuthorized($type, $object, $user);
+
+ // view prefixごとのチェック
+ if ($valid) {
+ if (isset($this->params['prefix'])
+ && $this->params['prefix'] == Configure::read('Routing.admin')) {
+ $valid = $this->Acl->check(
+ $this->user(),
+ 'admin',
+ $this->actionMap[$this->params['action']]
+ );
+ }
+ }
+
+ return $valid;
+ }
+
+
+}
+
+
--- /dev/null
+<?php
+/**
+ * CSRF対策用Tokenチェッカー
+ * Security.level = medium または low のみ
+ */
+
+class TokenComponent extends Object
+{
+
+/**
+ * Components used by TokenHelper
+ *
+ * @var array
+ * @access public
+ */
+ var $components = array('Session');
+
+ var $_modelClass;
+ var $_data = array();
+ var $_action;
+ var $_actionMap = array();
+ var $type;
+ var $useToken = false;
+ var $disableActions = array();
+
+ function initialize(&$controller)
+ {
+ $this->_modelClass = $controller->modelClass;
+ $this->_action = $controller->action;
+ if (isset($controller->params['data'])) {
+ $this->_data = $controller->params['data'];
+ }
+
+ if (isset($controller->AuthPlus)) {
+ $this->_actionMap = $controller->AuthPlus->actionMap;
+ } else {
+ return ;
+ }
+
+ if (isset($this->_actionMap[$this->_action])) {
+ $this->type = $this->_actionMap[$this->_action];
+ }
+
+ if (!isset($controller->disableTokenActions)) {
+ $this->useToken = false;
+ } else {
+ $this->useToken = $this->isUseToken($controller->disableTokenActions);
+ }
+
+ $this->Session->startup($controller);
+ }
+
+ /* true: Token OK */
+ function checkToken($tag_name = '__Token', $hash_type = 'md5')
+ {
+ if ($this->useToken === false) {
+ return ;
+ }
+ $hashed_session_id = $this->get_hashed_session_id();
+
+ if ($this->_data) {
+ if (!isset($this->_data[$this->_modelClass][$tag_name])) {
+ $this->_blackHole();
+ }
+ if ($this->_data[$this->_modelClass][$tag_name] != $hashed_session_id) {
+ $this->_blackHole();
+ }
+ } else {
+ return ;
+ }
+ }
+
+ /* true:Token使用 */
+ function isUseToken($disableTokenActions)
+ {
+ if ($disableTokenActions == '*') {
+ return false;
+ }
+ if (!$this->type || $this->type == 'read') {
+ return false;
+ }
+ if (in_array($this->_action, (array)$disableTokenActions)) {
+ return false;
+ }
+
+ return true;
+ }
+
+ function _blackHole($msg='')
+ {
+ if (!$msg) {
+ $msg = _('ILLEGAL POST!');
+ }
+
+ die($msg);
+ }
+
+ /* 現在のセッションIDを暗号化して取得 */
+ function get_hashed_session_id($hash_type = 'md5')
+ {
+ $session_id = $this->Session->id(null);
+
+ if (!$session_id) {
+ $this->_blackHole('No Session.');
+ }
+
+ return Security::hash($session_id. Configure::read('Security.salt'), $hash_type);
+ }
+
+}
+
--- /dev/null
+<?php
+class GroupsController extends ModuleController {
+
+ var $name = 'Groups';
+ var $helpers = array('Html', 'Form');
+
+ function beforeFilter() {
+ parent::beforeFilter();
+
+ // \8b@\94\\92â\8e~
+ $this->Session->setFlash(__('Unavailable Now.', true));
+ $this->redirect($this->AuthPlus->loginRedirect);
+ }
+
+ function admin_index() {
+ $this->Group->recursive = 0;
+ $this->set('groups', $this->paginate());
+ }
+
+ function admin_view($id = null) {
+ if (!$id) {
+ $this->Session->setFlash(__('Invalid Group.', true));
+ $this->redirect(array('action'=>'index'));
+ }
+ $this->set('group', $this->Group->read(null, $id));
+ }
+
+ function admin_add() {
+ if (!empty($this->data)) {
+ $this->Group->create();
+ if ($this->Group->save($this->data)) {
+ $this->Session->setFlash(__('The Group has been saved', true));
+ $this->redirect(array('action'=>'index'));
+ } else {
+ $this->Session->setFlash(__('The Group could not be saved. Please, try again.', true));
+ }
+ }
+ }
+
+ function admin_edit($id = null) {
+ if (!$id && empty($this->data)) {
+ $this->Session->setFlash(__('Invalid Group', true));
+ $this->redirect(array('action'=>'index'));
+ }
+ if (!empty($this->data)) {
+ if ($this->Group->save($this->data)) {
+ $this->Session->setFlash(__('The Group has been saved', true));
+ $this->redirect(array('action'=>'index'));
+ } else {
+ $this->Session->setFlash(__('The Group could not be saved. Please, try again.', true));
+ }
+ }
+ if (empty($this->data)) {
+ $this->data = $this->Group->read(null, $id);
+ }
+ }
+
+ function admin_delete($id = null) {
+ if (!$id) {
+ $this->Session->setFlash(__('Invalid id for Group', true));
+ $this->redirect(array('action'=>'index'));
+ }
+ if ($this->Group->del($id)) {
+ $this->Session->setFlash(__('Group deleted', true));
+ $this->redirect(array('action'=>'index'));
+ }
+ }
+
+}
+?>
\ No newline at end of file
+++ /dev/null
-<?php
-class MembersController extends ModuleController {
-
- var $name = 'Members';
- var $helpers = array('Html', 'Form');
- var $components = array('MemberAuth');
-
- function beforeFilter() {
- parent::beforeFilter();
-
- // 認証なしアクセス可
- $this->MemberAuth->allow('login');
- $this->MemberAuth->allow('logout');
- $this->MemberAuth->allow('mobile_login');
- $this->MemberAuth->allow('mobile_logout');
- // 仮
- $this->MemberAuth->allow('add');
-
- }
-
- // 携帯用
- function mobile_login() {
-
- }
-
- function mobile_logout() {
- $this->Session->setFlash(__('Logout.', true));
- $this->redirect($this->MemberAuth->logout());
- }
-
- function mobile_index() {
- $this->set('member', $this->Member->read(null, $this->MemberAuth->user("id")));
- }
- function mobile_view($id = null) {
- if (!$id) {
- $this->Session->setFlash(__('Invalid Member.', true));
- $this->redirect(array('action'=>'listview'));
- }
- if ($id == $this->MemberAuth->user("id")) {
- $this->redirect(array('action'=>'index'));
- }
- $member = $this->Member->read(null, $id);
- if (!$member['Member']) {
- $this->Session->setFlash(__('Invalid Member.', true));
- $this->redirect(array('action'=>'listview'));
- }
- $this->set('member', $member);
- }
-
- function mobile_listview() {
- $this->Member->recursive = 0;
- $this->set('members', $this->paginate());
- }
- function mobile_add() {
- if (!empty($this->data)) {
- $this->Member->create();
- if ($this->Member->save($this->data)) {
- $this->Session->setFlash(__('The Member has been saved', true));
- $this->redirect(array('action'=>'index'));
- } else {
- $this->Session->setFlash(__('The Member could not be saved. Please, try again.', true));
- }
- }
- }
- function mobile_edit($id = null) {
- if (!$id && empty($this->data)) {
- $this->Session->setFlash(__('Invalid Member', true));
- $this->redirect(array('action'=>'index'));
- }
- if (!empty($this->data)) {
- if ($this->Member->save($this->data)) {
- $this->Session->setFlash(__('The Member has been saved', true));
- $this->redirect(array('action'=>'index'));
- } else {
- $this->Session->setFlash(__('The Member could not be saved. Please, try again.', true));
- }
- }
- if (empty($this->data)) {
- $this->data = $this->Member->read(null, $id);
- }
- }
- function mobile_delete($id = null) {
- if (!$id) {
- $this->Session->setFlash(__('Invalid id for Member', true));
- $this->redirect(array('action'=>'index'));
- }
- if ($id != $this->MemberAuth->user("id")) {
- $this->Session->setFlash(__('Permission denied.', true));
- $this->redirect(array('action'=>'index'));
- }
- if ($this->Member->del($id)) {
- $this->Session->setFlash(__('Member deleted', true));
- $this->redirect(array('action'=>'logout'));
- }
- }
-
- // PC用
- function login() { }
-
- function logout() {
- $this->Session->setFlash(__('Logout.', true));
- $this->redirect($this->MemberAuth->logout());
- }
-
- function index() {
- $this->set('member', $this->Member->read(null, $this->MemberAuth->user("id")));
- }
-
- function view($id = null) {
- if (!$id) {
- $this->Session->setFlash(__('Invalid Member.', true));
- $this->redirect(array('action'=>'listview'));
- }
- if ($id == $this->MemberAuth->user("id")) {
- $this->redirect(array('action'=>'index'));
- }
- $member = $this->Member->read(null, $id);
- if (!$member['Member']) {
- $this->Session->setFlash(__('Invalid Member.', true));
- $this->redirect(array('action'=>'listview'));
- }
- $this->set('member', $member);
- }
-
- function listview() {
- $this->Member->recursive = 0;
- $this->set('members', $this->paginate());
- }
-
- function add() {
- if (!empty($this->data)) {
- $this->Member->create();
- if ($this->Member->save($this->data)) {
- $this->Session->setFlash(__('The Member has been saved', true));
- $this->redirect(array('action'=>'index'));
- } else {
- $this->Session->setFlash(__('The Member could not be saved. Please, try again.', true));
- }
- }
- }
- function edit($id = null) {
- if (!$id && empty($this->data)) {
- $this->Session->setFlash(__('Invalid Member', true));
- $this->redirect(array('action'=>'index'));
- }
- if (!empty($this->data)) {
- if ($this->Member->save($this->data)) {
- $this->Session->setFlash(__('The Member has been saved', true));
- $this->redirect(array('action'=>'index'));
- } else {
- $this->Session->setFlash(__('The Member could not be saved. Please, try again.', true));
- }
- }
- if (empty($this->data)) {
- $this->data = $this->Member->read(null, $id);
- }
- }
- function delete($id = null) {
- if (!$id) {
- $this->Session->setFlash(__('Invalid id for Member', true));
- $this->redirect(array('action'=>'index'));
- }
- if ($id != $this->MemberAuth->user("id")) {
- $this->Session->setFlash(__('Permission denied.', true));
- $this->redirect(array('action'=>'index'));
- }
- if ($this->Member->del($id)) {
- $this->Session->setFlash(__('Member deleted', true));
- $this->redirect(array('action'=>'logout'));
- }
- }
-
- // 管理画面用
- function admin_index() {
- $this->Member->recursive = 0;
- $this->set('members', $this->paginate());
- }
- function admin_view($id = null) {
- if (!$id) {
- $this->Session->setFlash(__('Invalid Member.', true));
- $this->redirect(array('action'=>'index'));
- }
- $this->set('member', $this->Member->read(null, $id));
- }
- function admin_add() {
- if (!empty($this->data)) {
- $this->Member->create();
- if ($this->Member->save($this->data)) {
- $this->Session->setFlash(__('The Member has been saved', true));
- $this->redirect(array('action'=>'index'));
- } else {
- $this->Session->setFlash(__('The Member could not be saved. Please, try again.', true));
- }
- }
- }
- function admin_edit($id = null) {
- if (!$id && empty($this->data)) {
- $this->Session->setFlash(__('Invalid Member', true));
- $this->redirect(array('action'=>'index'));
- }
- if (!empty($this->data)) {
- if ($this->Member->save($this->data)) {
- $this->Session->setFlash(__('The Member has been saved', true));
- $this->redirect(array('action'=>'index'));
- } else {
- $this->Session->setFlash(__('The Member could not be saved. Please, try again.', true));
- }
- }
- if (empty($this->data)) {
- $this->data = $this->Member->read(null, $id);
- }
- }
-
- function admin_delete($id = null) {
- if (!$id) {
- $this->Session->setFlash(__('Invalid id for Member', true));
- $this->redirect(array('action'=>'index'));
- }
- if ($this->Member->del($id)) {
- $this->Session->setFlash(__('Member deleted', true));
- $this->redirect(array('action'=>'index'));
- }
- }
-
-}
-?>
\ No newline at end of file
+++ /dev/null
-<?php
-class NotesController extends ModuleController {
-
- var $name = 'Notes';
- var $helpers = array('Html', 'Form');
-
- // 携帯用
- function mobile_index() {
- $this->Note->recursive = 0;
- $this->set('notes', $this->paginate());
- }
- function mobile_view($id = null) {
- if (!$id) {
- $this->Session->setFlash(__('Invalid Note.', true));
- $this->redirect(array('action'=>'mobile_index'));
- }
- $this->set('note', $this->Note->read(null, $id));
- }
- function mobile_add() {
- if (!empty($this->data)) {
- $this->Note->create();
- if ($this->Note->save($this->data)) {
- $this->Session->setFlash(__('The Note has been saved', true));
- $this->redirect(array('action'=>'index'));
- } else {
- $this->Session->setFlash(__('The Note could not be saved. Please, try again.', true));
- }
- }
- $members = $this->Note->Member->find('list');
- $this->set(compact('members'));
- }
- function mobile_edit($id = null) {
- if (!$id && empty($this->data)) {
- $this->Session->setFlash(__('Invalid Note', true));
- $this->redirect(array('action'=>'index'));
- }
- if (!empty($this->data)) {
- if ($this->Note->save($this->data)) {
- $this->Session->setFlash(__('The Note has been saved', true));
- $this->redirect(array('action'=>'index'));
- } else {
- $this->Session->setFlash(__('The Note could not be saved. Please, try again.', true));
- }
- }
- if (empty($this->data)) {
- $this->data = $this->Note->read(null, $id);
- }
- $members = $this->Note->Member->find('list');
- $this->set(compact('members'));
- }
- function mobile_delete($id = null) {
- if (!$id) {
- $this->Session->setFlash(__('Invalid id for Note', true));
- $this->redirect(array('action'=>'index'));
- }
- if ($this->Note->del($id)) {
- $this->Session->setFlash(__('Note deleted', true));
- $this->redirect(array('action'=>'index'));
- }
- }
-
- // PC用
- function index() {
- $this->Note->recursive = 0;
- $this->set('notes', $this->paginate());
- }
- function view($id = null) {
- if (!$id) {
- $this->Session->setFlash(__('Invalid Note.', true));
- $this->redirect(array('action'=>'index'));
- }
- $this->set('note', $this->Note->read(null, $id));
- }
- function add() {
- if (!empty($this->data)) {
- $this->Note->create();
- if ($this->Note->save($this->data)) {
- $this->Session->setFlash(__('The Note has been saved', true));
- $this->redirect(array('action'=>'index'));
- } else {
- $this->Session->setFlash(__('The Note could not be saved. Please, try again.', true));
- }
- }
- $members = $this->Note->Member->find('list');
- $this->set(compact('members'));
- }
- function edit($id = null) {
- if (!$id && empty($this->data)) {
- $this->Session->setFlash(__('Invalid Note', true));
- $this->redirect(array('action'=>'index'));
- }
- if (!empty($this->data)) {
- if ($this->Note->save($this->data)) {
- $this->Session->setFlash(__('The Note has been saved', true));
- $this->redirect(array('action'=>'index'));
- } else {
- $this->Session->setFlash(__('The Note could not be saved. Please, try again.', true));
- }
- }
- if (empty($this->data)) {
- $this->data = $this->Note->read(null, $id);
- }
- $members = $this->Note->Member->find('list');
- $this->set(compact('members'));
- }
- function delete($id = null) {
- if (!$id) {
- $this->Session->setFlash(__('Invalid id for Note', true));
- $this->redirect(array('action'=>'index'));
- }
- if ($this->Note->del($id)) {
- $this->Session->setFlash(__('Note deleted', true));
- $this->redirect(array('action'=>'index'));
- }
- }
-
- // 管理画面用
- function admin_index() {
- $this->Note->recursive = 0;
- $this->set('notes', $this->paginate());
- }
- function admin_view($id = null) {
- if (!$id) {
- $this->Session->setFlash(__('Invalid Note.', true));
- $this->redirect(array('action'=>'index'));
- }
- $this->set('note', $this->Note->read(null, $id));
- }
- function admin_add() {
- if (!empty($this->data)) {
- $this->Note->create();
- if ($this->Note->save($this->data)) {
- $this->Session->setFlash(__('The Note has been saved', true));
- $this->redirect(array('action'=>'index'));
- } else {
- $this->Session->setFlash(__('The Note could not be saved. Please, try again.', true));
- }
- }
- $members = $this->Note->Member->find('list');
- $this->set(compact('members'));
- }
- function admin_edit($id = null) {
- if (!$id && empty($this->data)) {
- $this->Session->setFlash(__('Invalid Note', true));
- $this->redirect(array('action'=>'index'));
- }
- if (!empty($this->data)) {
- if ($this->Note->save($this->data)) {
- $this->Session->setFlash(__('The Note has been saved', true));
- $this->redirect(array('action'=>'index'));
- } else {
- $this->Session->setFlash(__('The Note could not be saved. Please, try again.', true));
- }
- }
- if (empty($this->data)) {
- $this->data = $this->Note->read(null, $id);
- }
- $members = $this->Note->Member->find('list');
- $this->set(compact('members'));
- }
- function admin_delete($id = null) {
- if (!$id) {
- $this->Session->setFlash(__('Invalid id for Note', true));
- $this->redirect(array('action'=>'index'));
- }
- if ($this->Note->del($id)) {
- $this->Session->setFlash(__('Note deleted', true));
- $this->redirect(array('action'=>'index'));
- }
- }
-
-}
-?>
\ No newline at end of file
class UsersController extends ModuleController {
var $name = 'Users';
- var $helpers = array('Html', 'Form');
- var $components = array('MemberAuth');
+ var $helpers = array(
+ 'Html',
+ 'Form',
+ 'Token'
+ );
+
+ /* ACL */
+ // 追加アクション用 crudMap
+ var $actionMapPlus = array(
+ 'listview' => 'read',
+ 'change_password' => 'update',
+ );
+
+ var $disableTokenActions = array('add','mobile_add');
function beforeFilter() {
+
parent::beforeFilter();
+ // 不正fieldsのPOST削除(id, createdなど)
+ $this->unsetData('auto', true);
+
// 認証なしアクセス可
- $this->MemberAuth->allow('admin_login');
- $this->MemberAuth->allow('admin_add');
- $this->MemberAuth->allow('admin_logout');
- $this->MemberAuth->allow('admin_to_login');
+ $this->AuthPlus->allow('login');
+ $this->AuthPlus->allow('add'); //todo:メール認証etc
+ $this->AuthPlus->allow('logout');
+ $this->AuthPlus->allow('to_login');
+ $this->AuthPlus->allow('mobile_login');
+ $this->AuthPlus->allow('mobile_add'); //todo:メール認証etc
+ $this->AuthPlus->allow('mobile_logout');
+ $this->AuthPlus->allow('mobile_to_login');
- // ログイン後遷移先
- $this->MemberAuth->loginRedirect = '/admin/users/index';
}
-
- function admin_login() {
+ /* PC */
+ function login() {
+ // 現在のセッション削除
+ $this->AuthPlus->deleteAuth();
}
- function admin_logout() {
- $this->Session->setFlash(__('Logout.', true));
- $this->redirect($this->MemberAuth->logout());
+ function logout() {
+ self::_logout();
}
- function admin_to_login($refresh = 5)
+ function to_login($refresh = 3)
{
+ // 現在のセッション削除
+ $this->AuthPlus->logout();
+
$this->set('refresh', array('time' => $refresh, 'url' => Router::url('index', false)));
+ }
+ function index() {
+ self::_index();
}
- function admin_index() {
- $this->User->recursive = 0;
- $this->set('users', $this->paginate());
+ function view($id = null) {
+ self::_view($id);
}
- function admin_add() {
+ function listview() {
+
+ self::_listview();
+ }
+
+ function add() {
+ if (!empty($this->data)) {
+ self::_add();
+ }
+
$this->set('idLength', Configure::read('User.UserId.Length'));
$this->set('passwordLength', Configure::read('User.Password.Length'));
+ }
+
+ function edit($id = null) {
+ self::_edit($id);
+ }
+
+ function change_password($id = null) {
+ self::_change_password($id);
+ $this->set('passwordLength', Configure::read('User.Password.Length'));
+ }
+
+ function delete($id = null) {
+ self::_delete($id);
+ }
+
+ /* 携帯側 */
+ function mobile_login() {
+ // 現在のセッション削除
+ $this->AuthPlus->deleteAuth();
+ }
+
+ function mobile_logout() {
+ self::_logout();
+ }
+
+ function mobile_index() {
+ self::_index();
+ }
+ function mobile_view($id = null) {
+ self::_view($id);
+ }
+
+ function mobile_listview() {
+
+ self::_listview();
+ }
+
+ function mobile_add() {
if (!empty($this->data)) {
- // バリデーション
- $this->User->set($this->data);
- if ($this->User->validates()) {
- // passwordセット
- $this->data['User']['password'] = $this->MemberAuth->password($this->data['User']['password1']);
-
- // save
- $this->User->create();
- if ($this->User->save($this->data)) {
- $this->Session->setFlash(__('The User has been saved', true));
- $this->redirect(array('action'=>'index'));
- }
+ self::_add();
+ }
+
+ $this->set('idLength', Configure::read('User.UserId.Length'));
+ $this->set('passwordLength', Configure::read('User.Password.Length'));
+ }
+
+ function mobile_edit($id = null) {
+ self::_edit($id);
+ }
+
+ function mobile_change_password($id = null) {
+ self::_change_password($id);
+
+ $this->set('passwordLength', Configure::read('User.Password.Length'));
+ }
+
+ function mobile_delete($id = null) {
+ self::_delete($id);
+ }
+
+ /* 管理画面 */
+ function admin_index() {
+ $this->redirect(array('controller' => 'users', 'action'=>'listview'));
+ }
+
+ function admin_listview() {
+
+ // 検索処理
+ $this->User->contain();
+ $contain = array();
+ $searchword = array();
+ if (!empty($this->data)) {
+ if (isset($this->data['User']['name'])) {
+ $name = $this->data['User']['name'];
+ }
+ } else {
+ if (isset($this->passedArgs['name'])) {
+ $name = urldecode($this->passedArgs['name']);
}
+ }
+
+ if (isset($name)) {
+ $this->data['User']['name'] = $name;
+ $contain["User.name LIKE"] = "%".Sanitize::html($name)."%";
+ $searchword['name'] = urlencode($name);
}
+ $this->set('searchword', $searchword);
+
+ $this->set('users', $this->paginate('User', $contain));
+
}
- function admin_change_password($id = null) {
+ function admin_view($id = null) {
+ if (!$id) {
+ $this->Session->setFlash(__('Invalid User.', true));
+ $this->redirect(array('controller' => 'users', 'action'=>'index'));
+ }
+ $this->set('user', $this->User->read(null, $id));
+ }
+
+ function admin_add() {
+ if (!empty($this->data)) {
+ self::_add(true);
+ }
+
+ $this->set('idLength', Configure::read('User.UserId.Length'));
$this->set('passwordLength', Configure::read('User.Password.Length'));
+ }
+
+ function admin_change_password($id = null) {
if (!$id && empty($this->data)) {
- $this->Session->setFlash(__('Invalid User', true));
- $this->redirect(array('action'=>'index'));
+ $this->Session->setFlash(__('No ID', true));
+ $this->redirect(array('controller' => 'users', 'action'=>'index'));
}
if (!empty($this->data)) {
- // バリデーション
- $this->User->set($this->data);
- if ($this->User->validates()) {
- // passwordセット
- $this->data[$this->MemberAuth->userModel]['password'] = $this->MemberAuth->password($this->data[$this->MemberAuth->userModel]['password1']);
+ $result = self::_exe_change_password($id);
+ if ($result) {
+ $this->Session->setFlash(__('The password has been changed.', true));
+ $this->redirect(array('controller' => 'users', 'action'=>'index'));
+ }
+ }
+ if (empty($this->data)) {
+ $this->data = $this->User->read(null, $id);
+ }
- if ($this->User->save($this->data)) {
- $this->Session->setFlash(__('The password has been changed. Please login at new password.', true));
+ $this->set('passwordLength', Configure::read('User.Password.Length'));
+ }
- if ($data[$this->MemberAuth->userModel]['id'] == $AuthUser[$this->MemberAuth->userModel]['id']) {
- $this->MemberAuth->logout();
- $this->redirect('/admin/users/to_login');
- } else {
- $this->redirect('/admin/users/index');
- }
+ function admin_delete($id = null) {
+ if (!$id) {
+ $this->Session->setFlash(__('No ID', true));
+ $this->redirect(array('controller' => 'users', 'action'=>'index'));
+ }
+ if ($this->data) {
+ $result = self::_exe_delete($id);
+ if ($result) {
+ $this->redirect(array('controller' => 'users', 'action'=>'index'));
+ }
+ }
+
+ $user = self::getUser($id);
+ if (!$user) {
+ $this->Session->setFlash(__('No Member', true));
+ $this->redirect(array('controller' => 'users', 'action'=>'listview'));
+ }
+ $this->set('user', $user);
+
+ $this->data['User']['id'] = $id;
+ }
+ /* Users共通メソッド */
+ function _logout() {
+ $this->Session->setFlash(__('Logout.', true));
+ $this->redirect($this->AuthPlus->logout());
+ }
+
+ function _index() {
+ // アクセス更新
+ $this->User->id = $this->AuthPlus->user('id');
+ $this->User->saveField('useragent', $_SERVER["HTTP_USER_AGENT"]);
+ $this->User->saveField('host', gethostbyaddr($_SERVER["REMOTE_ADDR"]));
+
+ $this->set('user', $this->User->read(null, $this->AuthPlus->user('id')));
+ }
+
+ function _view($id) {
+ if ($id && $id == $this->AuthPlus->user("id")) {
+ $this->redirect(array('action'=>'index'));
+ }
+
+ $user = self::getUser($id);
+ if (!$user) {
+ $this->redirect(array('action'=>'listview'));
+ }
+ $this->set('user', $user);
+ }
+
+ function _listview() {
+ $this->User->recursive = -1;
+ $this->set('users', $this->paginate());
+ }
+
+ function _add() {
+ $this->unsetData('add', false);
+ if (!$this->isAdmin) {
+ unset($this->data['User']['group_id']);
+ }
+ // バリデーション
+ $this->User->set($this->data);
+ if ($this->User->validates()) {
+
+ // ACL設定(デフォルト:一般ユーザ)
+ if (!isset($this->data['User']['group_id'])) {
+ $this->data['User']['group_id'] = Configure::read('Group.member');
+ }
+
+ // passwordセット
+ $this->data['User']['password'] = $this->AuthPlus->password($this->data['User']['password1']);
+
+ // 他データ
+ if (!$this->isAdmin) {
+ $this->data['User']['useragent'] = $_SERVER["HTTP_USER_AGENT"];
+ $this->data['User']['host'] = gethostbyaddr($_SERVER["REMOTE_ADDR"]);
+ }
+
+ // save
+ $this->User->create();
+ if ($this->User->save($this->data)) {
+ $this->Session->setFlash(__('The User has been saved', true));
+ if (!$this->isAdmin) {
+ $this->redirect($this->AuthPlus->logoutRedirect);
} else {
- $this->Session->setFlash(__('The User could not be saved. Please, try again.', true));
+ $this->redirect(array('controller' => 'users', 'action'=>'listview'));
}
+ } else {
+ $this->Session->setFlash(__('The User cannot be saved.', true));
+ }
+ }
+ }
+
+ function _edit($id) {
+ if (!$id && empty($this->data)) {
+ $this->Session->setFlash(__('Invalid User', true));
+ $this->redirect(array('action'=>'index'));
+ }
+ if ($id != $this->AuthPlus->user("id")) {
+ $this->Session->setFlash(__('No permission.', true));
+ $this->redirect(array('action'=>'index'));
+ }
+ if (!empty($this->data)) {
+ // ユーザ変更以外のPost削除
+ $this->unsetData('edit', false);
+
+ if ($this->User->save($this->data)) {
+ $this->Session->setFlash(__('The User has been saved', true));
+ $this->redirect(array('action'=>'index'));
+ } else {
+ $this->Session->setFlash(__('The User could not be saved. Please, try again.', true));
}
}
if (empty($this->data)) {
$this->data = $this->User->read(null, $id);
+
+ $this->data['User']['name'] = $this->User->restore_html($this->data['User']['name'], false);
}
}
- function admin_delete($id = null) {
+ function _change_password($id) {
+ if (!$id && empty($this->data)) {
+ $this->Session->setFlash(__('No ID', true));
+ $this->redirect(array('action'=>'index'));
+ }
+ if ($id != $this->AuthPlus->user("id")) {
+ $this->Session->setFlash(__('No permission.', true));
+ $this->redirect(array('action'=>'index'));
+ }
+ if (!empty($this->data)) {
+ // password以外のPost削除
+ $this->unsetData('*', '', 'password');
+
+ $data = $this->User->read('password', $id);
+ if ($data['User']['password'] != $this->AuthPlus->password($this->data['User']['password'])) {
+ $this->Session->setFlash(__('Old Password is wrong.', true));
+ } else {
+ $result = self::_exe_change_password($id);
+ if ($result) {
+ $this->Session->setFlash(__('The password has been changed. Please login at new password.', true));
+ $this->redirect($this->AuthPlus->logout());
+ }
+ }
+ }
+
+ $this->data['User']['id'] = $id;
+ }
+ function _exe_change_password($id) {
+ // バリデーション
+ $this->User->set($this->data);
+ if ($this->User->validates()) {
+
+ // passwordセット
+ $this->data[$this->AuthPlus->userModel]['password'] = $this->AuthPlus->password($this->data[$this->AuthPlus->userModel]['password1']);
+
+ if ($this->User->save($this->data)) {
+ return true;
+ } else {
+ $this->Session->setFlash(__('The User could not be saved. Please, try again.', true));
+ return false;
+ }
+ }
+ }
+
+ function _delete($id) {
if (!$id) {
- $this->Session->setFlash(__('Invalid id for User', true));
+ $this->Session->setFlash(__('No ID', true));
$this->redirect(array('action'=>'index'));
}
- if ($this->User->del($id)) {
- $this->Session->setFlash(__('User deleted', true));
+ if ($id != $this->AuthPlus->user("id")) {
+ $this->Session->setFlash(__('Permission denied.', true));
$this->redirect(array('action'=>'index'));
}
+ if ($this->data) {
+ $data = $this->User->read('password', $id);
+ if ($data['User']['password'] != $this->AuthPlus->password($this->data['User']['password'])) {
+ $this->Session->setFlash(__('Password is wrong.', true));
+ } else {
+ $result = self::_exe_delete($id);
+ if ($result) {
+ $this->redirect($this->AuthPlus->logout());
+ } else {
+ $this->redirect(array('action'=>'index'));
+ }
+ }
+ }
+ $this->data['User']['id'] = $id;
+ }
+ function _exe_delete($id) {
+ $user = self::getUser($id);
+ if (!$user) {
+ return false;
+ }
+ if ($user['User']['group_id'] == 1) {
+ $this->Session->setFlash(__('Super Administrator can not be deleted.', true));
+ return false;
+ }
+ if ($this->User->del($id)) {
+ $this->Session->setFlash(sprintf(__('%s was deleted.', true), $user['User']['name']));
+ return true;
+ } else {
+ $this->Session->setFlash(__('The account could not be deleted.', true));
+ return false;
+ }
+ }
+
+ function getUser($id) {
+ if (!$id) {
+ $this->Session->setFlash(__('Error, No id.', true));
+ return null;
+ }
+ $user = $this->User->read(null, $id);
+ if (!$user['User']) {
+ $this->Session->setFlash(__('Invalid User.', true));
+ return null;
+ }
+ return $user;
}
}
-?>
<?php
+
+app::import('Sanitize');
+
class AppModel extends Model {
var $actsAs = array(
'Cakeplus.ValidationErrorI18n',
+ 'Cakeplus.AddValidationRule',
+ 'SanitizePlus',
);
- function beforeValidate(){
+ /*
+ * DBフィールドごとの基本処理設定
+ * 例
+ * var $fields = array(
+ * 'field_name' => array( // field名
+ * 'auto' => false, // true:自動設定値 ユーザ設定不可(id, created, modified...)
+ * 'add' => true, // true: 追加画面でフォームを表示する項目
+ * 'edit' => false, // 編集画面でフォーム表示を表示する項目
+ * 'escape' => array( // escape処理
+ * 'html' => true, // true: Sanitize::html()を行なう
+ * 'all' => true, // true: Sanitize::stripAll()を行なう
+ * 'whitespace' => true, // true: Sanitize::stripWhitespace()を行なう
+ * 'images' => true, // true: Sanitize::stripImages()を行なう
+ * 'sctipts' => true, // true: Sanitize::stripScripts()を行なう
+ * ),
+ * ),
+ * $fields設定は個々のモデルで行なう
+ */
+ var $fields = array();
+
+ /* コールバックメソッド */
+ function beforeValidate($options = array())
+ {
+ // i18n Error Messages
+ // Working on the CakePlus
$error_messages = array(
'notEmpty' => __('Please be sure to input.', true),
'between' => __('Between %2$d and %3$d characters.', true),
+ 'minLength' => __('More than %2$d characters.', true),
+ 'maxLength' => __('Less than %2$d characters.', true),
'alphaNumeric' => __('Please input only alphameric characters.', true),
'compare2fields' => __('Please input same as above.', true),
'betweenWrapper' => __('Too short or Too long.', true),
+ 'isUnique' => __('It was already registed.', true),
);
$this->setErrorMessageI18n($error_messages, false);
$this->replaceValidationErrorMessagesI18n();
- return true;
+
+ return parent::beforeValidate($options);
}
- /* 本線alphaNumeric()の上書き */
+ function beforeSave($options = array())
+ {
+ // Sanitize(不正コード、SQL Injection)
+ $this->data = Sanitize::clean(
+ $this->data,
+ array(
+ 'encode' => false,
+ )
+ );
+
+ return parent::beforeSave($options);
+ }
+
+ /* Validation */
+ /* alphaNumeric() */
+ /** It Overwrites the original alphaNumeric() **/
function alphaNumeric($data)
{
$check = is_array($data) ? array_shift($data) : $data;
}
}
- /* 本線Betweenへのwrapper */
+ /* Wrapper to the origibal between() */
function betweenWrapper($check, $min, $max)
{
return Validation::between($check, $min, $max);
}
-
}
--- /dev/null
+<?php
+
+/*
+ * 独自のSanitize、逆Sanitizeの追加Behavoir
+ * The behavoir of the additional Sanitize rules, reverse-Sanitize rules.
+ */
+
+app::import('Sanitize');
+
+class SanitizePlusBehavior extends ModelBehavior {
+
+ var $settings = array();
+
+ function setup(&$model, $config = array()) {
+ $this->settings = $config;
+ }
+
+ /* 各modelに設定した$fieldsの設定でSanitize */
+ // Sanitize::clean(),Sanitize::escape()以外
+ function escapeByFields(&$model, $field, $string)
+ {
+ if (isset($model->fields[$field]['escape']['all']) && $model->fields[$field]['escape']['all']) {
+ $string = Sanitize::stripAll($string);
+ } else {
+ if (isset($model->fields[$field]['escape']['whitespace']) && $model->fields[$field]['escape']['whitespace']) {
+ $string = Sanitize::stripWhitespace($string);
+ }
+ if (isset($model->fields[$field]['escape']['images']) && $model->fields[$field]['escape']['images']) {
+ $string = Sanitize::stripImages($string);
+ }
+ if (isset($model->fields[$field]['escape']['sctipts']) && $model->fields[$field]['escape']['sctipts']) {
+ $string = Sanitize::stripScripts($string);
+ }
+ }
+ if (isset($model->fields[$field]['escape']['html']) && $model->fields[$field]['escape']['html']) {
+ $string = Sanitize::html($string);
+ }
+ return $string;
+ }
+
+ /* reverse-Sanitize */
+ /* return HTML tags from HTML entities.
+ * base on ver1.2.5
+ * @param string $string Sanitized Data
+ * @param boolean $strip_all If true, Sanitized by Sanitize::stripAll(), and NO NEEW to set below 3 $args.
+ * @param boolean $strip_scripts If true, Sanitized by Sanitize::stripScripts()
+ * @param boolean $strip_images If true, Sanitized by Sanitize::stripImages()
+ * @param boolean $strip_whitespace If true, Sanitized by Sanitize::stripWhitespace()
+ * return Data reverted HTML tags
+ */
+ function restore_html(&$model, $string, $strip_all = true, $strip_scripts = true, $strip_images = true, $strip_whitespace = true) {
+ $patterns = array("/\&/", "/\%/", "/\</", "/\>/", "/\"/", "/\'/", "/\(/", "/\)/", "/\+/", "/\-/");
+ $replacements = array("&", "%", "<", ">", '"', "'", "(", ")", "+", "-");
+
+ $string = preg_replace($patterns, $replacements, $string);
+
+ if ($strip_all) {
+ $string = Sanitize::stripAll($string);
+ } else {
+ if ($strip_scripts) {
+ $string = Sanitize::stripScripts($string);
+ }
+ if ($strip_images) {
+ $string = Sanitize::stripImages($string);
+ }
+ if ($strip_whitespace) {
+ $string = Sanitize::stripImages($string);
+ }
+ }
+
+ return $string;
+ }
+
+ /* return SQL descaped strings.
+ */
+ function restore_escape(&$model, $string) {
+
+ return stripslashes($string);
+ }
+
+}
--- /dev/null
+<?php
+class Group extends AppModel {
+
+ var $name = 'Group';
+ var $actsAs = array(
+ 'Acl' => 'requester', // ARO自動登録用
+ );
+
+ function parentNode() {
+ if (!$this->id) {
+ return null;
+ }
+ $data = $this->read();
+ if (!$data['Group']['parent_id']){
+ return null;
+ } else {
+ return array('model' => 'Group', 'foreign_key' => $data['Group']['parent_id']);
+ }
+ }
+
+ // 更新時に親IDを変更する
+ function save($data = null, $validate = true, $fieldList = array())
+ {
+ if (parent::save($data, $validate, $fieldList)) {
+ $conditions = array(
+ 'model' => $this->name,
+ 'foreign_key' => $this->id,
+ );
+
+ App::import('Component', 'Acl');
+ $Aro = new Aro;
+ $Aro->id = $Aro->field('id', $conditions);
+ $Aro->saveField('parent_id', $data['Group']['parent_id']);
+ $Aro->saveField('alias', $this->name . '::' . $this->id);
+ return true;
+ }
+ return false;
+ }
+
+}
+?>
+++ /dev/null
-<?php
-class Member extends AppModel {
-
- var $name = 'Member';
-
-}
-?>
\ No newline at end of file
+++ /dev/null
-<?php
-class Note extends AppModel {
-
- var $name = 'Note';
-
- //The Associations below have been created with all possible keys, those that are not needed can be removed
- var $belongsTo = array(
- 'Member' => array(
- 'className' => 'Member',
- 'foreignKey' => 'member_id',
- 'conditions' => '',
- 'fields' => '',
- 'order' => ''
- )
- );
-
-}
-?>
\ No newline at end of file
class User extends AppModel {
var $name = 'User';
+ var $belongsTo = array('Group');
var $actsAs = array(
- 'Cakeplus.AddValidationRule',
+ 'Acl' => 'requester', // ARO自動登録用
+ 'Containable',
+ );
+
+ var $fields = array(
+ 'id' => array(
+ 'auto' => true,
+ ),
+ 'group_id' => array(
+ 'auto' => false,
+ 'add' => true,
+ 'edit' => false,
+ ),
+ 'name' => array(
+ 'auto' => false,
+ 'add' => true,
+ 'edit' => true,
+ 'escape' => array(
+ 'html' => true,
+ 'all' => true,
+ ),
+ ),
+ 'username' => array(
+ 'auto' => false,
+ 'add' => true,
+ 'edit' => false,
+ ),
+ 'password' => array(
+ 'auto' => false,
+ 'add' => true,
+ 'edit' => false,
+ ),
+ 'pcmail' => array(
+ 'auto' => false,
+ 'add' => false,
+ 'edit' => false,
+ ),
+ 'mobile_mail' => array(
+ 'auto' => false,
+ 'add' => false,
+ 'edit' => false,
+ ),
+ 'useragent' => array(
+ 'auto' => true,
+ ),
+ 'host' => array(
+ 'auto' => true,
+ ),
+ 'created' => array(
+ 'auto' => true,
+ ),
+ 'modified' => array(
+ 'auto' => true,
+ ),
);
var $validate = array(
+ 'name' => array(
+ 'MaxLength' => array(
+ 'rule' => array('MaxLength', 64),
+ ),
+ 'notEmpty' => array(
+ 'rule' => 'notEmpty',
+ ),
+ ),
'username' => array(
+ 'isUnique' => array(
+ 'rule' => array('isUnique'),
+ ),
'betweenWrapper' => array(
'rule' => array('betweenUsername'),
),
'notEmpty' => array(
'rule' => 'notEmpty',
),
- )
+ ),
);
+ /* コールバックメソッド */
+ function beforeValidate($options = array())
+ {
+
+ return parent::beforeValidate($options);
+
+ }
+ function beforeSave($options = array())
+ {
+
+ // $fieldsの設定でSanitize
+ foreach($this->data['User'] as $field => $value) {
+ $this->data['User'][$field] = $this->escapeByFields($field, $value);
+ }
+ return parent::beforeSave($options);
+ }
+
+
+ /* validation */
function betweenUsername($data)
{
$idLength = Configure::read('User.UserId.Length');
return parent::betweenWrapper($check[0], $idLength['min'], $idLength['max']);
}
+ // ACL
+ function parentNode()
+ {
+ if (!$this->id && empty($this->data)) {
+ return null;
+ }
+ $data = $this->data;
+ if (empty($this->data)) {
+ $data = $this->read();
+ } elseif (!isset($data['User']['group_id']) || !$data['User']['group_id']) {
+ $data['User']['group_id'] = $this->read('group_id');
+ }
+ if (!$data['User']['group_id']) {
+ return null;
+ } else {
+ return array('model' => 'Group', 'foreign_key' => $data['User']['group_id']);
+ }
+ }
+ // 更新時に親IDを変更する
+ function save($data = null, $validate = true, $fieldList = array())
+ {
+ if (parent::save($data, $validate, $fieldList)) {
+ $conditions = array(
+ 'model' => $this->name,
+ 'foreign_key' => $this->id,
+ );
+
+ App::import('Component', 'Acl');
+ $Aro = new Aro;
+ $Aro->id = $Aro->field('id', $conditions);
+ if (isset($data['User']['group_id']) && $data['User']['group_id']) {
+ $Aro->saveField('parent_id', $data['User']['group_id']);
+ }
+ $Aro->saveField('alias', $this->name . '::' . $this->id);
+ return true;
+ }
+ return false;
+ }
+
}
?>
\ No newline at end of file
--- /dev/null
+Cake plus is cakephp plugin and provides some functions for CakePHP.
+
+We will provide functions as follow.
+
+#Component
+ -HtmlEscape: Execute Html Escape and nl2br to Array Data
+ (Option: you can set no escape list in Array Data)
+
+
+#Behavior
+ -AddValidationRule: Check number of Multi byte character.
+ Check difference between 2 fields.
+ Check Japanese Hiragana only input.
+ Check Japanese Katakana only input.
+ Check Japanese Zenkaku only input.
+ Check space and Multibyte space only input.
+
+ -ValidationErrorI18n: set validation error messages with gettext __()
+
+
+#Helper
+ -FormScreen: Auto create hidden tag
+
+
+
+===== Contributors ========================
+k1LoW : feature of hash value check with AuthComponent in add_validation_rule::checkCompare
+ adding validation rules(betweenJP, hiragana_only, zenkaku_only)
+ Help me to create ValidationErrorI18nBehavior.
+
--- /dev/null
+<?php
+
+
+class CakeplusAppController extends AppController {
+
+}
+
+?>
\ No newline at end of file
--- /dev/null
+<?php
+
+class CakeplusAppModel extends AppModel {
+
+
+
+}
+
+?>
\ No newline at end of file
--- /dev/null
+<?php
+
+/**
+ * Plugin component : Execute Html Escape and nl2br to Array Data
+ *
+ * Licensed under The MIT License
+ * Redistributions of files must retain the above copyright notice.
+ *
+ * @copyright Copyright 2009, Yasushi Ichikawa. (http://d.hatena.ne.jp/cakephper/)
+ * @link http://d.hatena.ne.jp/cakephper/
+ * @package cakeplus
+ * @subpackage html_escape
+ * @version 0.01
+ * @license MIT License (http://www.opensource.org/licenses/mit-license.php)
+ *
+ *
+ * =====Usage=====
+ * // do html escape to pagination data exclude Post.title.
+ * //in controller
+ * var $components = array( 'Cakeplus.HtmlEscape' );
+ *
+ * $this->set('posts', $this->HtmlEscape->nl2br_h($this->paginate( 'Post' ),null, array( 'Post.title') ) );
+ *
+ * ===============
+ *
+ *
+ */
+class HtmlEscapeComponent extends Object {
+
+
+ function startup() {
+
+ }
+
+
+ /**
+ * Execute nl2br() and h() to Array Data
+ *
+ * @param string or array $value
+ * @param string $charset
+ * @param array $noescape_list
+ * @param string $parent_key
+ * @return string or array
+ */
+ function nl2br_h( $value, $charset = null , $noescape_list = null ,$parent_key = null ) {
+
+ if (is_array($value)) {
+ foreach ($value as $key => $val) {
+ $parent_key_arr = ( isset($parent_key) ) ? $parent_key . '.' . $key : $key ;
+
+ $value[$key] = self::nl2br_h($val , $charset , $noescape_list , $parent_key_arr );
+ }
+ return $value;
+
+
+ } else {
+ if( is_array($noescape_list) ){
+ foreach( $noescape_list as $noescape_value ){
+ $noescape_value = str_replace( ".", '\.' , $noescape_value );
+
+ if( preg_match( "/^(.+\.|)$noescape_value(\..+|)$/", $parent_key ) ){
+ return $value;
+ }
+ }
+ }
+ $value = self::_nl2br_h( $value, $charset );
+ return $value;
+ }
+ }
+
+
+ /**
+ * Execute nl2br() and h() to String Data
+ * @param string $value
+ * @return string
+ */
+ function _nl2br_h( $value, $charset = null ){
+ return nl2br( h( $value, $charset ) );
+ }
+
+}
+?>
* @copyright Copyright 2009, Yasushi Ichikawa. (http://d.hatena.ne.jp/cakephper/)
* @link http://d.hatena.ne.jp/cakephper/
* @package cakeplus
- * @subpackage cakeplus
- * @version 0.03
+ * @subpackage add_validation_rule
+ * @version 0.04
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*
*
*
* 各モデルファイル内のバリデーションの書き方は下記を参考に。
* Example: validation definition in a model.
- * var $validate = array(
- * 'test' => array(
+ * var $validate = array(
+ * 'test' => array(
* "rule2" => array('rule' => array('maxLengthJP', 5),
- * 'message' => '5文字以内です'
- * ),
+ * 'message' => '5文字以内です'
+ * ),
* "rule3" => array('rule' => array('minLengthJP', 2),
- * 'message' => '2文字以上です'
- * ),
+ * 'message' => '2文字以上です'
+ * ),
* "rule4" => array('rule' => array('compare2fields', 'test_conf'),
- * 'message' => '値が違います'
- * ),
- * "rule5" => array('rule' => array('space_only'),
- * 'message' => 'スペース以外も入力してください'
- * ),
- * "rule6" => array('rule' => array('katakana_only'),
+ * 'message' => '値が違います'
+ * ),
+ * "rule5" => array('rule' => array('space_only'),
+ * 'message' => 'スペース以外も入力してください'
+ * ),
+ * "rule6" => array('rule' => array('katakana_only'),
* 'message' => 'カタカナのみ入力してください'
- * ),
- * ),
- * );
+ * ),
+ * "rule7" => array('rule' => array('betweenJP', 5, 10),
+ * 'message' => '5文字以上、10文字以内です'
+ * ),
+ * "rule8" => array('rule' => array('hiragana_only'),
+ * 'message' => 'ひらがなのみ入力してください'
+ * ),
+ * "rule9" => array('rule' => array('zenkaku_only'),
+ * 'message' => '全角文字のみ入力してください'
+ * ),
+ * ),
+ * );
*
* Authコンポーネントでパスワードフィールドがハッシュ化されている場合は、compare2fieldsの第3配列にtrueを指定する
* Using Auth component, If you want compare password and password confirm field,
* set "true" in 3rd parameter of compare2fields validation, password_conf field is encrypted.
- * var $validate = array(
- * 'password' => array(
+ * var $validate = array(
+ * 'password' => array(
* "rule" => array('rule' => array('compare2fields', 'password_conf',true),
- * 'message' => '値が違います'
- * ),
- * ),
- * );
+ * 'message' => '値が違います'
+ * ),
+ * ),
+ * );
*
*
*/
* マルチバイト用バリデーション 文字数上限チェック
* check max length with Multibyte character.
*
- * @param array &$model model object, automatically set
- * @param array $wordvalue field value, automatically set
+ * @param array &$model model object, automatically set
+ * @param array $wordvalue field value, automatically set
* @param int $length max length number
* @return boolean
*/
/**
+ * マルチバイト用のbetweenバリデーション
+ *
+ *
+ * @param array &$model
+ * @param array $wordvalue
+ * @param int $low
+ * @param int $high
+ * @return boolean
+ */
+ function betweenJP(&$model, $wordvalue, $low, $high) {
+ $value = array_shift($wordvalue);
+ if ( mb_strlen($value) >= $low && mb_strlen($value) <= $high ) {
+ return true;
+ } else {
+ return false;
+ }
+ }
+
+
+ /**
* フィールド値の比較
* emailとemail_confフィールドを比較する場合などに利用
* $compare_filedに比較したいフィールド名をセットする(必須)
* 比較するpassword_confフィールドの値をハッシュ化する
* If set "true" in $auth, $compare_filed is encrypted with Security::hash.
*
- * @param array &$model model object, automatically set
- * @param array $wordvalue field value, automatically set
- * @param string $compare_filed set field name for comparison
+ * @param array &$model model object, automatically set
+ * @param array $wordvalue field value, automatically set
+ * @param string $compare_filed set field name for comparison
* @param boolean $auth set true, $compare_filed is encrypted with Security::hash
* @return boolean
*/
}
+ /**
+ * 全角ひらがな以外が含まれていればエラーとするバリデーションチェック
+ * 全角ダッシュ「ー」のみ必要と考えられるので追加
+ * Japanese HIRAGANA Validation
+ * @param array &$model
+ * @param array $wordvalue
+ * @return boolean
+ */
+ function hiragana_only( &$model, $wordvalue){
+
+ $value = array_shift($wordvalue);
+
+ return preg_match("/^[ぁ-んー]*$/u", $value);
+
+ }
+
/**
* 全角カタカナ以外が含まれていればエラーとするバリデーションチェック
*/
function katakana_only( &$model, $wordvalue){
- $value = array_shift($wordvalue);
+ $value = array_shift($wordvalue);
- return preg_match("/^[ァ-ヶー゛゜]*$/u", $value);
+ return preg_match("/^[ァ-ヶー゛゜]*$/u", $value);
}
+ /**
+ * マルチバイト文字以外が含まれていればエラーとするバリデーションチェック
+ * Japanese ZENKAKU Validation
+ *
+ * @param array &$model
+ * @param array $wordvalue
+ * @return boolean
+ */
+ function zenkaku_only( &$model, $wordvalue){
+ $value = array_shift($wordvalue);
+ return !preg_match("/(?:\xEF\xBD[\xA1-\xBF]|\xEF\xBE[\x80-\x9F])|[\x20-\x7E]/", $value);
+ }
+
/**
*/
function space_only( &$model, $wordvalue){
- $value = array_shift($wordvalue);
+ $value = array_shift($wordvalue);
- if( mb_ereg_match("^(\s| )+$", $value) ){
+ if( mb_ereg_match("^(\s| )+$", $value) ){
- return false;
- }else{
- return true;
- }
+ return false;
+ }else{
+ return true;
+ }
}
--- /dev/null
+<?php
+
+App::import('Component', 'Security');
+App::import('Component', 'Auth');
+
+
+/**
+ * Base model that to load AddValidationRule behavior on every test model.
+ *
+ * @package app.tests
+ * @subpackage app.tests.cases.behaviors
+ */
+class AddValidationRuleTestModel extends CakeTestModel
+{
+ /**
+ * Behaviors for this model
+ *
+ * @var array
+ * @access public
+ */
+ var $actsAs = array('cakeplus.AddValidationRule');
+
+
+}
+
+
+/**
+ * Model used in test case.
+ *
+ * @package app.tests
+ * @subpackage app.tests.cases.behaviors
+ */
+class ValidationRule extends AddValidationRuleTestModel
+{
+ /**
+ * Name for this model
+ *
+ * @var string
+ * @access public
+ */
+ var $name = 'ValidationRule';
+ var $useTable = false;
+ var $useDbConfig = "test";
+
+
+ var $validate = array(
+ 'valuediff' => array(
+ "rule1" => array('rule' => array('compare2fields', 'valuediff_conf'),
+ 'message' => '【メールアドレス】 と【メールアドレス(確認)】の内容が異なります'
+ ),
+ ),
+ 'password' => array(
+ "rule1" => array('rule' => array('compare2fields', 'password_conf',true),
+ 'message' => 'パスワード と パスワード(確認)の内容が異なります'
+ ),
+ ),
+
+ 'spaceonly' => array(
+ "rule5" => array('rule' => array('space_only'),
+ 'message' => 'スペース以外も入力してください'
+ ),
+ ),
+ 'alphanumber' => array(
+ "rule7" => array('rule' => array('alpha_number'),
+ 'message' => '英数字のみで入力してください'
+ ),
+ ),
+ 'maxlengthjp' => array(
+ "rule2" => array('rule' => array('maxLengthJP', 10),
+ 'message' => '10文字以内です'
+ ),
+
+ ),
+ 'minlengthjp' => array(
+ "rule3" => array('rule' => array('minLengthJP', 2),
+ 'message' => '2文字以上です'
+ ),
+
+ ),
+ 'katakanaonly' => array(
+ "rule6" => array('rule' => array('katakana_only'),
+ 'message' => 'カタカナのみ入力してください'
+ ),
+ ),
+ 'betweenJP' => array(
+ "rule7" => array('rule' => array('betweenJP', 5, 10),
+ 'message' => '5文字以上10文字以内です'
+ ),
+ ),
+ 'hiragana_only' => array(
+ "rule8" => array('rule' => array('hiragana_only'),
+ 'message' => 'ひらがなのみ入力してください'
+ ),
+ ),
+ 'zenkaku_only' => array(
+ "rule9" => array('rule' => array('zenkaku_only'),
+ 'message' => '全角のみ入力してください'
+ ),
+ ),
+
+
+
+
+ );
+}
+
+
+
+
+
+class AddValidationRuleTestCase extends CakeTestCase
+{
+ /**
+ * @var ValidationRule
+ */
+ var $ValidationRule = null;
+
+ var $fixtures = null;
+
+
+ function startCase() {
+ echo '<h2>Starting Test Case</h2>';
+ $this->ValidationRule =& ClassRegistry::init('ValidationRule');
+ }
+
+ function endCase() {
+ echo '<h2>Ending Test Case</h2>';
+ }
+
+ function startTest($method) {
+ echo '<h3>Starting method '.$method.'</h3>';
+ }
+
+ function endTest($method) {
+ echo '<hr/>';
+ }
+
+
+ //全てバリデーションに引っかかるテスト
+ function testValidataionAllFail(){
+
+ $data = array(
+ 'ValidationRule' => array(
+ 'valuediff' => 'a',
+ 'valuediff_conf' => 's',
+ 'spaceonly' => ' ',
+ 'alphanumber' => 'あ',
+ 'maxlengthjp' => 'あああああああああああ',
+ 'minlengthjp' => 'あ',
+ 'katakanaonly' => 'あ',
+ 'betweenJP' => 'あいうえおかきくけこさしすせそ',
+ 'hiragana_only' => 'カタカナ',
+ 'zenkaku_only' => '090abc',
+
+ ),
+ );
+
+ $this->assertTrue( $this->ValidationRule->create( $data ) );
+
+ $this->assertFalse( $this->ValidationRule->validates() );
+
+ $this->assertTrue( array_key_exists("valuediff" , $this->ValidationRule->validationErrors ) );
+ $this->assertTrue( array_key_exists("spaceonly" , $this->ValidationRule->validationErrors ) );
+ $this->assertTrue( array_key_exists("alphanumber" , $this->ValidationRule->validationErrors ) );
+ $this->assertTrue( array_key_exists("maxlengthjp" , $this->ValidationRule->validationErrors ) );
+ $this->assertTrue( array_key_exists("minlengthjp" , $this->ValidationRule->validationErrors ) );
+ $this->assertTrue( array_key_exists("katakanaonly" , $this->ValidationRule->validationErrors ) );
+ $this->assertTrue( array_key_exists("betweenJP" , $this->ValidationRule->validationErrors ) );
+ $this->assertTrue( array_key_exists("hiragana_only" , $this->ValidationRule->validationErrors ) );
+ $this->assertTrue( array_key_exists("zenkaku_only" , $this->ValidationRule->validationErrors ) );
+
+ }
+
+ //全てバリデーションで成功するテスト
+ function testValidataionAllSuccess(){
+
+ $data = array(
+ 'ValidationRule' => array(
+ 'valuediff' => 'あいうえお',
+ 'valuediff_conf' => 'あいうえお',
+ 'spaceonly' => ' ええ',
+ 'alphanumber' => 'onlyAlpharNumeric123456789',
+ 'maxlengthjp' => '10ああああああああ',
+ 'minlengthjp' => 'あa',
+ 'katakanaonly' => 'カタカナノミァィゥェォー゛゜',
+ 'betweenJP' => 'あいうえおかきくけこ',
+ 'hiragana_only' => 'ひらがな',
+ 'zenkaku_only' => '全角のみです',
+ ),
+ );
+
+ $this->assertTrue( $this->ValidationRule->create( $data ) );
+ $this->assertTrue( $this->ValidationRule->validates() );
+
+
+ $this->assertFalse( array_key_exists("valuediff" , $this->ValidationRule->validationErrors ) );
+ $this->assertFalse( array_key_exists("spaceonly" , $this->ValidationRule->validationErrors ) );
+ $this->assertFalse( array_key_exists("alphanumber" , $this->ValidationRule->validationErrors ) );
+ $this->assertFalse( array_key_exists("maxlengthjp" , $this->ValidationRule->validationErrors ) );
+ $this->assertFalse( array_key_exists("minlengthjp" , $this->ValidationRule->validationErrors ) );
+ $this->assertFalse( array_key_exists("katakanaonly" , $this->ValidationRule->validationErrors ) );
+ $this->assertFalse( array_key_exists("betweenJP" , $this->ValidationRule->validationErrors ) );
+ $this->assertFalse( array_key_exists("hiragana_only" , $this->ValidationRule->validationErrors ) );
+ $this->assertFalse( array_key_exists("zenkaku_only" , $this->ValidationRule->validationErrors ) );
+
+ }
+
+ //spaceonly, alphanum, katakanaonlyフィールドのみバリデーションに引っかかるテスト
+ function testValidataion_spaceonly_alphanum_katakanaonly_Fail(){
+
+ $data = array(
+ 'ValidationRule' => array(
+ 'valuediff' => 'abcdefg 12345',
+ 'valuediff_conf' => 'abcdefg 12345',
+ 'spaceonly' => ' ',
+ 'alphanumber' => 'only AlpharNumeric 123456789',
+ 'maxlengthjp' => '1234567abc',
+ 'minlengthjp' => 'ab',
+ 'katakanaonly' => 'ハンカクカナ',
+
+ ),
+ );
+
+
+ $this->assertTrue( $this->ValidationRule->create( $data ) );
+ $this->assertFalse( $this->ValidationRule->validates() );
+
+
+ $this->assertFalse( array_key_exists("valuediff" , $this->ValidationRule->validationErrors ) );
+ $this->assertTrue( array_key_exists("spaceonly" , $this->ValidationRule->validationErrors ) );
+ $this->assertTrue( array_key_exists("alphanumber" , $this->ValidationRule->validationErrors ) );
+ $this->assertFalse( array_key_exists("maxlengthjp" , $this->ValidationRule->validationErrors ) );
+ $this->assertFalse( array_key_exists("minlengthjp" , $this->ValidationRule->validationErrors ) );
+ $this->assertTrue( array_key_exists("katakanaonly" , $this->ValidationRule->validationErrors ) );
+ }
+
+
+ //Authコンポーネント系テスト
+ function testAuthHash(){
+ //passwordフィールドがハッシュ化されなかった場合はエラー
+ $data = array(
+ 'ValidationRule' => array(
+ 'password' => 'abc123',
+ 'password_conf' => 'abc123',
+ ),
+ );
+ $this->assertTrue( $this->ValidationRule->create( $data ) );
+ $this->assertFalse( $this->ValidationRule->validates() );
+ $this->assertTrue( array_key_exists("password" , $this->ValidationRule->validationErrors ) );
+
+
+ //AuthComponent::passwordを使ってハッシュ化 同一値でバリデーションエラーがないことを確認
+ $data = array(
+ 'ValidationRule' => array(
+ 'password' => AuthComponent::password('abc123cvb'),
+ 'password_conf' => 'abc123cvb',
+ ),
+ );
+ $this->assertTrue( $this->ValidationRule->create( $data ) );
+ $this->assertTrue( $this->ValidationRule->validates() );
+ $this->assertFalse( array_key_exists("password" , $this->ValidationRule->validationErrors ) );
+
+
+ //AuthComponent::passwordを使ってハッシュ化 異なる値でバリデーションエラーに引っかかるテスト
+ $data = array(
+ 'ValidationRule' => array(
+ 'password' => AuthComponent::password('abc123cvb'),
+ 'password_conf' => 'hoge111',
+ ),
+ );
+ $this->assertTrue( $this->ValidationRule->create( $data ) );
+ $this->assertFalse( $this->ValidationRule->validates() );
+ $this->assertTrue( array_key_exists("password" , $this->ValidationRule->validationErrors ) );
+ }
+
+ //betweenJP テスト
+ function testValidataionBetweenJP(){
+
+ $setFailData = array('ああ','abあい', 'aabbccddええおお' );
+ $setSuccessData = array('abcde', 'aabbccddええ', '1122334');
+
+ $field = 'betweenJP';
+
+ //失敗パターン
+ $data = array();
+ foreach($setFailData as $key => $value){
+ $data['ValidationRule'][$field] = $value;
+ $this->assertTrue( $this->ValidationRule->create( $data ) );
+ $this->assertFalse( $this->ValidationRule->validates() );
+ $this->assertTrue( array_key_exists($field , $this->ValidationRule->validationErrors ) );
+ }
+
+ //成功パターン
+ $data = array();
+ foreach($setSuccessData as $key => $value){
+ $data['ValidationRule'][$field] = $value;
+ $this->assertTrue( $this->ValidationRule->create( $data ) );
+ $this->assertTrue( $this->ValidationRule->validates() );
+ $this->assertFalse( array_key_exists($field , $this->ValidationRule->validationErrors ) );
+ }
+ }
+
+ //hiragana_only テスト
+ function testValidataionHiraganaOnly(){
+
+ $setFailData = array('あカナ','abあい', '0011ええおお','漢字も' );
+ $setSuccessData = array('がぎぁ', 'たーいへーいよー', 'にゃぴょにょ');
+
+ $field = 'hiragana_only';
+
+ //失敗パターン
+ $data = array();
+ foreach($setFailData as $key => $value){
+ $data['ValidationRule'][$field] = $value;
+ $this->assertTrue( $this->ValidationRule->create( $data ) );
+ $this->assertFalse( $this->ValidationRule->validates() );
+ $this->assertTrue( array_key_exists($field , $this->ValidationRule->validationErrors ) );
+ }
+
+ //成功パターン
+ $data = array();
+ foreach($setSuccessData as $key => $value){
+ $data['ValidationRule'][$field] = $value;
+ $this->assertTrue( $this->ValidationRule->create( $data ) );
+ $this->assertTrue( $this->ValidationRule->validates() );
+ $this->assertFalse( array_key_exists($field , $this->ValidationRule->validationErrors ) );
+ }
+ }
+
+
+ //zenkaku_only テスト
+ function testValidataionZenkakuOnly(){
+
+ $setFailData = array('*カナ','abあい', '0011ええおお','漢字も!' );
+ $setSuccessData = array('漢字も', 'カタカナも', '今日はグッド!!');
+
+ $field = 'zenkaku_only';
+
+ //失敗パターン
+ $data = array();
+ foreach($setFailData as $key => $value){
+ $data['ValidationRule'][$field] = $value;
+ $this->assertTrue( $this->ValidationRule->create( $data ) );
+ $this->assertFalse( $this->ValidationRule->validates() );
+ $this->assertTrue( array_key_exists($field , $this->ValidationRule->validationErrors ) );
+ }
+
+ //成功パターン
+ $data = array();
+ foreach($setSuccessData as $key => $value){
+ $data['ValidationRule'][$field] = $value;
+ $this->assertTrue( $this->ValidationRule->create( $data ) );
+ $this->assertTrue( $this->ValidationRule->validates() );
+ $this->assertFalse( array_key_exists($field , $this->ValidationRule->validationErrors ) );
+ }
+ }
+
+
+
+}
+
+?>
--- /dev/null
+<?php
+
+App::import('Core', array('ClassRegistry', 'Controller', 'View'));
+App::import('Helper', 'Html');
+App::import('Helper', 'Form');
+App::import('Helper', 'Cakeplus.Formhidden');
+
+class ContactTestController extends Controller {
+/**
+ * name property
+ *
+ * @var string 'ContactTest'
+ * @access public
+ */
+ var $name = 'ContactTest';
+/**
+ * uses property
+ *
+ * @var mixed null
+ * @access public
+ */
+ var $uses = null;
+
+}
+
+
+class FormhiddenHelperTest extends CakeTestCase {
+
+ function setUp(){
+ $this->Formhidden =& new FormhiddenHelper();
+ $this->Formhidden->Form =& new FormHelper();
+ $this->Formhidden->Form->Html =& new HtmlHelper();
+
+ $this->Controller =& new ContactTestController();
+ $this->View =& new View($this->Controller);
+
+ }
+
+ function tearDown() {
+ ClassRegistry::removeObject('view');
+ unset($this->Formhidden, $this->Controller, $this->View);
+ }
+
+ function startCase() {
+ echo '<h2>Starting Test Case</h2>';
+
+ }
+
+ function endCase() {
+ echo '<h2>Ending Test Case</h2>';
+ }
+
+ function startTest($method) {
+ echo '<h3>Starting method '.$method.'</h3>';
+ }
+
+ function endTest($method) {
+ echo '<hr/>';
+ }
+
+
+ //test for using parameter
+ function test_basic_hidden_param_data(){
+ $data = array( 'Contact' => array(
+ 'id' => '1',
+ 'text' => 'aaaa',
+ 'body' => 'あいうえおテスト日本語1234abcd',
+ )
+ );
+
+ $expected = array(
+ array( 'input' => array('type' => 'hidden', 'name' => 'data[Contact][id]', 'value' => '1', 'id' => 'ContactId'), ),
+ array( 'input' => array('type' => 'hidden', 'name' => 'data[Contact][text]', 'value' => 'aaaa', 'id' => 'ContactText'), ),
+ array( 'input' => array('type' => 'hidden', 'name' => 'data[Contact][body]', 'value' => 'あいうえおテスト日本語1234abcd', 'id' => 'ContactBody'), ),
+ );
+
+ //check not using.
+ $this->Formhidden->data = array( 'Hoge' => array( 'id' => '199', 'hoge' => 'eeeee' ) );
+
+ // for using Form->hidden() method which uses $this->data to create hidden tag.
+ $this->Formhidden->Form->data = $data;
+
+ $result = $this->Formhidden->hiddenVars($data);
+
+ $this->assertTags($result, $expected);
+ }
+
+
+ //test for using $this->data
+ function test_basic_hidden_this_data(){
+ $data = array( 'Contact' => array(
+ 'id' => '1',
+ 'text' => 'aaaa',
+ 'body' => 'あいうえおテスト日本語1234abcd',
+ )
+ );
+
+ $expected = array(
+ array( 'input' => array('type' => 'hidden', 'name' => 'data[Contact][id]', 'value' => '1', 'id' => 'ContactId'), ),
+ array( 'input' => array('type' => 'hidden', 'name' => 'data[Contact][text]', 'value' => 'aaaa', 'id' => 'ContactText'), ),
+ array( 'input' => array('type' => 'hidden', 'name' => 'data[Contact][body]', 'value' => 'あいうえおテスト日本語1234abcd', 'id' => 'ContactBody'), ),
+ );
+
+ $this->Formhidden->data = $data;
+ $this->Formhidden->Form->data = $data;
+
+ $result = $this->Formhidden->hiddenVars();
+
+ $this->assertTags($result, $expected);
+ }
+
+
+ //test for no data
+ function test_basic_hidden_null(){
+ $data = array();
+
+ $this->Formhidden->data = $data;
+ $this->Formhidden->Form->data = $data;
+
+ $result = $this->Formhidden->hiddenVars();
+ $this->assertNull($result);
+
+ $result = $this->Formhidden->hiddenVars($data);
+ $this->assertNull($result);
+ }
+}
+
+
+?>
\ No newline at end of file
--- /dev/null
+<?php
+
+
+/**
+ * Formhidden Helper: create html hidden tags.
+ *
+ * Licensed under The MIT License
+ * Redistributions of files must retain the above copyright notice.
+ *
+ * @copyright Copyright 2009, Yasushi Ichikawa. (http://d.hatena.ne.jp/cakephper/)
+ * @link http://d.hatena.ne.jp/cakephper/
+ * @package cakeplus
+ * @subpackage cakeplus
+ * @version 0.02
+ * @license MIT License (http://www.opensource.org/licenses/mit-license.php)
+ *
+ *
+ * =====Usage=====
+ * //in controller
+ * var $helpers = array('Cakeplus.Formhidden');
+ *
+ * //in view(ctp file) for using $this->data
+ * <?php echo $formhidden->hiddenVars(); ?>
+ *
+ * //in view(ctp file) for using $data_arr parameter
+ * <?php echo $formhidden->hiddenVars($data_arr); ?>
+ *
+ * ===============
+ *
+ */
+class FormhiddenHelper extends Helper {
+ var $helpers = array('Form');
+
+ // String data of Hidden tags.
+ var $hidden_output = null;
+
+
+ /**
+ * construct html hidden tag
+ *
+ * @param array $data_arr //if not set, using $this->data
+ * @return String
+ */
+ function hiddenVars( $data_arr = null ) {
+
+ if( empty($this->data) && empty($data_arr) ){ return; }
+
+ if( !is_array($data_arr) || empty($data_arr) ){
+ $data_arr = $this->data;
+ }
+
+ $this->_createHidden( $data_arr );
+
+ return $this->hidden_output;
+ }
+
+
+ function _createHidden( $data, $parent_key = null ){
+ if( is_array( $data ) ){
+
+ foreach( $data as $key => $val ){
+ $parent_key_arr = ( isset($parent_key) ) ? $parent_key . '.' . $key : $key ;
+ self::_createHidden( $val, $parent_key_arr );
+ }
+
+ }else{
+ $this->hidden_output .= $this->Form->hidden( $parent_key )."\n";
+
+ }
+
+ }
+
+
+}
+
+?>
-<div class="members view">
-<h2><?php echo $member['Member']['nickname']; ?><?php __("'s ");?><?php __('Home');?></h2>
+<div class="users view">
+<h2><?php echo $user['User']['name']; ?><?php __("'s ");?><?php __('Home');?></h2>
<dl><?php $i = 0; $class = ' class="altrow"';?>
- <dt<?php if ($i % 2 == 0) echo $class;?>><?php __('Nickname'); ?></dt>
+ <dt<?php if ($i % 2 == 0) echo $class;?>><?php __('Name'); ?></dt>
<dd<?php if ($i++ % 2 == 0) echo $class;?>>
- <?php echo $member['Member']['nickname']; ?>
+ <?php echo $user['User']['name']; ?>
</dd>
<dt<?php if ($i % 2 == 0) echo $class;?>><?php __('Created'); ?></dt>
<dd<?php if ($i++ % 2 == 0) echo $class;?>>
- <?php echo $member['Member']['created']; ?>
+ <?php echo $user['User']['created']; ?>
</dd>
<dt<?php if ($i % 2 == 0) echo $class;?>><?php __('Modified'); ?></dt>
<dd<?php if ($i++ % 2 == 0) echo $class;?>>
- <?php echo $member['Member']['modified']; ?>
+ <?php echo $user['User']['modified']; ?>
</dd>
</dl>
<div class="actions">
<ul>
<?php if ($owner): ?>
- <li><?php echo $html->link(__('Edit Member', true), array('action' => 'edit', $member['Member']['id'])); ?> </li>
- <li><?php echo $html->link(__('Delete Member', true), array('action' => 'delete', $member['Member']['id']), null, __('Are you sure you want to delete?', true)); ?> </li>
+ <li><?php echo $html->link(__('Edit User', true), array('action' => 'edit', $user['User']['id'])); ?> </li>
+ <li><?php echo $html->link(__('Change Password', true), array('action' => 'change_password', $user['User']['id'])); ?> </li>
+ <li><?php echo $html->link(__('Delete User', true), array('action' => 'delete', $user['User']['id'])); ?> </li>
<?php endif; ?>
- <li><?php echo $html->link(__('List Members', true), array('action' => 'listview')); ?> </li>
+ <li><?php echo $html->link(__('List users', true), array('action' => 'listview')); ?> </li>
</ul>
</div>
-<div class="members view">
-<h2><?php __('Member');?></h2>
+<div class="users view">
+<h2><?php __('User');?></h2>
<dl><?php $i = 0; $class = ' class="altrow"';?>
<dt<?php if ($i % 2 == 0) echo $class;?>><?php __('Id'); ?></dt>
<dd<?php if ($i++ % 2 == 0) echo $class;?>>
-<?php echo $member['Member']['id']; ?>
+<?php echo $user['User']['id']; ?>
</dd>
-<dt<?php if ($i % 2 == 0) echo $class;?>><?php __('Nickname'); ?></dt>
+<dt<?php if ($i % 2 == 0) echo $class;?>><?php __('Name'); ?></dt>
<dd<?php if ($i++ % 2 == 0) echo $class;?>>
-<?php echo $member['Member']['nickname']; ?>
+<?php echo $user['User']['name']; ?>
</dd>
<dt<?php if ($i % 2 == 0) echo $class;?>><?php __('Created'); ?></dt>
<dd<?php if ($i++ % 2 == 0) echo $class;?>>
-<?php echo $member['Member']['created']; ?>
+<?php echo $user['User']['created']; ?>
</dd>
<dt<?php if ($i % 2 == 0) echo $class;?>><?php __('Modified'); ?></dt>
<dd<?php if ($i++ % 2 == 0) echo $class;?>>
-<?php echo $member['Member']['modified']; ?>
+<?php echo $user['User']['modified']; ?>
</dd>
</dl>
<div class="actions">
<ul>
<?php if ($owner): ?>
-<li><?php echo $html->link(__('Edit Member', true), array('action' => 'mobile_edit', $member['Member']['id'])); ?> </li>
-<li><?php echo $html->link(__('Delete Member', true), array('action' => 'mobile_delete', $member['Member']['id']), null, __('Are you sure you want to delete?', true)); ?> </li>
+<li><?php echo $html->link(__('Edit User', true), array('action' => 'mobile_edit', $user['User']['id'])); ?> </li>
+<li><?php echo $html->link(__('Change Password', true), array('action' => 'mobile_change_password', $user['User']['id'])); ?> </li>
+<li><?php echo $html->link(__('Delete User', true), array('action' => 'mobile_delete', $user['User']['id'])); ?> </li>
<?php endif; ?>
-<li><?php echo $html->link(__('List Members', true), array('action' => 'mobile_listview')); ?> </li>
+<li><?php echo $html->link(__('List users', true), array('action' => 'mobile_listview')); ?> </li>
</ul>
</div>
--- /dev/null
+<div class="groups form">
+<?php echo $form->create('Group');?>
+ <fieldset>
+ <legend><?php __('Add Group');?></legend>
+ <?php
+ echo $form->input('name');
+ echo $form->input('parent_id');
+ ?>
+ </fieldset>
+<?php echo $form->end('Submit');?>
+</div>
+<div class="actions">
+ <ul>
+ <li><?php echo $html->link(__('List Groups', true), array('action' => 'index'));?></li>
+ </ul>
+</div>
--- /dev/null
+<div class="groups form">
+<?php echo $form->create('Group');?>
+ <fieldset>
+ <legend><?php __('Edit Group');?></legend>
+ <?php
+ echo $form->input('id');
+ echo $form->input('name');
+ echo $form->input('parent_id');
+ ?>
+ </fieldset>
+<?php echo $form->end('Submit');?>
+</div>
+<div class="actions">
+ <ul>
+ <li><?php echo $html->link(__('Delete', true), array('action' => 'delete', $form->value('Group.id')), null, sprintf(__('Are you sure you want to delete # %s?', true), $form->value('Group.id'))); ?></li>
+ <li><?php echo $html->link(__('List Groups', true), array('action' => 'index'));?></li>
+ </ul>
+</div>
-<div class="members list">
-<h2><?php __('Members');?> <?php __('List');?></h2>
+<div class="groups index">
+<h2><?php __('Groups');?></h2>
<p>
<?php
echo $paginator->counter(array(
<table cellpadding="0" cellspacing="0">
<tr>
<th><?php echo $paginator->sort('id');?></th>
- <th><?php echo $paginator->sort('nickname');?></th>
- <th><?php echo $paginator->sort('created');?></th>
- <th><?php echo $paginator->sort('modified');?></th>
+ <th><?php echo $paginator->sort('name');?></th>
+ <th><?php echo $paginator->sort('parent_id');?></th>
<th class="actions"><?php __('Actions');?></th>
</tr>
<?php
$i = 0;
-foreach ($members as $member):
+foreach ($groups as $group):
$class = null;
if ($i++ % 2 == 0) {
$class = ' class="altrow"';
?>
<tr<?php echo $class;?>>
<td>
- <?php echo $member['Member']['id']; ?>
+ <?php echo $group['Group']['id']; ?>
</td>
<td>
- <?php echo $member['Member']['nickname']; ?>
+ <?php echo $group['Group']['name']; ?>
</td>
<td>
- <?php echo $member['Member']['created']; ?>
- </td>
- <td>
- <?php echo $member['Member']['modified']; ?>
+ <?php echo $group['Group']['parent_id']; ?>
</td>
<td class="actions">
- <?php echo $html->link(__('View', true), array('action' => 'view', $member['Member']['id'])); ?>
+ <?php echo $html->link(__('View', true), array('action' => 'view', $group['Group']['id'])); ?>
+ <?php echo $html->link(__('Edit', true), array('action' => 'edit', $group['Group']['id'])); ?>
+ <?php echo $html->link(__('Delete', true), array('action' => 'delete', $group['Group']['id']), null, sprintf(__('Are you sure you want to delete # %s?', true), $group['Group']['id'])); ?>
</td>
</tr>
<?php endforeach; ?>
</div>
<div class="actions">
<ul>
- <li><?php echo $html->link(__('New Member', true), array('action' => 'add')); ?></li>
+ <li><?php echo $html->link(__('New Group', true), array('action' => 'add')); ?></li>
</ul>
</div>
--- /dev/null
+<div class="groups view">
+<h2><?php __('Group');?></h2>
+ <dl><?php $i = 0; $class = ' class="altrow"';?>
+ <dt<?php if ($i % 2 == 0) echo $class;?>><?php __('Id'); ?></dt>
+ <dd<?php if ($i++ % 2 == 0) echo $class;?>>
+ <?php echo $group['Group']['id']; ?>
+
+ </dd>
+ <dt<?php if ($i % 2 == 0) echo $class;?>><?php __('Name'); ?></dt>
+ <dd<?php if ($i++ % 2 == 0) echo $class;?>>
+ <?php echo $group['Group']['name']; ?>
+
+ </dd>
+ <dt<?php if ($i % 2 == 0) echo $class;?>><?php __('Parent Id'); ?></dt>
+ <dd<?php if ($i++ % 2 == 0) echo $class;?>>
+ <?php echo $group['Group']['parent_id']; ?>
+
+ </dd>
+ </dl>
+</div>
+<div class="actions">
+ <ul>
+ <li><?php echo $html->link(__('Edit Group', true), array('action' => 'edit', $group['Group']['id'])); ?> </li>
+ <li><?php echo $html->link(__('Delete Group', true), array('action' => 'delete', $group['Group']['id']), null, sprintf(__('Are you sure you want to delete # %s?', true), $group['Group']['id'])); ?> </li>
+ <li><?php echo $html->link(__('List Groups', true), array('action' => 'index')); ?> </li>
+ <li><?php echo $html->link(__('New Group', true), array('action' => 'add')); ?> </li>
+ </ul>
+</div>
--- /dev/null
+<?php
+/**
+ * CSRF対策用Token出力ヘルパー
+ * 要Formヘルパー
+ */
+
+class TokenHelper extends AppHelper {
+/**
+ * Other helpers used by TokenHelper
+ *
+ * @var array
+ * @access public
+ */
+ var $helpers = array('Form', 'Session');
+
+ /* Tokenをセットしたhiddenタグ出力 */
+ function create($tag_name = '__Token', $hash_type = 'md5')
+ {
+ $hashed_id = $this-> get_hashed_session_id($hash_type);
+
+ return $this->Form->input($tag_name, array(
+ 'type' => 'hidden',
+ 'value' => $hashed_id,
+ )
+ );
+ }
+
+ /* 現在のセッションIDを暗号化して取得 */
+ function get_hashed_session_id($hash_type = 'md5')
+ {
+ $session_id = $this->Session->id();
+
+ return Security::hash($session_id. Configure::read('Security.salt'), $hash_type);
+ }
+
+}
+
+
<body>
<div id="container">
<div id="header">
+ <?php if ($isAdministrator): ?>
+ <ul>
+ <li>
+ <?php if (!$admin): ?>
+ <?php echo $html->link(__('Administration', true), '/admin/users/index'); ?>
+ <?php else: ?>
+ <?php echo $html->link(__('Members', true), '/users/index'); ?>
+ <?php endif; ?>
+ </li>
+ </ul>
+ <?php endif; ?>
+ <?php if ($uid): ?>
+ <ul>
+ <li><?php echo $html->link(__('Home', true), '/users/index'); ?>
+ <li><?php echo $html->link(__('Logout', true), '/users/logout'); ?>
+</li>
+ </ul>
+ <?php endif; ?>
</div>
<div id="content">
<?php $session->flash(); ?>
+ <?php if ($session->check('Message.auth')): ?>
+ <div><?php $session->flash('auth'); ?></div>
+ <?php endif; ?>
<?php echo $content_for_layout; ?>
</div>
<div id="footer">
<?php if ($session->flash()): ?>
<div><?php $session->flash(); ?></div>
<?php endif; ?>
+<?php if ($session->check('Message.auth')): ?>
+<div><?php $session->flash('auth'); ?></div>
+<?php endif; ?>
<?php echo $content_for_layout; ?>
<div id="footer"></div>
<?php echo $cakeDebug; ?>
+++ /dev/null
-<div class="members form">
-<?php echo $form->create('Member');?>
- <fieldset>
- <legend><?php __('Add Member');?></legend>
- <?php
- echo $form->input('username');
- echo $form->input('password');
- echo $form->input('nickname');
- echo $form->input('uid');
- echo $form->input('career');
- echo $form->input('useragent');
- ?>
- </fieldset>
-<?php echo $form->end('Submit');?>
-</div>
-<div class="actions">
- <ul>
- <li><?php echo $html->link(__('List Members', true), array('action' => 'index'));?></li>
- </ul>
-</div>
+++ /dev/null
-<div class="members form">
-<?php echo $form->create('Member');?>
- <fieldset>
- <legend><?php __('Add Member');?></legend>
- <?php
- echo $form->input('username');
- echo $form->input('password');
- echo $form->input('nickname');
- echo $form->input('uid');
- echo $form->input('career');
- echo $form->input('useragent');
- ?>
- </fieldset>
-<?php echo $form->end('Submit');?>
-</div>
-<div class="actions">
- <ul>
- <li><?php echo $html->link(__('List Members', true), array('action' => 'index'));?></li>
- </ul>
-</div>
+++ /dev/null
-<div class="members form">
-<?php echo $form->create('Member');?>
- <fieldset>
- <legend><?php __('Edit Member');?></legend>
- <?php
- echo $form->input('id');
- echo $form->input('username');
- echo $form->input('password');
- echo $form->input('nickname');
- echo $form->input('uid');
- echo $form->input('career');
- echo $form->input('useragent');
- ?>
- </fieldset>
-<?php echo $form->end('Submit');?>
-</div>
-<div class="actions">
- <ul>
- <li><?php echo $html->link(__('Delete', true), array('action' => 'delete', $form->value('Member.id')), null, sprintf(__('Are you sure you want to delete # %s?', true), $form->value('Member.id'))); ?></li>
- <li><?php echo $html->link(__('List Members', true), array('action' => 'index'));?></li>
- </ul>
-</div>
+++ /dev/null
-<div class="members index">
-<h2><?php __('Members');?></h2>
-<p>
-<?php
-echo $paginator->counter(array(
-'format' => __('Page %page% of %pages%, showing %current% records out of %count% total, starting on record %start%, ending on %end%', true)
-));
-?></p>
-<table cellpadding="0" cellspacing="0">
-<tr>
- <th><?php echo $paginator->sort('id');?></th>
- <th><?php echo $paginator->sort('nickname');?></th>
- <th><?php echo $paginator->sort('username');?></th>
- <th><?php echo $paginator->sort('uid');?></th>
- <th><?php echo $paginator->sort('career');?></th>
- <th><?php echo $paginator->sort('useragent');?></th>
- <th><?php echo $paginator->sort('created');?></th>
- <th><?php echo $paginator->sort('modified');?></th>
- <th class="actions"><?php __('Actions');?></th>
-</tr>
-<?php
-$i = 0;
-foreach ($members as $member):
- $class = null;
- if ($i++ % 2 == 0) {
- $class = ' class="altrow"';
- }
-?>
- <tr<?php echo $class;?>>
- <td>
- <?php echo $member['Member']['id']; ?>
- </td>
- <td>
- <?php echo $member['Member']['nickname']; ?>
- </td>
- <td>
- <?php echo $member['Member']['username']; ?>
- </td>
- <td>
- <?php if($member['Member']['uid']): ?>
- <?php __('Registered');?>
- <?php endif; ?>
- </td>
- <td>
- <?php echo $member['Member']['career']; ?>
- </td>
- <td>
- <?php echo $member['Member']['useragent']; ?>
- </td>
- <td>
- <?php echo $member['Member']['created']; ?>
- </td>
- <td>
- <?php echo $member['Member']['modified']; ?>
- </td>
- <td class="actions">
- <?php echo $html->link(__('View', true), array('action' => 'view', $member['Member']['id'])); ?>
- <?php echo $html->link(__('Edit', true), array('action' => 'edit', $member['Member']['id'])); ?>
- <?php echo $html->link(__('Delete', true), array('action' => 'delete', $member['Member']['id']), null, sprintf(__('Are you sure you want to delete # %s?', true), $member['Member']['id'])); ?>
- </td>
- </tr>
-<?php endforeach; ?>
-</table>
-</div>
-<div class="paging">
- <?php echo $paginator->prev('<< '.__('previous', true), array(), null, array('class'=>'disabled'));?>
- | <?php echo $paginator->numbers();?>
- <?php echo $paginator->next(__('next', true).' >>', array(), null, array('class' => 'disabled'));?>
-</div>
-<div class="actions">
- <ul>
- <li><?php echo $html->link(__('New Member', true), array('action' => 'add')); ?></li>
- </ul>
-</div>
+++ /dev/null
-<div class="members view">
-<h2><?php __('Member');?></h2>
- <dl><?php $i = 0; $class = ' class="altrow"';?>
- <dt<?php if ($i % 2 == 0) echo $class;?>><?php __('Id'); ?></dt>
- <dd<?php if ($i++ % 2 == 0) echo $class;?>>
- <?php echo $member['Member']['id']; ?>
-
- </dd>
- <dt<?php if ($i % 2 == 0) echo $class;?>><?php __('Nickname'); ?></dt>
- <dd<?php if ($i++ % 2 == 0) echo $class;?>>
- <?php echo $member['Member']['nickname']; ?>
-
- </dd>
- <dt<?php if ($i % 2 == 0) echo $class;?>><?php __('Username'); ?></dt>
- <dd<?php if ($i++ % 2 == 0) echo $class;?>>
- <?php echo $member['Member']['username']; ?>
-
- </dd>
- <dt<?php if ($i % 2 == 0) echo $class;?>><?php __('Uid'); ?></dt>
- <dd<?php if ($i++ % 2 == 0) echo $class;?>>
- <?php if($member['Member']['uid']): ?>
- <?php __('Registered');?>
- <?php endif; ?>
-
- </dd>
- <dt<?php if ($i % 2 == 0) echo $class;?>><?php __('Career'); ?></dt>
- <dd<?php if ($i++ % 2 == 0) echo $class;?>>
- <?php echo $member['Member']['career']; ?>
-
- </dd>
- <dt<?php if ($i % 2 == 0) echo $class;?>><?php __('Useragent'); ?></dt>
- <dd<?php if ($i++ % 2 == 0) echo $class;?>>
- <?php echo $member['Member']['useragent']; ?>
-
- </dd>
- <dt<?php if ($i % 2 == 0) echo $class;?>><?php __('Created'); ?></dt>
- <dd<?php if ($i++ % 2 == 0) echo $class;?>>
- <?php echo $member['Member']['created']; ?>
-
- </dd>
- <dt<?php if ($i % 2 == 0) echo $class;?>><?php __('Modified'); ?></dt>
- <dd<?php if ($i++ % 2 == 0) echo $class;?>>
- <?php echo $member['Member']['modified']; ?>
-
- </dd>
- </dl>
-</div>
-<div class="actions">
- <ul>
- <li><?php echo $html->link(__('Edit Member', true), array('action' => 'edit', $member['Member']['id'])); ?> </li>
- <li><?php echo $html->link(__('Delete Member', true), array('action' => 'delete', $member['Member']['id']), null, sprintf(__('Are you sure you want to delete # %s?', true), $member['Member']['id'])); ?> </li>
- <li><?php echo $html->link(__('List Members', true), array('action' => 'index')); ?> </li>
- <li><?php echo $html->link(__('New Member', true), array('action' => 'add')); ?> </li>
- </ul>
-</div>
+++ /dev/null
-<div class="members form">
-<?php echo $form->create('Member');?>
- <fieldset>
- <legend><?php __('Edit Member');?></legend>
- <?php
- echo $form->input('id');
- echo $form->input('username');
- echo $form->input('password');
- echo $form->input('nickname');
- echo $form->input('uid');
- echo $form->input('career');
- echo $form->input('useragent');
- ?>
- </fieldset>
-<?php echo $form->end('Submit');?>
-</div>
-<div class="actions">
- <ul>
- <li><?php echo $html->link(__('Delete', true), array('action' => 'delete', $form->value('Member.id')), null, sprintf(__('Are you sure you want to delete # %s?', true), $form->value('Member.id'))); ?></li>
- <li><?php echo $html->link(__('List Members', true), array('action' => 'index'));?></li>
- </ul>
-</div>
+++ /dev/null
-<?php
-if ($session->check('Message.auth')) {
- $session->flash('auth');
-}
-
-echo $form->create('Member', array('action' => 'login'));
-echo $form->input('username');
-echo $form->input('password');
-echo $form->end('Login');
-
-
+++ /dev/null
-<div class="members form">
-<?php echo $form->create('Member');?>
- <fieldset>
- <legend><?php __('Add Member');?></legend>
- <?php
- echo $form->input('username');
- echo $form->input('password');
- echo $form->input('nickname');
- echo $form->input('uid');
- echo $form->input('career');
- echo $form->input('useragent');
- ?>
- </fieldset>
-<?php echo $form->end('Submit');?>
-</div>
-<div class="actions">
- <ul>
- <li><?php echo $html->link(__('List Members', true), array('action' => 'mobile_index'));?></li>
- </ul>
-</div>
+++ /dev/null
-<div class="members form">
-<?php echo $form->create('Member');?>
- <fieldset>
- <legend><?php __('Edit Member');?></legend>
- <?php
- echo $form->input('id');
- echo $form->input('username');
- echo $form->input('password');
- echo $form->input('nickname');
- echo $form->input('uid');
- echo $form->input('career');
- echo $form->input('useragent');
- ?>
- </fieldset>
-<?php echo $form->end('Submit');?>
-</div>
-<div class="actions">
- <ul>
- <li><?php echo $html->link(__('Delete', true), array('action' => 'mobile_delete', $form->value('Member.id')), null, sprintf(__('Are you sure you want to delete # %s?', true), $form->value('Member.id'))); ?></li>
- <li><?php echo $html->link(__('List Members', true), array('action' => 'mobile_index'));?></li>
- </ul>
-</div>
+++ /dev/null
-<?php
-if ($session->check('Message.auth')) {
- $session->flash('auth');
-}
-
-echo $form->create('Member', array('action' => 'mobile_login'));
-echo $form->input('username');
-echo $form->input('password');
-echo $form->end('Login');
-
-
+++ /dev/null
-<div class="notes form">
-<?php echo $form->create('Note');?>
- <fieldset>
- <legend><?php __('Add Note');?></legend>
- <?php
- echo $form->input('member_id');
- echo $form->input('lat');
- echo $form->input('lon');
- echo $form->input('title');
- echo $form->input('body');
- echo $form->input('public_flag');
- ?>
- </fieldset>
-<?php echo $form->end('Submit');?>
-</div>
-<div class="actions">
- <ul>
- <li><?php echo $html->link(__('List Notes', true), array('action' => 'index'));?></li>
- <li><?php echo $html->link(__('List Members', true), array('controller' => 'members', 'action' => 'index')); ?> </li>
- <li><?php echo $html->link(__('New Member', true), array('controller' => 'members', 'action' => 'add')); ?> </li>
- </ul>
-</div>
+++ /dev/null
-<div class="notes form">
-<?php echo $form->create('Note');?>
- <fieldset>
- <legend><?php __('Add Note');?></legend>
- <?php
- echo $form->input('member_id');
- echo $form->input('lat');
- echo $form->input('lon');
- echo $form->input('title');
- echo $form->input('body');
- echo $form->input('public_flag');
- ?>
- </fieldset>
-<?php echo $form->end('Submit');?>
-</div>
-<div class="actions">
- <ul>
- <li><?php echo $html->link(__('List Notes', true), array('action' => 'index'));?></li>
- <li><?php echo $html->link(__('List Members', true), array('controller' => 'members', 'action' => 'index')); ?> </li>
- <li><?php echo $html->link(__('New Member', true), array('controller' => 'members', 'action' => 'add')); ?> </li>
- </ul>
-</div>
+++ /dev/null
-<div class="notes form">
-<?php echo $form->create('Note');?>
- <fieldset>
- <legend><?php __('Edit Note');?></legend>
- <?php
- echo $form->input('id');
- echo $form->input('member_id');
- echo $form->input('lat');
- echo $form->input('lon');
- echo $form->input('title');
- echo $form->input('body');
- echo $form->input('public_flag');
- ?>
- </fieldset>
-<?php echo $form->end('Submit');?>
-</div>
-<div class="actions">
- <ul>
- <li><?php echo $html->link(__('Delete', true), array('action' => 'delete', $form->value('Note.id')), null, sprintf(__('Are you sure you want to delete # %s?', true), $form->value('Note.id'))); ?></li>
- <li><?php echo $html->link(__('List Notes', true), array('action' => 'index'));?></li>
- <li><?php echo $html->link(__('List Members', true), array('controller' => 'members', 'action' => 'index')); ?> </li>
- <li><?php echo $html->link(__('New Member', true), array('controller' => 'members', 'action' => 'add')); ?> </li>
- </ul>
-</div>
+++ /dev/null
-<div class="notes index">
-<h2><?php __('Notes');?></h2>
-<p>
-<?php
-echo $paginator->counter(array(
-'format' => __('Page %page% of %pages%, showing %current% records out of %count% total, starting on record %start%, ending on %end%', true)
-));
-?></p>
-<table cellpadding="0" cellspacing="0">
-<tr>
- <th><?php echo $paginator->sort('id');?></th>
- <th><?php echo $paginator->sort('member_id');?></th>
- <th><?php echo $paginator->sort('lat');?></th>
- <th><?php echo $paginator->sort('lon');?></th>
- <th><?php echo $paginator->sort('title');?></th>
- <th><?php echo $paginator->sort('body');?></th>
- <th><?php echo $paginator->sort('public_flag');?></th>
- <th><?php echo $paginator->sort('created');?></th>
- <th><?php echo $paginator->sort('modified');?></th>
- <th class="actions"><?php __('Actions');?></th>
-</tr>
-<?php
-$i = 0;
-foreach ($notes as $note):
- $class = null;
- if ($i++ % 2 == 0) {
- $class = ' class="altrow"';
- }
-?>
- <tr<?php echo $class;?>>
- <td>
- <?php echo $note['Note']['id']; ?>
- </td>
- <td>
- <?php echo $html->link($note['Member']['id'], array('controller' => 'members', 'action' => 'view', $note['Member']['id'])); ?>
- </td>
- <td>
- <?php echo $note['Note']['lat']; ?>
- </td>
- <td>
- <?php echo $note['Note']['lon']; ?>
- </td>
- <td>
- <?php echo $note['Note']['title']; ?>
- </td>
- <td>
- <?php echo $note['Note']['body']; ?>
- </td>
- <td>
- <?php echo $note['Note']['public_flag']; ?>
- </td>
- <td>
- <?php echo $note['Note']['created']; ?>
- </td>
- <td>
- <?php echo $note['Note']['modified']; ?>
- </td>
- <td class="actions">
- <?php echo $html->link(__('View', true), array('action' => 'view', $note['Note']['id'])); ?>
- <?php echo $html->link(__('Edit', true), array('action' => 'edit', $note['Note']['id'])); ?>
- <?php echo $html->link(__('Delete', true), array('action' => 'delete', $note['Note']['id']), null, sprintf(__('Are you sure you want to delete # %s?', true), $note['Note']['id'])); ?>
- </td>
- </tr>
-<?php endforeach; ?>
-</table>
-</div>
-<div class="paging">
- <?php echo $paginator->prev('<< '.__('previous', true), array(), null, array('class'=>'disabled'));?>
- | <?php echo $paginator->numbers();?>
- <?php echo $paginator->next(__('next', true).' >>', array(), null, array('class' => 'disabled'));?>
-</div>
-<div class="actions">
- <ul>
- <li><?php echo $html->link(__('New Note', true), array('action' => 'add')); ?></li>
- <li><?php echo $html->link(__('List Members', true), array('controller' => 'members', 'action' => 'index')); ?> </li>
- <li><?php echo $html->link(__('New Member', true), array('controller' => 'members', 'action' => 'add')); ?> </li>
- </ul>
-</div>
+++ /dev/null
-<div class="notes view">
-<h2><?php __('Note');?></h2>
- <dl><?php $i = 0; $class = ' class="altrow"';?>
- <dt<?php if ($i % 2 == 0) echo $class;?>><?php __('Id'); ?></dt>
- <dd<?php if ($i++ % 2 == 0) echo $class;?>>
- <?php echo $note['Note']['id']; ?>
-
- </dd>
- <dt<?php if ($i % 2 == 0) echo $class;?>><?php __('Member'); ?></dt>
- <dd<?php if ($i++ % 2 == 0) echo $class;?>>
- <?php echo $html->link($note['Member']['id'], array('controller' => 'members', 'action' => 'view', $note['Member']['id'])); ?>
-
- </dd>
- <dt<?php if ($i % 2 == 0) echo $class;?>><?php __('Lat'); ?></dt>
- <dd<?php if ($i++ % 2 == 0) echo $class;?>>
- <?php echo $note['Note']['lat']; ?>
-
- </dd>
- <dt<?php if ($i % 2 == 0) echo $class;?>><?php __('Lon'); ?></dt>
- <dd<?php if ($i++ % 2 == 0) echo $class;?>>
- <?php echo $note['Note']['lon']; ?>
-
- </dd>
- <dt<?php if ($i % 2 == 0) echo $class;?>><?php __('Title'); ?></dt>
- <dd<?php if ($i++ % 2 == 0) echo $class;?>>
- <?php echo $note['Note']['title']; ?>
-
- </dd>
- <dt<?php if ($i % 2 == 0) echo $class;?>><?php __('Body'); ?></dt>
- <dd<?php if ($i++ % 2 == 0) echo $class;?>>
- <?php echo $note['Note']['body']; ?>
-
- </dd>
- <dt<?php if ($i % 2 == 0) echo $class;?>><?php __('Public Flag'); ?></dt>
- <dd<?php if ($i++ % 2 == 0) echo $class;?>>
- <?php echo $note['Note']['public_flag']; ?>
-
- </dd>
- <dt<?php if ($i % 2 == 0) echo $class;?>><?php __('Created'); ?></dt>
- <dd<?php if ($i++ % 2 == 0) echo $class;?>>
- <?php echo $note['Note']['created']; ?>
-
- </dd>
- <dt<?php if ($i % 2 == 0) echo $class;?>><?php __('Modified'); ?></dt>
- <dd<?php if ($i++ % 2 == 0) echo $class;?>>
- <?php echo $note['Note']['modified']; ?>
-
- </dd>
- </dl>
-</div>
-<div class="actions">
- <ul>
- <li><?php echo $html->link(__('Edit Note', true), array('action' => 'edit', $note['Note']['id'])); ?> </li>
- <li><?php echo $html->link(__('Delete Note', true), array('action' => 'delete', $note['Note']['id']), null, sprintf(__('Are you sure you want to delete # %s?', true), $note['Note']['id'])); ?> </li>
- <li><?php echo $html->link(__('List Notes', true), array('action' => 'index')); ?> </li>
- <li><?php echo $html->link(__('New Note', true), array('action' => 'add')); ?> </li>
- <li><?php echo $html->link(__('List Members', true), array('controller' => 'members', 'action' => 'index')); ?> </li>
- <li><?php echo $html->link(__('New Member', true), array('controller' => 'members', 'action' => 'add')); ?> </li>
- </ul>
-</div>
+++ /dev/null
-<div class="notes form">
-<?php echo $form->create('Note');?>
- <fieldset>
- <legend><?php __('Edit Note');?></legend>
- <?php
- echo $form->input('id');
- echo $form->input('member_id');
- echo $form->input('lat');
- echo $form->input('lon');
- echo $form->input('title');
- echo $form->input('body');
- echo $form->input('public_flag');
- ?>
- </fieldset>
-<?php echo $form->end('Submit');?>
-</div>
-<div class="actions">
- <ul>
- <li><?php echo $html->link(__('Delete', true), array('action' => 'delete', $form->value('Note.id')), null, sprintf(__('Are you sure you want to delete # %s?', true), $form->value('Note.id'))); ?></li>
- <li><?php echo $html->link(__('List Notes', true), array('action' => 'index'));?></li>
- <li><?php echo $html->link(__('List Members', true), array('controller' => 'members', 'action' => 'index')); ?> </li>
- <li><?php echo $html->link(__('New Member', true), array('controller' => 'members', 'action' => 'add')); ?> </li>
- </ul>
-</div>
+++ /dev/null
-<div class="notes index">
-<h2><?php __('Notes');?></h2>
-<p>
-<?php
-echo $paginator->counter(array(
-'format' => __('Page %page% of %pages%, showing %current% records out of %count% total, starting on record %start%, ending on %end%', true)
-));
-?></p>
-<table cellpadding="0" cellspacing="0">
-<tr>
- <th><?php echo $paginator->sort('id');?></th>
- <th><?php echo $paginator->sort('member_id');?></th>
- <th><?php echo $paginator->sort('lat');?></th>
- <th><?php echo $paginator->sort('lon');?></th>
- <th><?php echo $paginator->sort('title');?></th>
- <th><?php echo $paginator->sort('body');?></th>
- <th><?php echo $paginator->sort('public_flag');?></th>
- <th><?php echo $paginator->sort('created');?></th>
- <th><?php echo $paginator->sort('modified');?></th>
- <th class="actions"><?php __('Actions');?></th>
-</tr>
-<?php
-$i = 0;
-foreach ($notes as $note):
- $class = null;
- if ($i++ % 2 == 0) {
- $class = ' class="altrow"';
- }
-?>
- <tr<?php echo $class;?>>
- <td>
- <?php echo $note['Note']['id']; ?>
- </td>
- <td>
- <?php echo $html->link($note['Member']['id'], array('controller' => 'members', 'action' => 'view', $note['Member']['id'])); ?>
- </td>
- <td>
- <?php echo $note['Note']['lat']; ?>
- </td>
- <td>
- <?php echo $note['Note']['lon']; ?>
- </td>
- <td>
- <?php echo $note['Note']['title']; ?>
- </td>
- <td>
- <?php echo $note['Note']['body']; ?>
- </td>
- <td>
- <?php echo $note['Note']['public_flag']; ?>
- </td>
- <td>
- <?php echo $note['Note']['created']; ?>
- </td>
- <td>
- <?php echo $note['Note']['modified']; ?>
- </td>
- <td class="actions">
- <?php echo $html->link(__('View', true), array('action' => 'view', $note['Note']['id'])); ?>
- <?php echo $html->link(__('Edit', true), array('action' => 'edit', $note['Note']['id'])); ?>
- <?php echo $html->link(__('Delete', true), array('action' => 'delete', $note['Note']['id']), null, sprintf(__('Are you sure you want to delete # %s?', true), $note['Note']['id'])); ?>
- </td>
- </tr>
-<?php endforeach; ?>
-</table>
-</div>
-<div class="paging">
- <?php echo $paginator->prev('<< '.__('previous', true), array(), null, array('class'=>'disabled'));?>
- | <?php echo $paginator->numbers();?>
- <?php echo $paginator->next(__('next', true).' >>', array(), null, array('class' => 'disabled'));?>
-</div>
-<div class="actions">
- <ul>
- <li><?php echo $html->link(__('New Note', true), array('action' => 'add')); ?></li>
- <li><?php echo $html->link(__('List Members', true), array('controller' => 'members', 'action' => 'index')); ?> </li>
- <li><?php echo $html->link(__('New Member', true), array('controller' => 'members', 'action' => 'add')); ?> </li>
- </ul>
-</div>
+++ /dev/null
-<div class="notes form">
-<?php echo $form->create('Note');?>
- <fieldset>
- <legend><?php __('Add Note');?></legend>
- <?php
- echo $form->input('member_id');
- echo $form->input('lat');
- echo $form->input('lon');
- echo $form->input('title');
- echo $form->input('body');
- echo $form->input('public_flag');
- ?>
- </fieldset>
-<?php echo $form->end('Submit');?>
-</div>
-<div class="actions">
- <ul>
- <li><?php echo $html->link(__('List Notes', true), array('action' => 'mobile_index'));?></li>
- <li><?php echo $html->link(__('List Members', true), array('controller' => 'members', 'action' => 'mobile_index')); ?> </li>
- <li><?php echo $html->link(__('New Member', true), array('controller' => 'members', 'action' => 'mobile_add')); ?> </li>
- </ul>
-</div>
+++ /dev/null
-<div class="notes form">
-<?php echo $form->create('Note');?>
- <fieldset>
- <legend><?php __('Edit Note');?></legend>
- <?php
- echo $form->input('id');
- echo $form->input('member_id');
- echo $form->input('lat');
- echo $form->input('lon');
- echo $form->input('title');
- echo $form->input('body');
- echo $form->input('public_flag');
- ?>
- </fieldset>
-<?php echo $form->end('Submit');?>
-</div>
-<div class="actions">
- <ul>
- <li><?php echo $html->link(__('Delete', true), array('action' => 'mobile_delete', $form->value('Note.id')), null, sprintf(__('Are you sure you want to delete # %s?', true), $form->value('Note.id'))); ?></li>
- <li><?php echo $html->link(__('List Notes', true), array('action' => 'mobile_index'));?></li>
- <li><?php echo $html->link(__('List Members', true), array('controller' => 'members', 'action' => 'mobile_index')); ?> </li>
- <li><?php echo $html->link(__('New Member', true), array('controller' => 'members', 'action' => 'mobile_add')); ?> </li>
- </ul>
-</div>
+++ /dev/null
-<div class="notes index">
-<h2><?php __('Notes');?> for Mobile</h2>
-<p>
-<?php
-echo $paginator->counter(array(
-'format' => __('Page %page% of %pages%, showing %current% records out of %count% total, starting on record %start%, ending on %end%', true)
-));
-?></p>
-<table cellpadding="0" cellspacing="0">
-<tr>
- <th><?php echo $paginator->sort('id');?></th>
- <th><?php echo $paginator->sort('member_id');?></th>
- <th><?php echo $paginator->sort('lat');?></th>
- <th><?php echo $paginator->sort('lon');?></th>
- <th><?php echo $paginator->sort('title');?></th>
- <th><?php echo $paginator->sort('body');?></th>
- <th><?php echo $paginator->sort('public_flag');?></th>
- <th><?php echo $paginator->sort('created');?></th>
- <th><?php echo $paginator->sort('modified');?></th>
- <th class="actions"><?php __('Actions');?></th>
-</tr>
-<?php
-$i = 0;
-foreach ($notes as $note):
- $class = null;
- if ($i++ % 2 == 0) {
- $class = ' class="altrow"';
- }
-?>
- <tr<?php echo $class;?>>
- <td>
- <?php echo $note['Note']['id']; ?>
- </td>
- <td>
- <?php echo $html->link($note['Member']['id'], array('controller' => 'members', 'action' => 'mobile_view', $note['Member']['id'])); ?>
- </td>
- <td>
- <?php echo $note['Note']['lat']; ?>
- </td>
- <td>
- <?php echo $note['Note']['lon']; ?>
- </td>
- <td>
- <?php echo $note['Note']['title']; ?>
- </td>
- <td>
- <?php echo $note['Note']['body']; ?>
- </td>
- <td>
- <?php echo $note['Note']['public_flag']; ?>
- </td>
- <td>
- <?php echo $note['Note']['created']; ?>
- </td>
- <td>
- <?php echo $note['Note']['modified']; ?>
- </td>
- <td class="actions">
- <?php echo $html->link(__('View', true), array('action' => 'mobile_view', $note['Note']['id'])); ?>
- <?php echo $html->link(__('Edit', true), array('action' => 'mobile_edit', $note['Note']['id'])); ?>
- <?php echo $html->link(__('Delete', true), array('action' => 'mobile_delete', $note['Note']['id']), null, sprintf(__('Are you sure you want to delete # %s?', true), $note['Note']['id'])); ?>
- </td>
- </tr>
-<?php endforeach; ?>
-</table>
-</div>
-<div class="paging">
- <?php echo $paginator->prev('<< '.__('previous', true), array(), null, array('class'=>'disabled'));?>
- | <?php echo $paginator->numbers();?>
- <?php echo $paginator->next(__('next', true).' >>', array(), null, array('class' => 'disabled'));?>
-</div>
-<div class="actions">
- <ul>
- <li><?php echo $html->link(__('New Note', true), array('action' => 'mobile_add')); ?></li>
- <li><?php echo $html->link(__('List Members', true), array('controller' => 'members', 'action' => 'mobile_index')); ?> </li>
- <li><?php echo $html->link(__('New Member', true), array('controller' => 'members', 'action' => 'mobile_add')); ?> </li>
- </ul>
-</div>
+++ /dev/null
-<div class="notes view">
-<h2><?php __('Note');?> for Mobile</h2>
- <dl><?php $i = 0; $class = ' class="altrow"';?>
- <dt<?php if ($i % 2 == 0) echo $class;?>><?php __('Id'); ?></dt>
- <dd<?php if ($i++ % 2 == 0) echo $class;?>>
- <?php echo $note['Note']['id']; ?>
-
- </dd>
- <dt<?php if ($i % 2 == 0) echo $class;?>><?php __('Member'); ?></dt>
- <dd<?php if ($i++ % 2 == 0) echo $class;?>>
- <?php echo $html->link($note['Member']['id'], array('controller' => 'members', 'action' => 'mobile_view', $note['Member']['id'])); ?>
-
- </dd>
- <dt<?php if ($i % 2 == 0) echo $class;?>><?php __('Lat'); ?></dt>
- <dd<?php if ($i++ % 2 == 0) echo $class;?>>
- <?php echo $note['Note']['lat']; ?>
-
- </dd>
- <dt<?php if ($i % 2 == 0) echo $class;?>><?php __('Lon'); ?></dt>
- <dd<?php if ($i++ % 2 == 0) echo $class;?>>
- <?php echo $note['Note']['lon']; ?>
-
- </dd>
- <dt<?php if ($i % 2 == 0) echo $class;?>><?php __('Title'); ?></dt>
- <dd<?php if ($i++ % 2 == 0) echo $class;?>>
- <?php echo $note['Note']['title']; ?>
-
- </dd>
- <dt<?php if ($i % 2 == 0) echo $class;?>><?php __('Body'); ?></dt>
- <dd<?php if ($i++ % 2 == 0) echo $class;?>>
- <?php echo $note['Note']['body']; ?>
-
- </dd>
- <dt<?php if ($i % 2 == 0) echo $class;?>><?php __('Public Flag'); ?></dt>
- <dd<?php if ($i++ % 2 == 0) echo $class;?>>
- <?php echo $note['Note']['public_flag']; ?>
-
- </dd>
- <dt<?php if ($i % 2 == 0) echo $class;?>><?php __('Created'); ?></dt>
- <dd<?php if ($i++ % 2 == 0) echo $class;?>>
- <?php echo $note['Note']['created']; ?>
-
- </dd>
- <dt<?php if ($i % 2 == 0) echo $class;?>><?php __('Modified'); ?></dt>
- <dd<?php if ($i++ % 2 == 0) echo $class;?>>
- <?php echo $note['Note']['modified']; ?>
-
- </dd>
- </dl>
-</div>
-<div class="actions">
- <ul>
- <li><?php echo $html->link(__('Edit Note', true), array('action' => 'mobile_edit', $note['Note']['id'])); ?> </li>
- <li><?php echo $html->link(__('Delete Note', true), array('action' => 'mobile_delete', $note['Note']['id']), null, sprintf(__('Are you sure you want to delete # %s?', true), $note['Note']['id'])); ?> </li>
- <li><?php echo $html->link(__('List Notes', true), array('action' => 'mobile_index')); ?> </li>
- <li><?php echo $html->link(__('New Note', true), array('action' => 'add')); ?> </li>
- <li><?php echo $html->link(__('List Members', true), array('controller' => 'members', 'action' => 'mobile_index')); ?> </li>
- <li><?php echo $html->link(__('New Member', true), array('controller' => 'members', 'action' => 'mobile_add')); ?> </li>
- </ul>
-</div>
+++ /dev/null
-<div class="notes view">
-<h2><?php __('Note');?></h2>
- <dl><?php $i = 0; $class = ' class="altrow"';?>
- <dt<?php if ($i % 2 == 0) echo $class;?>><?php __('Id'); ?></dt>
- <dd<?php if ($i++ % 2 == 0) echo $class;?>>
- <?php echo $note['Note']['id']; ?>
-
- </dd>
- <dt<?php if ($i % 2 == 0) echo $class;?>><?php __('Member'); ?></dt>
- <dd<?php if ($i++ % 2 == 0) echo $class;?>>
- <?php echo $html->link($note['Member']['id'], array('controller' => 'members', 'action' => 'view', $note['Member']['id'])); ?>
-
- </dd>
- <dt<?php if ($i % 2 == 0) echo $class;?>><?php __('Lat'); ?></dt>
- <dd<?php if ($i++ % 2 == 0) echo $class;?>>
- <?php echo $note['Note']['lat']; ?>
-
- </dd>
- <dt<?php if ($i % 2 == 0) echo $class;?>><?php __('Lon'); ?></dt>
- <dd<?php if ($i++ % 2 == 0) echo $class;?>>
- <?php echo $note['Note']['lon']; ?>
-
- </dd>
- <dt<?php if ($i % 2 == 0) echo $class;?>><?php __('Title'); ?></dt>
- <dd<?php if ($i++ % 2 == 0) echo $class;?>>
- <?php echo $note['Note']['title']; ?>
-
- </dd>
- <dt<?php if ($i % 2 == 0) echo $class;?>><?php __('Body'); ?></dt>
- <dd<?php if ($i++ % 2 == 0) echo $class;?>>
- <?php echo $note['Note']['body']; ?>
-
- </dd>
- <dt<?php if ($i % 2 == 0) echo $class;?>><?php __('Public Flag'); ?></dt>
- <dd<?php if ($i++ % 2 == 0) echo $class;?>>
- <?php echo $note['Note']['public_flag']; ?>
-
- </dd>
- <dt<?php if ($i % 2 == 0) echo $class;?>><?php __('Created'); ?></dt>
- <dd<?php if ($i++ % 2 == 0) echo $class;?>>
- <?php echo $note['Note']['created']; ?>
-
- </dd>
- <dt<?php if ($i % 2 == 0) echo $class;?>><?php __('Modified'); ?></dt>
- <dd<?php if ($i++ % 2 == 0) echo $class;?>>
- <?php echo $note['Note']['modified']; ?>
-
- </dd>
- </dl>
-</div>
-<div class="actions">
- <ul>
- <li><?php echo $html->link(__('Edit Note', true), array('action' => 'edit', $note['Note']['id'])); ?> </li>
- <li><?php echo $html->link(__('Delete Note', true), array('action' => 'delete', $note['Note']['id']), null, sprintf(__('Are you sure you want to delete # %s?', true), $note['Note']['id'])); ?> </li>
- <li><?php echo $html->link(__('List Notes', true), array('action' => 'index')); ?> </li>
- <li><?php echo $html->link(__('New Note', true), array('action' => 'add')); ?> </li>
- <li><?php echo $html->link(__('List Members', true), array('controller' => 'members', 'action' => 'index')); ?> </li>
- <li><?php echo $html->link(__('New Member', true), array('controller' => 'members', 'action' => 'add')); ?> </li>
- </ul>
-</div>
--- /dev/null
+<div class="users form">
+<?php echo $form->create('User');?>
+ <fieldset>
+ <legend><?php __('Add User');?></legend>
+ <?php
+ echo $form->input('name', array(
+ 'label' => __('YourName', true),
+ )
+ );
+ echo $form->input('username', array(
+ 'label' => __('UserId', true),
+ 'maxlength' => $idLength['max'],
+ 'after' => sprintf(__('Between %d to %d characters', true), $idLength['min'], $idLength['max']),
+ )
+ );
+ echo $form->input('password1', array(
+ 'label' => __('Password', true),
+ 'maxlength' => $passwordLength['max'],
+ 'after' => sprintf(__('Between %d to %d characters', true), $passwordLength['min'], $passwordLength['max']),
+ 'type' => 'password',
+ )
+ );
+ echo $form->input('password2', array(
+ 'label' => __('Password [confirm]', true),
+ 'maxlength' => $passwordLength['max'],
+ 'type' => 'password',
+ )
+ );
+ ?>
+ </fieldset>
+<?php echo $form->end('Submit');?>
+</div>
+<div class="actions">
+</div>
<fieldset>
<legend><?php __('Add User');?></legend>
<?php
+ echo $form->input('name', array(
+ 'label' => __('YourName', true),
+ )
+ );
echo $form->input('username', array(
'label' => __('UserId', true),
'maxlength' => $idLength['max'],
'after' => sprintf(__('Between %d to %d characters', true), $idLength['min'], $idLength['max']),
)
);
+ echo $form->input('group_id', array(
+ 'label' => __('GroupId', true),
+ )
+ );
echo $form->input('password1', array(
'label' => __('Password', true),
'maxlength' => $passwordLength['max'],
'type' => 'password',
)
);
+ echo $token->create();
?>
</fieldset>
<?php echo $form->end('Submit');?>
</div>
<div class="actions">
<ul>
- <li><?php echo $html->link(__('List Users', true), array('action' => 'index'));?></li>
+ <li><?php echo $html->link(__('List Users', true), array('action' => 'admin_listview'));?></li>
</ul>
</div>
<fieldset>
<legend><?php __('Change Password');?></legend>
<?php
- echo $form->input('id');
echo $form->input('password1', array(
'label' => __('New Password', true),
'maxlength' => $passwordLength['max'],
'type' => 'password',
)
);
+ echo $token->create();
?>
</fieldset>
<?php echo $form->end('Submit');?>
</div>
<div class="actions">
<ul>
- <li><?php echo $html->link(__('Delete', true), array('action' => 'delete', $form->value('User.id')), null, sprintf(__('Are you sure you want to delete # %s?', true), $form->value('User.id'))); ?></li>
- <li><?php echo $html->link(__('List Users', true), array('action' => 'index'));?></li>
+ <li><?php echo $html->link(__('List Users', true), array('action' => 'listview'));?></li>
</ul>
</div>
--- /dev/null
+<div class="users delete">
+
+<?php echo $form->create('User', array('action'=>'delete/'));?>
+<fieldset>
+ <legend><?php __('Do you really delete the account?');?></legend>
+
+ <dl><?php $i = 0; $class = ' class="altrow"';?>
+ <dt<?php if ($i % 2 == 0) echo $class;?>><?php __('Id'); ?></dt>
+ <dd<?php if ($i++ % 2 == 0) echo $class;?>>
+ <?php echo $user['User']['id']; ?>
+
+ </dd>
+ <dt<?php if ($i % 2 == 0) echo $class;?>><?php __('GroupId'); ?></dt>
+ <dd<?php if ($i++ % 2 == 0) echo $class;?>>
+ <?php echo $user['User']['group_id']; ?>
+
+ </dd>
+ <dt<?php if ($i % 2 == 0) echo $class;?>><?php __('Name'); ?></dt>
+ <dd<?php if ($i++ % 2 == 0) echo $class;?>>
+ <?php echo $user['User']['name']; ?>
+
+ </dd>
+ <dt<?php if ($i % 2 == 0) echo $class;?>><?php __('UserId'); ?></dt>
+ <dd<?php if ($i++ % 2 == 0) echo $class;?>>
+ <?php echo $user['User']['username']; ?>
+
+ </dd>
+ <dt<?php if ($i % 2 == 0) echo $class;?>><?php __('Created'); ?></dt>
+ <dd<?php if ($i++ % 2 == 0) echo $class;?>>
+ <?php echo $user['User']['created']; ?>
+
+ </dd>
+ <dt<?php if ($i % 2 == 0) echo $class;?>><?php __('Modified'); ?></dt>
+ <dd<?php if ($i++ % 2 == 0) echo $class;?>>
+ <?php echo $user['User']['modified']; ?>
+
+ </dd>
+ </dl>
+</div>
+
+ <?php
+ echo $token->create();
+ ?>
+</fieldset>
+<?php echo $form->end('Submit');?>
--- /dev/null
+<div class="users form">
+<?php echo $form->create('User');?>
+ <fieldset>
+ <legend><?php __('Change Password');?></legend>
+ <?php
+ echo $form->input('id');
+ echo $form->input('username', array(
+ 'type' => 'hidden',
+ )
+ );
+ echo $form->input('password');
+ echo $form->input('password1', array(
+ 'label' => __('New Password', true),
+ 'maxlength' => $passwordLength['max'],
+ 'after' => sprintf(__('Between %d to %d characters', true), $passwordLength['min'], $passwordLength['max']),
+ 'type' => 'password',
+ )
+ );
+ echo $form->input('password2', array(
+ 'label' => __('New Password [confirm]', true),
+ 'maxlength' => $passwordLength['max'],
+ 'type' => 'password',
+ )
+ );
+ ?>
+ </fieldset>
+<?php echo $form->end('Submit');?>
+</div>
+<div class="actions">
+ <ul>
+ <li><?php echo $html->link(__('Delete', true), array('action' => 'delete', $form->value('User.id')), null, sprintf(__('Are you sure you want to delete # %s?', true), $form->value('User.id'))); ?></li>
+ <li><?php echo $html->link(__('List Users', true), array('action' => 'index'));?></li>
+ </ul>
+</div>
--- /dev/null
+<div class="users listview">
+<h2><?php __('Users');?></h2>
+
+<h4><?php //todo:toggle echo $html->link(__('Search Users', true)); ?></h4>
+<fieldset class="searchFieldset" id="adminSearchFieldset">
+<legend><?php __('Search User');?></legend>
+<div class="search form">
+<?php echo $form->create('User', array('action' => 'listview', 'type' => 'post')); ?>
+<?php echo $form->input('name'); ?>
+<?php echo $form->end('Search'); ?>
+</div>
+<?php $paginator->options(array('url' => $searchword)); ?>
+</fieldset>
+<br>
+
+<div class="paging">
+ <?php echo $paginator->prev('<< '.__('previous', true), array(), null, array('class'=>'disabled'));?>
+ | <?php echo $paginator->numbers();?>
+ <?php echo $paginator->next(__('next', true).' >>', array(), null, array('class' => 'disabled'));?>
+</div>
+<table cellpadding="0" cellspacing="0">
+<tr>
+ <th><?php echo $paginator->sort('id');?></th>
+ <th><?php echo $paginator->sort('name');?></th>
+ <th><?php echo $paginator->sort('group_id');?></th>
+ <th><?php echo $paginator->sort('modefied');?></th>
+ <th><?php echo $paginator->sort('username');?></th>
+ <th><?php echo $paginator->sort('pcmail');?></th>
+ <th><?php echo $paginator->sort('mobile_mail');?></th>
+ <th><?php echo $paginator->sort('created');?></th>
+ <th><?php echo $paginator->sort('useragent');?></th>
+ <th><?php echo $paginator->sort('host');?></th>
+</tr>
+<?php
+$i = 0;
+foreach ($users as $user):
+ $class = null;
+ if ($i++ % 2 == 0) {
+ $class = ' class="altrow"';
+ }
+?>
+ <tr<?php echo $class;?>>
+ <td>
+ <?php echo $user['User']['id']; ?>
+ </td>
+ <td>
+ <?php echo $html->link($user['User']['name'], array('action' => 'view', $user['User']['id']), array(), false, false); ?>
+ </td>
+ <td>
+ <?php echo $user['User']['group_id']; ?>
+ </td>
+ <td>
+ <?php echo $user['User']['modified']; ?>
+ </td>
+ <td>
+ <?php echo $user['User']['username']; ?>
+ </td>
+ <td>
+ <?php echo $user['User']['pcmail']; ?>
+ </td>
+ <td>
+ <?php echo $user['User']['mobile_mail']; ?>
+ </td>
+ <td>
+ <?php echo $user['User']['created']; ?>
+ </td>
+ <td>
+ <?php echo $user['User']['useragent']; ?>
+ </td>
+ <td>
+ <?php echo $user['User']['host']; ?>
+ </td>
+ </tr>
+<?php endforeach; ?>
+</table>
+</div>
+<div class="paging">
+ <?php echo $paginator->prev('<< '.__('previous', true), array(), null, array('class'=>'disabled'));?>
+ | <?php echo $paginator->numbers();?>
+ <?php echo $paginator->next(__('next', true).' >>', array(), null, array('class' => 'disabled'));?>
+</div>
+<div class="actions">
+<?php if($gid==1): ?>
+ <li><?php echo $html->link(__('Add Users', true), array('action' => 'admin_add'));?></li>
+<?php endif; ?>
+</div>
--- /dev/null
+<div class="users view">
+<h2><?php __('User');?></h2>
+ <dl><?php $i = 0; $class = ' class="altrow"';?>
+ <dt<?php if ($i % 2 == 0) echo $class;?>><?php __('Id'); ?></dt>
+ <dd<?php if ($i++ % 2 == 0) echo $class;?>>
+ <?php echo $user['User']['id']; ?>
+
+ </dd>
+ <dt<?php if ($i % 2 == 0) echo $class;?>><?php __('GroupId'); ?></dt>
+ <dd<?php if ($i++ % 2 == 0) echo $class;?>>
+ <?php echo $user['User']['group_id']; ?>
+
+ </dd>
+ <dt<?php if ($i % 2 == 0) echo $class;?>><?php __('Name'); ?></dt>
+ <dd<?php if ($i++ % 2 == 0) echo $class;?>>
+ <?php echo $user['User']['name']; ?>
+
+ </dd>
+ <dt<?php if ($i % 2 == 0) echo $class;?>><?php __('UserId'); ?></dt>
+ <dd<?php if ($i++ % 2 == 0) echo $class;?>>
+ <?php echo $user['User']['username']; ?>
+
+ </dd>
+ <dt<?php if ($i % 2 == 0) echo $class;?>><?php __('Pc Mail Address'); ?></dt>
+ <dd<?php if ($i++ % 2 == 0) echo $class;?>>
+ <?php echo $user['User']['pcmail']; ?>
+
+ </dd>
+ <dt<?php if ($i % 2 == 0) echo $class;?>><?php __('Mobile Mail Address'); ?></dt>
+ <dd<?php if ($i++ % 2 == 0) echo $class;?>>
+ <?php echo $user['User']['mobile_mail']; ?>
+
+ </dd>
+ <dt<?php if ($i % 2 == 0) echo $class;?>><?php __('Useragent'); ?></dt>
+ <dd<?php if ($i++ % 2 == 0) echo $class;?>>
+ <?php echo $user['User']['useragent']; ?>
+
+ </dd>
+ <dt<?php if ($i % 2 == 0) echo $class;?>><?php __('Host'); ?></dt>
+ <dd<?php if ($i++ % 2 == 0) echo $class;?>>
+ <?php echo $user['User']['host']; ?>
+
+ </dd>
+ <dt<?php if ($i % 2 == 0) echo $class;?>><?php __('Created'); ?></dt>
+ <dd<?php if ($i++ % 2 == 0) echo $class;?>>
+ <?php echo $user['User']['created']; ?>
+
+ </dd>
+ <dt<?php if ($i % 2 == 0) echo $class;?>><?php __('Modified'); ?></dt>
+ <dd<?php if ($i++ % 2 == 0) echo $class;?>>
+ <?php echo $user['User']['modified']; ?>
+
+ </dd>
+ </dl>
+</div>
+<div class="actions">
+ <ul>
+ <li><?php echo $html->link(__('Change Password', true), array('action' => 'change_password', $user['User']['id'])); ?> </li>
+ <li><?php echo $html->link(__('Delete User', true), array('action' => 'delete', $user['User']['id'])); ?> </li>
+ <li><?php echo $html->link(__('List Users', true), array('action' => 'listview')); ?> </li>
+ </ul>
+</div>
--- /dev/null
+<div class="users form">
+<?php echo $form->create('User', array('action'=>'change_password/'));?>
+ <fieldset>
+ <legend><?php __('Change Password');?></legend>
+ <?php
+ echo $form->input('password', array(
+ 'label' => __('Old Password', true),
+ 'maxlength' => $passwordLength['max'],
+ 'type' => 'password',
+ )
+ );
+ echo $form->input('password1', array(
+ 'label' => __('New Password', true),
+ 'maxlength' => $passwordLength['max'],
+ 'after' => sprintf(__('Between %d to %d characters', true), $passwordLength['min'], $passwordLength['max']),
+ 'type' => 'password',
+ )
+ );
+ echo $form->input('password2', array(
+ 'label' => __('New Password [confirm]', true),
+ 'maxlength' => $passwordLength['max'],
+ 'type' => 'password',
+ )
+ );
+ echo $token->create();
+ ?>
+ </fieldset>
+<?php echo $form->end('Submit');?>
+</div>
+<div class="actions">
+ <ul>
+ <li><?php echo $html->link(__('List Users', true), array('action' => 'listview'));?></li>
+ </ul>
+</div>
--- /dev/null
+<div class="users form">
+<?php echo $form->create('User', array('action'=>'delete/'));?>
+ <fieldset>
+ <legend><?php __('Do you really delete your account?');?></legend>
+ <?php
+ echo $html->div('caution', __('Please input your password, if you want to delete your account.', true));
+ echo $form->input('password', array(
+ 'type' => 'password',
+ )
+ );
+ echo $token->create();
+ ?>
+ </fieldset>
+<?php echo $form->end('Submit');?>
+</div>
--- /dev/null
+<div class="users form">
+<?php echo $form->create('User');?>
+ <fieldset>
+ <legend><?php __('Edit User');?></legend>
+ <?php
+ echo $form->input('name', array(
+ 'label' => __('YourName', true),
+ )
+ );
+ echo $token->create();
+ ?>
+ </fieldset>
+<?php echo $form->end('Submit');?>
+</div>
+<div class="actions">
+</div>
<?php
echo $this->renderElement('home',
array(
- 'member' => $member,
+ 'user' => $user,
'owner' => true,
)
);
\ No newline at end of file
-<div class="users index">
-<h2><?php __('Users');?></h2>
+<div class="users list">
+<h2><?php __('Users');?> <?php __('List');?></h2>
<p>
<?php
echo $paginator->counter(array(
'format' => __('Page %page% of %pages%, showing %current% records out of %count% total, starting on record %start%, ending on %end%', true)
));
?></p>
+
+<div class="paging">
+ <?php echo $paginator->prev('<< '.__('previous', true), array(), null, array('class'=>'disabled'));?>
+ | <?php echo $paginator->numbers();?>
+ <?php echo $paginator->next(__('next', true).' >>', array(), null, array('class' => 'disabled'));?>
+</div>
+
<table cellpadding="0" cellspacing="0">
<tr>
<th><?php echo $paginator->sort('id');?></th>
- <th><?php echo $paginator->sort('username');?></th>
- <th class="actions"><?php __('Change Password');?></th>
- <th class="actions"><?php __('delete');?></th>
+ <th><?php echo $paginator->sort('name');?></th>
+ <th><?php echo $paginator->sort('modified');?></th>
</tr>
<?php
$i = 0;
<?php echo $user['User']['id']; ?>
</td>
<td>
- <?php echo $user['User']['username']; ?>
- </td>
- <td class="actions">
- <?php if ($uid == 1 || $uid == $user['User']['id']): ?>
- <?php echo $html->link(__('Edit', true), array('action' => 'change_password', $user['User']['id'])); ?>
- <?php endif; ?>
+ <?php echo $html->link($user['User']['name'], array('action' => 'view', $user['User']['id']), array(), false, false); ?>
</td>
- <td class="actions">
- <?php if ($uid == 1 || $uid == $user['User']['id']): ?>
- <?php echo $html->link(__('Delete', true), array('action' => 'delete', $user['User']['id']), null, sprintf(__('Are you sure you want to delete # %s?', true), $user['User']['id'])); ?>
- <?php endif; ?>
+ <td>
+ <?php echo $user['User']['modified']; ?>
</td>
</tr>
<?php endforeach; ?>
<?php
-if ($session->check('Message.auth')) {
- $session->flash('auth');
-}
-
echo $form->create('User', array('action' => 'login'));
echo $form->input('username');
echo $form->input('password');
--- /dev/null
+<div class="Users form">
+<?php echo $form->create('User');?>
+<fieldset>
+<legend><?php __('Add User');?></legend>
+<?php
+echo $form->input('name', array(
+'label' => __('YourName', true),
+)
+);
+echo $form->input('username', array(
+'label' => __('UserId', true),
+'maxlength' => $idLength['max'],
+'after' => sprintf(__('Between %d to %d characters', true), $idLength['min'], $idLength['max']),
+)
+);
+echo $form->input('password1', array(
+'label' => __('Password', true),
+'maxlength' => $passwordLength['max'],
+'after' => sprintf(__('Between %d to %d characters', true), $passwordLength['min'], $passwordLength['max']),
+'type' => 'password',
+)
+);
+echo $form->input('password2', array(
+'label' => __('Password [confirm]', true),
+'maxlength' => $passwordLength['max'],
+'type' => 'password',
+)
+);
+?>
+</fieldset>
+<?php echo $form->end('Submit');?>
+</div>
+<div class="actions">
+<ul>
+<li><?php echo $html->link(__('List Users', true), array('action' => 'mobile_index'));?></li>
+</ul>
+</div>
--- /dev/null
+<div class="users form">
+<?php echo $form->create('User', array('action' => 'change_password')); ?>
+<fieldset>
+<legend><?php __('Change Password');?></legend>
+<?php
+echo $form->input('password', array(
+'label' => __('Old Password', true),
+'maxlength' => $passwordLength['max'],
+'type' => 'password',
+)
+);
+echo $form->input('password1', array(
+'label' => __('New Password', true),
+'maxlength' => $passwordLength['max'],
+'after' => sprintf(__('Between %d to %d characters', true), $passwordLength['min'], $passwordLength['max']),
+'type' => 'password',
+)
+);
+echo $form->input('password2', array(
+'label' => __('New Password [confirm]', true),
+'maxlength' => $passwordLength['max'],
+'type' => 'password',
+)
+echo $token->create();
+);
+?>
+</fieldset>
+<?php echo $form->end('Submit');?>
+</div>
+<div class="actions">
+<ul>
+<li><?php echo $html->link(__('List Users', true), array('action' => 'mobile_listview'));?></li>
+</ul>
+</div>
--- /dev/null
+<div class="users form">
+<h3><?php echo _=('Do you really delete your account?', true) ?></h3>
+<?php echo __('Please input your password, if you want to delete your account.', true) ?>
+<?php echo $form->create('User', array('action'=>'delete/'));?>
+<fieldset>
+<?php
+echo $form->input('password', array(
+'type' => 'password',
+)
+);
+echo $token->create();
+?>
+</fieldset>
+<?php echo $form->end('Submit');?>
+</div>
--- /dev/null
+<div class="users form">
+<?php echo $form->create('User');?>
+<fieldset>
+<legend><?php __('Edit User');?></legend>
+<?php
+echo $form->input('name', array(
+'label' => __('YourName', true),
+)
+);
+echo $token->create();
+?>
+</fieldset>
+<?php echo $form->end('Submit');?>
+</div>
+<div class="actions">
+</div>
<?php
echo $this->renderElement('mobile_home',
array(
- 'member' => $member,
+ 'user' => $user,
'owner' => true,
)
);
\ No newline at end of file
-<div class="members index">
-<h2><?php __('Members');?></h2>
+<div class="Users index">
+<h2><?php __('Users');?> <?php __('List');?></h2>
<p>
<?php
echo $paginator->counter(array(
'format' => __('Page %page% of %pages%, showing %current% records out of %count% total, starting on record %start%, ending on %end%', true)
));
?></p>
+<div class="paging">
+<?php echo $paginator->prev('<< '.__('previous', true), array(), null, array('class'=>'disabled'));?>
+ | <?php echo $paginator->numbers();?>
+<?php echo $paginator->next(__('next', true).' >>', array(), null, array('class' => 'disabled'));?>
+</div>
+
<table cellpadding="0" cellspacing="0">
<tr>
<th><?php echo $paginator->sort('id');?></th>
-<th><?php echo $paginator->sort('nickname');?></th>
+<th><?php echo $paginator->sort('name');?></th>
<th><?php echo $paginator->sort('modified');?></th>
-<th class="actions"><?php __('Actions');?></th>
</tr>
<?php
$i = 0;
-foreach ($members as $member):
+foreach ($users as $user):
$class = null;
if ($i++ % 2 == 0) {
$class = ' class="altrow"';
?>
<tr<?php echo $class;?>>
<td>
-<?php echo $member['Member']['id']; ?>
+<?php echo $user['User']['id']; ?>
</td>
<td>
-<?php echo $member['Member']['nickname']; ?>
+<?php echo $html->link($user['User']['name'], array('action' => 'mobile_view', $user['User']['id']), array(), false, false); ?>
</td>
<td>
-<?php echo $member['Member']['modified']; ?>
-</td>
-<td class="actions">
-<?php echo $html->link(__('View', true), array('action' => 'mobile_view', $member['Member']['id'])); ?>
+<?php echo $user['User']['modified']; ?>
</td>
</tr>
<?php endforeach; ?>
--- /dev/null
+<?php
+echo $form->create('User', array('action' => 'mobile_login'));
+echo $form->input('username');
+echo $form->input('password');
+echo $form->end('Login');
+
+
<?php
echo $this->renderElement('mobile_home',
array(
- 'member' => $member,
+ 'user' => $user,
'owner' => false,
)
);
\ No newline at end of file
<?php
echo $this->renderElement('home',
array(
- 'member' => $member,
+ 'user' => $user,
'owner' => false,
)
);
\ No newline at end of file
if (!empty($status)) {
$this->header($status);
}
+// var_dump(Router::url($url, true));
+// exit;
if ($url !== null) {
$this->header('Location: ' . Router::url($url, true));
}
}
break;
case 'medium':
- $this->cookieLifeTime = 7 * 86400;
+// $this->cookieLifeTime = 7 * 86400;
+// modified: Change LifeTime on Browser
+ $this->cookieLifeTime = 0;
if ($iniSet) {
ini_set('session.referer_check', $this->host);
}