OSDN Git Service

profile_type判断をhelper処理共有に変更
authorCake <cake_67@users.sourceforge.jp>
Tue, 26 Jan 2010 08:12:02 +0000 (17:12 +0900)
committerCake <cake_67@users.sourceforge.jp>
Tue, 26 Jan 2010 08:44:49 +0000 (17:44 +0900)
app/controllers/profile_selects_controller.php
app/controllers/profiles_controller.php

index e3234b8..e87d279 100644 (file)
@@ -123,7 +123,11 @@ class ProfileSelectsController extends AppController {
                        $this->redirect(array('controller' => 'systems', 'action'=>'admin_index'));
                }
 
-               if ($profile['Profile']['profile_type'] != 'select' && $profile['Profile']['profile_type'] != 'm-select') {
+               App::import('Helper', 'Profiledisp');
+               $Profiledisp = new ProfiledispHelper;
+               $Profiledisp->set_profile_type4view($profile['Profile']);
+
+               if (!$Profiledisp->profile_type['is_select'] && !$Profiledisp->profile_type['is_checkbox']) {
                        $this->Session->setFlash(__('Profile type is not valid.', true));
                        $this->redirect(array('controller' => 'profiles', 'action'=>'admin_edit', $profile['Profile']['id']));
                }
index f591dee..cc5b86a 100644 (file)
@@ -89,13 +89,19 @@ class ProfilesController extends AppController {
                                        $this->Session->setFlash(__('The Profile has been saved', true));
 
                                        // profile_tablesの削除
-                                       if ($profile['Profile']['profile_type'] == 'table') {
+                                       App::import('Helper', 'Profiledisp');
+                                       $Profiledisp = new ProfiledispHelper;
+                                       $Profiledisp->set_profile_type4view($profile['Profile']);
+                                       if ($Profiledisp->profile_type['is_table']) {
                                                $this->Profile->ProfileTable->deleteAll(array('ProfileTable.profile_id' => $id), true);
                                        }
 
                                        // profile_selectsの削除
-                                       if (in_array($profile['Profile']['profile_type'], array('select', 'm-select')) && !in_array($this->data['Profile']['profile_type'], array('select', 'm-select'))) {
-                                               $this->Profile->ProfileSelect->deleteAll(array('ProfileSelect.profile_id' => $id), true);
+                                       if ($Profiledisp->profile_type['is_select']) {
+                                               $Profiledisp->set_profile_type4view($this->data['Profile']);
+                                               if (!$Profiledisp->profile_type['is_select']) {
+                                                       $this->Profile->ProfileSelect->deleteAll(array('ProfileSelect.profile_id' => $id), true);
+                                               }
                                        }
                                        $this->redirect(array('controller' => 'systems', 'action'=>'admin_view', $profile['Profile']['system_id']));
                                } else {