'Form',
'Javascript',
'Settings',
+ 'Media.Medium',
'Token'
);
$this->AuthPlus->actionPath = 'controllers/';
$this->AuthPlus->authorize = 'crud';
// 認証済みユーザ情報のセット
- $this->user = $this->AuthPlus->user();
- $this->user_id = $this->user['User']['id'];
+ $this->user_id = $this->AuthPlus->user('id');
+ $user = $this->getUser($this->user_id);
+ if (!empty($user)) {
+ $this->user = $user;
+ }
+
if (in_array($this->AuthPlus->user('group_id'), array(1,2,3))) {
$this->isAdministrator = true;
}
parent::beforeRender();
}
+
+
+ /* ユーザ情報取得 */
+ function getUser($id) {
+ if (!$id) {
+ return array();
+ }
+
+ // Media.Attachmentから関連ファイルの取得
+ $this->User->hasMany['Attachment']['conditions']['foreign_key'] = $id;
+ $user = $this->User->find('first', array(
+ 'conditions' => array('User.id' => $id),
+ 'fields' => array(
+ 'User.id',
+ 'User.group_id',
+ 'User.name',
+ 'User.pcmail',
+ 'User.mobile_mail',
+ 'User.modified',
+ ),
+ 'recursive' => 1,
+ 'contain' => array(
+ 'Attachment',
+ ),
+ ));
+
+ return $user;
+ }
+
}
'host' => gethostbyaddr($_SERVER["REMOTE_ADDR"]),
)
);
- $this->set('target_user', $this->user);
+
+ $user = $this->getUser($this->User->id);
+ $this->set('target_user', $user);
}
function _view($id) {
}
}
- /* ユーザ情報取得 */
- function getUser($id) {
- if (!$id) {
- return $this->user;
- }
- $user = $this->User->read(null, $id);
- if (!$user['User']) {
- $this->Session->setFlash(__('Invalid User.', true));
- return $this->user;
- }
- return $user;
- }
-
}
'className' => 'Media.Attachment',
'foreignKey' => 'foreign_key',
'conditions' => array('model' => 'User'),
+ 'fields' => array(
+ 'Attachment.id',
+ 'Attachment.dirname',
+ 'Attachment.basename',
+ 'Attachment.alternative',
+ 'Attachment.group',
+ 'Attachment.checksum',
+ ),
)
);
<div class="users view">
<h2><?php echo $target_user['User']['name']; ?><?php __("'s ");?><?php __('Home');?></h2>
- <dl><?php $i = 0; $class = ' class="altrow"';?>
- <dt<?php if ($i % 2 == 0) echo $class;?>><?php __('Name'); ?></dt>
- <dd<?php if ($i++ % 2 == 0) echo $class;?>>
- <?php echo $target_user['User']['name']; ?>
-
- </dd>
- <dt<?php if ($i % 2 == 0) echo $class;?>><?php __('Created'); ?></dt>
- <dd<?php if ($i++ % 2 == 0) echo $class;?>>
- <?php echo $target_user['User']['created']; ?>
-
- </dd>
- <dt<?php if ($i % 2 == 0) echo $class;?>><?php __('Modified'); ?></dt>
- <dd<?php if ($i++ % 2 == 0) echo $class;?>>
- <?php echo $target_user['User']['modified']; ?>
-
- </dd>
- </dl>
+<dl>
+<dt><?php __('Name'); ?></dt>
+<dd>
+<?php echo $target_user['User']['name']; ?>
+</dd>
+<dt><?php __('Image'); ?></dt>
+<dd>
+<?php
+ if (isset($target_user['Attachment'][0])) {
+ $img_name = isset($target_user['Attachment'][0]['alternative']) ? $target_user['Attachment'][0]['alternative'] : $target_user['Attachment'][0]['basename'];
+
+ echo $medium->embed($medium->file('filter/s', $target_user['Attachment'][0]));
+
+ } else {
+ echo " ";
+ }
+?>
+</dd>
+<dt><?php __('Modified'); ?></dt>
+<dd>
+<?php echo $target_user['User']['modified']; ?>
+</dd>
+</dl>
</div>
<?php echo $target_user['User']['group_id']; ?>
</dd>
+<dt<?php if ($i % 2 == 0) echo $class;?>><?php __('Image'); ?></dt>
+<dd<?php if ($i++ % 2 == 0) echo $class;?>>
+<?php
+ if (isset($target_user['Attachment'][0])) {
+ $img_name = isset($target_user['Attachment'][0]['alternative']) ? $target_user['Attachment'][0]['alternative'] : $target_user['Attachment'][0]['basename'];
+
+ echo $medium->embed($medium->file('filter/s', $target_user['Attachment'][0]));
+
+ } else {
+ echo " ";
+ }
+?>
+</dd>
<dt<?php if ($i % 2 == 0) echo $class;?>><?php __('Name'); ?></dt>
<dd<?php if ($i++ % 2 == 0) echo $class;?>>
<?php echo $target_user['User']['name']; ?>