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) {
<div class="characterPictures view">
-<h2><?php __('CharacterPicture');?></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 $characterPicture['CharacterPicture']['id']; ?>
-
- </dd>
- <dt<?php if ($i % 2 == 0) echo $class;?>><?php __('User'); ?></dt>
- <dd<?php if ($i++ % 2 == 0) echo $class;?>>
- <?php echo $html->link($characterPicture['User']['name'], array('controller' => 'users', 'action' => 'view', $characterPicture['User']['id'])); ?>
-
- </dd>
- <dt<?php if ($i % 2 == 0) echo $class;?>><?php __('Character'); ?></dt>
- <dd<?php if ($i++ % 2 == 0) echo $class;?>>
- <?php echo $html->link($characterPicture['Character']['name'], array('controller' => 'characters', 'action' => 'view', $characterPicture['Character']['id'])); ?>
-
- </dd>
- <dt<?php if ($i % 2 == 0) echo $class;?>><?php __('Public Flag'); ?></dt>
- <dd<?php if ($i++ % 2 == 0) echo $class;?>>
- <?php echo $characterPicture['CharacterPicture']['public_flag']; ?>
-
- </dd>
- <dt<?php if ($i % 2 == 0) echo $class;?>><?php __('Created'); ?></dt>
- <dd<?php if ($i++ % 2 == 0) echo $class;?>>
- <?php echo $characterPicture['CharacterPicture']['created']; ?>
-
- </dd>
- <dt<?php if ($i % 2 == 0) echo $class;?>><?php __('Modified'); ?></dt>
- <dd<?php if ($i++ % 2 == 0) echo $class;?>>
- <?php echo $characterPicture['CharacterPicture']['modified']; ?>
-
- </dd>
- </dl>
+<h2><?php echo $html->link($characterPicture['Character']['name'].__("'s Picture", true), array('controller' => 'characters', 'action' => 'view', $characterPicture['Character']['id']));?></h2>
+
+<p>
+<?php if ($characterPicture['Attachment'][0]['alternative']):?>
+<div class="title"><?php echo $characterPicture['Attachment'][0]['alternative']; ?></div>
+<?php endif; ?>
+<div class="image">
+<?php
+ echo $this->renderElement('character_picture_image', array(
+ 'attachment' => $characterPicture['Attachment'][0],
+ 'options' => array(
+ 'previewVersion' => 'orig',
+ 'class' => 'shadow',
+ )
+ ));
+ ?>
</div>
+<?php if ($isOwner): ?>
+<div><?php echo $select->get_i18n_public_flag($characterPicture['CharacterPicture']['public_flag'], $public_flags); ?></div>
+<?php endif; ?>
+</p>
+
+<p>
<div class="actions">
<ul>
- <li><?php echo $html->link(__('Edit CharacterPicture', true), array('action' => 'edit', $characterPicture['CharacterPicture']['id'])); ?> </li>
- <li><?php echo $html->link(__('Delete CharacterPicture', true), array('action' => 'delete', $characterPicture['CharacterPicture']['id']), null, sprintf(__('Are you sure you want to delete # %s?', true), $characterPicture['CharacterPicture']['id'])); ?> </li>
- <li><?php echo $html->link(__('List CharacterPictures', true), array('action' => 'index')); ?> </li>
- <li><?php echo $html->link(__('New CharacterPicture', true), array('action' => 'add')); ?> </li>
- <li><?php echo $html->link(__('List Users', true), array('controller' => 'users', 'action' => 'index')); ?> </li>
- <li><?php echo $html->link(__('New User', true), array('controller' => 'users', 'action' => 'add')); ?> </li>
- <li><?php echo $html->link(__('List Characters', true), array('controller' => 'characters', 'action' => 'index')); ?> </li>
- <li><?php echo $html->link(__('New Character', true), array('controller' => 'characters', 'action' => 'add')); ?> </li>
- <li><?php echo $html->link(__('List Attachments', true), array('controller' => 'attachments', 'action' => 'index')); ?> </li>
- <li><?php echo $html->link(__('New Attachment', true), array('controller' => 'attachments', 'action' => 'add')); ?> </li>
+ <li><?php echo $html->link(__('Edit', true), array('action' => 'edit', $characterPicture['CharacterPicture']['id'])); ?> </li>
+ <li><?php echo $html->link(__('Delete', true), array('action' => 'delete', $characterPicture['CharacterPicture']['id']), null, __('Are you sure you want to delete it?', true)); ?> </li>
+ <li><?php echo $html->link(__('List Pictures', true), array('action' => 'index', $characterPicture['Character']['id'])); ?> </li>
+ <li><?php echo $html->link(__('New Picture', true), array('action' => 'add')); ?> </li>
</ul>
</div>
-<div class="related">
- <h3><?php __('Related Attachments');?></h3>
- <?php if (!empty($characterPicture['Attachment'])):?>
- <table cellpadding = "0" cellspacing = "0">
- <tr>
- <th><?php __('Id'); ?></th>
- <th><?php __('User Id'); ?></th>
- <th><?php __('Model'); ?></th>
- <th><?php __('Foreign Key'); ?></th>
- <th><?php __('Dirname'); ?></th>
- <th><?php __('Basename'); ?></th>
- <th><?php __('Checksum'); ?></th>
- <th><?php __('Size'); ?></th>
- <th><?php __('Alternative'); ?></th>
- <th><?php __('Group'); ?></th>
- <th><?php __('Created'); ?></th>
- <th><?php __('Modified'); ?></th>
- <th class="actions"><?php __('Actions');?></th>
- </tr>
- <?php
- $i = 0;
- foreach ($characterPicture['Attachment'] as $attachment):
- $class = null;
- if ($i++ % 2 == 0) {
- $class = ' class="altrow"';
- }
- ?>
- <tr<?php echo $class;?>>
- <td><?php echo $attachment['id'];?></td>
- <td><?php echo $attachment['user_id'];?></td>
- <td><?php echo $attachment['model'];?></td>
- <td><?php echo $attachment['foreign_key'];?></td>
- <td><?php echo $attachment['dirname'];?></td>
- <td><?php echo $attachment['basename'];?></td>
- <td><?php echo $attachment['checksum'];?></td>
- <td><?php echo $attachment['size'];?></td>
- <td><?php echo $attachment['alternative'];?></td>
- <td><?php echo $attachment['group'];?></td>
- <td><?php echo $attachment['created'];?></td>
- <td><?php echo $attachment['modified'];?></td>
- <td class="actions">
- <?php echo $html->link(__('View', true), array('controller' => 'attachments', 'action' => 'view', $attachment['id'])); ?>
- <?php echo $html->link(__('Edit', true), array('controller' => 'attachments', 'action' => 'edit', $attachment['id'])); ?>
- <?php echo $html->link(__('Delete', true), array('controller' => 'attachments', 'action' => 'delete', $attachment['id']), null, sprintf(__('Are you sure you want to delete # %s?', true), $attachment['id'])); ?>
- </td>
- </tr>
- <?php endforeach; ?>
- </table>
-<?php endif; ?>
-
- <div class="actions">
- <ul>
- <li><?php echo $html->link(__('New Attachment', true), array('controller' => 'attachments', 'action' => 'add'));?> </li>
- </ul>
- </div>
-</div>
+</p>
\ No newline at end of file