OSDN Git Service

add ACS webapp, sql, htdocs
[acs/acs.git] / webapp / modules / Community / views / FolderSuccessView.class.php
1 <?php
2 /**
3  * ¥³¥ß¥å¥Ë¥Æ¥£¤Î¥Õ¥©¥ë¥Àɽ¼¨
4  *
5  * @author  kuwayama
6  * @version $Revision: 1.20 $ $Date: 2006/12/08 05:06:37 $
7  */
8 class FolderSuccessView extends BaseView
9 {
10         function execute() {
11                 $context = $this->getContext();
12                 $controller = $context->getController();
13                 $request =  $context->getRequest();
14                 $user = $context->getUser();
15                 
16                 $acs_user_info_row    = $user->getAttribute('acs_user_info_row');
17                 $target_community_row = $request->getAttribute('target_community_row');
18                 $community_folder_obj = $request->getAttribute('community_folder_obj');
19                 $target_folder_obj    = $community_folder_obj->get_folder_obj();
20                 $folder_obj_array     = $target_folder_obj->get_folder_obj_array();
21                 $file_obj_array       = $target_folder_obj->get_file_obj_array();
22
23                 $mode = $request->getAttribute('mode');
24                 if ($mode == 'group') {
25                         $file_detail_info_row_array = $request->getAttribute('file_detail_info_row_array');
26                         $file_contents_type_master_row_array_array = $request->getAttribute('file_contents_type_master_row_array_array');
27                 }
28
29
30                 // URL ¤ËÉղ乤ë target_community
31                 $target_community_info = '&community_id=' . $target_community_row['community_id'];
32                 // URL ¤ËÉղ乤ë target_folder
33                 $target_folder_info = '&folder_id=' . $target_folder_obj->get_folder_id();
34
35                 // ¥³¥ß¥å¥Ë¥Æ¥£¤ÎURL
36                 $community_top_page_url  = $this->getControllerPath('Community', 'Index');
37                 $community_top_page_url .= $target_community_info;
38
39                 // ¥Õ¥©¥ë¥À¥Ñ¥¹¾ðÊó
40                 $path_folder_obj_array = $community_folder_obj->get_path_folder_obj_array();
41                 // É½¼¨ÍѤ˲ù©
42                 $path_folder_obj_row_array = $this->make_display_folder_row_array($path_folder_obj_array, $target_community_info, $target_folder_info, $target_community_row, $mode, $controller);
43
44                 // ¥Õ¥©¥ë¥À¤Î¸ø³«ÈÏ°Ï
45                 $target_folder_open_level_row['name'] = $target_folder_obj->get_open_level_name();
46                 $target_folder_open_level_row['trusted_community_row_array'] = $this->make_display_trusted_community_row_array($target_folder_obj->get_trusted_community_row_array(), &$controller);
47
48                 // ¥³¥ß¥å¥Ë¥Æ¥£¥á¥ó¥Ð¤«¤É¤¦¤«
49                 $is_community_member = ACSCommunity::is_community_member($acs_user_info_row['user_community_id'],
50                                                                                                                                  $target_community_row['community_id']);
51
52                 // ¥ë¡¼¥È¥Õ¥©¥ë¥À¤«¤É¤¦¤«
53                 $is_root_folder = $target_folder_obj->get_is_root_folder();
54
55                 // ¥×¥Ã¥È¥Õ¥©¥ë¥À¤«¤É¤¦¤«
56                 $is_put_folder = $target_folder_obj->is_put_folder($target_community_row['community_id']);
57
58                 // ¥Õ¥¡¥¤¥ë¥¢¥Ã¥×¥í¡¼¥É URL
59                 $upload_file_url = $this->getControllerPath('Community',
60                                                                                                                   'UploadFile');
61                 $upload_file_url .= $target_community_info;
62                 $upload_file_url .= $target_folder_info;
63
64                 /* ¥Õ¥©¥ë¥À¡¦¥Õ¥¡¥¤¥ë°ìÍ÷ */
65                 // ¥Õ¥©¥ë¥À°ìÍ÷
66                 $display_folder_obj_array = $target_folder_obj->get_display_folder_obj_array_for_community($acs_user_info_row, $target_community_row);
67                 $folder_row_array = $this->make_display_folder_row_array($display_folder_obj_array, $target_community_info, $target_folder_info, $target_community_row, $mode, $controller);
68
69
70                 if ($mode == 'group') {
71                         // ¥°¥ë¡¼¥×ɽ¼¨ //
72                         // ¥Õ¥¡¥¤¥ë¥«¥Æ¥´¥ê¥Þ¥¹¥¿
73                         $file_category_master_array = ACSDB::get_master_array('file_category');
74
75                         // »ØÄê¤Ê¤·¤Î¥Õ¥¡¥¤¥ë¥«¥Æ¥´¥ê¥³¡¼¥É
76                         $default_file_category_code = array_search(ACSMsg::get_mst('file_category_master','D0000'), $file_category_master_array);
77
78                         $file_detail_info_row_array_array = array();
79                         foreach ($file_category_master_array as $file_category_code => $file_category_name) {
80                                 $file_detail_info_row_array_array[$file_category_code] = array();
81                                 $file_detail_info_row_array_array[$file_category_code]['file_category_code'] = $file_category_code;
82                                 $file_detail_info_row_array_array[$file_category_code]['file_category_name'] = $file_category_name;
83                                 $file_detail_info_row_array_array[$file_category_code]['file_detail_info_row_array'] = array();
84                         }
85
86
87                         // Action¤Ç¼èÆÀ¤·¤¿$file_detail_info_row¤ÎÇÛÎó¤ò¡¢¥Õ¥¡¥¤¥ë¼ïÎॳ¡¼¥É¤´¤È¤ÎÇÛÎó¤Ë¿¶¤êʬ¤±¤ë
88                         foreach ($file_detail_info_row_array as $file_detail_info_row) {
89                                 // ¥Õ¥¡¥¤¥ë¥«¥Æ¥´¥ê¥³¡¼¥É
90                                 $file_category_code = $file_detail_info_row['file_category_code'];
91
92                                 // ¥ê¥ó¥¯URL
93                                 $file_detail_info_row['link_url'] = $this->getControllerPath('Community', 'DownloadFile')
94                                          . $target_community_info . '&file_id=' . $file_detail_info_row['file_id'] . $target_folder_info;
95                                 // ¥Õ¥¡¥¤¥ë¾ÜºÙ¾ðÊóURL
96                                 $file_detail_info_row['file_detail_url'] = $this->getControllerPath('Community', 'FileDetail')
97                                          . $target_community_info . '&file_id=' . $file_detail_info_row['file_id'] . $target_folder_info;
98                                 // ¥µ¥à¥Í¥¤¥ë²èÁüURL
99                                 if ($file_category_master_array[$file_category_code] == ACSMsg::get_mst('file_category_master','D0003')) {
100                                         $file_detail_info_row['image_url'] = $this->getControllerPath('Community', 'DownloadFile')
101                                                  . $target_community_info . '&file_id=' . $file_detail_info_row['file_id'] . $target_folder_info . '&mode=thumb';
102                                 }
103
104                                 // push
105                                 if ($file_category_code == '') {
106                                         // ¥Õ¥¡¥¤¥ë¥«¥Æ¥´¥ê¥³¡¼¥É¤¬Â¸ºß¤·¤Ê¤¤¾ì¹ç¤Ï¥Ç¥Õ¥©¥ë¥È(»ØÄê¤Ê¤·)°·¤¤
107                                         $file_category_code = $default_file_category_code;
108                                 }
109                                 array_push($file_detail_info_row_array_array[$file_category_code]['file_detail_info_row_array'], $file_detail_info_row);
110                         }
111
112                         // ¥Õ¥©¥ë¥À Ä̾ïɽ¼¨URL
113                         $folder_url  = $this->getControllerPath('Community', 'Folder');
114                         $folder_url .= $target_community_info;
115                         $folder_url .= $target_folder_info;
116
117                 } else {
118                         // ¥Õ¥¡¥¤¥ë°ìÍ÷
119                         $file_row_array = array();
120                         foreach ($file_obj_array as $file_obj) {
121                                 $a_file = array();
122                                 $link_url = "";
123                                 $update_user_community_link_url = "";
124
125                                 $link_url  = $this->getControllerPath('Community',
126                                                                                                                         'DownloadFile');
127                                 $link_url .= $target_community_info;
128                                 $link_url .= "&file_id=" . $file_obj->get_file_id();
129                                 $link_url .= $target_folder_info;
130
131                                 $update_user_community_link_url  = $this->getControllerPath('User', 'Index');
132                                 $update_user_community_link_url .= "&id=" . $file_obj->get_update_user_community_id();
133
134                                 $a_file['name'] = $file_obj->get_display_file_name();
135                                 $a_file['file_id'] = $file_obj->get_file_id();
136                                 $a_file['link_url'] = $link_url;
137                                 $a_file['file_size'] = $file_obj->get_file_size_kb();
138                                 $a_file['update_user_community_name'] = $file_obj->get_update_user_community_name();
139                                 $a_file['update_user_community_link_url'] = $update_user_community_link_url;
140                                 $a_file['update_date'] = $file_obj->get_update_date_yyyymmddhmi();
141
142                                 // ¥Õ¥¡¥¤¥ë¾ÜºÙ¾ðÊóURL
143                                 $a_file['detail_url']  = $this->getControllerPath('Community', 'FileDetail');
144                                 $a_file['detail_url'] .= $target_community_info;
145                                 $a_file['detail_url'] .= "&file_id=" . $file_obj->get_file_id();
146                                 $a_file['detail_url'] .= $target_folder_info;
147
148                                 // ¥×¥Ã¥È¥Õ¥¡¥¤¥ë¤«¤É¤¦¤«
149                                 if ($file_obj->get_owner_community_id() == $target_community_row['community_id']) {
150                                         $a_file['is_put'] = false;
151                                 } else {
152                                         $a_file['is_put'] = true;
153                                 }
154
155                                 array_push($file_row_array, $a_file);
156                         }
157
158                         // ¥Õ¥©¥ë¥À ¥°¥ë¡¼¥×ɽ¼¨URL
159                         $folder_group_mode_url  = $this->getControllerPath('Community', 'Folder');
160                         $folder_group_mode_url .= $target_community_info;
161                         $folder_group_mode_url .= $target_folder_info;
162                         $folder_group_mode_url .= '&mode=group';
163                 }
164
165                 // ¥ë¡¼¥È¥Õ¥©¥ë¥À¤Î¥Õ¥¡¥¤¥ë¤Ï¡¢Èó¸ø³«¤È¤·¤Æ°·¤¦
166                 if ((!$is_community_member) && $is_root_folder) {
167                         $file_row_array = array();
168                         $file_detail_info_row_array_array = array();
169                 }
170
171                 // ¥Õ¥©¥ë¥ÀºîÀ® URL
172                 if (!$is_put_folder) {
173                         $edit_folder_url  = $this->getControllerPath('Community', 'EditFolder');
174                         $edit_folder_url .= $target_community_info;
175                         $edit_folder_url .= $target_folder_info;
176                 } else {
177                         $edit_folder_url = "";
178                 }
179
180                 // Ì¾Á°Êѹ¹URL
181                 $rename_folder_url = "";
182                 $rename_folder_url  = $this->getControllerPath('Community', 'RenameFolderList');
183                 $rename_folder_url .= $target_community_info;
184                 $rename_folder_url .= $target_folder_info;
185
186                 // ºï½üURL
187                 $delete_folder_url = "";
188                 $delete_folder_url  = $this->getControllerPath('Community', 'DeleteFolder');
189                 $delete_folder_url .= $target_community_info;
190                 $delete_folder_url .= $target_folder_info;
191                 $delete_folder_url .= "&action_type=confirm";  // Á«°Ü¤¹¤ëÀè¤Î²èÌ̤ϳÎǧ²èÌÌ
192
193                 // °ÜÆ°URL
194                 $move_folder_url = "";
195                 $move_folder_url  = $this->getControllerPath('Community', 'MoveFolderList');
196                 $move_folder_url .= $target_community_info;
197                 $move_folder_url .= $target_folder_info;
198
199                 // ¥³¥ß¥å¥Ë¥Æ¥£¥Õ¥©¥ë¥À¸¡º÷URL
200                 $search_folder_url  = $this->getControllerPath('Community', 'SearchFolder');
201                 $search_folder_url .= $target_community_info;
202
203                 $this->setAttribute('target_folder_open_level_row', $target_folder_open_level_row);
204                 $this->setAttribute('community_top_page_url', $community_top_page_url);
205                 $this->setAttribute('is_community_member', $is_community_member);
206                 $this->setAttribute('is_root_folder', $is_root_folder);
207                 $this->setAttribute('is_put_folder', $is_put_folder);
208                 $this->setAttribute('upload_file_url', $upload_file_url);
209                 $this->setAttribute('folder_put_community_url', $folder_put_community_url);
210
211                 $this->setAttribute('target_user_community_name', $target_community_row['community_name']);
212
213                 $this->setAttribute('path_folder_obj_row_array', $path_folder_obj_row_array);
214                 $this->setAttribute('folder_row_array', $folder_row_array);
215                 $this->setAttribute('file_row_array', $file_row_array);
216
217                 // Áàºî¥á¥Ë¥å¡¼
218                 $this->setAttribute('edit_folder_url', $edit_folder_url);
219                 $this->setAttribute('rename_folder_url', $rename_folder_url);
220                 $this->setAttribute('delete_folder_url', $delete_folder_url);
221                 $this->setAttribute('move_folder_url', $move_folder_url);
222                 $this->setAttribute('search_folder_url', $search_folder_url);
223
224                 $this->setAttribute('mode', $mode);
225                 if ($mode == 'group') {
226                         $this->setAttribute('folder_url', $folder_url);
227                         $this->setAttribute('file_detail_info_row_array_array', $file_detail_info_row_array_array);
228                         $this->setAttribute('file_contents_type_master_row_array_array', $file_contents_type_master_row_array_array);
229                 } else {
230                         $this->setAttribute('folder_group_mode_url', $folder_group_mode_url);
231                 }
232
233                 // ¥¨¥é¡¼¥á¥Ã¥»¡¼¥¸
234                 $this->setAttribute('error_message', $this->getErrorMessage($controller, $request, $user));
235
236                 // ¥Æ¥ó¥×¥ì¡¼¥È
237                 if ($mode == 'group') {
238                         $this->setScreenId("0001");
239                         $this->setTemplate('Folder_group.tpl.php');
240                 } else {
241                         $this->setScreenId("0001");
242                         $this->setTemplate('Folder.tpl.php');
243                 }
244
245                 return parent::execute();
246         }
247
248         function make_display_folder_row_array ($folder_obj_array,
249                                                                                         $target_community_info,
250                                                                                         $target_folder_info,
251                                                                                         $target_community_row,
252                                                                                         $mode,
253                                                                                         &$controller) {
254                 $folder_row_array = array();
255                 foreach ($folder_obj_array as $folder_obj) {
256                         $folder_row = array();
257                         $link_url = "";
258                         $name     = "";
259                         $update_user_community_link_url = "";
260
261                         $link_url  = $this->getControllerPath('Community', 'Folder');
262                         $link_url .= $target_community_info;
263                         $link_url .= "&folder_id=" . $folder_obj->get_folder_id();
264                         if ($mode == 'group') {
265                                 $link_url .= '&mode=' . $mode;
266                         }
267
268
269                         $update_user_community_link_url  = $this->getControllerPath('User', 'Index');
270                         $update_user_community_link_url .= "&id=" . $folder_obj->get_update_user_community_id();
271
272                         // ¥Õ¥©¥ë¥À¾ÜºÙ URL
273                         $detail_url  = $this->getControllerPath('Community', 'FolderDetail');
274                         $detail_url .= $target_community_info;
275                         $detail_url .= $target_folder_info;
276                         $detail_url .= "&detail_folder_id=" . $folder_obj->get_folder_id();
277
278                         if ($folder_obj->get_is_root_folder()) {
279                                 $name  = $target_community_row['community_name'];
280                                 //$name .= "¤Î¥Õ¥©¥ë¥À";
281                                 $name = ACSMsg::get_tag_replace(ACSMsg::get_msg('Community', 'FolderSuccessView.class.php', 'FOLDER_NM'),
282                                         array("{COMMUNITY_NAME}" => $target_community_row['community_name']));
283                         } else {
284                                 $name = $folder_obj->get_folder_name();
285                         }
286
287                         // ±ÜÍ÷µö²Ä¥³¥ß¥å¥Ë¥Æ¥£Ì¾ºîÀ®
288                         $trusted_community_row_array = $folder_obj->get_trusted_community_row_array();
289                         $new_trusted_community_row_array = $this->make_display_trusted_community_row_array($trusted_community_row_array, &$controller);
290
291                         $folder_row['name'] = $name;
292                         $folder_row['folder_id'] = $folder_obj->get_folder_id();
293                         $folder_row['link_url'] = $link_url;
294                         $folder_row['open_level_name'] = $folder_obj->get_open_level_name();
295                         $folder_row['trusted_community_row_array'] = $new_trusted_community_row_array;
296                         $folder_row['update_user_community_name'] = $folder_obj->get_update_user_community_name();
297                         $folder_row['update_user_community_link_url'] = $update_user_community_link_url;
298                         $folder_row['update_date'] = $folder_obj->get_update_date_yyyymmddhmi();
299
300                         $folder_row['detail_url'] = $detail_url;
301
302                         // ¥×¥Ã¥È¥Õ¥©¥ë¥À¤«¤É¤¦¤«
303                         $folder_row['is_put'] = $folder_obj->is_put_folder($target_community_row['community_id']);
304
305                         array_push($folder_row_array, $folder_row);
306                 }
307                 return $folder_row_array;
308         }
309
310         function make_display_trusted_community_row_array ($trusted_community_row_array, &$controller) {
311                 $new_trusted_community_row_array = array();
312                 foreach ($trusted_community_row_array as $trusted_community_row) {
313                         $new_trusted_community_row = array();
314                         $community_top_page_url    = "";
315
316                         $community_top_page_url  = $this->getControllerPath('Community', 'Index');
317                         $community_top_page_url .= "&community_id=" . $trusted_community_row['community_id'];
318
319                         $new_trusted_community_row['community_name'] = $trusted_community_row['community_name'];
320                         $new_trusted_community_row['community_top_page_url'] = $community_top_page_url;
321
322                         array_push($new_trusted_community_row_array, $new_trusted_community_row);
323                 }
324
325                 return $new_trusted_community_row_array;
326         }
327 }
328 ?>