Changeset 1127
- Timestamp:
- 11/14/06 15:11:42 (7 years ago)
- Location:
- trunk/wifidog-auth
- Files:
-
- 2 added
- 88 modified
-
CHANGELOG (modified) (1 diff)
-
wifidog/admin/admin_common.php (modified) (1 diff)
-
wifidog/admin/generic_object_admin.php (modified) (3 diffs)
-
wifidog/admin/hotspot_location_map.php (modified) (1 diff)
-
wifidog/admin/import_user_database.php (modified) (1 diff)
-
wifidog/admin/index.php (modified) (1 diff)
-
wifidog/admin/online_users.php (modified) (1 diff)
-
wifidog/admin/stats.php (modified) (1 diff)
-
wifidog/admin/user_log.php (modified) (1 diff)
-
wifidog/change_password.php (modified) (3 diffs)
-
wifidog/classes/AbstractDb.php (modified) (1 diff)
-
wifidog/classes/Authenticator.php (modified) (4 diffs)
-
wifidog/classes/Authenticators/AuthenticatorLDAP.php (modified) (1 diff)
-
wifidog/classes/Authenticators/AuthenticatorLocalUser.php (modified) (1 diff)
-
wifidog/classes/Authenticators/AuthenticatorRadius.php (modified) (4 diffs)
-
wifidog/classes/Content.php (modified) (23 diffs)
-
wifidog/classes/Content/ContentGroup/ContentGroup.php (modified) (12 diffs)
-
wifidog/classes/Content/ContentGroup/ContentGroupElement.php (modified) (1 diff)
-
wifidog/classes/Content/EmbeddedContent/EmbeddedContent.php (modified) (2 diffs)
-
wifidog/classes/Content/File/File.php (modified) (1 diff)
-
wifidog/classes/Content/FlickrPhotostream/FlickrPhotostream.php (modified) (1 diff)
-
wifidog/classes/Content/HTMLeditor/HTMLeditor.php (modified) (5 diffs)
-
wifidog/classes/Content/IFrame/IFrame.php (modified) (1 diff)
-
wifidog/classes/Content/Langstring/Langstring.php (modified) (5 diffs)
-
wifidog/classes/Content/PatternLanguage/PatternLanguage.php (modified) (2 diffs)
-
wifidog/classes/Content/Picture/Picture.php (modified) (1 diff)
-
wifidog/classes/Content/RssAggregator/RssAggregator.php (modified) (8 diffs)
-
wifidog/classes/Content/Stylesheet (added)
-
wifidog/classes/Content/Stylesheet/Stylesheet.php (added)
-
wifidog/classes/FormSelectGenerator.php (modified) (2 diffs)
-
wifidog/classes/Locale.php (modified) (3 diffs)
-
wifidog/classes/LocaleList.php (modified) (2 diffs)
-
wifidog/classes/MainUI.php (modified) (17 diffs)
-
wifidog/classes/Network.php (modified) (34 diffs)
-
wifidog/classes/Node.php (modified) (24 diffs)
-
wifidog/classes/NodeLists/NodeListHTML.php (modified) (2 diffs)
-
wifidog/classes/NodeLists/NodeListJiWireCSV.php (modified) (1 diff)
-
wifidog/classes/NodeLists/NodeListKML.php (modified) (1 diff)
-
wifidog/classes/NodeLists/NodeListPDF.php (modified) (3 diffs)
-
wifidog/classes/NodeLists/NodeListRSS.php (modified) (2 diffs)
-
wifidog/classes/NodeLists/NodeListXML.php (modified) (1 diff)
-
wifidog/classes/Server.php (modified) (14 diffs)
-
wifidog/classes/Session.php (modified) (2 diffs)
-
wifidog/classes/SmartyWifidog.php (modified) (2 diffs)
-
wifidog/classes/StatisticGraph.php (modified) (2 diffs)
-
wifidog/classes/StatisticGraph/ConnectionsPerHour.php (modified) (1 diff)
-
wifidog/classes/StatisticGraph/RegistrationsCumulative.php (modified) (1 diff)
-
wifidog/classes/StatisticGraph/RegistrationsPerMonth.php (modified) (1 diff)
-
wifidog/classes/StatisticGraph/VisitsPerMonth.php (modified) (1 diff)
-
wifidog/classes/StatisticGraph/VisitsPerWeekday.php (modified) (1 diff)
-
wifidog/classes/StatisticReport/ConnectionGraphs.php (modified) (1 diff)
-
wifidog/classes/StatisticReport/ConnectionLog.php (modified) (1 diff)
-
wifidog/classes/StatisticReport/HighestBandwidthUsers.php (modified) (1 diff)
-
wifidog/classes/StatisticReport/MostFrequentUsers.php (modified) (1 diff)
-
wifidog/classes/StatisticReport/MostMobileUsers.php (modified) (1 diff)
-
wifidog/classes/StatisticReport/MostPopularNodes.php (modified) (1 diff)
-
wifidog/classes/StatisticReport/NetworkStatus.php (modified) (1 diff)
-
wifidog/classes/StatisticReport/NodeStatus.php (modified) (1 diff)
-
wifidog/classes/StatisticReport/RegistrationLog.php (modified) (1 diff)
-
wifidog/classes/StatisticReport/UserRegistrationReport.php (modified) (1 diff)
-
wifidog/classes/StatisticReport/UserReport.php (modified) (1 diff)
-
wifidog/classes/Statistics.php (modified) (6 diffs)
-
wifidog/classes/User.php (modified) (26 diffs)
-
wifidog/clickthrough.php (modified) (1 diff)
-
wifidog/content/PatternLanguage/archives.php (modified) (2 diffs)
-
wifidog/content/PatternLanguage/hotspots.php (modified) (2 diffs)
-
wifidog/content/PatternLanguage/index.php (modified) (2 diffs)
-
wifidog/content/PatternLanguage/narrative.php (modified) (2 diffs)
-
wifidog/content/PatternLanguage/subscription.php (modified) (2 diffs)
-
wifidog/content/index.php (modified) (3 diffs)
-
wifidog/cron/vacuum.php (modified) (1 diff)
-
wifidog/faq.php (modified) (1 diff)
-
wifidog/file_download.php (modified) (1 diff)
-
wifidog/gw_message.php (modified) (1 diff)
-
wifidog/help.php (modified) (1 diff)
-
wifidog/hotspot_status.php (modified) (1 diff)
-
wifidog/hotspots_map.php (modified) (2 diffs)
-
wifidog/include/common.php (modified) (2 diffs)
-
wifidog/include/common_interface.php (modified) (1 diff)
-
wifidog/include/language.php (modified) (1 diff)
-
wifidog/include/schema_validate.php (modified) (3 diffs)
-
wifidog/index.php (modified) (2 diffs)
-
wifidog/login/index.php (modified) (4 diffs)
-
wifidog/lost_password.php (modified) (3 diffs)
-
wifidog/lost_username.php (modified) (3 diffs)
-
wifidog/node_list.php (modified) (2 diffs)
-
wifidog/portal/index.php (modified) (7 diffs)
-
wifidog/resend_validation.php (modified) (3 diffs)
-
wifidog/signup.php (modified) (4 diffs)
-
wifidog/validate.php (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/wifidog-auth/CHANGELOG
r1126 r1127 1 2006-11-13 Benoit Grégoire <bock@step.polymtl.ca> 2 * Make the MainUI, SmartyWifidog and Session and AbstractDb classes singletons 3 * Implement two pass content display. All Content can now implement a prepareGetUserUI(), allowing them to interact with MainUI and other Content before display. 4 Allow creating content such as stylesheets, feed accumulators, etc. 5 * SmartyWifidog.php Turn on security, begin preparing for standardisation of Smarty variables 6 * New Content type: Stylesheet. Allows specific nodes, or even specific content groups to have custom stylesheets. 7 * Langstring.php: Make getAdminUI calling conventions coherent with other content types. 8 1 9 2006-11-11 Benoit Grégoire <bock@step.polymtl.ca> 2 10 * Authenticator.php: Critical: Fix SQL query syntax in acctStart() -
trunk/wifidog-auth/wifidog/admin/admin_common.php
r914 r1127 49 49 require_once('include/common_interface.php'); 50 50 require_once('classes/Security.php'); 51 52 51 /* 53 52 * Local variables: -
trunk/wifidog-auth/wifidog/admin/generic_object_admin.php
r1100 r1127 70 70 71 71 // Init values 72 $ui = MainUI::getObject(); 72 73 $html = ""; 73 74 $errmsg = ""; … … 184 185 185 186 if (method_exists($object, "getUserUI")) { 186 $ html .= $object->getUserUI();187 $ui->addContent('main_area_middle', $object, 1); 187 188 } 188 189 … … 418 419 * Render output 419 420 */ 420 $ui = new MainUI(); 421 421 422 $ui->setTitle(_("Generic object editor")); 422 423 $ui->setHtmlHeader($_htmlHeader); -
trunk/wifidog-auth/wifidog/admin/hotspot_location_map.php
r1030 r1127 56 56 require_once('classes/Server.php'); 57 57 58 $ui = new MainUI();58 $ui = MainUI::getObject(); 59 59 $ui->setTitle(_("Hotspot location map")); 60 60 -
trunk/wifidog-auth/wifidog/admin/import_user_database.php
r1123 r1127 260 260 $html .= "</fieldset>\n"; 261 261 262 $ui= new MainUI();262 $ui=MainUI::getObject(); 263 263 $ui->setToolSection('ADMIN'); 264 264 $ui->addContent('main_area_middle', $html); -
trunk/wifidog-auth/wifidog/admin/index.php
r1030 r1127 54 54 55 55 // Load MainUI class 56 $ui = new MainUI();56 $ui = MainUI::getObject(); 57 57 58 58 // Get information about curent user -
trunk/wifidog-auth/wifidog/admin/online_users.php
r1030 r1127 52 52 Security::requireAdmin(); 53 53 54 global $db;54 $db = AbstractDb::getObject(); 55 55 $online_users = null; 56 56 $db->execSql("SELECT connections.user_id, name, username, account_origin, timestamp_in, incoming, outgoing FROM connections,users,nodes WHERE token_status='".TOKEN_INUSE."' AND users.user_id=connections.user_id AND nodes.node_id=connections.node_id ORDER BY account_origin, timestamp_in DESC", $online_users); 57 57 $smarty->assign("users_array", $online_users); 58 58 59 $ui = new MainUI();59 $ui = MainUI::getObject(); 60 60 $ui->setToolSection('ADMIN'); 61 61 $ui->addContent('main_area_middle', $smarty->fetch("admin/templates/online_users.html")); -
trunk/wifidog-auth/wifidog/admin/stats.php
r1095 r1127 124 124 $html .= "</p>"; 125 125 } 126 $ui = new MainUI();126 $ui = MainUI::getObject(); 127 127 $ui->setToolSection('ADMIN'); 128 128 $ui->addContent('main_area_middle', $html); -
trunk/wifidog-auth/wifidog/admin/user_log.php
r1030 r1127 119 119 $html .= $smarty->fetch("admin/templates/user_log.html"); 120 120 121 $ui= new MainUI();121 $ui=MainUI::getObject(); 122 122 $ui->setToolSection('ADMIN'); 123 123 $ui->addContent('main_area_middle', $html); -
trunk/wifidog-auth/wifidog/change_password.php
r1031 r1127 54 54 require_once('include/common_interface.php'); 55 55 require_once('classes/User.php'); 56 56 $smarty = SmartyWifidog::getObject(); 57 $smarty = SmartyWifidog::getObject(); 57 58 $smarty->assign('error', ''); 58 59 … … 130 131 } 131 132 132 $ui = new MainUI();133 $ui = MainUI::getObject(); 133 134 $ui->addContent('main_area_middle', $smarty->fetch("templates/sites/validate.tpl")); 134 135 $ui->display(); … … 152 153 isset ($_REQUEST["auth_source"]) && $smarty->assign('selected_auth_source', $_REQUEST["auth_source"]); 153 154 154 $ui = new MainUI();155 $ui = MainUI::getObject(); 155 156 $smarty->assign('SelectNetworkUI', Network::getSelectNetworkUI('auth_source')); 156 157 $ui->addContent('main_area_middle', $smarty->fetch("templates/change_password.html")); -
trunk/wifidog-auth/wifidog/classes/AbstractDb.php
r1079 r1127 54 54 class AbstractDb 55 55 { 56 private static $object; 57 public static function getObject() { 58 if (self::$object==null) 59 { 60 self::$object=new self(); 61 } 62 return self::$object; 63 } 64 /** Constructor */ 65 private function __construct() { 66 } 67 56 68 // Connects to PostgreSQL database 57 69 function connect($db_name) -
trunk/wifidog-auth/wifidog/classes/Authenticator.php
r1126 r1127 120 120 public function logout($conn_id = null) 121 121 { 122 // Define globals123 global $db;124 global $session;122 123 $db = AbstractDb::getObject(); 124 $session = Session::getObject(); 125 125 126 126 $conn_id = $db->escapeString($conn_id); … … 184 184 public function acctStart($conn_id) 185 185 { 186 // Define globals187 global $db;186 187 $db = AbstractDb::getObject(); 188 188 189 189 $conn_id = $db->escapeString($conn_id); … … 236 236 public function acctUpdate($conn_id, $incoming, $outgoing) 237 237 { 238 // Define globals239 global $db;238 239 $db = AbstractDb::getObject(); 240 240 241 241 // Write traffic counters to database … … 254 254 public function acctStop($conn_id) 255 255 { 256 // Define globals257 global $db;256 257 $db = AbstractDb::getObject(); 258 258 259 259 // Stop traffic counters update -
trunk/wifidog-auth/wifidog/classes/Authenticators/AuthenticatorLDAP.php
r1090 r1127 232 232 public function login($username, $password, &$errmsg = null) 233 233 { 234 // Define globals235 global $db;234 235 $db = AbstractDb::getObject(); 236 236 237 237 // Init values -
trunk/wifidog-auth/wifidog/classes/Authenticators/AuthenticatorLocalUser.php
r1090 r1127 107 107 public function login($username, $password, &$errmsg = null) 108 108 { 109 // Define globals110 global $db;109 110 $db = AbstractDb::getObject(); 111 111 112 112 // Init values -
trunk/wifidog-auth/wifidog/classes/Authenticators/AuthenticatorRadius.php
r1123 r1127 172 172 public function login($username, $password, &$errmsg = null) 173 173 { 174 // Define globals175 global $db;174 175 $db = AbstractDb::getObject(); 176 176 177 177 // Init values … … 308 308 public function acctStart($conn_id, &$errmsg = null) 309 309 { 310 // Define globals311 global $db;310 311 $db = AbstractDb::getObject(); 312 312 313 313 // Init values … … 378 378 parent::acctUpdate($conn_id, $incoming, $outgoing); 379 379 380 // Define globals381 global $db;382 383 380 // Init values 381 $db = AbstractDb::getObject(); 384 382 $info = null; 385 383 $conn_id = $db->escapeString($conn_id); … … 448 446 parent::acctStop($conn_id); 449 447 450 // Define globals451 global $db;448 449 $db = AbstractDb::getObject(); 452 450 453 451 // Init values -
trunk/wifidog-auth/wifidog/classes/Content.php
r1123 r1127 98 98 */ 99 99 private function __construct($content_id) { 100 // Define globals101 global $db;100 101 $db = AbstractDb::getObject(); 102 102 103 103 // Init values … … 150 150 */ 151 151 public static function createNewObject($content_type = "Content", $id = null) { 152 // Define globals153 global $db;152 153 $db = AbstractDb::getObject(); 154 154 155 155 if (empty ($id)) { … … 241 241 */ 242 242 public static function getObject($content_id) { 243 // Define globals244 global $db;243 244 $db = AbstractDb::getObject(); 245 245 246 246 // Init values … … 383 383 */ 384 384 public static function getAllContent($content_type = "") { 385 // Define globals386 global $db;385 386 $db = AbstractDb::getObject(); 387 387 388 388 // Init values … … 419 419 */ 420 420 public static function getNewContentUI($user_prefix, $content_type_filter = null, $title = null) { 421 // Define globals422 global $db;421 422 $db = AbstractDb::getObject(); 423 423 424 424 // Init values … … 537 537 */ 538 538 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') { 539 // Define globals540 global $db;539 540 $db = AbstractDb::getObject(); 541 541 542 542 // Init values … … 616 616 */ 617 617 static function processLinkedContentUI($user_prefix, $link_table, $link_table_obj_key_col, $link_table_obj_key) { 618 global $db;618 $db = AbstractDb::getObject(); 619 619 $link_table = $db->escapeString($link_table); 620 620 $link_table_obj_key_col = $db->escapeString($link_table_obj_key_col); … … 722 722 */ 723 723 public static function getSelectExistingContentUI($user_prefix, $sql_additional_where = null, $content_type_filter = null, $order = "creation_timestamp", $type_interface = "select") { 724 // Define globals725 global $db;724 725 $db = AbstractDb::getObject(); 726 726 727 727 // Init values … … 889 889 * */ 890 890 private function setContentType($content_type) { 891 global $db;891 $db = AbstractDb::getObject(); 892 892 $content_type = $db->escapeString($content_type); 893 893 if (!self :: isContentTypeAvailable($content_type)) { … … 907 907 * @return true on success, false on failure */ 908 908 public function addOwner(User $user, $is_author = false) { 909 global $db;909 $db = AbstractDb::getObject(); 910 910 $content_id = "'" . $this->id . "'"; 911 911 $user_id = "'" . $db->escapeString($user->getId()) . "'"; … … 924 924 */ 925 925 public function deleteOwner(User $user, $is_author = false) { 926 global $db;926 $db = AbstractDb::getObject(); 927 927 $content_id = "'" . $this->id . "'"; 928 928 $user_id = "'" . $db->escapeString($user->getId()) . "'"; … … 959 959 */ 960 960 public function getLastDisplayTimestamp($user = null, $node = null) { 961 global $db;961 $db = AbstractDb::getObject(); 962 962 $retval = ''; 963 963 $sql = "SELECT EXTRACT(EPOCH FROM last_display_timestamp) as last_display_unix_timestamp FROM content_display_log WHERE content_id='{$this->id}' \n"; … … 991 991 * @return true if the user is a owner, false if he isn't of the user is null */ 992 992 public function isOwner($user) { 993 global $db;993 $db = AbstractDb::getObject(); 994 994 $retval = false; 995 995 if ($user != null) { … … 1007 1007 * @return null or array of User objects */ 1008 1008 public function getAuthors() { 1009 global $db;1009 $db = AbstractDb::getObject(); 1010 1010 $retval = array (); 1011 1011 $sql = "SELECT user_id FROM content_has_owners WHERE content_id='$this->id' AND is_author=TRUE"; … … 1029 1029 return false; 1030 1030 } 1031 1032 /** This function will be called by MainUI for each Content BEFORE any getUserUI function is called to allow two pass Content display. 1033 * Two pass Content display allows such things as modyfying headers, title, creating content type that accumulate content from other pieces (like RSS feeds) 1034 * @return null 1035 */ 1036 public function prepareGetUserUI() { 1037 return null; 1038 } 1031 1039 /** 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. 1032 1040 * @param $subclass_admin_interface Html content of the interface element of a children … … 1120 1128 $user_id = $user->getId(); 1121 1129 $node_id = $node->getId(); 1122 global $db;1130 $db = AbstractDb::getObject(); 1123 1131 1124 1132 $sql = "SELECT * FROM content_display_log WHERE user_id='$user_id' AND node_id='$node_id' AND content_id='$this->id'"; … … 1163 1171 */ 1164 1172 public function getAdminUI($subclass_admin_interface = null, $title = null) { 1165 global $db;1173 $db = AbstractDb::getObject(); 1166 1174 1167 1175 $html = ''; … … 1306 1314 $html .= "<ul class='admin_element_list'>\n"; 1307 1315 1308 global $db;1316 $db = AbstractDb::getObject(); 1309 1317 $sql = "SELECT * FROM content_has_owners WHERE content_id='$this->id'"; 1310 1318 $db->execSql($sql, $content_owner_rows, false); … … 1354 1362 public function processAdminUI() { 1355 1363 if ($this->isOwner(User :: getCurrentUser()) || User :: getCurrentUser()->isSuperAdmin()) { 1356 global $db;1364 $db = AbstractDb::getObject(); 1357 1365 if ($this->getObjectType() == 'Content') /* The object hasn't yet been typed */ { 1358 1366 $content_type = FormSelectGenerator :: getResult("content_" . $this->id . "_content_type", "Content"); … … 1490 1498 */ 1491 1499 public function isUserSubscribed(User $user) { 1492 global $db;1500 $db = AbstractDb::getObject(); 1493 1501 $sql = "SELECT content_id FROM user_has_content WHERE user_id = '{$user->getId()}' AND content_id = '{$this->getId()}';"; 1494 1502 $db->execSqlUniqueRes($sql, $row, false); … … 1528 1536 if ($should_display != $this->titleShouldDisplay()) /* Only update database if there is an actual change */ { 1529 1537 $should_display ? $should_display_sql = 'TRUE' : $should_display_sql = 'FALSE'; 1530 global $db;1538 $db = AbstractDb::getObject(); 1531 1539 $db->execSqlUpdate("UPDATE content SET title_is_displayed = $should_display_sql WHERE content_id = '$this->id'", false); 1532 1540 $this->refresh(); … … 1553 1561 $is_persistent ? $is_persistent_sql = 'TRUE' : $is_persistent_sql = 'FALSE'; 1554 1562 1555 global $db;1563 $db = AbstractDb::getObject(); 1556 1564 $db->execSqlUpdate("UPDATE content SET is_persistent = $is_persistent_sql WHERE content_id = '$this->id'", false); 1557 1565 $this->refresh(); … … 1576 1584 $errmsg = _("Content is persistent (you must make it non persistent before you can delete it)"); 1577 1585 } else { 1578 global $db;1586 $db = AbstractDb::getObject(); 1579 1587 if ($this->isOwner(User :: getCurrentUser()) || User :: getCurrentUser()->isSuperAdmin()) { 1580 1588 $sql = "DELETE FROM content WHERE content_id='$this->id'"; -
trunk/wifidog-auth/wifidog/classes/Content/ContentGroup/ContentGroup.php
r1094 r1127 85 85 private $expand_status = false; 86 86 private $temporary_display_num_elements; 87 87 private $display_elements; 88 88 private $content_selection_mode; 89 89 private $content_group_row; … … 92 92 93 93 protected function __construct($content_id) { 94 // Define globals95 global $db;94 95 $db = AbstractDb::getObject(); 96 96 97 97 // Init values … … 145 145 $is_artistic_content ? $is_artistic_content_sql = 'TRUE' : $is_artistic_content_sql = 'FALSE'; 146 146 147 global $db;147 $db = AbstractDb::getObject(); 148 148 $db->execSqlUpdate("UPDATE content_group SET is_artistic_content = $is_artistic_content_sql WHERE content_group_id = '$this->id'", false); 149 149 $this->refresh(); … … 170 170 $is_locative_content ? $is_locative_content_sql = 'TRUE' : $is_locative_content_sql = 'FALSE'; 171 171 172 global $db;172 $db = AbstractDb::getObject(); 173 173 $db->execSqlUpdate("UPDATE content_group SET is_locative_content = $is_locative_content_sql WHERE content_group_id = '$this->id'", false); 174 174 $this->refresh(); … … 190 190 $retval = false; 191 191 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 */ { 192 global $db;192 $db = AbstractDb::getObject(); 193 193 $content_ordering_mode = $db->escapeString($content_ordering_mode); 194 194 $db->execSqlUpdate("UPDATE content_group SET content_ordering_mode = '$content_ordering_mode' WHERE content_group_id = '$this->id'", false); … … 219 219 $retval = false; 220 220 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 */ { 221 global $db;221 $db = AbstractDb::getObject(); 222 222 $content_changes_on_mode = $db->escapeString($content_changes_on_mode); 223 223 $db->execSqlUpdate("UPDATE content_group SET content_changes_on_mode = '$content_changes_on_mode' WHERE content_group_id = '$this->id'", false); … … 248 248 $retval = false; 249 249 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 */ { 250 global $db;250 $db = AbstractDb::getObject(); 251 251 $allow_repeat = $db->escapeString($allow_repeat); 252 252 $db->execSqlUpdate("UPDATE content_group SET allow_repeat = '$allow_repeat' WHERE content_group_id = '$this->id'", false); … … 280 280 $retval = false; 281 281 if (($display_num_elements > 0) && $display_num_elements != $this->getDisplayNumElements()) /* Only update database if the mode is valid and there is an actual change */ { 282 global $db;282 $db = AbstractDb::getObject(); 283 283 $display_num_elements = $db->escapeString($display_num_elements); 284 284 $db->execSqlUpdate("UPDATE content_group SET display_num_elements = '$display_num_elements' WHERE content_group_id = '$this->id'", false); … … 491 491 * @return an array of ContentGroupElement or an empty arrray */ 492 492 function getDisplayElements() { 493 // Define globals 494 global $db; 493 //This function is very expensive, cache the results 494 if(!is_array($this->display_elements)){ 495 496 $db = AbstractDb::getObject(); 495 497 496 498 // Init values … … 642 644 $retval = array_merge($new_objects, $redisplay_objects); 643 645 //echo count($retval).' returned <br>'; 644 return $retval; 646 $this->display_elements=$retval; 647 } 648 return $this->display_elements; 645 649 } 646 650 … … 689 693 } 690 694 695 /** This function will be called by MainUI for each Content BEFORE any getUserUI function is called to allow two pass Content display. 696 * Two pass Content display allows such things as modyfying headers, title, creating content type that accumulate content from other pieces (like RSS feeds) 697 * @return null 698 */ 699 public function prepareGetUserUI() { 700 $display_elements = $this->getDisplayElements(); 701 foreach ($display_elements as $display_element) { 702 $display_element->prepareGetUserUI(); 703 } 704 return parent :: prepareGetUserUI(); 705 } 706 691 707 /** 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. 692 708 * @param $subclass_admin_interface Html content of the interface element of a children … … 722 738 * @return an array of ContentGroupElement or an empty arrray */ 723 739 function getElements($additional_where=null) { 724 // Define globals725 global $db;740 741 $db = AbstractDb::getObject(); 726 742 727 743 // Init values -
trunk/wifidog-auth/wifidog/classes/Content/ContentGroup/ContentGroupElement.php
r1092 r1127 63 63 class ContentGroupElement extends Content { 64 64 65 /** 66 67 */ 68 private $content_group_element_row; 69 70 /** 71 * Constructor 72 * 73 * @param string $content_id Content Id 74 * 75 * @return void */ 76 protected function __construct($content_id) { 77 // Define globals 78 global $db; 79 80 // Init values 81 $row = null; 82 83 parent :: __construct($content_id); 84 $content_id = $db->escapeString($content_id); 85 86 $sql_select = "SELECT * FROM content_group_element WHERE content_group_element_id='$content_id'"; 87 $db->execSqlUniqueRes($sql_select, $row, false); 88 89 if ($row == null) { 90 // The database was corrupted, let's fix it ... 91 $sql = "DELETE FROM content WHERE content_id='$content_id'"; 92 $db->execSqlUpdate($sql, true); 93 } 94 95 $this->content_group_element_row = $row; 96 97 /* A content group element is NEVER persistent */ 98 parent :: setIsPersistent(false); 99 } 100 /** 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 101 * @return true or false */ 102 public function isSimpleContent() { 103 return true; 104 } 105 /** 106 * Replace and delete the old displayed_content (if any) by the new 107 * content (or no content) 108 * 109 * @param object $new_displayed_content Content object or null. If 110 * null the old content is still 111 * deleted. 112 * 113 * @return void 114 115 */ 116 private function replaceDisplayedContent($new_displayed_content) { 117 // Define globals 118 global $db; 119 120 // Init values 121 $old_displayed_content = null; 122 $errmsg = null; 123 124 if (!empty ($this->content_group_element_row['displayed_content_id'])) { 125 $old_displayed_content = self :: getObject($this->content_group_element_row['displayed_content_id']); 126 } 127 128 if ($new_displayed_content != null) { 129 $new_displayed_content_id_sql = "'" . $new_displayed_content->GetId() . "'"; 130 } else { 131 $new_displayed_content_id_sql = "NULL"; 132 } 133 134 $db->execSqlUpdate("UPDATE content_group_element SET displayed_content_id = $new_displayed_content_id_sql WHERE content_group_element_id = '$this->id'", FALSE); 135 136 if ($old_displayed_content != null) { 137 $old_displayed_conten->delete($errmsg); 138 } 139 } 140 141 /** 142 * Get the order of the element in the content group 143 * 144 * @return string the order of the element in the content group 145 */ 146 public function getDisplayOrder() { 147 return $this->content_group_element_row['display_order']; 148 } 149 150 /** 151 * Set the order of the element in the content group 152 * 153 * @param string $order Order how items should be displayed 154 * 155 * @return void 156 */ 157 public function setDisplayOrder($order) { 158 // Define globals 159 global $db; 160 161 if ($order != $this->getDisplayOrder()) { 162 /* 163 * Only update database if there is an actual change 164 */ 165 $order = $db->escapeString($order); 166 $db->execSqlUpdate("UPDATE content_group_element SET display_order = $order WHERE content_group_element_id = '$this->id'", false); 167 } 168 } 169 170 /** 171 * Like the same method as defined in Content, this method will create a 172 * ContentGroupElement based on the content type specified by 173 * getNewContentUI OR get an existing element by getSelectExistingContentUI 174 * 175 * @param string $user_prefix A identifier provided by the programmer to 176 * recognise it's generated form 177 * @param string $content_group Must be present 178 * @param bool $associate_existing_content If set to true, will get an 179 * existing element instead of creating a 180 * new content. 181 * 182 * @return object The ContentGroup object, or null if the user didn't greate one 183 * @static 184 */ 185 public static function processNewContentUI($user_prefix, ContentGroup $content_group, $associate_existing_content = false) { 186 // Define globals 187 global $db; 188 189 // Init values 190 $content_group_element_object = null; 191 $max_display_order_row = null; 192 193 if ($associate_existing_content == true) { 194 $name = "{$user_prefix}_add"; 195 } else { 196 $name = "get_new_content_{$user_prefix}_add"; 197 } 198 199 if (!empty ($_REQUEST[$name]) && $_REQUEST[$name] == true) { 200 /* Get the display order to add the GontentGroupElement at the end */ 201 $sql = "SELECT MAX(display_order) as max_display_order FROM content_group_element WHERE content_group_id='" . $content_group->getId() . "'"; 202 $db->execSqlUniqueRes($sql, $max_display_order_row, false); 203 $display_order = $max_display_order_row['max_display_order'] + 1; 204 205 if ($associate_existing_content == true) { 206 $name = "{$user_prefix}"; 207 } else { 208 $name = "get_new_content_{$user_prefix}_content_type"; 209 } 210 211 $content_id = get_guid(); 212 $content_type = 'ContentGroupElement'; 213 $sql = "INSERT INTO content (content_id, content_type) VALUES ('$content_id', '$content_type');"; 214 215 if (!$db->execSqlUpdate($sql, false)) { 216 throw new Exception(_('Unable to insert new content into database!')); 217 } 218 219 $sql = "INSERT INTO content_group_element (content_group_element_id, content_group_id, display_order) VALUES ('$content_id', '" . $content_group->GetId() . "', $display_order);"; 220 221 if (!$db->execSqlUpdate($sql, false)) { 222 throw new Exception(_('Unable to insert new content into database!')); 223 } 224 225 $content_group_element_object = self :: getObject($content_id); 226 227 $content_ui_result = FormSelectGenerator :: getResult($name, null); 228 229 if ($associate_existing_content == true) { 230 $displayed_content_object = self :: getObject($content_ui_result); 231 } else { 232 $displayed_content_object = self :: createNewObject($content_ui_result); 233 } 234 235 $content_group_element_object->replaceDisplayedContent($displayed_content_object); 236 } 237 238 return $content_group_element_object; 239 } 240 /** If set, content will only be displayed from this date on. */ 241 function getValidFromDate() { 242 return $this->content_group_element_row['valid_from_timestamp']; 243 } 244 245 /** If set, content will only be displayed from this date on. 246 * @param string @date Start date. To always display, set to null or an empty string */ 247 function setValidFromDate($date) { 248 // Define globals 249 global $db; 250 if ($date != $this->getValidFromDate()) { 251 if (!empty ($date)) { 252 $date = "'" . $db->escapeString($date) . "'"; 253 } else { 254 $date = 'NULL'; 255 } 256 $db->execSqlUpdate("UPDATE content_group_element SET valid_from_timestamp = {$date} WHERE content_group_element_id = '{$this->getId()}'"); 257 $this->refresh(); 258 } 259 } 260 /** If set, content will only be displayed untill this date (and will then be archived). */ 261 function getValidUntilDate() { 262 return $this->content_group_element_row['valid_until_timestamp']; 263 } 264 265 /** If set, content will only be displayed untill this date (and will then be archived). 266 * @param string @date End date. To always display, set to null or an empty string */ 267 function setValidUntilDate($date) { 268 // Define globals 269 global $db; 270 if ($date != $this->getValidUntilDate()) { 271 if (!empty ($date)) { 272 $date = "'" . $db->escapeString($date) . "'"; 273 } else { 274 $date = 'NULL'; 275 } 276 $db->execSqlUpdate("UPDATE content_group_element SET valid_until_timestamp = {$date} WHERE content_group_element_id = '{$this->getId()}'"); 277 $this->refresh(); 278 } 279 } 280 281 /** 282 * Shows the administration interface for ContentGroupElement 283 * 284 * @param string $subclass_admin_interface HTML code to be added after the 285 * administration interface 286 * 287 * @return string HTML code for the administration interface 288 */ 289 public function getAdminUI($subclass_admin_interface = null, $title = null) { 290 // Define globals 291 global $db; 292 293 // Init values 294 $html = ''; 295 $html .= "<li class='admin_element_item_container'>\n"; 296 $html .= "<fieldset class='admin_element_group'>\n"; 297 $html .= "<legend>" . sprintf(_("%s %d display conditions"), get_class($this), $this->getDisplayOrder()) . "</legend>\n"; 298 299 $allowed_node_rows = null; 300 $html .= "<ul class='admin_element_list'>\n"; 301 /* display_order */ 302 $html .= "<li class='admin_element_item_container'>\n"; 303 $html .= "<div class='admin_element_label'>Display order: </div>\n"; 304 $html .= "<div class='admin_element_data'>\n"; 305 $name = "content_group_element_" . $this->id . "_display_order"; 306 $html .= "<input type='text' name='$name' value='" . $this->getDisplayOrder() . "' size='2'>\n"; 307 $html .= _("(Ignored if display type is random)") . "\n"; 308 $html .= "</div>\n"; 309 $html .= "</li>\n"; 310 311 $html .= "<li class='admin_element_item_container'>\n"; 312 // valid_from_timestamp 313 $html .= "<div class='admin_element_label'>" . _("Only display from") . "</div>\n"; 314 $html .= "<div class='admin_element_data'>\n"; 315 $name = "content_group_element_" . $this->id . "_valid_from"; 316 $html .= DateTime :: getSelectDateTimeUI(new DateTime($this->getValidFromDate()), $name, DateTime :: INTERFACE_DATETIME_FIELD, null); 317 $html .= "</div>\n"; 318 319 // valid_until_timestamp 320 $html .= "<div class='admin_element_label'>until</div>\n"; 321 $html .= "<div class='admin_element_data'>\n"; 322 $name = "content_group_element_" . $this->id . "_valid_until"; 323 $html .= DateTime :: getSelectDateTimeUI(new DateTime($this->getValidUntilDate()), $name, DateTime :: INTERFACE_DATETIME_FIELD, null); 324 $html .= "</div>\n"; 325 326 $html .= _("(Content can be displayed at any date if no start or end date is specified. Warning: If you do not specify a specifig time of day, midnight is assumed.)") . "\n"; 327 $html .= "</li>\n"; 328 329 /* content_group_element_has_allowed_nodes */ 330 $html .= "<li class='admin_element_item_container'>\n"; 331 $html .= "<div class='admin_element_label'>" . _("Only display at node(s):") . "</div>\n"; 332 $html .= "<ul class='admin_element_list'>\n"; 333 334 $sql = "SELECT * FROM content_group_element_has_allowed_nodes WHERE content_group_element_id='$this->id'"; 335 $db->execSql($sql, $allowed_node_rows, false); 336 337 if ($allowed_node_rows != null) { 338 foreach ($allowed_node_rows as $allowed_node_row) { 339 $node = Node :: getObject($allowed_node_row['node_id']); 340 $html .= "<li class='admin_element_item_container'>\n"; 341 $html .= "<div class='admin_element_data'>\n"; 342 $html .= "" . $node->GetId() . ": " . $node->GetName() . ""; 343 $html .= "</div>\n"; 344 $html .= "<div class='admin_element_tools'>\n"; 345 $name = "content_group_element_" . $this->id . "_allowed_node_" . $node->GetId() . "_remove"; 346 $html .= "<input type='submit' name='$name' value='" . _("Remove") . "'>"; 347 $html .= "</div>\n"; 348 $html .= "</li>\n"; 349 } 350 } 351 352 $html .= "<li class='admin_element_item_container'>\n"; 353 354 $sql_additional_where = "AND node_id NOT IN (SELECT node_id FROM content_group_element_has_allowed_nodes WHERE content_group_element_id='$this->id')"; 355 $name = "content_group_element_{$this->id}_new_allowed_node"; 356 $html .= Node :: getSelectNodeUI($name, $sql_additional_where); 357 $name = "content_group_element_{$this->id}_new_allowed_node_submit"; 358 $html .= "<input type='submit' name='$name' value='" . _("Add new allowed node") . "'>"; 359 $html .= "</li'>\n"; 360 $html .= "</ul>\n"; 361 $html .= _("(Content can be displayed at ANY node unless one or more nodes are selected)") . "\n"; 362 363 $html .= "</li>\n"; 364 $html .= "</fieldset>\n"; 365 $html .= "</li>\n"; 366 367 /* displayed_content_id */ 368 $html .= "<li class='admin_element_item_container'>\n"; 369 if (empty ($this->content_group_element_row['displayed_content_id'])) { 370 $html .= "<div class='errormsg'>Sorry, display element is missing.</div>\n"; 371 /* $html .= "<fieldset class='admin_element_group'>\n"; 372 $html .= "<legend>"._("Add a new displayed content OR select an existing one")."</legend>\n"; 373 $html .= self :: getNewContentUI("content_group_element_{$this->id}_new_displayed_content")."<br>"; 374 $html .= self :: getSelectExistingContentUI("content_group_element_{$this->id}_new_displayed_existing_element", "AND content_id != '$this->id'"); 375 $html .= "</fieldset>\n";*/ 376 } else { 377 $displayed_content = self :: getObject($this->content_group_element_row['displayed_content_id']); 378 $html .= $displayed_content->getAdminUI(null, sprintf(_("%s %d displayed content (%s)"), get_class($this), $this->getDisplayOrder(), get_class($displayed_content))); 379 /*$html .= "<div class='admin_element_tools'>\n"; 380 $name = "content_group_element_{$this->id}_erase_displayed_content"; 381 $html .= "<input type='submit' name='$name' value='"._("Delete")."'>"; 382 $html .= "</div>\n";*/ 383 } 384 $html .= "</li>\n"; 385 386 $html .= $subclass_admin_interface; 387 388 return parent :: getAdminUI($html, $title); 389 } 390 391 /** 392 * Processes the input of the administration interface for ContentGroupElement 393 * 394 * @return void 395 */ 396 public function processAdminUI() { 397 // Define globals 398 global $db; 399 400 // Init values 401 $allowed_node_rows = null; 402 $errmsg = null; 403 404 parent :: processAdminUI(); 405 406 /* display_order */ 407 $name = "content_group_element_" . $this->id . "_display_order"; 408 $this->setDisplayOrder($_REQUEST[$name]); 409 410 // valid_from_timestamp 411 $name = "content_group_element_" . $this->id . "_valid_from"; 412 $this->setValidFromDate(DateTime :: processSelectDateTimeUI($name, DateTime :: INTERFACE_DATETIME_FIELD)->getIso8601FormattedString()); 413 414 // valid_until_timestamp 415 416 $name = "content_group_element_" . $this->id . "_valid_until"; 417 $this->setValidUntilDate(DateTime :: processSelectDateTimeUI($name, DateTime :: INTERFACE_DATETIME_FIELD)->getIso8601FormattedString()); 418 419 /* content_group_element_has_allowed_nodes */ 420 $sql = "SELECT * FROM content_group_element_has_allowed_nodes WHERE content_group_element_id='$this->id'"; 421 $db->execSql($sql, $allowed_node_rows, false); 422 423 if ($allowed_node_rows != null) { 424 foreach ($allowed_node_rows as $allowed_node_row) { 425 $node = Node :: getObject($allowed_node_row['node_id']); 426 $name = "content_group_element_" . $this->id . "_allowed_node_" . $node->GetId() . "_remove"; 427 428 if (!empty ($_REQUEST[$name]) && $_REQUEST[$name] == true) { 429 $sql = "DELETE FROM content_group_element_has_allowed_nodes WHERE content_group_element_id='$this->id' AND node_id='" . $node->GetId() . "'"; 430 $db->execSqlUpdate($sql, false); 431 } 432 } 433 } 434 435 $name = "content_group_element_{$this->id}_new_allowed_node_submit"; 436 437 if (!empty ($_REQUEST[$name]) && $_REQUEST[$name] == true) { 438 $name = "content_group_element_{$this->id}_new_allowed_node"; 439 $node = Node :: processSelectNodeUI($name); 440 $node_id = $node->GetId(); 441 $db->execSqlUpdate("INSERT INTO content_group_element_has_allowed_nodes (content_group_element_id, node_id) VALUES ('$this->id', '$node_id')", FALSE); 442 } 443 444 /* displayed_content_id */ 445 if (empty ($this->content_group_element_row['displayed_content_id'])) { 446 // Could be either a new content or existing content ( try both successively ) 447 $displayed_content = Content :: processNewContentUI("content_group_element_{$this->id}_new_displayed_content"); 448 449 if ($displayed_content == null) { 450 $displayed_content = Content :: processNewContentUI("content_group_element_{$this->id}_new_displayed_existing_element", true); 451 } 452 453 if ($displayed_content != null) { 454 $displayed_content_id = $displayed_content->GetId(); 455 $db->execSqlUpdate("UPDATE content_group_element SET displayed_content_id = '$displayed_content_id' WHERE content_group_element_id = '$this->id'", FALSE); 456 } 457 } else { 458 $displayed_content = self :: getObject($this->content_group_element_row['displayed_content_id']); 459 $name = "content_group_element_{$this->id}_erase_displayed_content"; 460 461 if (!empty ($_REQUEST[$name]) && $_REQUEST[$name] == true) { 462 if ($displayed_content->delete($errmsg) != false) { 463 $db->execSqlUpdate("UPDATE content_group_element SET displayed_content_id = NULL WHERE content_group_element_id = '$this->id'", FALSE); 464 } else { 465 echo $errmsg; 466 } 467 } else { 468 $displayed_content->processAdminUI(); 469 } 470 } 471 } 472 473 /** 474 * Retreives the user interface of this object. 475 * 476 * @return string The HTML fragment for this interface 477 */ 478 public function getUserUI($subclass_user_interface = null) { 479 // Init values 480 $html = ''; 481 482 if (!empty ($this->content_group_element_row['displayed_content_id'])) { 483 $displayed_content = self :: getObject($this->content_group_element_row['displayed_content_id']); 484 485 // If the content group logging is disabled, all the children will inherit this property temporarly 486 if ($this->getLoggingStatus() == false) { 487 $displayed_content->setLoggingStatus(false); 488 } 489 490 $displayed_content_html = $displayed_content->getUserUI(); 491 } 492 493 $html .= "<div class='user_ui_container " . get_class($this) . "'>\n"; 494 $html .= $displayed_content_html; 495 $html .= $subclass_user_interface; 496 $html .= "</div>\n"; 497 498 return parent :: getUserUI($html); 499 } 500 501 /** 502 * Returns if this this Content element is displayable at this hotspot 503 * 504 * @param string $node Node Id 505 * 506 * @return bool True if it is displayable 507 */ 508 public function isDisplayableAt($node) { 509 // Define globals 510 global $db; 511 512 // Init values 513 $retval = false; 514 $allowed_node_rows = null; 515 516 $sql = "SELECT * FROM content_group_element_has_allowed_nodes WHERE content_group_element_id='$this->id'"; 517 $db->execSql($sql, $allowed_node_rows, false); 518 519 if ($allowed_node_rows != null) { 520 if ($node) { 521 $node_id = $node->getId(); 522 /** 523 * @todo Proper algorithm, this is a dirty and slow hack 524 */ 525 foreach ($allowed_node_rows as $allowed_node_row) { 526 if ($allowed_node_row['node_id'] == $node_id) { 527 $retval = true; 528 } 529 } 530 } else { 531 /* There are allowed nodes, but we don't know at which node we want to display */ 532 $retval = false; 533 } 534 } else { 535 /* No allowed node means all nodes are allowed */ 536 $retval = true; 537 } 538 539 return $retval; 540 } 541 542 /** 543 * Detects if a user is owner of a ContentGroupElement 544 * 545 * Override the method in Content. 546 * 547 * The owners of the content element are always considered to be the ContentGroup's 548 * 549 * @param object $user User object: the user to be tested. 550 * 551 * @return bool True if the user is a owner, false if he isn't or if the user is null 552 */ 553 public function isOwner($user) { 554 $content_group = Content :: getObject($this->content_group_element_row['content_group_id']); 555 return $content_group->isOwner($user); 556 } 557 558 /** 559 * Deletes a ContentGroupElement object 560 * 561 * @param string $errmsg Reference to error message 562 * 563 * @return bool True if deletion was successful 564 * @internal Persistent content will not be deleted 565 * 566 * @todo Implement proper access control 567 */ 568 public function delete(& $errmsg) { 569 if ($this->isPersistent() == false && !empty ($this->content_group_element_row['displayed_content_id'])) { 570 $displayed_content = self :: getObject($this->content_group_element_row['displayed_content_id']); 571 $displayed_content->delete($errmsg); 572 parent :: delete($errmsg); 573 } 574 } 575 /** Reloads the object from the database. Should normally be called after a set operation */ 576 protected function refresh() { 577 $this->__construct($this->id); 578 } 65 /** 66 67 */ 68 private $content_group_element_row; 69 /** The content object to be displayed by this element */ 70 private $displayed_content; 71 72 /** 73 * Constructor 74 * 75 * @param string $content_id Content Id 76 * 77 * @return void */ 78 protected function __construct($content_id) { 79 80 $db = AbstractDb::getObject(); 81 82 // Init values 83 $row = null; 84 85 parent :: __construct($content_id); 86 $content_id = $db->escapeString($content_id); 87 88 $sql_select = "SELECT * FROM content_group_element WHERE content_group_element_id='$content_id'"; 89 $db->execSqlUniqueRes($sql_select, $row, false); 90 91 if ($row == null) { 92 // The database was corrupted, let's fix it ... 93 $sql = "DELETE FROM content WHERE content_id='$content_id'"; 94 $db->execSqlUpdate($sql, true); 95 } 96 97 $this->content_group_element_row = $row; 98 99 /* A content group element is NEVER persistent */ 100 parent :: setIsPersistent(false); 101 } 102 /** 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 103 * @return true or false */ 104 public function isSimpleContent() { 105 return true; 106 } 107 /** 108 * Replace and delete the old displayed_content (if any) by the new 109 * content (or no content) 110 * 111 * @param object $new_displayed_content Content object or null. If 112 * null the old content is still 113 * deleted. 114 * 115 * @return void 116 117 */ 118 private function replaceDisplayedContent($new_displayed_content) { 119 120 $db = AbstractDb::getObject(); 121 122 // Init values 123 $old_displayed_content = null; 124 $errmsg = null; 125 126 if (!empty ($this->content_group_element_row['displayed_content_id'])) { 127 $old_displayed_content = self :: getObject($this->content_group_element_row['displayed_content_id']); 128 } 129 130 if ($new_displayed_content != null) { 131 $new_displayed_content_id_sql = "'" . $new_displayed_content->GetId() . "'"; 132 } else { 133 $new_displayed_content_id_sql = "NULL"; 134 } 135 136 $db->execSqlUpdate("UPDATE content_group_element SET displayed_content_id = $new_displayed_content_id_sql WHERE content_group_element_id = '$this->id'", FALSE); 137 138 if ($old_displayed_content != null) { 139 $old_displayed_conten->delete($errmsg); 140 } 141 } 142 143 /** 144 * Get the displayed content object 145 * 146 * @return Content object 147 */ 148 public function getDisplayedContent() { 149 if ($this->displayed_content == null) { 150 $this->displayed_content = self :: getObject($this->content_group_element_row['displayed_content_id']); 151 152 } 153 return $this->displayed_content; 154 } 155 /** 156 * Get the order of the element in the content group 157 * 158 * @return string the order of the element in the content group 159 */ 160 public function getDisplayOrder() { 161 return $this->content_group_element_row['display_order']; 162 } 163 164 /** 165 * Set the order of the element in the content group 166 * 167 * @param string $order Order how items should be displayed 168 * 169 * @return void 170 */ 171 public function setDisplayOrder($order) { 172 173 $db = AbstractDb::getObject(); 174 175 if ($order != $this->getDisplayOrder()) { 176 /* 177 * Only update database if there is an actual change 178 */ 179 $order = $db->escapeString($order); 180 $db->execSqlUpdate("UPDATE content_group_element SET display_order = $order WHERE content_group_element_id = '$this->id'", false); 181 } 182 } 183 184 /** 185 * Like the same method as defined in Content, this method will create a 186 * ContentGroupElement based on the content type specified by 187 * getNewContentUI OR get an existing element by getSelectExistingContentUI 188 * 189 * @param string $user_prefix A identifier provided by the programmer to 190 * recognise it's generated form 191 * @param string $content_group Must be present 192 * @param bool $associate_existing_content If set to true, will get an 193 * existing element instead of creating a 194 * new content. 195 * 196 * @return object The ContentGroup object, or null if the user didn't greate one 197 * @static 198 */ 199 public static function processNewContentUI($user_prefix, ContentGroup $content_group, $associate_existing_content = false) { 200 201 $db = AbstractDb::getObject(); 202 203 // Init values 204 $content_group_element_object = null; 205 $max_display_order_row = null; 206 207 if ($associate_existing_content == true) { 208 $name = "{$user_prefix}_add"; 209 } else { 210 $name = "get_new_content_{$user_prefix}_add"; 211 } 212 213 if (!empty ($_REQUEST[$name]) && $_REQUEST[$name] == true) { 214 /* Get the display order to add the GontentGroupElement at the end */ 215 $sql = "SELECT MAX(display_order) as max_display_order FROM content_group_element WHERE content_group_id='" . $content_group->getId() . "'"; 216 $db->execSqlUniqueRes($sql, $max_display_order_row, false); 217 $display_order = $max_display_order_row['max_display_order'] + 1; 218 219 if ($associate_existing_content == true) { 220 $name = "{$user_prefix}"; 221 } else { 222 $name = "get_new_content_{$user_prefix}_content_type"; 223 } 224 225 $content_id = get_guid(); 226 $content_type = 'ContentGroupElement'; 227 $sql = "INSERT INTO content (content_id, content_type) VALUES ('$content_id', '$content_type');"; 228 229 if (!$db->execSqlUpdate($sql, false)) { 230 throw new Exception(_('Unable to insert new content into database!')); 231 } 232 233 $sql = "INSERT INTO content_group_element (content_group_element_id, content_group_id, display_order) VALUES ('$content_id', '" . $content_group->GetId() . "', $display_order);"; 234 235 if (!$db->execSqlUpdate($sql, false)) { 236 throw new Exception(_('Unable to insert new content into database!')); 237 } 238 239 $content_group_element_object = self :: getObject($content_id); 240 241 $content_ui_result = FormSelectGenerator :: getResult($name, null); 242 243 if ($associate_existing_content == true) { 244 $displayed_content_object = self :: getObject($content_ui_result); 245 } else { 246 $displayed_content_object = self :: createNewObject($content_ui_result); 247 } 248 249 $content_group_element_object->replaceDisplayedContent($displayed_content_object); 250 } 251 252 return $content_group_element_object; 253 } 254 /** If set, content will only be displayed from this date on. */ 255 function getValidFromDate() { 256 return $this->content_group_element_row['valid_from_timestamp']; 257 } 258 259 /** If set, content will only be displayed from this date on. 260 * @param string @date Start date. To always display, set to null or an empty string */ 261 function setValidFromDate($date) { 262 263 $db = AbstractDb::getObject(); 264 if ($date != $this->getValidFromDate()) { 265 if (!empty ($date)) { 266 $date = "'" . $db->escapeString($date) . "'"; 267 } else { 268 $date = 'NULL'; 269 } 270 $db->execSqlUpdate("UPDATE content_group_element SET valid_from_timestamp = {$date} WHERE content_group_element_id = '{$this->getId()}'"); 271 $this->refresh(); 272 } 273 } 274 /** If set, content will only be displayed untill this date (and will then be archived). */ 275 function getValidUntilDate() { 276 return $this->content_group_element_row['valid_until_timestamp']; 277 } 278 279 /** If set, content will only be displayed untill this date (and will then be archived). 280 * @param string @date End date. To always display, set to null or an empty string */ 281 function setValidUntilDate($date) { 282 283 $db = AbstractDb::getObject(); 284 if ($date != $this->getValidUntilDate()) { 285 if (!empty ($date)) { 286 $date = "'" . $db->escapeString($date) . "'"; 287 } else { 288 $date = 'NULL'; 289 } 290 $db->execSqlUpdate("UPDATE content_group_element SET valid_until_timestamp = {$date} WHERE content_group_element_id = '{$this->getId()}'"); 291 $this->refresh(); 292 } 293 } 294 295 /** 296 * Shows the administration interface for ContentGroupElement 297 * 298 * @param string $subclass_admin_interface HTML code to be added after the 299 * administration interface 300 * 301 * @return string HTML code for the administration interface 302 */ 303 public function getAdminUI($subclass_admin_interface = null, $title = null) { 304 305 $db = AbstractDb::getObject(); 306 307 // Init values 308 $html = ''; 309 $html .= "<li class='admin_element_item_container'>\n"; 310 $html .= "<fieldset class='admin_element_group'>\n"; 311 $html .= "<legend>" . sprintf(_("%s %d display conditions"), get_class($this), $this->getDisplayOrder()) . "</legend>\n"; 312 313 $allowed_node_rows = null; 314 $html .= "<ul class='admin_element_list'>\n"; 315 /* display_order */ 316 $html .= "<li class='admin_element_item_container'>\n"; 317 $html .= "<div class='admin_element_label'>Display order: </div>\n"; 318 $html .= "<div class='admin_element_data'>\n"; 319 $name = "content_group_element_" . $this->id . "_display_order"; 320 $html .= "<input type='text' name='$name' value='" . $this->getDisplayOrder() . "' size='2'>\n"; 321 $html .= _("(Ignored if display type is random)") . "\n"; 322 $html .= "</div>\n"; 323 $html .= "</li>\n"; 324 325 $html .= "<li class='admin_element_item_container'>\n"; 326 // valid_from_timestamp 327 $html .= "<div class='admin_element_label'>" . _("Only display from") . "</div>\n"; 328 $html .= "<div class='admin_element_data'>\n"; 329 $name = "content_group_element_" . $this->id . "_valid_from"; 330 $html .= DateTime :: getSelectDateTimeUI(new DateTime($this->getValidFromDate()), $name, DateTime :: INTERFACE_DATETIME_FIELD, null); 331 $html .= "</div>\n"; 332 333 // valid_until_timestamp 334 $html .= "<div class='admin_element_label'>until</div>\n"; 335 $html .= "<div class='admin_element_data'>\n"; 336 $name = "content_group_element_" . $this->id . "_valid_until"; 337 $html .= DateTime :: getSelectDateTimeUI(new DateTime($this->getValidUntilDate()), $name, DateTime :: INTERFACE_DATETIME_FIELD, null); 338 $html .= "</div>\n"; 339 340 $html .= _("(Content can be displayed at any date if no start or end date is specified. Warning: If you do not specify a specifig time of day, midnight is assumed.)") . "\n"; 341 $html .= "</li>\n"; 342 343 /* content_group_element_has_allowed_nodes */ 344 $html .= "<li class='admin_element_item_container'>\n"; 345 $html .= "<div class='admin_element_label'>" . _("Only display at node(s):") . "</div>\n"; 346 $html .= "<ul class='admin_element_list'>\n"; 347 348 $sql = "SELECT * FROM content_group_element_has_allowed_nodes WHERE content_group_element_id='$this->id'"; 349 $db->execSql($sql, $allowed_node_rows, false); 350 351 if ($allowed_node_rows != null) { 352 foreach ($allowed_node_rows as $allowed_node_row) { 353 $node = Node :: getObject($allowed_node_row['node_id']); 354 $html .= "<li class='admin_element_item_container'>\n"; 355 $html .= "<div class='admin_element_data'>\n"; 356 $html .= "" . $node->GetId() . ": " . $node->GetName() . ""; 357 $html .= "</div>\n"; 358 $html .= "<div class='admin_element_tools'>\n"; 359 $name = "content_group_element_" . $this->id . "_allowed_node_" . $node->GetId() . "_remove"; 360 $html .= "<input type='submit' name='$name' value='" . _("Remove") . "'>"; 361 $html .= "</div>\n"; 362 $html .= "</li>\n"; 363 } 364 } 365 366 $html .= "<li class='admin_element_item_container'>\n"; 367 368 $sql_additional_where = "AND node_id NOT IN (SELECT node_id FROM content_group_element_has_allowed_nodes WHERE content_group_element_id='$this->id')"; 369 $name = "content_group_element_{$this->id}_new_allowed_node"; 370 $html .= Node :: getSelectNodeUI($name, $sql_additional_where); 371 $name = "content_group_element_{$this->id}_new_allowed_node_submit"; 372 $html .= "<input type='submit' name='$name' value='" . _("Add new allowed node") . "'>"; 373 $html .= "</li'>\n"; 374 $html .= "</ul>\n"; 375 $html .= _("(Content can be displayed at ANY node unless one or more nodes are selected)") . "\n"; 376 377 $html .= "</li>\n"; 378 $html .= "</fieldset>\n"; 379 $html .= "</li>\n"; 380 381 /* displayed_content_id */ 382 $html .= "<li class='admin_element_item_container'>\n"; 383 if (empty ($this->content_group_element_row['displayed_content_id'])) { 384 $html .= "<div class='errormsg'>Sorry, display element is missing.</div>\n"; 385 /* $html .= "<fieldset class='admin_element_group'>\n"; 386 $html .= "<legend>"._("Add a new displayed content OR select an existing one")."</legend>\n"; 387 $html .= self :: getNewContentUI("content_group_element_{$this->id}_new_displayed_content")."<br>"; 388 $html .= self :: getSelectExistingContentUI("content_group_element_{$this->id}_new_displayed_existing_element", "AND content_id != '$this->id'"); 389 $html .= "</fieldset>\n";*/ 390 } else { 391 $displayed_content = self :: getObject($this->content_group_element_row['displayed_content_id']); 392 $html .= $displayed_content->getAdminUI(null, sprintf(_("%s %d displayed content (%s)"), get_class($this), $this->getDisplayOrder(), get_class($displayed_content))); 393 /*$html .= "<div class='admin_element_tools'>\n"; 394 $name = "content_group_element_{$this->id}_erase_displayed_content"; 395 $html .= "<input type='submit' name='$name' value='"._("Delete")."'>"; 396 $html .= "</div>\n";*/ 397 } 398 $html .= "</li>\n"; 399 400 $html .= $subclass_admin_interface; 401 402 return parent :: getAdminUI($html, $title); 403 } 404 405 /** 406 * Processes the input of the administration interface for ContentGroupElement 407 * 408 * @return void 409 */ 410 public function processAdminUI() { 411 412 $db = AbstractDb::getObject(); 413 414 // Init values 415 $allowed_node_rows = null; 416 $errmsg = null; 417 418 parent :: processAdminUI(); 419 420 /* display_order */ 421 $name = "content_group_element_" . $this->id . "_display_order"; 422 $this->setDisplayOrder($_REQUEST[$name]); 423 424 // valid_from_timestamp 425 $name = "content_group_element_" . $this->id . "_valid_from"; 426 $this->setValidFromDate(DateTime :: processSelectDateTimeUI($name, DateTime :: INTERFACE_DATETIME_FIELD)->getIso8601FormattedString()); 427 428 // valid_until_timestamp 429 430 $name = "content_group_element_" . $this->id . "_valid_until"; 431 $this->setValidUntilDate(DateTime :: processSelectDateTimeUI($name, DateTime :: INTERFACE_DATETIME_FIELD)->getIso8601FormattedString()); 432 433 /* content_group_element_has_allowed_nodes */ 434 $sql = "SELECT * FROM content_group_element_has_allowed_nodes WHERE content_group_element_id='$this->id'"; 435 $db->execSql($sql, $allowed_node_rows, false); 436 437 if ($allowed_node_rows != null) { 438 foreach ($allowed_node_rows as $allowed_node_row) { 439 $node = Node :: getObject($allowed_node_row['node_id']); 440 $name = "content_group_element_" . $this->id . "_allowed_node_" . $node->GetId() . "_remove"; 441 442 if (!empty ($_REQUEST[$name]) && $_REQUEST[$name] == true) { 443 $sql = "DELETE FROM content_group_element_has_allowed_nodes WHERE content_group_element_id='$this->id' AND node_id='" . $node->GetId() . "'"; 444 $db->execSqlUpdate($sql, false); 445 } 446 } 447 } 448 449 $name = "content_group_element_{$this->id}_new_allowed_node_submit"; 450 451 if (!empty ($_REQUEST[$name]) && $_REQUEST[$name] == true) { 452 $name = "content_group_element_{$this->id}_new_allowed_node"; 453 $node = Node :: processSelectNodeUI($name); 454 $node_id = $node->GetId(); 455 $db->execSqlUpdate("INSERT INTO content_group_element_has_allowed_nodes (content_group_element_id, node_id) VALUES ('$this->id', '$node_id')", FALSE); 456 } 457 458 /* displayed_content_id */ 459 if (empty ($this->content_group_element_row['displayed_content_id'])) { 460 // Could be either a new content or existing content ( try both successively ) 461 $displayed_content = Content :: processNewContentUI("content_group_element_{$this->id}_new_displayed_content"); 462 463 if ($displayed_content == null) { 464 $displayed_content = Content :: processNewContentUI("content_group_element_{$this->id}_new_displayed_existing_element", true); 465 } 466 467 if ($displayed_content != null) { 468 $displayed_content_id = $displayed_content->GetId(); 469 $db->execSqlUpdate("UPDATE content_group_element SET displayed_content_id = '$displayed_content_id' WHERE content_group_element_id = '$this->id'", FALSE); 470 } 471 } else { 472 $displayed_content = self :: getObject($this->content_group_element_row['displayed_content_id']); 473 $name = "content_group_element_{$this->id}_erase_displayed_content"; 474 475 if (!empty ($_REQUEST[$name]) && $_REQUEST[$name] == true) { 476 if ($displayed_content->delete($errmsg) != false) { 477 $db->execSqlUpdate("UPDATE content_group_element SET displayed_content_id = NULL WHERE content_group_element_id = '$this->id'", FALSE); 478 } else { 479 echo $errmsg; 480 } 481 } else { 482 $displayed_content->processAdminUI(); 483 } 484 } 485 } 486 487 /** This function will be called by MainUI for each Content BEFORE any getUserUI function is called to allow two pass Content display. 488 * Two pass Content display allows such things as modyfying headers, title, creating content type that accumulate content from other pieces (like RSS feeds) 489 * @return null 490 */ 491 public function prepareGetUserUI() { 492 $displayed_content = $this->getDisplayedContent(); 493 $displayed_content->prepareGetUserUI(); 494 return parent :: prepareGetUserUI(); 495 } 496 497 /** 498 * Retreives the user interface of this object. 499 * 500 * @return string The HTML fragment for this interface 501 */ 502 public function getUserUI($subclass_user_interface = null) { 503 // Init values 504 $html = ''; 505 506 if (!empty ($this->content_group_element_row['displayed_content_id'])) { 507 $displayed_content = $this->getDisplayedContent(); 508 509 // If the content group logging is disabled, all the children will inherit this property temporarly 510 if ($this->getLoggingStatus() == false) { 511 $displayed_content->setLoggingStatus(false); 512 } 513 514 $displayed_content_html = $displayed_content->getUserUI(); 515 } 516 517 $html .= "<div class='user_ui_container " . get_class($this) . "'>\n"; 518 $html .= $displayed_content_html; 519 $html .= $subclass_user_interface; 520 $html .= "</div>\n"; 521 522 return parent :: getUserUI($html); 523 } 524 525 /** 526 * Returns if this this Content element is displayable at this hotspot 527 * 528 * @param string $node Node Id 529 * 530 * @return bool True if it is displayable 531 */ 532 public function isDisplayableAt($node) { 533 534 $db = AbstractDb::getObject(); 535 536 // Init values 537 $retval = false; 538 $allowed_node_rows = null; 539 540 $sql = "SELECT * FROM content_group_element_has_allowed_nodes WHERE content_group_element_id='$this->id'"; 541 $db->execSql($sql, $allowed_node_rows, false); 542 543 if ($allowed_node_rows != null) { 544 if ($node) { 545 $node_id = $node->getId(); 546 /** 547 * @todo Proper algorithm, this is a dirty and slow hack 548 */ 549 foreach ($allowed_node_rows as $allowed_node_row) { 550 if ($allowed_node_row['node_id'] == $node_id) { 551 $retval = true; 552 } 553 } 554 } else { 555 /* There are allowed nodes, but we don't know at which node we want to display */ 556 $retval = false; 557 } 558 } else { 559 /* No allowed node means all nodes are allowed */ 560 $retval = true; 561 } 562 563 return $retval; 564 } 565 566 /** 567 * Detects if a user is owner of a ContentGroupElement 568 * 569 * Override the method in Content. 570 * 571 * The owners of the content element are always considered to be the ContentGroup's 572 * 573 * @param object $user User object: the user to be tested. 574 * 575 * @return bool True if the user is a owner, false if he isn't or if the user is null 576 */ 577 public function isOwner($user) { 578 $content_group = Content :: getObject($this->content_group_element_row['content_group_id']); 579 return $content_group->isOwner($user); 580 } 581 582 /** 583 * Deletes a ContentGroupElement object 584 * 585 * @param string $errmsg Reference to error message 586 * 587 * @return bool True if deletion was successful 588 * @internal Persistent content will not be deleted 589 * 590 * @todo Implement proper access control 591 */ 592 public function delete(& $errmsg) { 593 if ($this->isPersistent() == false && !empty ($this->content_group_element_row['displayed_content_id'])) { 594 $displayed_content = self :: getObject($this->content_group_element_row['displayed_content_id']); 595 $displayed_content->delete($errmsg); 596 parent :: delete($errmsg); 597 } 598 } 599 /** Reloads the object from the database. Should normally be called after a set operation */ 600 protected function refresh() { 601 $this->__construct($this->id); 602 } 579 603 } 580 604 -
trunk/wifidog-auth/wifidog/classes/Content/EmbeddedContent/EmbeddedContent.php
r1118 r1127 69 69 protected function __construct($content_id) 70 70 { 71 // Define globals72 global $db;71 72 $db = AbstractDb::getObject(); 73 73 74 74 // Init values … … 244 244 { 245 245 if ($this->isOwner(User :: getCurrentUser()) || User :: getCurrentUser()->isSuperAdmin()) { 246 // Define globals247 global $db;246 247 $db = AbstractDb::getObject(); 248 248 249 249 // Init values -
trunk/wifidog-auth/wifidog/classes/Content/File/File.php
r1123 r1127 89 89 public function __construct($content_id) 90 90 { 91 // Define globals92 global $db;91 92 $db = AbstractDb::getObject(); 93 93 94 94 // Init values -
trunk/wifidog-auth/wifidog/classes/Content/FlickrPhotostream/FlickrPhotostream.php
r1123 r1127 108 108 if (Dependencies::check("Phlickr", $errmsg)) { 109 109 // Defined globals 110 global $db;110 $db = AbstractDb::getObject(); 111 111 112 112 // Load Phlickr classes -
trunk/wifidog-auth/wifidog/classes/Content/HTMLeditor/HTMLeditor.php
r1096 r1127 59 59 class HTMLeditor extends Langstring 60 60 { 61 62 /**63 * HTML allowed to be used64 */65 const ALLOWED_HTML_TAGS = "<p><div><pre><address><h1><h2><h3><h4><h5><h6><br><b><strong><i><em><u><span><ol><ul><li><a><img><embed><table><tbody><thead><th><tr><td><hr>";66 67 61 /** 68 62 * Defines if the FCKeditor library has been installed … … 81 75 { 82 76 parent::__construct($content_id); 77 $this->allowed_html_tags = "<p><div><pre><address><h1><h2><h3><h4><h5><h6><br><b><strong><i><em><u><span><ol><ul><li><a><img><embed><table><tbody><thead><th><tr><td><hr>"; 83 78 84 79 // Check FCKeditor support … … 89 84 } 90 85 } 91 92 /** 93 * Shows the administration interface for HTMLeditor. 94 * 95 * @param string $type_interface SIMPLE for a small HTML editor, LARGE 96 * for a larger HTML editor (default). 97 * @param int $num_nouveau Number of new HTML editors to be created. 98 * 99 * @return string HTML code for the administration interface. 86 /** 87 * Retreives the admin interface of this object. Anything that overrides 88 * this method should call the parent method with it's output at the END of 89 * processing. 90 * @param string $subclass_admin_interface HTML content of the interface 91 * element of a children. 92 * @param string $type_interface SIMPLE pour éditer un seul champ, COMPLETE 93 * pour voir toutes les chaînes, LARGE pour 94 * avoir un textarea. 95 * @return string The HTML fragment for this interface. 100 96 */ 101 public function getAdminUI($ type_interface = 'LARGE')97 public function getAdminUI($subclass_admin_interface = null, $title = null, $type_interface = "LARGE") 102 98 { 103 99 if ($this->_FCKeditorAvailable) { … … 105 101 $_result = null; 106 102 $_html = ''; 103 $_html .= $subclass_admin_interface; 107 104 $_languages = new LocaleList(); 108 105 $_html .= "<ul class='admin_element_list'>\n"; … … 197 194 } 198 195 199 return Content :: getAdminUI($_html );196 return Content :: getAdminUI($_html, $title); 200 197 } 201 198 -
trunk/wifidog-auth/wifidog/classes/Content/IFrame/IFrame.php
r1090 r1127 62 62 public function __construct($content_id) 63 63 { 64 // Define globals65 global $db;64 65 $db = AbstractDb::getObject(); 66 66 67 67 // Init value -
trunk/wifidog-auth/wifidog/classes/Content/Langstring/Langstring.php
r1094 r1127 61 61 */ 62 62 class Langstring extends Content { 63 /** 64 * HTML allowed to be used 65 */ 66 const ALLOWED_HTML_TAGS = "<a><br><b><h1><h2><h3><h4><i><img><li><ol><p><strong><u><ul><li>"; 67 63 protected $allowed_html_tags; 68 64 /** 69 65 * Constructor … … 73 69 public function __construct($content_id) 74 70 { 75 // Define globals76 global $db;77 78 71 parent::__construct($content_id); 72 73 $db = AbstractDb::getObject(); 74 /** 75 * HTML allowed to be used 76 */ 77 $this->allowed_html_tags = "<a><br><b><h1><h2><h3><h4><i><img><li><ol><p><strong><u><ul><li>"; 79 78 $this->mBd = &$db; 80 79 } … … 242 241 243 242 /** 244 * Affiche l'interface d'administration de l'objet 245 * 243 * Retreives the admin interface of this object. Anything that overrides 244 * this method should call the parent method with it's output at the END of 245 * processing. 246 * @param string $subclass_admin_interface HTML content of the interface 247 * element of a children. 246 248 * @param string $type_interface SIMPLE pour éditer un seul champ, COMPLETE 247 249 * pour voir toutes les chaînes, LARGE pour 248 250 * avoir un textarea. 249 * @return string HTML code of administration interface250 */ 251 public function getAdminUI($ type_interface = "LARGE", $title=null)251 * @return string The HTML fragment for this interface. 252 */ 253 public function getAdminUI($subclass_admin_interface = null, $title = null, $type_interface = "LARGE") 252 254 { 253 255 // Init values. 254 256 $html = ''; 257 $html .= $subclass_admin_interface; 255 258 $result = ""; 256 259 //$variantsCounter = 0; 257 260 //$_hideNewContent = false; 258 $html .= "<div class='admin_section_hint'>" . _("Only these HTML tags are allowed : ") . htmlentities(self::ALLOWED_HTML_TAGS) . "</div>"; 261 if(!empty($this->allowed_html_tags)) { 262 $html .= "<div class='admin_section_hint'>" . _("Only these HTML tags are allowed : ") . htmlentities($this->allowed_html_tags) . "</div>"; 263 } 259 264 $html .= "<ul class='admin_element_list'>\n"; 260 265 $liste_languages = new LocaleList(); … … 433 438 // Strip HTML tags ! 434 439 $string = $_REQUEST["langstrings_".$this->id."_substring_$value[langstring_entries_id]_string"]; 435 $string = $this->mBd->escapeString(strip_tags($string, self :: ALLOWED_HTML_TAGS));440 $string = $this->mBd->escapeString(strip_tags($string, $this->allowed_html_tags)); 436 441 437 442 // If PEAR::HTML_Safe is available strips down all potentially dangerous content … … 536 541 $errmsg = _("Content is persistent (you must make it non persistent before you can delete it)"); 537 542 } else { 538 global $db;543 $db = AbstractDb::getObject(); 539 544 540 545 if ($this->isOwner(User :: getCurrentUser()) || User :: getCurrentUser()->isSuperAdmin()) { -
trunk/wifidog-auth/wifidog/classes/Content/PatternLanguage/PatternLanguage.php
r1090 r1127 148 148 public function displayNarrative(User $user) 149 149 { 150 // Define globals151 global $db;150 151 $db = AbstractDb::getObject(); 152 152 153 153 // Init values … … 181 181 public function getNarrativeList() 182 182 { 183 // Define globals184 global $db;183 184 $db = AbstractDb::getObject(); 185 185 186 186 // Init values -
trunk/wifidog-auth/wifidog/classes/Content/Picture/Picture.php
r1090 r1127 68 68 protected function __construct($content_id) 69 69 { 70 // Define globals71 global $db;70 71 $db = AbstractDb::getObject(); 72 72 73 73 // Init values -
trunk/wifidog-auth/wifidog/classes/Content/RssAggregator/RssAggregator.php
r1092 r1127 85 85 * @return void */ 86 86 protected function __construct($content_id) { 87 // Define globals88 global $db;87 88 $db = AbstractDb::getObject(); 89 89 90 90 // Init values … … 168 168 * Only update database if the mode is valid and there is an actual change 169 169 */ 170 global $db;170 $db = AbstractDb::getObject(); 171 171 172 172 $num_items = $db->escapeString($num_items); … … 229 229 * Only update database if the mode is valid and there is an actual change 230 230 */ 231 global $db;231 $db = AbstractDb::getObject(); 232 232 233 233 $strength = $db->escapeString($strength); … … 285 285 * Only update database if the mode is valid and there is an actual change 286 286 */ 287 global $db;287 $db = AbstractDb::getObject(); 288 288 289 289 if ($max_item_age == null) { … … 319 319 */ 320 320 public function addFeed($url) { 321 // Define globals322 global $db;321 322 $db = AbstractDb::getObject(); 323 323 324 324 // Init values … … 344 344 */ 345 345 public function removeFeed($url) { 346 // Define globals347 global $db;346 347 $db = AbstractDb::getObject(); 348 348 349 349 // Init values … … 370 370 */ 371 371 public function getAdminUI($subclass_admin_interface = null, $title = null) { 372 // Define globals373 global $db;372 373 $db = AbstractDb::getObject(); 374 374 375 375 // Init values … … 652 652 */ 653 653 private function processFeedAdminUI($feed_row) { 654 // Define globals655 global $db;654 655 $db = AbstractDb::getObject(); 656 656 657 657 $original_url = $db->escapeString($feed_row['url']); -
trunk/wifidog-auth/wifidog/classes/FormSelectGenerator.php
r1074 r1127 57 57 function __construct() 58 58 { 59 global $db;59 $db = AbstractDb::getObject(); 60 60 $this->mAbstractBd = $db; 61 61 } … … 148 148 static function generateFromTable($table, $primaryKeyField, $displayField, $selectedPrimaryKey, $userPrefix, $objectPrefix, $displayFieldIsLangstring=false, $allowNullValues=false, $nullCaptionString = ' - - - ', $additionalSelectAttribute = null) 149 149 { 150 global $db;150 $db = AbstractDb::getObject(); 151 151 $results = null; 152 152 $db->execSql("SELECT $primaryKeyField, $displayField FROM $table", $results, false); -
trunk/wifidog-auth/wifidog/classes/Locale.php
r1084 r1127 68 68 define('GETTEXT_AVAILABLE', true); 69 69 } 70 70 require_once('classes/Session.php'); 71 71 /** 72 72 * Designates a human language, possibly localized ie fr_CA … … 124 124 125 125 public static function getCurrentLocale() { 126 global $session;126 $session = Session::getObject(); 127 127 global $AVAIL_LOCALE_ARRAY; 128 128 $object = null; … … 216 216 */ 217 217 public static function setCurrentLocale($locale) { 218 global $session;218 $session = Session::getObject(); 219 219 global $AVAIL_LOCALE_ARRAY; 220 220 $retval = false; -
trunk/wifidog-auth/wifidog/classes/LocaleList.php
r1094 r1127 53 53 54 54 function __construct() { 55 global $db;55 $db = AbstractDb::getObject(); 56 56 $this->mBd = & $db; //for backward compatibility 57 57 } … … 132 132 */ 133 133 function GetDefault() { 134 global $session;134 $session = Session::getObject(); 135 135 136 136 if ($user = User :: getCurrentUser()) { -
trunk/wifidog-auth/wifidog/classes/MainUI.php
r1100 r1127 64 64 65 65 /** 66 * S tyle contains functionsmanaging headers, footers, stylesheet, etc.66 * Singleton class for managing headers, footers, stylesheet, etc. 67 67 * 68 68 * @package WiFiDogAuthServer … … 72 72 class MainUI 73 73 { 74 /** holder for the singleton */ 75 private static $object; 74 76 75 77 /** … … 109 111 private $_pageName; 110 112 113 /** list of URLs to stylesheet to be included */ 114 private $stylesheetUrlArray=array(); 115 111 116 /** 112 117 * Headers of HTML page … … 134 139 135 140 private $_shrinkLeftArea = false; 136 141 /** 142 * Get the MainUI object 143 * @return object The MainUI object 144 */ 145 public static function getObject() { 146 if (self::$object==null) 147 { 148 self::$object=new self(); 149 } 150 return self::$object; 151 } 137 152 /** 138 153 * Contructor … … 142 157 * @access public 143 158 */ 144 p ublicfunction __construct()145 { 146 global $db;159 private function __construct() 160 { 161 $db = AbstractDb::getObject(); 147 162 // Init Smarty 148 $this->smarty = new SmartyWifidog();163 $this->smarty = SmartyWifidog::getObject(); 149 164 150 165 // Set default title … … 167 182 * content_available_display_areas table 168 183 * 169 * @param string $content HTML content to be added to the area184 * @param string $content Either a Content object (recommended) or raw HTML content to be added to the area 170 185 * 171 186 * @param integer $display_order_index The order in which the content should … … 198 213 } 199 214 200 /** 215 /** Main processing function do generate the final content. 216 * It will successively call prepareGetUserUI() on all content objects, 217 * and then getUserUI() on all objects. Note that the point of calling 218 * prepareGetUserUI is to allow that function to call methods of MainUI 219 * (such ans changing headers, etc.). However, please note that you should not 220 * call MainUI::addContent() from prepareGetUserUI, as prepareGetUserUI() wouldn't 221 * in turn get called on objects added this way. 201 222 * Orders the content and put it in the _contentDisplayArray array 202 223 * … … 210 231 "_contentArrayCmp" 211 232 )); 233 234 //Fist pass (preparation pass) 212 235 foreach ($this->_contentArray as $content_fragment) 213 236 { 214 $this->_contentDisplayArray[$content_fragment['display_area']] .= $content_fragment['content']; 237 $content=$content_fragment['content']; 238 239 if (is_object($content)) 240 { 241 if ($content instanceof Content) 242 { 243 //echo "<h1>prepareGetUserUI on ".$content->getId()."</h1>"; 244 $content->prepareGetUserUI(); 245 } 246 else 247 { 248 throw new exception ("Object must be a subclass of Content"); 249 } 250 } 251 252 } 253 foreach ($this->_contentArray as $content_fragment) 254 { 255 $content=$content_fragment['content']; 256 if (is_object($content)) 257 { 258 if ($content instanceof Content) 259 { 260 $this->_contentDisplayArray[$content_fragment['display_area']] .= $content->getUserUI(); 261 } 262 else 263 { 264 throw new exception ("Object must be a subclass of Content"); 265 } 266 } 267 else 268 { 269 $this->_contentDisplayArray[$content_fragment['display_area']] .= $content; 270 } 215 271 } 216 272 … … 225 281 private function addEverywhereContent() 226 282 { 227 global $db;283 $db = AbstractDb::getObject(); 228 284 // Get all network content and node "everywhere" content 229 285 $content_rows = null; … … 248 304 if ($content->isDisplayableAt($node)) 249 305 { 250 $this->addContent($content_row['display_area'], $content ->getUserUI(), $content_row['display_order']);306 $this->addContent($content_row['display_area'], $content, $content_row['display_order']); 251 307 } 252 308 } … … 344 400 $this->_htmlHeaders = $headers_string; 345 401 } 346 402 403 /** 404 * Add a stylesheet URL to the main page 405 * 406 * @param string Stylesheet URL 407 * 408 * @return void 409 * 410 * @access public 411 */ 412 public function appendStylesheetURL($stylesheet_url) 413 { 414 //Note: using the URL as value AND key will remove duplicate while keeping the stylesheet inclusion order, because of the way foreach is implemented in PHP 415 $this->stylesheetUrlArray[$stylesheet_url] = $stylesheet_url; 416 } 347 417 /** 348 418 * Set the section to be displayed in the tool pane … … 428 498 private function getToolContent() 429 499 { 430 // Define globals431 global $session;500 501 $session = Session::getObject(); 432 502 global $AVAIL_LOCALE_ARRAY; 433 503 … … 572 642 public function display() 573 643 { 574 575 644 // Init values 576 645 // Asign base CSS and theme pack CSS stylesheet 646 $this->appendStylesheetURL(BASE_THEME_URL . STYLESHEET_NAME); 647 $networkThemePack = Network :: getCurrentNetwork()->getThemePack(); 648 if ($networkThemePack) { 649 $this->appendStylesheetURL($networkThemePack->getStylesheetUrl()); 650 } 651 652 //Handle content (must be done before headers and anything else is handled) 653 /* 654 * Build tool pane if it has been enabled 655 */ 656 if ($this->isToolSectionEnabled()) 657 { 658 $this->addContent('left_area_top', $this->getToolContent()); 659 } 660 $this->addEverywhereContent(); 661 $this->generateDisplayContent(); 662 577 663 // Add SQL queries log 578 664 if(defined("LOG_SQL_QUERIES") && LOG_SQL_QUERIES == true) … … 581 667 // Init ALL smarty values 582 668 $this->smarty->assign('htmlHeaders', ""); 583 $this->smarty->assign('title', "");584 $this->smarty->assign('stylesheetURL', "");585 669 // $this->smarty->assign('isSuperAdmin', false); 586 670 // $this->smarty->assign('isOwner', false); … … 597 681 // Asign CSS class for body 598 682 $this->smarty->assign('page_name', $this->_pageName); 599 600 // Asign path to CSS stylesheets 601 $stylesheetUrlArray[] = BASE_THEME_URL . STYLESHEET_NAME; 602 $networkThemePack = Network :: getCurrentNetwork()->getThemePack(); 603 if ($networkThemePack) 604 { 605 $stylesheetUrlArray[] = $networkThemePack->getStylesheetUrl(); 606 } 607 $this->smarty->assign('stylesheetUrlArray', $stylesheetUrlArray); 683 684 $this->smarty->assign('stylesheetUrlArray', $this->stylesheetUrlArray); 608 685 609 686 /* … … 615 692 User :: assignSmartyValues($this->smarty); 616 693 617 //Handle content618 619 $this->addContent('page_header', $this->customBanner());620 /*621 * Build tool pane if it has been enabled622 */623 if ($this->isToolSectionEnabled())624 {625 $this->addContent('left_area_top', $this->getToolContent());626 }627 $this->addEverywhereContent();628 $this->generateDisplayContent();629 694 // Provide the content array to Smarty 630 695 $this->smarty->assign('contentDisplayArray', $this->_contentDisplayArray); … … 684 749 echo "<html>\n" . "<head><meta http-equiv='Refresh' content='$timeout; URL=$redirect_url'/></head>\n" . "<body>\n" . "<noscript>\n" . "<span style='display:none;'>\n" . "<h1>" . $redirect_to_title . "</h1>\n" . sprintf(_("Click <a href='%s'>here</a> to continue"), $redirect_url) . "<br/>\n" . _("The transfer from secure login back to regular http may cause a warning.") . "\n" . "</span>\n" . "</noscript>\n" . "</body>\n" . "</html>\n"; 685 750 exit; 686 }687 688 public function customBanner()689 {690 $custom_banner = '';691 692 return $custom_banner;693 751 } 694 752 } -
trunk/wifidog-auth/wifidog/classes/Network.php
r1124 r1127 109 109 { 110 110 $retval = array (); 111 global $db;111 $db = AbstractDb::getObject(); 112 112 $sql = "SELECT network_id FROM networks ORDER BY is_default_network DESC"; 113 113 $network_rows = null; … … 135 135 { 136 136 $retval = null; 137 global $db;137 $db = AbstractDb::getObject(); 138 138 $sql = "SELECT network_id FROM networks WHERE is_default_network=TRUE ORDER BY creation_date LIMIT 1"; 139 139 $network_row = null; … … 188 188 public static function createNewObject($network_id = null) 189 189 { 190 global $db;190 $db = AbstractDb::getObject(); 191 191 if (empty ($network_id)) { 192 192 $network_id = get_guid(); … … 231 231 } 232 232 233 global $db;233 $db = AbstractDb::getObject(); 234 234 $additional_where = $db->escapeString($additional_where); 235 235 $sql = "SELECT network_id, name FROM networks WHERE 1=1 $additional_where ORDER BY is_default_network DESC"; … … 329 329 } 330 330 } catch (Exception $e) { 331 $ui = new MainUI();331 $ui = MainUI::getObject(); 332 332 $ui->setToolSection('ADMIN'); 333 333 $ui->displayError($e->getMessage(), false); … … 353 353 private function __construct($p_network_id) 354 354 { 355 // Define globals356 global $db;355 356 $db = AbstractDb::getObject(); 357 357 358 358 $network_id_str = $db->escapeString($p_network_id); … … 406 406 407 407 if ($value != $this->getName()) { 408 global $db;408 $db = AbstractDb::getObject(); 409 409 $value = $db->escapeString($value); 410 410 $retval = $db->execSqlUpdate("UPDATE networks SET tech_support_email = '{$value}' WHERE network_id = '{$this->getId()}'", false); … … 442 442 443 443 if ($value != $this->getName()) { 444 global $db;444 $db = AbstractDb::getObject(); 445 445 $value = $db->escapeString($value); 446 446 $retval = $db->execSqlUpdate("UPDATE networks SET name = '{$value}' WHERE network_id = '{$this->getId()}'", false); … … 482 482 483 483 if ($value != $this->getThemePack()) { 484 global $db;484 $db = AbstractDb::getObject(); 485 485 empty($value)?$value="NULL":$value="'".$db->escapeString($value->getId())."'"; 486 486 $retval = $db->execSqlUpdate("UPDATE networks SET theme_pack = {$value} WHERE network_id = '{$this->getId()}'", false); … … 512 512 public function setCreationDate($value) 513 513 { 514 // Define globals515 global $db;514 515 $db = AbstractDb::getObject(); 516 516 517 517 // Init values … … 554 554 555 555 if ($value != $this->getName()) { 556 global $db;556 $db = AbstractDb::getObject(); 557 557 $value = $db->escapeString($value); 558 558 $retval = $db->execSqlUpdate("UPDATE networks SET homepage_url = '{$value}' WHERE network_id = '{$this->getId()}'", false); … … 585 585 public function setAuthenticatorClassName($value) 586 586 { 587 // Define globals588 global $db;587 588 $db = AbstractDb::getObject(); 589 589 590 590 // Init values … … 621 621 public function setAuthenticatorConstructorParams($value) 622 622 { 623 // Define globals624 global $db;623 624 $db = AbstractDb::getObject(); 625 625 626 626 // init values … … 735 735 public static function getSelectAuthenticator($user_prefix, $pre_selected_authenticator = null) 736 736 { 737 // Define globals738 global $db;737 738 $db = AbstractDb::getObject(); 739 739 740 740 // Init values … … 788 788 789 789 if (!$this->isDefaultNetwork()) { 790 global $db;790 $db = AbstractDb::getObject(); 791 791 $sql = "UPDATE networks SET is_default_network = FALSE;\n"; 792 792 $sql .= "UPDATE networks SET is_default_network = TRUE WHERE network_id = '{$this->getId()}';\n"; … … 828 828 829 829 if ($value != $this->getValidationGraceTime()) { 830 global $db;830 $db = AbstractDb::getObject(); 831 831 $value = $db->escapeString($value); 832 832 $retval = $db->execSqlUpdate("UPDATE networks SET validation_grace_time = '{$value} seconds' WHERE network_id = '{$this->getId()}'", false); … … 864 864 865 865 if ($value != $this->getValidationEmailFromAddress()) { 866 global $db;866 $db = AbstractDb::getObject(); 867 867 $value = $db->escapeString($value); 868 868 $retval = $db->execSqlUpdate("UPDATE networks SET validation_email_from_address = '{$value}' WHERE network_id = '{$this->getId()}'", false); … … 900 900 901 901 if ($value != $this->getMultipleLoginAllowed()) { 902 global $db;902 $db = AbstractDb::getObject(); 903 903 $value ? $value = 'TRUE' : $value = 'FALSE'; 904 904 $retval = $db->execSqlUpdate("UPDATE networks SET allow_multiple_login = {$value} WHERE network_id = '{$this->getId()}'", false); … … 936 936 937 937 if ($value != $this->getSplashOnlyNodesAllowed()) { 938 global $db;938 $db = AbstractDb::getObject(); 939 939 $value ? $value = 'TRUE' : $value = 'FALSE'; 940 940 $retval = $db->execSqlUpdate("UPDATE networks SET allow_splash_only_nodes = {$value} WHERE network_id = '{$this->getId()}'", false); … … 964 964 public function setGisLocation($pt) 965 965 { 966 // Define globals967 global $db;966 967 $db = AbstractDb::getObject(); 968 968 969 969 if (!empty ($pt)) { … … 1002 1002 public function setGisMapType($value) 1003 1003 { 1004 // Define globals1005 global $db;1004 1005 $db = AbstractDb::getObject(); 1006 1006 1007 1007 // Init values … … 1030 1030 public static function getSelectGisMapType($user_prefix, $pre_selected_map_type = "G_NORMAL_MAP") 1031 1031 { 1032 // Define globals1033 global $db;1032 1033 $db = AbstractDb::getObject(); 1034 1034 1035 1035 // Init values … … 1082 1082 public function getNumUsers() 1083 1083 { 1084 // Define globals1085 global $db;1084 1085 $db = AbstractDb::getObject(); 1086 1086 1087 1087 // Init values … … 1130 1130 public function getNumValidUsers() 1131 1131 { 1132 // Define globals1133 global $db;1132 1133 $db = AbstractDb::getObject(); 1134 1134 1135 1135 // Init values … … 1179 1179 public function getNumOnlineUsers() 1180 1180 { 1181 // Define globals1182 global $db;1181 1182 $db = AbstractDb::getObject(); 1183 1183 1184 1184 // Init values … … 1227 1227 public function getNumNodes() 1228 1228 { 1229 // Define globals1230 global $db;1229 1230 $db = AbstractDb::getObject(); 1231 1231 1232 1232 // Init values … … 1275 1275 public function getNumDeployedNodes() 1276 1276 { 1277 // Define globals1278 global $db;1277 1278 $db = AbstractDb::getObject(); 1279 1279 1280 1280 // Init values … … 1325 1325 public function getNumOnlineNodes($nonMonitoredOnly = false) 1326 1326 { 1327 // Define globals1328 global $db;1327 1328 $db = AbstractDb::getObject(); 1329 1329 1330 1330 // Init values … … 1404 1404 1405 1405 if ($value != $this->getCustomPortalRedirectAllowed()) { 1406 global $db;1406 $db = AbstractDb::getObject(); 1407 1407 $value ? $value = 'TRUE' : $value = 'FALSE'; 1408 1408 $retval = $db->execSqlUpdate("UPDATE networks SET allow_custom_portal_redirect = {$value} WHERE network_id = '{$this->getId()}'", false); … … 1422 1422 public function hasAdminAccess(User $user) 1423 1423 { 1424 // Define globals1425 global $db;1424 1425 $db = AbstractDb::getObject(); 1426 1426 1427 1427 // Init values … … 1457 1457 /*public function getAllContent($exclude_subscribed_content = false, $subscriber = null) 1458 1458 { 1459 // Define globals1460 global $db;1459 1460 $db = AbstractDb::getObject(); 1461 1461 1462 1462 // Init values … … 1792 1792 public function addContent(Content $content) 1793 1793 { 1794 // Define globals1795 global $db;1794 1795 $db = AbstractDb::getObject(); 1796 1796 1797 1797 $content_id = $db->escapeString($content->getId()); … … 1811 1811 public function removeContent(Content $content) 1812 1812 { 1813 // Define globals1814 global $db;1813 1814 $db = AbstractDb::getObject(); 1815 1815 1816 1816 $content_id = $db->escapeString($content->getId()); … … 1840 1840 $errmsg = _('Cannot delete default network, create another one and select it before remove this one.'); 1841 1841 } else { 1842 global $db;1842 $db = AbstractDb::getObject(); 1843 1843 $id = $db->escapeString($this->getId()); 1844 1844 if (!$db->execSqlUpdate("DELETE FROM networks WHERE network_id='{$id}'", false)) { -
trunk/wifidog-auth/wifidog/classes/Node.php
r1123 r1127 128 128 public static function getCurrentRealNode() 129 129 { 130 global $db;130 $db = AbstractDb::getObject(); 131 131 $retval = null; 132 132 $sql = "SELECT node_id, last_heartbeat_ip from nodes WHERE last_heartbeat_ip='$_SERVER[REMOTE_ADDR]' ORDER BY last_heartbeat_timestamp DESC"; … … 175 175 $user = User :: getCurrentUser(); 176 176 if ($user->isSuperAdmin()) { 177 global $db;177 $db = AbstractDb::getObject(); 178 178 $id = $db->escapeString($this->getId()); 179 179 if (!$db->execSqlUpdate("DELETE FROM nodes WHERE node_id='{$id}'", false)) … … 210 210 public static function createNewObject($node_id = null, $network = null) 211 211 { 212 // Define globals213 global $db;212 213 $db = AbstractDb::getObject(); 214 214 215 215 if (empty ($node_id)) { … … 250 250 public static function getSelectNodeUI($user_prefix, $sql_additional_where = null,$type_interface = "select") 251 251 { 252 global $db;252 $db = AbstractDb::getObject(); 253 253 $html = ''; 254 254 $name = "{$user_prefix}"; … … 374 374 } 375 375 } catch (Exception $e) { 376 $ui = new MainUI();376 $ui = MainUI::getObject(); 377 377 $ui->setToolSection('ADMIN'); 378 378 $ui->displayError($e->getMessage(), false); … … 397 397 public function getSelectDeploymentStatus($user_prefix) 398 398 { 399 // Define globals400 global $db;399 400 $db = AbstractDb::getObject(); 401 401 402 402 // Init values … … 442 442 private function __construct($node_id) 443 443 { 444 global $db;444 $db = AbstractDb::getObject(); 445 445 $this->mDb = & $db; 446 446 … … 762 762 if ($value != $this->isConfiguredSplashOnly()) 763 763 { 764 global $db;764 $db = AbstractDb::getObject(); 765 765 $value ? $value = 'TRUE' : $value = 'FALSE'; 766 766 $retval = $db->execSqlUpdate("UPDATE nodes SET is_splash_only_node = {$value} WHERE node_id = '{$this->getId()}'", false); … … 786 786 if ($value != $this->getCustomPortalRedirectUrl()) 787 787 { 788 global $db;788 $db = AbstractDb::getObject(); 789 789 $value = $db->escapeString($value); 790 790 $retval = $db->execSqlUpdate("UPDATE nodes SET custom_portal_redirect_url = '{$value}' WHERE node_id = '{$this->getId()}'", false); … … 1273 1273 public function addContent(Content $content) 1274 1274 { 1275 global $db;1275 $db = AbstractDb::getObject(); 1276 1276 $content_id = $db->escapeString($content->getId()); 1277 1277 $sql = "INSERT INTO node_has_content (node_id, content_id) VALUES ('$this->id','$content_id')"; … … 1283 1283 public function removeContent(Content $content) 1284 1284 { 1285 global $db;1285 $db = AbstractDb::getObject(); 1286 1286 $content_id = $db->escapeString($content->getId()); 1287 1287 $sql = "DELETE FROM node_has_content WHERE node_id='$this->id' AND content_id='$content_id'"; … … 1297 1297 /*function getAllContent($exclude_subscribed_content = false, $subscriber = null, $display_page = 'portal') 1298 1298 { 1299 global $db;1299 $db = AbstractDb::getObject(); 1300 1300 $retval = array (); 1301 1301 $content_rows = null; … … 1321 1321 function getAllLocativeArtisticContent() 1322 1322 { 1323 global $db;1323 $db = AbstractDb::getObject(); 1324 1324 $retval = array (); 1325 1325 $sql = "SELECT * FROM content_group JOIN content ON (content.content_id = content_group.content_group_id) JOIN node_has_content ON (node_has_content.content_id = content_group.content_group_id AND node_has_content.node_id = '{$this->getId()}') WHERE is_persistent = true AND is_artistic_content = true AND is_locative_content = true ORDER BY subscribe_timestamp DESC"; … … 1356 1356 public function getOnlineUsers() 1357 1357 { 1358 // Define globals1359 global $db;1358 1359 $db = AbstractDb::getObject(); 1360 1360 1361 1361 // Init values … … 1384 1384 public function getNumOnlineUsers() 1385 1385 { 1386 // Define globals1387 global $db;1386 1387 $db = AbstractDb::getObject(); 1388 1388 1389 1389 // Init values … … 1404 1404 function getOwners() 1405 1405 { 1406 global $db;1406 $db = AbstractDb::getObject(); 1407 1407 $retval = array (); 1408 1408 $owners = null; … … 1424 1424 function getTechnicalOfficers() 1425 1425 { 1426 global $db;1426 $db = AbstractDb::getObject(); 1427 1427 $retval = array (); 1428 1428 $officers = null; … … 1443 1443 function addOwner(User $user) 1444 1444 { 1445 global $db;1445 $db = AbstractDb::getObject(); 1446 1446 $rows = null; 1447 1447 $db->execSql("SELECT * FROM node_stakeholders WHERE node_id = '{$this->getId()}' AND user_id = '{$user->getId()}'", $rows, false); … … 1461 1461 function addTechnicalOfficer(User $user) 1462 1462 { 1463 global $db;1463 $db = AbstractDb::getObject(); 1464 1464 $rows = null; 1465 1465 $db->execSql("SELECT * FROM node_stakeholders WHERE node_id = '{$this->getId()}' AND user_id = '{$user->getId()}'", $rows, false); … … 1479 1479 function removeOwner(User $user) 1480 1480 { 1481 global $db;1481 $db = AbstractDb::getObject(); 1482 1482 if (!$db->execSqlUpdate("UPDATE node_stakeholders SET is_owner = false WHERE node_id = '{$this->getId()}' AND user_id = '{$user->getId()}';", false)) 1483 1483 throw new Exception(_('Could not remove owner')); … … 1489 1489 function removeTechnicalOfficer(User $user) 1490 1490 { 1491 global $db;1491 $db = AbstractDb::getObject(); 1492 1492 if (!$db->execSqlUpdate("UPDATE node_stakeholders SET is_tech_officer = false WHERE node_id = '{$this->getId()}' AND user_id = '{$user->getId()}';", false)) 1493 1493 throw new Exception(_('Could not remove tech officer')); … … 1498 1498 function isOwner(User $user) 1499 1499 { 1500 global $db;1500 $db = AbstractDb::getObject(); 1501 1501 if ($user != null) 1502 1502 { … … 1517 1517 function isTechnicalOfficer(User $user) 1518 1518 { 1519 global $db;1519 $db = AbstractDb::getObject(); 1520 1520 if ($user != null) 1521 1521 { … … 1544 1544 private static function nodeExists($id) 1545 1545 { 1546 // Define globals1547 global $db;1546 1547 $db = AbstractDb::getObject(); 1548 1548 1549 1549 // Init values -
trunk/wifidog-auth/wifidog/classes/NodeLists/NodeListHTML.php
r1123 r1127 109 109 public function __construct(&$network) 110 110 { 111 // Define globals112 global $db;113 global $smarty;111 112 $db = AbstractDb::getObject(); 113 $smarty = SmartyWifidog::getObject(); 114 114 115 115 // Init Smarty … … 123 123 124 124 // Init MainUI class 125 $this->_mainUI = new MainUI();125 $this->_mainUI = MainUI::getObject(); 126 126 127 127 // Query the database, sorting by node name -
trunk/wifidog-auth/wifidog/classes/NodeLists/NodeListJiWireCSV.php
r1123 r1127 87 87 public function __construct(&$network) 88 88 { 89 // Define globals90 global $db;89 90 $db = AbstractDb::getObject(); 91 91 92 92 // Init network -
trunk/wifidog-auth/wifidog/classes/NodeLists/NodeListKML.php
r1123 r1127 92 92 public function __construct(&$network) 93 93 { 94 // Define globals95 global $db;94 95 $db = AbstractDb::getObject(); 96 96 97 97 // Init XML Document -
trunk/wifidog-auth/wifidog/classes/NodeLists/NodeListPDF.php
r1123 r1127 787 787 } 788 788 } else { 789 $ui = new MainUI();789 $ui = MainUI::getObject(); 790 790 791 791 $errmsg = _("To protect the server the PDF file has not been created, because the server is too busy right now!"); … … 795 795 } 796 796 } else { 797 $ui = new MainUI();797 $ui = MainUI::getObject(); 798 798 799 799 $errmsg = _("PDF file cannot be created because the FPDF library is not installed!"); … … 892 892 public function __construct(&$network) 893 893 { 894 // Define globals895 global $db;894 895 $db = AbstractDb::getObject(); 896 896 897 897 // Init network -
trunk/wifidog-auth/wifidog/classes/NodeLists/NodeListRSS.php
r1123 r1127 91 91 public function __construct(&$network) 92 92 { 93 // Define globals94 global $db;93 94 $db = AbstractDb::getObject(); 95 95 96 96 // Init XML Document … … 135 135 public function getOutput($return_object = false) 136 136 { 137 // Define globals138 global $db;137 138 $db = AbstractDb::getObject(); 139 139 140 140 // Root node -
trunk/wifidog-auth/wifidog/classes/NodeLists/NodeListXML.php
r1123 r1127 90 90 public function __construct(&$network) 91 91 { 92 // Define globals93 global $db;92 93 $db = AbstractDb::getObject(); 94 94 95 95 // Init XML Document -
trunk/wifidog-auth/wifidog/classes/Server.php
r1096 r1127 82 82 private function __construct($p_server_id) 83 83 { 84 // Define globals85 global $db;84 85 $db = AbstractDb::getObject(); 86 86 87 87 // Init values … … 137 137 public static function getAllServers() 138 138 { 139 // Define globals140 global $db;139 140 $db = AbstractDb::getObject(); 141 141 142 142 // Init values … … 169 169 public static function getDefaultServer($silent=false) 170 170 { 171 // Define globals172 global $db;171 172 $db = AbstractDb::getObject(); 173 173 174 174 // Init values … … 211 211 return null; //We were probably called from the command line 212 212 } 213 // Define globals214 global $db;213 214 $db = AbstractDb::getObject(); 215 215 216 216 // Init values … … 245 245 public static function createNewObject($server_id = null) 246 246 { 247 // Define globals248 global $db;247 248 $db = AbstractDb::getObject(); 249 249 250 250 if (empty($server_id)) { … … 284 284 public static function getSelectServerUI($user_prefix, $pre_selected_server = null, $additional_where = null) 285 285 { 286 // Define globals287 global $db;286 287 $db = AbstractDb::getObject(); 288 288 289 289 // Init values … … 428 428 public function setName($value) 429 429 { 430 // Define globals431 global $db;430 431 $db = AbstractDb::getObject(); 432 432 433 433 // Init values … … 464 464 public function setCreationDate($value) 465 465 { 466 // Define globals467 global $db;466 467 $db = AbstractDb::getObject(); 468 468 469 469 // Init values … … 498 498 public function setHostname($value) 499 499 { 500 // Define globals501 global $db;500 501 $db = AbstractDb::getObject(); 502 502 503 503 // Init values … … 540 540 public function setAsDefaultServer() 541 541 { 542 // Define globals543 global $db;542 543 $db = AbstractDb::getObject(); 544 544 545 545 // Init values … … 582 582 public function setSSLAvailable($value) 583 583 { 584 // Define globals585 global $db;584 585 $db = AbstractDb::getObject(); 586 586 587 587 // Init values … … 621 621 public function setGoogleAPIKey($value) 622 622 { 623 // Define globals624 global $db;623 624 $db = AbstractDb::getObject(); 625 625 626 626 // Init values … … 755 755 } 756 756 } catch (Exception $e) { 757 $ui = new MainUI();757 $ui = MainUI::getObject(); 758 758 $ui->setToolSection('ADMIN'); 759 759 $ui->displayError($e->getMessage(), false); … … 804 804 { 805 805 require_once('classes/User.php'); 806 // Define globals807 global $db;806 807 $db = AbstractDb::getObject(); 808 808 809 809 // Init values -
trunk/wifidog-auth/wifidog/classes/Session.php
r1090 r1127 51 51 class Session 52 52 { 53 53 private static $object; 54 public static function getObject() { 55 if (self::$object==null) 56 { 57 self::$object=new self(); 58 } 59 return self::$object; 60 } 54 61 /** 55 62 * Constructor … … 57 64 * @return void 58 65 */ 59 p ublicfunction __construct()66 private function __construct() 60 67 { 61 68 $session_id = session_id(); -
trunk/wifidog-auth/wifidog/classes/SmartyWifidog.php
r1090 r1127 123 123 */ 124 124 class SmartyWifidog extends Smarty { 125 126 function __construct() 125 private static $object; 126 public static function getObject() { 127 if (self::$object==null) 128 { 129 self::$object=new self(); 130 } 131 return self::$object; 132 } 133 private function __construct() 127 134 { 128 135 … … 130 137 131 138 $this->Smarty(); 132 133 $this->template_dir = WIFIDOG_ABS_FILE_PATH; 139 //Now that we have user-definable templates, we must turn on security 140 $this->security = true; 141 //pretty_print_r($this->security_settings); 142 $this->security_settings['MODIFIER_FUNCS'][] = 'sprintf'; 143 $this->template_dir = WIFIDOG_ABS_FILE_PATH; 134 144 $this->compile_dir = $this->template_dir . 'tmp/smarty/templates_c/'; 135 145 $this->config_dir = $this->template_dir . 'tmp/smarty/configs/'; -
trunk/wifidog-auth/wifidog/classes/StatisticGraph.php
r1075 r1127 93 93 protected function __construct() 94 94 { 95 $session = new Session();95 $session = Session::getObject(); 96 96 self :: $stats = $session->get('current_statistics_object'); 97 97 } … … 106 106 public function getReportUI(Statistics $statistics_object, $child_html = null) 107 107 { 108 $session = new Session();108 $session = Session::getObject(); 109 109 $session->set('current_statistics_object', $statistics_object); 110 110 self :: $stats = $statistics_object; /* Update it in case someone whants to use it right now */ -
trunk/wifidog-auth/wifidog/classes/StatisticGraph/ConnectionsPerHour.php
r1013 r1127 77 77 { 78 78 require_once ("Image/Graph.php"); 79 global $db;79 $db = AbstractDb::getObject(); 80 80 81 81 $Graph =& Image_Graph::factory("Image_Graph", array(600, 200)); -
trunk/wifidog-auth/wifidog/classes/StatisticGraph/RegistrationsCumulative.php
r1013 r1127 77 77 { 78 78 require_once ("Image/Graph.php"); 79 global $db;79 $db = AbstractDb::getObject(); 80 80 81 81 $Graph = & Image_Graph :: factory("Image_Graph", array (600, 200)); -
trunk/wifidog-auth/wifidog/classes/StatisticGraph/RegistrationsPerMonth.php
r1013 r1127 77 77 { 78 78 require_once ("Image/Graph.php"); 79 global $db;79 $db = AbstractDb::getObject(); 80 80 81 81 $Graph = & Image_Graph :: factory("Image_Graph", array (600, 200)); -
trunk/wifidog-auth/wifidog/classes/StatisticGraph/VisitsPerMonth.php
r1013 r1127 92 92 { 93 93 require_once ("Image/Graph.php"); 94 global $db;94 $db = AbstractDb::getObject(); 95 95 $Graph =& Image_Graph::factory("Image_Graph", array(600, 200)); 96 96 $Plotarea =& $Graph->add(Image_Graph::factory("Image_Graph_Plotarea")); -
trunk/wifidog-auth/wifidog/classes/StatisticGraph/VisitsPerWeekday.php
r1013 r1127 92 92 { 93 93 require_once ("Image/Graph.php"); 94 global $db;94 $db = AbstractDb::getObject(); 95 95 96 96 $Graph = & Image_Graph :: factory("Image_Graph", array (600, 200)); -
trunk/wifidog-auth/wifidog/classes/StatisticReport/ConnectionGraphs.php
r1031 r1127 78 78 public function getReportUI($child_html = null) 79 79 { 80 global $db;80 $db = AbstractDb::getObject(); 81 81 $html = ''; 82 82 -
trunk/wifidog-auth/wifidog/classes/StatisticReport/ConnectionLog.php
r1037 r1127 80 80 public function getReportUI($child_html = null) 81 81 { 82 global $db;82 $db = AbstractDb::getObject(); 83 83 $html = ''; 84 84 -
trunk/wifidog-auth/wifidog/classes/StatisticReport/HighestBandwidthUsers.php
r1013 r1127 81 81 public function getReportUI($child_html = null) 82 82 { 83 global $db;83 $db = AbstractDb::getObject(); 84 84 $html = ''; 85 85 $distinguish_users_by = $this->stats->getDistinguishUsersBy(); -
trunk/wifidog-auth/wifidog/classes/StatisticReport/MostFrequentUsers.php
r1013 r1127 82 82 public function getReportUI($child_html = null) 83 83 { 84 global $db;84 $db = AbstractDb::getObject(); 85 85 $html = ''; 86 86 $distinguish_users_by = $this->stats->getDistinguishUsersBy(); -
trunk/wifidog-auth/wifidog/classes/StatisticReport/MostMobileUsers.php
r1013 r1127 81 81 public function getReportUI($child_html = null) 82 82 { 83 global $db;83 $db = AbstractDb::getObject(); 84 84 $html = ''; 85 85 $distinguish_users_by = $this->stats->getDistinguishUsersBy(); -
trunk/wifidog-auth/wifidog/classes/StatisticReport/MostPopularNodes.php
r1013 r1127 81 81 public function getReportUI($child_html = null) 82 82 { 83 global $db;83 $db = AbstractDb::getObject(); 84 84 $html = ''; 85 85 $node_usage_stats = null; -
trunk/wifidog-auth/wifidog/classes/StatisticReport/NetworkStatus.php
r1037 r1127 80 80 public function getReportUI($child_html = null) 81 81 { 82 global $db;82 $db = AbstractDb::getObject(); 83 83 $html = ''; 84 84 $selected_network = $this->stats->getSelectedNetworks(); -
trunk/wifidog-auth/wifidog/classes/StatisticReport/NodeStatus.php
r1123 r1127 80 80 public function getReportUI($child_html = null) 81 81 { 82 global $db;82 $db = AbstractDb::getObject(); 83 83 $html = ''; 84 84 $selected_nodes = $this->stats->getSelectedNodes(); -
trunk/wifidog-auth/wifidog/classes/StatisticReport/RegistrationLog.php
r1075 r1127 80 80 public function getReportUI($child_html = null) 81 81 { 82 global $db;82 $db = AbstractDb::getObject(); 83 83 $html = ''; 84 84 /* Users who signed up here */ -
trunk/wifidog-auth/wifidog/classes/StatisticReport/UserRegistrationReport.php
r1075 r1127 78 78 public function getReportUI($child_html = null) 79 79 { 80 global $db;80 $db = AbstractDb::getObject(); 81 81 $html = ''; 82 82 /* Monthly registration graph */ -
trunk/wifidog-auth/wifidog/classes/StatisticReport/UserReport.php
r1114 r1127 80 80 public function getReportUI($child_html = null) 81 81 { 82 // Define globals83 global $db;82 83 $db = AbstractDb::getObject(); 84 84 global $account_status_to_text; 85 85 global $token_to_text; -
trunk/wifidog-auth/wifidog/classes/Statistics.php
r1124 r1127 216 216 public function getSqlDateConstraint($column = 'timestamp_in') 217 217 { 218 global $db;218 $db = AbstractDb::getObject(); 219 219 $column = $db->escapeString($column); 220 220 $sql = ''; … … 239 239 public function getSqlNodeConstraint($column) 240 240 { 241 global $db;241 $db = AbstractDb::getObject(); 242 242 $column = $db->escapeString($column); 243 243 $sql = ''; … … 265 265 public function getSqlNetworkConstraint($column) 266 266 { 267 global $db;267 $db = AbstractDb::getObject(); 268 268 $column = $db->escapeString($column); 269 269 $sql = ''; … … 291 291 public function getSqlUserConstraint() 292 292 { 293 global $db;293 $db = AbstractDb::getObject(); 294 294 $column = $db->escapeString($this->report_distinguish_users_by); 295 295 $sql = ''; … … 381 381 private function getSelectedNodesUI() 382 382 { 383 // Define globals384 global $db;383 384 $db = AbstractDb::getObject(); 385 385 386 386 // Init values … … 547 547 if ($this->report_distinguish_users_by == 'user_id') 548 548 { 549 global $db;549 $db = AbstractDb::getObject(); 550 550 $username = $db->escapeString($_REQUEST['stats_selected_users']); 551 551 $row = null; -
trunk/wifidog-auth/wifidog/classes/User.php
r1123 r1127 98 98 public static function getCurrentUser() { 99 99 require_once ('classes/Session.php'); 100 $session = new Session();100 $session = Session::getObject(); 101 101 $user = null; 102 102 try { … … 122 122 public static function setCurrentUser(User $user) { 123 123 try { 124 $session = new Session();124 $session = Session::getObject(); 125 125 $session->set(SESS_USER_ID_VAR, $user->getId()); 126 126 $session->set(SESS_PASSWORD_HASH_VAR, $user->getPasswordHash()); … … 147 147 */ 148 148 public static function getUserByUsernameAndOrigin($username, Network $account_origin) { 149 global $db;149 $db = AbstractDb::getObject(); 150 150 $object = null; 151 151 … … 165 165 */ 166 166 public static function getUserByEmailAndOrigin($email, Network $account_origin) { 167 global $db;167 $db = AbstractDb::getObject(); 168 168 $object = null; 169 169 … … 194 194 */ 195 195 static function createUser($id, $username, Network $account_origin, $email, $password) { 196 global $db;196 $db = AbstractDb::getObject(); 197 197 198 198 $object = null; … … 214 214 /* public static function purgeUnvalidatedUsers($days_since_creation) 215 215 { 216 global $db;216 $db = AbstractDb::getObject(); 217 217 $days_since_creation = $db->escapeString($days_since_creation); 218 218 … … 222 222 /** @param $object_id The id of the user */ 223 223 function __construct($object_id) { 224 global $db;224 $db = AbstractDb::getObject(); 225 225 $this->mDb = & $db; 226 226 $object_id_str = $db->escapeString($object_id); … … 282 282 $retval = true; 283 283 if ($value != $this->getUsername()) { 284 global $db;284 $db = AbstractDb::getObject(); 285 285 $value = $db->escapeString($value); 286 286 $retval = @ $db->execSqlUpdate("UPDATE users SET username = '{$value}' WHERE user_id='{$this->id}'", false); … … 308 308 $retval = true; 309 309 if ($value != $this->isAdvertised()) { 310 global $db;310 $db = AbstractDb::getObject(); 311 311 $value ? $value = 'TRUE' : $value = 'FALSE'; 312 312 $retval = $db->execSqlUpdate("UPDATE users SET is_invisible = {$value} WHERE user_id = '{$this->getId()}'", false); … … 322 322 /**What locale (language) does the user prefer? */ 323 323 public function getPreferedLocale() { 324 global $session;324 $session = Session::getObject(); 325 325 $locale = $this->mRow['prefered_locale']; 326 326 if (empty ($locale) && !empty ($session)) … … 352 352 353 353 function setAccountStatus($status) { 354 global $db;354 $db = AbstractDb::getObject(); 355 355 356 356 $status_str = $db->escapeString($status); … … 364 364 $errmsg: Returs the reason why the account is or isn't valid */ 365 365 function isUserValid(& $errmsg = null) { 366 global $db;366 $db = AbstractDb::getObject(); 367 367 $retval = false; 368 368 $account_status = $this->getAccountStatus(); … … 389 389 390 390 public function isSuperAdmin() { 391 global $db;391 $db = AbstractDb::getObject(); 392 392 //$this->session->dump(); 393 393 … … 405 405 */ 406 406 public function isOwner() { 407 global $db;407 $db = AbstractDb::getObject(); 408 408 $db->execSql("SELECT * FROM node_stakeholders WHERE is_owner = true AND user_id='{$this->getId()}'", $row, false); 409 409 if ($row != null) … … 414 414 415 415 public function isNobody() { 416 global $db;416 $db = AbstractDb::getObject(); 417 417 $db->execSqlUniqueRes("SELECT DISTINCT user_id FROM (SELECT user_id FROM network_stakeholders WHERE user_id='{$this->getId()}' UNION SELECT user_id FROM node_stakeholders WHERE user_id='{$this->getId()}' UNION SELECT user_id FROM administrators WHERE user_id='{$this->getId()}') as tmp", $row, false); 418 418 if ($row == null) … … 439 439 function generateConnectionToken() { 440 440 if ($this->isUserValid()) { 441 global $db;442 global $session;441 $db = AbstractDb::getObject(); 442 $session = Session::getObject(); 443 443 444 444 $token = self :: generateToken(); … … 460 460 461 461 function setPassword($password) { 462 global $db;462 $db = AbstractDb::getObject(); 463 463 464 464 $new_password_hash = User :: passwordHash($password); … … 476 476 */ 477 477 static function getAllUsers() { 478 global $db;478 $db = AbstractDb::getObject(); 479 479 480 480 $db->execSql("SELECT * FROM users", $objects, false); … … 532 532 533 533 static function userExists($id) { 534 global $db;534 $db = AbstractDb::getObject(); 535 535 $id_str = $db->escapeString($id); 536 536 $sql = "SELECT * FROM users WHERE user_id='{$id_str}'"; … … 540 540 541 541 public static function emailExists($id) { 542 global $db;542 $db = AbstractDb::getObject(); 543 543 $id_str = $db->escapeString($id); 544 544 $sql = "SELECT * FROM users WHERE email='{$id_str}'"; … … 613 613 */ 614 614 public static function getSelectUserUI($user_prefix, $add_button_name = null, $add_button_value = null) { 615 // Define globals616 global $db;615 616 $db = AbstractDb::getObject(); 617 617 618 618 $_networkSelector = InterfaceElements :: generateDiv(Network :: getSelectNetworkUI($user_prefix), "admin_section_network_selector", "admin_section_network_selector_" . $user_prefix); … … 652 652 653 653 public function getAdminUI() { 654 global $db;654 $db = AbstractDb::getObject(); 655 655 $currentUser = self :: getCurrentUser(); 656 656 $html = ''; … … 690 690 691 691 public function processAdminUI() { 692 global $db;692 $db = AbstractDb::getObject(); 693 693 $currentUser = self :: getCurrentUser(); 694 694 if ($this == $currentUser || $this->getNetwork()->hasAdminAccess($currentUser)) { … … 711 711 /** Add content to this user ( subscription ) */ 712 712 public function addContent(Content $content) { 713 global $db;713 $db = AbstractDb::getObject(); 714 714 $content_id = $db->escapeString($content->getId()); 715 715 $sql = "INSERT INTO user_has_content (user_id, content_id) VALUES ('$this->id','$content_id')"; … … 720 720 /** Remove content from this node */ 721 721 public function removeContent(Content $content) { 722 global $db;722 $db = AbstractDb::getObject(); 723 723 $content_id = $db->escapeString($content->getId()); 724 724 $sql = "DELETE FROM user_has_content WHERE user_id='$this->id' AND content_id='$content_id'"; … … 730 730 * @return an array of Content or an empty arrray */ 731 731 function getAllContent() { 732 global $db;732 $db = AbstractDb::getObject(); 733 733 $retval = array (); 734 734 $sql = "SELECT * FROM user_has_content WHERE user_id='$this->id' ORDER BY subscribe_timestamp"; -
trunk/wifidog-auth/wifidog/clickthrough.php
r1080 r1127 48 48 require_once (dirname(__FILE__) . '/include/common.php'); 49 49 50 global $db;50 $db = AbstractDb::getObject(); 51 51 if (!empty ($_REQUEST['destination_url'])) { 52 52 -
trunk/wifidog-auth/wifidog/content/PatternLanguage/archives.php
r1031 r1127 51 51 require_once('classes/Content/PatternLanguage.php'); 52 52 require_once('classes/MainUI.php'); 53 53 $smarty = SmartyWifidog::getObject(); 54 $session = Session::getObject(); 54 55 // This trick is done to allow displaying of Pattern Language right away if there is only one available. 55 56 if(!empty($_REQUEST['content_id'])) … … 97 98 $body_html .= "</div>\n"; 98 99 99 $ui = new MainUI();100 $ui = MainUI::getObject(); 100 101 $ui->addContent('left_area_middle', $tool_html); 101 102 $ui->setTitle(_("Pattern Language - Archives")); -
trunk/wifidog-auth/wifidog/content/PatternLanguage/hotspots.php
r1031 r1127 50 50 require_once('classes/MainUI.php'); 51 51 require_once('classes/Content/PatternLanguage.php'); 52 52 $smarty = SmartyWifidog::getObject(); 53 $session = Session::getObject(); 53 54 // This trick is done to allow displaying of Pattern Language right away if there is only one available. 54 55 if(!empty($_REQUEST['content_id'])) … … 102 103 $body_html .= "</div>\n"; 103 104 104 $ui= new MainUI();105 $ui=MainUI::getObject(); 105 106 $ui->addContent('left_area_middle', $tool_html); 106 107 $ui->setTitle(_("Pattern Language - Hotspots list")); -
trunk/wifidog-auth/wifidog/content/PatternLanguage/index.php
r1031 r1127 50 50 require_once('classes/MainUI.php'); 51 51 require_once('classes/Content/PatternLanguage.php'); 52 52 $smarty = SmartyWifidog::getObject(); 53 $session = Session::getObject(); 53 54 // This trick is done to allow displaying of Pattern Language right away if there is only one available. 54 55 if(!empty($_REQUEST['content_id'])) … … 92 93 93 94 94 $ui= new MainUI();95 $ui=MainUI::getObject(); 95 96 $ui->addContent('left_area_middle', $tool_html); 96 97 $ui->setTitle(_("Pattern Language - About")); -
trunk/wifidog-auth/wifidog/content/PatternLanguage/narrative.php
r1031 r1127 51 51 require_once('classes/Content/PatternLanguage.php'); 52 52 require_once('classes/MainUI.php'); 53 53 $smarty = SmartyWifidog::getObject(); 54 $session = Session::getObject(); 54 55 // This trick is done to allow displaying of Pattern Language right away if there is only one available. 55 56 if(!empty($_REQUEST['content_id'])) … … 113 114 } 114 115 115 $ui = new MainUI();116 $ui = MainUI::getObject(); 116 117 $ui->addContent('left_area_middle', $tool_html); 117 118 $ui->setTitle(_("Pattern Language - Narrative")); -
trunk/wifidog-auth/wifidog/content/PatternLanguage/subscription.php
r1031 r1127 51 51 require_once('classes/Content/PatternLanguage.php'); 52 52 require_once('classes/MainUI.php'); 53 53 $smarty = SmartyWifidog::getObject(); 54 $session = Session::getObject(); 54 55 // This trick is done to allow displaying of Pattern Language right away if there is only one available. 55 56 if(!empty($_REQUEST['content_id'])) … … 141 142 $body_html .= "</div>\n"; 142 143 143 $ui = new MainUI();144 $ui = MainUI::getObject(); 144 145 $ui->addContent('left_area_middle', $tool_html); 145 146 $ui->setTitle(_("Pattern Language - Subscription")); -
trunk/wifidog-auth/wifidog/content/index.php
r1092 r1127 51 51 require_once('classes/MainUI.php'); 52 52 require_once('include/common_interface.php'); 53 $smarty = SmartyWifidog::getObject(); 53 54 require_once('classes/Node.php'); 54 55 … … 58 59 59 60 if ($node == null) { 60 $ui = new MainUI();61 $ui = MainUI::getObject(); 61 62 $ui->displayError(_("No Hotspot specified!")); 62 63 exit; … … 67 68 Node :: setCurrentNode($node); 68 69 69 $ui = new MainUI(); 70 if (isset ($session)) 71 { 72 $smarty->assign("original_url_requested", $session->get(SESS_ORIGINAL_URL_VAR)); 73 } 70 $ui = MainUI::getObject(); 71 $session = Session::getObject(); 72 $smarty->assign("original_url_requested", $session->get(SESS_ORIGINAL_URL_VAR)); 74 73 75 74 $tool_html = ''; -
trunk/wifidog-auth/wifidog/cron/vacuum.php
r947 r1127 47 47 require_once(dirname(__FILE__) . '/../include/common.php'); 48 48 49 // Define globals 50 global $db;49 50 $db = AbstractDb::getObject(); 51 51 52 52 // Run vacuum -
trunk/wifidog-auth/wifidog/faq.php
r1030 r1127 51 51 require_once('include/common_interface.php'); 52 52 require_once('classes/MainUI.php'); 53 54 $ui = new MainUI();53 $smarty = SmartyWifidog::getObject(); 54 $ui = MainUI::getObject(); 55 55 $ui->addContent('main_area_middle', $smarty->fetch("templates/faq.html")); 56 56 $ui->display(); -
trunk/wifidog-auth/wifidog/file_download.php
r1074 r1127 50 50 if (!empty ($_REQUEST['file_id'])) 51 51 { 52 global $db;52 $db = AbstractDb::getObject(); 53 53 $file_id = $db->escapeString($_REQUEST['file_id']); 54 54 $sql = "SELECT * FROM content_file WHERE files_id = '$file_id'"; -
trunk/wifidog-auth/wifidog/gw_message.php
r979 r1127 54 54 require_once('classes/MainUI.php'); 55 55 56 $ui = new MainUI();56 $ui = MainUI::getObject(); 57 57 $errmsg = ""; 58 58 -
trunk/wifidog-auth/wifidog/help.php
r1030 r1127 52 52 require_once('classes/MainUI.php'); 53 53 require_once('classes/Network.php'); 54 54 $smarty = SmartyWifidog::getObject(); 55 55 Network::assignSmartyValues($smarty); 56 56 $smarty->assign('read_the_faq', 57 57 sprintf('Read the <a href="%sfaq.php">faq</a> document for more information.', BASE_URL_PATH)); 58 58 59 $ui = new MainUI();59 $ui = MainUI::getObject(); 60 60 $ui->addContent('main_area_middle', $smarty->fetch("templates/sites/help.tpl")); 61 61 $ui->display(); -
trunk/wifidog-auth/wifidog/hotspot_status.php
r1031 r1127 56 56 require_once('classes/Network.php'); 57 57 require_once('classes/NodeList.php'); 58 58 $smarty = SmartyWifidog::getObject(); 59 59 if (!empty ($_REQUEST['format'])) { 60 60 $format = $db->escapeString($_REQUEST['format']); -
trunk/wifidog-auth/wifidog/hotspots_map.php
r1051 r1127 57 57 require_once('classes/User.php'); 58 58 require_once('classes/Server.php'); 59 59 $smarty = SmartyWifidog::getObject(); 60 60 // Get information about user 61 61 $currentUser = User::getCurrentUser(); … … 167 167 * Render output 168 168 */ 169 $ui = new MainUI();169 $ui = MainUI::getObject(); 170 170 $ui->setTitle(_("Hotspots status map")); 171 171 $ui->setHtmlHeader($html_headers); -
trunk/wifidog-auth/wifidog/include/common.php
r1123 r1127 102 102 require_once ('classes/Dependencies.php'); 103 103 require_once ('classes/Server.php'); 104 global $db; 105 106 $db = new AbstractDb(); 104 $db = AbstractDb::getObject(); 107 105 108 106 /** … … 195 193 /** Cleanup dangling tokens and connections from the database, left if a gateway crashed, etc. */ 196 194 function garbage_collect() { 197 global $db;195 $db = AbstractDb::getObject(); 198 196 199 197 // 10 minutes -
trunk/wifidog-auth/wifidog/include/common_interface.php
r1091 r1127 61 61 require_once('classes/SmartyWifidog.php'); 62 62 require_once('classes/User.php'); 63 64 $session = new Session();65 $smarty = new SmartyWifidog;66 67 63 require_once('include/language.php'); 68 69 try70 {71 $username = null;72 $current_user = User :: getCurrentUser();73 if ($current_user != null)74 {75 $username = $current_user->getUsername();76 }77 78 $smarty->assign("auth_user", $username);79 }80 catch (Exception $e)81 {82 ;83 }84 64 85 65 /* -
trunk/wifidog-auth/wifidog/include/language.php
r1031 r1127 48 48 49 49 if (!empty ($_REQUEST['wifidog_language'])) { 50 50 $session = Session::getObject(); 51 51 //echo "Setting to $_REQUEST[wifidog_language]<br/>"; 52 52 $session->set(SESS_LANGUAGE_VAR, $_REQUEST['wifidog_language']); -
trunk/wifidog-auth/wifidog/include/schema_validate.php
r1090 r1127 56 56 function validate_schema() 57 57 { 58 // Define globals59 global $db;58 59 $db = AbstractDb::getObject(); 60 60 61 61 // Init values … … 90 90 function check_users_not_empty() 91 91 { 92 // Define globals93 global $db;92 93 $db = AbstractDb::getObject(); 94 94 95 95 // Extract the first account origin, assume it's the default … … 140 140 function update_schema() 141 141 { 142 // Define globals143 global $db;142 143 $db = AbstractDb::getObject(); 144 144 145 145 // Init values -
trunk/wifidog-auth/wifidog/index.php
r1073 r1127 57 57 require_once('classes/Node.php'); 58 58 require_once('classes/User.php'); 59 59 $smarty = SmartyWifidog::getObject(); 60 60 // Init ALL smarty SWITCH values 61 61 $smarty->assign('sectionTOOLCONTENT', false); … … 102 102 * Render output 103 103 */ 104 $ui = new MainUI();104 $ui = MainUI::getObject(); 105 105 $ui->addContent('left_area_middle', $html); 106 106 $ui->addContent('main_area_top', $html_body); -
trunk/wifidog-auth/wifidog/login/index.php
r1092 r1127 79 79 require_once('classes/Network.php'); 80 80 require_once('classes/MainUI.php'); 81 // require_once('lib/magpie/rss_fetch.inc'); // Added so RSS code which depends on the Magpie RSS functions will work. // 82 81 $smarty = SmartyWifidog::getObject(); 82 $session = Session::getObject(); 83 83 // Init values 84 84 $continueToAdmin = false; … … 149 149 150 150 catch (Exception $e) { 151 $ui = new MainUI();151 $ui = MainUI::getObject(); 152 152 $ui->displayError($e->getMessage()); 153 153 exit; … … 254 254 $html = $smarty->fetch("templates/sites/login.tpl"); 255 255 256 $ui = new MainUI();256 $ui = MainUI::getObject(); 257 257 if($node) { 258 258 $ui->setTitle(sprintf(_("%s login page for %s"), $network->getName(), $node->getName())); … … 292 292 $content = Content :: getObject($content_row['content_id']); 293 293 if ($content->isDisplayableAt($node)) { 294 $ui->addContent($content_row['display_area'], $content ->getUserUI(), $content_row['display_order']);294 $ui->addContent($content_row['display_area'], $content, $content_row['display_order']); 295 295 } 296 296 } -
trunk/wifidog-auth/wifidog/lost_password.php
r1031 r1127 56 56 require_once('classes/User.php'); 57 57 require_once('classes/MainUI.php'); 58 58 $smarty = SmartyWifidog::getObject(); 59 59 /** 60 60 * Process recovering username … … 140 140 * Render output 141 141 */ 142 $ui = new MainUI();142 $ui = MainUI::getObject(); 143 143 $ui->addContent('left_area_middle', $html); 144 144 $ui->addContent('main_area_middle', $html_body); … … 210 210 * Render output 211 211 */ 212 $ui = new MainUI();212 $ui = MainUI::getObject(); 213 213 $ui->addContent('left_area_middle', $html); 214 214 $ui->addContent('main_area_middle', $html_body); -
trunk/wifidog-auth/wifidog/lost_username.php
r1031 r1127 56 56 require_once('classes/User.php'); 57 57 require_once('classes/MainUI.php'); 58 58 $smarty = SmartyWifidog::getObject(); 59 59 /** 60 60 * Process recovering username … … 124 124 * Render output 125 125 */ 126 $ui = new MainUI();126 $ui = MainUI::getObject(); 127 127 $ui->addContent('left_area_middle', $html); 128 128 $ui->addContent('main_area_middle', $html_body); … … 194 194 * Render output 195 195 */ 196 $ui = new MainUI();196 $ui = MainUI::getObject(); 197 197 $ui->addContent('left_area_middle', $html); 198 198 $ui->addContent('main_area_middle', $html_body); -
trunk/wifidog-auth/wifidog/node_list.php
r1123 r1127 57 57 require_once('classes/Node.php'); 58 58 require_once('classes/Utils.php'); 59 60 global $db;59 $smarty = SmartyWifidog::getObject(); 60 $db = AbstractDb::getObject(); 61 61 62 62 // Set the sort parameter, defaults to name … … 148 148 require_once('classes/MainUI.php'); 149 149 150 $ui = new MainUI();150 $ui = MainUI::getObject(); 151 151 $ui->addContent('main_area_middle', $smarty->fetch("templates/node_list.html")); 152 152 $ui->display(); -
trunk/wifidog-auth/wifidog/portal/index.php
r1090 r1127 58 58 require_once ('classes/MainUI.php'); 59 59 require_once ('classes/Session.php'); 60 60 $smarty = SmartyWifidog::getObject(); 61 61 /* 62 62 * Check for missing URL switch 63 63 */ 64 64 if (isset ($_REQUEST['missing']) && $_REQUEST['missing'] == "url") { 65 $ui = new MainUI();65 $ui = MainUI::getObject(); 66 66 $ui->displayError(_('For some reason, we were unable to determine the web site you initially wanted to see. You should now enter a web address in your URL bar.'), false); 67 67 exit; … … 74 74 75 75 // Init session 76 $session = new Session();76 $session = Session::getObject(); 77 77 78 78 // Get the current user … … 87 87 $network = $node->getNetwork(); 88 88 } catch (Exception $e) { 89 $ui = new MainUI();89 $ui = MainUI::getObject(); 90 90 $ui->displayError($e->getMessage()); 91 91 exit; 92 92 } 93 93 } else { 94 $ui = new MainUI();94 $ui = MainUI::getObject(); 95 95 $ui->displayError(_("No Hotspot specified!")); 96 96 exit; … … 202 202 */ 203 203 204 $ui = new MainUI();204 $ui = MainUI::getObject(); 205 205 $ui->setTitle(sprintf(_("%s portal for %s"), $network->getName(), $node->getName())); 206 206 $ui->setPageName('portal'); … … 234 234 $content = Content :: getObject($content_row['content_id']); 235 235 if ($content->isDisplayableAt($node)) { 236 $ui->addContent($content_row['display_area'], $content ->getUserUI(), $content_row['display_order']);236 $ui->addContent($content_row['display_area'], $content, $content_row['display_order']); 237 237 } 238 238 } … … 254 254 $content = Content :: getObject($content_row['content_id']); 255 255 if ($content->isDisplayableAt($node)) { 256 $ui->addContent($content_row['display_area'], $content ->getUserUI(), $content_row['display_order']);256 $ui->addContent($content_row['display_area'], $content, $content_row['display_order']); 257 257 } 258 258 // Check for content requirements to show the "Show all contents" link … … 279 279 $content = Content :: getObject($content_row['content_id']); 280 280 if ($content->isDisplayableAt($node)) { 281 $ui->addContent('main_area_middle', $content ->getUserUI());281 $ui->addContent('main_area_middle', $content); 282 282 } 283 283 } -
trunk/wifidog-auth/wifidog/resend_validation.php
r1031 r1127 56 56 require_once('classes/User.php'); 57 57 require_once('classes/MainUI.php'); 58 58 $smarty = SmartyWifidog::getObject(); 59 59 /** 60 60 * Process recovering username … … 123 123 * Render output 124 124 */ 125 $ui = new MainUI();125 $ui = MainUI::getObject(); 126 126 $ui->addContent('left_area_middle', $html); 127 127 $ui->addContent('main_area_middle', $html_body); … … 193 193 * Render output 194 194 */ 195 $ui = new MainUI();195 $ui = MainUI::getObject(); 196 196 $ui->addContent('left_area_middle', $html); 197 197 $ui->addContent('main_area_middle', $html_body); -
trunk/wifidog-auth/wifidog/signup.php
r1031 r1127 58 58 require_once('classes/MainUI.php'); 59 59 require_once('classes/Mail.php'); 60 60 $smarty = SmartyWifidog::getObject(); 61 61 /** 62 62 * Load custom signup URL if it has been defined in config.php … … 233 233 234 234 // If the user is at a REAL hotspot, give him his sign-up minutes right away 235 $session = Session::getObject(); 235 236 $gw_id = $session->get(SESS_GW_ID_VAR); 236 237 $gw_address = $session->get(SESS_GW_ADDRESS_VAR); … … 256 257 * Render output 257 258 */ 258 $ui = new MainUI();259 $ui = MainUI::getObject(); 259 260 260 261 $ui->addContent('left_area_middle', $html); … … 344 345 * Render output 345 346 */ 346 $ui = new MainUI();347 $ui = MainUI::getObject(); 347 348 $ui->addContent('left_area_middle', $html); 348 349 $ui->addContent('main_area_middle', $html_body); -
trunk/wifidog-auth/wifidog/validate.php
r1031 r1127 53 53 require_once('classes/Node.php'); 54 54 require_once('classes/MainUI.php'); 55 55 $smarty = SmartyWifidog::getObject(); 56 56 try { 57 57 if (!isset($_REQUEST["token"])) … … 76 76 // Try to current physical node: if possible it will regenerate the session accordingly with the connection token. 77 77 $current_user_node = Node::getCurrentRealNode(); 78 if($current_user_node) 79 $gw_id = $session->set(SESS_GW_ID_VAR, $current_user_node->getId()); 80 78 if($current_user_node) { 79 $session = Session::getObject(); 80 $gw_id = $session->set(SESS_GW_ID_VAR, $current_user_node->getId()); 81 } 81 82 // Show activation message 82 83 $smarty->assign('message', _("Your account has been succesfully activated!\n\nYou may now browse to a remote Internet address and take advantage of the free Internet access!\n\nIf you get prompted for a login, enter the username and password you have just created.")); … … 85 86 } 86 87 87 $ui = new MainUI();88 $ui = MainUI::getObject(); 88 89 $ui->addContent('main_area_middle', $smarty->fetch("templates/sites/validate.tpl")); 89 90 $ui->display();
