XpressEngine Core  1.11.2
 All Classes Namespaces Files Functions Variables Pages
document.class.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (C) NAVER <http://www.navercorp.com> */
3 require_once(_XE_PATH_.'modules/document/document.item.php');
4 
14 class document extends ModuleObject
15 {
20  var $search_option = array('title','content','title_content','user_name',); // /< Search options
25  var $statusList = array('private'=>'PRIVATE', 'public'=>'PUBLIC', 'secret'=>'SECRET', 'temp'=>'TEMP');
26 
31  function moduleInstall()
32  {
33  // Register action forward (to use in administrator mode)
35 
36  $oDB = &DB::getInstance();
37  $oDB->addIndex("documents","idx_module_list_order", array("module_srl","list_order"));
38  $oDB->addIndex("documents","idx_module_update_order", array("module_srl","update_order"));
39  $oDB->addIndex("documents","idx_module_readed_count", array("module_srl","readed_count"));
40  $oDB->addIndex("documents","idx_module_voted_count", array("module_srl","voted_count"));
41  $oDB->addIndex("documents","idx_module_notice", array("module_srl","is_notice"));
42  $oDB->addIndex("documents","idx_module_document_srl", array("module_srl","document_srl"));
43  $oDB->addIndex("documents","idx_module_blamed_count", array("module_srl","blamed_count"));
44  $oDB->addIndex("document_aliases", "idx_module_title", array("module_srl","alias_title"), true);
45  $oDB->addIndex("document_extra_vars", "unique_extra_vars", array("module_srl","document_srl","var_idx","lang_code"), true);
46  // 2007. 10. 17 Add a trigger to delete all posts together when the module is deleted
47  $oModuleController->insertTrigger('module.deleteModule', 'document', 'controller', 'triggerDeleteModuleDocuments', 'after');
48 
49  // 2009. 01. 29 Added a trigger for additional setup
50  $oModuleController->insertTrigger('module.dispAdditionSetup', 'document', 'view', 'triggerDispDocumentAdditionSetup', 'before');
51 
52  if(!is_dir('./files/cache/tmp'))
53  {
54  FileHandler::makeDir('./files/cache/tmp');
55  }
56 
57  return new BaseObject();
58  }
59 
64  function checkUpdate()
65  {
66  $oDB = &DB::getInstance();
67  $oModuleModel = getModel('module');
69  $version_update_id = implode('.', array(__CLASS__, __XE_VERSION__, 'updated'));
70  if($oModuleModel->needUpdate($version_update_id))
71  {
72  // 2007. 7. 25: Add a column(notify_message) for notification
73  if(!$oDB->isColumnExists("documents","notify_message")) return true;
74 
75  // 2007. 8. 23: create a clustered index in the document table
76  if(!$oDB->isIndexExists("documents","idx_module_list_order")) return true;
77  if(!$oDB->isIndexExists("documents","idx_module_update_order")) return true;
78  if(!$oDB->isIndexExists("documents","idx_module_readed_count")) return true;
79  if(!$oDB->isIndexExists("documents","idx_module_voted_count")) return true;
80  // 2007. 10. 17 Add a trigger to delete all posts together when the module is deleted
81  if(!$oModuleModel->getTrigger('module.deleteModule', 'document', 'controller', 'triggerDeleteModuleDocuments', 'after')) return true;
82  // 2007. 10. 25 add parent_srl, expand to the document category
83  if(!$oDB->isColumnExists("document_categories","parent_srl")) return true;
84  if(!$oDB->isColumnExists("document_categories","expand")) return true;
85  if(!$oDB->isColumnExists("document_categories","group_srls")) return true;
86  // 2007. 11. 20 create a composite index on the columns(module_srl + is_notice)
87  if(!$oDB->isIndexExists("documents","idx_module_notice")) return true;
88  // 2008. 02. 18 create a composite index on the columns(module_srl + document_srl) (checked by Manian))
89  if(!$oDB->isIndexExists("documents","idx_module_document_srl")) return true;
90 
91  // 2007. 12. 03: Add if the colume(extra_vars) doesn't exist
92  if(!$oDB->isColumnExists("documents","extra_vars")) return true;
93  // 2008. 04. 23 Add a column(blamed_count)
94  if(!$oDB->isColumnExists("documents", "blamed_count")) return true;
95  if(!$oDB->isIndexExists("documents","idx_module_blamed_count")) return true;
96  if(!$oDB->isColumnExists("document_voted_log", "point")) return true;
97  // 2008-12-15 Add a column(color)
98  if(!$oDB->isColumnExists("document_categories", "color")) return true;
99 
103  if(!$oDB->isColumnExists("document_extra_vars","lang_code")) return true;
104 
105  if(!$oModuleModel->getTrigger('module.dispAdditionSetup', 'document', 'view', 'triggerDispDocumentAdditionSetup', 'before')) return true;
106  // 2009. 03. 09 Add a column(lang_code) to the documnets table
107  if(!$oDB->isColumnExists("documents","lang_code")) return true;
108  // 2009. 03. 11 check the index in the document_extra_vars table
109  if(!$oDB->isIndexExists("document_extra_vars", "unique_extra_vars")) return true;
110 
111  // 2009. 03. 19: Add a column(eid) if not exist in the table
112  if(!$oDB->isColumnExists("document_extra_keys","eid")) return true;
113  if(!$oDB->isColumnExists("document_extra_vars","eid")) return true;
114 
115  // 2011. 03. 30 Cubrid index Check the index in the document_extra_vars table
116  if(!$oDB->isIndexExists("document_extra_vars", "idx_document_list_order")) return true;
117 
118  //2011. 04. 07 adding description column to document categories
119  if(!$oDB->isColumnExists("document_categories","description")) return true;
120 
121  //2011. 05. 23 adding status column to document
122  if(!$oDB->isColumnExists('documents', 'status')) return true;
123 
124  //2011. 06. 07 check comment status update
125  if($oDB->isColumnExists('documents', 'allow_comment') || $oDB->isColumnExists('documents', 'lock_comment')) return true;
126 
127  // 2011. 10. 25 status index check
128  if(!$oDB->isIndexExists("documents", "idx_module_status")) return true;
129 
130  // 2012. 02. 27 Add a trigger to copy extra keys when the module is copied
131  if(!$oModuleModel->getTrigger('module.procModuleAdminCopyModule', 'document', 'controller', 'triggerCopyModuleExtraKeys', 'after')) return true;
132 
133  // 2012. 08. 29 Add a trigger to copy additional setting when the module is copied
134  if(!$oModuleModel->getTrigger('module.procModuleAdminCopyModule', 'document', 'controller', 'triggerCopyModule', 'after')) return true;
135 
136  $oModuleController->insertUpdatedLog($version_update_id);
137  }
138 
139  return false;
140  }
141 
146  function moduleUpdate()
147  {
148  $oDB = &DB::getInstance();
149  $oModuleModel = getModel('module');
150  $oModuleController = getController('module');
151  $version_update_id = implode('.', array(__CLASS__, __XE_VERSION__, 'updated'));
152  if($oModuleModel->needUpdate($version_update_id))
153  {
154  // 2007. 7. 25: Add a column(notify_message) for notification
155  if(!$oDB->isColumnExists("documents","notify_message"))
156  {
157  $oDB->addColumn('documents',"notify_message","char",1);
158  }
159 
160  // 2007. 8. 23: create a clustered index in the document table
161  if(!$oDB->isIndexExists("documents","idx_module_list_order"))
162  {
163  $oDB->addIndex("documents","idx_module_list_order", array("module_srl","list_order"));
164  }
165 
166  if(!$oDB->isIndexExists("documents","idx_module_update_order"))
167  {
168  $oDB->addIndex("documents","idx_module_update_order", array("module_srl","update_order"));
169  }
170 
171  if(!$oDB->isIndexExists("documents","idx_module_readed_count"))
172  {
173  $oDB->addIndex("documents","idx_module_readed_count", array("module_srl","readed_count"));
174  }
175 
176  if(!$oDB->isIndexExists("documents","idx_module_voted_count"))
177  {
178  $oDB->addIndex("documents","idx_module_voted_count", array("module_srl","voted_count"));
179  }
180  // 2007. 10. 17 Add a trigger to delete all posts together when the module is deleted
181  if(!$oModuleModel->getTrigger('module.deleteModule', 'document', 'controller', 'triggerDeleteModuleDocuments', 'after'))
182  $oModuleController->insertTrigger('module.deleteModule', 'document', 'controller', 'triggerDeleteModuleDocuments', 'after');
183  // 2007. 10. 25 add columns(parent_srl, expand)
184  if(!$oDB->isColumnExists("document_categories","parent_srl")) $oDB->addColumn('document_categories',"parent_srl","number",12,0);
185  if(!$oDB->isColumnExists("document_categories","expand")) $oDB->addColumn('document_categories',"expand","char",1,"N");
186  if(!$oDB->isColumnExists("document_categories","group_srls")) $oDB->addColumn('document_categories',"group_srls","text");
187  // 2007. 11. 20 create a composite index on the columns(module_srl + is_notice)
188  if(!$oDB->isIndexExists("documents","idx_module_notice")) $oDB->addIndex("documents","idx_module_notice", array("module_srl","is_notice"));
189 
190  // 2007. 12. 03: Add if the colume(extra_vars) doesn't exist
191  if(!$oDB->isColumnExists("documents","extra_vars")) $oDB->addColumn('documents','extra_vars','text');
192 
193  // 2008. 02. 18 create a composite index on the columns(module_srl + document_srl) (checked by Manian))
194  if(!$oDB->isIndexExists("documents","idx_module_document_srl")) $oDB->addIndex("documents","idx_module_document_srl", array("module_srl","document_srl"));
195  // 2008. 04. 23 Add a column(blamed count)
196  if(!$oDB->isColumnExists("documents", "blamed_count"))
197  {
198  $oDB->addColumn('documents', 'blamed_count', 'number', 11, 0, true);
199  $oDB->addIndex('documents', 'idx_blamed_count', array('blamed_count'));
200  }
201 
202  if(!$oDB->isIndexExists("documents","idx_module_blamed_count"))
203  {
204  $oDB->addIndex('documents', 'idx_module_blamed_count', array('module_srl', 'blamed_count'));
205  }
206 
207  if(!$oDB->isColumnExists("document_voted_log", "point"))
208  $oDB->addColumn('document_voted_log', 'point', 'number', 11, 0, true);
209 
210 
211  if(!$oDB->isColumnExists("document_categories","color")) $oDB->addColumn('document_categories',"color","char",7);
212 
213  // 2009. 01. 29: Add a column(lang_code) if not exist in the document_extra_vars table
214  if(!$oDB->isColumnExists("document_extra_vars","lang_code")) $oDB->addColumn('document_extra_vars',"lang_code","varchar",10);
215 
216  // 2009. 01. 29 Added a trigger for additional setup
217  if(!$oModuleModel->getTrigger('module.dispAdditionSetup', 'document', 'view', 'triggerDispDocumentAdditionSetup', 'before'))
218  $oModuleController->insertTrigger('module.dispAdditionSetup', 'document', 'view', 'triggerDispDocumentAdditionSetup', 'before');
219  // 2009. 03. 09 Add a column(lang_code) to the documnets table
220  if(!$oDB->isColumnExists("documents","lang_code"))
221  {
222  $db_info = Context::getDBInfo();
223  $oDB->addColumn('documents',"lang_code","varchar",10, $db_info->lang_code);
224  $obj->lang_code = $db_info->lang_type;
225  executeQuery('document.updateDocumentsLangCode', $obj);
226  }
227  // 2009. 03. 11 Check the index in the document_extra_vars table
228  if(!$oDB->isIndexExists("document_extra_vars", "unique_extra_vars"))
229  {
230  $oDB->addIndex("document_extra_vars", "unique_extra_vars", array("module_srl","document_srl","var_idx","lang_code"), true);
231  }
232 
233  if($oDB->isIndexExists("document_extra_vars", "unique_module_vars"))
234  {
235  $oDB->dropIndex("document_extra_vars", "unique_module_vars", true);
236  }
237 
238  // 2009. 03. 19: Add a column(eid)
239  // 2009. 04. 12: Fixed the issue(#17922959) that changes another column values when adding eid column
240  if(!$oDB->isColumnExists("document_extra_keys","eid"))
241  {
242  $oDB->addColumn("document_extra_keys","eid","varchar",40);
243 
244  $output = executeQuery('document.getGroupsExtraKeys', $obj);
245  if($output->toBool() && $output->data && count($output->data)) {
246  foreach($output->data as $extra_keys) {
247  $args->module_srl = $extra_keys->module_srl;
248  $args->var_idx = $extra_keys->idx;
249  $args->new_eid = "extra_vars".$extra_keys->idx;
250  $output = executeQuery('document.updateDocumentExtraKeyEid', $args);
251  }
252  }
253  }
254 
255  if(!$oDB->isColumnExists("document_extra_vars","eid"))
256  {
257  $oDB->addColumn("document_extra_vars","eid","varchar",40);
258  $obj->var_idx = '-1,-2';
259  $output = executeQuery('document.getGroupsExtraVars', $obj);
260  if($output->toBool() && $output->data && count($output->data))
261  {
262  foreach($output->data as $extra_vars)
263  {
264  $args->module_srl = $extra_vars->module_srl;
265  $args->var_idx = $extra_vars->idx;
266  $args->new_eid = "extra_vars".$extra_vars->idx;
267  $output = executeQuery('document.updateDocumentExtraVarEid', $args);
268  }
269  }
270  }
271 
272  // 2011. 03. 30 Cubrid index Check the index in the document_extra_vars table
273  if(!$oDB->isIndexExists("document_extra_vars", "idx_document_list_order"))
274  {
275  $oDB->addIndex("document_extra_vars", "idx_document_list_order", array("document_srl","module_srl","var_idx"), false);
276  }
277 
278  //2011. 04. 07 adding description column to document categories
279  if(!$oDB->isColumnExists("document_categories","description")) $oDB->addColumn('document_categories',"description","varchar",200,0);
280 
281  //2011. 05. 23 adding status column to document
282  if(!$oDB->isColumnExists('documents', 'status'))
283  {
284  $oDB->addColumn('documents', 'status', 'varchar', 20, 'PUBLIC');
285  $args->is_secret = 'Y';
286  $output = executeQuery('document.updateDocumentStatus', $args);
287  }
288 
289  // 2011. 09. 08 drop column document is_secret
290  if($oDB->isColumnExists('documents', 'status') && $oDB->isColumnExists('documents', 'is_secret'))
291  $oDB->dropColumn('documents', 'is_secret');
292 
293  //2011. 06. 07 merge column, allow_comment and lock_comment
294  if($oDB->isColumnExists('documents', 'allow_comment') || $oDB->isColumnExists('documents', 'lock_comment'))
295  {
296  $oDB->addColumn('documents', 'comment_status', 'varchar', 20, 'ALLOW');
297 
298  $args->commentStatus = 'DENY';
299 
300  // allow_comment='Y', lock_comment='Y'
301  $args->allowComment = 'Y';
302  $args->lockComment = 'Y';
303  $output = executeQuery('document.updateDocumentCommentStatus', $args);
304 
305  // allow_comment='N', lock_comment='Y'
306  $args->allowComment = 'N';
307  $args->lockComment = 'Y';
308  $output = executeQuery('document.updateDocumentCommentStatus', $args);
309 
310  // allow_comment='N', lock_comment='N'
311  $args->allowComment = 'N';
312  $args->lockComment = 'N';
313  $output = executeQuery('document.updateDocumentCommentStatus', $args);
314  }
315 
316  if($oDB->isColumnExists('documents', 'allow_comment') && $oDB->isColumnExists('documents', 'comment_status'))
317  $oDB->dropColumn('documents', 'allow_comment');
318 
319  if($oDB->isColumnExists('documents', 'lock_comment') && $oDB->isColumnExists('documents', 'comment_status'))
320  $oDB->dropColumn('documents', 'lock_comment');
321 
322  if(!$oDB->isIndexExists("documents", "idx_module_status"))
323  $oDB->addIndex("documents", "idx_module_status", array("module_srl","status"));
324 
325  // 2012. 02. 27 Add a trigger to copy extra keys when the module is copied
326  if(!$oModuleModel->getTrigger('module.procModuleAdminCopyModule', 'document', 'controller', 'triggerCopyModuleExtraKeys', 'after'))
327  {
328  $oModuleController->insertTrigger('module.procModuleAdminCopyModule', 'document', 'controller', 'triggerCopyModuleExtraKeys', 'after');
329  }
330 
331  // 2012. 08. 29 Add a trigger to copy additional setting when the module is copied
332  if(!$oModuleModel->getTrigger('module.procModuleAdminCopyModule', 'document', 'controller', 'triggerCopyModule', 'after'))
333  {
334  $oModuleController->insertTrigger('module.procModuleAdminCopyModule', 'document', 'controller', 'triggerCopyModule', 'after');
335  }
336 
337  $oModuleController->insertUpdatedLog($version_update_id);
338  }
339 
340  return new BaseObject(0,'success_updated');
341  }
342 
347  function recompileCache()
348  {
349  if(!is_dir('./files/cache/tmp'))
350  {
351  FileHandler::makeDir('./files/cache/tmp');
352  }
353  }
354 
359  function getStatusList()
360  {
361  return $this->statusList;
362  }
363 
368  function getDefaultStatus()
369  {
370  return $this->statusList['public'];
371  }
372 
377  function getConfigStatus($key)
378  {
379  if(array_key_exists(strtolower($key), $this->statusList)) return $this->statusList[$key];
380  else $this->getDefaultStatus();
381  }
382 }
383 /* End of file document.class.php */
384 /* Location: ./modules/document/document.class.php */
getConfigStatus($key)
$oModuleModel
Definition: ko.install.php:236
getController($module_name)
Definition: func.inc.php:90
const __XE_VERSION__
Definition: config.inc.php:32
$obj
Definition: ko.install.php:262
$output
Definition: ko.install.php:193
foreach($sitemap as $id=> &$val) $extra_vars
Definition: ko.install.php:180
$args
Definition: ko.install.php:185
getInstance($db_type=NULL)
Definition: DB.class.php:142
document the module&#39;s high class {
makeDir($path_string)
const _XE_PATH_
Definition: config.inc.php:49
getModel($module_name)
Definition: func.inc.php:145
executeQuery($query_id, $args=NULL, $arg_columns=NULL)
Definition: func.inc.php:203
$oModuleController
Definition: ko.install.php:287