Changeset 1431
- Timestamp:
- 11/18/09 09:40:57 (3 years ago)
- Location:
- branches/gbastien/wifidog
- Files:
-
- 3 added
- 8 modified
-
classes/Content.php (modified) (1 diff)
-
classes/HotspotGraph.php (added)
-
classes/HotspotGraphElement.php (added)
-
classes/Menu.php (modified) (1 diff)
-
classes/Network.php (modified) (9 diffs)
-
classes/Node.php (modified) (8 diffs)
-
classes/NodeGroup.php (added)
-
classes/Permission.php (modified) (2 diffs)
-
classes/StakeholderType.php (modified) (1 diff)
-
include/schema_validate.php (modified) (2 diffs)
-
portal/index.php (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/gbastien/wifidog/classes/Content.php
r1421 r1431 788 788 $rows = null; 789 789 $db->execSql($current_content_sql, $rows, false); 790 790 791 if ($rows) 791 792 foreach ($rows as $row) { -
branches/gbastien/wifidog/classes/Menu.php
r1421 r1431 188 188 $this->processHookMenu('Server'); 189 189 $this->processHookMenu('Node'); 190 $this->processHookMenu('NodeGroup'); 190 191 $this->processHookMenu('Network'); 191 192 $this->processHookMenu('User'); -
branches/gbastien/wifidog/classes/Network.php
r1428 r1431 55 55 require_once('classes/ThemePack.php'); 56 56 require_once('classes/Security.php'); 57 require_once('classes/HotspotGraphElement.php'); 57 58 58 59 /** … … 71 72 /** Object cache for the object factory (getObject())*/ 72 73 private static $instanceArray = array(); 74 protected $_hotspotGraphElement; 73 75 74 76 /** … … 201 203 throw new Exception(_('Unable to insert the new network in the database!')); 202 204 } 205 206 HotspotGraphElement::createNewObject($network_id, 'Network'); 207 203 208 $object = self::getObject($network_id); 204 209 require_once('classes/Stakeholder.php'); … … 378 383 { 379 384 $db = AbstractDb::getObject(); 385 if ($p_network_id == "") 386 $p_network_id = self::getDefaultNetwork()->getId(); 380 387 $network_id_str = $db->escapeString($p_network_id); 381 if ($network_id_str == "")382 $network_id_str = $db->escapeString(self::getDefaultNetwork()->getId());383 388 384 389 $sql = "SELECT *, EXTRACT(EPOCH FROM validation_grace_time) as validation_grace_time_seconds FROM networks WHERE network_id='$network_id_str'"; … … 390 395 $this->_row = $row; 391 396 $this->_id = $p_network_id; 397 $this->_hotspotGraphElement = HotspotGraphElement::getObject($this->_id,'Network'); 392 398 } 393 399 … … 1696 1702 * Content management 1697 1703 */ 1698 $title = _("Network content");1704 /* $title = _("Network content"); 1699 1705 $name = "network_".$this->_id."_content"; 1700 1706 $data = Content::getLinkedContentUI($name, "network_has_content", "network_id", $this->_id, $display_page = "portal"); 1701 $html .= InterfaceElements::generateAdminSectionContainer("network_content", $title, $data); 1707 $html .= InterfaceElements::generateAdminSectionContainer("network_content", $title, $data);*/ 1708 if (!is_null($this->_hotspotGraphElement)) 1709 $html .= $this->_hotspotGraphElement->getContentAdminUI(); 1702 1710 1703 1711 /* … … 1927 1935 $data = ProfileTemplate::getLinkedProfileTemplateUI($name, "network_has_profile_templates", "network_id", $this->_id); 1928 1936 $html .= InterfaceElements::generateAdminSectionContainer("network_profile_templates", $title, $data); 1937 1938 // objects hierarchy 1939 if (!is_null($this->_hotspotGraphElement)) 1940 $html .= $this->_hotspotGraphElement->getGraphAdminUI($this); 1929 1941 1930 1942 $html .= "</ul>\n"; … … 1946 1958 1947 1959 // Content management 1948 $name = "network_".$this->_id."_content"; 1949 Content :: processLinkedContentUI($name, 'network_has_content', 'network_id', $this->_id); 1960 if (!is_null($this->_hotspotGraphElement)) 1961 $this->_hotspotGraphElement->processContentAdminUI(); 1962 /* $name = "network_".$this->_id."_content"; 1963 Content :: processLinkedContentUI($name, 'network_has_content', 'network_id', $this->_id);*/ 1950 1964 1951 1965 // name … … 2064 2078 $name = "network_".$this->_id."_profile_templates"; 2065 2079 ProfileTemplate :: processLinkedProfileTemplateUI($name, 'network_has_profile_templates', 'network_id', $this->_id); 2080 2081 if (!is_null($this->_hotspotGraphElement)) 2082 $this->_hotspotGraphElement->processGraphAdminUI($errMsg, $this); 2083 if(!empty($errMsg)) { 2084 echo $errMsg; 2085 $errMsg = null; 2086 } 2066 2087 2067 2088 // Node creation -
branches/gbastien/wifidog/classes/Node.php
r1419 r1431 50 50 require_once('classes/Utils.php'); 51 51 require_once('classes/DateTimeWD.php'); 52 require_once('classes/HotspotGraphElement.php'); 52 53 53 54 /** … … 69 70 private $id; 70 71 private static $currentNode = null; 72 protected $_hotspotGraphElement; 71 73 72 74 /** … … 287 289 } 288 290 291 HotspotGraphElement::createNewObject($node_id, 'Node'); 292 289 293 $object = self::getObject($node_id); 290 294 … … 693 697 $this->_row = $row; 694 698 $this->id = $row['node_id']; 699 700 $this->_hotspotGraphElement = HotspotGraphElement::getObject($this->id, 'Node'); 695 701 } 696 702 … … 1187 1193 1188 1194 //Node content 1189 $_html_content = array();1195 /*$_html_content = array(); 1190 1196 $_title = _("Node content"); 1191 1197 $_data = Content::getLinkedContentUI("node_" . $node_id . "_content", "node_has_content", "node_id", $this->id, "portal"); 1192 $html .= InterfaceElements::generateAdminSectionContainer("node_content", $_title, $_data); 1193 1198 $html .= InterfaceElements::generateAdminSectionContainer("node_content", $_title, $_data);*/ 1199 if (!is_null($this->_hotspotGraphElement)) 1200 $html .= $this->_hotspotGraphElement->getContentAdminUI(); 1201 1194 1202 // Name 1195 1203 $permArray = null; … … 1362 1370 $html .= InterfaceElements::generateAdminSectionContainer("access_rights", _("Access rights"), $html_access_rights); 1363 1371 } 1372 1373 //Node hierarchy 1374 if (!is_null($this->_hotspotGraphElement)) 1375 $html .= $this->_hotspotGraphElement->getGraphAdminUI($network); 1364 1376 1365 1377 $html .= "</ul>\n"; … … 1404 1416 } 1405 1417 // Content processing 1406 $name = "node_{$node_id}_content"; 1407 Content::processLinkedContentUI($name, 'node_has_content', 'node_id', $this->id); 1418 if (!is_null($this->_hotspotGraphElement)) 1419 $this->_hotspotGraphElement->processContentAdminUI(); 1420 /*$name = "node_{$node_id}_content"; 1421 Content::processLinkedContentUI($name, 'node_has_content', 'node_id', $this->id);*/ 1408 1422 1409 1423 // Name … … 1566 1580 1567 1581 // End Node configuration section 1582 1583 if (!is_null($this->_hotspotGraphElement)) 1584 $this->_hotspotGraphElement->processGraphAdminUI($errMsg, $network); 1585 if(!empty($errMsg)) { 1586 echo $errMsg; 1587 $errMsg = null; 1588 } 1568 1589 1569 1590 // Access rights -
branches/gbastien/wifidog/classes/Permission.php
r1421 r1431 89 89 $PERMISSIONS['NETWORK_PERM_VIEW_STATISTICS'] = array(_("User is allowed to view all statistics for this network"), StakeholderType::Network, true); 90 90 $PERMISSIONS['NETWORK_PERM_EDIT_ANY_NODE_CONFIG'] = array(_("User is allowed to edit any configuration of any node on the network"), StakeholderType::Network, true); 91 $PERMISSIONS['NETWORK_PERM_EDIT_ANY_NODEGROUP_CONFIG'] = array(_("User is allowed to edit any configuration of any node group on the network"), StakeholderType::Network, true); 91 92 $PERMISSIONS['NETWORK_PERM_ADD_NODE'] = array(_("User is allowed to create a new Node on this network"), StakeholderType::Network, true); 93 $PERMISSIONS['NETWORK_PERM_ADD_NODEGROUP'] = array(_("User is allowed to create a new Node Group on this network"), StakeholderType::Network, true); 92 94 $PERMISSIONS['NETWORK_PERM_EDIT_DYNAMIC_ABUSE_CONTROL'] = array(_("User is allowed to set dynamic abuse control options for the network"), StakeholderType::Network, false); 95 $PERMISSIONS['NETWORK_PERM_ALLOW_GROUP_NODE'] = array(_("User is allowed group nodes into virtual node groups"), StakeholderType::Network, false); 93 96 94 97 $PERMISSIONS['SERVER_PERM_EDIT_ROLES'] = array(_("User is allowed to edit user role definitions"), StakeholderType::Server, true); … … 107 110 $PERMISSIONS['NODE_PERM_BYPASS_DYNAMIC_ABUSE_CONTROL'] = array(_("User is allowed to exceed dynamic abuse control limits at this node"), StakeholderType::Node, false); 108 111 $PERMISSIONS['NODE_PERM_ALLOW_GENERATING_PUBLIC_STATS'] = array(_("User is allowed to turn on publicly accessible aggregate statistics for this node"), StakeholderType::Node, false); 112 113 $PERMISSIONS['NODEGROUP_PERM_DELETE_NODEGROUP'] = array(_("User is allowed to delete this node group"), StakeholderType::NodeGroup, true); 114 $PERMISSIONS['NODEGROUP_PERM_EDIT_ANY_NODEGROUP_CONFIG'] = array(_("User is allowed to edit any configuration of any node group on the network"), StakeholderType::NodeGroup, true); 115 $PERMISSIONS['NODEGROUP_PERM_EDIT_NODEGROUP_CONFIG'] = array(_("User is allowed to edit any configuration of this node group"), StakeholderType::NodeGroup, true); 116 $PERMISSIONS['NODEGROUP_PERM_ADD_NODEGROUP'] = array(_("User is allowed to create a new Node Group on this network"), StakeholderType::NodeGroup, true); 109 117 110 118 self::$_permissionArray = $PERMISSIONS; -
branches/gbastien/wifidog/classes/StakeholderType.php
r1419 r1431 64 64 const Server = 'Server'; 65 65 const Content = 'Content'; 66 const NodeGroup = 'NodeGroup'; 67 66 68 /** 67 69 * Get an instance of the object -
branches/gbastien/wifidog/include/schema_validate.php
r1428 r1431 48 48 * Define current database schema version 49 49 */ 50 define('REQUIRED_SCHEMA_VERSION', 6 7);50 define('REQUIRED_SCHEMA_VERSION', 68); 51 51 /** Used to test a new shecma version before modyfying the database */ 52 52 define('SCHEMA_UPDATE_TEST_MODE', false); … … 1456 1456 } 1457 1457 1458 $new_schema_version = 68; 1459 if ($schema_version < $new_schema_version && $new_schema_version <= $targetSchema) { 1460 printUpdateVersion($new_schema_version); 1461 $sql .= "\n\nUPDATE schema_info SET value='$new_schema_version' WHERE tag='schema_version';\n"; 1462 1463 $sql .= "CREATE TABLE node_groups \n"; 1464 $sql .= "( \n"; 1465 $sql .= "node_group_id character varying(32) PRIMARY KEY, \n"; 1466 $sql .= "name text, \n"; 1467 $sql .= "description text , \n"; 1468 $sql .= "group_creation_date timestamp NOT NULL DEFAULT now() \n"; 1469 $sql .= ");\n\n"; 1470 1471 $sql .= "CREATE TABLE hotspot_graph_elements \n"; 1472 $sql .= "( \n"; 1473 $sql .= "hotspot_graph_element_id character varying(32) PRIMARY KEY, \n"; 1474 $sql .= "element_id text, \n"; 1475 $sql .= "element_type character varying(16) \n"; 1476 $sql .= ");\n\n"; 1477 1478 $sql .= "CREATE TABLE hotspot_graph \n"; 1479 $sql .= "( \n"; 1480 $sql .= "child_element_id character varying(32) REFERENCES hotspot_graph_elements (hotspot_graph_element_id) ON UPDATE CASCADE ON DELETE CASCADE NOT NULL , \n"; 1481 $sql .= "parent_element_id character varying(32) REFERENCES hotspot_graph_elements (hotspot_graph_element_id) ON UPDATE CASCADE ON DELETE CASCADE NOT NULL , \n"; 1482 $sql .= "link_order integer DEFAULT 1 , \n"; 1483 $sql .= "PRIMARY KEY(child_element_id, parent_element_id) \n"; 1484 $sql .= ");\n\n"; 1485 1486 $sql .= "CREATE TABLE hotspot_graph_element_has_content (\n"; 1487 $sql .= "hotspot_graph_element_id character varying(32) REFERENCES hotspot_graph_elements (hotspot_graph_element_id) ON UPDATE CASCADE ON DELETE CASCADE NOT NULL ,\n"; 1488 $sql .= "content_id text NOT NULL,\n"; 1489 $sql .= "subscribe_timestamp timestamp without time zone DEFAULT now() NOT NULL,\n"; 1490 $sql .= "display_page text DEFAULT 'portal'::text NOT NULL,\n"; 1491 $sql .= "display_area text DEFAULT 'main_area_middle'::text NOT NULL,\n"; 1492 $sql .= "display_order integer DEFAULT 1 NOT NULL\n"; 1493 $sql .= ");\n\n"; 1494 1495 $sql .= "INSERT INTO stakeholder_types (stakeholder_type_id) VALUES ('NodeGroup');\n"; 1496 1497 //$networks = Network::getAllNetworks(); 1498 $networks = array(); 1499 $db->execSql("Select network_id from networks", $networks, false); 1500 foreach ($networks as $network) { 1501 $new_guid = get_guid(); 1502 $sql .= "INSERT INTO hotspot_graph_elements values('{$new_guid}', '{$network['network_id']}', 'Network' );\n "; 1503 $nodes = array(); 1504 $db->execSql("SELECT node_id FROM nodes where network_id = '{$network['network_id']}'", $nodes, false); 1505 foreach ($nodes as $node) { 1506 $node_guid = get_guid(); 1507 $sql .= "INSERT INTO hotspot_graph_elements values('{$node_guid}', '{$node['node_id']}', 'Node' );\n "; 1508 $sql .= "INSERT INTO hotspot_graph(child_element_id, parent_element_id) VALUES ('{$node_guid}', '{$new_guid}');\n"; 1509 } 1510 } 1511 1512 $sql .= "INSERT INTO hotspot_graph_element_has_content (\n"; 1513 $sql .= "SELECT hge.hotspot_graph_element_id, content_id, subscribe_timestamp, display_page, display_area, display_order \n"; 1514 $sql .= "FROM hotspot_graph_elements hge inner join network_has_content nhc on nhc.network_id = hge.element_id \n"; 1515 $sql .= "WHERE hge.element_type = 'Network');\n\n"; 1516 1517 $sql .= "INSERT INTO hotspot_graph_element_has_content (\n"; 1518 $sql .= "SELECT hge.hotspot_graph_element_id, content_id, subscribe_timestamp, display_page, display_area, display_order \n"; 1519 $sql .= "FROM hotspot_graph_elements hge inner join node_has_content nhc on nhc.node_id = hge.element_id \n"; 1520 $sql .= "WHERE hge.element_type = 'Node');\n\n"; 1521 1522 $sql .= "CREATE TABLE nodegroup_stakeholders (\n"; 1523 $sql .= ")\n"; 1524 $sql .= "INHERITS (stakeholders);\n\n"; 1525 } 1526 1527 1458 1528 /* 1459 1529 $new_schema_version = ; -
branches/gbastien/wifidog/portal/index.php
r1421 r1431 166 166 } 167 167 168 // Get all the parent objects of the node 169 $parents = HotspotGraph::getAllParents(HotspotGraphElement::getObjectFor($node)); 170 171 // Get the contents for all elements parents of and including the node, but exclude user subscribed content if user is known 172 foreach($parents as $parentid) { 173 $content_rows = array (); 174 $parent_id = $db->escapeString($parentid); 175 if ($current_user) { 176 $user_id = $db->escapeString($current_user->getId()); 177 $sql = "SELECT content_id, display_area, display_order FROM hotspot_graph_element_has_content hgehc "; 178 $sql .= "INNER JOIN hotspot_graph_elements hge on hgehc.hotspot_graph_element_id = hge.hotspot_graph_element_id "; 179 $sql .= "WHERE hge.hotspot_graph_element_id='$parent_id' AND display_page='portal' AND content_id NOT IN (SELECT content_id FROM user_has_content WHERE user_id = '{$user_id}') ORDER BY display_area, display_order, subscribe_timestamp DESC"; 180 } else { 181 $sql = "SELECT content_id, display_area, display_order FROM hotspot_graph_element_has_content hgehc "; 182 $sql .= "INNER JOIN hotspot_graph_elements hge on hgehc.hotspot_graph_element_id = hge.hotspot_graph_element_id "; 183 $sql .= "WHERE hge.hotspot_graph_element_id='$parent_id' AND display_page='portal' ORDER BY display_area, display_order, subscribe_timestamp DESC"; 184 } 185 $db->execSql($sql, $content_rows, false); 186 if ($content_rows) { 187 foreach ($content_rows as $content_row) { 188 $content = Content :: getObject($content_row['content_id']); 189 if ($content->isDisplayableAt($node)) { 190 $ui->addContent($content_row['display_area'], $content, $content_row['display_order']); 191 } 192 } 193 } 194 } 195 $showMoreLink = false; 196 168 197 // Get all network content, but exclude user subscribed content if user is known 169 $content_rows = array ();198 /*$content_rows = array (); 170 199 $network_id = $db->escapeString($network->getId()); 171 200 if ($current_user) { 172 201 $user_id = $db->escapeString($current_user->getId()); 173 $sql = "SELECT content_id, display_area, display_order FROM network_has_content WHERE network_id='$network_id' AND display_page='portal' AND content_id NOT IN (SELECT content_id FROM user_has_content WHERE user_id = '{$user_id}') ORDER BY display_area, display_order, subscribe_timestamp DESC"; 202 $sql = "SELECT content_id, display_area, display_order FROM hotspot_graph_element_has_content hgehc "; 203 $sql .= "INNER JOIN hotspot_graph_elements hge on hgehc.hotspot_graph_element_id = hge.hotspot_graph_element_id "; 204 $sql .= "WHERE hge.element_id='$network_id' AND hge.element_type = 'Network' AND display_page='portal' AND content_id NOT IN (SELECT content_id FROM user_has_content WHERE user_id = '{$user_id}') ORDER BY display_area, display_order, subscribe_timestamp DESC"; 174 205 } else { 175 $sql = "SELECT content_id, display_area, display_order FROM network_has_content WHERE network_id='$network_id' AND display_page='portal' ORDER BY display_area, display_order, subscribe_timestamp DESC"; 206 $sql = "SELECT content_id, display_area, display_order FROM hotspot_graph_element_has_content hgehc "; 207 $sql .= "INNER JOIN hotspot_graph_elements hge on hgehc.hotspot_graph_element_id = hge.hotspot_graph_element_id "; 208 $sql .= "WHERE hge.element_id='$network_id' AND hge.element_type = 'Network' AND display_page='portal' ORDER BY display_area, display_order, subscribe_timestamp DESC"; 176 209 } 177 210 $db->execSql($sql, $content_rows, false); … … 183 216 } 184 217 } 185 } 218 }*/ 186 219 187 220 // Get all node content and EXCLUDE user subscribed content 188 $content_rows = array ();221 /*$content_rows = array (); 189 222 $node_id = $db->escapeString($node->getId()); 190 223 if ($current_user) { 191 224 $user_id = $db->escapeString($current_user->getId()); 192 $sql = "SELECT content_id, display_area, display_order FROM node_has_content WHERE node_id='$node_id' AND display_page='portal' AND content_id NOT IN (SELECT content_id FROM user_has_content WHERE user_id = '{$user_id}') ORDER BY display_area, display_order, subscribe_timestamp DESC"; 225 $sql = "SELECT content_id, display_area, display_order FROM hotspot_graph_element_has_content hgehc "; 226 $sql .= "INNER JOIN hotspot_graph_elements hge on hgehc.hotspot_graph_element_id = hge.hotspot_graph_element_id "; 227 $sql .= "WHERE hge.element_id='$node_id' AND hge.element_type = 'Node' AND display_page='portal' AND content_id NOT IN (SELECT content_id FROM user_has_content WHERE user_id = '{$user_id}') ORDER BY display_area, display_order, subscribe_timestamp DESC"; 193 228 } else { 194 $sql = "SELECT content_id, display_area, display_order FROM node_has_content WHERE node_id='$node_id' AND display_page='portal' ORDER BY display_area, display_order, subscribe_timestamp DESC"; 229 $sql = "SELECT content_id, display_area, display_order FROM hotspot_graph_element_has_content hgehc "; 230 $sql .= "INNER JOIN hotspot_graph_elements hge on hgehc.hotspot_graph_element_id = hge.hotspot_graph_element_id "; 231 $sql .= "WHERE hge.element_id='$node_id' AND hge.element_type = 'Node' AND display_page='portal' ORDER BY display_area, display_order, subscribe_timestamp DESC"; 195 232 } 196 233 $db->execSql($sql, $content_rows, false); … … 203 240 } 204 241 } 205 } 242 }*/ 206 243 207 244 // Get all user content
