Changeset 1085

Show
Ignore:
Timestamp:
08/31/06 07:31:33 (7 years ago)
Author:
benoitg
Message:
  • Server.php: Make sure getCurrentServer returns the default server if the hostname isn't recognised.
  • Content manager:

-Allow deleting simple (trivial) but persistent content
-Remove the sponsor info field from Content Metadata. Best practices is now to use the project info field to show this information.

  • Add the necessary schema constraints to allow manually deleting networks, nodes and users. Be carefull, removing any of theses will remove all traces of connection statistics as well. You've been warned.
  • Do not display the network in the login interface if there is only one.
  • Add a pseudo-random content ordering mode. Pick content elements randomly, but do not display the same content twice untill all content has been seen.
  • Allow setting a title but not displaying it (very usefull for reusable content)


Location:
trunk/wifidog-auth
Files:
7 modified

Legend:

Unmodified
Added
Removed
  • trunk/wifidog-auth/CHANGELOG

    r1084 r1085  
     12006-08-31 Benoit Grégoire  <bock@step.polymtl.ca> 
     2        * Server.php:  Make sure getCurrentServer returns the default server if the hostname isn't recognised. 
     3        * Content manager: 
     4                -Allow deleting simple (trivial) but persistent content 
     5                -Remove the sponsor info field from Content Metadata.  Best practices is now to use the project info field to show this information. 
     6        * Add the necessary schema constraints to allow manually deleting networks, nodes and users.  Be carefull, removing any of theses will remove all traces of connection statistics as well.  You've been warned. 
     7        * Do not display the network in the login interface if there is only one. 
     8        * Add a pseudo-random content ordering mode.  Pick content elements randomly, but do not display the same content twice untill all content has been seen. 
     9        * Allow setting a title but not displaying it (very usefull for reusable content) 
     10         
    1112006-08-29 Max Horváth <max.horvath@maxspot.de> 
    212        * Cleaned up PHPdoc tags 
  • trunk/wifidog-auth/wifidog/classes/Content.php

    r1081 r1085  
    874874    } 
    875875 
    876     /** 
    877      * Get content sponsor info 
    878      * @return content a content sub-class 
    879      */ 
    880     public function getSponsorInfo() { 
    881         try { 
    882             return self :: getObject($this->content_row['sponsor_info']); 
    883         } catch (Exception $e) { 
    884             return null; 
    885         } 
    886     } 
    887  
    888876    /** Set the object type of this object 
    889877     * Note that after using this, the object must be re-instanciated to have the right type 
     
    10401028        $html .= "<div class='user_ui_main_inner'>\n"; 
    10411029 
    1042         if (!empty ($this->content_row['title'])) { 
     1030        if (!empty ($this->content_row['title'])  && $this->titleShouldDisplay()) { 
    10431031            $html .= "<div class='user_ui_title'>\n"; 
    10441032            $title = self :: getObject($this->content_row['title']); 
     
    10761064        } 
    10771065 
    1078         if (!empty ($this->content_row['project_info']) || !empty ($this->content_row['sponsor_info'])) { 
     1066        if (!empty ($this->content_row['project_info']) ) { 
    10791067            if (!empty ($this->content_row['project_info'])) { 
    10801068                $html .= "<div class='user_ui_projet_info'>\n"; 
     
    10861074                    $project_info->setLoggingStatus(false); 
    10871075                $html .= $project_info->getUserUI(); 
    1088                 $html .= "</div>\n"; 
    1089             } 
    1090  
    1091             if (!empty ($this->content_row['sponsor_info'])) { 
    1092                 $html .= "<div class='user_ui_sponsor_info'>\n"; 
    1093                 $html .= "<b>"._("Project sponsor:")."</b>"; 
    1094                 $sponsor_info = self :: getObject($this->content_row['sponsor_info']); 
    1095                 $sponsor_info->setLogAsContent($this); 
    1096                 // If the content logging is disabled, all the children will inherit this property temporarly 
    1097                 if ($this->getLoggingStatus() == false) 
    1098                     $sponsor_info->setLoggingStatus(false); 
    1099                 $html .= $sponsor_info->getUserUI(); 
    11001076                $html .= "</div>\n"; 
    11011077            } 
     
    11941170            $html .= FormSelectGenerator :: generateFromArray($tab, null, "content_".$this->id."_content_type", "Content", false); 
    11951171        } else { 
     1172           // Content metadata 
    11961173            if ($this->is_trivial_content == false) { 
    11971174                        $html .= "<fieldset class='admin_element_group'>\n"; 
    11981175                                $html .= "<legend>".sprintf(_("%s MetaData"),get_class($this))."</legend>\n"; 
    11991176 
     1177                /* title_is_displayed */ 
     1178                $html_title_is_displayed = _("Display the title?").": \n"; 
     1179                $name = "content_".$this->id."_title_is_displayed"; 
     1180                $this->titleShouldDisplay() ? $checked = 'CHECKED' : $checked = ''; 
     1181                $html_title_is_displayed .= "<input type='checkbox' name='$name' $checked>\n"; 
     1182                 
    12001183                /* title */ 
    12011184                $html .= "<li class='admin_element_item_container admin_section_edit_title'>\n"; 
    1202                 $html .= "<div class='admin_element_data'>\n"; 
     1185                $html .= "<div class='admin_element_data'>\n";   
    12031186                if (empty ($this->content_row['title'])) { 
    1204                     $html .= self :: getNewContentUI("title_{$this->id}_new", null, _("Title:")); 
     1187                    $html .= self :: getNewContentUI("title_{$this->id}_new", null, _("Title:"));                 
    12051188                    $html .= "</div>\n"; 
    12061189                } else { 
     1190                    $html .= $html_title_is_displayed;  
    12071191                    $title = self :: getObject($this->content_row['title']); 
    12081192                    $html .= $title->getAdminUI(null, _("Title:")); 
     
    12141198                } 
    12151199                $html .= "</li>\n"; 
    1216  
    1217  
    12181200 
    12191201                /* description */ 
     
    12671249                } 
    12681250                $html .= "</li>\n"; 
    1269  
    1270                 /* sponsor_info */ 
    1271                 $html .= "<li class='admin_element_item_container admin_section_edit_sponsor'>\n"; 
    1272                 $html .= "<div class='admin_element_data'>\n"; 
    1273                 if (empty ($this->content_row['sponsor_info'])) { 
    1274                     $html .= self :: getNewContentUI("sponsor_info_{$this->id}_new", null, _("Sponsor of this project:")); 
    1275                     $html .= "</div>\n"; 
    1276                 } else { 
    1277                     $sponsor_info = self :: getObject($this->content_row['sponsor_info']); 
    1278                     $html .= $sponsor_info->getAdminUI(null, _("Sponsor of this project:")); 
    1279                     $html .= "</div>\n"; 
    1280                     $html .= "<div class='admin_element_tools'>\n"; 
    1281                     $name = "content_".$this->id."_sponsor_info_erase"; 
    1282                     $html .= "<input type='submit' class='submit' name='$name' value='".sprintf(_("Delete %s (%s)"),_("sponsor"),get_class($sponsor_info))."'>"; 
    1283                     $html .= "</div>\n"; 
    1284                 } 
    1285                 $html .= "</li>\n"; 
    1286                 $html .= "</fieldset>\n"; 
    1287  
    1288                         $html .= "<fieldset class='admin_element_group'>\n"; 
     1251            }//End content medatada 
     1252             
     1253            if ($this->is_trivial_content == false || $this->isPersistent()) {                   
     1254                $html .= "<fieldset class='admin_element_group'>\n"; 
    12891255                                $html .= "<legend>".sprintf(_("%s access control"),get_class($this))."</legend>\n"; 
    12901256 
     
    12951261                $name = "content_".$this->id."_is_persistent"; 
    12961262                $this->isPersistent() ? $checked = 'CHECKED' : $checked = ''; 
    1297                 $html .= "<input type='checkbox' name='$name' $checked>\n"; 
     1263                $html .= "<input type='checkbox' name='$name' $checked onChange='submit();'>\n"; 
    12981264                $html .= "</div>\n"; 
    12991265                $html .= "</li>\n"; 
     
    13381304                $html .= "</li>\n"; 
    13391305                $html .= "</fieldset>\n"; 
    1340             }//End if is trivial content 
     1306 
     1307            } 
    13411308        } 
    13421309        $html .= $subclass_admin_interface; 
     
    13551322                $this->setContentType($content_type); 
    13561323            } else 
     1324            {//Content medatada 
     1325                            /* title_is_displayed */ 
     1326                if (!empty ($this->content_row['title'])){ 
     1327                $name = "content_".$this->id."_title_is_displayed"; 
     1328                !empty ($_REQUEST[$name]) ? $this->setTitleIsDisplayed(true) : $this->setTitleIsDisplayed(false); 
     1329                } 
     1330                 
    13571331                if ($this->is_trivial_content == false) { 
    13581332                    /* title */ 
     
    14271401                        } 
    14281402                    } 
    1429  
    1430                     /* sponsor_info */ 
    1431                     if (empty ($this->content_row['sponsor_info'])) { 
    1432                         $sponsor_info = self :: processNewContentUI("sponsor_info_{$this->id}_new"); 
    1433                         if ($sponsor_info != null) { 
    1434                             $sponsor_info_id = $sponsor_info->GetId(); 
    1435                             $db->execSqlUpdate("UPDATE content SET sponsor_info = '$sponsor_info_id' WHERE content_id = '$this->id'", FALSE); 
    1436                         } 
    1437                     } else { 
    1438                         $sponsor_info = self :: getObject($this->content_row['sponsor_info']); 
    1439                         $name = "content_".$this->id."_sponsor_info_erase"; 
    1440                         if (!empty ($_REQUEST[$name]) && $_REQUEST[$name] == true) { 
    1441                             $db->execSqlUpdate("UPDATE content SET sponsor_info = NULL WHERE content_id = '$this->id'", FALSE); 
    1442                             $sponsor_info->delete($errmsg); 
    1443                         } else { 
    1444                             $sponsor_info->processAdminUI(); 
    1445                         } 
    1446                     } 
    1447  
     1403                }//End content metadata 
     1404 
     1405           if ($this->is_trivial_content == false || $this->isPersistent()) { 
    14481406                    /* is_persistent */ 
    14491407                    $name = "content_".$this->id."_is_persistent"; 
     
    14821440                        $this->addOwner($user); 
    14831441                    } 
    1484  
     1442           } 
    14851443                } 
    14861444            $this->refresh(); 
     
    15131471    public function unsubscribe(User $user) { 
    15141472        return $user->removeContent($this); 
     1473    } 
     1474 
     1475    /** If the title is not empty, should it be displayed? 
     1476    * @return true or false */ 
     1477    public function titleShouldDisplay() { 
     1478        if ($this->content_row['title_is_displayed'] == 't') { 
     1479            $retval = true; 
     1480        } else { 
     1481            $retval = false; 
     1482        } 
     1483        return $retval; 
     1484    } 
     1485 
     1486    /** If the title is not empty, should it be displayed? 
     1487     * @param $should_display true or false 
     1488     * */ 
     1489    public function setTitleIsDisplayed($should_display) { 
     1490        if ($should_display != $this->titleShouldDisplay()) /* Only update database if there is an actual change */ { 
     1491            $should_display ? $should_display_sql = 'TRUE' : $should_display_sql = 'FALSE'; 
     1492            global $db; 
     1493            $db->execSqlUpdate("UPDATE content SET title_is_displayed = $should_display_sql WHERE content_id = '$this->id'", false); 
     1494            $this->refresh(); 
     1495        } 
     1496 
    15151497    } 
    15161498 
     
    15251507        return $retval; 
    15261508    } 
    1527  
     1509     
    15281510    /** Set if the content group is persistent 
    15291511     * @param $is_locative_content true or false 
  • trunk/wifidog-auth/wifidog/classes/Content/ContentGroup/ContentGroup.php

    r1070 r1085  
    11<?php 
     2 
    23 
    34/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */ 
     
    4647 * Load ContentGroupElement class 
    4748 */ 
    48 require_once('classes/Content/ContentGroup/ContentGroupElement.php'); 
     49require_once ('classes/Content/ContentGroup/ContentGroupElement.php'); 
    4950 
    5051/** 
     
    5657 * @copyright  2005-2006 Benoit Grégoire, Technologies Coeus inc. 
    5758 */ 
    58 class ContentGroup extends Content 
    59 { 
    60  
    61     private $CONTENT_ORDERING_MODES = array ('RANDOM' => "Pick content elements randomly", 'SEQUENTIAL' => "Pick content elements in sequential order"); 
    62     private $CONTENT_CHANGES_ON_MODES = array ('ALWAYS' => "Content always rotates", 'NEXT_DAY' => "Content rotates once per day", 'NEXT_LOGIN' => "Content rotates once per session", 'NEXT_NODE' => "Content rotates each time you change node"); 
    63     private $ALLOW_REPEAT_MODES = array ('YES' => "Content can be shown more than once", 'NO' => "Content can only be shown once", 'ONCE_PER_NODE' => "Content can be shown more than once, but not at the same node"); 
     59class ContentGroup extends Content { 
     60 
     61    private $CONTENT_ORDERING_MODES = array ( 
     62        'RANDOM' => "Pick content elements randomly", 
     63        'PSEUDO_RANDOM' => "Pick content elements randomly, but do not display the same content twice untill all content has been seen", 
     64        'SEQUENTIAL' => "Pick content elements in sequential order" 
     65    ); 
     66    private $CONTENT_CHANGES_ON_MODES = array ( 
     67        'ALWAYS' => "Content always rotates", 
     68        'NEXT_DAY' => "Content rotates once per day", 
     69        'NEXT_LOGIN' => "Content rotates once per session", 
     70        'NEXT_NODE' => "Content rotates each time you change node" 
     71    ); 
     72    private $ALLOW_REPEAT_MODES = array ( 
     73        'YES' => "Content can be shown more than once", 
     74        'NO' => "Content can only be shown once", 
     75        'ONCE_PER_NODE' => "Content can be shown more than once, but not at the same node" 
     76    ); 
    6477 
    6578    protected $is_artistic_content; 
     
    7588    private $content_group_row; 
    7689 
    77     protected function __construct($content_id) 
    78     { 
     90    protected function __construct($content_id) { 
    7991        // Define globals 
    8092        global $db; 
     
    89101        $sql = "SELECT * FROM content_group WHERE content_group_id='$content_id'"; 
    90102        $db->execSqlUniqueRes($sql, $row, false); 
    91         if ($row == null) 
    92         { 
     103        if ($row == null) { 
    93104            /*Since the parent Content exists, the necessary data in content_group had not yet been created */ 
    94105            $sql = "INSERT INTO content_group (content_group_id) VALUES ('$content_id')"; 
     
    96107            $sql = "SELECT * FROM content_group WHERE content_group_id='$content_id'"; 
    97108            $db->execSqlUniqueRes($sql, $row, false); 
    98             if ($row == null) 
    99             { 
    100                 throw new Exception(_("The content with the following id could not be found in the database: ").$content_id); 
     109            if ($row == null) { 
     110                throw new Exception(_("The content with the following id could not be found in the database: ") . $content_id); 
    101111            } 
    102112 
     
    111121    /** Is the content group artistic in nature? 
    112122     * @return true or false */ 
    113     public function isArtisticContent() 
    114     { 
    115         if ($this->content_group_row['is_artistic_content'] == 't') 
    116         { 
    117             $retval = true; 
    118         } 
    119         else 
    120         { 
     123    public function isArtisticContent() { 
     124        if ($this->content_group_row['is_artistic_content'] == 't') { 
     125            $retval = true; 
     126        } else { 
    121127            $retval = false; 
    122128        } 
     
    126132    /** Set if the content group is artistic in nature, 
    127133     * @param $is_artistic_content true or false*/ 
    128     public function setIsArtisticContent($is_artistic_content) 
    129     { 
    130         if ($is_artistic_content != $this->isArtisticContent()) /* Only update database if there is an actual change */ 
    131         { 
     134    public function setIsArtisticContent($is_artistic_content) { 
     135        if ($is_artistic_content != $this->isArtisticContent()) /* Only update database if there is an actual change */ { 
    132136            $is_artistic_content ? $is_artistic_content_sql = 'TRUE' : $is_artistic_content_sql = 'FALSE'; 
    133137 
     
    141145    /** Does the content shown or generated by the content group directly related to where it is viewed from? 
    142146     * @return true or false */ 
    143     public function isLocativeContent() 
    144     { 
    145         if ($this->content_group_row['is_locative_content'] == 't') 
    146         { 
    147             $retval = true; 
    148         } 
    149         else 
    150         { 
     147    public function isLocativeContent() { 
     148        if ($this->content_group_row['is_locative_content'] == 't') { 
     149            $retval = true; 
     150        } else { 
    151151            $retval = false; 
    152152        } 
     
    157157     * @param $is_locative_content true or false 
    158158     * */ 
    159     public function setIsLocativeContent($is_locative_content) 
    160     { 
    161         if ($is_locative_content != $this->isLocativeContent()) /* Only update database if there is an actual change */ 
    162         { 
     159    public function setIsLocativeContent($is_locative_content) { 
     160        if ($is_locative_content != $this->isLocativeContent()) /* Only update database if there is an actual change */ { 
    163161            $is_locative_content ? $is_locative_content_sql = 'TRUE' : $is_locative_content_sql = 'FALSE'; 
    164162 
     
    172170    /** In what order is the content displayed to the user 
    173171    * @return string, a key of CONTENT_SELECTION_MODES */ 
    174     public function getContentOrderingMode() 
    175     { 
     172    public function getContentOrderingMode() { 
    176173        return $this->content_group_row['content_ordering_mode']; 
    177174    } 
     
    181178     * @return true if successfull 
    182179     * */ 
    183     protected function setContentOrderingMode($content_ordering_mode, & $errormsg = null) 
    184     { 
     180    protected function setContentOrderingMode($content_ordering_mode, & $errormsg = null) { 
    185181        $retval = false; 
    186         if (isset ($this->CONTENT_ORDERING_MODES[$content_ordering_mode]) && $content_ordering_mode != $this->getContentOrderingMode()) /* Only update database if the mode is valid and there is an actual change */ 
    187         { 
     182        if (isset ($this->CONTENT_ORDERING_MODES[$content_ordering_mode]) && $content_ordering_mode != $this->getContentOrderingMode()) /* Only update database if the mode is valid and there is an actual change */ { 
    188183            global $db; 
    189184            $content_ordering_mode = $db->escapeString($content_ordering_mode); 
     
    192187            $retval = true; 
    193188        } 
    194         elseif (!isset ($this->CONTENT_ORDERING_MODES[$content_ordering_mode])) 
    195         { 
     189        elseif (!isset ($this->CONTENT_ORDERING_MODES[$content_ordering_mode])) { 
    196190            $errormsg = _("Invalid content selection mode (must be part of CONTENT_ORDERING_MODES)"); 
    197191            $retval = false; 
    198         } 
    199         else 
    200         { 
     192        } else { 
    201193            /* Successfull, but nothing modified */ 
    202194            $retval = true; 
     
    207199    /** When does the content rotate? 
    208200    * @return string, a key of CONTENT_SELECTION_MODES */ 
    209     public function getContentChangesOnMode() 
    210     { 
     201    public function getContentChangesOnMode() { 
    211202        return $this->content_group_row['content_changes_on_mode']; 
    212203    } 
     
    216207     * @return true if successfull 
    217208     * */ 
    218     protected function setContentChangesOnMode($content_changes_on_mode, & $errormsg = null) 
    219     { 
     209    protected function setContentChangesOnMode($content_changes_on_mode, & $errormsg = null) { 
    220210        $retval = false; 
    221         if (isset ($this->CONTENT_CHANGES_ON_MODES[$content_changes_on_mode]) && $content_changes_on_mode != $this->getContentChangesOnMode()) /* Only update database if the mode is valid and there is an actual change */ 
    222         { 
     211        if (isset ($this->CONTENT_CHANGES_ON_MODES[$content_changes_on_mode]) && $content_changes_on_mode != $this->getContentChangesOnMode()) /* Only update database if the mode is valid and there is an actual change */ { 
    223212            global $db; 
    224213            $content_changes_on_mode = $db->escapeString($content_changes_on_mode); 
     
    227216            $retval = true; 
    228217        } 
    229         elseif (!isset ($this->CONTENT_CHANGES_ON_MODES[$content_changes_on_mode])) 
    230         { 
     218        elseif (!isset ($this->CONTENT_CHANGES_ON_MODES[$content_changes_on_mode])) { 
    231219            $errormsg = _("Invalid content selection mode (must be part of CONTENT_CHANGES_ON_MODES)"); 
    232220            $retval = false; 
    233         } 
    234         else 
    235         { 
     221        } else { 
    236222            /* Successfull, but nothing modified */ 
    237223            $retval = true; 
     
    242228    /** Can the same content be shown twice 
    243229     * @return 'YES', 'NO', 'ONCE_PER_NODE' */ 
    244     public function getAllowRepeat() 
    245     { 
     230    public function getAllowRepeat() { 
    246231        return $this->content_group_row['allow_repeat']; 
    247232    } 
     
    251236     * @return true if successfull 
    252237     * */ 
    253     protected function setAllowRepeat($allow_repeat, & $errormsg = null) 
    254     { 
     238    protected function setAllowRepeat($allow_repeat, & $errormsg = null) { 
    255239        $retval = false; 
    256         if (isset ($this->ALLOW_REPEAT_MODES[$allow_repeat]) && $allow_repeat != $this->getAllowRepeat()) /* Only update database if the mode is valid and there is an actual change */ 
    257         { 
     240        if (isset ($this->ALLOW_REPEAT_MODES[$allow_repeat]) && $allow_repeat != $this->getAllowRepeat()) /* Only update database if the mode is valid and there is an actual change */ { 
    258241            global $db; 
    259242            $allow_repeat = $db->escapeString($allow_repeat); 
     
    262245            $retval = true; 
    263246        } 
    264         elseif (!isset ($this->ALLOW_REPEAT_MODES[$allow_repeat])) 
    265         { 
     247        elseif (!isset ($this->ALLOW_REPEAT_MODES[$allow_repeat])) { 
    266248            $errormsg = _("Invalid content selection mode (must be part of ALLOW_REPEAT_MODES)"); 
    267249            $retval = false; 
    268         } 
    269         else 
    270         { 
     250        } else { 
    271251            /* Successfull, but nothing modified */ 
    272252            $retval = true; 
     
    277257    /** How many element should be picked for display at once? 
    278258    * @return integer */ 
    279     public function getDisplayNumElements() 
    280     { 
    281         if($this->temporary_display_num_elements == null) 
     259    public function getDisplayNumElements() { 
     260        if ($this->temporary_display_num_elements == null) 
    282261            return $this->content_group_row['display_num_elements']; 
    283262        else 
     
    289268    * @return true if successfull 
    290269    * */ 
    291     protected function setDisplayNumElements($display_num_elements, & $errormsg = null) 
    292     { 
     270    protected function setDisplayNumElements($display_num_elements, & $errormsg = null) { 
    293271        $retval = false; 
    294         if (($display_num_elements > 0) && $display_num_elements != $this->getDisplayNumElements()) /* Only update database if the mode is valid and there is an actual change */ 
    295         { 
     272        if (($display_num_elements > 0) && $display_num_elements != $this->getDisplayNumElements()) /* Only update database if the mode is valid and there is an actual change */ { 
    296273            global $db; 
    297274            $display_num_elements = $db->escapeString($display_num_elements); 
     
    300277            $retval = true; 
    301278        } 
    302         elseif ($display_num_elements <= 0) 
    303         { 
     279        elseif ($display_num_elements <= 0) { 
    304280            $errormsg = _("You must display at least one element"); 
    305281            $retval = false; 
    306         } 
    307         else 
    308         { 
     282        } else { 
    309283            /* Successfull, but nothing modified */ 
    310284            $retval = true; 
     
    318292     * at once 
    319293     */ 
    320     private function setTemporaryDisplayNumElements($temporary_num_elements) 
    321     { 
     294    private function setTemporaryDisplayNumElements($temporary_num_elements) { 
    322295        $this->temporary_display_num_elements = $temporary_num_elements; 
    323296    } 
    324297 
    325     public function getAdminUI($subclass_admin_interface = null, $title=null) 
    326     { 
     298    public function getAdminUI($subclass_admin_interface = null, $title = null) { 
    327299        $html = ''; 
    328                 $html .= "<fieldset class='admin_element_group'>\n"; 
    329                 $html .= "<legend>".sprintf(_("%s configuration"),get_class($this))."</legend>\n"; 
     300        $html .= "<fieldset class='admin_element_group'>\n"; 
     301        $html .= "<legend>" . sprintf(_("%s configuration"), get_class($this)) . "</legend>\n"; 
    330302 
    331303        /* is_artistic_content */ 
     
    333305        $html .= "<div class='admin_element_label'>Is artistic content?: </div>\n"; 
    334306        $html .= "<div class='admin_element_data'>\n"; 
    335         $name = "content_group_".$this->id."_is_artistic_content"; 
     307        $name = "content_group_" . $this->id . "_is_artistic_content"; 
    336308        $this->isArtisticContent() ? $checked = 'CHECKED' : $checked = ''; 
    337309        $html .= "<input type='checkbox' name='$name' $checked>\n"; 
     
    341313        /* is_locative_content */ 
    342314        $html .= "<li class='admin_element_item_container'>\n"; 
    343         $html .= "<div class='admin_element_label'>". ("Is locative content?").": </div>\n"; 
     315        $html .= "<div class='admin_element_label'>" . ("Is locative content?") . ": </div>\n"; 
    344316        $html .= "<div class='admin_element_data'>\n"; 
    345         $name = "content_group_".$this->id."_is_locative_content"; 
     317        $name = "content_group_" . $this->id . "_is_locative_content"; 
    346318        $this->isLocativeContent() ? $checked = 'CHECKED' : $checked = ''; 
    347319        $html .= "<input type='checkbox' name='$name' $checked>\n"; 
     
    351323        /* content_ordering_mode */ 
    352324        $html .= "<li class='admin_element_item_container'>\n"; 
    353         $html .= "<div class='admin_element_label'>"._("In what order should the content displayed?").": </div>\n"; 
     325        $html .= "<div class='admin_element_label'>" . _("In what order should the content displayed?") . ": </div>\n"; 
    354326        $html .= "<div class='admin_element_data'>\n"; 
    355         $name = "content_group_".$this->id."_content_ordering_mode"; 
     327        $name = "content_group_" . $this->id . "_content_ordering_mode"; 
    356328 
    357329        $i = 0; 
    358330        $tab = null; 
    359         foreach ($this->CONTENT_ORDERING_MODES as $select_mode_id => $select_mode_descr) 
    360         { 
     331        foreach ($this->CONTENT_ORDERING_MODES as $select_mode_id => $select_mode_descr) { 
    361332            $tab[$i][0] = $select_mode_id; 
    362333            $tab[$i][1] = $select_mode_descr; 
    363             $i ++; 
     334            $i++; 
    364335        } 
    365336        $html .= FormSelectGenerator :: generateFromArray($tab, $this->getContentOrderingMode(), $name, null, false); 
     
    369340        /*content_changes_on_mode */ 
    370341        $html .= "<li class='admin_element_item_container'>\n"; 
    371         $html .= "<div class='admin_element_label'>"._("When does the content rotate?").": </div>\n"; 
     342        $html .= "<div class='admin_element_label'>" . _("When does the content rotate?") . ": </div>\n"; 
    372343        $html .= "<div class='admin_element_data'>\n"; 
    373         $name = "content_group_".$this->id."_content_changes_on_mode"; 
     344        $name = "content_group_" . $this->id . "_content_changes_on_mode"; 
    374345        $i = 0; 
    375346        $tab = null; 
    376         foreach ($this->CONTENT_CHANGES_ON_MODES as $select_mode_id => $select_mode_descr) 
    377         { 
     347        foreach ($this->CONTENT_CHANGES_ON_MODES as $select_mode_id => $select_mode_descr) { 
    378348            $tab[$i][0] = $select_mode_id; 
    379349            $tab[$i][1] = $select_mode_descr; 
    380             $i ++; 
     350            $i++; 
    381351        } 
    382352        $html .= FormSelectGenerator :: generateFromArray($tab, $this->getContentChangesOnMode(), $name, null, false); 
     
    386356        /* allow_repeat*/ 
    387357        $html .= "<li class='admin_element_item_container'>\n"; 
    388         $html .= "<div class='admin_element_label'>"._("Can content be shown more than once to the same user?").": </div>\n"; 
     358        $html .= "<div class='admin_element_label'>" . _("Can content be shown more than once to the same user?") . ": </div>\n"; 
    389359        $html .= "<div class='admin_element_data'>\n"; 
    390         $name = "content_group_".$this->id."_allow_repeat"; 
     360        $name = "content_group_" . $this->id . "_allow_repeat"; 
    391361        $i = 0; 
    392362        $tab = null; 
    393         foreach ($this->ALLOW_REPEAT_MODES as $select_mode_id => $select_mode_descr) 
    394         { 
     363        foreach ($this->ALLOW_REPEAT_MODES as $select_mode_id => $select_mode_descr) { 
    395364            $tab[$i][0] = $select_mode_id; 
    396365            $tab[$i][1] = $select_mode_descr; 
    397             $i ++; 
     366            $i++; 
    398367        } 
    399368        $html .= FormSelectGenerator :: generateFromArray($tab, $this->getAllowRepeat(), $name, null, false); 
     
    403372        /*display_num_elements*/ 
    404373        $html .= "<li class='admin_element_item_container'>\n"; 
    405         $html .= "<div class='admin_element_label'>". ("Pick how many elements for each display?").": </div>\n"; 
     374        $html .= "<div class='admin_element_label'>" . ("Pick how many elements for each display?") . ": </div>\n"; 
    406375        $html .= "<div class='admin_element_data'>\n"; 
    407         $name = "content_group_".$this->id."_display_num_elements"; 
     376        $name = "content_group_" . $this->id . "_display_num_elements"; 
    408377        $value = $this->getDisplayNumElements(); 
    409378        $html .= "<input type='text' size='2' value='$value' name='$name'>\n"; 
     
    411380        $html .= "</li>\n"; 
    412381        $html .= "</fieldset>\n"; 
    413          
     382 
    414383        $html .= "<li class='admin_element_item_container'>\n"; 
    415384        $html .= "<fieldset class='admin_element_group'>\n"; 
    416                 $html .= "<legend>".sprintf(_("%s display element list"),get_class($this))."</legend>\n"; 
     385        $html .= "<legend>" . sprintf(_("%s display element list"), get_class($this)) . "</legend>\n"; 
    417386 
    418387        /* content_group_element*/ 
    419388 
    420389        $html .= "<ul class='admin_element_list'>\n"; 
    421         foreach ($this->getElements() as $element) 
    422         { 
     390        foreach ($this->getElements() as $element) { 
    423391            $html .= "<li class='admin_element_item_container'>\n"; 
    424392            $html .= $element->getAdminUI(null, sprintf(_("%s %d"), get_class($element), $element->getDisplayOrder())); 
    425393            $html .= "<div class='admin_element_tools'>\n"; 
    426             $name = "content_group_".$this->id."_element_".$element->GetId()."_erase"; 
    427             $html .= "<input type='submit' class='submit' name='$name' value='".sprintf(_("Delete %s %d"),get_class($element), $element->getDisplayOrder())."'>"; 
     394            $name = "content_group_" . $this->id . "_element_" . $element->GetId() . "_erase"; 
     395            $html .= "<input type='submit' class='submit' name='$name' value='" . sprintf(_("Delete %s %d"), get_class($element), $element->getDisplayOrder()) . "'>"; 
    428396            $html .= "</div>\n"; 
    429397            $html .= "</li>\n"; 
    430398        } 
    431399        $html .= "<li class='admin_element_item_container'>\n"; 
    432         $html .= self :: getNewContentUI("content_group_{$this->id}_new_element")."<br>"; 
     400        $html .= self :: getNewContentUI("content_group_{$this->id}_new_element") . "<br>"; 
    433401        $html .= "</li>\n"; 
    434402        $html .= "<li class='admin_element_item_container'>\n"; 
     
    442410    } 
    443411 
    444     function processAdminUI() 
    445     { 
     412    function processAdminUI() { 
    446413        // Init values 
    447414        $errmsg = null; 
    448415 
    449         if ($this->isOwner(User :: getCurrentUser()) || User :: getCurrentUser()->isSuperAdmin()) 
    450         { 
     416        if ($this->isOwner(User :: getCurrentUser()) || User :: getCurrentUser()->isSuperAdmin()) { 
    451417            parent :: processAdminUI(); 
    452418 
    453419            /* is_artistic_content */ 
    454             $name = "content_group_".$this->id."_is_artistic_content"; 
     420            $name = "content_group_" . $this->id . "_is_artistic_content"; 
    455421            !empty ($_REQUEST[$name]) ? $this->setIsArtisticContent(true) : $this->setIsArtisticContent(false); 
    456422 
    457423            /* is_locative_content */ 
    458             $name = "content_group_".$this->id."_is_locative_content"; 
     424            $name = "content_group_" . $this->id . "_is_locative_content"; 
    459425            !empty ($_REQUEST[$name]) ? $this->setIsLocativeContent(true) : $this->setIsLocativeContent(false); 
    460426 
    461427            /* content_ordering_mode */ 
    462             $name = "content_group_".$this->id."_content_ordering_mode"; 
     428            $name = "content_group_" . $this->id . "_content_ordering_mode"; 
    463429            $this->setContentOrderingMode(FormSelectGenerator :: getResult($name, null)); 
    464430 
    465431            /*content_changes_on_mode */ 
    466             $name = "content_group_".$this->id."_content_changes_on_mode"; 
     432            $name = "content_group_" . $this->id . "_content_changes_on_mode"; 
    467433            $this->setContentChangesOnMode(FormSelectGenerator :: getResult($name, null)); 
    468434 
    469435            /* allow_repeat*/ 
    470             $name = "content_group_".$this->id."_allow_repeat"; 
     436            $name = "content_group_" . $this->id . "_allow_repeat"; 
    471437            $this->setAllowRepeat(FormSelectGenerator :: getResult($name, null)); 
    472438 
    473439            /*display_num_elements*/ 
    474             $name = "content_group_".$this->id."_display_num_elements"; 
     440            $name = "content_group_" . $this->id . "_display_num_elements"; 
    475441            $this->setDisplayNumElements($_REQUEST[$name]); 
    476442 
    477443            /* content_group_element */ 
    478             foreach ($this->getElements() as $element) 
    479             { 
    480                 $name = "content_group_".$this->id."_element_".$element->GetId()."_erase"; 
    481                 if (!empty ($_REQUEST[$name]) && $_REQUEST[$name] == true) 
    482                 { 
     444            foreach ($this->getElements() as $element) { 
     445                $name = "content_group_" . $this->id . "_element_" . $element->GetId() . "_erase"; 
     446                if (!empty ($_REQUEST[$name]) && $_REQUEST[$name] == true) { 
    483447                    $element->delete($errmsg); 
    484                 } 
    485                 else 
    486                 { 
     448                } else { 
    487449                    $element->processAdminUI(); 
    488450                } 
     
    500462     * @param $node Node, optionnal 
    501463     * @return true or false */ 
    502     public function isDisplayableAt($node) 
    503     { 
    504         $old_curent_node = Node::getCurrentNode(); 
    505         Node::setCurrentNode($node); 
    506  
    507         if (count($this->getDisplayElements())>0) { 
     464    public function isDisplayableAt($node) { 
     465        $old_curent_node = Node :: getCurrentNode(); 
     466        Node :: setCurrentNode($node); 
     467 
     468        if (count($this->getDisplayElements()) > 0) { 
    508469            $retval = true; 
    509470        } else { 
     
    512473 
    513474        if ($old_curent_node != null) { 
    514             Node::setCurrentNode($old_curent_node); 
    515         } 
    516  
    517         return $retval; 
    518     } 
    519  
     475            Node :: setCurrentNode($old_curent_node); 
     476        } 
     477 
     478        return $retval; 
     479    } 
    520480 
    521481    /**Get the next element or elements to be displayed, depending on the display mode 
    522482    * @return an array of ContentGroupElement or an empty arrray */ 
    523     function getDisplayElements() 
    524     { 
     483    function getDisplayElements() { 
    525484        // Define globals 
    526485        global $db; 
     
    533492        $element_rows = null; 
    534493 
    535         if ($user) 
    536         { 
     494        if ($user) { 
    537495            $user_id = $user->getId(); 
    538         } 
    539         else 
    540         { 
     496        } else { 
    541497            $user_id = ''; 
    542498        } 
    543499        $node = Node :: getCurrentNode(); 
    544         if ($node) 
    545         { 
     500        if ($node) { 
    546501            $node_id = $node->getId(); 
    547         } 
    548         else 
    549         { 
     502        } else { 
    550503            $node_id = ''; 
    551504        } 
     
    560513 
    561514        $redisplay_objects = array (); 
    562         if ($content_changes_on_mode != 'ALWAYS') 
    563         { 
     515        if ($content_changes_on_mode != 'ALWAYS') { 
    564516            $sql = "SELECT content_group_element_id FROM content_group_element \n"; 
    565517            $sql .= "JOIN content_display_log ON (content_group_element_id=content_id) \n"; 
    566518            $sql .= " WHERE content_group_id='$this->id' \n"; 
    567519 
    568             if ($content_changes_on_mode == 'NEXT_DAY') 
    569             { 
     520            if ($content_changes_on_mode == 'NEXT_DAY') { 
    570521                $sql .= "AND date_trunc('day', last_display_timestamp) = date_trunc('day', CURRENT_DATE) \n"; 
    571522            } 
    572             if ($content_changes_on_mode == 'NEXT_LOGIN') 
    573             { 
     523            if ($content_changes_on_mode == 'NEXT_LOGIN') { 
    574524                /**@todo Must fix, this will fail if the user never really connected from a hotspot... */ 
    575525                $sql .= "AND last_display_timestamp > (SELECT timestamp_in FROM connections WHERE user_id='$user_id' ORDER BY timestamp_in DESC LIMIT 1) \n"; 
    576526            } 
    577             if ($content_changes_on_mode == 'NEXT_NODE') 
    578             { 
     527            if ($content_changes_on_mode == 'NEXT_NODE') { 
    579528                /** We find the close time of the last connection from another node */ 
    580529                $sql .= "AND last_display_timestamp > (SELECT timestamp_out FROM connections WHERE user_id='$user_id' AND node_id != '$node_id' ORDER BY timestamp_in DESC LIMIT 1) \n"; 
     
    584533            $db->execSql($sql, $redisplay_rows, false); 
    585534            $redisplay_objects = array (); 
    586             if ($redisplay_rows != null) 
    587             { 
    588                 foreach ($redisplay_rows as $redisplay_row) 
    589                 { 
     535            if ($redisplay_rows != null) { 
     536                foreach ($redisplay_rows as $redisplay_row) { 
    590537                    $object = self :: getObject($redisplay_row['content_group_element_id']); 
    591538                    if ($object->isDisplayableAt(Node :: GetCurrentNode()) == true) /** Only content available at this hotspot are considered */ 
    592                     { 
     539                        { 
    593540                        $redisplay_objects[] = $object; 
    594541                    } 
     
    601548 
    602549        $new_objects = array (); 
    603         if (count($redisplay_objects) < $display_num_elements) 
    604         { 
    605             /* We need new content */ 
    606  
    607             $sql = "SELECT content_group_element_id FROM content_group_element WHERE content_group_id='$this->id' \n"; 
     550        if (count($redisplay_objects) < $display_num_elements) { 
     551            /* There aren't enough elements to redisplay, We need new content */ 
     552 
     553            $sql_base = "SELECT content_group_element_id FROM content_group_element WHERE content_group_id='$this->id' \n"; 
     554                        $sql = $sql_base; 
    608555 
    609556            /*'YES' => "Content can be shown more than once", 'NO' => "Content can only be shown once", 'ONCE_PER_NODE' => "Content can be shown more than once, but not at the same node"*/ 
    610557            $allow_repeat = $this->getAllowRepeat(); 
    611  
    612             if ($allow_repeat == 'NO') 
    613             { 
    614                 $sql .= "AND content_group_element_id NOT IN (SELECT content_id FROM content_display_log WHERE user_id = '$user_id') \n"; 
    615             } 
    616             elseif ($allow_repeat == 'ONCE_PER_NODE') 
    617             { 
    618                 $sql .= "AND content_group_element_id NOT IN (SELECT content_id FROM content_display_log WHERE user_id = '$user_id' AND  node_id = '$node_id') \n"; 
    619             } 
    620  
    621             /* 'RANDOM' => "Pick content elements randomly",'SEQUENTIAL' => "Pick content elements in sequential order" */ 
    622             $content_ordering_mode = $this->getContentOrderingMode(); 
    623  
    624             if ($content_ordering_mode == 'SEQUENTIAL') 
    625             { 
    626                 $order_by = ' ORDER BY display_order '; 
    627             $sql_last_order = "SELECT display_order FROM content_group_element \n"; 
    628             $sql_last_order .= "JOIN content_display_log ON (content_group_element_id=content_id) \n"; 
    629             $sql_last_order .= " WHERE content_group_id='$this->id' \n"; 
    630             $sql_last_order .= " ORDER BY last_display_timestamp DESC LIMIT 1"; 
    631             $db->execSqlUniqueRes($sql_last_order, $last_order_row, false); 
    632             if($last_order_row['display_order']!=null) 
    633             { 
    634             $last_order=$last_order_row['display_order']; 
     558            if ($allow_repeat == 'NO') { 
     559                $sql_repeat .= "AND content_group_element_id NOT IN (SELECT content_id FROM content_display_log WHERE user_id = '$user_id') \n"; 
     560            } 
     561            elseif ($allow_repeat == 'ONCE_PER_NODE') { 
     562                $sql_repeat .= "AND content_group_element_id NOT IN (SELECT content_id FROM content_display_log WHERE user_id = '$user_id' AND  node_id = '$node_id') \n"; 
    635563            } 
    636564            else 
    637565            { 
    638             $last_order=0; 
    639             } 
    640             } 
    641             else 
    642             { 
     566            $sql_repeat=null; 
     567            } 
     568            $sql .= $sql_repeat; 
     569 
     570            $content_ordering_mode = $this->getContentOrderingMode(); 
     571            if ($content_ordering_mode == 'SEQUENTIAL') { 
     572                $order_by = ' ORDER BY display_order '; 
     573                //Find the last content displayed 
     574                $sql_last_order = "SELECT display_order FROM content_group_element \n"; 
     575                $sql_last_order .= "JOIN content_display_log ON (content_group_element_id=content_id) \n"; 
     576                $sql_last_order .= " WHERE content_group_id='$this->id' \n"; 
     577                $sql_last_order .= " ORDER BY last_display_timestamp DESC LIMIT 1"; 
     578                $db->execSqlUniqueRes($sql_last_order, $last_order_row, false); 
     579                if ($last_order_row['display_order'] != null) { 
     580                    $last_order = $last_order_row['display_order']; 
     581                } else { 
     582                    $last_order = 0; 
     583                } 
     584            } else { 
    643585                $order_by = ' '; 
    644586            } 
    645587            $sql .= $order_by; 
    646588 
     589$element_rows = null; 
     590if ($content_ordering_mode == 'PSEUDO_RANDOM') { 
     591    //Special case, first get only the rows that haven't been displayed before' 
     592                    $sql_no_repeat = " AND content_group_element_id NOT IN (SELECT content_id FROM content_display_log WHERE user_id = '$user_id') \n"; 
     593                    $db->execSql($sql_base.$sql_no_repeat, $element_rows, false); 
     594} 
     595//Normal case, or there wasn't any undisplayed content in PSEUDO_RANDOM 
     596 if ($element_rows == null) { 
    647597            $db->execSql($sql, $element_rows, false); 
    648             if ($element_rows == null) 
    649             { 
     598 } 
     599            if ($element_rows == null) { 
    650600                $element_rows = array (); 
    651601            } 
    652             foreach ($element_rows as $element_row) 
    653             { 
     602            foreach ($element_rows as $element_row) { 
    654603                $object = self :: getObject($element_row['content_group_element_id']); 
    655604                if ($object->isDisplayableAt(Node :: GetCurrentNode()) == true) /** Only content available at this hotspot are considered */ 
    656                 { 
     605                    { 
    657606                    $new_objects[] = $object; 
    658607                } 
    659608            } 
    660609 
    661             if ($content_ordering_mode == 'RANDOM') 
    662             { 
     610            if ($content_ordering_mode == 'RANDOM' || $content_ordering_mode == 'PSEUDO_RANDOM') { 
    663611                shuffle($new_objects); 
    664612            } 
    665             elseif($content_ordering_mode == 'SEQUENTIAL') 
    666             { 
    667                 foreach($new_objects as $object) 
    668                 { 
    669                     if($object->getDisplayOrder()<=$last_order) 
    670                     { 
    671                         array_push ( $new_objects, array_shift ( $new_objects )); 
     613            elseif ($content_ordering_mode == 'SEQUENTIAL') { 
     614                foreach ($new_objects as $object) { 
     615                    if ($object->getDisplayOrder() <= $last_order) { 
     616                        array_push($new_objects, array_shift($new_objects)); 
    672617                        //echo " Pushed ".$object->getDisplayOrder(); 
    673618                    } 
     
    676621 
    677622            /** Pick the proper number of elements */ 
    678             $num_to_pick = $display_num_elements - count($redisplay_objects); 
     623            $num_to_pick = $display_num_elements -count($redisplay_objects); 
    679624            $new_objects = array_slice($new_objects, 0, $num_to_pick); 
    680625        } 
     
    685630        print_r($new_objects); 
    686631        echo "</pre>"; 
    687 */ 
     632        */ 
    688633        $retval = array_merge($new_objects, $redisplay_objects); 
    689634        //echo count($retval).' returned <br>'; 
     
    696641     * @param $status boolean 
    697642     */ 
    698     protected function setIsExpandable($status) 
    699     { 
    700         if(is_bool($status)) 
     643    protected function setIsExpandable($status) { 
     644        if (is_bool($status)) 
    701645            $this->is_expandable = $status; 
    702646    } 
     
    705649     * Tells if this object could be expanded 
    706650     */ 
    707     protected function isExpandable() 
    708     { 
     651    protected function isExpandable() { 
    709652        return $this->is_expandable; 
    710653    } 
     
    714657     * @param $status boolean 
    715658     */ 
    716     public function setExpandStatus($status) 
    717     { 
    718         if($this->isExpandable() && is_bool($status)) 
    719         { 
     659    public function setExpandStatus($status) { 
     660        if ($this->isExpandable() && is_bool($status)) { 
    720661            //TODO: Try to find a better solution to this problem... 
    721             if($status == true) 
     662            if ($status == true) 
    722663                $this->setTemporaryDisplayNumElements(3000); 
    723664            else 
     
    733674     * NON expandable contents ie PatternLanguage will NEVER return true 
    734675     */ 
    735     public function getExpandStatus() 
    736     { 
    737         if($this->expand_status == null) 
     676    public function getExpandStatus() { 
     677        if ($this->expand_status == null) 
    738678            return false; 
    739679        return $this->expand_status; 
     
    746686     * elements that need to be hidden before subscription 
    747687     * @return The HTML fragment for this interface */ 
    748     public function getUserUI($subclass_user_interface = null, $hide_elements = false) 
    749     { 
     688    public function getUserUI($subclass_user_interface = null, $hide_elements = false) { 
    750689        $html = ''; 
    751         $html .= "<div class='user_ui_container  ".get_class($this)."'>\n"; 
    752  
    753         if($hide_elements == false) 
    754         { 
     690        $html .= "<div class='user_ui_container  " . get_class($this) . "'>\n"; 
     691 
     692        if ($hide_elements == false) { 
    755693            $display_elements = $this->getDisplayElements(); 
    756             if (count($display_elements) > 0) 
    757             { 
    758                 foreach ($display_elements as $display_element) 
    759                 { 
     694            if (count($display_elements) > 0) { 
     695                foreach ($display_elements as $display_element) { 
    760696                    // If the content group logging is disabled, all the children will inherit this property temporarly 
    761                     if($this->getLoggingStatus() == false) 
     697                    if ($this->getLoggingStatus() == false) 
    762698                        $display_element->setLoggingStatus(false); 
    763699                    $html .= $display_element->getUserUI(); 
    764700                } 
    765             } 
    766             else 
    767             { 
    768                 $html .= '<p class="warningmsg">'._("Sorry, no elements available at this hotspot or all elements of the content group have already been shown")."</p>\n"; 
     701            } else { 
     702                $html .= '<p class="warningmsg">' . _("Sorry, no elements available at this hotspot or all elements of the content group have already been shown") . "</p>\n"; 
    769703            } 
    770704        } 
     
    778712    /**Get all elements 
    779713     * @return an array of ContentGroupElement or an empty arrray */ 
    780     function getElements() 
    781     { 
     714    function getElements() { 
    782715        // Define globals 
    783716        global $db; 
     
    789722        $sql = "SELECT content_group_element_id FROM content_group_element WHERE content_group_id='$this->id' ORDER BY display_order"; 
    790723        $db->execSql($sql, $element_rows, false); 
    791         if ($element_rows != null) 
    792         { 
    793             foreach ($element_rows as $element_row) 
    794             { 
     724        if ($element_rows != null) { 
     725            foreach ($element_rows as $element_row) { 
    795726                $retval[] = self :: getObject($element_row['content_group_element_id']); 
    796727            } 
     
    801732    /** Delete this Content from the database 
    802733    */ 
    803     public function delete(& $errmsg) 
    804     { 
    805         if ($this->isPersistent() == false) 
    806         { 
    807             foreach ($this->getElements() as $element) 
    808             { 
     734    public function delete(& $errmsg) { 
     735        if ($this->isPersistent() == false) { 
     736            foreach ($this->getElements() as $element) { 
    809737                $element->delete($errmsg); 
    810738            } 
     
    812740        return parent :: delete($errmsg); 
    813741    } 
    814         /** Reloads the object from the database.  Should normally be called after a set operation. 
    815      * This function is private because calling it from a subclass will call the 
    816      * constructor from the wrong scope */ 
    817     private function refresh() 
    818     { 
     742    /** Reloads the object from the database.  Should normally be called after a set operation. 
     743    * This function is private because calling it from a subclass will call the 
     744    * constructor from the wrong scope */ 
     745    private function refresh() { 
    819746        $this->__construct($this->id); 
    820747    } 
     
    829756 * End: 
    830757 */ 
    831  
    832  
  • trunk/wifidog-auth/wifidog/classes/Network.php

    r1083 r1085  
    177177        $html = ''; 
    178178        $name = $user_prefix; 
    179         $html .= _("Network:")." \n"; 
    180179 
    181180        if ($pre_selected_network) { 
     
    202201                $i ++; 
    203202            } 
     203            $html .= _("Network:")." \n"; 
    204204            $html .= FormSelectGenerator :: generateFromArray($tab, $selected_id, $name, null, false); 
    205205 
     
    208208            foreach ($network_rows as $network_row) //iterates only once... 
    209209                { 
    210                 $html .= " $network_row[name] "; 
     210                //$html .= _("Network:")." \n"; 
     211                //$html .= " $network_row[name] "; 
    211212                $html .= "<input type='hidden' name='$name' value='".htmlspecialchars($network_row['network_id'], ENT_QUOTES, 'UTF-8')."'>"; 
    212213            } 
  • trunk/wifidog-auth/wifidog/classes/Server.php

    r1070 r1085  
    222222 
    223223                if ($_server_row == null && !$silent) { 
    224                         throw new Exception(_("Server::getCurrentServer: Fatal error: Unable to find current server in the database!")); 
     224                        throw new Exception(sprintf(_("Server::getCurrentServer: Fatal error: Unable to find a server matching hostname %s in the database!"), $_SERVER['SERVER_NAME'])); 
    225225                } else if ($_server_row != null) { 
    226226                $_retVal = new self($_server_row['server_id']); 
  • trunk/wifidog-auth/wifidog/include/schema_validate.php

    r1084 r1085  
    4747 * Define current database schema version 
    4848 */ 
    49 define('REQUIRED_SCHEMA_VERSION', 44); 
     49define('REQUIRED_SCHEMA_VERSION', 45); 
    5050 
    5151/** 
     
    909909        } 
    910910 
     911        $new_schema_version = 45; 
     912        if ($schema_version < $new_schema_version) { 
     913            printUpdateVersion($new_schema_version); 
     914            $sql .= "\n\nUPDATE schema_info SET value='$new_schema_version' WHERE tag='schema_version';\n"; 
     915            $sql .= "ALTER TABLE content DROP COLUMN sponsor_info;\n"; 
     916            $sql .= "ALTER TABLE users DROP CONSTRAINT account_origin_fkey;\n"; 
     917            $sql .= "ALTER TABLE users ADD CONSTRAINT account_origin_fkey FOREIGN KEY (account_origin) REFERENCES networks (network_id) ON UPDATE CASCADE ON DELETE CASCADE;\n"; 
     918            $sql .= "ALTER TABLE nodes DROP CONSTRAINT network_id_fkey;\n"; 
     919            $sql .= "ALTER TABLE nodes ADD CONSTRAINT network_id_fkey FOREIGN KEY (network_id) REFERENCES networks (network_id) ON UPDATE CASCADE ON DELETE CASCADE;\n"; 
     920                $sql .= "ALTER TABLE users DROP CONSTRAINT check_account_origin_not_empty;\n"; 
     921                $sql .= "ALTER TABLE connections DROP CONSTRAINT fk_nodes;\n"; 
     922                $sql .= "ALTER TABLE connections ADD CONSTRAINT fk_nodes FOREIGN KEY (node_id) REFERENCES nodes (node_id) ON UPDATE CASCADE ON DELETE CASCADE;\n"; 
     923                $sql .= "ALTER TABLE connections DROP CONSTRAINT fk_users;\n"; 
     924                $sql .= "ALTER TABLE connections ADD CONSTRAINT fk_users FOREIGN KEY (user_id) REFERENCES users (user_id) ON UPDATE CASCADE ON DELETE CASCADE;\n"; 
     925                $sql .= "ALTER TABLE node_stakeholders DROP CONSTRAINT \"$2\";\n"; 
     926                $sql .= "ALTER TABLE node_stakeholders ADD CONSTRAINT fk_users FOREIGN KEY (user_id) REFERENCES users (user_id) ON UPDATE CASCADE ON DELETE CASCADE;\n"; 
     927                        $sql .= "ALTER TABLE network_stakeholders DROP CONSTRAINT \"$1\";\n";    
     928                        $sql .= "ALTER TABLE network_stakeholders ADD CONSTRAINT fk_network FOREIGN KEY (network_id) REFERENCES networks (network_id) ON UPDATE CASCADE ON DELETE CASCADE;\n"; 
     929                        $sql .= "ALTER TABLE network_stakeholders DROP CONSTRAINT \"$2\";\n"; 
     930                        $sql .= "ALTER TABLE network_stakeholders ADD CONSTRAINT fk_users FOREIGN KEY (user_id) REFERENCES users (user_id) ON UPDATE CASCADE ON DELETE CASCADE;\n"; 
     931                        $sql .= "ALTER TABLE content ADD COLUMN title_is_displayed bool;\n"; 
     932                        $sql .= "ALTER TABLE content ALTER COLUMN title_is_displayed SET DEFAULT true;\n"; 
     933            $sql .= "UPDATE content SET title_is_displayed=true;\n";             
     934            $sql .= "ALTER TABLE content ALTER COLUMN title_is_displayed SET NOT NULL;\n\n"; 
     935                                 
     936         
     937        } 
    911938        /* 
    912939        $new_schema_version = 44; 
  • trunk/wifidog-auth/wifidog/media/base_theme/stylesheet.css

    r1070 r1085  
    565565    background-color: rgb(235, 235, 235); 
    566566} 
    567 .user_ui_sponsor_info { 
    568     background-color: rgb(235, 235, 235); 
    569 } 
    570567.list_ui_container { 
    571568    display: inline;