Documentation is available at RSDEngineDBApplicationConfigFile.php
1 <?php
2 // RSDEngine: The Rapid and Secure Development Engine
3 // Copyright (C) 2003 Lukas Feiler
4 //
5 // This library is free software; you can redistribute it and/or
6 // modify it under the terms of the GNU Lesser General Public
7 // License as published by the Free Software Foundation; either
8 // version 2.1 of the License, or (at your option) any later version.
9 //
10 // This library is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 // Lesser General Public License for more details.
14 //
15 // You should have received a copy of the GNU Lesser General Public
16 // License along with this library; if not, write to the Free Software
17 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18
19 /**Contains just the class RSDEngineDBApplicationConfigFile.
20 *
21 * @package RSDEngine
22 * @author Lukas Feiler <lukas.feiler@chello.at>
23 * @copyright Lukas Feiler 2003
24 * @filesource
25 */
26
27 /**RSDEngineDBApplicationConfigFile extends RSDEngineFile.
28 */
29 require_once('RSDEngine/RSDEngineFile.php');
30
31
32 /**Generates the configuration file for database backended applications.
33 *
34 * @author Lukas Feiler <lukas.feiler@chello.at>
35 * @version 0.1.9
36 * @copyright Lukas Feiler 2003
37 * @package RSDEngine
38 */
39 class RSDEngineDBApplicationConfigFile extends RSDEngineFile{
40
41 /**Returns the name of the configuration file of the application class.
42 *
43 * In fact strtolower($this->config['projectName']) . "Config.php" is returned.
44 * @see config
45 *
46 * @return String The configuration file name.
47 */
48 function getFilename()
49 {
50 return strtolower($this->config['projectName']) . "Config.php";
51 }
52
53 /**Returns the code for the configuratin file.
54 *
55 * Note that this method requires $this->config to be correctly
56 * filled with all configuration options of the RSDEngine.
57 * @see config
58 *
59 * @return String The code of the configuration file.
60 */
61 function getCode()
62 {
63 extract($this->config);
64 $data = "";
65 $authors = RSArrayUtil::toString(split("\n",$authors),"\n",'* @author %val');
66 $projectNameUC = strtoupper($projectName);
67 $projectNameLC = strtolower($projectName);
68
69 $write = $this->config['writeConfigFile'];
70 $this->setWrite($write);
71
72 if (RSValidation::startsWith($fileStorageDirectory, './') || RSValidation::startsWith($fileStorageDirectory, '../')) {
73 $fileStorageDirectory = "dirname(__FILE__) . '/../$fileStorageDirectory'";
74 } else {
75 $fileStorageDirectory = "'$fileStorageDirectory'";
76 }
77
78 $data .= "/" . "**Configuration of $projectName.\n" .
79 "*\n" .
80 $authors . "\n" .
81 '* @copyright ' . $copyright . "\n" .
82 '* @package ' . $projectName . "\n" .
83 '* @filesource' . "\n" .
84 '*/' . "\n" .
85 "\n" .
86 "/" . "**The database host.\n" .
87 "*/\n" .
88 "DEFINE('${projectNameUC}_DB_HOST', '$databaseHost');\n" .
89 "\n" .
90 "/" . "**The database name.\n" .
91 "*/\n" .
92 "DEFINE('${projectNameUC}_DB_NAME', '$databaseName');\n" .
93 "\n" .
94 "/" . "**The username to use to log onto the database server.\n" .
95 "*/\n" .
96 "DEFINE('${projectNameUC}_DB_USERNAME', '$databaseUsername');\n" .
97 "\n" .
98 "/" . "**The password to use to log onto the database server.\n" .
99 "*/\n" .
100 "DEFINE('${projectNameUC}_DB_PASSWORD', '$databasePassword');\n" .
101 "\n" .
102 "/" . "**The type of the database.\n" .
103 "*/\n" .
104 "DEFINE('${projectNameUC}_DB_TYPE', '$databaseType');\n" .
105 "\n" .
106 "/" . "**If referential integrity should be ensured in the application layer.\n" .
107 "*/\n" .
108 "DEFINE('${projectNameUC}_DB_ENSURE_REFERENTIAL_INTEGRITY', '$databaseEnsureReferentialIntegrity');\n" .
109 "\n" .
110 "/" . "**The directory where all files will be stored that were uploaded for a column that was not defined with an own storage directory.\n" .
111 "*/\n" .
112 "DEFINE('${projectNameUC}_FILE_STORAGE_DIR',$fileStorageDirectory);\n";
113 reset($rsdEngineDB->tables);
114 while (list($tableName, $table) = each($rsdEngineDB->tables)) {
115 echo $tableName . ':';
116 echo $rsdEngineDB->tables[$tableName] . ':' . gettype($rsdEngineDB->tables[$tableName]) . ':';
117 echo $rsdEngineDB->tables[$tableName]->name . ':';
118 echo $rsdEngineDB->tables[$tableName]->columns . ':' . gettype($rsdEngineDB->tables[$tableName]->columns) . "<br>";
119 reset($rsdEngineDB->tables[$tableName]->columns);
120 while (list($columnName, $column) = each($rsdEngineDB->tables[$tableName]->columns)) {
121 if (is_array($isValidFileOptions = $column->getIsValidFileOptions())) {
122 $storageDir = $isValidFileOptions['storageDir'];
123 $storageDirConstant = $isValidFileOptions['storageDirConstant'];
124
125 $defaultFile = $isValidFileOptions['defaultFile'];
126 $defaultFileConstant = $isValidFileOptions['defaultFileConstant'];
127 $data .="\n" .
128 "/" . "**The directory where all files uploaded for $column->fullName will be stored.\n" .
129 "*/\n" .
130 "DEFINE('$storageDirConstant',$storageDir);\n";
131
132
133 $data .="\n" .
134 "/" . "**The default file for $column->fullName.\n" .
135 "*/\n" .
136 "DEFINE('$defaultFileConstant',$defaultFile);\n";
137 }
138 }
139 }
140 if ($databaseBackend && $webApplication) {
141 $data .="\n" .
142 "/" . "**Which method to call to get the records for the getOne controller.\n" .
143 "*/\n" .
144 "DEFINE('${projectNameUC}_GETONE_SELECT_METHOD_NAME', '$getOneSelectMethodName');\n" .
145 "\n" .
146 "/" . "**Which method to call to get the records for the get controller.\n" .
147 "*/\n" .
148 "DEFINE('${projectNameUC}_GET_SELECT_METHOD_NAME', '$getSelectMethodName');\n" .
149 "\n" .
150 "/" . "**Which method to call to get the records for the search controller.\n" .
151 "*/\n" .
152 "DEFINE('${projectNameUC}_SEARCH_SELECT_METHOD_NAME', '$searchSelectMethodName');\n" .
153 "\n" .
154 "/" . "**How many records to show in per page (if paging is activated).\n" .
155 "*/\n" .
156 "DEFINE('${projectNameUC}_RECORDS_PER_PAGE', '$recordsPerPage');\n";
157 }
158 if ($auth) {
159 $data .="\n\n" .
160 "/" . "**The table where the login information is stored.\n" .
161 "*/\n" .
162 "DEFINE('${projectNameUC}_AUTH_TABLE', '$authTable');\n" .
163 "\n" .
164 "/" . "**The username column.\n" .
165 "*/\n" .
166 "DEFINE('${projectNameUC}_AUTH_USERNAME_COLUMN', '$authUsernameColumn');\n" .
167 "\n" .
168 "/" . "**The password column.\n" .
169 "*/\n" .
170 "DEFINE('${projectNameUC}_AUTH_PASSWORD_COLUMN', '$authPasswordColumn');\n" .
171 "\n" .
172 "/" . "**The activated column.\n" .
173 "*/\n" .
174 "DEFINE('${projectNameUC}_AUTH_ACTIVATED_COLUMN', '$authActivatedColumn');\n" .
175 "\n" .
176 "/" . "**The crypttype for saving passwords.\n" .
177 "*/\n" .
178 "DEFINE('${projectNameUC}_AUTH_CRYPTTYPE', '$authCryptType');\n" .
179 "\n" .
180 "/" . "**The session name.\n" .
181 "*/\n" .
182 "DEFINE('${projectNameUC}_AUTH_SESSION_NAME', '$authSessionName');\n" .
183 "\n" .
184 "/" . "**The session timeout in seconds.\n" .
185 "*/\n" .
186 "DEFINE('${projectNameUC}_AUTH_SESSION_TIMEOUT', '$authSessionTimeout');\n" .
187 "\n" .
188 "/" . "**The session timeout in seconds.\n" .
189 "*/\n" .
190 "DEFINE('${projectNameUC}_AUTH_LOGOUT_URL', '$authLogoutURL');";
191 }
192 if ($liveUser) {
193 $data .= <<<END
194
195
196 /**The session name LiveUser uses for all sessions
197 */
198 DEFINE('${projectNameUC}_LIVEUSER_SESSION_NAME', '$liveUserSessionName');
199
200 /**The session name LiveUser uses for all sessions
201 */
202 DEFINE('${projectNameUC}_LIVEUSER_LOGIN_SUBMIT_METHOD', '$liveUserLoginSubmitMethod');
203
204 /**This flag determines if "remember me" cookies are allowed. If not, LiveUser won't even look for a cookie, so login information has to be re-entered for every session.
205 */
206 DEFINE('${projectNameUC}_LIVEUSER_REMEMBER_ME', '$liveUserRememberMe');
207
208 /**The name for the cookie to store auth information in (used for the "remember me" function).
209 */
210 DEFINE('${projectNameUC}_LIVEUSER_REMEMBER_ME_COOKIE_NAME', '$liveUserRememberMeCookieName');
211
212 /**The lifetime of the "remember me" cookie in days. Note that the cookie lifetime will be refreshed every time the user logs in.
213 */
214 DEFINE('${projectNameUC}_LIVEUSER_REMEMBER_ME_COOKIE_LIFETIME', '$liveUserRememberMeCookieLifetime');
215
216 /**The domain for the "remember me" cookie. To make the cookie available on all subdomains of example.com then you'd set it to '.example.com'. The . is not required but makes it compatible with more browsers. Setting it to www.example.com will make the cookie only available in the www subdomain.
217 */
218 DEFINE('${projectNameUC}_LIVEUSER_REMEMBER_ME_COOKIE_DOMAIN', '$liveUserRememberMeCookieDomain');
219
220 /**The path for the "remember me" cookie. If set to '/', the cookie will be available within the entire domain. If set to '/foo/', the cookie will only be available within the /foo/ directory and all sub-directories such as /foo/bar/ of domain. The default value is the current directory that the cookie is being set in.
221 */
222 DEFINE('${projectNameUC}_LIVEUSER_REMEMBER_ME_COOKIE_PATH', '$liveUserRememberMeCookiePath');
223
224 /**Secret key used for cookie value encryption
225 */
226 DEFINE('${projectNameUC}_LIVEUSER_REMEMBER_ME_COOKIE_SECRET_KEY', '$liveUserRememberMeCookieSecretKey');
227
228 /**The URL to redirect to when the user logs out.
229 */
230 DEFINE('${projectNameUC}_LIVEUSER_LOGOUT_REDIRECT_URL', '$liveUserLogoutRedirectURL');
231
232 /**Whether or not to destroy the entire session on logout.
233 */
234 DEFINE('${projectNameUC}_LIVEUSER_DESTROY_SESSION_ON_LOGOUT', '$liveUserDestroySessionOnLogout');
235
236 /**Maximum time of idleness in seconds. Idletime gets refreshed each time, init() is called. If this variable is set to 0, idle time is never checked.
237 */
238 DEFINE('${projectNameUC}_LIVEUSER_AUTH_IDLE_TIME', '$liveUserAuthIdleTime');
239
240 /**Number of hours that must pass between two logins to be counted as a new login.
241 * If you want the auth container to count each login as new login, you've to set it to 0.
242 */
243 DEFINE('${projectNameUC}_LIVEUSER_AUTH_LOGIN_TIMEOUT', '$liveUserAuthLoginTimeout');
244
245 /**Auth lifetime or maximum login time in seconds. If you want the user to be automaticly logged out after one hour, you've to set it to 3600.
246 * Attention: If you want to use expire, you should set loginTimeout to 0 !!!
247 */
248 DEFINE('${projectNameUC}_LIVEUSER_AUTH_EXPIRE_TIME', '$liveUserAuthExpireTime');
249
250 /**Whether to allow multiple users in the database to have the same login handle.
251 */
252 DEFINE('${projectNameUC}_LIVEUSER_AUTH_ALLOW_DUPLICATE_HANDLES', '$liveUserAuthAllowDuplicateHandles');
253
254 /**The encryption mode the password is stored in the container. You shouldn't use plain here for security reasons.
255 */
256 DEFINE('${projectNameUC}_LIVEUSER_AUTH_PASSWORD_ENCRYPTION_MODE', '$liveUserAuthPasswordEncryptionMode');
257
258 /**Whether to refresh a user's rights on every request or not.
259 */
260 DEFINE('${projectNameUC}_LIVEUSER_REFRESH_RIGHTS', '$liveUserRefreshRights');
261
262 /**The name of the database table to be used by the authentication container.
263 */
264 DEFINE('${projectNameUC}_LIVEUSER_AUTH_TABLE', '$liveUserAuthTable');
265
266 /**The name of the user-ID column in the table specified by ${projectNameUC}_LIVEUSER_AUTH_TABLE.
267 */
268 DEFINE('${projectNameUC}_LIVEUSER_AUTH_TABLE_COLUMN_USERID', '$liveUserAuthTableColumnUserid');
269
270 /**The name of the handle (username) column in the table specified by ${projectNameUC}_LIVEUSER_AUTH_TABLE.
271 */
272 DEFINE('${projectNameUC}_LIVEUSER_AUTH_TABLE_COLUMN_HANDLE', '$liveUserAuthTableColumnHandle');
273
274 /**The name of the password column in the table specified by ${projectNameUC}_LIVEUSER_AUTH_TABLE.
275 */
276 DEFINE('${projectNameUC}_LIVEUSER_AUTH_TABLE_COLUMN_PASSWORD', '$liveUserAuthTableColumnPassword');
277
278 /**The name of the last-login column in the table specified by ${projectNameUC}_LIVEUSER_AUTH_TABLE.
279 */
280 DEFINE('${projectNameUC}_LIVEUSER_AUTH_TABLE_COLUMN_LAST_LOGIN', '$liveUserAuthTableColumnLastLogin');
281
282 /**The name of the is-active column in the table specified by ${projectNameUC}_LIVEUSER_AUTH_TABLE.
283 */
284 DEFINE('${projectNameUC}_LIVEUSER_AUTH_TABLE_COLUMN_IS_ACTIVE', '$liveUserAuthTableColumnIsActive');
285
286
287 /**The "name" of the container.
288 * LiveUser includes the container found in /LiveUser/Perm/Container/"type".php and creates
289 * a new object \$_perm. For now available are 'DB_Simple', 'DB_Medium' and 'DB_Complex'.
290 */
291 DEFINE('${projectNameUC}_LIVEUSER_PERM_TYPE', '$liveUserPermType');
292
293 /**Prefix for all database tables used by the permission container.
294 */
295 DEFINE('${projectNameUC}_LIVEUSER_PERM_TABLE_PREFIX', '$liveUserPermTablePrefix');
296
297 /**The class name of the auth admin class.
298 */
299 DEFINE('${projectNameUC}_LIVEUSER_AUTH_ADMIN_CLASS', '$liveUserAuthAdminClass');
300
301 /**The path to the file that contains the class specified by ${projectNameUC}_LIVEUSER_AUTH_ADMIN_CLASS.
302 */
303 DEFINE('${projectNameUC}_LIVEUSER_AUTH_ADMIN_FILE', '$liveUserAuthAdminFile');
304
305 /**The class name of the perm admin class.
306 */
307 DEFINE('${projectNameUC}_LIVEUSER_PERM_ADMIN_CLASS', '$liveUserPermAdminClass');
308
309 /**The path to the file that contains the class specified by ${projectNameUC}_LIVEUSER_PERM_ADMIN_CLASS.
310 */
311 DEFINE('${projectNameUC}_LIVEUSER_PERM_ADMIN_FILE', '$liveUserPermAdminFile');
312 END;;; }
313
314 if ($webApplication) {
315 $data .="\n" .
316 "\n" .
317 "/" . "**Smarty Directory.\n" .
318 "*/\n" .
319 "DEFINE('${projectNameUC}_SMARTY_DIR', '$smartyDir');\n" .
320 "\n" .
321 "/" . "**Smarty left delimiter.\n" .
322 "*/\n" .
323 "DEFINE('${projectNameUC}_SMARTY_LEFT_DELIMITER', '$smartyLeftDelimiter');\n" .
324 "\n" .
325 "/" . "**Smarty right delimiter.\n" .
326 "*/\n" .
327 "DEFINE('${projectNameUC}_SMARTY_RIGHT_DELIMITER', '$smartyRightDelimiter');";
328 }
329
330
331 if ($mail) {
332 $data .="\n" .
333 "\n" .
334 "/" . "**The name of the backend mailer class.\n" .
335 "*/\n" .
336 "DEFINE('${projectNameUC}_MAIL_TYPE', '$mailType');\n" .
337 "\n" .
338 "/" . "**The default sender mail address.\n" .
339 "*/\n" .
340 "DEFINE('${projectNameUC}_MAIL_DEFAULT_SENDER', '$mailDefaultSender');\n";
341 if ($mailType == 'sendmail') {
342 $data .="\n" .
343 "/" . "**The location of the sendmail program on the filesystem.\n" .
344 "*/\n" .
345 "DEFINE('${projectNameUC}_MAIL_SENDMAIL_PATH', '$mailSendmailPath');\n" .
346 "\n" .
347 "/" . "**Additional parameters to pass to the sendmail program.\n" .
348 "*/\n" .
349 "DEFINE('${projectNameUC}_MAIL_SENDMAIL_ARGS', '$mailSendmailArgs');";
350 } elseif ($mailType == 'smtp') {
351 $data .="\n" .
352 "/" . "**The SMTP server to connect to.\n" .
353 "*/\n" .
354 "DEFINE('${projectNameUC}_MAIL_SMTP_HOST', '$mailSMTPHost');\n" .
355 "\n" .
356 "/" . "**The port to connect to.\n" .
357 "*/\n" .
358 "DEFINE('${projectNameUC}_MAIL_SMTP_PORT', '$mailSMTPPort');\n" .
359 "\n" .
360 "/" . "**Whether or not to use SMTP authentication.\n" .
361 "*/\n" .
362 "DEFINE('${projectNameUC}_MAIL_SMTP_AUTH', '$mailSMTPAuth');\n" .
363 "\n" .
364 "/" . "**The username to use for SMTP authentication.\n" .
365 "*/\n" .
366 "DEFINE('${projectNameUC}_MAIL_SMTP_USERNAME', '$mailSMTPUsername');\n" .
367 "\n" .
368 "/" . "**The password to use for SMTP authentication.\n" .
369 "*/\n" .
370 "DEFINE('${projectNameUC}_MAIL_SMTP_PASSWORD', '$mailSMTPPassword');";
371 }
372 }
373
374 $data .= "\n\n" . $additionalConfig;
375 return "<?php\n$data\n?>";
376 }
377 }
378 ?>
Documentation generated on Mon, 8 Dec 2003 13:11:03 +0100 by phpDocumentor 1.2.3