Changeset 1090
- Timestamp:
- 09/06/06 09:01:54 (5 years ago)
- Location:
- trunk/wifidog-auth
- Files:
-
- 5 added
- 58 modified
- 2 moved
-
CHANGELOG (modified) (2 diffs)
-
sql/wifidog-postgres-initial-data.sql (modified) (3 diffs)
-
sql/wifidog-postgres-schema.sql (modified) (21 diffs)
-
wifidog/admin/generic_object_admin.php (modified) (3 diffs)
-
wifidog/classes/Authenticator.php (modified) (9 diffs)
-
wifidog/classes/Authenticators/AuthenticatorLDAP.php (modified) (11 diffs)
-
wifidog/classes/Authenticators/AuthenticatorLocalUser.php (modified) (7 diffs)
-
wifidog/classes/Authenticators/AuthenticatorLocalUserNoSignup.php (modified) (1 diff)
-
wifidog/classes/Authenticators/AuthenticatorRadius.php (modified) (10 diffs)
-
wifidog/classes/Cache.php (modified) (13 diffs)
-
wifidog/classes/Content.php (modified) (72 diffs)
-
wifidog/classes/Content/Avatar/Avatar.php (modified) (4 diffs)
-
wifidog/classes/Content/BannerAdGroup (added)
-
wifidog/classes/Content/BannerAdGroup/BannerAdGroup.php (added)
-
wifidog/classes/Content/ContentGroup/ContentGroup.php (modified) (2 diffs)
-
wifidog/classes/Content/ContentGroup/ContentGroupElement.php (modified) (20 diffs)
-
wifidog/classes/Content/EmbeddedContent/EmbeddedContent.php (modified) (10 diffs)
-
wifidog/classes/Content/File/File.php (modified) (2 diffs)
-
wifidog/classes/Content/FlickrPhotostream/FlickrPhotostream.php (modified) (1 diff)
-
wifidog/classes/Content/HTMLeditor/HTMLeditor.php (modified) (4 diffs)
-
wifidog/classes/Content/IFrame/IFrame.php (modified) (11 diffs)
-
wifidog/classes/Content/IFrameRest/IFrameRest.php (modified) (4 diffs)
-
wifidog/classes/Content/Langstring/Langstring.php (modified) (9 diffs)
-
wifidog/classes/Content/PatternLanguage/PatternLanguage.php (modified) (6 diffs)
-
wifidog/classes/Content/Picture/Picture.php (modified) (10 diffs)
-
wifidog/classes/Content/RssAggregator/RssAggregator.php (modified) (17 diffs)
-
wifidog/classes/Content/SimpleIFrame/SimpleIFrame.php (modified) (3 diffs)
-
wifidog/classes/Content/SimplePicture/SimplePicture.php (modified) (3 diffs)
-
wifidog/classes/Content/TrivialLangstring/TrivialLangstring.php (modified) (3 diffs)
-
wifidog/classes/ContentTypeFilter.php (added)
-
wifidog/classes/DateTime.php (modified) (2 diffs)
-
wifidog/classes/HtmlSafe.php (modified) (14 diffs)
-
wifidog/classes/InterfaceElements.php (modified) (16 diffs)
-
wifidog/classes/Mail.php (modified) (2 diffs)
-
wifidog/classes/Network.php (modified) (24 diffs)
-
wifidog/classes/Node.php (modified) (2 diffs)
-
wifidog/classes/NodeList.php (modified) (4 diffs)
-
wifidog/classes/NodeLists/NodeListHTML.php (modified) (8 diffs)
-
wifidog/classes/NodeLists/NodeListJiWireCSV.php (modified) (5 diffs)
-
wifidog/classes/NodeLists/NodeListKML.php (modified) (6 diffs)
-
wifidog/classes/NodeLists/NodeListPDF.php (modified) (41 diffs)
-
wifidog/classes/NodeLists/NodeListRSS.php (modified) (6 diffs)
-
wifidog/classes/NodeLists/NodeListXML.php (modified) (6 diffs)
-
wifidog/classes/Security.php (modified) (2 diffs)
-
wifidog/classes/Server.php (modified) (21 diffs)
-
wifidog/classes/Session.php (modified) (7 diffs)
-
wifidog/classes/SmartyWifidog.php (modified) (1 diff)
-
wifidog/classes/ThemePack.php (modified) (10 diffs)
-
wifidog/classes/User.php (modified) (6 diffs)
-
wifidog/config.php (modified) (1 diff)
-
wifidog/cron/page.php (modified) (2 diffs)
-
wifidog/include/path_defines_url_content.php (modified) (1 diff)
-
wifidog/include/schema_validate.php (modified) (2 diffs)
-
wifidog/lib/PHPMailer (added)
-
wifidog/lib/PHPMailer/class.phpmailer.php (moved) (moved from trunk/wifidog-auth/wifidog/include/class.phpmailer.php)
-
wifidog/lib/RssPressReview (modified) (1 prop)
-
wifidog/lib/SMTP (added)
-
wifidog/lib/SMTP/class.smtp.php (moved) (moved from trunk/wifidog-auth/wifidog/include/class.smtp.php)
-
wifidog/lib/fpdf (modified) (1 prop)
-
wifidog/lib/magpie (modified) (1 prop)
-
wifidog/lib/smarty (modified) (1 prop)
-
wifidog/login/index.php (modified) (2 diffs)
-
wifidog/portal/index.php (modified) (1 diff)
-
wifidog/templates/classes/MainUI_ToolSection.tpl (modified) (1 diff)
-
wifidog/tmp (modified) (1 prop)
Legend:
- Unmodified
- Added
- Removed
-
trunk/wifidog-auth/CHANGELOG
r1089 r1090 1 2006-09-06 Benoit Grégoire <bock@step.polymtl.ca> 2 * ContentTypeFilter: New class, implements #159. Allows to filter content type according to various criteria. Will be used more extensively in the profile manager. 3 * Content manager: Use content type filter to only allow Simple content types (Content without metadata) to be used for metadata. 4 * New content type BannerAdGroup. Used (primarily) to display banner adds, or any other image rotation. Size constraints not yet implemented 5 * Move externally maintained class.phpmailer.php, class.smtp.php into lib where they belong 6 * DateTime.php: Make class handle an empty date sensibly. 7 * Network.php: Show the network again when there is only one. It was confusing in some screens. 8 * page.php: Clarify error message, and set a more reasonnable paging cascade: 9 5 min, 30 min, 2 hours, 1 day, 1 week, 1 month 10 * Finally fix #127 11 * At last, working content scheduled display and expiration for ContentGroups. Archiving does not yet have a UI. Content that expires will simply seem to disapear. 12 * Fix #247 (somebody filed a bug before I commited, conveniently saving me the need to describe it). 13 * The Fix for #106 in [1089] returned non-objects, causing error messages and not displaying what it was meant to display. 14 This re-fix does not include duplicate counting yet. Splash users are not the only users that could log-in multiple times. 15 I don't have a staging server here, a fix will be commited in a few minutes if something goes wrong. 16 * Cleanup coments. 17 * Sync schemas 18 1 19 2006-09-03 Max Horváth <max.horvath@maxspot.de> 2 20 * The term SPLASH_ONLY_USER displayed to people visiting the portal has been … … 26 44 27 45 2006-09-01 Benoit Grégoire <bock@step.polymtl.ca> 28 * Fix #189, #173, 46 * Fix #189, #173 47 29 48 30 49 2006-09-01 Benoit Grégoire <bock@step.polymtl.ca> -
trunk/wifidog-auth/sql/wifidog-postgres-initial-data.sql
r1029 r1090 1 \connect wifidog;2 1 BEGIN; 3 2 -- … … 175 174 -- 176 175 177 INSERT INTO schema_info (tag, value) VALUES ('schema_version', ' 39');176 INSERT INTO schema_info (tag, value) VALUES ('schema_version', '46'); 178 177 179 178 … … 200 199 INSERT INTO locales (locales_id) VALUES ('de'); 201 200 INSERT INTO locales (locales_id) VALUES ('pt'); 201 INSERT INTO locales (locales_id) VALUES ('ja'); 202 INSERT INTO locales (locales_id) VALUES ('es'); 202 203 203 204 -
trunk/wifidog-auth/sql/wifidog-postgres-schema.sql
r1024 r1090 73 73 description text, 74 74 project_info text, 75 sponsor_info text,76 75 creation_timestamp timestamp without time zone DEFAULT now(), 77 76 is_persistent boolean DEFAULT false, 78 77 long_description text, 78 title_is_displayed boolean DEFAULT true NOT NULL, 79 79 CONSTRAINT content_type_not_empty_string CHECK ((content_type <> ''::text)) 80 80 ); 81 81 82 83 SET default_with_oids = false;84 82 85 83 -- … … 92 90 93 91 94 SET default_with_oids = true;95 96 92 -- 97 93 -- Name: content_available_display_pages; Type: TABLE; Schema: public; Owner: wifidog; Tablespace: … … 102 98 ); 103 99 100 101 SET default_with_oids = false; 102 103 -- 104 -- Name: content_clickthrough_log; Type: TABLE; Schema: public; Owner: wifidog; Tablespace: 105 -- 106 107 CREATE TABLE content_clickthrough_log ( 108 user_id text, 109 content_id text NOT NULL, 110 clickthrough_timestamp timestamp without time zone DEFAULT now() NOT NULL, 111 node_id text NOT NULL, 112 destination_url text NOT NULL, 113 CONSTRAINT content_clickthrough_log_destination_url_check CHECK ((destination_url <> ''::text)) 114 ); 115 116 117 SET default_with_oids = true; 104 118 105 119 -- … … 140 154 url text, 141 155 data_blob oid, 142 local_binary_size bigint 156 local_binary_size bigint, 157 creation_date timestamp without time zone DEFAULT now(), 158 last_update_date timestamp without time zone DEFAULT now() 143 159 ); 144 160 … … 151 167 pictures_id text NOT NULL, 152 168 width integer, 153 height integer 169 height integer, 170 hyperlink_url text 154 171 ); 155 172 … … 209 226 display_order integer DEFAULT 1, 210 227 displayed_content_id text, 211 force_only_allowed_node boolean 228 force_only_allowed_node boolean, 229 valid_from_timestamp timestamp without time zone, 230 valid_until_timestamp timestamp without time zone 212 231 ); 213 232 … … 342 361 gmaps_initial_zoom_level integer, 343 362 gmaps_map_type text DEFAULT 'G_NORMAL_MAP'::text NOT NULL, 344 CONSTRAINT networks_gmaps_map_type_check CHECK ((gmaps_map_type <> ''::text)), 363 theme_pack text, 364 CONSTRAINT networks_gmaps_map_type CHECK ((gmaps_map_type <> ''::text)), 345 365 CONSTRAINT networks_name CHECK ((name <> ''::text)), 346 366 CONSTRAINT networks_network_authenticator_class CHECK ((network_authenticator_class <> ''::text)), … … 435 455 436 456 437 SET default_with_oids = false;438 439 457 -- 440 458 -- Name: servers; Type: TABLE; Schema: public; Owner: wifidog; Tablespace: … … 449 467 ssl_available boolean DEFAULT false NOT NULL, 450 468 gmaps_api_key text, 451 CONSTRAINT servers_name_check CHECK ((name <> ''::text)), 452 CONSTRAINT servers_name_check1 CHECK ((name <> ''::text)) 453 ); 454 455 456 SET default_with_oids = true; 469 CONSTRAINT servers_hostname CHECK ((name <> ''::text)), 470 CONSTRAINT servers_name CHECK ((name <> ''::text)) 471 ); 472 457 473 458 474 -- … … 493 509 website text, 494 510 prefered_locale text, 495 CONSTRAINT check_account_origin_not_empty CHECK ((account_origin <> ''::text)),496 511 CONSTRAINT check_user_not_empty CHECK (((user_id)::text <> ''::text)) 497 512 ); … … 796 811 797 812 -- 813 -- Name: idx_content_group_element_valid_from_timestamp; Type: INDEX; Schema: public; Owner: wifidog; Tablespace: 814 -- 815 816 CREATE INDEX idx_content_group_element_valid_from_timestamp ON content_group_element USING btree (valid_from_timestamp); 817 818 819 -- 820 -- Name: idx_content_group_element_valid_until_timestamp; Type: INDEX; Schema: public; Owner: wifidog; Tablespace: 821 -- 822 823 CREATE INDEX idx_content_group_element_valid_until_timestamp ON content_group_element USING btree (valid_until_timestamp); 824 825 826 -- 798 827 -- Name: idx_token; Type: INDEX; Schema: public; Owner: wifidog; Tablespace: 799 828 -- … … 945 974 946 975 -- 947 -- Name: $1; Type: FK CONSTRAINT; Schema: public; Owner: wifidog948 --949 950 ALTER TABLE ONLY network_stakeholders951 ADD CONSTRAINT "$1" FOREIGN KEY (network_id) REFERENCES networks(network_id);952 953 954 --955 976 -- Name: $2; Type: FK CONSTRAINT; Schema: public; Owner: wifidog 956 977 -- … … 1020 1041 -- 1021 1042 1022 ALTER TABLE ONLY node_stakeholders 1023 ADD CONSTRAINT "$2" FOREIGN KEY (user_id) REFERENCES users(user_id); 1024 1025 1026 -- 1027 -- Name: $2; Type: FK CONSTRAINT; Schema: public; Owner: wifidog 1028 -- 1029 1030 ALTER TABLE ONLY network_stakeholders 1031 ADD CONSTRAINT "$2" FOREIGN KEY (user_id) REFERENCES users(user_id); 1043 ALTER TABLE ONLY network_has_content 1044 ADD CONSTRAINT "$2" FOREIGN KEY (display_area) REFERENCES content_available_display_areas(display_area) ON UPDATE CASCADE ON DELETE CASCADE; 1032 1045 1033 1046 … … 1057 1070 1058 1071 -- 1059 -- Name: $ 4; Type: FK CONSTRAINT; Schema: public; Owner: wifidog1060 -- 1061 1062 ALTER TABLE ONLY content1063 ADD CONSTRAINT "$ 4" FOREIGN KEY (sponsor_info) REFERENCES content(content_id) ON UPDATE CASCADE ON DELETE RESTRICT;1072 -- Name: $3; Type: FK CONSTRAINT; Schema: public; Owner: wifidog 1073 -- 1074 1075 ALTER TABLE ONLY node_has_content 1076 ADD CONSTRAINT "$3" FOREIGN KEY (display_area) REFERENCES content_available_display_areas(display_area) ON UPDATE CASCADE ON DELETE CASCADE; 1064 1077 1065 1078 … … 1077 1090 1078 1091 ALTER TABLE ONLY users 1079 ADD CONSTRAINT account_origin_fkey FOREIGN KEY (account_origin) REFERENCES networks(network_id) ON UPDATE CASCADE ON DELETE RESTRICT;1092 ADD CONSTRAINT account_origin_fkey FOREIGN KEY (account_origin) REFERENCES networks(network_id) ON UPDATE CASCADE ON DELETE CASCADE; 1080 1093 1081 1094 … … 1089 1102 1090 1103 -- 1104 -- Name: content_clickthrough_log_content_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: wifidog 1105 -- 1106 1107 ALTER TABLE ONLY content_clickthrough_log 1108 ADD CONSTRAINT content_clickthrough_log_content_id_fkey FOREIGN KEY (content_id) REFERENCES content(content_id) ON UPDATE CASCADE ON DELETE CASCADE; 1109 1110 1111 -- 1112 -- Name: content_clickthrough_log_node_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: wifidog 1113 -- 1114 1115 ALTER TABLE ONLY content_clickthrough_log 1116 ADD CONSTRAINT content_clickthrough_log_node_id_fkey FOREIGN KEY (node_id) REFERENCES nodes(node_id) ON UPDATE CASCADE ON DELETE CASCADE; 1117 1118 1119 -- 1120 -- Name: content_clickthrough_log_user_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: wifidog 1121 -- 1122 1123 ALTER TABLE ONLY content_clickthrough_log 1124 ADD CONSTRAINT content_clickthrough_log_user_id_fkey FOREIGN KEY (user_id) REFERENCES users(user_id) ON UPDATE CASCADE ON DELETE CASCADE; 1125 1126 1127 -- 1091 1128 -- Name: display_location_fkey; Type: FK CONSTRAINT; Schema: public; Owner: wifidog 1092 1129 -- … … 1105 1142 1106 1143 -- 1144 -- Name: fk_network; Type: FK CONSTRAINT; Schema: public; Owner: wifidog 1145 -- 1146 1147 ALTER TABLE ONLY network_stakeholders 1148 ADD CONSTRAINT fk_network FOREIGN KEY (network_id) REFERENCES networks(network_id) ON UPDATE CASCADE ON DELETE CASCADE; 1149 1150 1151 -- 1107 1152 -- Name: fk_node_deployment_status; Type: FK CONSTRAINT; Schema: public; Owner: wifidog 1108 1153 -- … … 1117 1162 1118 1163 ALTER TABLE ONLY connections 1119 ADD CONSTRAINT fk_nodes FOREIGN KEY (node_id) REFERENCES nodes(node_id) ON UPDATE CASCADE ON DELETE RESTRICT;1164 ADD CONSTRAINT fk_nodes FOREIGN KEY (node_id) REFERENCES nodes(node_id) ON UPDATE CASCADE ON DELETE CASCADE; 1120 1165 1121 1166 … … 1125 1170 1126 1171 ALTER TABLE ONLY connections 1127 ADD CONSTRAINT fk_users FOREIGN KEY (user_id) REFERENCES users(user_id) ON UPDATE CASCADE ON DELETE RESTRICT; 1172 ADD CONSTRAINT fk_users FOREIGN KEY (user_id) REFERENCES users(user_id) ON UPDATE CASCADE ON DELETE CASCADE; 1173 1174 1175 -- 1176 -- Name: fk_users; Type: FK CONSTRAINT; Schema: public; Owner: wifidog 1177 -- 1178 1179 ALTER TABLE ONLY node_stakeholders 1180 ADD CONSTRAINT fk_users FOREIGN KEY (user_id) REFERENCES users(user_id) ON UPDATE CASCADE ON DELETE CASCADE; 1181 1182 1183 -- 1184 -- Name: fk_users; Type: FK CONSTRAINT; Schema: public; Owner: wifidog 1185 -- 1186 1187 ALTER TABLE ONLY network_stakeholders 1188 ADD CONSTRAINT fk_users FOREIGN KEY (user_id) REFERENCES users(user_id) ON UPDATE CASCADE ON DELETE CASCADE; 1128 1189 1129 1190 … … 1145 1206 1146 1207 -- 1147 -- Name: network_has_content_display_area_fkey; Type: FK CONSTRAINT; Schema: public; Owner: wifidog1148 --1149 1150 ALTER TABLE ONLY network_has_content1151 ADD CONSTRAINT network_has_content_display_area_fkey FOREIGN KEY (display_area) REFERENCES content_available_display_areas(display_area) ON UPDATE CASCADE ON DELETE CASCADE;1152 1153 1154 --1155 -- Name: network_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: wifidog1156 --1157 1158 ALTER TABLE ONLY nodes1159 ADD CONSTRAINT network_id_fkey FOREIGN KEY (network_id) REFERENCES networks(network_id) ON UPDATE CASCADE ON DELETE RESTRICT;1160 1161 1162 --1163 1208 -- Name: network_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: wifidog 1164 1209 -- … … 1169 1214 1170 1215 -- 1171 -- Name: n ode_has_content_display_area_fkey; Type: FK CONSTRAINT; Schema: public; Owner: wifidog1172 -- 1173 1174 ALTER TABLE ONLY node _has_content1175 ADD CONSTRAINT n ode_has_content_display_area_fkey FOREIGN KEY (display_area) REFERENCES content_available_display_areas(display_area) ON UPDATE CASCADE ON DELETE CASCADE;1216 -- Name: network_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: wifidog 1217 -- 1218 1219 ALTER TABLE ONLY nodes 1220 ADD CONSTRAINT network_id_fkey FOREIGN KEY (network_id) REFERENCES networks(network_id) ON UPDATE CASCADE ON DELETE CASCADE; 1176 1221 1177 1222 -
trunk/wifidog-auth/wifidog/admin/generic_object_admin.php
r1089 r1090 92 92 $supportsPreview = true; 93 93 $supportsDeletion = true; 94 94 /* 95 * Check for the object class to use 96 */ 97 if (empty($_REQUEST['object_class'])) { 98 echo "<div class='errormsg'>"._("Sorry, the 'object_class' parameter must be specified")."</div>\n"; 99 exit; 100 } else { 101 $class = $_REQUEST['object_class']; 102 } 95 103 // Init text values 96 104 $createText = sprintf(_("Create %s"), $_REQUEST['object_class']); … … 115 123 116 124 /* 117 * Check for the object class to use118 */119 if (empty($_REQUEST['object_class'])) {120 echo "<div class='errormsg'>"._("Sorry, the 'object_class' parameter must be specified")."</div>\n";121 exit;122 } else {123 $class = $_REQUEST['object_class'];124 }125 126 /*127 125 * Check for action requests 128 126 */ … … 266 264 case "Content": 267 265 $displayShowAllButton = true; 268 $objectSelector = Content::getSelectExistingContentUI('object_id', null, ((isset($_REQUEST['display_content']) && $_REQUEST['display_content'] == "all_content") ? false : true), "content_type", "table"); 266 ((isset($_REQUEST['display_content']) && $_REQUEST['display_content'] == "all_content") ? $sql_additional_where = null : $sql_additional_where = " AND is_persistent=TRUE "); 267 $objectSelector = Content::getSelectExistingContentUI('object_id', $sql_additional_where, null, "content_type", "table"); 269 268 $displayEditButton = false; 270 269 break; -
trunk/wifidog-auth/wifidog/classes/Authenticator.php
r1031 r1090 69 69 * 70 70 * @var object 71 * 72 * @access private 71 73 72 */ 74 73 private $mNetwork; … … 80 79 * 81 80 * @return void 82 *83 * @access public84 81 */ 85 82 public function __construct($network_id) … … 92 89 * 93 90 * @return object Object of current network 94 *95 * @access public96 91 */ 97 92 public function getNetwork() … … 104 99 * 105 100 * If successfull, returns a User object. 106 *107 * @access public108 101 */ 109 102 public function login() … … 124 117 * 125 118 * @return void 126 *127 * @access public128 119 */ 129 120 public function logout($conn_id = null) … … 190 181 * 191 182 * @return void 192 *193 * @access public194 183 */ 195 184 public function acctStart($conn_id) … … 244 233 * 245 234 * @return void 246 *247 * @access public248 235 */ 249 236 public function acctUpdate($conn_id, $incoming, $outgoing) … … 264 251 * 265 252 * @return void 266 *267 * @access public268 253 * */ 269 254 public function acctStop($conn_id) … … 281 266 * 282 267 * @return bool Returns if the class allows registration 283 *284 * @access public285 268 */ 286 269 public function isRegistrationPermitted() -
trunk/wifidog-auth/wifidog/classes/Authenticators/AuthenticatorLDAP.php
r1022 r1090 69 69 * 70 70 * @var string 71 * 72 * @access private 71 73 72 */ 74 73 private $mldap_hostname; … … 78 77 * 79 78 * @var string 80 * 81 * @access private 79 82 80 */ 83 81 private $mldap_rdn; … … 87 85 * 88 86 * @var string 89 * 90 * @access private 87 91 88 */ 92 89 private $mldap_pass; … … 96 93 * 97 94 * @var string 98 * 99 * @access private 95 100 96 */ 101 97 private $mldap_o; … … 106 102 * 107 103 * @var string 108 * 109 * @access private 104 110 105 */ 111 106 private $mldap_filter; … … 129 124 * 130 125 * @return void 131 *132 * @access public133 126 */ 134 127 public function __construct($account_orgin, $host, $rdn, $pass, $o, $filter) … … 156 149 * 157 150 * @return bool True if the parameter refers to a Local User account origin 158 * 159 * @access private 151 160 152 */ 161 153 private function checkLdapUser($username, $password, $ldap_server, $o, $f, &$errmsg = null ) … … 237 229 * @return object The actual User object if login was successfull, false 238 230 * otherwise. 239 *240 * @access public241 231 */ 242 232 public function login($username, $password, &$errmsg = null) … … 292 282 * 293 283 * @return bool Returns always true 294 *295 * @access public296 284 */ 297 285 public function acctStart($conn_id, &$errmsg = null) … … 312 300 * 313 301 * @return bool Returns always true 314 *315 * @access public316 302 */ 317 303 public function acctUpdate($conn_id, $incoming, $outgoing, &$errmsg = null) … … 331 317 * 332 318 * @return bool Returns always true 333 *334 * @access public335 319 */ 336 320 public function acctStop($conn_id, &$errmsg = null) -
trunk/wifidog-auth/wifidog/classes/Authenticators/AuthenticatorLocalUser.php
r1031 r1090 71 71 * 72 72 * @return void 73 *74 * @access public75 73 */ 76 74 public function __construct($account_orgin) … … 86 84 * 87 85 * @return bool True if the parameter refers to a Local User account origin 88 * 89 * @access private 86 90 87 */ 91 88 private static function isLocalUserAccountOrigin($account_origin) … … 107 104 * @return object The actual User object if login was successfull, false 108 105 * otherwise. 109 *110 * @access public111 106 */ 112 107 public function login($username, $password, &$errmsg = null) … … 164 159 * 165 160 * @return bool Returns always true 166 *167 * @access public168 161 */ 169 162 public function acctStart($conn_id, &$errmsg = null) … … 184 177 * 185 178 * @return bool Returns always true 186 *187 * @access public188 179 */ 189 180 public function acctUpdate($conn_id, $incoming, $outgoing, &$errmsg = null) … … 203 194 * 204 195 * @return bool Returns always true 205 *206 * @access public207 196 */ 208 197 public function acctStop($conn_id, &$errmsg = null) … … 218 207 * 219 208 * @return bool Returns if the class allows registration 220 *221 * @access public222 209 */ 223 210 public function isRegistrationPermitted() -
trunk/wifidog-auth/wifidog/classes/Authenticators/AuthenticatorLocalUserNoSignup.php
r1031 r1090 63 63 * 64 64 * @return bool Returns if the class allows registration 65 *66 * @access public67 65 */ 68 66 function isRegistrationPermitted() -
trunk/wifidog-auth/wifidog/classes/Authenticators/AuthenticatorRadius.php
r1031 r1090 76 76 * 77 77 * @var string 78 * 79 * @access private 78 80 79 */ 81 80 private $mRadius_hostname; … … 85 84 * 86 85 * @var int 87 * 88 * @access private 86 89 87 */ 90 88 private $mRadius_auth_port; … … 94 92 * 95 93 * @var int 96 * 97 * @access private 94 98 95 */ 99 96 private $mRadius_acct_port; … … 103 100 * 104 101 * @var string 105 * 106 * @access private 102 107 103 */ 108 104 private $mRadius_secret_key; … … 112 108 * 113 109 * @var string 114 * 115 * @access private 110 116 111 */ 117 112 private $mRadius_encryption_method; … … 133 128 * 134 129 * @return void 135 *136 * @access public137 130 */ 138 131 public function __construct($account_orgin, $host = "localhost", $auth_port = 1812, $acct_port = 1813, $secret_key = "", $encryption_method = "CHAP_MD5") … … 176 169 * @return object The actual User object if login was successfull, 177 170 * false otherwise. 178 *179 * @access public180 171 */ 181 172 public function login($username, $password, &$errmsg = null) … … 314 305 * 315 306 * @return bool Returns whether successful or not 316 *317 * @access public318 307 */ 319 308 public function acctStart($conn_id, &$errmsg = null) … … 383 372 * 384 373 * @return bool Returns whether successful or not 385 *386 * @access public387 374 */ 388 375 function acctUpdate($conn_id, $incoming, $outgoing, & $errmsg = null) … … 455 442 * 456 443 * @return bool Returns whether successful or not 457 *458 * @access public459 444 */ 460 445 function acctStop($conn_id, &$errmsg = null) -
trunk/wifidog-auth/wifidog/classes/Cache.php
r1013 r1090 57 57 * Defines if caching is enabled or not 58 58 * 59 * @var bool60 * @access public61 59 */ 62 60 public $isCachingEnabled = false; … … 65 63 * Lifetime of cache (value in seconds or null). 66 64 * 67 * @var mixed (int or null) 68 * @access private 65 69 66 */ 70 67 private $_lifeTime = null; … … 73 70 * PEAR::Cache_Lite object. 74 71 * 75 * @var object 76 * @access private 72 77 73 */ 78 74 private $_cacheLite; … … 81 77 * ID of PEAR::Cache_Lite object. 82 78 * 83 * @var mixed (string or null) 84 * @access private 79 85 80 */ 86 81 private $_cacheID = null; … … 89 84 * Group of PEAR::Cache_Lite object. 90 85 * 91 * @var string 92 * @access private 86 93 87 */ 94 88 private $_cacheGroup = "default"; … … 101 95 * 102 96 * @return void 103 *104 * @access public105 97 */ 106 98 public function __construct($id, $group = "default", $lifeTime = null) … … 141 133 * 142 134 * @return bool Caching enabled or disabled. 143 * 144 * @access private 135 145 136 */ 146 137 private function _cachingEnabled() … … 165 156 * @return int Lifetime of an cache object in seconds or null if lifetime 166 157 * is unlimited 167 *168 * @access public169 158 */ 170 159 public function getLifeTime() … … 180 169 * 181 170 * @return void 182 *183 * @access public184 171 */ 185 172 public function setLifeTime($lifetime) … … 201 188 * 202 189 * @return string Data of cache. 203 *204 * @access public205 190 */ 206 191 public function getCachedData($cacheType = "string") … … 236 221 * 237 222 * @return bool Saving data into cache was successful or not. 238 *239 * @access public240 223 */ 241 224 public function saveCachedData($data, $cacheType = "string") … … 260 243 * 261 244 * @return bool Removing data from cache was successful or not. 262 *263 * @access public264 245 */ 265 246 public function eraseCachedData() … … 281 262 * 282 263 * @return bool Removing data from cache was successful or not. 283 *284 * @access public285 264 */ 286 265 public function eraseCachedGroupData() -
trunk/wifidog-auth/wifidog/classes/Content.php
r1089 r1090 65 65 * Id of content 66 66 * 67 * @var string */ 68 protected $id; 69 70 /** 71 * Array containg content from database 72 * 73 * @var array */ 74 protected $content_row; 75 76 /** 77 * Type of content 78 * 67 79 * @var string 68 *69 * @access protected70 */71 protected $id;72 73 /**74 * Array containg content from database75 *76 * @var array77 *78 * @access protected79 */80 protected $content_row;81 82 /**83 * Type of content84 *85 * @var string86 *87 * @access private88 80 */ 89 81 private $content_type; 90 82 91 83 /** 92 * Defines if content is trivialor not84 * Defines if logging is enabled or not 93 85 * 94 86 * @var bool 95 *96 * @access private97 */98 private $is_trivial_content;99 100 /**101 * Defines if logging is enabled or not102 *103 * @var bool104 *105 * @access private106 87 */ 107 88 private $is_logging_enabled; … … 116 97 * 117 98 * @return void 118 *119 * @access private120 99 */ 121 100 private function __construct($content_id) { … … 132 111 133 112 if ($row == null) { 134 throw new Exception(_("The content with the following id could not be found in the database: ") .$content_id);113 throw new Exception(_("The content with the following id could not be found in the database: ") . $content_id); 135 114 } 136 115 … … 141 120 // By default content display logging is enabled 142 121 $this->setLoggingStatus(true); 143 $this->log_as_content = & $this;122 $this->log_as_content = & $this; 144 123 } 145 124 … … 148 127 * 149 128 * @return string String representation of the content 150 *151 * @access public152 129 */ 153 130 public function __toString() { … … 171 148 * @return object The newly created Content object, or null if there was an 172 149 * error (an exception is also trown) 173 * 174 * @static 175 * @access public 150 176 151 */ 177 152 public static function createNewObject($content_type = "Content", $id = null) { 178 // Define globals179 global $db;153 // Define globals 154 global $db; 180 155 181 156 if (empty ($id)) { … … 212 187 * 213 188 * @return string HTML markup 214 *215 * @static216 * @access public217 189 */ 218 190 public static function getCreateNewObjectUI() { … … 225 197 $tab[$i][0] = $className; 226 198 $tab[$i][1] = $className; 227 $i ++;199 $i++; 228 200 } 229 201 … … 246 218 * 247 219 * @return object The node object or null if no new node was created 248 *249 * @static250 * @access public251 220 */ 252 221 public static function processCreateNewObjectUI() { … … 270 239 * @return object The Content object, or null if there was an error 271 240 * (an exception is also thrown) 272 * 273 * @static 274 * @access public 241 275 242 */ 276 243 public static function getObject($content_id) { … … 286 253 287 254 if ($row == null) { 288 throw new Exception(_("The content with the following id could not be found in the database: ").$content_id); 289 } 290 291 $contentType = $row['content_type']; 292 $object = new $contentType ($content_id); 293 294 return $object; 255 throw new Exception(_("The content with the following id could not be found in the database: ") . $content_id); 256 } 257 if (!class_exists($row['content_type'])) { 258 //throw new Exception(_("The following content type isn't valid: ").$row['content_type']); 259 return null; 260 } else { 261 $object = new $row['content_type'] ($content_id); 262 return $object; 263 } 295 264 } 296 265 … … 299 268 * 300 269 * @return array An array of class names 301 *302 * @static303 * @access public304 270 */ 305 271 public static function getAvailableContentTypes() { … … 324 290 325 291 if (!$useCache) { 326 $dir = WIFIDOG_ABS_FILE_PATH ."classes/Content";292 $dir = WIFIDOG_ABS_FILE_PATH . "classes/Content"; 327 293 $dirHandle = @ opendir($dir); 328 294 … … 341 307 closedir($dirHandle); 342 308 } else { 343 throw new Exception(_('Unable to open directory ') .$dir);309 throw new Exception(_('Unable to open directory ') . $dir); 344 310 } 345 311 … … 357 323 return $contentTypes; 358 324 } 359 325 /** 326 * Check if the ContentType is available on the system * 327 * @param string $classname The classname to check 328 * @return true or flase 329 */ 330 public static function isContentTypeAvailable($classname) { 331 if (false === array_search($classname, Content :: getAvailableContentTypes(), true)) { 332 //throw new Exception(_("The following content type isn't valid: ").$contentType); 333 return false; 334 } else { 335 return true; 336 } 337 338 } 339 340 /** 341 * Check if this class is a class or subclass of one of the content types given as parameter 342 * * 343 * @param array $candidates The classnames to check 344 * @return true or flase 345 */ 346 public static function isContentType($candidates, $classname) { 347 $retval = false; 348 if (false === is_array($candidates)) { 349 throw new exception("classnames must be an array"); 350 } 351 $classname_reflector = new ReflectionClass($classname); 352 353 foreach ($candidates as $candidate) { 354 $candidate_reflector = new ReflectionClass($candidate); 355 //echo"classname: $classname, candidate: $candidate<br>"; 356 if ($classname_reflector->isSubclassOf($candidate_reflector)) { 357 //The content meets the criteria 358 //echo "TRUE<br>"; 359 $retval = true; 360 break; 361 } 362 } 363 return $retval; 364 } 360 365 /** 361 366 * Get all content … … 366 371 * 367 372 * @return mixed Requested content 368 *369 * @static370 * @access public371 373 */ 372 374 public static function getAllContent($content_type = "") { 373 // Define globals374 global $db;375 // Define globals 376 global $db; 375 377 376 378 // Init values … … 400 402 * @param string $user_prefix A identifier provided by the programmer 401 403 * to recognise it's generated HTML form 402 * @param string $content_type If set, the created content will be of403 * this type, otherwise, the user will have404 * @param string $content_type_filter If set, the created content must match the filter. Of only one type matches, 405 * the content will be of this type, otherwise, the user will have 404 406 * to choose 405 407 * 406 408 * @return string HTML markup 407 * 408 * @static 409 * @access public 410 */ 411 public static function getNewContentUI($user_prefix, $content_type = null, $title = null) { 412 // Define globals 413 global $db; 409 */ 410 public static function getNewContentUI($user_prefix, $content_type_filter = null, $title = null) { 411 // Define globals 412 global $db; 414 413 415 414 // Init values 416 415 $html = ""; 417 416 $html .= "<fieldset class='admin_container Content'>\n"; 418 if(!empty($title)){419 $html .= "<legend>$title</legend>\n";420 }417 if (!empty ($title)) { 418 $html .= "<legend>$title</legend>\n"; 419 } 421 420 422 421 $availableContentTypes = self :: getAvailableContentTypes(); … … 424 423 $name = "get_new_content_{$user_prefix}_content_type"; 425 424 426 if (empty ($content_type)) { 427 $label = _("Add new Content of type").": "; 428 429 $i = 0; 430 431 foreach ($availableContentTypes as $className) { 425 if (!$content_type_filter) { 426 //Get an empty filter 427 $content_type_filter = ContentTypeFilter :: getObject(array ()); 428 } 429 430 $i = 0; 431 $tab = array (); 432 foreach ($availableContentTypes as $className) { 433 if ($content_type_filter->isAcceptableContentClass($className)) { 432 434 $tab[$i][0] = $className; 433 435 $tab[$i][1] = $className; 434 $i ++; 435 } 436 $i++; 437 } 438 } 439 if (count($tab) > 1) { 440 $label = _("Add new Content of type") . ": "; 436 441 $html .= "<div class='admin_element_data content_add'>"; 437 442 $html .= $label; 438 443 $html .= FormSelectGenerator :: generateFromArray($tab, 'TrivialLangstring', $name, null, false); 439 444 $html .= "</div>"; 440 } else { 441 if (false === array_search($content_type, $availableContentTypes, true)) { 442 throw new Exception(_("The following content type isn't valid: ").$content_type); 443 } 444 445 $html .= '<input type="hidden" name="'.$name.'" value="'.$content_type.'">'; 446 } 445 } else 446 if (count($tab) == 1) { 447 $html .= '<input type="hidden" name="' . $name . '" value="' . $tab[0][0] . '">'; 448 } else { 449 throw new Exception(_("No content type matches the filter.")); 450 } 447 451 448 452 $name = "get_new_content_{$user_prefix}_add"; 449 453 450 if ( $content_type) {451 $value = sprintf(_("Add a %s"), $ content_type);454 if (count($tab) == 1) { 455 $value = sprintf(_("Add a %s"), $tab[0][1]); 452 456 } else { 453 457 $value = _("Add"); … … 455 459 456 460 $html .= "<div class='admin_element_tools'>"; 457 $html .= '<input type="submit" class="submit" name="' .$name.'" value="'.$value.'">';461 $html .= '<input type="submit" class="submit" name="' . $name . '" value="' . $value . '">'; 458 462 $html .= "</div>"; 459 463 $html .= "</fieldset>\n"; … … 472 476 * 473 477 * @return object The Content object, or null if the user didn't create one 474 * 475 * @static 476 * @access public 478 477 479 */ 478 480 public static function processNewContentUI($user_prefix, $associate_existing_content = false) { 479 // Init values480 $object = null;481 // Init values 482 $object = null; 481 483 482 484 if ($associate_existing_content == true) { … … 522 524 * @param string $default_display_area 523 525 * @return string HTML markup 524 * 525 * @static 526 * @access public 526 527 527 */ 528 528 public static function getLinkedContentUI($user_prefix, $link_table, $link_table_obj_key_col, $link_table_obj_key, $default_display_page = 'portal', $default_display_area = 'main_area_middle') { 529 // Define globals530 global $db;529 // Define globals 530 global $db; 531 531 532 532 // Init values … … 543 543 544 544 $html .= "<table class='content_management_tools'>\n"; 545 $html .= "<th>" ._('Display page').'</th><th>'._('Area').'</th><th>'._('Order').'</th><th>'._('Content').'</th><th>'._('Actions').'</th>'."\n";545 $html .= "<th>" . _('Display page') . '</th><th>' . _('Area') . '</th><th>' . _('Order') . '</th><th>' . _('Content') . '</th><th>' . _('Actions') . '</th>' . "\n"; 546 546 if ($rows) 547 547 foreach ($rows as $row) { … … 549 549 $html .= "<tr class='already_linked_content'>\n"; 550 550 /* Display page */ 551 $name = "{$user_prefix}_" .$content->GetId()."_display_page";552 $html .= "<td>" .FormSelectGenerator :: generateFromTable('content_available_display_pages', 'display_page', 'display_page', $row['display_page'], $name, null)."</td>\n";553 $name = "{$user_prefix}_" .$content->GetId()."_display_area";554 $html .= "<td>" .FormSelectGenerator :: generateFromTable('content_available_display_areas', 'display_area', 'display_area', $row['display_area'], $name, null)."</td>\n";555 $name = "{$user_prefix}_" .$content->GetId()."_display_order";551 $name = "{$user_prefix}_" . $content->GetId() . "_display_page"; 552 $html .= "<td>" . FormSelectGenerator :: generateFromTable('content_available_display_pages', 'display_page', 'display_page', $row['display_page'], $name, null) . "</td>\n"; 553 $name = "{$user_prefix}_" . $content->GetId() . "_display_area"; 554 $html .= "<td>" . FormSelectGenerator :: generateFromTable('content_available_display_areas', 'display_area', 'display_area', $row['display_area'], $name, null) . "</td>\n"; 555 $name = "{$user_prefix}_" . $content->GetId() . "_display_order"; 556 556 $html .= "<td><input type='text' name='$name' value='{$row['display_order']}' size=2 class='linked_content_order'></td>\n"; 557 557 $html .= "<td>\n"; … … 559 559 $html .= "</td>\n"; 560 560 $html .= "<td>\n"; 561 $name = "{$user_prefix}_" .$content->GetId()."_edit";562 $html .= "<input type='button' class='submit' name='$name' value='" ._("Edit")."' onClick='window.location.href = \"".GENERIC_OBJECT_ADMIN_ABS_HREF."?object_class=Content&action=edit&object_id=".$content->GetId()."\";'>\n";563 $name = "{$user_prefix}_" .$content->GetId()."_erase";564 $html .= "<input type='submit' class='submit' name='$name' value='" ._("Remove")."'>";561 $name = "{$user_prefix}_" . $content->GetId() . "_edit"; 562 $html .= "<input type='button' class='submit' name='$name' value='" . _("Edit") . "' onClick='window.location.href = \"" . GENERIC_OBJECT_ADMIN_ABS_HREF . "?object_class=Content&action=edit&object_id=" . $content->GetId() . "\";'>\n"; 563 $name = "{$user_prefix}_" . $content->GetId() . "_erase"; 564 $html .= "<input type='submit' class='submit' name='$name' value='" . _("Remove") . "'>"; 565 565 $html .= "</td>\n"; 566 566 $html .= "</tr>\n"; … … 570 570 $html .= "<tr class='add_existing_content'>\n"; 571 571 $name = "{$user_prefix}_new_existing_display_page"; 572 $html .= "<td>" .FormSelectGenerator :: generateFromTable('content_available_display_pages', 'display_page', 'display_page', $default_display_page, $name, null)."</td>\n";572 $html .= "<td>" . FormSelectGenerator :: generateFromTable('content_available_display_pages', 'display_page', 'display_page', $default_display_page, $name, null) . "</td>\n"; 573 573 $name = "{$user_prefix}_new_existing_display_area"; 574 $html .= "<td>" .FormSelectGenerator :: generateFromTable('content_available_display_areas', 'display_area', 'display_area', $default_display_area, $name, null)."</td>\n";574 $html .= "<td>" . FormSelectGenerator :: generateFromTable('content_available_display_areas', 'display_area', 'display_area', $default_display_area, $name, null) . "</td>\n"; 575 575 $name = "{$user_prefix}_new_existing_display_order"; 576 576 $html .= "<td><input type='text' name='$name' value='1' size=2 class='linked_content_order'></td>\n"; … … 585 585 $html .= "<tr class='add_new_content'>\n"; 586 586 $name = "{$user_prefix}_new_display_page"; 587 $html .= "<td>" .FormSelectGenerator :: generateFromTable('content_available_display_pages', 'display_page', 'display_page', $default_display_page, $name, null)."</td>\n";587 $html .= "<td>" . FormSelectGenerator :: generateFromTable('content_available_display_pages', 'display_page', 'display_page', $default_display_page, $name, null) . "</td>\n"; 588 588 $name = "{$user_prefix}_new_display_area"; 589 $html .= "<td>" .FormSelectGenerator :: generateFromTable('content_available_display_areas', 'display_area', 'display_area', $default_display_area, $name, null)."</td>\n";589 $html .= "<td>" . FormSelectGenerator :: generateFromTable('content_available_display_areas', 'display_area', 'display_area', $default_display_area, $name, null) . "</td>\n"; 590 590 $name = "{$user_prefix}_new_display_order"; 591 591 $html .= "<td><input type='text' name='$name' value='1' size=2 class='linked_content_order'></td>\n"; … … 619 619 $content_id = $db->escapeString($content->getId()); 620 620 $sql = null; 621 $name = "{$user_prefix}_" .$content->GetId()."_erase";621 $name = "{$user_prefix}_" . $content->GetId() . "_erase"; 622 622 if (!empty ($_REQUEST[$name])) { 623 623 $sql .= "DELETE FROM $link_table WHERE $link_table_obj_key_col='$link_table_obj_key' AND content_id = '$content_id';\n"; … … 625 625 } else { 626 626 /* Display page */ 627 $name = "{$user_prefix}_" .$content->GetId()."_display_page";627 $name = "{$user_prefix}_" . $content->GetId() . "_display_page"; 628 628 $new_display_page = FormSelectGenerator :: getResult($name, null); 629 629 if ($new_display_page != $row['display_page']) { … … 633 633 } 634 634 /* Display area */ 635 $name = "{$user_prefix}_" .$content->GetId()."_display_area";635 $name = "{$user_prefix}_" . $content->GetId() . "_display_area"; 636 636 $new_display_area = FormSelectGenerator :: getResult($name, null); 637 637 if ($new_display_area != $row['display_area']) { … … 640 640 } 641 641 /* Display order */ 642 $name = "{$user_prefix}_" .$content->GetId()."_display_order";642 $name = "{$user_prefix}_" . $content->GetId() . "_display_order"; 643 643 if ($_REQUEST[$name] != $row['display_order']) { 644 644 $new_display_order = $db->escapeString($_REQUEST[$name]); … … 699 699 * @param string $sql_additional_where Addidional where conditions to 700 700 * restrict the candidate objects 701 * @param bool $show_persistant_content Defines if to list persistant 702 * content, only 701 * @param string $content_type_filter If set, the created content must match the filter. 703 702 * @param string $order Order of output (default: by 704 703 * creation time) … … 710 709 * 711 710 * @return string HTML markup 712 * 713 * @static 714 * @access public 715 */ 716 public static function getSelectExistingContentUI($user_prefix, $sql_additional_where = null, $show_persistant_content = true, $order = "creation_timestamp", $type_interface = "select") 717 { 711 712 */ 713 public static function getSelectExistingContentUI($user_prefix, $sql_additional_where = null, $content_type_filter = null, $order = "creation_timestamp", $type_interface = "select") { 718 714 // Define globals 719 715 global $db; … … 723 719 $retVal = array (); 724 720 $contentRows = null; 721 if ($content_type_filter == null) { 722 //Get an empty filter 723 $content_type_filter = ContentTypeFilter :: getObject(array ()); 724 } 725 725 726 726 try { … … 738 738 $html .= "<fieldset class='admin_container Content'>\n"; 739 739 740 if (!empty ($title)) {740 if (!empty ($title)) { 741 741 $html .= "<legend>$title</legend>\n"; 742 742 } 743 743 744 $html .= _("Add existing content") .": ";744 $html .= _("Add existing content") . ": "; 745 745 } 746 746 747 747 $name = "{$user_prefix}"; 748 748 749 if ($show_persistant_content) { 750 $sql = "SELECT * FROM content WHERE is_persistent=TRUE $sql_additional_where ORDER BY $order"; 751 } else { 752 $sql = "SELECT * FROM content $sql_additional_where ORDER BY $order"; 753 } 749 $sql = "SELECT * FROM content WHERE 1=1 $sql_additional_where ORDER BY $order"; 754 750 755 751 $db->execSql($sql, $contentRows, false); … … 760 756 if ($type_interface == "table") { 761 757 $html .= "<table class='content_admin'>\n"; 762 $html .= "<tr><th>" ._("Title")."</th><th>"._("Content type")."</th><th>"._("Description")."</th><th></th></tr>\n";758 $html .= "<tr><th>" . _("Title") . "</th><th>" . _("Content type") . "</th><th>" . _("Description") . "</th><th></th></tr>\n"; 763 759 } 764 760 765 761 foreach ($contentRows as $contentRow) { 766 $content = Content::getObject($contentRow['content_id']); 767 768 if (User::getCurrentUser()->isSuperAdmin() || $content->isOwner(User::getCurrentUser())) { 769 if ($type_interface != "table") { 770 $tab[$i][0] = $content->getId(); 771 $tab[$i][1] = $content->__toString()." (".get_class($content).")"; 772 $i ++; 773 } else { 774 if (!empty ($contentRow['title'])) { 775 $title = Content :: getObject($contentRow['title']); 776 $titleUI = $title->__toString(); 762 $content = Content :: getObject($contentRow['content_id']); 763 //echo get_class($content)." ".$contentRow['content_id']."<br>"; 764 if ($content && $content_type_filter->isAcceptableContentClass(get_class($content))) { 765 if (User :: getCurrentUser()->isSuperAdmin() || $content->isOwner(User :: getCurrentUser())) { 766 if ($type_interface != "table") { 767 $tab[$i][0] = $content->getId(); 768 $tab[$i][1] = $content->__toString() . " (" . get_class($content) . ")"; 769 $i++; 777 770 } else { 778 $titleUI = ""; 771 if (!empty ($contentRow['title'])) { 772 $title = Content :: getObject($contentRow['title']); 773 $titleUI = $title->__toString(); 774 } else { 775 $titleUI = ""; 776 } 777 778 if (!empty ($contentRow['description'])) { 779 $description = Content :: getObject($contentRow['description']); 780 $descriptionUI = $description->__toString(); 781 } else { 782 $descriptionUI = ""; 783 } 784 785 $href = GENERIC_OBJECT_ADMIN_ABS_HREF . "?object_id={$contentRow['content_id']}&object_class=Content&action=edit"; 786 $html .= "<tr><td>$titleUI</td><td><a href='$href'>{$contentRow['content_type']}</a></td><td>$descriptionUI</td>\n"; 787 788 $href = GENERIC_OBJECT_ADMIN_ABS_HREF . "?object_id={$contentRow['content_id']}&object_class=Content&action=delete"; 789 $html .= "<td><a href='$href'>" . _("Delete") . "</a></td>"; 790 791 $html .= "</tr>\n"; 779 792 } 780 781 if (!empty ($contentRow['description'])) {782 $description = Content :: getObject($contentRow['description']);783 $descriptionUI = $description->__toString();784 } else {785 $descriptionUI = "";786 }787 788 $href = GENERIC_OBJECT_ADMIN_ABS_HREF."?object_id={$contentRow['content_id']}&object_class=Content&action=edit";789 $html .= "<tr><td>$titleUI</td><td><a href='$href'>{$contentRow['content_type']}</a></td><td>$descriptionUI</td>\n";790 791 $href = GENERIC_OBJECT_ADMIN_ABS_HREF."?object_id={$contentRow['content_id']}&object_class=Content&action=delete";792 $html .= "<td><a href='$href'>"._("Delete")."</a></td>";793 794 $html .= "</tr>\n";795 793 } 796 794 } … … 801 799 $html .= FormSelectGenerator :: generateFromArray($tab, null, $name, null, false, null, null, 40); 802 800 //DEBUG!! get_existing_content_ 803 $name = "{$user_prefix}_add";804 $value = _("Add");805 $html .= "<div class='admin_element_tools'>";806 $html .= '<input type="submit" class="submit" name="'.$name.'" value="'.$value.'">';807 $html .= "</div>";801 $name = "{$user_prefix}_add"; 802 $value = _("Add"); 803 $html .= "<div class='admin_element_tools'>"; 804 $html .= '<input type="submit" class="submit" name="' . $name . '" value="' . $value . '">'; 805 $html .= "</div>"; 808 806 } else { 809 $html .= "<div class='warningmsg'>" ._("Sorry, no content available in the database")."</div>\n";807 $html .= "<div class='warningmsg'>" . _("Sorry, no elligible content available in the database") . "</div>\n"; 810 808 } 811 809 $html .= "</fieldset>\n"; … … 814 812 } 815 813 } else { 816 $html .= "<div class='warningmsg'>" ._("Sorry, no content available in the database")."</div>\n";814 $html .= "<div class='warningmsg'>" . _("Sorry, no elligible content available in the database") . "</div>\n"; 817 815 } 818 816 … … 892 890 global $db; 893 891 $content_type = $db->escapeString($content_type); 894 $available_content_types = self :: getAvailableContentTypes(); 895 if (false === array_search($content_type, $available_content_types, true)) { 896 throw new Exception(_("The following content type isn't valid: ").$content_type); 892 if (!self :: isContentTypeAvailable($content_type)) { 893 throw new Exception(_("The following content type isn't valid: ") . $content_type); 897 894 } 898 895 $sql = "UPDATE content SET content_type = '$content_type' WHERE content_id='$this->id'"; … … 910 907 public function addOwner(User $user, $is_author = false) { 911 908 global $db; 912 $content_id = "'" .$this->id."'";913 $user_id = "'" .$db->escapeString($user->getId())."'";909 $content_id = "'" . $this->id . "'"; 910 $user_id = "'" . $db->escapeString($user->getId()) . "'"; 914 911 $is_author ? $is_author = 'TRUE' : $is_author = 'FALSE'; 915 912 $sql = "INSERT INTO content_has_owners (content_id, user_id, is_author) VALUES ($content_id, $user_id, $is_author)"; … … 927 924 public function deleteOwner(User $user, $is_author = false) { 928 925 global $db; 929 $content_id = "'" .$this->id."'";930 $user_id = "'" .$db->escapeString($user->getId())."'";926 $content_id = "'" . $this->id . "'"; 927 $user_id = "'" . $db->escapeString($user->getId()) . "'"; 931 928 932 929 $sql = "DELETE FROM content_has_owners WHERE content_id=$content_id AND user_id=$user_id"; … … 1026 1023 } 1027 1024 1028 /** When a content object is set as trivial, it means that is is used merely to contain it's own data. No title, description or other data will be set or displayed, during display or administration 1029 * @param $is_trivial true or false */ 1030 public function setIsTrivialContent($is_trivial) { 1031 $this->is_trivial_content = $is_trivial; 1032 } 1033 1025 /** When a content object is set as Simple, it means that is is used merely to contain it's own data. No title, description or other metadata will be set or displayed, during display or administration 1026 * @return true or false */ 1027 public function isSimpleContent() { 1028 return false; 1029 } 1034 1030 /** Retreives the user interface of this object. Anything that overrides this method should call the parent method with it's output at the END of processing. 1035 1031 * @param $subclass_admin_interface Html content of the interface element of a children … … 1037 1033 public function getUserUI($subclass_user_interface = null) { 1038 1034 $html = ''; 1039 $html .= "<div class='user_ui_main_outer " .get_class($this)."'>\n";1035 $html .= "<div class='user_ui_main_outer " . get_class($this) . "'>\n"; 1040 1036 $html .= "<div class='user_ui_main_inner'>\n"; 1041 1037 1042 if (!empty ($this->content_row['title']) && $this->titleShouldDisplay()) {1038 if (!empty ($this->content_row['title']) && $this->titleShouldDisplay()) { 1043 1039 $html .= "<div class='user_ui_title'>\n"; 1044 1040 $title = self :: getObject($this->content_row['title']); … … 1060 1056 $html .= _("Author(s):"); 1061 1057 foreach ($authors as $user) { 1062 $html .= $user->getUsername() ." ";1058 $html .= $user->getUsername() . " "; 1063 1059 } 1064 1060 $html .= "</div>\n"; … … 1076 1072 } 1077 1073 1078 if (!empty ($this->content_row['project_info']) ) {1074 if (!empty ($this->content_row['project_info'])) { 1079 1075 if (!empty ($this->content_row['project_info'])) { 1080 1076 $html .= "<div class='user_ui_projet_info'>\n"; 1081 $html .= "<b>" ._("Project information:")."</b>";1077 $html .= "<b>" . _("Project information:") . "</b>"; 1082 1078 $project_info = self :: getObject($this->content_row['project_info']); 1083 1079 $project_info->setLogAsContent($this); … … 1099 1095 } 1100 1096 1101 1102 /** Allow logging as part of another content (usually the parent for metadata). 1103 * Redirects clickthrough logging to the parent's content id, and does not log 1104 * display */ 1105 protected function setLogAsContent(Content $content) 1106 { 1107 $this->log_as_content = $content; 1108 } 1097 /** Allow logging as part of another content (usually the parent for metadata). 1098 * Redirects clickthrough logging to the parent's content id, and does not log 1099 * display */ 1100 protected function setLogAsContent(Content $content) { 1101 $this->log_as_content = $content; 1102 } 1109 1103 1110 1104 /** Log that this content has just been displayed to the user. Will only log if the user is logged in */ 1111 1105 private function logContentDisplay() { 1112 if ($this->getLoggingStatus() == true && $this->log_as_content->getId() ==$this->getId()) {1106 if ($this->getLoggingStatus() == true && $this->log_as_content->getId() == $this->getId()) { 1113 1107 // DEBUG:: 1114 1108 //echo "Logging ".get_class($this)." :: ".$this->__toString()."<br>"; … … 1132 1126 } 1133 1127 /** Handle replacements of hyperlinks for clickthrough tracking (if appropriate) */ 1134 protected function replaceHyperLinks(& $html) {1128 protected function replaceHyperLinks(& $html) { 1135 1129 /* Handle hyperlink clicktrough logging */ 1136 1130 if ($this->getLoggingStatus() == true) { 1137 1131 $html = HyperLink :: replaceHyperLinks($html, $this->log_as_content); 1138 }1132 } 1139 1133 return $html; 1140 1134 } … … 1146 1140 $html = ''; 1147 1141 $html .= "<div class='list_ui_container'>\n"; 1148 $html .= $this->__toString() ." (".get_class($this).")\n";1142 $html .= $this->__toString() . " (" . get_class($this) . ")\n"; 1149 1143 $html .= $subclass_list_interface; 1150 1144 $html .= "</div>\n"; … … 1160 1154 * @return string The HTML fragment for this interface. 1161 1155 */ 1162 public function getAdminUI($subclass_admin_interface = null, $title =null) {1156 public function getAdminUI($subclass_admin_interface = null, $title = null) { 1163 1157 global $db; 1164 1158 1165 1159 $html = ''; 1166 $html .= "<fieldset class='admin_container " .get_class($this)."'>\n";1167 if(!empty($title)){1168 $html .= "<legend>$title</legend>\n";1169 }1170 $html .= "<ul class='admin_element_list'>\n";1160 $html .= "<fieldset class='admin_container " . get_class($this) . "'>\n"; 1161 if (!empty ($title)) { 1162 $html .= "<legend>$title</legend>\n"; 1163 } 1164 $html .= "<ul class='admin_element_list'>\n"; 1171 1165 if ($this->getObjectType() == 'Content') { 1172 1166 // The object hasn't yet been typed. … … 1177 1171 $tab[$i][0] = $classname; 1178 1172 $tab[$i][1] = $classname; 1179 $i ++;1180 } 1181 1182 $html .= FormSelectGenerator :: generateFromArray($tab, null, "content_" .$this->id."_content_type", "Content", false);1173 $i++; 1174 } 1175 1176 $html .= FormSelectGenerator :: generateFromArray($tab, null, "content_" . $this->id . "_content_type", "Content", false); 1183 1177 } else { 1184 // Content metadata 1185 if ($this->is_trivial_content == false || $this->isPersistent()) { 1186 $html .= "<fieldset class='admin_element_group'>\n"; 1187 $html .= "<legend>".sprintf(_("%s MetaData"),get_class($this))."</legend>\n"; 1178 $criteria_array = array ( 1179 array ( 1180 'isSimpleContent' 1181 ) 1182 ); 1183 $metadada_allowed_content_types = ContentTypeFilter :: getObject($criteria_array); 1184 1185 // Content metadata 1186 if ($this->isSimpleContent() == false || $this->isPersistent()) { 1187 $html .= "<fieldset class='admin_element_group'>\n"; 1188 $html .= "<legend>" . sprintf(_("%s MetaData"), get_class($this)) . "</legend>\n"; 1188 1189 1189 1190 /* title_is_displayed */ 1190 $html_title_is_displayed = _("Display the title?") .": \n";1191 $name = "content_" .$this->id."_title_is_displayed";1191 $html_title_is_displayed = _("Display the title?") . ": \n"; 1192 $name = "content_" . $this->id . "_title_is_displayed"; 1192 1193 $this->titleShouldDisplay() ? $checked = 'CHECKED' : $checked = ''; 1193 1194 $html_title_is_displayed .= "<input type='checkbox' name='$name' $checked>\n"; … … 1197 1198 $html .= "<div class='admin_element_data'>\n"; 1198 1199 if (empty ($this->content_row['title'])) { 1199 $html .= self :: getNewContentUI("title_{$this->id}_new", null, _("Title:"));1200 $html .= self :: getNewContentUI("title_{$this->id}_new", $metadada_allowed_content_types, _("Title:")); 1200 1201 $html .= "</div>\n"; 1201 1202 } else { … … 1205 1206 $html .= "</div>\n"; 1206 1207 $html .= "<div class='admin_element_tools admin_section_delete_title'>\n"; 1207 $name = "content_" .$this->id."_title_erase";1208 $html .= "<input type='submit' class='submit' name='$name' value='" .sprintf(_("Delete %s (%s)"),_("title"),get_class($title))."'>";1208 $name = "content_" . $this->id . "_title_erase"; 1209 $html .= "<input type='submit' class='submit' name='$name' value='" . sprintf(_("Delete %s (%s)"), _("title"), get_class($title)) . "'>"; 1209 1210 $html .= "</div>\n"; 1210 1211 } … … 1212 1213 } 1213 1214 1214 if ($this->is _trivial_content== false) {1215 if ($this->isSimpleContent() == false) { 1215 1216 /* description */ 1216 1217 $html .= "<li class='admin_element_item_container admin_section_edit_description'>\n"; 1217 1218 $html .= "<div class='admin_element_data'>\n"; 1218 1219 if (empty ($this->content_row['description'])) { 1219 $html .= self :: getNewContentUI("description_{$this->id}_new", null, _("Description:"));1220 $html .= self :: getNewContentUI("description_{$this->id}_new", $metadada_allowed_content_types, _("Description:")); 1220 1221 $html .= "</div>\n"; 1221 1222 } else { … … 1224 1225 $html .= "</div>\n"; 1225 1226 $html .= "<div class='admin_element_tools'>\n"; 1226 $name = "content_" .$this->id."_description_erase";1227 $html .= "<input type='submit' class='submit' name='$name' value='" .sprintf(_("Delete %s (%s)"),_("description"),get_class($description))."'>";1227 $name = "content_" . $this->id . "_description_erase"; 1228 $html .= "<input type='submit' class='submit' name='$name' value='" . sprintf(_("Delete %s (%s)"), _("description"), get_class($description)) . "'>"; 1228 1229 $html .= "</div>\n"; 1229 1230 } … … 1234 1235 $html .= "<div class='admin_element_data'>\n"; 1235 1236 if (empty ($this->content_row['long_description'])) { 1236 $html .= self :: getNewContentUI("long_description_{$this->id}_new", null, _("Long description:"));1237 $html .= self :: getNewContentUI("long_description_{$this->id}_new", $metadada_allowed_content_types, _("Long description:")); 1237 1238 $html .= "</div>\n"; 1238 1239 } else { … … 1241 1242 $html .= "</div>\n"; 1242 1243 $html .= "<div class='admin_element_tools'>\n"; 1243 $name = "content_" .$this->id."_long_description_erase";1244 $html .= "<input type='submit' class='submit' name='$name' value='" .sprintf(_("Delete %s (%s)"),_("long description"),get_class($description))."'>";1244 $name = "content_" . $this->id . "_long_description_erase"; 1245 $html .= "<input type='submit' class='submit' name='$name' value='" . sprintf(_("Delete %s (%s)"), _("long description"), get_class($description)) . "'>"; 1245 1246 $html .= "</div>\n"; 1246 1247 } … … 1251 1252 $html .= "<div class='admin_element_data'>\n"; 1252 1253 if (empty ($this->content_row['project_info'])) { 1253 $html .= self :: getNewContentUI("project_info_{$this->id}_new", null, _("Information on this project:"));1254 $html .= self :: getNewContentUI("project_info_{$this->id}_new", $metadada_allowed_content_types, _("Information on this project:")); 1254 1255 $html .= "</div>\n"; 1255 1256 } else { … … 1258 1259 $html .= "</div>\n"; 1259 1260 $html .= "<div class='admin_element_tools'>\n"; 1260 $name = "content_" .$this->id."_project_info_erase";1261 $html .= "<input type='submit' class='submit' name='$name' value='" .sprintf(_("Delete %s (%s)"),_("project information"),get_class($project_info))."'>";1261 $name = "content_" . $this->id . "_project_info_erase"; 1262 $html .= "<input type='submit' class='submit' name='$name' value='" . sprintf(_("Delete %s (%s)"), _("project information"), get_class($project_info)) . "'>"; 1262 1263 $html .= "</div>\n"; 1263 1264 } … … 1266 1267 1267 1268 //End content medatada 1268 if ($this->is_trivial_content == false || $this->isPersistent()) { 1269 $html .= "</fieldset>\n"; 1270 } 1271 if ($this->is_trivial_content == false || $this->isPersistent()) { 1269 if ($this->isSimpleContent() == false || $this->isPersistent()) { 1270 $html .= "</fieldset>\n"; 1271 } 1272 1273 if ($this->isSimpleContent() == false || $this->isPersistent()) { 1274 1272 1275 $html .= "<fieldset class='admin_element_group'>\n"; 1273 $html .= "<legend>".sprintf(_("%s access control"),get_class($this))."</legend>\n";1274 1275 /* is_persistent */1276 $html .= "<legend>" . sprintf(_("%s access control"), get_class($this)) . "</legend>\n"; 1277 1278 /* is_persistent */ 1276 1279 $html .= "<li class='admin_element_item_container admin_section_edit_persistant'>\n"; 1277 $html .= "<div class='admin_element_label'>" ._("Is persistent (reusable and read-only)?").": </div>\n";1280 $html .= "<div class='admin_element_label'>" . _("Is persistent (reusable and read-only)?") . ": </div>\n"; 1278 1281 $html .= "<div class='admin_element_data'>\n"; 1279 $name = "content_" .$this->id."_is_persistent";1282 $name = "content_" . $this->id . "_is_persistent"; 1280 1283 $this->isPersistent() ? $checked = 'CHECKED' : $checked = ''; 1281 1284 $html .= "<input type='checkbox' name='$name' $checked onChange='submit();'>\n"; … … 1285 1288 /* content_has_owners */ 1286 1289 $html .= "<li class='admin_element_item_container content_has_owners'>\n"; 1287 $html .= "<div class='admin_element_label'>" ._("Content owner list")."</div>\n";1290 $html .= "<div class='admin_element_label'>" . _("Content owner list") . "</div>\n"; 1288 1291 $html .= "<ul class='admin_element_list'>\n"; 1289 1292 … … 1298 1301 1299 1302 $html .= $user->getListUI(); 1300 $name = "content_" .$this->id."_owner_".$user->GetId()."_is_author";1303 $name = "content_" . $this->id . "_owner_" . $user->GetId() . "_is_author"; 1301 1304 $html .= " Is content author? "; 1302 1305 … … 1305 1308 $html .= "</div>\n"; 1306 1309 $html .= "<div class='admin_element_tools'>\n"; 1307 $name = "content_" .$this->id."_owner_".$user->GetId()."_remove";1308 $html .= "<input type='submit' class='submit' name='$name' value='" ._("Remove owner")."'>";1310 $name = "content_" . $this->id . "_owner_" . $user->GetId() . "_remove"; 1311 $html .= "<input type='submit' class='submit' name='$name' value='" . _("Remove owner") . "'>"; 1309 1312 $html .= "</div>\n"; 1310 1313 $html .= "</li>\n"; … … 1331 1334 } 1332 1335 /** Process admin interface of this object. When an object overrides this method, they should call the parent processAdminUI at the BEGINING of processing. 1333 1336 1334 1337 */ 1335 1338 public function processAdminUI() { … … 1337 1340 global $db; 1338 1341 if ($this->getObjectType() == 'Content') /* The object hasn't yet been typed */ { 1339 $content_type = FormSelectGenerator :: getResult("content_" .$this->id."_content_type", "Content");1342 $content_type = FormSelectGenerator :: getResult("content_" . $this->id . "_content_type", "Content"); 1340 1343 $this->setContentType($content_type); 1341 } else 1342 {//Content medatada 1343 1344 1345 if ($this->is_trivial_content == false || $this->isPersistent()) { 1346 /* title_is_displayed */ 1347 if (!empty ($this->content_row['title'])){ 1348 $name = "content_".$this->id."_title_is_displayed"; 1349 !empty ($_REQUEST[$name]) ? $this->setTitleIsDisplayed(true) : $this->setTitleIsDisplayed(false); 1350 } 1344 } else { 1345 //Content medatada 1346 1347 if ($this->isSimpleContent() == false || $this->isPersistent()) { 1348 /* title_is_displayed */ 1349 if (!empty ($this->content_row['title'])) { 1350 $name = "content_" . $this->id . "_title_is_displayed"; 1351 !empty ($_REQUEST[$name]) ? $this->setTitleIsDisplayed(true) : $this->setTitleIsDisplayed(false); 1352 } 1351 1353 /* title */ 1352 1354 if (empty ($this->content_row['title'])) { … … 1358 1360 } else { 1359 1361 $title = self :: getObject($this->content_row['title']); 1360 $name = "content_" .$this->id."_title_erase";1362 $name = "content_" . $this->id . "_title_erase"; 1361 1363 if (!empty ($_REQUEST[$name]) && $_REQUEST[$name] == true) { 1362 1364 $db->execSqlUpdate("UPDATE content SET title = NULL WHERE content_id = '$this->id'", FALSE); … … 1366 1368 } 1367 1369 } 1368 }1369 if ($this->is_trivial_content== false) {1370 } 1371 if ($this->isSimpleContent() == false) { 1370 1372 /* description */ 1371 1373 if (empty ($this->content_row['description'])) { … … 1377 1379 } else { 1378 1380 $description = self :: getObject($this->content_row['description']); 1379 $name = "content_" .$this->id."_description_erase";1381 $name = "content_" . $this->id . "_description_erase"; 1380 1382 if (!empty ($_REQUEST[$name]) && $_REQUEST[$name] == true) { 1381 1383 $db->execSqlUpdate("UPDATE content SET description = NULL WHERE content_id = '$this->id'", FALSE); … … 1395 1397 } else { 1396 1398 $long_description = self :: getObject($this->content_row['long_description']); 1397 $name = "content_" .$this->id."_long_description_erase";1399 $name = "content_" . $this->id . "_long_description_erase"; 1398 1400 if (!empty ($_REQUEST[$name]) && $_REQUEST[$name] == true) { 1399 1401 $db->execSqlUpdate("UPDATE content SET long_description = NULL WHERE content_id = '$this->id'", FALSE); … … 1413 1415 } else { 1414 1416 $project_info = self :: getObject($this->content_row['project_info']); 1415 $name = "content_" .$this->id."_project_info_erase";1417 $name = "content_" . $this->id . "_project_info_erase"; 1416 1418 if (!empty ($_REQUEST[$name]) && $_REQUEST[$name] == true) { 1417 1419 $db->execSqlUpdate("UPDATE content SET project_info = NULL WHERE content_id = '$this->id'", FALSE); … … 1421 1423 } 1422 1424 } 1423 } //End content metadata1424 1425 if ($this->is_trivial_content== false || $this->isPersistent()) {1425 } //End content metadata 1426 1427 if ($this->isSimpleContent() == false || $this->isPersistent()) { 1426 1428 /* is_persistent */ 1427 $name = "content_" .$this->id."_is_persistent";1429 $name = "content_" . $this->id . "_is_persistent"; 1428 1430 !empty ($_REQUEST[$name]) ? $this->setIsPersistent(true) : $this->setIsPersistent(false); 1429 1431 … … 1435 1437 $user = User :: getObject($content_owner_row['user_id']); 1436 1438 $user_id = $user->getId(); 1437 $name = "content_" .$this->id."_owner_".$user->GetId()."_remove";1439 $name = "content_" . $this->id . "_owner_" . $user->GetId() . "_remove"; 1438 1440 if (!empty ($_REQUEST[$name])) { 1439 1441 $this->deleteOwner($user); 1440 1442 } else { 1441 $name = "content_" .$this->id."_owner_".$user->GetId()."_is_author";1443 $name = "content_" . $this->id . "_owner_" . $user->GetId() . "_is_author"; 1442 1444 $content_owner_row['is_author'] == 't' ? $is_author = true : $is_author = false; 1443 1445 !empty ($_REQUEST[$name]) ? $should_be_author = true : $should_be_author = false; … … 1460 1462 $this->addOwner($user); 1461 1463 } 1462 }1463 1464 } 1465 } 1464 1466 $this->refresh(); 1465 1467 } … … 1579 1581 * Load requested content class 1580 1582 */ 1581 require_once ('classes/Content/' .$class_name.'/'.$class_name.'.php');1583 require_once ('classes/Content/' . $class_name . '/' . $class_name . '.php'); 1582 1584 } 1583 1585 -
trunk/wifidog-auth/wifidog/classes/Content/Avatar/Avatar.php
r1070 r1090 62 62 * @param string $content_id Content id 63 63 * 64 * @return void 65 * 66 * @access protected 67 */ 64 * @return void */ 68 65 protected function __construct($content_id) 69 66 { 70 67 parent :: __construct($content_id); 71 $this->setIsTrivialContent(true);72 68 } 73 69 70 /** When a content object is set as Simple, it means that is is used merely to contain it's own data. No title, description or other metadata will be set or displayed, during display or administration 71 * @return true or false */ 72 public function isSimpleContent() { 73 return true; 74 } 75 74 76 /** 75 77 * Shows the administration interface for Avatar … … 137 139 * 138 140 * @return void 139 *140 * @access public141 141 */ 142 142 public function processAdminUI() … … 151 151 * 152 152 * @return string The HTML fragment for this interface 153 *154 * @access public155 153 */ 156 154 public function getUserUI() … … 173 171 * 174 172 * @return void 175 * 176 * @access private 173 177 174 */ 178 175 private function refresh() -
trunk/wifidog-auth/wifidog/classes/Content/ContentGroup/ContentGroup.php
r1088 r1090 48 48 */ 49 49 require_once ('classes/Content/ContentGroup/ContentGroupElement.php'); 50 require_once ('classes/ContentTypeFilter.php'); 50 51 51 52 /** … … 59 60 class ContentGroup extends Content { 60 61 61 private $CONTENT_ORDERING_MODES = array ( 62 'RANDOM' => "Pick content elements randomly", 63 'PSEUDO_RANDOM' => "Pick content elements randomly, but do not display the same content twice untill all content has been seen", 64 'SEQUENTIAL' => "Pick content elements in sequential order" 65 ); 66 private $CONTENT_CHANGES_ON_MODES = array ( 67 'ALWAYS' => "Content always rotates", 68 'NEXT_DAY' => "Content rotates once per day", 69 'NEXT_LOGIN' => "Content rotates once per session", 70 'NEXT_NODE' => "Content rotates each time you change node" 71 ); 72 private $ALLOW_REPEAT_MODES = array ( 73 'YES' => "Content can be shown more than once", 74 'NO' => "Content can only be shown once", 75 'ONCE_PER_NODE' => "Content can be shown more than once, but not at the same node" 76 ); 77 78 protected $is_artistic_content; 79 protected $is_locative_content; 80 81 // is_expandable is ONLY for internal use, it use normally only set by the constructor 82 private $is_expandable = true; 83 // this is the actual publicly available status ( so if is_expandable == true it CANNOT be true ) 84 private $expand_status = false; 85 private $temporary_display_num_elements; 86 87 private $content_selection_mode; 88 private $content_group_row; 89 90 protected function __construct($content_id) { 91 // Define globals 92 global $db; 93 94 // Init values 95 $row = null; 96 97 parent :: __construct($content_id); 98 99 $content_id = $db->escapeString($content_id); 100 101 $sql = "SELECT * FROM content_group WHERE content_group_id='$content_id'"; 102 $db->execSqlUniqueRes($sql, $row, false); 103 if ($row == null) { 104 /*Since the parent Content exists, the necessary data in content_group had not yet been created */ 105 $sql = "INSERT INTO content_group (content_group_id) VALUES ('$content_id')"; 106 $db->execSqlUpdate($sql, false); 107 $sql = "SELECT * FROM content_group WHERE content_group_id='$content_id'"; 108 $db->execSqlUniqueRes($sql, $row, false); 109 if ($row == null) { 110 throw new Exception(_("The content with the following id could not be found in the database: ") . $content_id); 111 } 112 113 } 114 115 $this->content_group_row = $row; 116 117 // These are for internal use only ( private and protected methods ) for dealing with expanding content 118 $this->setTemporaryDisplayNumElements(null); 119 } 120 121 /** Is the content group artistic in nature? 122 * @return true or false */ 123 public function isArtisticContent() { 124 if ($this->content_group_row['is_artistic_content'] == 't') { 125 $retval = true; 126 } else { 127 $retval = false; 128 } 129 return $retval; 130 } 131 132 /** Set if the content group is artistic in nature, 133 * @param $is_artistic_content true or false*/ 134 public function setIsArtisticContent($is_artistic_content) { 135 if ($is_artistic_content != $this->isArtisticContent()) /* Only update database if there is an actual change */ { 136 $is_artistic_content ? $is_artistic_content_sql = 'TRUE' : $is_artistic_content_sql = 'FALSE'; 137 138 global $db; 139 $db->execSqlUpdate("UPDATE content_group SET is_artistic_content = $is_artistic_content_sql WHERE content_group_id = '$this->id'", false); 140 $this->refresh(); 141 } 142 143 } 144 145 /** Does the content shown or generated by the content group directly related to where it is viewed from? 146 * @return true or false */ 147 public function isLocativeContent() { 148 if ($this->content_group_row['is_locative_content'] == 't') { 149 $retval = true; 150 } else { 151 $retval = false; 152 } 153 return $retval; 154 } 155 156 /** Set if the content group is locative 157 * @param $is_locative_content true or false 158 * */ 159 public function setIsLocativeContent($is_locative_content) { 160 if ($is_locative_content != $this->isLocativeContent()) /* Only update database if there is an actual change */ { 161 $is_locative_content ? $is_locative_content_sql = 'TRUE' : $is_locative_content_sql = 'FALSE'; 162 163 global $db; 164 $db->execSqlUpdate("UPDATE content_group SET is_locative_content = $is_locative_content_sql WHERE content_group_id = '$this->id'", false); 165 $this->refresh(); 166 } 167 168 } 169 170 /** In what order is the content displayed to the user 171 * @return string, a key of CONTENT_SELECTION_MODES */ 172 public function getContentOrderingMode() { 173 return $this->content_group_row['content_ordering_mode']; 174 } 175 176 /** In what order is the content displayed to the user 177 * @param $content_ordering_mode One of the CONTENT_ORDERING_MODES constants defined in the class 178 * @return true if successfull 179 * */ 180 protected function setContentOrderingMode($content_ordering_mode, & $errormsg = null) { 181 $retval = false; 182 if (isset ($this->CONTENT_ORDERING_MODES[$content_ordering_mode]) && $content_ordering_mode != $this->getContentOrderingMode()) /* Only update database if the mode is valid and there is an actual change */ { 183 global $db; 184 $content_ordering_mode = $db->escapeString($content_ordering_mode); 185 $db->execSqlUpdate("UPDATE content_group SET content_ordering_mode = '$content_ordering_mode' WHERE content_group_id = '$this->id'", false); 186 $this->refresh(); 187 $retval = true; 188 } 189 elseif (!isset ($this->CONTENT_ORDERING_MODES[$content_ordering_mode])) { 190 $errormsg = _("Invalid content selection mode (must be part of CONTENT_ORDERING_MODES)"); 191 $retval = false; 192 } else { 193 /* Successfull, but nothing modified */ 194 $retval = true; 195 } 196 return $retval; 197 } 198 199 /** When does the content rotate? 200 * @return string, a key of CONTENT_SELECTION_MODES */ 201 public function getContentChangesOnMode() { 202 return $this->content_group_row['content_changes_on_mode']; 203 } 204 205 /** When does the content rotate? 206 * @param $content_changes_on_mode One of the content_changes_on_modeS constants defined in the class 207 * @return true if successfull 208 * */ 209 protected function setContentChangesOnMode($content_changes_on_mode, & $errormsg = null) { 210 $retval = false; 211 if (isset ($this->CONTENT_CHANGES_ON_MODES[$content_changes_on_mode]) && $content_changes_on_mode != $this->getContentChangesOnMode()) /* Only update database if the mode is valid and there is an actual change */ { 212 global $db; 213 $content_changes_on_mode = $db->escapeString($content_changes_on_mode); 214 $db->execSqlUpdate("UPDATE content_group SET content_changes_on_mode = '$content_changes_on_mode' WHERE content_group_id = '$this->id'", false); 215 $this->refresh(); 216 $retval = true; 217 } 218 elseif (!isset ($this->CONTENT_CHANGES_ON_MODES[$content_changes_on_mode])) { 219 $errormsg = _("Invalid content selection mode (must be part of CONTENT_CHANGES_ON_MODES)"); 220 $retval = false; 221 } else { 222 /* Successfull, but nothing modified */ 223 $retval = true; 224 } 225 return $retval; 226 } 227 228 /** Can the same content be shown twice 229 * @return 'YES', 'NO', 'ONCE_PER_NODE' */ 230 public function getAllowRepeat() { 231 return $this->content_group_row['allow_repeat']; 232 } 233 234 /** When does the content rotate? 235 * @param $allow_repeat One of the allow_repeatS constants defined in the class 236 * @return true if successfull 237 * */ 238 protected function setAllowRepeat($allow_repeat, & $errormsg = null) { 239 $retval = false; 240 if (isset ($this->ALLOW_REPEAT_MODES[$allow_repeat]) && $allow_repeat != $this->getAllowRepeat()) /* Only update database if the mode is valid and there is an actual change */ { 241 global $db; 242 $allow_repeat = $db->escapeString($allow_repeat); 243 $db->execSqlUpdate("UPDATE content_group SET allow_repeat = '$allow_repeat' WHERE content_group_id = '$this->id'", false); 244 $this->refresh(); 245 $retval = true; 246 } 247 elseif (!isset ($this->ALLOW_REPEAT_MODES[$allow_repeat])) { 248 $errormsg = _("Invalid content selection mode (must be part of ALLOW_REPEAT_MODES)"); 249 $retval = false; 250 } else { 251 /* Successfull, but nothing modified */ 252 $retval = true; 253 } 254 return $retval; 255 } 256 257 /** How many element should be picked for display at once? 258 * @return integer */ 259 public function getDisplayNumElements() { 260 if ($this->temporary_display_num_elements == null) 261 return $this->content_group_row['display_num_elements']; 262 else 263 return $this->temporary_display_num_elements; 264 } 265 266 /** How many element should be picked for display at once? 267 * @param $display_num_elements integer, must be greater than zero. 268 * @return true if successfull 269 * */ 270 protected function setDisplayNumElements($display_num_elements, & $errormsg = null) { 271 $retval = false; 272 if (($display_num_elements > 0) && $display_num_elements != $this->getDisplayNumElements()) /* Only update database if the mode is valid and there is an actual change */ { 273 global $db; 274 $display_num_elements = $db->escapeString($display_num_elements); 275 $db->execSqlUpdate("UPDATE content_group SET display_num_elements = '$display_num_elements' WHERE content_group_id = '$this->id'", false); 276 $this->refresh(); 277 $retval = true; 278 } 279 elseif ($display_num_elements <= 0) { 280 $errormsg = _("You must display at least one element"); 281 $retval = false; 282 } else { 283 /* Successfull, but nothing modified */ 284 $retval = true; 285 } 286 return $retval; 287 } 288 289 /** 290 * This will a temporary limit ( NOT ACTUALLY STORED IN DATABASE ) 291 * Use getDisplayNumElements to get the number of elements that can be shown 292 * at once 293 */ 294 private function setTemporaryDisplayNumElements($temporary_num_elements) { 295 $this->temporary_display_num_elements = $temporary_num_elements; 296 } 297 298 public function getAdminUI($subclass_admin_interface = null, $title = null) { 299 $html = ''; 300 $html .= "<fieldset class='admin_element_group'>\n"; 301 $html .= "<legend>" . sprintf(_("%s configuration"), get_class($this)) . "</legend>\n"; 302 303 /* is_artistic_content */ 304 $html .= "<li class='admin_element_item_container'>\n"; 305 $html .= "<div class='admin_element_label'>Is artistic content?: </div>\n"; 306 $html .= "<div class='admin_element_data'>\n"; 307 $name = "content_group_" . $this->id . "_is_artistic_content"; 308 $this->isArtisticContent() ? $checked = 'CHECKED' : $checked = ''; 309 $html .= "<input type='checkbox' name='$name' $checked>\n"; 310 $html .= "</div>\n"; 311 $html .= "</li>\n"; 312 313 /* is_locative_content */ 314 $html .= "<li class='admin_element_item_container'>\n"; 315 $html .= "<div class='admin_element_label'>" . ("Is locative content?") . ": </div>\n"; 316 $html .= "<div class='admin_element_data'>\n"; 317 $name = "content_group_" . $this->id . "_is_locative_content"; 318 $this->isLocativeContent() ? $checked = 'CHECKED' : $checked = ''; 319 $html .= "<input type='checkbox' name='$name' $checked>\n"; 320 $html .= "</div>\n"; 321 $html .= "</li>\n"; 322 323 /* content_ordering_mode */ 324 $html .= "<li class='admin_element_item_container'>\n"; 325 $html .= "<div class='admin_element_label'>" . _("In what order should the content displayed?") . ": </div>\n"; 326 $html .= "<div class='admin_element_data'>\n"; 327 $name = "content_group_" . $this->id . "_content_ordering_mode"; 328 329 $i = 0; 330 $tab = null; 331 foreach ($this->CONTENT_ORDERING_MODES as $select_mode_id => $select_mode_descr) { 332 $tab[$i][0] = $select_mode_id; 333 $tab[$i][1] = $select_mode_descr; 334 $i++; 335 } 336 $html .= FormSelectGenerator :: generateFromArray($tab, $this->getContentOrderingMode(), $name, null, false); 337 $html .= "</div>\n"; 338 $html .= "</li>\n"; 339 340 /*content_changes_on_mode */ 341 $html .= "<li class='admin_element_item_container'>\n"; 342 $html .= "<div class='admin_element_label'>" . _("When does the content rotate?") . ": </div>\n"; 343 $html .= "<div class='admin_element_data'>\n"; 344 $name = "content_group_" . $this->id . "_content_changes_on_mode"; 345 $i = 0; 346 $tab = null; 347 foreach ($this->CONTENT_CHANGES_ON_MODES as $select_mode_id => $select_mode_descr) { 348 $tab[$i][0] = $select_mode_id; 349 $tab[$i][1] = $select_mode_descr; 350 $i++; 351 } 352 $html .= FormSelectGenerator :: generateFromArray($tab, $this->getContentChangesOnMode(), $name, null, false); 353 $html .= "</div>\n"; 354 $html .= "</li>\n"; 355 356 /* allow_repeat*/ 357 $html .= "<li class='admin_element_item_container'>\n"; 358 $html .= "<div class='admin_element_label'>" . _("Can content be shown more than once to the same user?") . ": </div>\n"; 359 $html .= "<div class='admin_element_data'>\n"; 360 $name = "content_group_" . $this->id . "_allow_repeat"; 361 $i = 0; 362 $tab = null; 363 foreach ($this->ALLOW_REPEAT_MODES as $select_mode_id => $select_mode_descr) { 364 $tab[$i][0] = $select_mode_id; 365 $tab[$i][1] = $select_mode_descr; 366 $i++; 367 } 368 $html .= FormSelectGenerator :: generateFromArray($tab, $this->getAllowRepeat(), $name, null, false); 369 $html .= "</div>\n"; 370 $html .= "</li>\n"; 371 372 /*display_num_elements*/ 373 $html .= "<li class='admin_element_item_container'>\n"; 374 $html .= "<div class='admin_element_label'>" . ("Pick how many elements for each display?") . ": </div>\n"; 375 $html .= "<div class='admin_element_data'>\n"; 376 $name = "content_group_" . $this->id . "_display_num_elements"; 377 $value = $this->getDisplayNumElements(); 378 $html .= "<input type='text' size='2' value='$value' name='$name'>\n"; 379 $html .= "</div>\n"; 380 $html .= "</li>\n"; 381 $html .= "</fieldset>\n"; 382 383 $html .= "<li class='admin_element_item_container'>\n"; 384 $html .= "<fieldset class='admin_element_group'>\n"; 385 $html .= "<legend>" . sprintf(_("%s display element list"), get_class($this)) . "</legend>\n"; 386 387 /* content_group_element*/ 388 389 $html .= "<ul class='admin_element_list'>\n"; 390 foreach ($this->getElements() as $element) { 391 $html .= "<li class='admin_element_item_container'>\n"; 392 $html .= $element->getAdminUI(null, sprintf(_("%s %d"), get_class($element), $element->getDisplayOrder())); 393 $html .= "<div class='admin_element_tools'>\n"; 394 $name = "content_group_" . $this->id . "_element_" . $element->GetId() . "_erase"; 395 $html .= "<input type='submit' class='submit' name='$name' value='" . sprintf(_("Delete %s %d"), get_class($element), $element->getDisplayOrder()) . "'>"; 396 $html .= "</div>\n"; 397 $html .= "</li>\n"; 398 } 399 $html .= "<li class='admin_element_item_container'>\n"; 400 $html .= self :: getNewContentUI("content_group_{$this->id}_new_element") . "<br>"; 401 $html .= "</li>\n"; 402 $html .= "<li class='admin_element_item_container'>\n"; 403 $html .= self :: getSelectExistingContentUI("content_group_{$this->id}_existing_element", "AND content_id != '$this->id'"); 404 $html .= "</li>\n"; 405 $html .= "</ul>\n"; 406 $html .= "</fieldset>\n"; 407 $html .= "</li>\n"; 408 $html .= $subclass_admin_interface; 409 return parent :: getAdminUI($html, $title); 410 } 411 412 function processAdminUI() { 413 // Init values 414 $errmsg = null; 415 416 if ($this->isOwner(User :: getCurrentUser()) || User :: getCurrentUser()->isSuperAdmin()) { 417 parent :: processAdminUI(); 418 419 /* is_artistic_content */ 420 $name = "content_group_" . $this->id . "_is_artistic_content"; 421 !empty ($_REQUEST[$name]) ? $this->setIsArtisticContent(true) : $this->setIsArtisticContent(false); 422 423 /* is_locative_content */ 424 $name = "content_group_" . $this->id . "_is_locative_content"; 425 !empty ($_REQUEST[$name]) ? $this->setIsLocativeContent(true) : $this->setIsLocativeContent(false); 426 427 /* content_ordering_mode */ 428 $name = "content_group_" . $this->id . "_content_ordering_mode"; 429 $this->setContentOrderingMode(FormSelectGenerator :: getResult($name, null)); 430 431 /*content_changes_on_mode */ 432 $name = "content_group_" . $this->id . "_content_changes_on_mode"; 433 $this->setContentChangesOnMode(FormSelectGenerator :: getResult($name, null)); 434 435 /* allow_repeat*/ 436 $name = "content_group_" . $this->id . "_allow_repeat"; 437 $this->setAllowRepeat(FormSelectGenerator :: getResult($name, null)); 438 439 /*display_num_elements*/ 440 $name = "content_group_" . $this->id . "_display_num_elements"; 441 $this->setDisplayNumElements($_REQUEST[$name]); 442 443 /* content_group_element */ 444 foreach ($this->getElements() as $element) { 445 $name = "content_group_" . $this->id . "_element_" . $element->GetId() . "_erase"; 446 if (!empty ($_REQUEST[$name]) && $_REQUEST[$name] == true) { 447 $element->delete($errmsg); 448 } else { 449 $element->processAdminUI(); 450 } 451 } 452 453 // The two following calls will either add a new element or add an existing one ( depending on what button the user clicked 454 /* We explicitely call the ContentGroupElement version of processNewContentUI */ 455 ContentGroupElement :: processNewContentUI("content_group_{$this->id}_new_element", $this); 456 // Last parameters allows for existing content ( if any was selected ) 457 ContentGroupElement :: processNewContentUI("content_group_{$this->id}_existing_element", $this, true); 458 } 459 } 460 461 /** Is this Content element displayable at this hotspot 462 * @param $node Node, optionnal 463 * @return true or false */ 464 public function isDisplayableAt($node) { 465 $old_curent_node = Node :: getCurrentNode(); 466 Node :: setCurrentNode($node); 467 468 if (count($this->getDisplayElements()) > 0) { 469 $retval = true; 470 } else { 471 $retval = false; 472 } 473 474 if ($old_curent_node != null) { 475 Node :: setCurrentNode($old_curent_node); 476 } 477 478 return $retval; 479 } 480 481 /**Get the next element or elements to be displayed, depending on the display mode 482 * @return an array of ContentGroupElement or an empty arrray */ 483 function getDisplayElements() { 484 // Define globals 485 global $db; 486 487 // Init values 488 $retval = array (); 489 $user = User :: getCurrentUser(); 490 $redisplay_rows = null; 491 $last_order_row = null; 492 $element_rows = null; 493 494 if ($user) { 495 $user_id = $user->getId(); 496 } else { 497 $user_id = ''; 498 } 499 $node = Node :: getCurrentNode(); 500 if ($node) { 501 $node_id = $node->getId(); 502 } else { 503 $node_id = ''; 504 } 505 $display_num_elements = $this->getDisplayNumElements(); 506 507 /** First, find if we have content to display again because we haven't passed the rotation period */ 508 /* 'ALWAYS' => "Content always rotates" 509 * 'NEXT_DAY' => "Content rotates once per day" 510 * 'NEXT_LOGIN' => "Content rotates once per session" 511 * 'NEXT_NODE' => "Content rotates each time you change node"*/ 512 $content_changes_on_mode = $this->getContentChangesOnMode(); 513 514 $redisplay_objects = array (); 515 if ($content_changes_on_mode != 'ALWAYS') { 516 $sql = "SELECT content_group_element_id FROM content_group_element \n"; 517 $sql .= "JOIN content_display_log ON (content_group_element_id=content_id) \n"; 518 $sql .= " WHERE content_group_id='$this->id' \n"; 519 520 if ($content_changes_on_mode == 'NEXT_DAY') { 521 $sql .= "AND date_trunc('day', last_display_timestamp) = date_trunc('day', CURRENT_DATE) \n"; 522 } 523 if ($content_changes_on_mode == 'NEXT_LOGIN') { 524 /**@todo Must fix, this will fail if the user never really connected from a hotspot... */ 525 $sql .= "AND last_display_timestamp > (SELECT timestamp_in FROM connections WHERE user_id='$user_id' ORDER BY timestamp_in DESC LIMIT 1) \n"; 526 } 527 if ($content_changes_on_mode == 'NEXT_NODE') { 528 /** We find the close time of the last connection from another node */ 529 $sql .= "AND last_display_timestamp > (SELECT timestamp_out FROM connections WHERE user_id='$user_id' AND node_id != '$node_id' ORDER BY timestamp_in DESC LIMIT 1) \n"; 530 } 531 /* There usually won't be more than one, but if there is, we want the most recents */ 532 $sql .= " ORDER BY last_display_timestamp DESC "; 533 $db->execSql($sql, $redisplay_rows, false); 534 $redisplay_objects = array (); 535 if ($redisplay_rows != null) { 536 foreach ($redisplay_rows as $redisplay_row) { 537 $object = self :: getObject($redisplay_row['content_group_element_id']); 538 if ($object->isDisplayableAt(Node :: GetCurrentNode()) == true) /** Only content available at this hotspot are considered */ 539 { 540 $redisplay_objects[] = $object; 541 } 542 } 543 } 544 /* Pick the proper number of elements to be re-displayed */ 545 $redisplay_objects = array_slice($redisplay_objects, 0, $display_num_elements); 546 547 } 548 549 $new_object
