From: cake_67 Date: Fri, 9 Oct 2009 02:31:21 +0000 (+0000) Subject: members and notes scoffold X-Git-Tag: version-alpha~240 X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=9ab5b7f30499d248105f5702a5ddc68986e88e04;p=trpgtools-onweb%2Fcake-frame.git members and notes scoffold git-svn-id: svn+ssh://svn.sourceforge.jp/svnroot/trpgtools-onweb/src/trunk/cakePHP_frame@62 46fa8b77-3530-0410-9d82-d95c44d28aba --- diff --git a/app/config/sql/members.sql b/app/config/sql/members.sql new file mode 100644 index 0000000..11c51db --- /dev/null +++ b/app/config/sql/members.sql @@ -0,0 +1,12 @@ +CREATE TABLE members ( + id INTEGER UNSIGNED NOT NULL AUTO_INCREMENT, + username VARCHAR(40) NOT NULL default '', + password VARCHAR(40) NOT NULL default '', + uid VARCHAR(40) NOT NULL, + created_at DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00', + PRIMARY KEY(id), + INDEX members_login(username, password), + UNIQUE INDEX members_uid(uid), + UNIQUE INDEX members_username(username) +); + diff --git a/app/config/sql/notes.sql b/app/config/sql/notes.sql new file mode 100644 index 0000000..f3a5147 --- /dev/null +++ b/app/config/sql/notes.sql @@ -0,0 +1,16 @@ +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; diff --git a/app/controllers/members_controller.php b/app/controllers/members_controller.php new file mode 100644 index 0000000..54f8987 --- /dev/null +++ b/app/controllers/members_controller.php @@ -0,0 +1,117 @@ +Member->recursive = 0; + $this->set('members', $this->paginate()); + } + + function 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 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 ($this->Member->del($id)) { + $this->Session->setFlash(__('Member deleted', true)); + $this->redirect(array('action'=>'index')); + } + } + + + 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 diff --git a/app/controllers/notes_controller.php b/app/controllers/notes_controller.php new file mode 100644 index 0000000..6613c80 --- /dev/null +++ b/app/controllers/notes_controller.php @@ -0,0 +1,125 @@ +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 diff --git a/app/models/member.php b/app/models/member.php new file mode 100644 index 0000000..16bf051 --- /dev/null +++ b/app/models/member.php @@ -0,0 +1,9 @@ + diff --git a/app/models/note.php b/app/models/note.php new file mode 100644 index 0000000..ce2e73a --- /dev/null +++ b/app/models/note.php @@ -0,0 +1,18 @@ + array( + 'className' => 'Member', + 'foreignKey' => 'member_id', + 'conditions' => '', + 'fields' => '', + 'order' => '' + ) + ); + +} +?> \ No newline at end of file diff --git a/app/views/members/add.ctp b/app/views/members/add.ctp new file mode 100644 index 0000000..1a6a84d --- /dev/null +++ b/app/views/members/add.ctp @@ -0,0 +1,18 @@ +
+create('Member');?> +
+ + input('username'); + echo $form->input('password'); + echo $form->input('uid'); + echo $form->input('created_at'); + ?> +
+end('Submit');?> +
+
+ +
diff --git a/app/views/members/admin_add.ctp b/app/views/members/admin_add.ctp new file mode 100644 index 0000000..1a6a84d --- /dev/null +++ b/app/views/members/admin_add.ctp @@ -0,0 +1,18 @@ +
+create('Member');?> +
+ + input('username'); + echo $form->input('password'); + echo $form->input('uid'); + echo $form->input('created_at'); + ?> +
+end('Submit');?> +
+
+ +
diff --git a/app/views/members/admin_edit.ctp b/app/views/members/admin_edit.ctp new file mode 100644 index 0000000..33ffdb0 --- /dev/null +++ b/app/views/members/admin_edit.ctp @@ -0,0 +1,20 @@ +
+create('Member');?> +
+ + input('id'); + echo $form->input('username'); + echo $form->input('password'); + echo $form->input('uid'); + echo $form->input('created_at'); + ?> +
+end('Submit');?> +
+
+ +
diff --git a/app/views/members/admin_index.ctp b/app/views/members/admin_index.ctp new file mode 100644 index 0000000..749f58c --- /dev/null +++ b/app/views/members/admin_index.ctp @@ -0,0 +1,60 @@ +
+

+

+counter(array( +'format' => __('Page %page% of %pages%, showing %current% records out of %count% total, starting on record %start%, ending on %end%', true) +)); +?>

+ + + + + + + + + + + > + + + + + + + + +
sort('id');?>sort('username');?>sort('password');?>sort('uid');?>sort('created_at');?>
+ + + + + + + + + + + link(__('View', true), array('action' => 'view', $member['Member']['id'])); ?> + link(__('Edit', true), array('action' => 'edit', $member['Member']['id'])); ?> + link(__('Delete', true), array('action' => 'delete', $member['Member']['id']), null, sprintf(__('Are you sure you want to delete # %s?', true), $member['Member']['id'])); ?> +
+
+
+ prev('<< '.__('previous', true), array(), null, array('class'=>'disabled'));?> + | numbers();?> + next(__('next', true).' >>', array(), null, array('class' => 'disabled'));?> +
+
+ +
diff --git a/app/views/members/admin_view.ctp b/app/views/members/admin_view.ctp new file mode 100644 index 0000000..699246d --- /dev/null +++ b/app/views/members/admin_view.ctp @@ -0,0 +1,38 @@ +
+

+
+ > + > + +   + + > + > + +   + + > + > + +   + + > + > + +   + + > + > + +   + +
+
+
+ +
diff --git a/app/views/members/edit.ctp b/app/views/members/edit.ctp new file mode 100644 index 0000000..33ffdb0 --- /dev/null +++ b/app/views/members/edit.ctp @@ -0,0 +1,20 @@ +
+create('Member');?> +
+ + input('id'); + echo $form->input('username'); + echo $form->input('password'); + echo $form->input('uid'); + echo $form->input('created_at'); + ?> +
+end('Submit');?> +
+
+ +
diff --git a/app/views/members/index.ctp b/app/views/members/index.ctp new file mode 100644 index 0000000..749f58c --- /dev/null +++ b/app/views/members/index.ctp @@ -0,0 +1,60 @@ +
+

+

+counter(array( +'format' => __('Page %page% of %pages%, showing %current% records out of %count% total, starting on record %start%, ending on %end%', true) +)); +?>

+ + + + + + + + + + + > + + + + + + + + +
sort('id');?>sort('username');?>sort('password');?>sort('uid');?>sort('created_at');?>
+ + + + + + + + + + + link(__('View', true), array('action' => 'view', $member['Member']['id'])); ?> + link(__('Edit', true), array('action' => 'edit', $member['Member']['id'])); ?> + link(__('Delete', true), array('action' => 'delete', $member['Member']['id']), null, sprintf(__('Are you sure you want to delete # %s?', true), $member['Member']['id'])); ?> +
+
+
+ prev('<< '.__('previous', true), array(), null, array('class'=>'disabled'));?> + | numbers();?> + next(__('next', true).' >>', array(), null, array('class' => 'disabled'));?> +
+
+ +
diff --git a/app/views/members/view.ctp b/app/views/members/view.ctp new file mode 100644 index 0000000..699246d --- /dev/null +++ b/app/views/members/view.ctp @@ -0,0 +1,38 @@ +
+

+
+ > + > + +   + + > + > + +   + + > + > + +   + + > + > + +   + + > + > + +   + +
+
+
+ +
diff --git a/app/views/notes/add.ctp b/app/views/notes/add.ctp new file mode 100644 index 0000000..c14039e --- /dev/null +++ b/app/views/notes/add.ctp @@ -0,0 +1,22 @@ +
+create('Note');?> +
+ + input('member_id'); + echo $form->input('lat'); + echo $form->input('lon'); + echo $form->input('title'); + echo $form->input('body'); + echo $form->input('public_flag'); + ?> +
+end('Submit');?> +
+
+ +
diff --git a/app/views/notes/admin_add.ctp b/app/views/notes/admin_add.ctp new file mode 100644 index 0000000..c14039e --- /dev/null +++ b/app/views/notes/admin_add.ctp @@ -0,0 +1,22 @@ +
+create('Note');?> +
+ + input('member_id'); + echo $form->input('lat'); + echo $form->input('lon'); + echo $form->input('title'); + echo $form->input('body'); + echo $form->input('public_flag'); + ?> +
+end('Submit');?> +
+
+ +
diff --git a/app/views/notes/admin_edit.ctp b/app/views/notes/admin_edit.ctp new file mode 100644 index 0000000..0532562 --- /dev/null +++ b/app/views/notes/admin_edit.ctp @@ -0,0 +1,24 @@ +
+create('Note');?> +
+ + 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'); + ?> +
+end('Submit');?> +
+
+ +
diff --git a/app/views/notes/admin_index.ctp b/app/views/notes/admin_index.ctp new file mode 100644 index 0000000..ccc6ec9 --- /dev/null +++ b/app/views/notes/admin_index.ctp @@ -0,0 +1,78 @@ +
+

+

+counter(array( +'format' => __('Page %page% of %pages%, showing %current% records out of %count% total, starting on record %start%, ending on %end%', true) +)); +?>

+ + + + + + + + + + + + + + + > + + + + + + + + + + + + +
sort('id');?>sort('member_id');?>sort('lat');?>sort('lon');?>sort('title');?>sort('body');?>sort('public_flag');?>sort('created');?>sort('modified');?>
+ + + link($note['Member']['id'], array('controller' => 'members', 'action' => 'view', $note['Member']['id'])); ?> + + + + + + + + + + + + + + + + link(__('View', true), array('action' => 'view', $note['Note']['id'])); ?> + link(__('Edit', true), array('action' => 'edit', $note['Note']['id'])); ?> + link(__('Delete', true), array('action' => 'delete', $note['Note']['id']), null, sprintf(__('Are you sure you want to delete # %s?', true), $note['Note']['id'])); ?> +
+
+
+ prev('<< '.__('previous', true), array(), null, array('class'=>'disabled'));?> + | numbers();?> + next(__('next', true).' >>', array(), null, array('class' => 'disabled'));?> +
+
+ +
diff --git a/app/views/notes/admin_view.ctp b/app/views/notes/admin_view.ctp new file mode 100644 index 0000000..90e32c1 --- /dev/null +++ b/app/views/notes/admin_view.ctp @@ -0,0 +1,60 @@ +
+

+
+ > + > + +   + + > + > + link($note['Member']['id'], array('controller' => 'members', 'action' => 'view', $note['Member']['id'])); ?> +   + + > + > + +   + + > + > + +   + + > + > + +   + + > + > + +   + + > + > + +   + + > + > + +   + + > + > + +   + +
+
+
+ +
diff --git a/app/views/notes/edit.ctp b/app/views/notes/edit.ctp new file mode 100644 index 0000000..0532562 --- /dev/null +++ b/app/views/notes/edit.ctp @@ -0,0 +1,24 @@ +
+create('Note');?> +
+ + 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'); + ?> +
+end('Submit');?> +
+
+ +
diff --git a/app/views/notes/index.ctp b/app/views/notes/index.ctp new file mode 100644 index 0000000..ccc6ec9 --- /dev/null +++ b/app/views/notes/index.ctp @@ -0,0 +1,78 @@ +
+

+

+counter(array( +'format' => __('Page %page% of %pages%, showing %current% records out of %count% total, starting on record %start%, ending on %end%', true) +)); +?>

+ + + + + + + + + + + + + + + > + + + + + + + + + + + + +
sort('id');?>sort('member_id');?>sort('lat');?>sort('lon');?>sort('title');?>sort('body');?>sort('public_flag');?>sort('created');?>sort('modified');?>
+ + + link($note['Member']['id'], array('controller' => 'members', 'action' => 'view', $note['Member']['id'])); ?> + + + + + + + + + + + + + + + + link(__('View', true), array('action' => 'view', $note['Note']['id'])); ?> + link(__('Edit', true), array('action' => 'edit', $note['Note']['id'])); ?> + link(__('Delete', true), array('action' => 'delete', $note['Note']['id']), null, sprintf(__('Are you sure you want to delete # %s?', true), $note['Note']['id'])); ?> +
+
+
+ prev('<< '.__('previous', true), array(), null, array('class'=>'disabled'));?> + | numbers();?> + next(__('next', true).' >>', array(), null, array('class' => 'disabled'));?> +
+
+ +
diff --git a/app/views/notes/view.ctp b/app/views/notes/view.ctp new file mode 100644 index 0000000..90e32c1 --- /dev/null +++ b/app/views/notes/view.ctp @@ -0,0 +1,60 @@ +
+

+
+ > + > + +   + + > + > + link($note['Member']['id'], array('controller' => 'members', 'action' => 'view', $note['Member']['id'])); ?> +   + + > + > + +   + + > + > + +   + + > + > + +   + + > + > + +   + + > + > + +   + + > + > + +   + + > + > + +   + +
+
+
+ +