OSDN Git Service

管理アカウントの設定追加
authorCake <cake_67@users.sourceforge.jp>
Sun, 18 Apr 2010 14:05:36 +0000 (23:05 +0900)
committerCake <cake_67@users.sourceforge.jp>
Sun, 18 Apr 2010 14:05:36 +0000 (23:05 +0900)
app/config/sql/install/insert_data.sql
app/models/app_model.php
app/plugins/install/controllers/install_controller.php
app/plugins/install/views/install/regist.ctp [new file with mode: 0644]

index f99a22f..93026fe 100644 (file)
@@ -17,15 +17,14 @@ UNLOCK TABLES;
 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);
+(1,NULL,'Group',1,'Group::1',1,2),
+(2,NULL,'Group',2,'Group::2',3,4),
+(3,NULL,'Group',3,'Group::3',5,6),
+(4,NULL,'Group',4,'Group::4',7,8),
+(5,NULL,'Group',5,'Group::5',9,10),
+(6,NULL,'Group',6,'Group::6',11,12),
+(7,NULL,'Group',7,'Group::7',13,14),
+(8,NULL,'Group',8,'Group::8',15,16);
 /*!40000 ALTER TABLE `aros` ENABLE KEYS */;
 UNLOCK TABLES;
 
index cdee3c0..173bc7e 100644 (file)
@@ -45,6 +45,7 @@ class AppModel extends Model {
                        'between' => __('Between %2$d and %3$d characters.', true),
                        'betweenWrapper' => __('Too short or Too long.', true),
                        'boolean' => __('Incorrect value.', true),
+                       'compare2fields' => __('Input same as avobe.', true),
                        'comparison' => __('Please input number %2$s %3$d.', true),
                        'isUnique' => __('It was already registed.', true),
                        'isUniqueKeyname4profile' => __('It was already registed.', true),
index a91d675..f2fa0e9 100644 (file)
@@ -170,21 +170,6 @@ class InstallController extends InstallAppController {
                 $this->__executeSQLScript($db, CONFIGS.'sql'.DS.'install'.DS.'create_table.sql');
                 $this->__executeSQLScript($db, CONFIGS.'sql'.DS.'install'.DS.'insert_data.sql');
 
-                $this->redirect(array('action' => 'finish'));
-                exit();
-            }
-        }
-    }
-/**
- * Step 3: finish
- *
- * Remind the user to delete 'install' plugin.
- *
- * @return void
- */
-    function finish() {
-        $this->pageTitle = __('Installation completed successfully', true);
-
                // set new salt and seed value
                $File =& new File(CONFIGS . 'core.php');
                if (!class_exists('Security')) {
@@ -199,6 +184,65 @@ class InstallController extends InstallAppController {
                        $this->Session->setFlash(__('Could not set Security.salt of "app/config/core.php" files. PLEASE edit Security.salt manually.', true));
                }
 
+               $this->redirect(array('action' => 'regist'));
+            }
+        }
+    }
+/**
+ * Step 3: regist
+ *
+ * Regist Administrator Account and come informations of the site.
+ *
+ * @return void
+ */
+    function regist() {
+        $this->pageTitle = __('Initial registration for the Site.', true);
+
+       if (!empty($this->data)) {
+
+               $this->User = CorePlus::set_model('User');
+               $this->User->set($this->data);
+               if ($this->User->validates()) {
+
+                       // SiteConfig
+                       $this->SiteConfig = CorePlus::set_model('SiteConfig');
+
+                       $siteConfig['SiteConfig'] = array(
+                               'key_name' => 'Site.siteName',
+                               'value' => $this->data['SiteConfig']['siteName']
+                       );
+                       unset($this->data['SiteConfig']['siteName']);
+
+                       $this->SiteConfig->save($siteConfig, array('fieldList' => $this->SiteConfig->fields['add']));
+
+                       // Set Administrator
+                       $this->data['User']['group_id'] = Configure::read('Group.admin');
+
+                       App::import('Component', 'Auth');
+                       $this->Auth = new AuthComponent;
+                       $this->data['User']['password'] = $this->Auth->password($this->data['User']['password1']);
+
+                       if ($this->User->save($this->data, array('fieldList' => $this->User->fields['add']))) {
+                       $this->redirect(array('action' => 'finish'));
+                       } else {
+                               $this->Session->setFlash(__('Initial registrations could not be saves.', true));
+                       }
+               }
+       }
+
+       $this->set('idLength', Configure::read('User.UserId.Length'));
+       $this->set('passwordLength', Configure::read('User.Password.Length'));
+
+    }
+/**
+ * Step 4: finish
+ *
+ * Remind the user to delete 'install' plugin.
+ *
+ * @return void
+ */
+    function finish() {
+        $this->pageTitle = __('Installation completed successfully', true);
 
 /* Delete method killed (because it depending on Permission)
         if (isset($this->params['named']['delete'])) {
diff --git a/app/plugins/install/views/install/regist.ctp b/app/plugins/install/views/install/regist.ctp
new file mode 100644 (file)
index 0000000..0e6b0e8
--- /dev/null
@@ -0,0 +1,91 @@
+<div class="install form">
+<h2><?php echo $this->pageTitle; ?></h2>
+<p><?php __('Registration of some Initial information for the site.') ?></p>
+
+<p>
+<?php
+       echo $form->create('Install', array(
+               'url' => array('plugin' => 'install', 'controller' => 'install', 'action' => 'regist')
+       ));
+?>
+
+<p>
+<?php
+       $name = 'Administrator';
+       if (isset($this->data['User']['name'])) {
+               $name = $this->data['User']['name'];
+       }
+       echo $form->input('User.name', array(
+               'label' => __('Name of the Administrator', true),
+               'value' => $name,
+               'after' => $html->div('required', 
+                       __(' * required', true)
+               ),
+       ));
+?>
+</p>
+<p>
+<?php
+       $username = 'admin';
+       if (isset($this->data['User']['username'])) {
+               $username = $this->data['User']['username'];
+       }
+       echo $form->input('User.username', array(
+               'label' => __('UserId of the Administrator', true),
+               'value' => $username,
+               'maxlength' => $idLength['max'],
+               'after' => $html->tag('div',
+                       sprintf(__('Between %d to %d characters', true), $idLength['min'], $idLength['max']),
+                       array('class' => 'attention')
+               ).
+               $html->div('required', 
+                       __(' * required', true)
+               ),
+       ));
+?>
+</p>
+<p>
+<?php
+       echo $form->input('User.password1', array(
+               'label' => 'Password of the Administrator',
+               'type' => 'password',
+               'value' => '',
+               'maxlength' => $passwordLength['max'],
+               'after' => $html->div('attention',
+               sprintf(__('Between %d to %d characters', true), $passwordLength['min'], $passwordLength['max'])
+               ).
+               $html->tag('div',
+'required', 
+                       __(' * required', true),
+                       array('class' => '')
+               )
+       ));
+       echo $form->input('User.password2', array(
+               'label' => 'Password of the Administrator[Confirm]',
+               'type' => 'password',
+               'value' => '',
+               'after' => $html->div('required', 
+                       __(' * required', true)
+               ),
+       ));
+?>
+</p>
+<p>
+<?php
+       $siteName = __('Chara-Shee!', true);
+       if (isset($this->data['SiteConfig']['siteName'])) {
+               $siteName = $this->data['SiteConfig']['siteName'];
+       }
+       echo $form->input('SiteConfig.siteName', array(
+               'label' => 'Site Name',
+               'value' => $siteName,
+       ));
+
+?>
+</p>
+<p>
+<?php
+       echo $form->end('Submit');
+?>
+</p>
+</div>