Changeset 1092
- Timestamp:
- 09/07/06 04:38:25 (4 years ago)
- Location:
- trunk/wifidog-auth
- Files:
-
- 13 modified
-
CHANGELOG (modified) (1 diff)
-
wifidog/admin/generic_object_admin.php (modified) (1 diff)
-
wifidog/classes/Content.php (modified) (6 diffs)
-
wifidog/classes/Content/ContentGroup/ContentGroupElement.php (modified) (1 diff)
-
wifidog/classes/Content/Langstring/Langstring.php (modified) (1 diff)
-
wifidog/classes/Content/RssAggregator/RssAggregator.php (modified) (19 diffs)
-
wifidog/classes/Node.php (modified) (1 diff)
-
wifidog/classes/User.php (modified) (45 diffs)
-
wifidog/content/index.php (modified) (2 diffs)
-
wifidog/include/common.php (modified) (1 diff)
-
wifidog/login/index.php (modified) (1 diff)
-
wifidog/media/base_theme/stylesheet.css (modified) (2 diffs)
-
wifidog/templates/classes/MainUI_ToolSection.tpl (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/wifidog-auth/CHANGELOG
r1091 r1092 1 1 2006-09-06 Benoit Grégoire <bock@step.polymtl.ca> 2 2 * Fix #63 3 * Fix problem with my Splash only user fix (I used match on the user_id instead of the username). 4 * Prevent the Splash only user from logging out, wrecking havock in the tokens. 5 * Do not allow SplashOnlyUser to set his preferences. 6 * Assigning a reusable content to a contentgroup element would make it non-reusable. 7 Usability and UI fixes: 8 * Allow other users to log in when they are at a splash only node. 9 * Make isSimpleContent class available for Simple content types. Make it borderless and backgroundless in the default theme_pack. 10 * Simplify HTML output for simple content. 11 * Fix IE layout bug in node admin 12 * Content linked to nodes and networks now edits in a new window. 13 * Remove "Add new node" menu item for consistency. 14 15 2006-09-06 Benoit Grégoire <bock@step.polymtl.ca> 16 * Remove most inclusions of MainUI in classes. 17 That completely broke authentication (circular dependencies). 18 Fixes 245. 19 Unfixes 242. Exceptions should not be caught in the context 20 they are thrown in. Else there no point in throwing exception in the 21 first place. 3 22 * HyperLink.php: Fix bug where a link with identical text as it's link would see the text replaced by the clickthrough-tracked equivalent. 4 23 -
trunk/wifidog-auth/wifidog/admin/generic_object_admin.php
r1090 r1092 236 236 $object->processAdminUI(); 237 237 238 // Renew information about the object239 $object = call_user_func(array($class, 'getObject'), $_REQUEST['object_id']);240 241 238 // Now try to delete the content 242 239 if ($object->delete($errmsg) == true) { -
trunk/wifidog-auth/wifidog/classes/Content.php
r1091 r1092 559 559 $html .= "<td>\n"; 560 560 $name = "{$user_prefix}_" . $content->GetId() . "_edit"; 561 $html .= "<input type='button' class='submit' name='$name' value='" . _("Edit") . "' onClick='window. location.href = \"" . GENERIC_OBJECT_ADMIN_ABS_HREF . "?object_class=Content&action=edit&object_id=" . $content->GetId() . "\";'>\n";561 $html .= "<input type='button' class='submit' name='$name' value='" . _("Edit") . "' onClick='window.open(\"" . GENERIC_OBJECT_ADMIN_ABS_HREF . "?object_class=Content&action=edit&object_id=" . $content->GetId() . "\");'>\n"; 562 562 $name = "{$user_prefix}_" . $content->GetId() . "_erase"; 563 563 $html .= "<input type='submit' class='submit' name='$name' value='" . _("Remove") . "'>"; … … 734 734 } 735 735 736 $html .= _("Add existing content") . ": ";736 $html .= _("Add reusable content from library") . ": "; 737 737 } 738 738 … … 1025 1025 public function getUserUI($subclass_user_interface = null) { 1026 1026 $html = ''; 1027 $html .= "<div class='user_ui_main_outer " . get_class($this) . "'>\n"; 1027 $this->isSimpleContent() ? $isSimpleContentClass = 'isSimpleContent' : $isSimpleContentClass = null; 1028 $html .= "<div class='user_ui_main_outer " . get_class($this) . " $isSimpleContentClass'>\n"; 1028 1029 $html .= "<div class='user_ui_main_inner'>\n"; 1029 1030 … … 1039 1040 } 1040 1041 1041 $html .= "<table><tr>\n"; 1042 if($this->isSimpleContent()) 1043 { 1044 $html .= "\n$subclass_user_interface\n"; 1045 } 1046 else{ 1047 $html .= "<table><tr>\n"; 1042 1048 $html .= "<td>\n$subclass_user_interface</td>\n"; 1043 1044 1049 $html .= "<td>\n"; 1050 } 1045 1051 $authors = $this->getAuthors(); 1046 1052 if (count($authors) > 0) { … … 1077 1083 } 1078 1084 } 1079 1085 if(!$this->isSimpleContent()) 1086 { 1080 1087 $html .= "</td>\n"; 1081 1088 $html .= "</tr></table>\n"; 1082 1089 } 1083 1090 $html .= "</div>\n"; 1084 1091 $html .= "</div>\n"; … … 1270 1277 /* is_persistent */ 1271 1278 $html .= "<li class='admin_element_item_container admin_section_edit_persistant'>\n"; 1272 $html .= "<div class='admin_element_label'>" . _("Is p ersistent (reusable and read-only)?") . ": </div>\n";1279 $html .= "<div class='admin_element_label'>" . _("Is part of reusable content library (protected from deletion)?") . ": </div>\n"; 1273 1280 $html .= "<div class='admin_element_data'>\n"; 1274 1281 $name = "content_" . $this->id . "_is_persistent"; -
trunk/wifidog-auth/wifidog/classes/Content/ContentGroup/ContentGroupElement.php
r1091 r1092 454 454 $displayed_content_id = $displayed_content->GetId(); 455 455 $db->execSqlUpdate("UPDATE content_group_element SET displayed_content_id = '$displayed_content_id' WHERE content_group_element_id = '$this->id'", FALSE); 456 $displayed_content->setIsPersistent(false);457 456 } 458 457 } else { -
trunk/wifidog-auth/wifidog/classes/Content/Langstring/Langstring.php
r1090 r1092 494 494 $html = ''; 495 495 496 $html .= "<div class='user_ui_container ".get_class($this)."'>\n";497 496 $html .= "<div class='langstring'>\n"; 498 497 $html .= $this->getString(); 499 498 $html .= $subclass_user_interface; 500 $html .= "</div>\n";501 499 $html .= "</div>\n"; 502 500 /* Handle hyperlink clicktrough logging */ -
trunk/wifidog-auth/wifidog/classes/Content/RssAggregator/RssAggregator.php
r1090 r1092 64 64 class RssAggregator extends Content { 65 65 /** 66 66 67 67 */ 68 68 private $content_rss_aggregator_row; 69 69 70 70 /** 71 71 72 72 */ 73 73 private $content_rss_aggregator_feeds_rows; 74 74 75 75 /** 76 76 77 77 */ 78 78 private $press_review; … … 114 114 if ($content_rss_aggregator_rows != null) { 115 115 $this->content_rss_aggregator_feeds_rows = $content_rss_aggregator_rows; 116 } 117 else { 116 } else { 118 117 $this->content_rss_aggregator_feeds_rows = array (); 119 118 } … … 139 138 } 140 139 } 141 } 142 else { 140 } else { 143 141 $html = _("RSS support is disabled"); 144 142 } … … 182 180 183 181 $retval = false; 184 } 185 else { 182 } else { 186 183 /* 187 184 * Successfull, but nothing modified … … 239 236 240 237 $retval = true; 241 } 242 else { 238 } else { 243 239 /* 244 240 * Successfull, but nothing modified … … 305 301 306 302 $retval = false; 307 } 308 else { 303 } else { 309 304 /* 310 305 * Successfull, but nothing modified … … 405 400 $html .= "<div class='admin_element_label'>\n"; 406 401 $html .= _("How much bonus feeds that do not publish as often get over feed that publish more often. 407 The default is 0.75, with a typical range between 0 and 1.408 At 0, you have a classic RSS aggregator, meaning the n most recent entries picked from all feeds409 will be displayed. 1 is usually as high as you'll want to go: Assuming that all410 an homogenous internal distribution (ex: one feed publishes exactly one entry a day, the411 second once every two days, and the third once every three days), and you ask for 15 entries,412 there will be 5 of each. While that may not sound usefull, it still is, as the feed's distribution is413 usually not homogenous.");402 The default is 0.75, with a typical range between 0 and 1. 403 At 0, you have a classic RSS aggregator, meaning the n most recent entries picked from all feeds 404 will be displayed. 1 is usually as high as you'll want to go: Assuming that all 405 an homogenous internal distribution (ex: one feed publishes exactly one entry a day, the 406 second once every two days, and the third once every three days), and you ask for 15 entries, 407 there will be 5 of each. While that may not sound usefull, it still is, as the feed's distribution is 408 usually not homogenous."); 414 409 $html .= ": </div>\n"; 415 410 $html .= "<div class='admin_element_data'>\n"; … … 428 423 $html .= "<div class='admin_element_label'>\n"; 429 424 $html .= _("Set the oldest entries (in seconds) you are willing to see. Any entries older than this will not 430 be considered at all for display, even if it means that the configured number of items to be displayed isn't reached.431 It's only usefull if all your feed publish very rarely, and you don't want very old entries to show up.");425 be considered at all for display, even if it means that the configured number of items to be displayed isn't reached. 426 It's only usefull if all your feed publish very rarely, and you don't want very old entries to show up."); 432 427 $html .= ": </div>\n"; 433 428 $html .= "<div class='admin_element_data'>\n"; … … 473 468 474 469 $sql = "SELECT count, content_rss_aggregator_feeds.url, title FROM content_rss_aggregator_feeds 475 JOIN (SELECT url, count(content_rss_aggregator_feeds.url) as count476 FROM content_rss_aggregator_feeds477 WHERE content_rss_aggregator_feeds.url NOT IN (SELECT url FROM content_rss_aggregator_feeds WHERE content_id='{$this->id}')478 GROUP BY content_rss_aggregator_feeds.content_id, content_rss_aggregator_feeds.url)479 AS available_feeds480 ON (available_feeds.url=content_rss_aggregator_feeds.url)481 ORDER by count DESC";470 JOIN (SELECT url, count(content_rss_aggregator_feeds.url) as count 471 FROM content_rss_aggregator_feeds 472 WHERE content_rss_aggregator_feeds.url NOT IN (SELECT url FROM content_rss_aggregator_feeds WHERE content_id='{$this->id}') 473 GROUP BY content_rss_aggregator_feeds.content_id, content_rss_aggregator_feeds.url) 474 AS available_feeds 475 ON (available_feeds.url=content_rss_aggregator_feeds.url) 476 ORDER by count DESC"; 482 477 483 478 $db->execSql($sql, $feed_urls, false); 484 485 foreach ($feed_urls as $feed_row) {486 $tab[$i][0] = $feed_row['url'];487 empty ($feed_row['title']) ? $title = $feed_row['url'] : $title = $feed_row['title'];488 $tab[$i][1] = sprintf(_("%s, used %d times"), $title, $feed_row['count']);489 $i++;490 }491 479 if ($feed_urls) { 480 foreach ($feed_urls as $feed_row) { 481 $tab[$i][0] = $feed_row['url']; 482 empty ($feed_row['title']) ? $title = $feed_row['url'] : $title = $feed_row['title']; 483 $tab[$i][1] = sprintf(_("%s, used %d times"), $title, $feed_row['count']); 484 $i++; 485 } 486 } 492 487 $name = "rss_aggregator_{$this->id}_feed_add"; 493 488 $html .= "<input type='text' size='60' value='' name='$name' id='$name'>\n"; … … 563 558 * 564 559 * @return string HTML code for the administration interface 565 560 566 561 */ 567 562 private function getFeedAdminUI($feed_row) { … … 602 597 if ($calculated_pub_interval == true) { 603 598 $html .= sprintf(_("The feed publishes an item every %.2f day(s)"), $calculated_pub_interval / (60 * 60 * 24)); 604 } 605 else { 599 } else { 606 600 $html .= "<div class='admin_element_label'><span class='warningmsg'>" . _("WARNING: This feed does not include the publication dates. 607 The system needs to be able to compute approximate publication608 date for each entry, so the entry can be weighted against the609 others. In order for the aggregator to do a good job, you need610 to estimate fublication frequency of the items, in days.611 If unset, defaults to one day.") . ": </span></div>\n";601 The system needs to be able to compute approximate publication 602 date for each entry, so the entry can be weighted against the 603 others. In order for the aggregator to do a good job, you need 604 to estimate fublication frequency of the items, in days. 605 If unset, defaults to one day.") . ": </span></div>\n"; 612 606 $html .= "<div class='admin_element_data'>\n"; 613 607 $name = "rss_aggregator_" . $this->id . "_feed_" . md5($feed_row['url']) . "_default_publication_interval"; … … 615 609 if (!empty ($feed_row['default_publication_interval'])) { 616 610 $value = $feed_row['default_publication_interval'] / (60 * 60 * 24); 617 } 618 else { 611 } else { 619 612 $value = ''; 620 613 } … … 631 624 $html .= "<li class='admin_element_item_container'>\n"; 632 625 $html .= "<div class='admin_element_label'>" . _("The bias to be given to the source by the selection algorithm. 633 Bias must be > 0 , typical values would be between 0.75 and 1.5634 and default is 1 (no bias). A bias of 2 will cause the items635 to \"look\" twice as recent to the algorithm. A bias of 0.5 to636 look twice as old. Be carefull, a bias of 2 will statistically637 cause the feed to have MORE than twice as many items displayed.") . ": </div>\n";626 Bias must be > 0 , typical values would be between 0.75 and 1.5 627 and default is 1 (no bias). A bias of 2 will cause the items 628 to \"look\" twice as recent to the algorithm. A bias of 0.5 to 629 look twice as old. Be carefull, a bias of 2 will statistically 630 cause the feed to have MORE than twice as many items displayed.") . ": </div>\n"; 638 631 $html .= "<div class='admin_element_data'>\n"; 639 632 … … 656 649 * 657 650 * @return void 658 651 659 652 */ 660 653 private function processFeedAdminUI($feed_row) { … … 680 673 elseif (!is_numeric($bias) || $bias <= 0) { 681 674 echo _("The bias must be a positive real number"); 682 } 683 else { 675 } else { 684 676 /* 685 677 * Successfull, but nothing modified … … 709 701 elseif (!is_numeric($bias) || $bias <= 0) { 710 702 echo _("The default publication must must be a positive integer or empty"); 711 } 712 else { 703 } else { 713 704 /* 714 705 * Successfull, but nothing modified … … 732 723 elseif (empty ($url)) { 733 724 echo _("The URL cannot be empty!"); 734 } 735 else { 725 } else { 736 726 /* 737 727 * Successfull, but nothing modified … … 754 744 try { 755 745 $html = $this->press_review->get_rss_html($this->content_rss_aggregator_row['number_of_display_items']); 756 } 757 catch (Exception $e) { 746 } catch (Exception $e) { 758 747 $html = sprintf(_("Could not get RSS feed: %s"), $feed_row['url']); 759 748 } 760 /* Handle hyperlink clicktrough logging */ 761 $html = $this->replaceHyperLinks($html); 762 763 } 764 else { 749 /* Handle hyperlink clicktrough logging */ 750 $html = $this->replaceHyperLinks($html); 751 752 } else { 765 753 $html = _("RSS support is disabled"); 766 754 } … … 780 768 * 781 769 * @return void 782 770 783 771 */ 784 772 private function refresh() { -
trunk/wifidog-auth/wifidog/classes/Node.php
r1091 r1092 997 997 // custom_portal_redirect_url 998 998 if ($network->getCustomPortalRedirectAllowed()) { 999 $_title = _("URL to show instead of the portal (if this is not empty, the portal will be disabled and this URL will be shown instead)");999 $_title = _("URL to show instead of the portal"); 1000 1000 $_data = InterfaceElements::generateInputText("node_" . $hashed_node_id . "_custom_portal_redirect_url", $this->getCustomPortalRedirectUrl(), "node_custom_portal_redirect_url_input"); 1001 $_html_node_config[] = InterfaceElements::generateAdminSectionContainer("node_custom_portal_redirect_url", $_title, $_data); 1001 $_data .= _("If this is not empty, the portal will be disabled and this URL will be shown instead"); 1002 $_html_node_config[] = InterfaceElements::generateAdminSectionContainer("node_custom_portal_redirect_url", $_title, $_data); 1002 1003 } 1003 1004 -
trunk/wifidog-auth/wifidog/classes/User.php
r1090 r1092 1 1 <?php 2 2 3 3 4 /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */ … … 45 46 * Load required classes 46 47 */ 47 require_once ('classes/Network.php');48 require_once ('classes/Mail.php');49 require_once ('classes/InterfaceElements.php');48 require_once ('classes/Network.php'); 49 require_once ('classes/Mail.php'); 50 require_once ('classes/InterfaceElements.php'); 50 51 51 52 /** … … 56 57 * @copyright 2005-2006 Benoit Grégoire, Technologies Coeus inc. 57 58 */ 58 class User implements GenericObject 59 { 59 class User implements GenericObject { 60 60 private $mRow; 61 61 private $id; … … 65 65 * @return a User object, or null if there was an error 66 66 */ 67 public static function getObject($id) 68 { 67 public static function getObject($id) { 69 68 $object = null; 70 69 $object = new self($id); … … 72 71 } 73 72 74 static function createNewObject() 75 { 73 static function createNewObject() { 76 74 echo "<h1>Use User::createUser() instead</h1>"; 77 75 } … … 79 77 * @return html markup 80 78 */ 81 public static function getCreateNewObjectUI() 82 { 79 public static function getCreateNewObjectUI() { 83 80 return null; 84 81 } … … 90 87 * @return the node object or null if no new node was created. 91 88 */ 92 static function processCreateNewObjectUI() 93 { 89 static function processCreateNewObjectUI() { 94 90 return self :: createNewObject(); 95 91 } … … 98 94 * 99 95 * @return mixed A User object, or null if there was an error 100 101 */ 102 public static function getCurrentUser() 103 { 104 require_once('classes/Session.php'); 96 97 */ 98 public static function getCurrentUser() { 99 require_once ('classes/Session.php'); 105 100 $session = new Session(); 106 101 $user = null; 107 try 108 { 102 try { 109 103 $user = self :: getObject($session->get(SESS_USER_ID_VAR)); 110 104 //$user = new User($session->get(SESS_USER_ID_VAR)); 111 } 112 catch (Exception $e) 113 { 105 } catch (Exception $e) { 114 106 /**If any problem occurs, the user should be considered logged out*/ 115 107 $session->set(SESS_USER_ID_VAR, null); … … 126 118 * 127 119 * @return bool True if everything went well setting the session 128 129 */ 130 public static function setCurrentUser(User $user) 131 { 132 try 133 { 120 121 */ 122 public static function setCurrentUser(User $user) { 123 try { 134 124 $session = new Session(); 135 125 $session->set(SESS_USER_ID_VAR, $user->getId()); 136 126 $session->set(SESS_PASSWORD_HASH_VAR, $user->getPasswordHash()); 137 127 return true; 138 } 139 catch (Exception $e) 140 { 128 } catch (Exception $e) { 141 129 return false; 142 130 } … … 147 135 * 148 136 * @return string Hostname of server 149 150 */ 151 public static function getCurrentServer() 152 { 137 138 */ 139 public static function getCurrentServer() { 153 140 return $_SERVER['SERVER_NAME']; 154 141 } … … 159 146 * @return a User object, or null if there was an error 160 147 */ 161 public static function getUserByUsernameAndOrigin($username, Network $account_origin) 162 { 148 public static function getUserByUsernameAndOrigin($username, Network $account_origin) { 163 149 global $db; 164 150 $object = null; … … 178 164 * @return a User object, or null if there was an error 179 165 */ 180 public static function getUserByEmailAndOrigin($email, Network $account_origin) 181 { 166 public static function getUserByEmailAndOrigin($email, Network $account_origin) { 182 167 global $db; 183 168 $object = null; … … 195 180 * @return The 32 character hash. 196 181 */ 197 public static function passwordHash($password) 198 { 182 public static function passwordHash($password) { 199 183 /** 200 184 * utf8_decode is used for backward compatibility with old passwords … … 209 193 * @return the newly created User object, or null if there was an error 210 194 */ 211 static function createUser($id, $username, Network $account_origin, $email, $password) 212 { 195 static function createUser($id, $username, Network $account_origin, $email, $password) { 213 196 global $db; 214 197 … … 229 212 } 230 213 231 /* public static function purgeUnvalidatedUsers($days_since_creation)232 {233 global $db;234 $days_since_creation = $db->escapeString($days_since_creation);235 236 //$db->execSqlUpdate("INSERT INTO users (user_id,username, account_origin,email,pass,account_status,validation_token,reg_date) VALUES ('$id_str','$username_str','$account_origin_str','$email_str','$password_hash','$status','$token',NOW())");237 }*/214 /* public static function purgeUnvalidatedUsers($days_since_creation) 215 { 216 global $db; 217 $days_since_creation = $db->escapeString($days_since_creation); 218 219 //$db->execSqlUpdate("INSERT INTO users (user_id,username, account_origin,email,pass,account_status,validation_token,reg_date) VALUES ('$id_str','$username_str','$account_origin_str','$email_str','$password_hash','$status','$token',NOW())"); 220 }*/ 238 221 239 222 /** @param $object_id The id of the user */ 240 function __construct($object_id) 241 { 223 function __construct($object_id) { 242 224 global $db; 243 225 $this->mDb = & $db; … … 245 227 $sql = "SELECT * FROM users WHERE user_id='{$object_id_str}'"; 246 228 $db->execSqlUniqueRes($sql, $row, false); 247 if ($row == null) 248 { 229 if ($row == null) { 249 230 throw new Exception(sprintf(_("User id: %s could not be found in the database"), $object_id_str)); 250 231 } … … 253 234 } //End class 254 235 255 function getId() 256 { 236 function getId() { 257 237 return $this->id; 258 238 } … … 261 241 * @return Network object (never returns null) 262 242 */ 263 public function getNetwork() 264 { 243 public function getNetwork() { 265 244 return Network :: getObject($this->mRow['account_origin']); 266 245 } 267 246 268 247 /** Get a user display suitable for a user list. Will include link to the user profile. */ 269 function getListUI() 270 { 248 function getListUI() { 271 249 /* $roles = array (); 272 273 if ($current_node->isOwner($online_user)) {250 251 if ($current_node->isOwner($online_user)) { 274 252 $roles[] = _("owner"); 275 }276 277 if ($current_node->isTechnicalOfficer($online_user)) {253 } 254 255 if ($current_node->isTechnicalOfficer($online_user)) { 278 256 $roles[] = _("technical officer"); 279 }280 281 if ($roles) {257 } 258 259 if ($roles) { 282 260 $rolenames = join($roles, ","); 283 }*/261 }*/ 284 262 $html = ''; 285 if($this->isSplashOnlyUser()) 286 { 287 $html .= _("Guest"); 263 if ($this->isSplashOnlyUser()) { 264 $html .= _("Guest"); 288 265 } 289 266 $html .= $this->getUserName(); … … 291 268 } 292 269 293 function getUsername() 294 { 270 function getUsername() { 295 271 return $this->mRow['username']; 296 272 } 297 298 /** Set the user's username299 * @param $value The new value300 * @return true on success, false on failure301 * @throws exception if the user tries to set a duplicate username302 */273 274 /** Set the user's username 275 * @param $value The new value 276 * @return true on success, false on failure 277 * @throws exception if the user tries to set a duplicate username 278 */ 303 279 function setUsername($value) { 304 280 $retval = true; … … 306 282 global $db; 307 283 $value = $db->escapeString($value); 308 $retval = @$db->execSqlUpdate("UPDATE users SET username = '{$value}' WHERE user_id='{$this->id}'", false); 309 if(!$retval) 310 { 311 throw new exception (sprintf(_("Sorry, the username %s is not available"), $value)); 284 $retval = @ $db->execSqlUpdate("UPDATE users SET username = '{$value}' WHERE user_id='{$this->id}'", false); 285 if (!$retval) { 286 throw new exception(sprintf(_("Sorry, the username %s is not available"), $value)); 312 287 } 313 288 $this->refresh(); … … 316 291 } 317 292 318 public function getEmail() 319 { 293 public function getEmail() { 320 294 return $this->mRow['email']; 321 295 } 322 296 323 public function setEmail($email) 324 { 325 $email_str = $this->mDb->escapeString($email); 326 if (!($update = $this->mDb->execSqlUpdate("UPDATE users SET email='{$email_str}' WHERE user_id='{$this->id}'"))) 327 { 328 throw new Exception(_("Could not update email address.")); 329 } 330 $this->mRow['email'] = $email; // unescaped 331 } 332 333 function setIsInvisible($value) 334 { 335 $retval = true; 336 if ($value != $this->isAdvertised()) 337 { 338 global $db; 339 $value ? $value = 'TRUE' : $value = 'FALSE'; 340 $retval = $db->execSqlUpdate("UPDATE users SET is_invisible = {$value} WHERE user_id = '{$this->getId()}'", false); 341 $this->refresh(); 342 } 343 return $retval; 344 } 345 346 public function isInvisible() 347 { 348 return (($this->mRow['is_invisible'] == 't') ? true : false); 297 public function setEmail($email) { 298 $email_str = $this->mDb->escapeString($email); 299 if (!($update = $this->mDb->execSqlUpdate("UPDATE users SET email='{$email_str}' WHERE user_id='{$this->id}'"))) { 300 throw new Exception(_("Could not update email address.")); 301 } 302 $this->mRow['email'] = $email; // unescaped 303 } 304 305 function setIsInvisible($value) { 306 $retval = true; 307 if ($value != $this->isAdvertised()) { 308 global $db; 309 $value ? $value = 'TRUE' : $value = 'FALSE'; 310 $retval = $db->execSqlUpdate("UPDATE users SET is_invisible = {$value} WHERE user_id = '{$this->getId()}'", false); 311 $this->refresh(); 312 } 313 return $retval; 314 } 315 316 public function isInvisible() { 317 return (($this->mRow['is_invisible'] == 't') ? true : false); 349 318 } 350 319 351 320 /**What locale (language) does the user prefer? */ 352 public function getPreferedLocale() 353 { 354 global $session; 355 $locale = $this->mRow['prefered_locale']; 356 if (empty($locale) && !empty($session)) 357 $locale = $session->get(SESS_LANGUAGE_VAR); 358 if (empty($locale)) 359 $locale = DEFAULT_LANG; 360 return $locale; 361 } 362 363 public function setPreferedLocale($locale) 364 { 365 $locale_str = $this->mDb->escapeString($locale); 366 if (!($update = $this->mDb->execSqlUpdate("UPDATE users SET prefered_locale='{$locale_str}' WHERE user_id='{$this->id}'"))) 367 { 368 throw new Exception(_("Could not update username locale.")); 369 } 370 $this->mRow['prefered_locale'] = $locale; 321 public function getPreferedLocale() { 322 global $session; 323 $locale = $this->mRow['prefered_locale']; 324 if (empty ($locale) && !empty ($session)) 325 $locale = $session->get(SESS_LANGUAGE_VAR); 326 if (empty ($locale)) 327 $locale = DEFAULT_LANG; 328 return $locale; 329 } 330 331 public function setPreferedLocale($locale) { 332 $locale_str = $this->mDb->escapeString($locale); 333 if (!($update = $this->mDb->execSqlUpdate("UPDATE users SET prefered_locale='{$locale_str}' WHERE user_id='{$this->id}'"))) { 334 throw new Exception(_("Could not update username locale.")); 335 } 336 $this->mRow['prefered_locale'] = $locale; 371 337 } 372 338 373 339 /** get the hashed password stored in the database */ 374 public function getPasswordHash() 375 { 340 public function getPasswordHash() { 376 341 return $this->mRow['pass']; 377 342 } … … 380 345 * @return Possible values are listed in common.php 381 346 */ 382 function getAccountStatus() 383 { 347 function getAccountStatus() { 384 348 return $this->mRow['account_status']; 385 349 } 386 350 387 function setAccountStatus($status) 388 { 351 function setAccountStatus($status) { 389 352 global $db; 390 353 391 354 $status_str = $db->escapeString($status); 392 if (!($update = $db->execSqlUpdate("UPDATE users SET account_status='{$status_str}' WHERE user_id='{$this->id}'"))) 393 { 355 if (!($update = $db->execSqlUpdate("UPDATE users SET account_status='{$status_str}' WHERE user_id='{$this->id}'"))) { 394 356 throw new Exception(_("Could not update status.")); 395 357 } … … 399 361 /** Is the user valid? Valid means that the account is validated or hasn't exhausted it's validation period. 400 362 $errmsg: Returs the reason why the account is or isn't valid */ 401 function isUserValid(& $errmsg = null) 402 { 363 function isUserValid(& $errmsg = null) { 403 364 global $db; 404 365 $retval = false; 405 366 $account_status = $this->getAccountStatus(); 406 if ($account_status == ACCOUNT_STATUS_ALLOWED) 407 { 367 if ($account_status == ACCOUNT_STATUS_ALLOWED) { 408 368 $retval = true; 409 } 410 else 411 if ($account_status == ACCOUNT_STATUS_VALIDATION) 412 { 369 } else 370 if ($account_status == ACCOUNT_STATUS_VALIDATION) { 413 371 $sql = "SELECT CASE WHEN ((NOW() - reg_date) > networks.validation_grace_time) THEN true ELSE false END AS validation_grace_time_expired, networks.validation_grace_time FROM users JOIN networks ON (users.account_origin = networks.network_id) WHERE (user_id='{$this->id}')"; 414 372 $db->execSqlUniqueRes($sql, $user_info, false); 415 373 416 if ($user_info['validation_grace_time_expired'] == 't') 417 { 418 $errmsg = sprintf(_("Sorry, your %s minutes grace period to retrieve your email and validate your account has now expired. You will have to connect to the internet and validate your account from another location or create a new account. For help, please %s click here %s."), $user_info['validation_grace_time_expired'], '<a href="'.BASE_URL_PATH.'faq.php'.'">', '</a>'); 374 if ($user_info['validation_grace_time_expired'] == 't') { 375 $errmsg = sprintf(_("Sorry, your %s minutes grace period to retrieve your email and validate your account has now expired. You will have to connect to the internet and validate your account from another location or create a new account. For help, please %s click here %s."), $user_info['validation_grace_time_expired'], '<a href="' . BASE_URL_PATH . 'faq.php' . '">', '</a>'); 419 376 $retval = false; 420 } 421 else 422 { 377 } else { 423 378 $errmsg = _("Your account is currently valid."); 424 379 $retval = true; 425 380 } 426 } 427 else 428 { 429 $errmsg = _("Sorry, your account is not valid: ").$account_status_to_text[$account_status]; 381 } else { 382 $errmsg = _("Sorry, your account is not valid: ") . $account_status_to_text[$account_status]; 430 383 $retval = false; 431 384 } … … 433 386 } 434 387 435 public function isSuperAdmin() 436 { 388 public function isSuperAdmin() { 437 389 global $db; 438 390 //$this->session->dump(); 439 391 440 392 $db->execSqlUniqueRes("SELECT * FROM users NATURAL JOIN administrators WHERE (users.user_id='$this->id')", $user_info, false); 441 if (!empty ($user_info)) 442 { 393 if (!empty ($user_info)) { 443 394 return true; 444 } 445 else 446 { 395 } else { 447 396 return false; 448 397 } … … 453 402 * Tells if the current user is owner of at least one hotspot. 454 403 */ 455 public function isOwner() 456 { 404 public function isOwner() { 457 405 global $db; 458 406 $db->execSql("SELECT * FROM node_stakeholders WHERE is_owner = true AND user_id='{$this->getId()}'", $row, false); … … 463 411 } 464 412 465 public function isNobody() 466 { 467 global $db; 468 $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); 469 if ($row == null) 470 return true; 471 return false; 472 } 473 474 /** Is this user the Splash Only User() */ 475 public function isSplashOnlyUser() 476 { 477 if($this->mRow['user_id'] == "SPLASH_ONLY_USER") { 478 return true; 479 } 480 else { 481 return false; 482 } 483 } 484 485 function getValidationToken() 486 { 413 public function isNobody() { 414 global $db; 415 $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); 416 if ($row == null) 417 return true; 418 return false; 419 } 420 421 /** Is this user the Splash Only User() */ 422 public function isSplashOnlyUser() { 423 if ($this->mRow['username'] == "SPLASH_ONLY_USER") { 424 return true; 425 } else { 426 return false; 427 } 428 } 429 430 function getValidationToken() { 487 431 return $this->mRow['validation_token']; 488 432 } … … 491 435 @return true on success, false on failure 492 436 */ 493 function generateConnectionToken() 494 { 495 if ($this->isUserValid()) 496 { 437 function generateConnectionToken() { 438 if ($this->isUserValid()) { 497 439 global $db; 498 440 global $session; 499 441 500 442 $token = self :: generateToken(); 501 if ($_SERVER['REMOTE_ADDR']) 502 { 443 if ($_SERVER['REMOTE_ADDR']) { 503 444 $node_ip = $db->escapeString($_SERVER['REMOTE_ADDR']); 504 445 } 505 446 506 if ($session && $node_ip && $session->get(SESS_GW_ID_VAR)) 507 { 447 if ($session && $node_ip && $session->get(SESS_GW_ID_VAR)) { 508 448 $node_id = $db->escapeString($session->get(SESS_GW_ID_VAR)); 509 $db->execSqlUpdate("INSERT INTO connections (user_id, token, token_status, timestamp_in, node_id, node_ip, last_updated) VALUES ('" .$this->getId()."', '$token', '".TOKEN_UNUSED."', NOW(), '$node_id', '$node_ip', NOW())", false);449 $db->execSqlUpdate("INSERT INTO connections (user_id, token, token_status, timestamp_in, node_id, node_ip, last_updated) VALUES ('" . $this->getId() . "', '$token', '" . TOKEN_UNUSED . "', NOW(), '$node_id', '$node_ip', NOW())", false); 510 450 $retval = $token; 511 } 512 else 451 } else 513 452 $retval = false; 514 } 515 else 516 { 453 } else { 517 454 $retval = false; 518 455 } … … 520 457 } 521 458 522 function setPassword($password) 523 { 459 function setPassword($password) { 524 460 global $db; 525 461 526 462 $new_password_hash = User :: passwordHash($password); 527 if (!($update = $db->execSqlUpdate("UPDATE users SET pass='$new_password_hash' WHERE user_id='{$this->id}'"))) 528 { 463 if (!($update = $db->execSqlUpdate("UPDATE users SET pass='$new_password_hash' WHERE user_id='{$this->id}'"))) { 529 464 throw new Exception(_("Could not change user's password.")); 530 465 } … … 532 467 } 533 468 534 function getAccountOrigin() 535 { 469 function getAccountOrigin() { 536 470 return $this->mRow['account_origin']; 537 471 } … … 539 473 /** Return all the users 540 474 */ 541 static function getAllUsers() 542 { 475 static function getAllUsers() { 543 476 global $db; 544 477 545 478 $db->execSql("SELECT * FROM users", $objects, false); 546 if ($objects == null) 547 { 479 if ($objects == null) { 548 480 throw new Exception(_("No users could not be found in the database")); 549 481 } … … 551 483 } 552 484 553 function sendLostUsername() 554 { 485 function sendLostUsername() { 555 486 $network = $this->getNetwork(); 556 487 $mail = new Mail(); … … 558 489 $mail->setSenderEmail($network->getValidationEmailFromAddress()); 559 490 $mail->setRecipientEmail($this->getEmail()); 560 $mail->setMessageSubject($network->getName() ._(" lost username request"));561 $mail->setMessageBody(_("Hello,\nYou have requested that the authentication server send you your username:\nUsername: ") .$this->getUsername()._("\n\nHave a nice day,\nThe Team"));491 $mail->setMessageSubject($network->getName() . _(" lost username request")); 492 $mail->setMessageBody(_("Hello,\nYou have requested that the authentication server send you your username:\nUsername: ") . $this->getUsername() . _("\n\nHave a nice day,\nThe Team")); 562 493 $mail->send(); 563 494 } 564 495 565 function sendValidationEmail() 566 { 567 if ($this->getAccountStatus() != ACCOUNT_STATUS_VALIDATION) 568 { 496 function sendValidationEmail() { 497 if ($this->getAccountStatus() != ACCOUNT_STATUS_VALIDATION) { 569 498 throw new Exception(_("The user is not in validation period.")); 570 } 571 else 572 { 573 if ($this->getValidationToken() == "") 574 { 499 } else { 500 if ($this->getValidationToken() == "") { 575 501 throw new Exception(_("The validation token is empty.")); 576 } 577 else 578 { 502 } else { 579 503 $network = $this->getNetwork(); 580 504 … … 583 507 $mail->setSenderEmail($network->getValidationEmailFromAddress()); 584 508 $mail->setRecipientEmail($this->getEmail()); 585 $mail->setMessageSubject($network->getName() ._(" new user validation"));586 $url = BASE_SSL_PATH . "validate.php?user_id=" .$this->getId()."&token=".$this->getValidationToken();587 $mail->setMessageBody(_("Hello,\nPlease follow the link below to validate your account.\n") .$url._("\n\nThank you,\nThe Team."));509 $mail->setMessageSubject($network->getName() . _(" new user validation")); 510 $url = BASE_SSL_PATH . "validate.php?user_id=" . $this->getId() . "&token=" . $this->getValidationToken(); 511 $mail->setMessageBody(_("Hello,\nPlease follow the link below to validate your account.\n") . $url . _("\n\nThank you,\nThe Team.")); 588 512 $mail->send(); 589 513 } … … 591 515 } 592 516 593 function sendLostPasswordEmail() 594 { 517 function sendLostPasswordEmail() { 595 518 $network = $this->getNetwork(); 596 519 $new_password = $this->randomPass(); … … 601 524 $mail->setSenderEmail($network->getValidationEmailFromAddress()); 602 525 $mail->setRecipientEmail($this->getEmail()); 603 $mail->setMessageSubject($network->getName() ._(" new password request"));604 $mail->setMessageBody(_("Hello,\nYou have requested that the authentication server send you a new password:\nUsername: ") .$this->getUsername()._("\nPassword: ").$new_password._("\n\nHave a nice day,\nThe Team"));526 $mail->setMessageSubject($network->getName() . _(" new password request")); 527 $mail->setMessageBody(_("Hello,\nYou have requested that the authentication server send you a new password:\nUsername: ") . $this->getUsername() . _("\nPassword: ") . $new_password . _("\n\nHave a nice day,\nThe Team")); 605 528 $mail->send(); 606 529 } 607 530 608 static function userExists($id) 609 { 531 static function userExists($id) { 610 532 global $db; 611 533 $id_str = $db->escapeString($id); … … 615 537 } 616 538 617 public static function emailExists($id) 618 { 539 public static function emailExists($id) { 619 540 global $db; 620 541 $id_str = $db->escapeString($id); … … 624 545 } 625 546 626 public static function randomPass() 627 { 547 public static function randomPass() { 628 548 $rand_pass = ''; // makes sure the $pass var is empty. 629 for ($j = 0; $j < 3; $j ++) 630 { 631 $startnend = array ('b', 'c', 'd', 'f', 'g', 'h', 'j', 'k', 'l', 'm', 'n', 'p', 'q', 'r', 's', 't', 'v', 'w', 'x', 'y', 'z',); 632 $id = array ('a', 'e', 'i', 'o', 'u', 'y',); 549 for ($j = 0; $j < 3; $j++) { 550 $startnend = array ( 551 'b', 552 'c', 553 'd', 554 'f', 555 'g', 556 'h', 557 'j', 558 'k', 559 'l', 560 'm', 561 'n', 562 'p', 563 'q', 564 'r', 565 's', 566 't', 567 'v', 568 'w', 569 'x', 570 'y', 571 'z', 572 573 ); 574 $id = array ( 575 'a', 576 'e', 577 'i', 578 'o', 579 'u', 580 'y', 581 582 ); 633 583 $count1 = count($startnend) - 1; 634 584 $count2 = count($id) - 1; 635 585 636 for ($i = 0; $i < 3; $i ++) 637 { 638 if ($i != 1) 639 { 586 for ($i = 0; $i < 3; $i++) { 587 if ($i != 1) { 640 588 $rand_pass .= $startnend[rand(0, $count1)]; 641 } 642 else 643 { 589 } else { 644 590 $rand_pass .= $id[rand(0, $count2)]; 645 591 } … … 649 595 } 650 596 651 public static function generateToken() 652 { 597 public static function generateToken() { 653 598 return md5(uniqid(rand(), 1)); 654 599 } … … 663 608 * 664 609 * @return string HTML markup 665 666 */ 667 public static function getSelectUserUI($user_prefix, $add_button_name = null, $add_button_value = null) 668 { 610 611 */ 612 public static function getSelectUserUI($user_prefix, $add_button_name = null, $add_button_value = null) { 669 613 // Define globals 670 614 global $db; 671 615 672 $_networkSelector = InterfaceElements ::generateDiv(Network::getSelectNetworkUI($user_prefix), "admin_section_network_selector", "admin_section_network_selector_" . $user_prefix);616 $_networkSelector = InterfaceElements :: generateDiv(Network :: getSelectNetworkUI($user_prefix), "admin_section_network_selector", "admin_section_network_selector_" . $user_prefix); 673 617 674 618 // Check if we need to add an "add" button 675 619 if ($add_button_name && $add_button_value) { 676 $_userSelector = _("Username") . ": " . InterfaceElements::generateInputText("select_user_" . $user_prefix . "_username", "", "", "input_text", array("onkeypress" => "if ((event.which ? event.which : event.keyCode) == 13) {form.$add_button_name.click() }")); 677 $_userSelector .= InterfaceElements::generateInputSubmit($add_button_name, $add_button_value); 620 $_userSelector = _("Username") . ": " . InterfaceElements :: generateInputText("select_user_" . $user_prefix . "_username", "", "", "input_text", array ( 621 "onkeypress" => "if ((event.which ? event.which : event.keyCode) == 13) {form.$add_button_name.click() }" 622 )); 623 $_userSelector .= InterfaceElements :: generateInputSubmit($add_button_name, $add_button_value); 678 624 } else { 679 $_userSelector = _("Username") . ": " . InterfaceElements::generateInputText("select_user_" . $user_prefix . "_username");680 } 681 $_html = InterfaceElements ::generateDiv($_networkSelector . $_userSelector, 'user_select_user_ui_container');625 $_userSelector = _("Username") . ": " . InterfaceElements :: generateInputText("select_user_" . $user_prefix . "_username"); 626 } 627 $_html = InterfaceElements :: generateDiv($_networkSelector . $_userSelector, 'user_select_user_ui_container'); 682 628 683 629 return $_html; … … 688 634 * @return the User object, or null if the user is invalid or none was selected 689 635 */ 690 static function processSelectUserUI($user_prefix) 691 { 636 static function processSelectUserUI($user_prefix) { 692 637 $object = null; 693 try 694 { 638 try { 695 639 $network = Network :: processSelectNetworkUI($user_prefix); 696 640 $name = "select_user_{$user_prefix}_username"; 697 if (!empty ($_REQUEST[$name])) 698 { 641 if (!empty ($_REQUEST[$name])) { 699 642 $username = $_REQUEST[$name]; 700 643 return self :: getUserByUsernameAndOrigin($username, $network); 701 } 702 else 644 } else 703 645 return null; 704 } 705 catch (Exception $e) 706 { 646 } catch (Exception $e) { 707 647 return null; 708 648 } 709 649 } 710 650 711 public function getAdminUI() 712 { 713 global $db; 714 $currentUser= self::getCurrentUser(); 651 public function getAdminUI() { 652 global $db; 653 $currentUser = self :: getCurrentUser(); 715 654 $html = ''; 716 $html .= "<fieldset class='admin_container " .get_class($this)."'>\n";655 $html .= "<fieldset class='admin_container " . get_class($this) . "'>\n"; 717 656 $html .= "<ul class='admin_element_list'>\n"; 718 if($this==$currentUser || $this->getNetwork()->hasAdminAccess($currentUser)) 719 { 720 //username 721 $html .= "<li class='admin_element_item_container'>\n"; 722 $html .= "<div class='admin_element_label'>"._("Username")." : </div>\n"; 723 $html .= "<div class='admin_element_data'>\n"; 724 $name = "user_".$this->getId()."_username"; 725 $html .= "<input type='text' name='$name' value='".htmlentities($this->getUsername())."' size=30>\n"; 726 $html .= _("Be carefull when changing this: it's the username you use to log in!"); 727 $html .= "</div>\n"; 728 $html .= "</li>\n"; 729 } 730 /* 731 $html .= "<li class='admin_element_item_container'>\n"; 732 $html .= "<div class='admin_element_label'>"._("Real name")." : </div>\n"; 733 $html .= "<div class='admin_element_data'>\n"; 734 $name = "user_".$this->getId()."_real_name"; 735 $html .= "<input type='text' name='$name' value='".htmlentities($this->getRealName())."' size=30 readonly>\n"; 736 $html .= "</div>\n"; 737 $html .= "</li>\n"; 738 739 $html .= "<li class='admin_element_item_container'>\n"; 740 $html .= "<div class='admin_element_label'>"._("Website URL")." : </div>\n"; 741 $html .= "<div class='admin_element_data'>\n"; 742 $name = "user_".$this->getId()."_website"; 743 $html .= "<input type='text' name='$name' value='".htmlentities($this->getWebsiteURL())."' size=30 readonly>\n"; 744 $html .= "</div>\n"; 745 $html .= "</li>\n"; 746 */ 657 if (($this == $currentUser && !$this->isSplashOnlyUser() )|| $this->getNetwork()->hasAdminAccess($currentUser)) { 658 //username 659 $html .= "<li class='admin_element_item_container'>\n"; 660 $html .= "<div class='admin_element_label'>" . _("Username") . " : </div>\n"; 661 $html .= "<div class='admin_element_data'>\n"; 662 $name = "user_" . $this->getId() . "_username"; 663 $html .= "<input type='text' name='$name' value='" . htmlentities($this->getUsername()) . "' size=30>\n"; 664 $html .= _("Be carefull when changing this: it's the username you use to log in!"); 665 $html .= "</div>\n"; 666 $html .= "</li>\n"; 667 } 668 /* 669 $html .= "<li class='admin_element_item_container'>\n"; 670 $html .= "<div class='admin_element_label'>"._("Real name")." : </div>\n"; 671 $html .= "<div class='admin_element_data'>\n"; 672 $name = "user_".$this->getId()."_real_name"; 673 $html .= "<input type='text' name='$name' value='".htmlentities($this->getRealName())."' size=30 readonly>\n"; 674 $html .= "</div>\n"; 675 $html .= "</li>\n"; 676 677 $html .= "<li class='admin_element_item_container'>\n"; 678 $html .= "<div class='admin_element_label'>"._("Website URL")." : </div>\n"; 679 $html .= "<div class='admin_element_data'>\n"; 680 $name = "user_".$this->getId()."_website"; 681 $html .= "<input type='text' name='$name' value='".htmlentities($this->getWebsiteURL())."' size=30 readonly>\n"; 682 $html .= "</div>\n"; 683 $html .= "</li>\n"; 684 */ 747 685 $html .= "</fieldset>\n"; 748 686 return $html; 749 687 } 750 688 751 public function processAdminUI() 752 { 753 global $db; 754 $currentUser= self::getCurrentUser(); 755 if($this==$currentUser || $this->getNetwork()->hasAdminAccess($currentUser)) 756 { 757 //username 758 $name = "user_".$this->getId()."_username"; 759 $this->setUsername($_REQUEST[$name]); 760 } 761 } 762 763 public function delete(& $errmsg) 764 { 765 } 766 767 public function getUserUI() 768 { 689 public function processAdminUI() { 690 global $db; 691 $currentUser = self :: getCurrentUser(); 692 if ($this == $currentUser || $this->getNetwork()->hasAdminAccess($currentUser)) { 693 //username 694 $name = "user_" . $this->getId() . "_username"; 695 $this->setUsername($_REQUEST[$name]); 696 } 697 } 698 699 public function delete(& $errmsg) { 700 } 701 702 public function getUserUI() { 769 703 $html = ""; 770 704 $html .= $this->getRealName(); 771 705 772 706 return $html; 773 }707 } 774 708 775 709 /** Add content to this user ( subscription ) */ 776 public function addContent(Content $content) 777 { 710 public function addContent(Content $content) { 778 711 global $db; 779 712 $content_id = $db->escapeString($content->getId()); … … 784 717 785 718 /** Remove content from this node */ 786 public function removeContent(Content $content) 787 { 719 public function removeContent(Content $content) { 788 720 global $db; 789 721 $content_id = $db->escapeString($content->getId()); … … 795 727 /**Get an array of all Content linked to this node 796 728 * @return an array of Content or an empty arrray */ 797 function getAllContent() 798 { 729 function getAllContent() { 799 730 global $db; 800 731 $retval = array (); 801 732 $sql = "SELECT * FROM user_has_content WHERE user_id='$this->id' ORDER BY subscribe_timestamp"; 802 733 $db->execSql($sql, $content_rows, false); 803 if ($content_rows != null) 804 { 805 foreach ($content_rows as $content_row) 806 { 734 if ($content_rows != null) { 735 foreach ($content_rows as $content_row) { 807 736 $retval[] = Content :: getObject($content_row['content_id']); 808 737 } … … 812 741 813 742 /** Reloads the object from the database. Should normally be called after a set operation */ 814 protected function refresh() 815 { 816 $this->__construct($this->id); 743 protected function refresh() { 744 $this->__construct($this->id); 817 745 } 818 746 819 747 /** Set Smarty template values. Standardization routine. */ 820 public static function assignSmartyValues($smarty, $user=null) { 821 if (!$user) $user = User::getCurrentUser(); 822 $smarty->assign('username', $user ? $user->getUsername() : ''); 748 public static function assignSmartyValues($smarty, $user = null) { 749 if (!$user) 750 $user = User :: getCurrentUser(); 751 $smarty->assign('username', $user ? $user->getListUI() : ''); 823 752 $smarty->assign('userId', $user ? $user->getId() : ''); 824 /**825 * Define user security levels for the template826 *827 * These values are used in the default template of WiFoDog but could be828 * used in a customized template to restrict certain links to specific829 * user access levels.830 */831 $smarty->assign('isValidUser', $user? true : false);832 $smarty->assign('isSuperAdmin', $user && $user->isSuperAdmin());833 $smarty->assign('isOwner', $user && $user->isOwner());753 /** 754 * Define user security levels for the template 755 * 756 * These values are used in the default template of WiFoDog but could be 757 * used in a customized template to restrict certain links to specific 758 * user access levels. 759 */ 760 $smarty->assign('isValidUser', $user && !$user->isSplashOnlyUser() ? true : false); 761 $smarty->assign('isSuperAdmin', $user && $user->isSuperAdmin()); 762 $smarty->assign('isOwner', $user && $user->isOwner()); 834 763 835 764 if (isset ($_REQUEST['debug_request']) && ($user && $user->isSuperAdmin())) { … … 838 767 $smarty->assign('debugOutput', print_r($_REQUEST, true)); 839 768 } 840 }769 } 841 770 } 842 771 … … 848 777 * End: 849 778 */ 850 -
trunk/wifidog-auth/wifidog/content/index.php
r1030 r1092 52 52 require_once('include/common_interface.php'); 53 53 require_once('classes/Node.php'); 54 55 if (CONF_USE_CRON_FOR_DB_CLEANUP == false)56 {57 garbage_collect();58 }59 54 60 55 $node = null; … … 142 137 foreach ($contents as $content) 143 138 { 144 $html .= "<div class='portal_content'>\n";145 139 $html .= $content->getUserUI(); 146 $html .= "</div>";147 140 } 148 141 $html .= "</div>\n"; -
trunk/wifidog-auth/wifidog/include/common.php
r1079 r1092 194 194 $tzd = substr(chunk_split($tzd, 3, ':'), 0, 6); 195 195 $date = date('Y-m-d\TH:i:s', $unix_timestamp).$tzd; 196 197 196 return $date; 198 197 } -
trunk/wifidog-auth/wifidog/login/index.php
r1090 r1092 219 219 * Once logged out, we display the login page 220 220 */ 221 if ((!empty($logout) && $logout) && ($user = User::getCurrentUser()) != null ) {221 if ((!empty($logout) && $logout) && ($user = User::getCurrentUser()) != null && !$user->isSplashOnlyUser()) { 222 222 $network->getAuthenticator()->logout(); 223 223 } -
trunk/wifidog-auth/wifidog/media/base_theme/stylesheet.css
r1085 r1092 493 493 } 494 494 495 .portal_content {496 }497 495 .user_ui_main_outer { 498 496 /* display: inline;*/ … … 504 502 padding: 0.1em; 505 503 } 504 505 .isSimpleContent{ 506 background: none; 507 border: none; 508 margin: 0em; 509 padding: 0.1em; 510 } 511 506 512 .user_ui_title .user_ui_main_outer, 507 513 .user_ui_description .user_ui_main_outer { -
trunk/wifidog-auth/wifidog/templates/classes/MainUI_ToolSection.tpl
r1090 r1092 77 77 <ul> 78 78 <li><a href="{$base_url_path}admin/generic_object_admin.php?object_class=Node&action=list">{"Nodes"|_}</a></li> 79 <li><a href="{$base_url_path}admin/generic_object_admin.php?object_class=Node&action=new_ui">{"Add new Node"|_}</a></li>80 79 </ul> 81 80 {/if} … … 94 93 <ul> 95 94 <li><a href="{$base_url_path}admin/generic_object_admin.php?object_class=Server&action=list">{"Servers"|_}</a></li> 96 <li><a href="{$base_url_path}admin/generic_object_admin.php?object_class=Content&action=list">{" Content library"|_}</a></li>95 <li><a href="{$base_url_path}admin/generic_object_admin.php?object_class=Content&action=list">{"Reusable content library"|_}</a></li> 97 96 </ul> 98 97 </fieldset>
