XpressEngine Core  1.11.2
 All Classes Namespaces Files Functions Variables Pages
comment.class.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (C) NAVER <http://www.navercorp.com> */
3 
4 require_once(_XE_PATH_ . 'modules/comment/comment.item.php');
5 
14 class comment extends ModuleObject
15 {
16 
21  function moduleInstall()
22  {
23  $oDB = DB::getInstance();
24 
25  // register the action forward (for using on the admin mode)
27 
28  $oDB->addIndex(
29  "comments", "idx_module_list_order", array("module_srl", "list_order"), TRUE
30  );
31 
32  // 2007. 10. 17 add a trigger to delete comments together with posting deleted
33  $oModuleController->insertTrigger('document.deleteDocument', 'comment', 'controller', 'triggerDeleteDocumentComments', 'after');
34  // 2007. 10. 17 add a trigger to delete all of comments together with module deleted
35  $oModuleController->insertTrigger('module.deleteModule', 'comment', 'controller', 'triggerDeleteModuleComments', 'after');
36  // 2008. 02. 22 add comment setting when a new module added
37  $oModuleController->insertTrigger('module.dispAdditionSetup', 'comment', 'view', 'triggerDispCommentAdditionSetup', 'before');
38 
39  if(!is_dir('./files/cache/tmp'))
40  {
41  FileHandler::makeDir('./files/cache/tmp');
42  }
43 
44  return new BaseObject();
45  }
46 
51  function checkUpdate()
52  {
53  $oDB = DB::getInstance();
54  $oModuleModel = getModel('module');
56  $version_update_id = implode('.', array(__CLASS__, __XE_VERSION__, 'updated'));
57  if($oModuleModel->needUpdate($version_update_id))
58  {
59  // 2007. 10. 17 add a trigger to delete comments together with posting deleted
60  if(!$oModuleModel->getTrigger('document.deleteDocument', 'comment', 'controller', 'triggerDeleteDocumentComments', 'after'))
61  {
62  return TRUE;
63  }
64  // 2007. 10. 17 add a trigger to delete all of comments together with module deleted
65  if(!$oModuleModel->getTrigger('module.deleteModule', 'comment', 'controller', 'triggerDeleteModuleComments', 'after'))
66  {
67  return TRUE;
68  }
69  // 2007. 10. 23 add a column for recommendation votes or notification of the comments
70  if(!$oDB->isColumnExists("comments", "voted_count"))
71  {
72  return TRUE;
73  }
74  if(!$oDB->isColumnExists("comments", "notify_message"))
75  {
76  return TRUE;
77  }
78  // 2008. 02. 22 add comment setting when a new module added
79  if(!$oModuleModel->getTrigger('module.dispAdditionSetup', 'comment', 'view', 'triggerDispCommentAdditionSetup', 'before'))
80  {
81  return TRUE;
82  }
83  // 2008. 05. 14 add a column for blamed count
84  if(!$oDB->isColumnExists("comments", "blamed_count"))
85  {
86  return TRUE;
87  }
88  if(!$oDB->isColumnExists("comment_voted_log", "point"))
89  {
90  return TRUE;
91  }
92 
93  if(!$oDB->isIndexExists("comments", "idx_module_list_order"))
94  {
95  return TRUE;
96  }
97  //2012. 02. 24 add comment published status column and index
98  if(!$oDB->isColumnExists("comments", "status"))
99  {
100  return TRUE;
101  }
102  if(!$oDB->isIndexExists("comments", "idx_status"))
103  {
104  return TRUE;
105  }
106 
107  // 2012. 08. 29 Add a trigger to copy additional setting when the module is copied
108  if(!$oModuleModel->getTrigger('module.procModuleAdminCopyModule', 'comment', 'controller', 'triggerCopyModule', 'after'))
109  {
110  return TRUE;
111  }
112 
113  if(!$oDB->isIndexExists("comments", "idx_parent_srl"))
114  {
115  return TRUE;
116  }
117 
118  $oModuleController->insertUpdatedLog($version_update_id);
119  }
120 
121  return FALSE;
122  }
123 
128  function moduleUpdate()
129  {
130  $oDB = DB::getInstance();
131  $oModuleModel = getModel('module');
132  $oModuleController = getController('module');
133  $version_update_id = implode('.', array(__CLASS__, __XE_VERSION__, 'updated'));
134  if($oModuleModel->needUpdate($version_update_id))
135  {
136  // 2007. 10. 17 add a trigger to delete comments together with posting deleted
137  if(!$oModuleModel->getTrigger('document.deleteDocument', 'comment', 'controller', 'triggerDeleteDocumentComments', 'after'))
138  {
139  $oModuleController->insertTrigger('document.deleteDocument', 'comment', 'controller', 'triggerDeleteDocumentComments', 'after');
140  }
141  // 2007. 10. 17 add a trigger to delete all of comments together with module deleted
142  if(!$oModuleModel->getTrigger('module.deleteModule', 'comment', 'controller', 'triggerDeleteModuleComments', 'after'))
143  {
144  $oModuleController->insertTrigger('module.deleteModule', 'comment', 'controller', 'triggerDeleteModuleComments', 'after');
145  }
146  // 2007. 10. 23 add a column for recommendation votes or notification of the comments
147  if(!$oDB->isColumnExists("comments", "voted_count"))
148  {
149  $oDB->addColumn("comments", "voted_count", "number", "11");
150  $oDB->addIndex("comments", "idx_voted_count", array("voted_count"));
151  }
152 
153  if(!$oDB->isColumnExists("comments", "notify_message"))
154  {
155  $oDB->addColumn("comments", "notify_message", "char", "1");
156  }
157  // 2008. 02. 22 add comment setting when a new module added
158  if(!$oModuleModel->getTrigger('module.dispAdditionSetup', 'comment', 'view', 'triggerDispCommentAdditionSetup', 'before'))
159  {
160  $oModuleController->insertTrigger('module.dispAdditionSetup', 'comment', 'view', 'triggerDispCommentAdditionSetup', 'before');
161  }
162  // 2008. 05. 14 add a column for blamed count
163  if(!$oDB->isColumnExists("comments", "blamed_count"))
164  {
165  $oDB->addColumn('comments', 'blamed_count', 'number', 11, 0, TRUE);
166  $oDB->addIndex('comments', 'idx_blamed_count', array('blamed_count'));
167  }
168  if(!$oDB->isColumnExists("comment_voted_log", "point"))
169  {
170  $oDB->addColumn('comment_voted_log', 'point', 'number', 11, 0, TRUE);
171  }
172 
173  if(!$oDB->isIndexExists("comments", "idx_module_list_order"))
174  {
175  $oDB->addIndex(
176  "comments", "idx_module_list_order", array("module_srl", "list_order"), TRUE
177  );
178  }
179 
180  //2012. 02. 24 add comment published status column and index
181  if(!$oDB->isColumnExists("comments", "status"))
182  {
183  $oDB->addColumn("comments", "status", "number", 1, 1, TRUE);
184  }
185  if(!$oDB->isIndexExists("comments", "idx_status"))
186  {
187  $oDB->addIndex(
188  "comments", "idx_status", array("status", "comment_srl", "module_srl", "document_srl"), TRUE
189  );
190  }
191 
192  // 2012. 08. 29 Add a trigger to copy additional setting when the module is copied
193  if(!$oModuleModel->getTrigger('module.procModuleAdminCopyModule', 'comment', 'controller', 'triggerCopyModule', 'after'))
194  {
195  $oModuleController->insertTrigger('module.procModuleAdminCopyModule', 'comment', 'controller', 'triggerCopyModule', 'after');
196  }
197 
198  if(!$oDB->isIndexExists("comments", "idx_parent_srl"))
199  {
200  $oDB->addIndex('comments', 'idx_parent_srl', array('parent_srl'));
201  }
202 
203  $oModuleController->insertUpdatedLog($version_update_id);
204  }
205 
206  return new BaseObject(0, 'success_updated');
207  }
208 
213  function recompileCache()
214  {
215  if(!is_dir('./files/cache/tmp'))
216  {
217  FileHandler::makeDir('./files/cache/tmp');
218  }
219  }
220 
221 }
222 /* End of file comment.class.php */
223 /* Location: ./modules/comment/comment.class.php */
$oModuleModel
Definition: ko.install.php:236
getController($module_name)
Definition: func.inc.php:90
const __XE_VERSION__
Definition: config.inc.php:32
getInstance($db_type=NULL)
Definition: DB.class.php:142
makeDir($path_string)
const _XE_PATH_
Definition: config.inc.php:49
getModel($module_name)
Definition: func.inc.php:145
$oModuleController
Definition: ko.install.php:287