Changeset 1431

Show
Ignore:
Timestamp:
11/18/09 09:40:57 (3 years ago)
Author:
gbastien
Message:

Addition of groups and hotspot graphs

Location:
branches/gbastien/wifidog
Files:
3 added
8 modified

Legend:

Unmodified
Added
Removed
  • branches/gbastien/wifidog/classes/Content.php

    r1421 r1431  
    788788        $rows = null; 
    789789        $db->execSql($current_content_sql, $rows, false); 
     790      
    790791        if ($rows) 
    791792        foreach ($rows as $row) { 
  • branches/gbastien/wifidog/classes/Menu.php

    r1421 r1431  
    188188        $this->processHookMenu('Server'); 
    189189        $this->processHookMenu('Node'); 
     190        $this->processHookMenu('NodeGroup'); 
    190191        $this->processHookMenu('Network'); 
    191192        $this->processHookMenu('User'); 
  • branches/gbastien/wifidog/classes/Network.php

    r1428 r1431  
    5555require_once('classes/ThemePack.php'); 
    5656require_once('classes/Security.php'); 
     57require_once('classes/HotspotGraphElement.php'); 
    5758 
    5859/** 
     
    7172    /** Object cache for the object factory (getObject())*/ 
    7273    private static $instanceArray = array(); 
     74    protected $_hotspotGraphElement; 
    7375 
    7476    /** 
     
    201203            throw new Exception(_('Unable to insert the new network in the database!')); 
    202204        } 
     205         
     206        HotspotGraphElement::createNewObject($network_id, 'Network'); 
     207         
    203208        $object = self::getObject($network_id); 
    204209        require_once('classes/Stakeholder.php'); 
     
    378383    { 
    379384        $db = AbstractDb::getObject(); 
     385        if ($p_network_id == "") 
     386            $p_network_id = self::getDefaultNetwork()->getId(); 
    380387        $network_id_str = $db->escapeString($p_network_id); 
    381         if ($network_id_str == "") 
    382         $network_id_str = $db->escapeString(self::getDefaultNetwork()->getId()); 
    383388 
    384389        $sql = "SELECT *, EXTRACT(EPOCH FROM validation_grace_time) as validation_grace_time_seconds FROM networks WHERE network_id='$network_id_str'"; 
     
    390395        $this->_row = $row; 
    391396        $this->_id = $p_network_id; 
     397        $this->_hotspotGraphElement = HotspotGraphElement::getObject($this->_id,'Network'); 
    392398    } 
    393399 
     
    16961702         * Content management 
    16971703         */ 
    1698         $title = _("Network content"); 
     1704       /* $title = _("Network content"); 
    16991705        $name = "network_".$this->_id."_content"; 
    17001706        $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(); 
    17021710 
    17031711        /* 
     
    19271935        $data = ProfileTemplate::getLinkedProfileTemplateUI($name, "network_has_profile_templates", "network_id", $this->_id); 
    19281936        $html .= InterfaceElements::generateAdminSectionContainer("network_profile_templates", $title, $data); 
     1937         
     1938        // objects hierarchy 
     1939        if (!is_null($this->_hotspotGraphElement)) 
     1940            $html .= $this->_hotspotGraphElement->getGraphAdminUI($this); 
    19291941 
    19301942        $html .= "</ul>\n"; 
     
    19461958 
    19471959        // 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);*/ 
    19501964 
    19511965        // name 
     
    20642078        $name = "network_".$this->_id."_profile_templates"; 
    20652079        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        } 
    20662087 
    20672088        // Node creation 
  • branches/gbastien/wifidog/classes/Node.php

    r1419 r1431  
    5050require_once('classes/Utils.php'); 
    5151require_once('classes/DateTimeWD.php'); 
     52require_once('classes/HotspotGraphElement.php'); 
    5253 
    5354/** 
     
    6970    private $id; 
    7071    private static $currentNode = null; 
     72    protected $_hotspotGraphElement; 
    7173 
    7274    /** 
     
    287289        } 
    288290 
     291        HotspotGraphElement::createNewObject($node_id, 'Node'); 
     292         
    289293        $object = self::getObject($node_id); 
    290294 
     
    693697        $this->_row = $row; 
    694698        $this->id = $row['node_id']; 
     699         
     700        $this->_hotspotGraphElement = HotspotGraphElement::getObject($this->id, 'Node'); 
    695701    } 
    696702 
     
    11871193 
    11881194        //Node content 
    1189         $_html_content = array(); 
     1195        /*$_html_content = array(); 
    11901196        $_title = _("Node content"); 
    11911197        $_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             
    11941202        // Name 
    11951203        $permArray = null; 
     
    13621370            $html .= InterfaceElements::generateAdminSectionContainer("access_rights", _("Access rights"), $html_access_rights); 
    13631371        } 
     1372         
     1373        //Node hierarchy 
     1374        if (!is_null($this->_hotspotGraphElement)) 
     1375            $html .= $this->_hotspotGraphElement->getGraphAdminUI($network); 
    13641376 
    13651377        $html .= "</ul>\n"; 
     
    14041416        } 
    14051417        // 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);*/ 
    14081422 
    14091423        // Name 
     
    15661580 
    15671581        // 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        } 
    15681589 
    15691590        // Access rights 
  • branches/gbastien/wifidog/classes/Permission.php

    r1421 r1431  
    8989            $PERMISSIONS['NETWORK_PERM_VIEW_STATISTICS'] = array(_("User is allowed to view all statistics for this network"), StakeholderType::Network, true); 
    9090            $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); 
    9192            $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); 
    9294            $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); 
    9396 
    9497            $PERMISSIONS['SERVER_PERM_EDIT_ROLES'] = array(_("User is allowed to edit user role definitions"), StakeholderType::Server, true); 
     
    107110            $PERMISSIONS['NODE_PERM_BYPASS_DYNAMIC_ABUSE_CONTROL'] = array(_("User is allowed to exceed dynamic abuse control limits at this node"), StakeholderType::Node, false); 
    108111            $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); 
    109117             
    110118            self::$_permissionArray = $PERMISSIONS; 
  • branches/gbastien/wifidog/classes/StakeholderType.php

    r1419 r1431  
    6464    const Server = 'Server'; 
    6565    const Content = 'Content'; 
     66    const NodeGroup = 'NodeGroup'; 
     67     
    6668    /** 
    6769     * Get an instance of the object 
  • branches/gbastien/wifidog/include/schema_validate.php

    r1428 r1431  
    4848 * Define current database schema version 
    4949 */ 
    50 define('REQUIRED_SCHEMA_VERSION', 67); 
     50define('REQUIRED_SCHEMA_VERSION', 68); 
    5151/** Used to test a new shecma version before modyfying the database */ 
    5252define('SCHEMA_UPDATE_TEST_MODE', false); 
     
    14561456    } 
    14571457     
     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     
    14581528    /* 
    14591529     $new_schema_version = ; 
  • branches/gbastien/wifidog/portal/index.php

    r1421 r1431  
    166166} 
    167167 
     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 
     172foreach($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 
    168197// Get all network content, but exclude user subscribed content if user is known 
    169 $content_rows = array (); 
     198/*$content_rows = array (); 
    170199$network_id = $db->escapeString($network->getId()); 
    171200if ($current_user) { 
    172201    $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"; 
    174205} 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"; 
    176209} 
    177210$db->execSql($sql, $content_rows, false); 
     
    183216        } 
    184217    } 
    185 } 
     218}*/ 
    186219 
    187220// Get all node content and EXCLUDE user subscribed content 
    188 $content_rows = array (); 
     221/*$content_rows = array (); 
    189222$node_id = $db->escapeString($node->getId()); 
    190223if ($current_user) { 
    191224    $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"; 
    193228} 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"; 
    195232} 
    196233$db->execSql($sql, $content_rows, false); 
     
    203240        } 
    204241    } 
    205 } 
     242}*/ 
    206243 
    207244// Get all user content