XpressEngine Core  1.11.2
 All Classes Namespaces Files Functions Variables Pages
file.class.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (C) NAVER <http://www.navercorp.com> */
7 class file extends ModuleObject
8 {
14  function moduleInstall()
15  {
16  // Register action forward (to use in administrator mode)
18 
19  // Save the default settings for attachments
20  $config = new stdClass;
21  $config->allowed_filesize = '2';
22  $config->allowed_attach_size = '2';
23  $config->allowed_filetypes = '*.*';
24  $oModuleController->insertModuleConfig('file', $config);
25  // Generate a directory for the file module
26  FileHandler::makeDir('./files/attach/images');
27  FileHandler::makeDir('./files/attach/binaries');
28  // 2007. 10. 17 Create a trigger to insert, update, delete documents and comments
29  $oModuleController->insertTrigger('document.insertDocument', 'file', 'controller', 'triggerCheckAttached', 'before');
30  $oModuleController->insertTrigger('document.insertDocument', 'file', 'controller', 'triggerAttachFiles', 'after');
31  $oModuleController->insertTrigger('document.updateDocument', 'file', 'controller', 'triggerCheckAttached', 'before');
32  $oModuleController->insertTrigger('document.updateDocument', 'file', 'controller', 'triggerAttachFiles', 'after');
33  $oModuleController->insertTrigger('document.deleteDocument', 'file', 'controller', 'triggerDeleteAttached', 'after');
34  $oModuleController->insertTrigger('comment.insertComment', 'file', 'controller', 'triggerCommentCheckAttached', 'before');
35  $oModuleController->insertTrigger('comment.insertComment', 'file', 'controller', 'triggerCommentAttachFiles', 'after');
36  $oModuleController->insertTrigger('comment.updateComment', 'file', 'controller', 'triggerCommentCheckAttached', 'before');
37  $oModuleController->insertTrigger('comment.updateComment', 'file', 'controller', 'triggerCommentAttachFiles', 'after');
38  $oModuleController->insertTrigger('comment.deleteComment', 'file', 'controller', 'triggerCommentDeleteAttached', 'after');
39  // 2009. 6. 9 Delete all the attachements when auto-saved document is deleted
40  $oModuleController->insertTrigger('editor.deleteSavedDoc', 'file', 'controller', 'triggerDeleteAttached', 'after');
41  // 2007. 10. 17 Create a trigger to delete all the attachements when the module is deleted
42  $oModuleController->insertTrigger('module.deleteModule', 'file', 'controller', 'triggerDeleteModuleFiles', 'after');
43  // 2007. 10. 19 Call a trigger to set up the file permissions before displaying
44  $oModuleController->insertTrigger('module.dispAdditionSetup', 'file', 'view', 'triggerDispFileAdditionSetup', 'before');
45 
46  return new BaseObject();
47  }
48 
54  function checkUpdate()
55  {
56  $oDB = &DB::getInstance();
57  $oModuleModel = getModel('module');
59  $version_update_id = implode('.', array(__CLASS__, __XE_VERSION__, 'updated'));
60  if($oModuleModel->needUpdate($version_update_id))
61  {
62  // 2007. 10. 17 Create a trigger to insert, update, delete documents and comments
63  if(!$oModuleModel->getTrigger('document.insertDocument', 'file', 'controller', 'triggerCheckAttached', 'before')) return true;
64  if(!$oModuleModel->getTrigger('document.insertDocument', 'file', 'controller', 'triggerAttachFiles', 'after')) return true;
65  if(!$oModuleModel->getTrigger('document.updateDocument', 'file', 'controller', 'triggerCheckAttached', 'before')) return true;
66  if(!$oModuleModel->getTrigger('document.updateDocument', 'file', 'controller', 'triggerAttachFiles', 'after')) return true;
67  if(!$oModuleModel->getTrigger('document.deleteDocument', 'file', 'controller', 'triggerDeleteAttached', 'after')) return true;
68  if(!$oModuleModel->getTrigger('comment.insertComment', 'file', 'controller', 'triggerCommentCheckAttached', 'before')) return true;
69  if(!$oModuleModel->getTrigger('comment.insertComment', 'file', 'controller', 'triggerCommentAttachFiles', 'after')) return true;
70  if(!$oModuleModel->getTrigger('comment.updateComment', 'file', 'controller', 'triggerCommentCheckAttached', 'before')) return true;
71  if(!$oModuleModel->getTrigger('comment.updateComment', 'file', 'controller', 'triggerCommentAttachFiles', 'after')) return true;
72  if(!$oModuleModel->getTrigger('comment.deleteComment', 'file', 'controller', 'triggerCommentDeleteAttached', 'after')) return true;
73  // 2009. 6. 9 Delete all the attachements when auto-saved document is deleted
74  if(!$oModuleModel->getTrigger('editor.deleteSavedDoc', 'file', 'controller', 'triggerDeleteAttached', 'after')) return true;
75  // 2007. 10. 17 Create a trigger to delete all the attachements when the module is deleted
76  if(!$oModuleModel->getTrigger('module.deleteModule', 'file', 'controller', 'triggerDeleteModuleFiles', 'after')) return true;
77  // 2007. 10. 19 Call a trigger to set up the file permissions before displaying
78  if(!$oModuleModel->getTrigger('module.dispAdditionSetup', 'file', 'view', 'triggerDispFileAdditionSetup', 'before')) return true;
79  // A column to determine a target type
80  if(!$oDB->isColumnExists('files', 'upload_target_type')) return true;
81 
82  // 2012. 08. 29 Add a trigger to copy additional setting when the module is copied
83  if(!$oModuleModel->getTrigger('module.procModuleAdminCopyModule', 'file', 'controller', 'triggerCopyModule', 'after')) return true;
84 
85  if(!$oDB->isColumnExists('files', 'cover_image')) return true;
86 
87  $oModuleController->insertUpdatedLog($version_update_id);
88  }
89 
90  return false;
91  }
92 
98  function moduleUpdate()
99  {
100  $oDB = &DB::getInstance();
101  $oModuleModel = getModel('module');
102  $oModuleController = getController('module');
103  $version_update_id = implode('.', array(__CLASS__, __XE_VERSION__, 'updated'));
104  if($oModuleModel->needUpdate($version_update_id))
105  {
106  // 2007. 10. 17 Create a trigger to insert, update, delete documents and comments
107  if(!$oModuleModel->getTrigger('document.insertDocument', 'file', 'controller', 'triggerCheckAttached', 'before'))
108  $oModuleController->insertTrigger('document.insertDocument', 'file', 'controller', 'triggerCheckAttached', 'before');
109 
110  if(!$oModuleModel->getTrigger('document.insertDocument', 'file', 'controller', 'triggerAttachFiles', 'after'))
111  $oModuleController->insertTrigger('document.insertDocument', 'file', 'controller', 'triggerAttachFiles', 'after');
112 
113  if(!$oModuleModel->getTrigger('document.updateDocument', 'file', 'controller', 'triggerCheckAttached', 'before'))
114  $oModuleController->insertTrigger('document.updateDocument', 'file', 'controller', 'triggerCheckAttached', 'before');
115 
116  if(!$oModuleModel->getTrigger('document.updateDocument', 'file', 'controller', 'triggerAttachFiles', 'after'))
117  $oModuleController->insertTrigger('document.updateDocument', 'file', 'controller', 'triggerAttachFiles', 'after');
118 
119  if(!$oModuleModel->getTrigger('document.deleteDocument', 'file', 'controller', 'triggerDeleteAttached', 'after'))
120  $oModuleController->insertTrigger('document.deleteDocument', 'file', 'controller', 'triggerDeleteAttached', 'after');
121 
122  if(!$oModuleModel->getTrigger('comment.insertComment', 'file', 'controller', 'triggerCommentCheckAttached', 'before'))
123  $oModuleController->insertTrigger('comment.insertComment', 'file', 'controller', 'triggerCommentCheckAttached', 'before');
124 
125  if(!$oModuleModel->getTrigger('comment.insertComment', 'file', 'controller', 'triggerCommentAttachFiles', 'after'))
126  $oModuleController->insertTrigger('comment.insertComment', 'file', 'controller', 'triggerCommentAttachFiles', 'after');
127 
128  if(!$oModuleModel->getTrigger('comment.updateComment', 'file', 'controller', 'triggerCommentCheckAttached', 'before'))
129  $oModuleController->insertTrigger('comment.updateComment', 'file', 'controller', 'triggerCommentCheckAttached', 'before');
130 
131  if(!$oModuleModel->getTrigger('comment.updateComment', 'file', 'controller', 'triggerCommentAttachFiles', 'after'))
132  $oModuleController->insertTrigger('comment.updateComment', 'file', 'controller', 'triggerCommentAttachFiles', 'after');
133 
134  if(!$oModuleModel->getTrigger('comment.deleteComment', 'file', 'controller', 'triggerCommentDeleteAttached', 'after'))
135  $oModuleController->insertTrigger('comment.deleteComment', 'file', 'controller', 'triggerCommentDeleteAttached', 'after');
136  // 2009. 6. 9 Delete all the attachements when auto-saved document is deleted
137  if(!$oModuleModel->getTrigger('editor.deleteSavedDoc', 'file', 'controller', 'triggerDeleteAttached', 'after'))
138  $oModuleController->insertTrigger('editor.deleteSavedDoc', 'file', 'controller', 'triggerDeleteAttached', 'after');
139  // 2007. 10. 17 Create a trigger to delete all the attachements when the module is deleted
140  if(!$oModuleModel->getTrigger('module.deleteModule', 'file', 'controller', 'triggerDeleteModuleFiles', 'after'))
141  $oModuleController->insertTrigger('module.deleteModule', 'file', 'controller', 'triggerDeleteModuleFiles', 'after');
142  // 2007. 10. 19 Call a trigger to set up the file permissions before displaying
143  if(!$oModuleModel->getTrigger('module.dispAdditionSetup', 'file', 'view', 'triggerDispFileAdditionSetup', 'before'))
144  $oModuleController->insertTrigger('module.dispAdditionSetup', 'file', 'view', 'triggerDispFileAdditionSetup', 'before');
145  // A column to determine a target type
146  if(!$oDB->isColumnExists('files', 'upload_target_type')) $oDB->addColumn('files', 'upload_target_type', 'char', '3');
147 
148  // 2012. 08. 29 Add a trigger to copy additional setting when the module is copied
149  if(!$oModuleModel->getTrigger('module.procModuleAdminCopyModule', 'file', 'controller', 'triggerCopyModule', 'after'))
150  {
151  $oModuleController->insertTrigger('module.procModuleAdminCopyModule', 'file', 'controller', 'triggerCopyModule', 'after');
152  }
153 
154  if(!$oDB->isColumnExists('files', 'cover_image')) $oDB->addColumn('files', 'cover_image', 'char', '1', 'N');
155 
156  $oModuleController->insertUpdatedLog($version_update_id);
157  }
158 
159  return new BaseObject(0, 'success_updated');
160  }
161 
167  function recompileCache()
168  {
169  }
170 }
171 /* End of file file.class.php */
172 /* Location: ./modules/file/file.class.php */
$oModuleModel
Definition: ko.install.php:236
getController($module_name)
Definition: func.inc.php:90
const __XE_VERSION__
Definition: config.inc.php:32
moduleUpdate()
Definition: file.class.php:98
moduleInstall()
Definition: file.class.php:14
getInstance($db_type=NULL)
Definition: DB.class.php:142
checkUpdate()
Definition: file.class.php:54
makeDir($path_string)
recompileCache()
Definition: file.class.php:167
getModel($module_name)
Definition: func.inc.php:145
$oModuleController
Definition: ko.install.php:287