From: Cake Date: Fri, 12 Mar 2010 05:16:56 +0000 (+0900) Subject: CharacterPicture View表示変更 X-Git-Tag: version-alpha~128 X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=d0bf752f9949afa301ed70dd1dd822fe88bbc07f;p=trpgtools-onweb%2Fcake-frame.git CharacterPicture View表示変更 --- diff --git a/app/controllers/app_controller.php b/app/controllers/app_controller.php index 46f6091..26936b9 100644 --- a/app/controllers/app_controller.php +++ b/app/controllers/app_controller.php @@ -139,6 +139,18 @@ class AppController extends Controller { return $this->{$this->modelClass}->public_flag; } + function check_public_flag($data, $key = null) + { + if ($this->isOwner($data, $this->user_id)) { + return true; + } + + if ($data['public_flag'] == 'public') { + return true; + } + + return false; + } /* isOwner */ function isOwner($data, $user_id) diff --git a/app/controllers/character_pictures_controller.php b/app/controllers/character_pictures_controller.php index c8be50e..4dd6464 100644 --- a/app/controllers/character_pictures_controller.php +++ b/app/controllers/character_pictures_controller.php @@ -94,10 +94,45 @@ class CharacterPicturesController extends AppController { function view($id = null) { if (!$id) { + $this->Session->setFlash(__('Invalid Id.', true)); + $this->redirect(array('action'=>'index')); + } + + $character_picture = $this->CharacterPicture->find('first', array( + 'conditions' => array( + 'CharacterPicture.id' => $id, + ), + 'fields' => array( + 'CharacterPicture.id', + 'CharacterPicture.public_flag', + 'CharacterPicture.created', + ), + 'contain' => array( + 'Character', + 'Attachment', + ), + 'recursive' => 1, + )); + + if (empty($character_picture)) { $this->Session->setFlash(__('Invalid CharacterPicture.', true)); $this->redirect(array('action'=>'index')); } - $this->set('characterPicture', $this->CharacterPicture->read(null, $id)); + + // public_flagチェック + if (!$this->check_public_flag($character_picture['Character'])) { + $this->Session->setFlash(__('No Permission.', true)); + $this->redirect(array('controller' => 'character', 'action'=>'index')); + } + if (!$this->check_public_flag($character_picture['CharacterPicture'])) { + $this->Session->setFlash(__('No Permission.', true)); + $this->redirect(array('action'=>'view', $character_picture['Character']['id'])); + } + + $isOwner = $this->isOwner($character_picture['CharacterPicture'], $this->user_id); + $this->set('isOwner', $isOwner); + + $this->set('characterPicture', $character_picture); } function add($character_id = null) { diff --git a/app/models/character_picture.php b/app/models/character_picture.php index 541ceda..e15c9b8 100644 --- a/app/models/character_picture.php +++ b/app/models/character_picture.php @@ -44,7 +44,12 @@ class CharacterPicture extends AppModel { 'className' => 'Character', 'foreignKey' => 'character_id', 'conditions' => '', - 'fields' => '', + 'fields' => array( + 'Character.id', + 'Character.name', + 'Character.main_picture', + 'Character.full_length', + ), 'order' => '' ) ); diff --git a/app/views/character_pictures/view.ctp b/app/views/character_pictures/view.ctp index fa35fc3..d942218 100644 --- a/app/views/character_pictures/view.ctp +++ b/app/views/character_pictures/view.ctp @@ -1,105 +1,33 @@
-

-
- > - > - -   - - > - > - link($characterPicture['User']['name'], array('controller' => 'users', 'action' => 'view', $characterPicture['User']['id'])); ?> -   - - > - > - link($characterPicture['Character']['name'], array('controller' => 'characters', 'action' => 'view', $characterPicture['Character']['id'])); ?> -   - - > - > - -   - - > - > - -   - - > - > - -   - -
+

link($characterPicture['Character']['name'].__("'s Picture", true), array('controller' => 'characters', 'action' => 'view', $characterPicture['Character']['id']));?>

+ +

+ +

+ +
+renderElement('character_picture_image', array( + 'attachment' => $characterPicture['Attachment'][0], + 'options' => array( + 'previewVersion' => 'orig', + 'class' => 'shadow', + ) + )); + ?>
+ +
get_i18n_public_flag($characterPicture['CharacterPicture']['public_flag'], $public_flags); ?>
+ +

+ +

    -
  • link(__('Edit CharacterPicture', true), array('action' => 'edit', $characterPicture['CharacterPicture']['id'])); ?>
  • -
  • link(__('Delete CharacterPicture', true), array('action' => 'delete', $characterPicture['CharacterPicture']['id']), null, sprintf(__('Are you sure you want to delete # %s?', true), $characterPicture['CharacterPicture']['id'])); ?>
  • -
  • link(__('List CharacterPictures', true), array('action' => 'index')); ?>
  • -
  • link(__('New CharacterPicture', true), array('action' => 'add')); ?>
  • -
  • link(__('List Users', true), array('controller' => 'users', 'action' => 'index')); ?>
  • -
  • link(__('New User', true), array('controller' => 'users', 'action' => 'add')); ?>
  • -
  • link(__('List Characters', true), array('controller' => 'characters', 'action' => 'index')); ?>
  • -
  • link(__('New Character', true), array('controller' => 'characters', 'action' => 'add')); ?>
  • -
  • link(__('List Attachments', true), array('controller' => 'attachments', 'action' => 'index')); ?>
  • -
  • link(__('New Attachment', true), array('controller' => 'attachments', 'action' => 'add')); ?>
  • +
  • link(__('Edit', true), array('action' => 'edit', $characterPicture['CharacterPicture']['id'])); ?>
  • +
  • link(__('Delete', true), array('action' => 'delete', $characterPicture['CharacterPicture']['id']), null, __('Are you sure you want to delete it?', true)); ?>
  • +
  • link(__('List Pictures', true), array('action' => 'index', $characterPicture['Character']['id'])); ?>
  • +
  • link(__('New Picture', true), array('action' => 'add')); ?>
- +

\ No newline at end of file diff --git a/app/views/elements/character_picture.ctp b/app/views/elements/character_picture.ctp index 97245ec..d13228f 100644 --- a/app/views/elements/character_picture.ctp +++ b/app/views/elements/character_picture.ctp @@ -114,4 +114,3 @@ if (!isset($isAdmin)) {
-