XpressEngine Core  1.11.2
 All Classes Namespaces Files Functions Variables Pages
point.class.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (C) NAVER <http://www.navercorp.com> */
8 class point extends ModuleObject
9 {
13  function moduleInstall()
14  {
15  // Registration in action forward (for using in the administrator mode)
17  // Create a directory to store points information
18  FileHandler::makeDir('./files/member_extra_info/point');
19 
21  // The highest level
22  $config = new stdClass;
23  // default, point module is OFF
24  $config->able_module = 'N';
25  $config->max_level = 30;
26  // Per-level score
27  for($i=1;$i<=30;$i++)
28  {
29  $config->level_step[$i] = pow($i,2)*90;
30  }
31  // Points for registration
32  $config->signup_point = 10;
33  // Login points
34  $config->login_point = 5;
35  // Point's name
36  $config->point_name = 'point';
37  // Level icon directory
38  $config->level_icon = "default";
39  // Prevent downloads if there are no scores
40  $config->disable_download = false;
41 
45  // Insert document
46  $config->insert_document = 10;
47 
48  $config->insert_document_act = 'procBoardInsertDocument';
49  $config->delete_document_act = 'procBoardDeleteDocument';
50  // Insert comment
51  $config->insert_comment = 5;
52 
53  $config->insert_comment_act = 'procBoardInsertComment,procBlogInsertComment';
54  $config->delete_comment_act = 'procBoardDeleteComment,procBlogDeleteComment';
55  // Upload
56  $config->upload_file = 5;
57 
58  $config->upload_file_act = 'procFileUpload';
59  $config->delete_file_act = 'procFileDelete';
60  // Download
61  $config->download_file = -5;
62  $config->download_file_act = 'procFileDownload';
63  // View
64  $config->read_document = 0;
65  // Vote up / Vote down
66  $config->voted = 0;
67  $config->blamed = 0;
68  // Save configurations
69  $oModuleController->insertModuleConfig('point', $config);
70  // Cash act list for faster execution
71  $oPointController = getAdminController('point');
72  $oPointController->cacheActList();
73 
74  return new BaseObject();
75  }
76 
80  function checkUpdate()
81  {
82  // Get the information of the point module
83  $oModuleModel = getModel('module');
84 
85  $config = $oModuleModel->getModuleConfig('point');
86  // check if module is abled
87  if($config->able_module != 'N')
88  {
89  // Add a trigger for registration/insert document/insert comment/upload a file/download
90  if(!$oModuleModel->getTrigger('member.insertMember', 'point', 'controller', 'triggerInsertMember', 'after')) return true;
91  if(!$oModuleModel->getTrigger('document.insertDocument', 'point', 'controller', 'triggerInsertDocument', 'after')) return true;
92  if(!$oModuleModel->getTrigger('document.deleteDocument', 'point', 'controller', 'triggerBeforeDeleteDocument', 'before')) return true;
93  if(!$oModuleModel->getTrigger('document.deleteDocument', 'point', 'controller', 'triggerDeleteDocument', 'after')) return true;
94  if(!$oModuleModel->getTrigger('comment.insertComment', 'point', 'controller', 'triggerInsertComment', 'after')) return true;
95  if(!$oModuleModel->getTrigger('comment.deleteComment', 'point', 'controller', 'triggerDeleteComment', 'after')) return true;
96  if(!$oModuleModel->getTrigger('file.insertFile', 'point', 'controller', 'triggerInsertFile', 'after')) return true;
97  if(!$oModuleModel->getTrigger('file.deleteFile', 'point', 'controller', 'triggerDeleteFile', 'after')) return true;
98  if(!$oModuleModel->getTrigger('file.downloadFile', 'point', 'controller', 'triggerBeforeDownloadFile', 'before')) return true;
99  if(!$oModuleModel->getTrigger('file.downloadFile', 'point', 'controller', 'triggerDownloadFile', 'after')) return true;
100  if(!$oModuleModel->getTrigger('member.doLogin', 'point', 'controller', 'triggerAfterLogin', 'after')) return true;
101  if(!$oModuleModel->getTrigger('module.dispAdditionSetup', 'point', 'view', 'triggerDispPointAdditionSetup', 'after')) return true;
102  if(!$oModuleModel->getTrigger('document.updateReadedCount', 'point', 'controller', 'triggerUpdateReadedCount', 'after')) return true;
103  // Add a trigger for voting up and down 2008.05.13 haneul
104  if(!$oModuleModel->getTrigger('document.updateVotedCount', 'point', 'controller', 'triggerUpdateVotedCount', 'after')) return true;
105  // Add a trigger for using points for permanent saving of a temporarily saved document 2009.05.19 zero
106  if(!$oModuleModel->getTrigger('document.updateDocument', 'point', 'controller', 'triggerUpdateDocument', 'before')) return true;
107 
108  // 2012. 08. 29 Add a trigger to copy additional setting when the module is copied
109  if(!$oModuleModel->getTrigger('module.procModuleAdminCopyModule', 'point', 'controller', 'triggerCopyModule', 'after')) return true;
110  }
111 
112  return false;
113  }
114 
118  function moduleUpdate()
119  {
120  // Get the information of the point module
121  $oModuleModel = getModel('module');
122  $oModuleController = getController('module');
123  // Add a trigger for registration/insert document/insert comment/upload a file/download
124  if(!$oModuleModel->getTrigger('member.insertMember', 'point', 'controller', 'triggerInsertMember', 'after'))
125  $oModuleController->insertTrigger('member.insertMember', 'point', 'controller', 'triggerInsertMember', 'after');
126  if(!$oModuleModel->getTrigger('document.insertDocument', 'point', 'controller', 'triggerInsertDocument', 'after'))
127  $oModuleController->insertTrigger('document.insertDocument', 'point', 'controller', 'triggerInsertDocument', 'after');
128  if(!$oModuleModel->getTrigger('document.deleteDocument', 'point', 'controller', 'triggerBeforeDeleteDocument', 'before'))
129  $oModuleController->insertTrigger('document.deleteDocument', 'point', 'controller', 'triggerBeforeDeleteDocument', 'before');
130  if(!$oModuleModel->getTrigger('document.deleteDocument', 'point', 'controller', 'triggerDeleteDocument', 'after'))
131  $oModuleController->insertTrigger('document.deleteDocument', 'point', 'controller', 'triggerDeleteDocument', 'after');
132  if(!$oModuleModel->getTrigger('comment.insertComment', 'point', 'controller', 'triggerInsertComment', 'after'))
133  $oModuleController->insertTrigger('comment.insertComment', 'point', 'controller', 'triggerInsertComment', 'after');
134  if(!$oModuleModel->getTrigger('comment.deleteComment', 'point', 'controller', 'triggerDeleteComment', 'after'))
135  $oModuleController->insertTrigger('comment.deleteComment', 'point', 'controller', 'triggerDeleteComment', 'after');
136  if(!$oModuleModel->getTrigger('file.insertFile', 'point', 'controller', 'triggerInsertFile', 'after'))
137  $oModuleController->insertTrigger('file.insertFile', 'point', 'controller', 'triggerInsertFile', 'after');
138  if(!$oModuleModel->getTrigger('file.deleteFile', 'point', 'controller', 'triggerDeleteFile', 'after'))
139  $oModuleController->insertTrigger('file.deleteFile', 'point', 'controller', 'triggerDeleteFile', 'after');
140  if(!$oModuleModel->getTrigger('file.downloadFile', 'point', 'controller', 'triggerBeforeDownloadFile', 'before'))
141  $oModuleController->insertTrigger('file.downloadFile', 'point', 'controller', 'triggerBeforeDownloadFile', 'before');
142  if(!$oModuleModel->getTrigger('file.downloadFile', 'point', 'controller', 'triggerDownloadFile', 'after'))
143  $oModuleController->insertTrigger('file.downloadFile', 'point', 'controller', 'triggerDownloadFile', 'after');
144  if(!$oModuleModel->getTrigger('member.doLogin', 'point', 'controller', 'triggerAfterLogin', 'after'))
145  $oModuleController->insertTrigger('member.doLogin', 'point', 'controller', 'triggerAfterLogin', 'after');
146  if(!$oModuleModel->getTrigger('module.dispAdditionSetup', 'point', 'view', 'triggerDispPointAdditionSetup', 'after'))
147  $oModuleController->insertTrigger('module.dispAdditionSetup', 'point', 'view', 'triggerDispPointAdditionSetup', 'after');
148  if(!$oModuleModel->getTrigger('document.updateReadedCount', 'point', 'controller', 'triggerUpdateReadedCount', 'after'))
149  $oModuleController->insertTrigger('document.updateReadedCount', 'point', 'controller', 'triggerUpdateReadedCount', 'after');
150  // Add a trigger for voting up and down 2008.05.13 haneul
151  if(!$oModuleModel->getTrigger('document.updateVotedCount', 'point', 'controller', 'triggerUpdateVotedCount', 'after'))
152  $oModuleController->insertTrigger('document.updateVotedCount', 'point', 'controller', 'triggerUpdateVotedCount', 'after');
153  // Add a trigger for using points for permanent saving of a temporarily saved document 2009.05.19 zero
154  if(!$oModuleModel->getTrigger('document.updateDocument', 'point', 'controller', 'triggerUpdateDocument', 'before'))
155  $oModuleController->insertTrigger('document.updateDocument', 'point', 'controller', 'triggerUpdateDocument', 'before');
156  // 2012. 08. 29 Add a trigger to copy additional setting when the module is copied
157  if(!$oModuleModel->getTrigger('module.procModuleAdminCopyModule', 'point', 'controller', 'triggerCopyModule', 'after'))
158  {
159  $oModuleController->insertTrigger('module.procModuleAdminCopyModule', 'point', 'controller', 'triggerCopyModule', 'after');
160  }
161 
162  return new BaseObject(0, 'success_updated');
163  }
164 
168  function recompileCache()
169  {
170  // redefine point action file
171  $oPointAdminController = getAdminController('point');
172  $oPointAdminController->cacheActList();
173  }
174 }
175 /* End of file point.class.php */
176 /* Location: ./modules/point/point.class.php */
$oModuleModel
Definition: ko.install.php:236
getController($module_name)
Definition: func.inc.php:90
recompileCache()
Re-create the cache file.
The parent class of the point module.
Definition: point.class.php:8
moduleInstall()
Additional tasks required to accomplish during the installation.
Definition: point.class.php:13
makeDir($path_string)
getModel($module_name)
Definition: func.inc.php:145
checkUpdate()
A method to check if the installation has been successful.
Definition: point.class.php:80
getAdminController($module_name)
Definition: func.inc.php:101
$oModuleController
Definition: ko.install.php:287
moduleUpdate()
Execute update.