Changeset 608

Show
Ignore:
Timestamp:
05/01/05 20:16:26 (8 years ago)
Author:
fproulx
Message:

2005-04-30 Francois Proulx <francois.proulx@…>

  • Fixed bug that could potentially let non owners add content in /content through content groups
  • Admin menu won't show node selector if the user is not owner of at least one hotspot
  • Added Width, height support for Picture
Location:
trunk/wifidog-auth
Files:
9 modified

Legend:

Unmodified
Added
Removed
  • trunk/wifidog-auth/ChangeLog

    r607 r608  
     12005-04-30 Francois Proulx <francois.proulx@gmail.com> 
     2        * Fixed bug that could potentially let non owners add content in /content through content groups 
     3        * Admin menu won't show node selector if the user is not owner of at least one hotspot 
     4        * Added Width, height support for Picture 
     5         
    162005-04-30 Francois Proulx <francois.proulx@gmail.com> 
    27        * Did my best for content styling ... ( it's 5h00 am ) 
  • trunk/wifidog-auth/wifidog/classes/Content.php

    r601 r608  
    481481                        { 
    482482                                $html .= "<div class='user_ui_projet_info'>\n"; 
    483                                 $html .= _("Project information:"); 
     483                                $html .= "<b>"._("Project information:")."</b>"; 
    484484                                $project_info = self :: getObject($this->content_row['project_info']); 
    485485                                // If the content logging is disabled, all the children will inherit this property temporarly 
     
    493493                        { 
    494494                                $html .= "<div class='user_ui_sponsor_info'>\n"; 
    495                                 $html .= _("Project sponsor:"); 
     495                                $html .= "<b>"._("Project sponsor:")."</b>"; 
    496496                                $sponsor_info = self :: getObject($this->content_row['sponsor_info']); 
    497497                                // If the content logging is disabled, all the children will inherit this property temporarly 
  • trunk/wifidog-auth/wifidog/classes/Content/File.php

    r593 r608  
    295295        if ($this->isOwner(User :: getCurrentUser()) || User :: getCurrentUser()->isSuperAdmin()) 
    296296        { 
    297                 parent :: processAdminUI(); 
    298              
    299                 // If no file was uploaded, update filename and mime type 
    300                 if (!empty ($_REQUEST["file_mode".$this->getId()])) 
    301                 { 
    302                 $this->setFilename($_REQUEST["file_file_name".$this->getId()]); 
    303                 $this->setMimeType($_REQUEST["file_mime_type".$this->getId()]); 
    304                  
    305                         $file_mode = $_REQUEST["file_mode".$this->getId()]; 
    306                         if ($file_mode == "by_upload") 
    307                         { 
    308                                 $this->setBinaryDataFromPostVar("file_file_upload".$this->getId()); 
    309                                 $this->setURL(null); 
    310                                 // Reset the remote file size ( not used ) 
    311                                 $this->setRemoteFileSize(0); 
    312                         } 
    313                         else 
    314                         { 
    315                                 if ($file_mode == "remote") 
    316                                 { 
    317                                         $this->setURL($_REQUEST["file_url".$this->getId()]); 
    318                                         $this->setBinaryData(null); 
    319                                         // When switching from local to remote, this field does not exist yet 
    320                                         if (!empty ($_REQUEST["file_old_remote_size".$this->getId()])) 
    321                                         { 
    322                                                 if ($_REQUEST["file_remote_size".$this->getId()] != $_REQUEST["file_old_remote_size".$this->getId()]) 
    323                                                         $this->setRemoteFileSize($_REQUEST["file_remote_size".$this->getId()]); 
    324                                         } 
    325                                         else 
    326                                                 $this->setRemoteFileSize(0); 
    327                                 } 
    328                         } 
    329                 } 
     297                        parent :: processAdminUI(); 
     298                     
     299                        // If no file was uploaded, update filename and mime type 
     300                        if (!empty ($_REQUEST["file_mode".$this->getId()])) 
     301                        { 
     302                                $this->setFilename($_REQUEST["file_file_name".$this->getId()]); 
     303                         
     304                                $file_mode = $_REQUEST["file_mode".$this->getId()]; 
     305                                if ($file_mode == "by_upload") 
     306                                { 
     307                                        $this->setMimeType($_REQUEST["file_mime_type".$this->getId()]); 
     308                                        $this->setBinaryDataFromPostVar("file_file_upload".$this->getId()); 
     309                                        $this->setURL(null); 
     310                                        // Reset the remote file size ( not used ) 
     311                                        $this->setRemoteFileSize(0); 
     312                                } 
     313                                else 
     314                                { 
     315                                        if ($file_mode == "remote") 
     316                                        { 
     317                                                $this->setURL($_REQUEST["file_url".$this->getId()]); 
     318                                                $this->setBinaryData(null); 
     319                                                // When switching from local to remote, this field does not exist yet 
     320                                                if (!empty ($_REQUEST["file_old_remote_size".$this->getId()])) 
     321                                                { 
     322                                                        if ($_REQUEST["file_remote_size".$this->getId()] != $_REQUEST["file_old_remote_size".$this->getId()]) 
     323                                                                $this->setRemoteFileSize($_REQUEST["file_remote_size".$this->getId()]); 
     324                                                } 
     325                                                else 
     326                                                        $this->setRemoteFileSize(0); 
     327                                        } 
     328                                } 
     329                        } 
    330330        } 
    331331        } 
  • trunk/wifidog-auth/wifidog/classes/Content/Picture.php

    r578 r608  
    3939        { 
    4040                parent :: __construct($content_id); 
     41                global $db; 
     42 
     43                $content_id = $db->EscapeString($content_id); 
     44                $sql = "SELECT * FROM pictures WHERE pictures_id='$content_id'"; 
     45                $db->ExecSqlUniqueRes($sql, $row, false); 
     46                if ($row == null) 
     47                { 
     48                        /*Since the parent Content exists, the necessary data in content_group had not yet been created */ 
     49                        $sql = "INSERT INTO pictures (pictures_id) VALUES ('$content_id')"; 
     50                        $db->ExecSqlUpdate($sql, false); 
     51 
     52                        $sql = "SELECT * FROM pictures WHERE pictures_id='$content_id'"; 
     53                        $db->ExecSqlUniqueRes($sql, $row, false); 
     54                        if ($row == null) 
     55                        { 
     56                                throw new Exception(_("The content with the following id could not be found in the database: ").$content_id); 
     57                        } 
     58 
     59                } 
     60                $this->mBd = & $db; 
     61                $this->pictures_row = $row; 
     62        } 
     63         
     64        function getWidth() 
     65        { 
     66                return $this->pictures_row['width']; 
     67        } 
     68         
     69        function setWidth($width) 
     70        { 
     71                if(empty($width) || is_numeric($width)) 
     72                { 
     73                        empty($width) ? $width = "NULL" : $width = $this->mBd->EscapeString($width) ; 
     74                        $this->mBd->ExecSqlUpdate("UPDATE pictures SET width =".$width." WHERE pictures_id='".$this->getId()."'", false); 
     75                        $this->refresh(); 
     76                } 
     77        } 
     78         
     79        function getHeight() 
     80        { 
     81                return $this->pictures_row['height']; 
     82        } 
     83         
     84        function setHeight($height) 
     85        { 
     86                if(empty($height) || is_numeric($height)) 
     87                { 
     88                        empty($height) ? $height = "NULL" : $height = $this->mBd->EscapeString($height) ; 
     89                        $this->mBd->ExecSqlUpdate("UPDATE pictures SET height =".$height." WHERE pictures_id='".$this->getId()."'", false); 
     90                        $this->refresh(); 
     91                } 
    4192        } 
    4293 
     
    4798        $html .= "<div class='admin_class'>Picture (".get_class($this)." instance)</div>\n"; 
    4899         
     100        $html .= "<div class='admin_section_container'>\n"; 
     101                $html .= "<div class='admin_section_data'>\n"; 
     102        $html .= "<div class='admin_section_title'>"._("Width (leave empty if you want to keep original width)")." : </div>\n"; 
     103                $html .= "<input type='text' name='pictures_{$this->getId()}_width' value='{$this->getWidth()}'>"; 
     104                $html .= "</div>\n"; 
     105        $html .= "</div>\n"; 
     106         
     107        $html .= "<div class='admin_section_container'>\n"; 
     108                $html .= "<div class='admin_section_data'>\n"; 
     109        $html .= "<div class='admin_section_title'>"._("Height (leave empty if you want to keep original height)")." : </div>\n"; 
     110                $html .= "<input type='text' name='pictures_{$this->getId()}_height' value='{$this->getHeight()}'>"; 
     111                $html .= "</div>\n"; 
     112        $html .= "</div>\n"; 
     113         
    49114        // Show File admin UI + display the picture 
    50115        $html .= "<div class='admin_section_container'>\n"; 
    51116                $html .= "<div class='admin_section_data'>\n"; 
    52117        $html .= "<div class='admin_section_title'>"._("Picture preview")." : </div>\n"; 
    53                 $html .= "<img src='".htmlentities($this->getFileUrl())."' alt='".$this->getFileName()."''>"; 
     118         
     119        $width = $this->getWidth(); 
     120                $height = $this->getHeight(); 
     121                 
     122                if(empty($width)) 
     123                        $width = ""; 
     124                else 
     125                        $width = "width='$width'"; 
     126                 
     127                if(empty($height)) 
     128                        $height = ""; 
     129                else 
     130                        $height = "height='$height'"; 
     131                         
     132                $html .= "<img src='".htmlentities($this->getFileUrl())."' $width $height alt='".$this->getFileName()."''>"; 
    54133                $html .= "</div>\n"; 
    55134        $html .= "</div>\n"; 
     
    57136        $html .= $subclass_admin_interface; 
    58137        return parent :: getAdminUI($html); 
     138        } 
     139         
     140        function processAdminUI() 
     141        { 
     142        if ($this->isOwner(User :: getCurrentUser()) || User :: getCurrentUser()->isSuperAdmin()) 
     143        { 
     144                        parent :: processAdminUI(); 
     145                         
     146                        $this->setWidth(intval($_REQUEST["pictures_{$this->getId()}_width"])); 
     147                        $this->setHeight(intval($_REQUEST["pictures_{$this->getId()}_height"])); 
     148        } 
    59149        } 
    60150 
     
    67157                $html .= "<div class='user_ui_container'>\n"; 
    68158                $html .= "<div class='user_ui_object_class'>Picture (".get_class($this)." instance)</div>\n"; 
    69                 $html .= "<img class='user_ui_picture' src='".htmlentities($this->getFileUrl())."' alt='".$this->getFileName()."''>"; 
     159                 
     160                $width = $this->getWidth(); 
     161                $height = $this->getHeight(); 
     162                 
     163                if(empty($width)) 
     164                        $width = ""; 
     165                else 
     166                        $width = "width='$width'"; 
     167                 
     168                if(empty($height)) 
     169                        $height = ""; 
     170                else 
     171                        $height = "height='$height'"; 
     172                         
     173                $html .= "<img src='".htmlentities($this->getFileUrl())."' $width $height alt='".$this->getFileName()."''>"; 
    70174                $html .= "</div>\n"; 
    71175        return $html; 
  • trunk/wifidog-auth/wifidog/classes/MainUI.php

    r600 r608  
    6868            } 
    6969 
    70                         /* Node admin */ 
    71                         $html .= "<div class='admin_section_container'>\n"; 
    72                         $html .= '<form action="'.GENERIC_OBJECT_ADMIN_ABS_HREF.'" method="get">'; 
    73                         $html .= "<div class='admin_section_title'>"._("Node administration:")." </div>\n"; 
    74  
    75                         $html .= "<div class='admin_section_data'>\n"; 
    76                         $html .= "<input type='hidden' name='action' value='edit'>\n"; 
    77                         $html .= "<input type='hidden' name='object_class' value='Node'><br>\n"; 
    78  
    79                         if ($current_user->isSuperAdmin()) 
    80                         { 
    81                                 $sql_additional_where = ''; 
    82                         } 
    83                         else 
    84                         { 
    85                                 $sql_additional_where = "AND node_id IN (SELECT node_id from node_owners WHERE user_id='".$current_user->getId()."')"; 
    86                         } 
    87             $html .= "<div id='NodeSelector'>\n"; 
    88                         $html .= Node :: getSelectNodeUI('object_id', $sql_additional_where); 
    89             $html .= "</div>\n"; 
    90                         $html .= "</div>\n"; 
    91                         $html .= "<div class='admin_section_tools'>\n"; 
    92  
    93                         $html .= "<input type=submit name='edit_submit' value='"._("Edit")."'>\n"; 
    94                         $html .= "</div>\n"; 
    95                         $html .= '</form>'; 
    96                         $html .= "</div>\n"; 
     70                        // If the user is super admin OR owner of at least one hotspot show the menu 
     71                        if($current_user->isSuperAdmin() || $current_user->isOwner()) 
     72                        { 
     73                                /* Node admin */ 
     74                                $html .= "<div class='admin_section_container'>\n"; 
     75                                $html .= '<form action="'.GENERIC_OBJECT_ADMIN_ABS_HREF.'" method="get">'; 
     76                                $html .= "<div class='admin_section_title'>"._("Node administration:")." </div>\n"; 
     77         
     78                                $html .= "<div class='admin_section_data'>\n"; 
     79                                $html .= "<input type='hidden' name='action' value='edit'>\n"; 
     80                                $html .= "<input type='hidden' name='object_class' value='Node'><br>\n"; 
     81 
     82                                if ($current_user->isSuperAdmin()) 
     83                                        $sql_additional_where = ''; 
     84                                else 
     85                                        $sql_additional_where = "AND node_id IN (SELECT node_id from node_owners WHERE user_id='".$current_user->getId()."')"; 
     86                    $html .= "<div id='NodeSelector'>\n"; 
     87                                $html .= Node :: getSelectNodeUI('object_id', $sql_additional_where); 
     88                    $html .= "</div>\n"; 
     89                                $html .= "</div>\n"; 
     90                                $html .= "<div class='admin_section_tools'>\n"; 
     91         
     92                                $html .= "<input type=submit name='edit_submit' value='"._("Edit")."'>\n"; 
     93                                $html .= "</div>\n"; 
     94                                $html .= '</form>'; 
     95                                $html .= "</div>\n"; 
     96                        } 
    9797 
    9898                        /* Network admin */ 
  • trunk/wifidog-auth/wifidog/classes/Node.php

    r601 r608  
    454454        global $db; 
    455455        $retval = array (); 
    456         $sql = "SELECT * FROM content_group JOIN content ON (content.content_id = content_group.content_group_id) WHERE is_persistent = true AND is_artistic_content = true AND is_locative_content = true"; 
     456        $sql = "SELECT * FROM content_group JOIN content ON (content.content_id = content_group.content_group_id) JOIN node_has_content ON (node_has_content.content_id = content_group.content_group_id AND node_has_content.node_id = '{$this->getId()}') WHERE is_persistent = true AND is_artistic_content = true AND is_locative_content = true"; 
    457457        $db->ExecSql($sql, $content_rows, false); 
    458458        if ($content_rows != null) 
     
    464464                if($content_group->getDisplayNumElements() >= 1) 
    465465                { 
    466                     // Disable logging and allow content to expand ( if possible ) 
    467                     $content_group->setExpandStatus(true); 
    468                     $content_group->setLoggingStatus(false); 
    469                     $retval[] = $content_group; 
     466                                if($content_group->isDisplayableAt($this)) 
     467                                { 
     468                                                // Disable logging and allow content to expand ( if possible ) 
     469                                                $content_group->setExpandStatus(true); 
     470                                                $content_group->setLoggingStatus(false); 
     471                                                $retval[] = $content_group; 
     472                                } 
    470473                } 
    471474            } 
  • trunk/wifidog-auth/wifidog/classes/User.php

    r600 r608  
    11<?php 
     2 
    23 
    34/********************************************************************\ 
     
    251252        } 
    252253 
    253 /** Get a user display suitable for a user list.  Will include link to the user profile. */ 
     254        /** Get a user display suitable for a user list.  Will include link to the user profile. */ 
    254255        function getUserListUI() 
    255256        { 
    256                                                 $html = ''; 
    257                                                 $html .= $this->getUserName(); 
    258                                                 return $html; 
     257                $html = ''; 
     258                $html .= $this->getUserName(); 
     259                return $html; 
    259260        } 
    260261 
     
    344345        } 
    345346 
    346   public function isSuperAdmin() { 
    347     global $db; 
    348     //$this->session->dump(); 
    349      
    350     $db->ExecSqlUniqueRes("SELECT * FROM users NATURAL JOIN administrators WHERE (users.user_id='$this->id')", $user_info, false); 
    351     if (!empty($user_info)) { 
    352      return true; 
    353     } else { 
    354      return false; 
    355     } 
    356  
    357   } 
     347        public function isSuperAdmin() 
     348        { 
     349                global $db; 
     350                //$this->session->dump(); 
     351 
     352                $db->ExecSqlUniqueRes("SELECT * FROM users NATURAL JOIN administrators WHERE (users.user_id='$this->id')", $user_info, false); 
     353                if (!empty ($user_info)) 
     354                { 
     355                        return true; 
     356                } 
     357                else 
     358                { 
     359                        return false; 
     360                } 
     361 
     362        } 
     363 
     364        /** 
     365         * Tells if the current user is owner of at least one hotspot. 
     366         */ 
     367        public function isOwner() 
     368        { 
     369                global $db; 
     370                $db->ExecSqlUniqueRes("SELECT * FROM node_owners WHERE user_id='{$this->getId()}'", $row, false); 
     371                if ($row != null) 
     372                        return true; 
     373                return false; 
     374 
     375        } 
     376         
    358377        function getValidationToken() 
    359378        { 
     
    413432                return $connections; 
    414433        } 
    415      
    416     function getAccountOrigin() 
    417     { 
    418         return $this->mRow['account_origin']; 
    419     } 
     434 
     435        function getAccountOrigin() 
     436        { 
     437                return $this->mRow['account_origin']; 
     438        } 
    420439 
    421440        /** Return all the users 
     
    432451                return $objects; 
    433452        } 
    434      
    435     /** 
    436     * Logout the current user 
    437     * Destroying session and cleaning tokens 
    438     */ 
    439     function logout() 
    440     { 
    441         global $session; 
    442         $session->destroy(); 
    443         //TODO: Completed this part with Network::getObject() 
    444         /* 
    445         try { 
    446             $connections = $this->getConnections(); 
    447             foreach($connections as $connection) 
    448                 if($connection['token_status'] == TOKEN_UNUSED || $connection['token_status'] == TOKEN_INUSE) 
    449                     Network::getCurrentNetwork()->getAuthenticator()->logout(array('conn_id' => $connection['conn_id']), $errmsg); 
    450         } catch(Exception $e) 
    451         { 
    452             //TODO: Error management ( MainUI ) 
    453         }*/ 
    454     } 
     453 
     454        /** 
     455        * Logout the current user 
     456        * Destroying session and cleaning tokens 
     457        */ 
     458        function logout() 
     459        { 
     460                global $session; 
     461                $session->destroy(); 
     462                //TODO: Completed this part with Network::getObject() 
     463                /* 
     464                try { 
     465                    $connections = $this->getConnections(); 
     466                    foreach($connections as $connection) 
     467                        if($connection['token_status'] == TOKEN_UNUSED || $connection['token_status'] == TOKEN_INUSE) 
     468                            Network::getCurrentNetwork()->getAuthenticator()->logout(array('conn_id' => $connection['conn_id']), $errmsg); 
     469                } catch(Exception $e) 
     470                { 
     471                    //TODO: Error management ( MainUI ) 
     472                }*/ 
     473        } 
    455474 
    456475        function sendLostUsername() 
     
    462481                $subject = HOTSPOT_NETWORK_NAME._(" lost username request"); 
    463482                $body = _("Hello,\nYou have requested that the authentication server send you your username:\nUsername: ").$username._("\n\nHave a nice day,\nThe Team"); 
    464          
    465         //TODO: Find a way to use correctly mb_encode_mimeheader  
    466         $subject = mb_convert_encoding($subject, "ISO-8859-1","AUTO"); 
    467          
     483 
     484                //TODO: Find a way to use correctly mb_encode_mimeheader  
     485                $subject = mb_convert_encoding($subject, "ISO-8859-1", "AUTO"); 
     486 
    468487                mail($this->getEmail(), $subject, $body, $headers); 
    469488        } 
     
    489508                                $url = "http://".$_SERVER["SERVER_NAME"]."/validate.php?user_id=".$this->getId()."&token=".$this->getValidationToken(); 
    490509                                $body = _("Hello,\nPlease follow the link below to validate your account.\n").$url._("\n\nThank you,\nThe Team."); 
    491                  
    492                 //TODO: Find a way to use correctly mb_encode_mimeheader  
    493                 $subject = mb_convert_encoding($subject, "ISO-8859-1","AUTO"); 
    494          
     510 
     511                                //TODO: Find a way to use correctly mb_encode_mimeheader  
     512                                $subject = mb_convert_encoding($subject, "ISO-8859-1", "AUTO"); 
     513 
    495514                                mail($this->getEmail(), $subject, $body, $headers); 
    496515                        } 
     
    508527                $headers = 'MIME-Version: 1.0'."\r\n"; 
    509528                $headers .= 'Content-type: text/plain; charset=UTF-8'."\r\n"; 
    510         $headers .= "From: ".VALIDATION_EMAIL_FROM_ADDRESS; 
     529                $headers .= "From: ".VALIDATION_EMAIL_FROM_ADDRESS; 
    511530                $subject = HOTSPOT_NETWORK_NAME._(" new password request"); 
    512531                $body = _("Hello,\nYou have requested that the authentication server send you a new password:\nUsername: ").$username._("\nPassword: ").$new_password._("\n\nHave a nice day,\nThe Team"); 
    513          
    514         //TODO: Find a way to use correctly mb_encode_mimeheader  
    515         $subject = mb_convert_encoding($subject, "ISO-8859-1","AUTO"); 
    516          
     532 
     533                //TODO: Find a way to use correctly mb_encode_mimeheader  
     534                $subject = mb_convert_encoding($subject, "ISO-8859-1", "AUTO"); 
     535 
    517536                mail($this->getEmail(), $subject, $body, $headers); 
    518537        } 
     
    580599                return $html; 
    581600        } 
    582      
     601 
    583602        /** Get the selected user, IF one was selected and is valid 
    584603         * @param $user_prefix A identifier provided by the programmer to recognise it's generated form 
     
    591610                $name = "select_user_{$user_prefix}_username"; 
    592611                $username = $_REQUEST[$name]; 
    593                 return self::getUserByUsernameAndOrigin($username, $network->GetId()); 
    594         } 
    595      
    596     /** Add content to this user ( subscription ) */ 
    597     public function addContent(Content $content) 
    598     { 
    599         global $db; 
    600         $content_id = $db->EscapeString($content->getId()); 
    601         $sql = "INSERT INTO user_has_content (user_id, content_id) VALUES ('$this->id','$content_id')"; 
    602         $db->ExecSqlUpdate($sql, false); 
    603         return true; 
    604     } 
    605  
    606     /** Remove content from this node */ 
    607     public function removeContent(Content $content) 
    608     { 
    609         global $db; 
    610         $content_id = $db->EscapeString($content->getId()); 
    611         $sql = "DELETE FROM user_has_content WHERE user_id='$this->id' AND content_id='$content_id'"; 
    612         $db->ExecSqlUpdate($sql, false); 
    613         return true; 
    614     } 
    615  
    616     /**Get an array of all Content linked to this node 
    617     * @return an array of Content or an empty arrray */ 
    618     function getAllContent() 
    619     { 
    620         global $db; 
    621         $retval = array (); 
    622         $sql = "SELECT * FROM user_has_content WHERE user_id='$this->id' ORDER BY subscribe_timestamp"; 
    623         $db->ExecSql($sql, $content_rows, false); 
    624         if ($content_rows != null) 
    625         { 
    626             foreach ($content_rows as $content_row) 
    627             { 
    628                 $retval[] = Content :: getObject($content_row['content_id']); 
    629             } 
    630         } 
    631         return $retval; 
    632     } 
    633      
     612                return self :: getUserByUsernameAndOrigin($username, $network->GetId()); 
     613        } 
     614 
     615        /** Add content to this user ( subscription ) */ 
     616        public function addContent(Content $content) 
     617        { 
     618                global $db; 
     619                $content_id = $db->EscapeString($content->getId()); 
     620                $sql = "INSERT INTO user_has_content (user_id, content_id) VALUES ('$this->id','$content_id')"; 
     621                $db->ExecSqlUpdate($sql, false); 
     622                return true; 
     623        } 
     624 
     625        /** Remove content from this node */ 
     626        public function removeContent(Content $content) 
     627        { 
     628                global $db; 
     629                $content_id = $db->EscapeString($content->getId()); 
     630                $sql = "DELETE FROM user_has_content WHERE user_id='$this->id' AND content_id='$content_id'"; 
     631                $db->ExecSqlUpdate($sql, false); 
     632                return true; 
     633        } 
     634 
     635        /**Get an array of all Content linked to this node 
     636        * @return an array of Content or an empty arrray */ 
     637        function getAllContent() 
     638        { 
     639                global $db; 
     640                $retval = array (); 
     641                $sql = "SELECT * FROM user_has_content WHERE user_id='$this->id' ORDER BY subscribe_timestamp"; 
     642                $db->ExecSql($sql, $content_rows, false); 
     643                if ($content_rows != null) 
     644                { 
     645                        foreach ($content_rows as $content_row) 
     646                        { 
     647                                $retval[] = Content :: getObject($content_row['content_id']); 
     648                        } 
     649                } 
     650                return $retval; 
     651        } 
     652 
    634653} // End class 
    635654?> 
  • trunk/wifidog-auth/wifidog/content/index.php

    r600 r608  
    110110 
    111111/* Node section */ 
    112 $html .= "<div class='portal_node_section'>\n"; 
    113 $html .= "<img class='portal_section_logo' src='{$hotspot_logo_url}' alt=''>\n"; 
    114 $html .= "<span class='portal_section_title'>"._("Content from:")."</span>"; 
    115  
    116 $node_homepage = $node->getHomePageURL(); 
    117 if(!empty($node_homepage)) 
    118 { 
    119         $html .= "<a href='$node_homepage'>"; 
    120 } 
    121 $html .= $node->getName(); 
    122 if(!empty($node_homepage)) 
    123 { 
    124         $html .= "</a>\n"; 
    125 } 
    126  
    127112// Get all locative artistic content for this node 
    128113$contents = $node->getAllLocativeArtisticContent(); 
    129 $html .= "<ul>\n"; 
    130 foreach ($contents as $content) 
     114if($contents) 
    131115{ 
    132     $html .= "<li>\n"; 
    133         $html .= $content->getUserUI(); 
    134     $html .= "</li>\n"; 
     116        $html .= "<table width='100%'><tr><td>"; 
     117        $html .= "<div class='portal_node_section'>\n"; 
     118        $html .= "<img class='portal_section_logo' src='{$hotspot_logo_url}' alt=''>\n"; 
     119        $html .= "<span class='portal_section_title'>"._("Content from:")." "; 
     120         
     121        $node_homepage = $node->getHomePageURL(); 
     122        if(!empty($node_homepage)) 
     123        { 
     124                $html .= "<a href='$node_homepage'>"; 
     125        } 
     126        $html .= $node->getName(); 
     127        if(!empty($node_homepage)) 
     128        { 
     129                $html .= "</a>\n"; 
     130        } 
     131        $html .= "</span>"; 
     132        $html .= "</td></tr></table>"; 
     133         
     134        foreach ($contents as $content) 
     135        { 
     136                $html .= "<div class='portal_content'>\n"; 
     137                $html .= $content->getUserUI(); 
     138                $html .= "</div>"; 
     139        } 
     140        $html .= "</div>\n"; 
    135141} 
    136 $html .= "</ul>\n"; 
    137  
    138 $html .= "</div>\n"; 
    139142 
    140143$ui->setMainContent($html); 
  • trunk/wifidog-auth/wifidog/include/schema_validate.php

    r585 r608  
    2929require_once BASEPATH.'classes/AbstractDb.php'; 
    3030require_once BASEPATH.'classes/Session.php'; 
    31 define('REQUIRED_SCHEMA_VERSION', 13); 
     31define('REQUIRED_SCHEMA_VERSION', 14); 
    3232 
    3333/** Check that the database schema is up to date.  If it isn't, offer to update it. */ 
     
    401401                        $sql .= "ALTER TABLE content_group ALTER COLUMN allow_repeat SET DEFAULT 'YES';\n"; 
    402402                        $sql .= "ALTER TABLE content_group ALTER COLUMN allow_repeat SET NOT NULL;\n"; 
    403                 }        
     403                } 
     404                 
     405                $new_schema_version = 14; 
     406        if($schema_version < $new_schema_version) 
     407        { 
     408            echo "<h2>Preparing SQL statements to update schema to version  $new_schema_version</h2>\n"; 
     409            $sql .= "\n\nUPDATE schema_info SET value='$new_schema_version' WHERE tag='schema_version';\n";  
     410            $sql .= "CREATE TABLE pictures " . 
     411                        "( " . 
     412                        "pictures_id text NOT NULL PRIMARY KEY REFERENCES files ON DELETE CASCADE ON UPDATE CASCADE, " . 
     413                        "width int4, ". 
     414                        "height int4". 
     415                        ");\n"; 
     416        }        
    404417         
    405418