XpressEngine Core  1.11.2
 All Classes Namespaces Files Functions Variables Pages
board.admin.controller.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (C) NAVER <http://www.navercorp.com> */
3 
10 class boardAdminController extends board {
11 
15  function init() {
16  }
17 
21  function procBoardAdminInsertBoard($args = null) {
22  // generate module model/controller object
24  $oModuleModel = getModel('module');
25 
26  // setup the board module infortmation
28  $args->module = 'board';
29  $args->mid = $args->board_name;
30  if(is_array($args->use_status)) $args->use_status = implode('|@|', $args->use_status);
31  unset($args->board_name);
32 
33  // setup extra_order_target
34  $extra_order_target = array();
35  if($args->module_srl)
36  {
37  $oDocumentModel = getModel('document');
38  $module_extra_vars = $oDocumentModel->getExtraKeys($args->module_srl);
39  foreach($module_extra_vars as $oExtraItem)
40  {
41  $extra_order_target[$oExtraItem->eid] = $oExtraItem->name;
42  }
43  }
44 
45  // setup other variables
46  if($args->except_notice != 'Y') $args->except_notice = 'N';
47  if($args->use_anonymous != 'Y') $args->use_anonymous = 'N';
48  if($args->consultation != 'Y') $args->consultation = 'N';
49  if($args->protect_content!= 'Y') $args->protect_content = 'N';
50  if(!in_array($args->order_target,$this->order_target) && !array_key_exists($args->order_target, $extra_order_target)) $args->order_target = 'list_order';
51  if(!in_array($args->order_type, array('asc', 'desc'))) $args->order_type = 'asc';
52 
53  // if there is an existed module
54  if($args->module_srl) {
55  $module_info = $oModuleModel->getModuleInfoByModuleSrl($args->module_srl);
56  if($module_info->module_srl != $args->module_srl) unset($args->module_srl);
57  }
58 
59  // insert/update the board module based on module_srl
60  if(!$args->module_srl) {
61  $args->hide_category = 'N';
62  $output = $oModuleController->insertModule($args);
63  $msg_code = 'success_registed';
64  } else {
65  $args->hide_category = $module_info->hide_category;
66  $output = $oModuleController->updateModule($args);
67  $msg_code = 'success_updated';
68  }
69 
70  if(!$output->toBool()) return $output;
71 
72  // setup list config
73  $list = explode(',',Context::get('list'));
74  if(count($list))
75  {
76  $list_arr = array();
77  foreach($list as $val)
78  {
79  $val = trim($val);
80  if(!$val) continue;
81  if(substr($val,0,10)=='extra_vars') $val = substr($val,10);
82  $list_arr[] = $val;
83  }
85  $oModuleController->insertModulePartConfig('board', $output->get('module_srl'), $list_arr);
86  }
87 
88  $this->setMessage($msg_code);
89  if (Context::get('success_return_url')){
90  changeValueInUrl('mid', $args->mid, $module_info->mid);
91  $this->setRedirectUrl(Context::get('success_return_url'));
92  }else{
93  $this->setRedirectUrl(getNotEncodedUrl('', 'module', 'admin', 'act', 'dispBoardAdminBoardInfo', 'module_srl', $output->get('module_srl')));
94  }
95  }
96 
102  {
104 
105  // for board info
106  $args->module = 'board';
107  $args->mid = $args->board_name;
108  if(is_array($args->use_status))
109  {
110  $args->use_status = implode('|@|', $args->use_status);
111  }
112  unset($args->board_name);
113 
114  if(!in_array($args->order_target, $this->order_target))
115  {
116  $args->order_target = 'list_order';
117  }
118  if(!in_array($args->order_type, array('asc', 'desc')))
119  {
120  $args->order_type = 'asc';
121  }
122 
123  $oModuleController = getController('module');
124  $output = $oModuleController->updateModule($args);
125 
126  // for grant info, Register Admin ID
127  $oModuleController->deleteAdminId($args->module_srl);
128  if($args->admin_member)
129  {
130  $admin_members = explode(',',$args->admin_member);
131  for($i=0;$i<count($admin_members);$i++)
132  {
133  $admin_id = trim($admin_members[$i]);
134  if(!$admin_id) continue;
135  $oModuleController->insertAdminId($args->module_srl, $admin_id);
136  }
137  }
138  }
139 
144  $module_srl = Context::get('module_srl');
145 
146  // get the current module
147  $oModuleController = getController('module');
148  $output = $oModuleController->deleteModule($module_srl);
149  if(!$output->toBool()) return $output;
150 
151  $this->add('module','board');
152  $this->add('page',Context::get('page'));
153  $this->setMessage('success_deleted');
154  }
155 
157  {
158  $module_srl = Context::get('module_srl');
159  $mid = Context::get('mid');
160 
161  $oModuleModel = getModel('module');
162  $module_info = $oModuleModel->getModuleInfoByModuleSrl($module_srl);
163  if($module_info->mid != $mid)
164  {
165  return new BaseObject(-1, 'msg_invalid_request');
166  }
167 
168  $module_info->hide_category = Context::get('hide_category') == 'Y' ? 'Y' : 'N';
169  $oModuleController = getController('module'); /* @var $oModuleController moduleController */
170  $output = $oModuleController->updateModule($module_info);
171  if(!$output->toBool())
172  {
173  return $output;
174  }
175 
176  $this->setMessage('success_updated');
177  if (Context::get('success_return_url'))
178  {
179  $this->setRedirectUrl(Context::get('success_return_url'));
180  }
181  else
182  {
183  $this->setRedirectUrl(getNotEncodedUrl('', 'module', 'admin', 'act', 'dispBoardAdminCategoryInfo', 'module_srl', $output->get('module_srl')));
184  }
185  }
186 }
$oModuleModel
Definition: ko.install.php:236
setMessage($message= 'success', $type=NULL)
getController($module_name)
Definition: func.inc.php:90
changeValueInUrl($key, $requestKey, $dbKey, $urlName= 'success_return_url')
Definition: func.inc.php:1688
$output
Definition: ko.install.php:193
add($key, $val)
procBoardAdminDeleteBoard()
delete the board module
getNotEncodedUrl()
Definition: func.inc.php:316
procBoardAdminInsertBoard($args=null)
insert borad module
$module_srl
integer value to represent a run-time instance of Module (XE Module)
$args
Definition: ko.install.php:185
$module_info
an object containing the module information
$mid
string to represent run-time instance of Module (XE Module)
setRedirectUrl($url= './', $output=NULL)
board module admin controller class
$oDocumentModel
Definition: ko.install.php:259
getModel($module_name)
Definition: func.inc.php:145
$oModuleController
Definition: ko.install.php:287
board module high class
Definition: board.class.php:10