Skip to content

Commit

Permalink
Merge pull request #6 from s-nakajima/master
Browse files Browse the repository at this point in the history
アバター処理の追加
  • Loading branch information
s-nakajima committed Nov 20, 2015
2 parents 8192253 + 1c636d1 commit e27c34d
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 2 deletions.
12 changes: 10 additions & 2 deletions Controller/Component/PrivateSpaceComponent.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,21 @@ class PrivateSpaceComponent extends Component {
* @return bool
*/
public function accessCheck(Controller $controller) {
if ($controller->request->params['action'] === 'download') {
return true;
}

if (! Current::read('RolesRoomsUser.user_id') ||
Current::read('RolesRoomsUser.user_id') !== Current::read('User.id') ||
! Current::read('User.UserRoleSetting.use_private_room')) {
Current::read('RolesRoomsUser.user_id') !== Current::read('User.id')) {

return false;
}

if ($controller->request->params['plugin'] !== Current::PLUGIN_USERS &&
! Current::read('User.UserRoleSetting.use_private_room')) {
return false;
}

if (! $controller->Session->check('roomAccesse.' . Current::read('RolesRoomsUser.id'))) {
$RolesRoomsUser = ClassRegistry::init('Rooms.RolesRoomsUser');
$RolesRoomsUser->saveAccessed(Current::read('RolesRoomsUser.id'));
Expand Down
52 changes: 52 additions & 0 deletions Model/Behavior/PrivateSpaceBehavior.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,56 @@
*/
class PrivateSpaceBehavior extends ModelBehavior {

/**
* Setup this behavior with the specified configuration settings.
*
* @param Model $model Model using this behavior
* @param array $config Configuration settings for $model
* @return void
*/
public function setup(Model $model, $config = array()) {
parent::setup($model, $config);

$model->loadModels([
'RolesRoomsUser' => 'Rooms.RolesRoomsUser',
'Room' => 'Rooms.Room',
'Space' => 'Rooms.Space',
]);
}

/**
* ルームデータ取得
*
* @param Model $model ビヘイビア呼び出し元モデル
* @param int $userId ユーザID
* @return array ルームデータ
*/
public function getPrivateRoomByUserId(Model $model, $userId) {
$result = $model->Room->find('first', array(
'recursive' => -1,
'fields' => array(
$model->Room->alias . '.*',
$model->RolesRoomsUser->alias . '.*',
),
'conditions' => array(
$model->Room->alias . '.space_id' => Space::PRIVATE_SPACE_ID,
$model->Room->alias . '.page_id_top NOT' => null,
//$model->Room->alias . '.root_id' => $rootIds,
),
'joins' => array(
array(
'table' => $model->RolesRoomsUser->table,
'alias' => $model->RolesRoomsUser->alias,
'type' => 'INNER',
'conditions' => array(
$model->RolesRoomsUser->alias . '.room_id' . ' = ' . $model->Room->alias . ' .id',
$model->RolesRoomsUser->alias . '.user_id' => $userId,
),
),
),
));

return $result;
}

}

0 comments on commit e27c34d

Please sign in to comment.