-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathPluginsRoom.php
More file actions
84 lines (75 loc) · 1.88 KB
/
PluginsRoom.php
File metadata and controls
84 lines (75 loc) · 1.88 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
<?php
/**
* PluginsRoom Model
*
* @author Noriko Arai <arai@nii.ac.jp>
* @author Shohei Nakajima <nakajimashouhei@gmail.com>
* @link http://www.netcommons.org NetCommons Project
* @license http://www.netcommons.org/license.txt NetCommons License
* @copyright Copyright 2014, NetCommons Project
*/
App::uses('AppModel', 'Model');
App::uses('Plugin', 'PluginManager.Model');
App::uses('Room', 'Rooms.Model');
App::uses('Space', 'Rooms.Model');
/**
* PluginsRoom Model
*
* @author Shohei Nakajima <nakajimashouhei@gmail.com>
* @package NetCommons\PluginManager\Model
*/
class PluginsRoom extends AppModel {
/**
* Behaviors
*
* @var array
*/
public $actsAs = array(
'PluginManager.PluginsRoom',
);
/**
* belongsTo associations
*
* @var array
*/
public $belongsTo = array(
'Plugin' => array(
'className' => 'PluginManager.Plugin',
'foreignKey' => false,
'type' => 'inner',
'conditions' => array('PluginsRoom.plugin_key = Plugin.key'),
),
'Room' => array(
'className' => 'Rooms.Room',
'foreignKey' => 'room_id',
'type' => 'inner',
),
);
/**
* Get plugin data from type and roomId, $langId
*
* @param int $roomId rooms.id
* @return mixed array or false
*/
public function getPlugins($roomId) {
//ルームIDのセット
if (! $roomId || ! is_numeric($roomId)) {
return array();
}
if ($roomId === Space::getRoomIdRoot(Space::WHOLE_SITE_ID)) {
$roomId = Space::getRoomIdRoot(Space::PUBLIC_SPACE_ID);
}
//plugins_languagesテーブルの取得
$this->belongsTo['Plugin']['conditions']['Plugin.language_id'] = Current::read('Language.id');
//pluginsテーブルの取得
$plugins = $this->find('all', array(
'conditions' => array(
'Plugin.type' => Plugin::PLUGIN_TYPE_FOR_FRAME,
//'Plugin.language_id' => Current::read('Language.id'),
'Room.id' => $roomId
),
'order' => $this->alias . '.id',
));
return $plugins;
}
}