Source for file RSDEngineDBTemplateFileUpdateRight.php

Documentation is available at RSDEngineDBTemplateFileUpdateRight.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 RSDEngineDBTemplateFileUpdateRight.
20 *
21 * @package RSDEngine
22 * @author Lukas Feiler <lukas.feiler@chello.at>
23 * @copyright Lukas Feiler 2003
24 * @filesource
25 */
26
27 /**RSDEngineDBTemplateFileUpdateRight extends RSDEngineTemplateFile.
28 */
29 require_once('RSDEngine/RSDEngineTemplateFile.php');
30
31 /**Generates the smarty template file for updating a LiveUser right.
32 *
33 * @author Lukas Feiler <lukas.feiler@chello.at>
34 * @version 0.1.9
35 * @copyright Lukas Feiler 2003
36 * @package RSDEngine
37 */
38 class RSDEngineDBTemplateFileUpdateRight extends RSDEngineTemplateFile {
39
40 /**Whether to overwrite an existing file.
41 * @var boolean
42 */
43 var $overwriteExisting = false;
44
45 /**Returns the filename.
46 * @return String
47 */
48 function getFilename()
49 {
50 return "update" . ucfirst($this->config['table']->getTableNameWithoutPrefix()) . "Right" . ucfirst($this->config['column']->getColumnNameForVariableName()) . ".tpl";
51 }
52
53 /**Returns the filename of the corresponding controller.
54 * @return String
55 */
56 function getControllerFilename()
57 {
58 return "update" . ucfirst($this->config['table']->getTableNameWithoutPrefix()) . "Right" . ucfirst($this->config['column']->getColumnNameForVariableName()) . ".php";
59 }
60
61 /**Returns the code for the template file for updating a LiveUser right.
62 *
63 * @access private
64 * @return String The code for the file.
65 */
66 function getCode()
67 {
68 extract($this->config);
69 $table =& $this->config['table'];
70 $OPEN = $smartyLeftDelimiter;
71 $CLOSE = $smartyRightDelimiter;
72 $authors = RSArrayUtil::toString(split("\n",$authors),"\n",'* @author %val');
73 $records = ucfirst($this->config['table']->getTableNameWithoutPrefix());
74 $tableInstanceName = $table->getChildClassInstanceName();
75 $appInstanceName = $this->relatedClasses['dbApplicationClass']->getInstanceName();
76 $columnName = $column->name;
77 $columnNameForVariableName = $column->getColumnNameForVariableName();
78 $columnNameForPartialMethodName = $column->getColumnNameForPartialMethodName();
79 $tableNameForVariableName = $table->getTableNameForVariableName();
80
81 $header = $table->getFileOptionProperty('updateTemplate', 'header');
82 $footer = $table->getFileOptionProperty('updateTemplate', 'footer');
83 $write = $table->getFileOptionProperty('updateTemplate', 'write');
84
85 $this->setWrite($write);
86
87 $data = '';
88 if (($primaryKeyColumn = $table->getPrimaryKeyColumn()) === false) {
89 $data .="No primary key was defined! Without a primary key the RSDEngine cannot generate code to update a single record!";
90 return "$data?>";
91 }
92 $primaryKeyColumnNameForVariableName = $primaryKeyColumn->getColumnNameForVariableName();
93
94 $data .= <<<END
95 <html>
96 <head>
97 <title>update $tableNameForVariableName Right $columnNameForVariableName</title>
98 </head>
99 <body>
100 END;;; if ($header) {
101 $data .="{{include file=\"header.tpl\"}}\n";
102 }
103
104
105 $data .= <<<END
106 ${OPEN}if \$error${CLOSE}
107 <font color="red">An error occured!</font>
108 ${OPEN}/if${CLOSE}
109 <form name="endlosForm" enctype="multipart/form-data" method="POST">
110 <table>
111 ${OPEN}if \$canGrant${columnNameForPartialMethodName}ToUsers${CLOSE}
112 <tr>
113 <td>Grant right to user:</td>
114 <td>
115 <select name="grant${columnNameForPartialMethodName}ToUsers[]" multiple="true">
116 ${OPEN}html_options options=\$grant${columnNameForPartialMethodName}ToUsersOptions selected=\$grant${columnNameForPartialMethodName}ToUsersSelected${CLOSE}
117 </select>
118 ${OPEN}if \$grant${columnNameForPartialMethodName}ToUsersError${CLOSE}
119 <font color="red">&nbsp;&nbsp;An error occurred.</font>
120 ${OPEN}/if${CLOSE}
121 </td>
122 </tr>
123 ${OPEN}/if${CLOSE}
124 ${OPEN}if \$canRevoke${columnNameForPartialMethodName}FromUsers${CLOSE}
125 <tr>
126 <td>Revoke right from user:</td>
127 <td>
128 <select name="revoke${columnNameForPartialMethodName}FromUsers[]" multiple="true">
129 ${OPEN}html_options options=\$revoke${columnNameForPartialMethodName}FromUsersOptions selected=\$revoke${columnNameForPartialMethodName}FromUsersSelected${CLOSE}
130 </select>
131 ${OPEN}if \$revoke${columnNameForPartialMethodName}FromUsersError${CLOSE}
132 <font color="red">&nbsp;&nbsp;An error occurred.</font>
133 ${OPEN}/if${CLOSE}
134 </td>
135 </tr>
136 ${OPEN}/if${CLOSE}
137
138 ${OPEN}if \$canGrant${columnNameForPartialMethodName}ToGroups${CLOSE}
139 <tr>
140 <td>Grant right to group:</td>
141 <td>
142 <select name="grant${columnNameForPartialMethodName}ToGroups[]" multiple="true">
143 ${OPEN}html_options options=\$grant${columnNameForPartialMethodName}ToGroupsOptions selected=\$grant${columnNameForPartialMethodName}ToGroupsSelected${CLOSE}
144 </select>
145 ${OPEN}if \$grant${columnNameForPartialMethodName}ToGroupsError${CLOSE}
146 <font color="red">&nbsp;&nbsp;An error occurred.</font>
147 ${OPEN}/if${CLOSE}
148 </td>
149 </tr>
150 ${OPEN}/if${CLOSE}
151 ${OPEN}if \$canRevoke${columnNameForPartialMethodName}FromGroups${CLOSE}
152 <tr>
153 <td>Revoke right from group:</td>
154 <td>
155 <select name="revoke${columnNameForPartialMethodName}FromGroups[]" multiple="true">
156 ${OPEN}html_options options=\$revoke${columnNameForPartialMethodName}FromGroupsOptions selected=\$revoke${columnNameForPartialMethodName}FromGroupsSelected${CLOSE}
157 </select>
158 ${OPEN}if \$revoke${columnNameForPartialMethodName}FromGroupsError${CLOSE}
159 <font color="red">&nbsp;&nbsp;An error occurred.</font>
160 ${OPEN}/if${CLOSE}
161 </td>
162 </tr>
163 ${OPEN}/if${CLOSE}
164
165 <tr>
166 <td></td>
167 <td>
168 <input type="hidden" name="action" value="1">
169 <input type="hidden" name="$primaryKeyColumnNameForVariableName" value="${OPEN}\$$primaryKeyColumnNameForVariableName${CLOSE}">
170 <input type="submit" value="Update">
171 <input type="submit" value="Next >>" name="next">
172 </td>
173 <tr>
174 </table>
175 </form>
176 END;;;
177 if ($footer) {
178 $data .="{{include file=\"footer.tpl\"}}\n";
179 }
180
181 $data .= <<<END
182 </body>
183 </html>
184
185 END;;; return $data;
186 }
187 }
188 ?>

Documentation generated on Mon, 8 Dec 2003 13:12:42 +0100 by phpDocumentor 1.2.3