Changeset 1090

Show
Ignore:
Timestamp:
09/06/06 09:01:54 (5 years ago)
Author:
benoitg
Message:

filter content type according to various criteria. Will be used more
extensively in the profile manager.

  • Content manager: Use content type filter to only allow Simple

content types (Content without metadata) to be used for metadata.

banner adds, or any other image rotation. Size constraints not yet
implemented

  • Move externally maintained class.phpmailer.php, class.smtp.php

into lib where they belong

  • DateTime?.php: Make class handle an empty date sensibly.
  • Network.php: Show the network again when there is only one.

It was confusing in some screens.

  • page.php: Clarify error message, and set a more reasonnable

paging cascade:

5 min, 30 min, 2 hours, 1 day, 1 week, 1 month

  • Finally fix #127
  • At last, working content scheduled display and expiration for

ContentGroups?. Archiving does not yet have a UI. Content that expires
will simply seem to disapear.

  • Fix #247 (somebody filed a bug before I commited, conveniently

saving me the need to describe it).

  • The Fix for #106 in [1089] returned non-objects, causing error

messages and not displaying what it was meant to display.

Used Guest instead of Annonymous, which will probably be

used for different purpose in the future.

This re-fix does not include duplicate counting yet.

Splash users are not the only users that could log-in multiple times.

I don't have a staging server here, a fix will be

commited in a few minutes if something goes wrong.

  • Cleanup coments.
  • Sync schemas
Location:
trunk/wifidog-auth
Files:
5 added
58 modified
2 moved

Legend:

Unmodified
Added
Removed
  • trunk/wifidog-auth/CHANGELOG

    r1089 r1090  
     12006-09-06 Benoit Grégoire  <bock@step.polymtl.ca> 
     2        * ContentTypeFilter:  New class, implements #159.  Allows to filter content type according to various criteria.  Will be used more extensively in the profile manager. 
     3        * Content manager:  Use content type filter to only allow Simple content types (Content without metadata) to be used for metadata. 
     4        * New content type BannerAdGroup.  Used (primarily) to display banner adds, or any other image rotation.  Size constraints not yet implemented 
     5        * Move externally maintained class.phpmailer.php, class.smtp.php into lib where they belong 
     6        * DateTime.php: Make class handle an empty date sensibly. 
     7        * Network.php:  Show the network again when there is only one.  It was confusing in some screens. 
     8        * page.php:  Clarify error message, and set a more reasonnable paging cascade: 
     9                5 min, 30 min, 2 hours, 1 day, 1 week, 1 month 
     10        * Finally fix #127 
     11        * At last, working content scheduled display and expiration for ContentGroups.  Archiving does not yet have a UI.  Content that expires will simply seem to disapear. 
     12        * Fix #247 (somebody filed a bug before I commited, conveniently saving me the need to describe it).     
     13        * The Fix for #106 in [1089] returned non-objects, causing error messages and not displaying what it was meant to display.    
     14                This re-fix does not include duplicate counting yet.  Splash users are not the only users that could log-in multiple times.   
     15                I don't have a staging server here, a fix will be commited in a few minutes if something goes wrong. 
     16        * Cleanup coments. 
     17        * Sync schemas 
     18 
    1192006-09-03 Max Horváth <max.horvath@maxspot.de> 
    220        * The term SPLASH_ONLY_USER displayed to people visiting the portal has been 
     
    2644 
    27452006-09-01 Benoit Grégoire  <bock@step.polymtl.ca> 
    28         * Fix #189, #173, 
     46        * Fix #189, #173 
     47 
    2948 
    30492006-09-01 Benoit Grégoire  <bock@step.polymtl.ca> 
  • trunk/wifidog-auth/sql/wifidog-postgres-initial-data.sql

    r1029 r1090  
    1 \connect wifidog; 
    21BEGIN; 
    32-- 
     
    175174-- 
    176175 
    177 INSERT INTO schema_info (tag, value) VALUES ('schema_version', '39'); 
     176INSERT INTO schema_info (tag, value) VALUES ('schema_version', '46'); 
    178177 
    179178 
     
    200199INSERT INTO locales (locales_id) VALUES ('de'); 
    201200INSERT INTO locales (locales_id) VALUES ('pt'); 
     201INSERT INTO locales (locales_id) VALUES ('ja'); 
     202INSERT INTO locales (locales_id) VALUES ('es'); 
    202203 
    203204 
  • trunk/wifidog-auth/sql/wifidog-postgres-schema.sql

    r1024 r1090  
    7373    description text, 
    7474    project_info text, 
    75     sponsor_info text, 
    7675    creation_timestamp timestamp without time zone DEFAULT now(), 
    7776    is_persistent boolean DEFAULT false, 
    7877    long_description text, 
     78    title_is_displayed boolean DEFAULT true NOT NULL, 
    7979    CONSTRAINT content_type_not_empty_string CHECK ((content_type <> ''::text)) 
    8080); 
    8181 
    82  
    83 SET default_with_oids = false; 
    8482 
    8583-- 
     
    9290 
    9391 
    94 SET default_with_oids = true; 
    95  
    9692-- 
    9793-- Name: content_available_display_pages; Type: TABLE; Schema: public; Owner: wifidog; Tablespace:  
     
    10298); 
    10399 
     100 
     101SET default_with_oids = false; 
     102 
     103-- 
     104-- Name: content_clickthrough_log; Type: TABLE; Schema: public; Owner: wifidog; Tablespace:  
     105-- 
     106 
     107CREATE TABLE content_clickthrough_log ( 
     108    user_id text, 
     109    content_id text NOT NULL, 
     110    clickthrough_timestamp timestamp without time zone DEFAULT now() NOT NULL, 
     111    node_id text NOT NULL, 
     112    destination_url text NOT NULL, 
     113    CONSTRAINT content_clickthrough_log_destination_url_check CHECK ((destination_url <> ''::text)) 
     114); 
     115 
     116 
     117SET default_with_oids = true; 
    104118 
    105119-- 
     
    140154    url text, 
    141155    data_blob oid, 
    142     local_binary_size bigint 
     156    local_binary_size bigint, 
     157    creation_date timestamp without time zone DEFAULT now(), 
     158    last_update_date timestamp without time zone DEFAULT now() 
    143159); 
    144160 
     
    151167    pictures_id text NOT NULL, 
    152168    width integer, 
    153     height integer 
     169    height integer, 
     170    hyperlink_url text 
    154171); 
    155172 
     
    209226    display_order integer DEFAULT 1, 
    210227    displayed_content_id text, 
    211     force_only_allowed_node boolean 
     228    force_only_allowed_node boolean, 
     229    valid_from_timestamp timestamp without time zone, 
     230    valid_until_timestamp timestamp without time zone 
    212231); 
    213232 
     
    342361    gmaps_initial_zoom_level integer, 
    343362    gmaps_map_type text DEFAULT 'G_NORMAL_MAP'::text NOT NULL, 
    344     CONSTRAINT networks_gmaps_map_type_check CHECK ((gmaps_map_type <> ''::text)), 
     363    theme_pack text, 
     364    CONSTRAINT networks_gmaps_map_type CHECK ((gmaps_map_type <> ''::text)), 
    345365    CONSTRAINT networks_name CHECK ((name <> ''::text)), 
    346366    CONSTRAINT networks_network_authenticator_class CHECK ((network_authenticator_class <> ''::text)), 
     
    435455 
    436456 
    437 SET default_with_oids = false; 
    438  
    439457-- 
    440458-- Name: servers; Type: TABLE; Schema: public; Owner: wifidog; Tablespace:  
     
    449467    ssl_available boolean DEFAULT false NOT NULL, 
    450468    gmaps_api_key text, 
    451     CONSTRAINT servers_name_check CHECK ((name <> ''::text)), 
    452     CONSTRAINT servers_name_check1 CHECK ((name <> ''::text)) 
    453 ); 
    454  
    455  
    456 SET default_with_oids = true; 
     469    CONSTRAINT servers_hostname CHECK ((name <> ''::text)), 
     470    CONSTRAINT servers_name CHECK ((name <> ''::text)) 
     471); 
     472 
    457473 
    458474-- 
     
    493509    website text, 
    494510    prefered_locale text, 
    495     CONSTRAINT check_account_origin_not_empty CHECK ((account_origin <> ''::text)), 
    496511    CONSTRAINT check_user_not_empty CHECK (((user_id)::text <> ''::text)) 
    497512); 
     
    796811 
    797812-- 
     813-- Name: idx_content_group_element_valid_from_timestamp; Type: INDEX; Schema: public; Owner: wifidog; Tablespace:  
     814-- 
     815 
     816CREATE INDEX idx_content_group_element_valid_from_timestamp ON content_group_element USING btree (valid_from_timestamp); 
     817 
     818 
     819-- 
     820-- Name: idx_content_group_element_valid_until_timestamp; Type: INDEX; Schema: public; Owner: wifidog; Tablespace:  
     821-- 
     822 
     823CREATE INDEX idx_content_group_element_valid_until_timestamp ON content_group_element USING btree (valid_until_timestamp); 
     824 
     825 
     826-- 
    798827-- Name: idx_token; Type: INDEX; Schema: public; Owner: wifidog; Tablespace:  
    799828-- 
     
    945974 
    946975-- 
    947 -- Name: $1; Type: FK CONSTRAINT; Schema: public; Owner: wifidog 
    948 -- 
    949  
    950 ALTER TABLE ONLY network_stakeholders 
    951     ADD CONSTRAINT "$1" FOREIGN KEY (network_id) REFERENCES networks(network_id); 
    952  
    953  
    954 -- 
    955976-- Name: $2; Type: FK CONSTRAINT; Schema: public; Owner: wifidog 
    956977-- 
     
    10201041-- 
    10211042 
    1022 ALTER TABLE ONLY node_stakeholders 
    1023     ADD CONSTRAINT "$2" FOREIGN KEY (user_id) REFERENCES users(user_id); 
    1024  
    1025  
    1026 -- 
    1027 -- Name: $2; Type: FK CONSTRAINT; Schema: public; Owner: wifidog 
    1028 -- 
    1029  
    1030 ALTER TABLE ONLY network_stakeholders 
    1031     ADD CONSTRAINT "$2" FOREIGN KEY (user_id) REFERENCES users(user_id); 
     1043ALTER TABLE ONLY network_has_content 
     1044    ADD CONSTRAINT "$2" FOREIGN KEY (display_area) REFERENCES content_available_display_areas(display_area) ON UPDATE CASCADE ON DELETE CASCADE; 
    10321045 
    10331046 
     
    10571070 
    10581071-- 
    1059 -- Name: $4; Type: FK CONSTRAINT; Schema: public; Owner: wifidog 
    1060 -- 
    1061  
    1062 ALTER TABLE ONLY content 
    1063     ADD CONSTRAINT "$4" FOREIGN KEY (sponsor_info) REFERENCES content(content_id) ON UPDATE CASCADE ON DELETE RESTRICT; 
     1072-- Name: $3; Type: FK CONSTRAINT; Schema: public; Owner: wifidog 
     1073-- 
     1074 
     1075ALTER TABLE ONLY node_has_content 
     1076    ADD CONSTRAINT "$3" FOREIGN KEY (display_area) REFERENCES content_available_display_areas(display_area) ON UPDATE CASCADE ON DELETE CASCADE; 
    10641077 
    10651078 
     
    10771090 
    10781091ALTER TABLE ONLY users 
    1079     ADD CONSTRAINT account_origin_fkey FOREIGN KEY (account_origin) REFERENCES networks(network_id) ON UPDATE CASCADE ON DELETE RESTRICT; 
     1092    ADD CONSTRAINT account_origin_fkey FOREIGN KEY (account_origin) REFERENCES networks(network_id) ON UPDATE CASCADE ON DELETE CASCADE; 
    10801093 
    10811094 
     
    10891102 
    10901103-- 
     1104-- Name: content_clickthrough_log_content_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: wifidog 
     1105-- 
     1106 
     1107ALTER TABLE ONLY content_clickthrough_log 
     1108    ADD CONSTRAINT content_clickthrough_log_content_id_fkey FOREIGN KEY (content_id) REFERENCES content(content_id) ON UPDATE CASCADE ON DELETE CASCADE; 
     1109 
     1110 
     1111-- 
     1112-- Name: content_clickthrough_log_node_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: wifidog 
     1113-- 
     1114 
     1115ALTER TABLE ONLY content_clickthrough_log 
     1116    ADD CONSTRAINT content_clickthrough_log_node_id_fkey FOREIGN KEY (node_id) REFERENCES nodes(node_id) ON UPDATE CASCADE ON DELETE CASCADE; 
     1117 
     1118 
     1119-- 
     1120-- Name: content_clickthrough_log_user_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: wifidog 
     1121-- 
     1122 
     1123ALTER TABLE ONLY content_clickthrough_log 
     1124    ADD CONSTRAINT content_clickthrough_log_user_id_fkey FOREIGN KEY (user_id) REFERENCES users(user_id) ON UPDATE CASCADE ON DELETE CASCADE; 
     1125 
     1126 
     1127-- 
    10911128-- Name: display_location_fkey; Type: FK CONSTRAINT; Schema: public; Owner: wifidog 
    10921129-- 
     
    11051142 
    11061143-- 
     1144-- Name: fk_network; Type: FK CONSTRAINT; Schema: public; Owner: wifidog 
     1145-- 
     1146 
     1147ALTER TABLE ONLY network_stakeholders 
     1148    ADD CONSTRAINT fk_network FOREIGN KEY (network_id) REFERENCES networks(network_id) ON UPDATE CASCADE ON DELETE CASCADE; 
     1149 
     1150 
     1151-- 
    11071152-- Name: fk_node_deployment_status; Type: FK CONSTRAINT; Schema: public; Owner: wifidog 
    11081153-- 
     
    11171162 
    11181163ALTER TABLE ONLY connections 
    1119     ADD CONSTRAINT fk_nodes FOREIGN KEY (node_id) REFERENCES nodes(node_id) ON UPDATE CASCADE ON DELETE RESTRICT; 
     1164    ADD CONSTRAINT fk_nodes FOREIGN KEY (node_id) REFERENCES nodes(node_id) ON UPDATE CASCADE ON DELETE CASCADE; 
    11201165 
    11211166 
     
    11251170 
    11261171ALTER TABLE ONLY connections 
    1127     ADD CONSTRAINT fk_users FOREIGN KEY (user_id) REFERENCES users(user_id) ON UPDATE CASCADE ON DELETE RESTRICT; 
     1172    ADD CONSTRAINT fk_users FOREIGN KEY (user_id) REFERENCES users(user_id) ON UPDATE CASCADE ON DELETE CASCADE; 
     1173 
     1174 
     1175-- 
     1176-- Name: fk_users; Type: FK CONSTRAINT; Schema: public; Owner: wifidog 
     1177-- 
     1178 
     1179ALTER TABLE ONLY node_stakeholders 
     1180    ADD CONSTRAINT fk_users FOREIGN KEY (user_id) REFERENCES users(user_id) ON UPDATE CASCADE ON DELETE CASCADE; 
     1181 
     1182 
     1183-- 
     1184-- Name: fk_users; Type: FK CONSTRAINT; Schema: public; Owner: wifidog 
     1185-- 
     1186 
     1187ALTER TABLE ONLY network_stakeholders 
     1188    ADD CONSTRAINT fk_users FOREIGN KEY (user_id) REFERENCES users(user_id) ON UPDATE CASCADE ON DELETE CASCADE; 
    11281189 
    11291190 
     
    11451206 
    11461207-- 
    1147 -- Name: network_has_content_display_area_fkey; Type: FK CONSTRAINT; Schema: public; Owner: wifidog 
    1148 -- 
    1149  
    1150 ALTER TABLE ONLY network_has_content 
    1151     ADD CONSTRAINT network_has_content_display_area_fkey FOREIGN KEY (display_area) REFERENCES content_available_display_areas(display_area) ON UPDATE CASCADE ON DELETE CASCADE; 
    1152  
    1153  
    1154 -- 
    1155 -- Name: network_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: wifidog 
    1156 -- 
    1157  
    1158 ALTER TABLE ONLY nodes 
    1159     ADD CONSTRAINT network_id_fkey FOREIGN KEY (network_id) REFERENCES networks(network_id) ON UPDATE CASCADE ON DELETE RESTRICT; 
    1160  
    1161  
    1162 -- 
    11631208-- Name: network_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: wifidog 
    11641209-- 
     
    11691214 
    11701215-- 
    1171 -- Name: node_has_content_display_area_fkey; Type: FK CONSTRAINT; Schema: public; Owner: wifidog 
    1172 -- 
    1173  
    1174 ALTER TABLE ONLY node_has_content 
    1175     ADD CONSTRAINT node_has_content_display_area_fkey FOREIGN KEY (display_area) REFERENCES content_available_display_areas(display_area) ON UPDATE CASCADE ON DELETE CASCADE; 
     1216-- Name: network_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: wifidog 
     1217-- 
     1218 
     1219ALTER TABLE ONLY nodes 
     1220    ADD CONSTRAINT network_id_fkey FOREIGN KEY (network_id) REFERENCES networks(network_id) ON UPDATE CASCADE ON DELETE CASCADE; 
    11761221 
    11771222 
  • trunk/wifidog-auth/wifidog/admin/generic_object_admin.php

    r1089 r1090  
    9292$supportsPreview = true; 
    9393$supportsDeletion = true; 
    94  
     94/* 
     95 * Check for the object class to use 
     96 */ 
     97if (empty($_REQUEST['object_class'])) { 
     98    echo "<div class='errormsg'>"._("Sorry, the 'object_class' parameter must be specified")."</div>\n"; 
     99    exit; 
     100} else { 
     101    $class = $_REQUEST['object_class']; 
     102} 
    95103// Init text values 
    96104$createText = sprintf(_("Create %s"), $_REQUEST['object_class']); 
     
    115123 
    116124/* 
    117  * Check for the object class to use 
    118  */ 
    119 if (empty($_REQUEST['object_class'])) { 
    120     echo "<div class='errormsg'>"._("Sorry, the 'object_class' parameter must be specified")."</div>\n"; 
    121     exit; 
    122 } else { 
    123     $class = $_REQUEST['object_class']; 
    124 } 
    125  
    126 /* 
    127125 * Check for action requests 
    128126 */ 
     
    266264    case "Content": 
    267265        $displayShowAllButton = true; 
    268         $objectSelector = Content::getSelectExistingContentUI('object_id', null, ((isset($_REQUEST['display_content']) && $_REQUEST['display_content'] == "all_content") ? false : true), "content_type", "table"); 
     266        ((isset($_REQUEST['display_content']) && $_REQUEST['display_content'] == "all_content") ? $sql_additional_where = null : $sql_additional_where = " AND is_persistent=TRUE "); 
     267        $objectSelector = Content::getSelectExistingContentUI('object_id', $sql_additional_where, null, "content_type", "table"); 
    269268        $displayEditButton = false; 
    270269        break; 
  • trunk/wifidog-auth/wifidog/classes/Authenticator.php

    r1031 r1090  
    6969     * 
    7070     * @var object 
    71      * 
    72      * @access private 
     71 
    7372     */ 
    7473    private $mNetwork; 
     
    8079     * 
    8180     * @return void 
    82      * 
    83      * @access public 
    8481     */ 
    8582    public function __construct($network_id) 
     
    9289     * 
    9390     * @return object Object of current network 
    94      * 
    95      * @access public 
    9691     */ 
    9792    public function getNetwork() 
     
    10499     * 
    105100     * If successfull, returns a User object. 
    106      * 
    107      * @access public 
    108101     */ 
    109102    public function login() 
     
    124117     * 
    125118     * @return void 
    126      * 
    127      * @access public 
    128119     */ 
    129120    public function logout($conn_id = null) 
     
    190181     * 
    191182     * @return void 
    192      * 
    193      * @access public 
    194183     */ 
    195184    public function acctStart($conn_id) 
     
    244233     * 
    245234     * @return void 
    246      * 
    247      * @access public 
    248235     */ 
    249236    public function acctUpdate($conn_id, $incoming, $outgoing) 
     
    264251     * 
    265252     * @return void 
    266      * 
    267      * @access public 
    268253     * */ 
    269254    public function acctStop($conn_id) 
     
    281266     * 
    282267     * @return bool Returns if the class allows registration 
    283      * 
    284      * @access public 
    285268     */ 
    286269    public function isRegistrationPermitted() 
  • trunk/wifidog-auth/wifidog/classes/Authenticators/AuthenticatorLDAP.php

    r1022 r1090  
    6969     * 
    7070     * @var string 
    71      * 
    72      * @access private 
     71 
    7372     */ 
    7473    private $mldap_hostname; 
     
    7877     * 
    7978     * @var string 
    80      * 
    81      * @access private 
     79 
    8280     */ 
    8381    private $mldap_rdn; 
     
    8785     * 
    8886     * @var string 
    89      * 
    90      * @access private 
     87 
    9188     */ 
    9289    private $mldap_pass; 
     
    9693     * 
    9794     * @var string 
    98      * 
    99      * @access private 
     95 
    10096     */ 
    10197    private $mldap_o; 
     
    106102     * 
    107103     * @var string 
    108      * 
    109      * @access private 
     104 
    110105     */ 
    111106    private $mldap_filter; 
     
    129124     * 
    130125     * @return void 
    131      * 
    132      * @access public 
    133126     */ 
    134127        public function __construct($account_orgin, $host, $rdn, $pass, $o, $filter) 
     
    156149     * 
    157150     * @return bool True if the parameter refers to a Local User account origin 
    158      * 
    159      * @access private 
     151 
    160152     */ 
    161153        private function checkLdapUser($username, $password, $ldap_server, $o, $f, &$errmsg = null ) 
     
    237229     * @return object The actual User object if login was successfull, false 
    238230     *                otherwise. 
    239      * 
    240      * @access public 
    241231     */ 
    242232        public function login($username, $password, &$errmsg = null) 
     
    292282     * 
    293283     * @return bool Returns always true 
    294      * 
    295      * @access public 
    296284     */ 
    297285    public function acctStart($conn_id, &$errmsg = null) 
     
    312300     * 
    313301     * @return bool Returns always true 
    314      * 
    315      * @access public 
    316302     */ 
    317303    public function acctUpdate($conn_id, $incoming, $outgoing, &$errmsg = null) 
     
    331317     * 
    332318     * @return bool Returns always true 
    333      * 
    334      * @access public 
    335319     */ 
    336320    public function acctStop($conn_id, &$errmsg = null) 
  • trunk/wifidog-auth/wifidog/classes/Authenticators/AuthenticatorLocalUser.php

    r1031 r1090  
    7171     * 
    7272     * @return void 
    73      * 
    74      * @access public 
    7573     */ 
    7674    public function __construct($account_orgin) 
     
    8684     * 
    8785     * @return bool True if the parameter refers to a Local User account origin 
    88      * 
    89      * @access private 
     86 
    9087     */ 
    9188    private static function isLocalUserAccountOrigin($account_origin) 
     
    107104     * @return object The actual User object if login was successfull, false 
    108105     *                otherwise. 
    109      * 
    110      * @access public 
    111106     */ 
    112107    public function login($username, $password, &$errmsg = null) 
     
    164159     * 
    165160     * @return bool Returns always true 
    166      * 
    167      * @access public 
    168161     */ 
    169162    public function acctStart($conn_id, &$errmsg = null) 
     
    184177     * 
    185178     * @return bool Returns always true 
    186      * 
    187      * @access public 
    188179     */ 
    189180    public function acctUpdate($conn_id, $incoming, $outgoing, &$errmsg = null) 
     
    203194     * 
    204195     * @return bool Returns always true 
    205      * 
    206      * @access public 
    207196     */ 
    208197    public function acctStop($conn_id, &$errmsg = null) 
     
    218207     * 
    219208     * @return bool Returns if the class allows registration 
    220      * 
    221      * @access public 
    222209     */ 
    223210    public function isRegistrationPermitted() 
  • trunk/wifidog-auth/wifidog/classes/Authenticators/AuthenticatorLocalUserNoSignup.php

    r1031 r1090  
    6363     * 
    6464     * @return bool Returns if the class allows registration 
    65      * 
    66      * @access public 
    6765     */ 
    6866    function isRegistrationPermitted() 
  • trunk/wifidog-auth/wifidog/classes/Authenticators/AuthenticatorRadius.php

    r1031 r1090  
    7676     * 
    7777     * @var string 
    78      * 
    79      * @access private 
     78 
    8079     */ 
    8180    private $mRadius_hostname; 
     
    8584     * 
    8685     * @var int 
    87      * 
    88      * @access private 
     86 
    8987     */ 
    9088    private $mRadius_auth_port; 
     
    9492     * 
    9593     * @var int 
    96      * 
    97      * @access private 
     94 
    9895     */ 
    9996    private $mRadius_acct_port; 
     
    103100     * 
    104101     * @var string 
    105      * 
    106      * @access private 
     102 
    107103     */ 
    108104    private $mRadius_secret_key; 
     
    112108     * 
    113109     * @var string 
    114      * 
    115      * @access private 
     110 
    116111     */ 
    117112    private $mRadius_encryption_method; 
     
    133128     * 
    134129     * @return void 
    135      * 
    136      * @access public 
    137130     */ 
    138131    public function __construct($account_orgin, $host = "localhost", $auth_port = 1812, $acct_port = 1813, $secret_key = "", $encryption_method = "CHAP_MD5") 
     
    176169     * @return object The actual User object if login was successfull, 
    177170     *                false otherwise. 
    178      * 
    179      * @access public 
    180171     */ 
    181172    public function login($username, $password, &$errmsg = null) 
     
    314305     * 
    315306     * @return bool Returns whether successful or not 
    316      * 
    317      * @access public 
    318307     */ 
    319308    public function acctStart($conn_id, &$errmsg = null) 
     
    383372     * 
    384373     * @return bool Returns whether successful or not 
    385      * 
    386      * @access public 
    387374     */ 
    388375    function acctUpdate($conn_id, $incoming, $outgoing, & $errmsg = null) 
     
    455442     * 
    456443     * @return bool Returns whether successful or not 
    457      * 
    458      * @access public 
    459444     */ 
    460445    function acctStop($conn_id, &$errmsg = null) 
  • trunk/wifidog-auth/wifidog/classes/Cache.php

    r1013 r1090  
    5757     * Defines if caching is enabled or not 
    5858     * 
    59      * @var bool 
    60      * @access public 
    6159     */ 
    6260    public $isCachingEnabled = false; 
     
    6563     * Lifetime of cache (value in seconds or null). 
    6664     * 
    67      * @var mixed (int or null) 
    68      * @access private 
     65 
    6966     */ 
    7067    private $_lifeTime = null; 
     
    7370     * PEAR::Cache_Lite object. 
    7471     * 
    75      * @var object 
    76      * @access private 
     72 
    7773     */ 
    7874    private $_cacheLite; 
     
    8177     * ID of PEAR::Cache_Lite object. 
    8278     * 
    83      * @var mixed (string or null) 
    84      * @access private 
     79 
    8580     */ 
    8681    private $_cacheID = null; 
     
    8984     * Group of PEAR::Cache_Lite object. 
    9085     * 
    91      * @var string 
    92      * @access private 
     86 
    9387     */ 
    9488    private $_cacheGroup = "default"; 
     
    10195     * 
    10296     * @return void 
    103      * 
    104      * @access public 
    10597     */ 
    10698    public function __construct($id, $group = "default", $lifeTime = null) 
     
    141133     * 
    142134     * @return bool Caching enabled or disabled. 
    143      * 
    144      * @access private 
     135 
    145136     */ 
    146137    private function _cachingEnabled() 
     
    165156     * @return int Lifetime of an cache object in seconds or null if lifetime 
    166157     *             is unlimited 
    167      * 
    168      * @access public 
    169158     */ 
    170159    public function getLifeTime() 
     
    180169     * 
    181170     * @return void 
    182      * 
    183      * @access public 
    184171     */ 
    185172    public function setLifeTime($lifetime) 
     
    201188     * 
    202189     * @return string Data of cache. 
    203      * 
    204      * @access public 
    205190     */ 
    206191    public function getCachedData($cacheType = "string") 
     
    236221     * 
    237222     * @return bool Saving data into cache was successful or not. 
    238      * 
    239      * @access public 
    240223     */ 
    241224    public function saveCachedData($data, $cacheType = "string") 
     
    260243     * 
    261244     * @return bool Removing data from cache was successful or not. 
    262      * 
    263      * @access public 
    264245     */ 
    265246    public function eraseCachedData() 
     
    281262     * 
    282263     * @return bool Removing data from cache was successful or not. 
    283      * 
    284      * @access public 
    285264     */ 
    286265    public function eraseCachedGroupData() 
  • trunk/wifidog-auth/wifidog/classes/Content.php

    r1089 r1090  
    6565     * Id of content 
    6666     * 
     67     * @var string     */ 
     68    protected $id; 
     69 
     70    /** 
     71     * Array containg content from database 
     72     * 
     73     * @var array     */ 
     74    protected $content_row; 
     75 
     76    /** 
     77     * Type of content 
     78     * 
    6779     * @var string 
    68      * 
    69      * @access protected 
    70      */ 
    71     protected $id; 
    72  
    73     /** 
    74      * Array containg content from database 
    75      * 
    76      * @var array 
    77      * 
    78      * @access protected 
    79      */ 
    80     protected $content_row; 
    81  
    82     /** 
    83      * Type of content 
    84      * 
    85      * @var string 
    86      * 
    87      * @access private 
    8880     */ 
    8981    private $content_type; 
    9082 
    9183    /** 
    92      * Definesif content is trivial or not 
     84     * Defines if logging is enabled or not 
    9385     * 
    9486     * @var bool 
    95      * 
    96      * @access private 
    97      */ 
    98     private $is_trivial_content; 
    99  
    100     /** 
    101      * Defines if logging is enabled or not 
    102      * 
    103      * @var bool 
    104      * 
    105      * @access private 
    10687     */ 
    10788    private $is_logging_enabled; 
     
    11697     * 
    11798     * @return void 
    118      * 
    119      * @access private 
    12099     */ 
    121100    private function __construct($content_id) { 
     
    132111 
    133112        if ($row == null) { 
    134             throw new Exception(_("The content with the following id could not be found in the database: ").$content_id); 
     113            throw new Exception(_("The content with the following id could not be found in the database: ") . $content_id); 
    135114        } 
    136115 
     
    141120        // By default content display logging is enabled 
    142121        $this->setLoggingStatus(true); 
    143         $this->log_as_content =& $this; 
     122        $this->log_as_content = & $this; 
    144123    } 
    145124 
     
    148127     * 
    149128     * @return string String representation of the content 
    150      * 
    151      * @access public 
    152129     */ 
    153130    public function __toString() { 
     
    171148     * @return object The newly created Content object, or null if there was an 
    172149     *                error (an exception is also trown) 
    173      * 
    174      * @static 
    175      * @access public 
     150     
    176151     */ 
    177152    public static function createNewObject($content_type = "Content", $id = null) { 
    178             // Define globals 
    179     global $db; 
     153        // Define globals 
     154        global $db; 
    180155 
    181156        if (empty ($id)) { 
     
    212187     * 
    213188     * @return string HTML markup 
    214      * 
    215      * @static 
    216      * @access public 
    217189     */ 
    218190    public static function getCreateNewObjectUI() { 
     
    225197            $tab[$i][0] = $className; 
    226198            $tab[$i][1] = $className; 
    227             $i ++; 
     199            $i++; 
    228200        } 
    229201 
     
    246218     * 
    247219     * @return object The node object or null if no new node was created 
    248      * 
    249      * @static 
    250      * @access public 
    251220     */ 
    252221    public static function processCreateNewObjectUI() { 
     
    270239     * @return object The Content object, or null if there was an error 
    271240     *                (an exception is also thrown) 
    272      * 
    273      * @static 
    274      * @access public 
     241     
    275242     */ 
    276243    public static function getObject($content_id) { 
     
    286253 
    287254        if ($row == null) { 
    288             throw new Exception(_("The content with the following id could not be found in the database: ").$content_id); 
    289         } 
    290  
    291         $contentType = $row['content_type']; 
    292         $object = new $contentType ($content_id); 
    293  
    294         return $object; 
     255            throw new Exception(_("The content with the following id could not be found in the database: ") . $content_id); 
     256        } 
     257        if (!class_exists($row['content_type'])) { 
     258            //throw new Exception(_("The following content type isn't valid: ").$row['content_type']); 
     259            return null; 
     260        } else { 
     261            $object = new $row['content_type'] ($content_id); 
     262            return $object; 
     263        } 
    295264    } 
    296265 
     
    299268     * 
    300269     * @return array An array of class names 
    301      * 
    302      * @static 
    303      * @access public 
    304270     */ 
    305271    public static function getAvailableContentTypes() { 
     
    324290 
    325291        if (!$useCache) { 
    326             $dir = WIFIDOG_ABS_FILE_PATH."classes/Content"; 
     292            $dir = WIFIDOG_ABS_FILE_PATH . "classes/Content"; 
    327293            $dirHandle = @ opendir($dir); 
    328294 
     
    341307                closedir($dirHandle); 
    342308            } else { 
    343                 throw new Exception(_('Unable to open directory ').$dir); 
     309                throw new Exception(_('Unable to open directory ') . $dir); 
    344310            } 
    345311 
     
    357323        return $contentTypes; 
    358324    } 
    359  
     325    /** 
     326     * Check if the ContentType is available on the system     * 
     327     * @param string $classname The classname to check 
     328     * @return true or flase 
     329     */ 
     330    public static function isContentTypeAvailable($classname) { 
     331        if (false === array_search($classname, Content :: getAvailableContentTypes(), true)) { 
     332            //throw new Exception(_("The following content type isn't valid: ").$contentType); 
     333            return false; 
     334        } else { 
     335            return true; 
     336        } 
     337 
     338    } 
     339 
     340    /** 
     341     * Check if this class is a class or subclass of one of the content types given as parameter 
     342     * * 
     343     * @param array $candidates The classnames to check 
     344     * @return true or flase 
     345     */ 
     346    public static function isContentType($candidates, $classname) { 
     347        $retval = false; 
     348        if (false === is_array($candidates)) { 
     349            throw new exception("classnames must be an array"); 
     350        } 
     351        $classname_reflector = new ReflectionClass($classname); 
     352 
     353        foreach ($candidates as $candidate) { 
     354            $candidate_reflector = new ReflectionClass($candidate); 
     355            //echo"classname: $classname, candidate: $candidate<br>"; 
     356            if ($classname_reflector->isSubclassOf($candidate_reflector)) { 
     357                //The content meets the criteria  
     358                //echo "TRUE<br>"; 
     359                $retval = true; 
     360                break; 
     361            } 
     362        } 
     363        return $retval; 
     364    } 
    360365    /** 
    361366     * Get all content 
     
    366371     * 
    367372     * @return mixed Requested content 
    368      * 
    369      * @static 
    370      * @access public 
    371373     */ 
    372374    public static function getAllContent($content_type = "") { 
    373             // Define globals 
    374     global $db; 
     375        // Define globals 
     376        global $db; 
    375377 
    376378        // Init values 
     
    400402     * @param string $user_prefix      A identifier provided by the programmer 
    401403     *                                 to recognise it's generated HTML form 
    402      * @param string $content_type     If set, the created content will be of 
    403      *                                 this type, otherwise, the user will have 
     404     * @param string $content_type_filter     If set, the created content must match the filter.  Of only one type matches,  
     405     * the content will be of this type, otherwise, the user will have 
    404406     *                                 to choose 
    405407     * 
    406408     * @return string HTML markup 
    407      * 
    408      * @static 
    409      * @access public 
    410      */ 
    411     public static function getNewContentUI($user_prefix, $content_type = null, $title = null) { 
    412             // Define globals 
    413     global $db; 
     409     */ 
     410    public static function getNewContentUI($user_prefix, $content_type_filter = null, $title = null) { 
     411        // Define globals 
     412        global $db; 
    414413 
    415414        // Init values 
    416415        $html = ""; 
    417416        $html .= "<fieldset class='admin_container Content'>\n"; 
    418                 if(!empty($title)){ 
    419                 $html .= "<legend>$title</legend>\n"; 
    420                 } 
     417        if (!empty ($title)) { 
     418            $html .= "<legend>$title</legend>\n"; 
     419        } 
    421420 
    422421        $availableContentTypes = self :: getAvailableContentTypes(); 
     
    424423        $name = "get_new_content_{$user_prefix}_content_type"; 
    425424 
    426         if (empty ($content_type)) { 
    427             $label = _("Add new Content of type").": "; 
    428  
    429             $i = 0; 
    430  
    431             foreach ($availableContentTypes as $className) { 
     425        if (!$content_type_filter) { 
     426            //Get an empty filter 
     427            $content_type_filter = ContentTypeFilter :: getObject(array ()); 
     428        } 
     429 
     430        $i = 0; 
     431        $tab = array (); 
     432        foreach ($availableContentTypes as $className) { 
     433            if ($content_type_filter->isAcceptableContentClass($className)) { 
    432434                $tab[$i][0] = $className; 
    433435                $tab[$i][1] = $className; 
    434                 $i ++; 
    435             } 
     436                $i++; 
     437            } 
     438        } 
     439        if (count($tab) > 1) { 
     440            $label = _("Add new Content of type") . ": "; 
    436441            $html .= "<div class='admin_element_data content_add'>"; 
    437442            $html .= $label; 
    438443            $html .= FormSelectGenerator :: generateFromArray($tab, 'TrivialLangstring', $name, null, false); 
    439444            $html .= "</div>"; 
    440         } else { 
    441             if (false === array_search($content_type, $availableContentTypes, true)) { 
    442                 throw new Exception(_("The following content type isn't valid: ").$content_type); 
    443             } 
    444  
    445             $html .= '<input type="hidden" name="'.$name.'" value="'.$content_type.'">'; 
    446         } 
     445        } else 
     446            if (count($tab) == 1) { 
     447                $html .= '<input type="hidden" name="' . $name . '" value="' . $tab[0][0] . '">'; 
     448            } else { 
     449                throw new Exception(_("No content type matches the filter.")); 
     450            } 
    447451 
    448452        $name = "get_new_content_{$user_prefix}_add"; 
    449453 
    450         if ($content_type) { 
    451             $value = sprintf(_("Add a %s"), $content_type); 
     454        if (count($tab) == 1) { 
     455            $value = sprintf(_("Add a %s"), $tab[0][1]); 
    452456        } else { 
    453457            $value = _("Add"); 
     
    455459 
    456460        $html .= "<div class='admin_element_tools'>"; 
    457         $html .= '<input type="submit" class="submit" name="'.$name.'" value="'.$value.'">'; 
     461        $html .= '<input type="submit" class="submit" name="' . $name . '" value="' . $value . '">'; 
    458462        $html .= "</div>"; 
    459463        $html .= "</fieldset>\n"; 
     
    472476     * 
    473477     * @return object The Content object, or null if the user didn't create one 
    474      * 
    475      * @static 
    476      * @access public 
     478     
    477479     */ 
    478480    public static function processNewContentUI($user_prefix, $associate_existing_content = false) { 
    479             // Init values 
    480     $object = null; 
     481        // Init values 
     482        $object = null; 
    481483 
    482484        if ($associate_existing_content == true) { 
     
    522524     * @param string $default_display_area 
    523525     * @return string HTML markup 
    524      * 
    525      * @static 
    526      * @access public 
     526     
    527527     */ 
    528528    public static function getLinkedContentUI($user_prefix, $link_table, $link_table_obj_key_col, $link_table_obj_key, $default_display_page = 'portal', $default_display_area = 'main_area_middle') { 
    529          // Define globals 
    530                 global $db; 
     529        // Define globals 
     530        global $db; 
    531531 
    532532        // Init values 
     
    543543 
    544544        $html .= "<table class='content_management_tools'>\n"; 
    545         $html .= "<th>"._('Display page').'</th><th>'._('Area').'</th><th>'._('Order').'</th><th>'._('Content').'</th><th>'._('Actions').'</th>'."\n"; 
     545        $html .= "<th>" . _('Display page') . '</th><th>' . _('Area') . '</th><th>' . _('Order') . '</th><th>' . _('Content') . '</th><th>' . _('Actions') . '</th>' . "\n"; 
    546546        if ($rows) 
    547547            foreach ($rows as $row) { 
     
    549549                $html .= "<tr class='already_linked_content'>\n"; 
    550550                /* Display page */ 
    551                 $name = "{$user_prefix}_".$content->GetId()."_display_page"; 
    552                 $html .= "<td>".FormSelectGenerator :: generateFromTable('content_available_display_pages', 'display_page', 'display_page', $row['display_page'], $name, null)."</td>\n"; 
    553                 $name = "{$user_prefix}_".$content->GetId()."_display_area"; 
    554                 $html .= "<td>".FormSelectGenerator :: generateFromTable('content_available_display_areas', 'display_area', 'display_area', $row['display_area'], $name, null)."</td>\n"; 
    555                 $name = "{$user_prefix}_".$content->GetId()."_display_order"; 
     551                $name = "{$user_prefix}_" . $content->GetId() . "_display_page"; 
     552                $html .= "<td>" . FormSelectGenerator :: generateFromTable('content_available_display_pages', 'display_page', 'display_page', $row['display_page'], $name, null) . "</td>\n"; 
     553                $name = "{$user_prefix}_" . $content->GetId() . "_display_area"; 
     554                $html .= "<td>" . FormSelectGenerator :: generateFromTable('content_available_display_areas', 'display_area', 'display_area', $row['display_area'], $name, null) . "</td>\n"; 
     555                $name = "{$user_prefix}_" . $content->GetId() . "_display_order"; 
    556556                $html .= "<td><input type='text' name='$name' value='{$row['display_order']}' size=2 class='linked_content_order'></td>\n"; 
    557557                $html .= "<td>\n"; 
     
    559559                $html .= "</td>\n"; 
    560560                $html .= "<td>\n"; 
    561                 $name = "{$user_prefix}_".$content->GetId()."_edit"; 
    562                 $html .= "<input type='button' class='submit' name='$name' value='"._("Edit")."' onClick='window.location.href = \"".GENERIC_OBJECT_ADMIN_ABS_HREF."?object_class=Content&action=edit&object_id=".$content->GetId()."\";'>\n"; 
    563                 $name = "{$user_prefix}_".$content->GetId()."_erase"; 
    564                 $html .= "<input type='submit' class='submit' name='$name' value='"._("Remove")."'>"; 
     561                $name = "{$user_prefix}_" . $content->GetId() . "_edit"; 
     562                $html .= "<input type='button' class='submit' name='$name' value='" . _("Edit") . "' onClick='window.location.href = \"" . GENERIC_OBJECT_ADMIN_ABS_HREF . "?object_class=Content&action=edit&object_id=" . $content->GetId() . "\";'>\n"; 
     563                $name = "{$user_prefix}_" . $content->GetId() . "_erase"; 
     564                $html .= "<input type='submit' class='submit' name='$name' value='" . _("Remove") . "'>"; 
    565565                $html .= "</td>\n"; 
    566566                $html .= "</tr>\n"; 
     
    570570        $html .= "<tr class='add_existing_content'>\n"; 
    571571        $name = "{$user_prefix}_new_existing_display_page"; 
    572         $html .= "<td>".FormSelectGenerator :: generateFromTable('content_available_display_pages', 'display_page', 'display_page', $default_display_page, $name, null)."</td>\n"; 
     572        $html .= "<td>" . FormSelectGenerator :: generateFromTable('content_available_display_pages', 'display_page', 'display_page', $default_display_page, $name, null) . "</td>\n"; 
    573573        $name = "{$user_prefix}_new_existing_display_area"; 
    574         $html .= "<td>".FormSelectGenerator :: generateFromTable('content_available_display_areas', 'display_area', 'display_area', $default_display_area, $name, null)."</td>\n"; 
     574        $html .= "<td>" . FormSelectGenerator :: generateFromTable('content_available_display_areas', 'display_area', 'display_area', $default_display_area, $name, null) . "</td>\n"; 
    575575        $name = "{$user_prefix}_new_existing_display_order"; 
    576576        $html .= "<td><input type='text' name='$name' value='1' size=2 class='linked_content_order'></td>\n"; 
     
    585585        $html .= "<tr class='add_new_content'>\n"; 
    586586        $name = "{$user_prefix}_new_display_page"; 
    587         $html .= "<td>".FormSelectGenerator :: generateFromTable('content_available_display_pages', 'display_page', 'display_page', $default_display_page, $name, null)."</td>\n"; 
     587        $html .= "<td>" . FormSelectGenerator :: generateFromTable('content_available_display_pages', 'display_page', 'display_page', $default_display_page, $name, null) . "</td>\n"; 
    588588        $name = "{$user_prefix}_new_display_area"; 
    589         $html .= "<td>".FormSelectGenerator :: generateFromTable('content_available_display_areas', 'display_area', 'display_area', $default_display_area, $name, null)."</td>\n"; 
     589        $html .= "<td>" . FormSelectGenerator :: generateFromTable('content_available_display_areas', 'display_area', 'display_area', $default_display_area, $name, null) . "</td>\n"; 
    590590        $name = "{$user_prefix}_new_display_order"; 
    591591        $html .= "<td><input type='text' name='$name' value='1' size=2 class='linked_content_order'></td>\n"; 
     
    619619                $content_id = $db->escapeString($content->getId()); 
    620620                $sql = null; 
    621                 $name = "{$user_prefix}_".$content->GetId()."_erase"; 
     621                $name = "{$user_prefix}_" . $content->GetId() . "_erase"; 
    622622                if (!empty ($_REQUEST[$name])) { 
    623623                    $sql .= "DELETE FROM $link_table WHERE $link_table_obj_key_col='$link_table_obj_key' AND content_id = '$content_id';\n"; 
     
    625625                } else { 
    626626                    /* Display page */ 
    627                     $name = "{$user_prefix}_".$content->GetId()."_display_page"; 
     627                    $name = "{$user_prefix}_" . $content->GetId() . "_display_page"; 
    628628                    $new_display_page = FormSelectGenerator :: getResult($name, null); 
    629629                    if ($new_display_page != $row['display_page']) { 
     
    633633                    } 
    634634                    /* Display area */ 
    635                     $name = "{$user_prefix}_".$content->GetId()."_display_area"; 
     635                    $name = "{$user_prefix}_" . $content->GetId() . "_display_area"; 
    636636                    $new_display_area = FormSelectGenerator :: getResult($name, null); 
    637637                    if ($new_display_area != $row['display_area']) { 
     
    640640                    } 
    641641                    /* Display order */ 
    642                     $name = "{$user_prefix}_".$content->GetId()."_display_order"; 
     642                    $name = "{$user_prefix}_" . $content->GetId() . "_display_order"; 
    643643                    if ($_REQUEST[$name] != $row['display_order']) { 
    644644                        $new_display_order = $db->escapeString($_REQUEST[$name]); 
     
    699699     * @param string $sql_additional_where    Addidional where conditions to 
    700700     *                                        restrict the candidate objects 
    701      * @param bool   $show_persistant_content Defines if to list persistant 
    702      *                                        content, only 
     701     * @param string $content_type_filter     If set, the created content must match the filter. 
    703702     * @param string $order                   Order of output (default: by 
    704703     *                                        creation time) 
     
    710709     * 
    711710     * @return string HTML markup 
    712      * 
    713      * @static 
    714      * @access public 
    715      */ 
    716     public static function getSelectExistingContentUI($user_prefix, $sql_additional_where = null, $show_persistant_content = true, $order = "creation_timestamp", $type_interface = "select") 
    717     { 
     711     
     712     */ 
     713    public static function getSelectExistingContentUI($user_prefix, $sql_additional_where = null, $content_type_filter = null, $order = "creation_timestamp", $type_interface = "select") { 
    718714        // Define globals 
    719715        global $db; 
     
    723719        $retVal = array (); 
    724720        $contentRows = null; 
     721        if ($content_type_filter == null) { 
     722            //Get an empty filter 
     723            $content_type_filter = ContentTypeFilter :: getObject(array ()); 
     724        } 
    725725 
    726726        try { 
     
    738738            $html .= "<fieldset class='admin_container Content'>\n"; 
    739739 
    740             if (!empty($title)) { 
     740            if (!empty ($title)) { 
    741741                $html .= "<legend>$title</legend>\n"; 
    742742            } 
    743743 
    744             $html .= _("Add existing content").": "; 
     744            $html .= _("Add existing content") . ": "; 
    745745        } 
    746746 
    747747        $name = "{$user_prefix}"; 
    748748 
    749         if ($show_persistant_content) { 
    750             $sql = "SELECT * FROM content WHERE is_persistent=TRUE $sql_additional_where ORDER BY $order"; 
    751         } else { 
    752             $sql = "SELECT * FROM content $sql_additional_where ORDER BY $order"; 
    753         } 
     749        $sql = "SELECT * FROM content WHERE 1=1 $sql_additional_where ORDER BY $order"; 
    754750 
    755751        $db->execSql($sql, $contentRows, false); 
     
    760756            if ($type_interface == "table") { 
    761757                $html .= "<table class='content_admin'>\n"; 
    762                 $html .= "<tr><th>"._("Title")."</th><th>"._("Content type")."</th><th>"._("Description")."</th><th></th></tr>\n"; 
     758                $html .= "<tr><th>" . _("Title") . "</th><th>" . _("Content type") . "</th><th>" . _("Description") . "</th><th></th></tr>\n"; 
    763759            } 
    764760 
    765761            foreach ($contentRows as $contentRow) { 
    766                 $content = Content::getObject($contentRow['content_id']); 
    767  
    768                 if (User::getCurrentUser()->isSuperAdmin() || $content->isOwner(User::getCurrentUser())) { 
    769                     if ($type_interface != "table") { 
    770                         $tab[$i][0] = $content->getId(); 
    771                         $tab[$i][1] = $content->__toString()." (".get_class($content).")"; 
    772                         $i ++; 
    773                     } else { 
    774                         if (!empty ($contentRow['title'])) { 
    775                             $title = Content :: getObject($contentRow['title']); 
    776                             $titleUI = $title->__toString(); 
     762                $content = Content :: getObject($contentRow['content_id']); 
     763                //echo get_class($content)." ".$contentRow['content_id']."<br>"; 
     764                if ($content && $content_type_filter->isAcceptableContentClass(get_class($content))) { 
     765                    if (User :: getCurrentUser()->isSuperAdmin() || $content->isOwner(User :: getCurrentUser())) { 
     766                        if ($type_interface != "table") { 
     767                            $tab[$i][0] = $content->getId(); 
     768                            $tab[$i][1] = $content->__toString() . " (" . get_class($content) . ")"; 
     769                            $i++; 
    777770                        } else { 
    778                             $titleUI = ""; 
     771                            if (!empty ($contentRow['title'])) { 
     772                                $title = Content :: getObject($contentRow['title']); 
     773                                $titleUI = $title->__toString(); 
     774                            } else { 
     775                                $titleUI = ""; 
     776                            } 
     777 
     778                            if (!empty ($contentRow['description'])) { 
     779                                $description = Content :: getObject($contentRow['description']); 
     780                                $descriptionUI = $description->__toString(); 
     781                            } else { 
     782                                $descriptionUI = ""; 
     783                            } 
     784 
     785                            $href = GENERIC_OBJECT_ADMIN_ABS_HREF . "?object_id={$contentRow['content_id']}&object_class=Content&action=edit"; 
     786                            $html .= "<tr><td>$titleUI</td><td><a href='$href'>{$contentRow['content_type']}</a></td><td>$descriptionUI</td>\n"; 
     787 
     788                            $href = GENERIC_OBJECT_ADMIN_ABS_HREF . "?object_id={$contentRow['content_id']}&object_class=Content&action=delete"; 
     789                            $html .= "<td><a href='$href'>" . _("Delete") . "</a></td>"; 
     790 
     791                            $html .= "</tr>\n"; 
    779792                        } 
    780  
    781                         if (!empty ($contentRow['description'])) { 
    782                             $description = Content :: getObject($contentRow['description']); 
    783                             $descriptionUI = $description->__toString(); 
    784                         } else { 
    785                             $descriptionUI = ""; 
    786                         } 
    787  
    788                         $href = GENERIC_OBJECT_ADMIN_ABS_HREF."?object_id={$contentRow['content_id']}&object_class=Content&action=edit"; 
    789                         $html .= "<tr><td>$titleUI</td><td><a href='$href'>{$contentRow['content_type']}</a></td><td>$descriptionUI</td>\n"; 
    790  
    791                         $href = GENERIC_OBJECT_ADMIN_ABS_HREF."?object_id={$contentRow['content_id']}&object_class=Content&action=delete"; 
    792                         $html .= "<td><a href='$href'>"._("Delete")."</a></td>"; 
    793  
    794                         $html .= "</tr>\n"; 
    795793                    } 
    796794                } 
     
    801799                    $html .= FormSelectGenerator :: generateFromArray($tab, null, $name, null, false, null, null, 40); 
    802800                    //DEBUG!! get_existing_content_ 
    803                      $name = "{$user_prefix}_add"; 
    804                      $value = _("Add"); 
    805                      $html .= "<div class='admin_element_tools'>"; 
    806                                 $html .= '<input type="submit" class="submit" name="'.$name.'" value="'.$value.'">'; 
    807                                 $html .= "</div>"; 
     801                    $name = "{$user_prefix}_add"; 
     802                    $value = _("Add"); 
     803                    $html .= "<div class='admin_element_tools'>"; 
     804                    $html .= '<input type="submit" class="submit" name="' . $name . '" value="' . $value . '">'; 
     805                    $html .= "</div>"; 
    808806                } else { 
    809                     $html .= "<div class='warningmsg'>"._("Sorry, no content available in the database")."</div>\n"; 
     807                    $html .= "<div class='warningmsg'>" . _("Sorry, no elligible content available in the database") . "</div>\n"; 
    810808                } 
    811809                $html .= "</fieldset>\n"; 
     
    814812            } 
    815813        } else { 
    816             $html .= "<div class='warningmsg'>"._("Sorry, no content available in the database")."</div>\n"; 
     814            $html .= "<div class='warningmsg'>" . _("Sorry, no elligible content available in the database") . "</div>\n"; 
    817815        } 
    818816 
     
    892890        global $db; 
    893891        $content_type = $db->escapeString($content_type); 
    894         $available_content_types = self :: getAvailableContentTypes(); 
    895         if (false === array_search($content_type, $available_content_types, true)) { 
    896             throw new Exception(_("The following content type isn't valid: ").$content_type); 
     892        if (!self :: isContentTypeAvailable($content_type)) { 
     893            throw new Exception(_("The following content type isn't valid: ") . $content_type); 
    897894        } 
    898895        $sql = "UPDATE content SET content_type = '$content_type' WHERE content_id='$this->id'"; 
     
    910907    public function addOwner(User $user, $is_author = false) { 
    911908        global $db; 
    912         $content_id = "'".$this->id."'"; 
    913         $user_id = "'".$db->escapeString($user->getId())."'"; 
     909        $content_id = "'" . $this->id . "'"; 
     910        $user_id = "'" . $db->escapeString($user->getId()) . "'"; 
    914911        $is_author ? $is_author = 'TRUE' : $is_author = 'FALSE'; 
    915912        $sql = "INSERT INTO content_has_owners (content_id, user_id, is_author) VALUES ($content_id, $user_id, $is_author)"; 
     
    927924    public function deleteOwner(User $user, $is_author = false) { 
    928925        global $db; 
    929         $content_id = "'".$this->id."'"; 
    930         $user_id = "'".$db->escapeString($user->getId())."'"; 
     926        $content_id = "'" . $this->id . "'"; 
     927        $user_id = "'" . $db->escapeString($user->getId()) . "'"; 
    931928 
    932929        $sql = "DELETE FROM content_has_owners WHERE content_id=$content_id AND user_id=$user_id"; 
     
    10261023    } 
    10271024 
    1028     /** When a content object is set as trivial, it means that is is used merely to contain it's own data.  No title, description or other data will be set or displayed, during display or administration 
    1029      * @param $is_trivial true or false */ 
    1030     public function setIsTrivialContent($is_trivial) { 
    1031         $this->is_trivial_content = $is_trivial; 
    1032     } 
    1033  
     1025    /** When a content object is set as Simple, it means that is is used merely to contain it's own data.  No title, description or other metadata will be set or displayed, during display or administration 
     1026     * @return true or false */ 
     1027    public function isSimpleContent() { 
     1028        return false; 
     1029    } 
    10341030    /** Retreives the user interface of this object.  Anything that overrides this method should call the parent method with it's output at the END of processing. 
    10351031     * @param $subclass_admin_interface Html content of the interface element of a children 
     
    10371033    public function getUserUI($subclass_user_interface = null) { 
    10381034        $html = ''; 
    1039         $html .= "<div class='user_ui_main_outer ".get_class($this)."'>\n"; 
     1035        $html .= "<div class='user_ui_main_outer " . get_class($this) . "'>\n"; 
    10401036        $html .= "<div class='user_ui_main_inner'>\n"; 
    10411037 
    1042         if (!empty ($this->content_row['title'])  && $this->titleShouldDisplay()) { 
     1038        if (!empty ($this->content_row['title']) && $this->titleShouldDisplay()) { 
    10431039            $html .= "<div class='user_ui_title'>\n"; 
    10441040            $title = self :: getObject($this->content_row['title']); 
     
    10601056            $html .= _("Author(s):"); 
    10611057            foreach ($authors as $user) { 
    1062                 $html .= $user->getUsername()." "; 
     1058                $html .= $user->getUsername() . " "; 
    10631059            } 
    10641060            $html .= "</div>\n"; 
     
    10761072        } 
    10771073 
    1078         if (!empty ($this->content_row['project_info']) ) { 
     1074        if (!empty ($this->content_row['project_info'])) { 
    10791075            if (!empty ($this->content_row['project_info'])) { 
    10801076                $html .= "<div class='user_ui_projet_info'>\n"; 
    1081                 $html .= "<b>"._("Project information:")."</b>"; 
     1077                $html .= "<b>" . _("Project information:") . "</b>"; 
    10821078                $project_info = self :: getObject($this->content_row['project_info']); 
    10831079                $project_info->setLogAsContent($this); 
     
    10991095    } 
    11001096 
    1101  
    1102 /** Allow logging as part of another content (usually the parent for metadata). 
    1103  * Redirects clickthrough logging to the parent's content id, and does not log 
    1104  * display */ 
    1105 protected function setLogAsContent(Content $content) 
    1106 { 
    1107    $this->log_as_content = $content; 
    1108 } 
     1097    /** Allow logging as part of another content (usually the parent for metadata). 
     1098     * Redirects clickthrough logging to the parent's content id, and does not log 
     1099     * display */ 
     1100    protected function setLogAsContent(Content $content) { 
     1101        $this->log_as_content = $content; 
     1102    } 
    11091103 
    11101104    /** Log that this content has just been displayed to the user.  Will only log if the user is logged in */ 
    11111105    private function logContentDisplay() { 
    1112         if ($this->getLoggingStatus() == true && $this->log_as_content->getId()==$this->getId()) { 
     1106        if ($this->getLoggingStatus() == true && $this->log_as_content->getId() == $this->getId()) { 
    11131107            // DEBUG:: 
    11141108            //echo "Logging ".get_class($this)." :: ".$this->__toString()."<br>"; 
     
    11321126    } 
    11331127    /** Handle replacements of hyperlinks for clickthrough tracking (if appropriate) */ 
    1134     protected function replaceHyperLinks(&$html) { 
     1128    protected function replaceHyperLinks(& $html) { 
    11351129        /* Handle hyperlink clicktrough logging */ 
    11361130        if ($this->getLoggingStatus() == true) { 
    11371131            $html = HyperLink :: replaceHyperLinks($html, $this->log_as_content); 
    1138             } 
     1132        } 
    11391133        return $html; 
    11401134    } 
     
    11461140        $html = ''; 
    11471141        $html .= "<div class='list_ui_container'>\n"; 
    1148         $html .= $this->__toString()." (".get_class($this).")\n"; 
     1142        $html .= $this->__toString() . " (" . get_class($this) . ")\n"; 
    11491143        $html .= $subclass_list_interface; 
    11501144        $html .= "</div>\n"; 
     
    11601154     * @return string The HTML fragment for this interface. 
    11611155     */ 
    1162     public function getAdminUI($subclass_admin_interface = null, $title=null) { 
     1156    public function getAdminUI($subclass_admin_interface = null, $title = null) { 
    11631157        global $db; 
    11641158 
    11651159        $html = ''; 
    1166         $html .= "<fieldset class='admin_container ".get_class($this)."'>\n"; 
    1167                 if(!empty($title)){ 
    1168                 $html .= "<legend>$title</legend>\n"; 
    1169                 } 
    1170                 $html .= "<ul class='admin_element_list'>\n"; 
     1160        $html .= "<fieldset class='admin_container " . get_class($this) . "'>\n"; 
     1161        if (!empty ($title)) { 
     1162            $html .= "<legend>$title</legend>\n"; 
     1163        } 
     1164        $html .= "<ul class='admin_element_list'>\n"; 
    11711165        if ($this->getObjectType() == 'Content') { 
    11721166            // The object hasn't yet been typed. 
     
    11771171                $tab[$i][0] = $classname; 
    11781172                $tab[$i][1] = $classname; 
    1179                 $i ++; 
    1180             } 
    1181  
    1182             $html .= FormSelectGenerator :: generateFromArray($tab, null, "content_".$this->id."_content_type", "Content", false); 
     1173                $i++; 
     1174            } 
     1175 
     1176            $html .= FormSelectGenerator :: generateFromArray($tab, null, "content_" . $this->id . "_content_type", "Content", false); 
    11831177        } else { 
    1184            // Content metadata 
    1185             if ($this->is_trivial_content == false || $this->isPersistent()) { 
    1186                         $html .= "<fieldset class='admin_element_group'>\n"; 
    1187                                 $html .= "<legend>".sprintf(_("%s MetaData"),get_class($this))."</legend>\n"; 
     1178            $criteria_array = array ( 
     1179                array ( 
     1180                    'isSimpleContent' 
     1181                ) 
     1182            ); 
     1183            $metadada_allowed_content_types = ContentTypeFilter :: getObject($criteria_array); 
     1184 
     1185            // Content metadata 
     1186            if ($this->isSimpleContent() == false || $this->isPersistent()) { 
     1187                $html .= "<fieldset class='admin_element_group'>\n"; 
     1188                $html .= "<legend>" . sprintf(_("%s MetaData"), get_class($this)) . "</legend>\n"; 
    11881189 
    11891190                /* title_is_displayed */ 
    1190                 $html_title_is_displayed = _("Display the title?").": \n"; 
    1191                 $name = "content_".$this->id."_title_is_displayed"; 
     1191                $html_title_is_displayed = _("Display the title?") . ": \n"; 
     1192                $name = "content_" . $this->id . "_title_is_displayed"; 
    11921193                $this->titleShouldDisplay() ? $checked = 'CHECKED' : $checked = ''; 
    11931194                $html_title_is_displayed .= "<input type='checkbox' name='$name' $checked>\n"; 
     
    11971198                $html .= "<div class='admin_element_data'>\n"; 
    11981199                if (empty ($this->content_row['title'])) { 
    1199                     $html .= self :: getNewContentUI("title_{$this->id}_new", null, _("Title:")); 
     1200                    $html .= self :: getNewContentUI("title_{$this->id}_new", $metadada_allowed_content_types, _("Title:")); 
    12001201                    $html .= "</div>\n"; 
    12011202                } else { 
     
    12051206                    $html .= "</div>\n"; 
    12061207                    $html .= "<div class='admin_element_tools admin_section_delete_title'>\n"; 
    1207                     $name = "content_".$this->id."_title_erase"; 
    1208                     $html .= "<input type='submit' class='submit' name='$name' value='".sprintf(_("Delete %s (%s)"),_("title"),get_class($title))."'>"; 
     1208                    $name = "content_" . $this->id . "_title_erase"; 
     1209                    $html .= "<input type='submit' class='submit' name='$name' value='" . sprintf(_("Delete %s (%s)"), _("title"), get_class($title)) . "'>"; 
    12091210                    $html .= "</div>\n"; 
    12101211                } 
     
    12121213            } 
    12131214 
    1214             if ($this->is_trivial_content == false) { 
     1215            if ($this->isSimpleContent() == false) { 
    12151216                /* description */ 
    12161217                $html .= "<li class='admin_element_item_container admin_section_edit_description'>\n"; 
    12171218                $html .= "<div class='admin_element_data'>\n"; 
    12181219                if (empty ($this->content_row['description'])) { 
    1219                     $html .= self :: getNewContentUI("description_{$this->id}_new", null, _("Description:")); 
     1220                    $html .= self :: getNewContentUI("description_{$this->id}_new", $metadada_allowed_content_types, _("Description:")); 
    12201221                    $html .= "</div>\n"; 
    12211222                } else { 
     
    12241225                    $html .= "</div>\n"; 
    12251226                    $html .= "<div class='admin_element_tools'>\n"; 
    1226                     $name = "content_".$this->id."_description_erase"; 
    1227                     $html .= "<input type='submit' class='submit' name='$name' value='".sprintf(_("Delete %s (%s)"),_("description"),get_class($description))."'>"; 
     1227                    $name = "content_" . $this->id . "_description_erase"; 
     1228                    $html .= "<input type='submit' class='submit' name='$name' value='" . sprintf(_("Delete %s (%s)"), _("description"), get_class($description)) . "'>"; 
    12281229                    $html .= "</div>\n"; 
    12291230                } 
     
    12341235                $html .= "<div class='admin_element_data'>\n"; 
    12351236                if (empty ($this->content_row['long_description'])) { 
    1236                     $html .= self :: getNewContentUI("long_description_{$this->id}_new", null, _("Long description:")); 
     1237                    $html .= self :: getNewContentUI("long_description_{$this->id}_new", $metadada_allowed_content_types, _("Long description:")); 
    12371238                    $html .= "</div>\n"; 
    12381239                } else { 
     
    12411242                    $html .= "</div>\n"; 
    12421243                    $html .= "<div class='admin_element_tools'>\n"; 
    1243                     $name = "content_".$this->id."_long_description_erase"; 
    1244                     $html .= "<input type='submit' class='submit' name='$name' value='".sprintf(_("Delete %s (%s)"),_("long description"),get_class($description))."'>"; 
     1244                    $name = "content_" . $this->id . "_long_description_erase"; 
     1245                    $html .= "<input type='submit' class='submit' name='$name' value='" . sprintf(_("Delete %s (%s)"), _("long description"), get_class($description)) . "'>"; 
    12451246                    $html .= "</div>\n"; 
    12461247                } 
     
    12511252                $html .= "<div class='admin_element_data'>\n"; 
    12521253                if (empty ($this->content_row['project_info'])) { 
    1253                     $html .= self :: getNewContentUI("project_info_{$this->id}_new", null, _("Information on this project:")); 
     1254                    $html .= self :: getNewContentUI("project_info_{$this->id}_new", $metadada_allowed_content_types, _("Information on this project:")); 
    12541255                    $html .= "</div>\n"; 
    12551256                } else { 
     
    12581259                    $html .= "</div>\n"; 
    12591260                    $html .= "<div class='admin_element_tools'>\n"; 
    1260                     $name = "content_".$this->id."_project_info_erase"; 
    1261                     $html .= "<input type='submit' class='submit' name='$name' value='".sprintf(_("Delete %s (%s)"),_("project information"),get_class($project_info))."'>"; 
     1261                    $name = "content_" . $this->id . "_project_info_erase"; 
     1262                    $html .= "<input type='submit' class='submit' name='$name' value='" . sprintf(_("Delete %s (%s)"), _("project information"), get_class($project_info)) . "'>"; 
    12621263                    $html .= "</div>\n"; 
    12631264                } 
     
    12661267 
    12671268            //End content medatada 
    1268                         if ($this->is_trivial_content == false || $this->isPersistent()) { 
    1269                         $html .= "</fieldset>\n"; 
    1270                         } 
    1271             if ($this->is_trivial_content == false || $this->isPersistent()) { 
     1269            if ($this->isSimpleContent() == false || $this->isPersistent()) { 
     1270                $html .= "</fieldset>\n"; 
     1271            } 
     1272 
     1273            if ($this->isSimpleContent() == false || $this->isPersistent()) { 
     1274 
    12721275                $html .= "<fieldset class='admin_element_group'>\n"; 
    1273                                 $html .= "<legend>".sprintf(_("%s access control"),get_class($this))."</legend>\n"; 
    1274  
    1275                         /* is_persistent */ 
     1276                $html .= "<legend>" . sprintf(_("%s access control"), get_class($this)) . "</legend>\n"; 
     1277 
     1278                /* is_persistent */ 
    12761279                $html .= "<li class='admin_element_item_container admin_section_edit_persistant'>\n"; 
    1277                 $html .= "<div class='admin_element_label'>"._("Is persistent (reusable and read-only)?").": </div>\n"; 
     1280                $html .= "<div class='admin_element_label'>" . _("Is persistent (reusable and read-only)?") . ": </div>\n"; 
    12781281                $html .= "<div class='admin_element_data'>\n"; 
    1279                 $name = "content_".$this->id."_is_persistent"; 
     1282                $name = "content_" . $this->id . "_is_persistent"; 
    12801283                $this->isPersistent() ? $checked = 'CHECKED' : $checked = ''; 
    12811284                $html .= "<input type='checkbox' name='$name' $checked onChange='submit();'>\n"; 
     
    12851288                /* content_has_owners */ 
    12861289                $html .= "<li class='admin_element_item_container content_has_owners'>\n"; 
    1287                 $html .= "<div class='admin_element_label'>"._("Content owner list")."</div>\n"; 
     1290                $html .= "<div class='admin_element_label'>" . _("Content owner list") . "</div>\n"; 
    12881291                $html .= "<ul class='admin_element_list'>\n"; 
    12891292 
     
    12981301 
    12991302                        $html .= $user->getListUI(); 
    1300                         $name = "content_".$this->id."_owner_".$user->GetId()."_is_author"; 
     1303                        $name = "content_" . $this->id . "_owner_" . $user->GetId() . "_is_author"; 
    13011304                        $html .= " Is content author? "; 
    13021305 
     
    13051308                        $html .= "</div>\n"; 
    13061309                        $html .= "<div class='admin_element_tools'>\n"; 
    1307                         $name = "content_".$this->id."_owner_".$user->GetId()."_remove"; 
    1308                         $html .= "<input type='submit' class='submit' name='$name' value='"._("Remove owner")."'>"; 
     1310                        $name = "content_" . $this->id . "_owner_" . $user->GetId() . "_remove"; 
     1311                        $html .= "<input type='submit' class='submit' name='$name' value='" . _("Remove owner") . "'>"; 
    13091312                        $html .= "</div>\n"; 
    13101313                        $html .= "</li>\n"; 
     
    13311334    } 
    13321335    /** Process admin interface of this object.  When an object overrides this method, they should call the parent processAdminUI at the BEGINING of processing. 
    1333  
     1336     
    13341337    */ 
    13351338    public function processAdminUI() { 
     
    13371340            global $db; 
    13381341            if ($this->getObjectType() == 'Content') /* The object hasn't yet been typed */ { 
    1339                 $content_type = FormSelectGenerator :: getResult("content_".$this->id."_content_type", "Content"); 
     1342                $content_type = FormSelectGenerator :: getResult("content_" . $this->id . "_content_type", "Content"); 
    13401343                $this->setContentType($content_type); 
    1341             } else 
    1342             {//Content medatada 
    1343  
    1344  
    1345                             if ($this->is_trivial_content == false || $this->isPersistent()) { 
    1346                                             /* title_is_displayed */ 
    1347                 if (!empty ($this->content_row['title'])){ 
    1348                 $name = "content_".$this->id."_title_is_displayed"; 
    1349                 !empty ($_REQUEST[$name]) ? $this->setTitleIsDisplayed(true) : $this->setTitleIsDisplayed(false); 
    1350                 } 
     1344            } else { 
     1345                //Content medatada 
     1346 
     1347                if ($this->isSimpleContent() == false || $this->isPersistent()) { 
     1348                    /* title_is_displayed */ 
     1349                    if (!empty ($this->content_row['title'])) { 
     1350                        $name = "content_" . $this->id . "_title_is_displayed"; 
     1351                        !empty ($_REQUEST[$name]) ? $this->setTitleIsDisplayed(true) : $this->setTitleIsDisplayed(false); 
     1352                    } 
    13511353                    /* title */ 
    13521354                    if (empty ($this->content_row['title'])) { 
     
    13581360                    } else { 
    13591361                        $title = self :: getObject($this->content_row['title']); 
    1360                         $name = "content_".$this->id."_title_erase"; 
     1362                        $name = "content_" . $this->id . "_title_erase"; 
    13611363                        if (!empty ($_REQUEST[$name]) && $_REQUEST[$name] == true) { 
    13621364                            $db->execSqlUpdate("UPDATE content SET title = NULL WHERE content_id = '$this->id'", FALSE); 
     
    13661368                        } 
    13671369                    } 
    1368                             } 
    1369                             if ($this->is_trivial_content == false) { 
     1370                } 
     1371                if ($this->isSimpleContent() == false) { 
    13701372                    /* description */ 
    13711373                    if (empty ($this->content_row['description'])) { 
     
    13771379                    } else { 
    13781380                        $description = self :: getObject($this->content_row['description']); 
    1379                         $name = "content_".$this->id."_description_erase"; 
     1381                        $name = "content_" . $this->id . "_description_erase"; 
    13801382                        if (!empty ($_REQUEST[$name]) && $_REQUEST[$name] == true) { 
    13811383                            $db->execSqlUpdate("UPDATE content SET description = NULL WHERE content_id = '$this->id'", FALSE); 
     
    13951397                    } else { 
    13961398                        $long_description = self :: getObject($this->content_row['long_description']); 
    1397                         $name = "content_".$this->id."_long_description_erase"; 
     1399                        $name = "content_" . $this->id . "_long_description_erase"; 
    13981400                        if (!empty ($_REQUEST[$name]) && $_REQUEST[$name] == true) { 
    13991401                            $db->execSqlUpdate("UPDATE content SET long_description = NULL WHERE content_id = '$this->id'", FALSE); 
     
    14131415                    } else { 
    14141416                        $project_info = self :: getObject($this->content_row['project_info']); 
    1415                         $name = "content_".$this->id."_project_info_erase"; 
     1417                        $name = "content_" . $this->id . "_project_info_erase"; 
    14161418                        if (!empty ($_REQUEST[$name]) && $_REQUEST[$name] == true) { 
    14171419                            $db->execSqlUpdate("UPDATE content SET project_info = NULL WHERE content_id = '$this->id'", FALSE); 
     
    14211423                        } 
    14221424                    } 
    1423                 }//End content metadata 
    1424  
    1425            if ($this->is_trivial_content == false || $this->isPersistent()) { 
     1425                } //End content metadata 
     1426 
     1427                if ($this->isSimpleContent() == false || $this->isPersistent()) { 
    14261428                    /* is_persistent */ 
    1427                     $name = "content_".$this->id."_is_persistent"; 
     1429                    $name = "content_" . $this->id . "_is_persistent"; 
    14281430                    !empty ($_REQUEST[$name]) ? $this->setIsPersistent(true) : $this->setIsPersistent(false); 
    14291431 
     
    14351437                            $user = User :: getObject($content_owner_row['user_id']); 
    14361438                            $user_id = $user->getId(); 
    1437                             $name = "content_".$this->id."_owner_".$user->GetId()."_remove"; 
     1439                            $name = "content_" . $this->id . "_owner_" . $user->GetId() . "_remove"; 
    14381440                            if (!empty ($_REQUEST[$name])) { 
    14391441                                $this->deleteOwner($user); 
    14401442                            } else { 
    1441                                 $name = "content_".$this->id."_owner_".$user->GetId()."_is_author"; 
     1443                                $name = "content_" . $this->id . "_owner_" . $user->GetId() . "_is_author"; 
    14421444                                $content_owner_row['is_author'] == 't' ? $is_author = true : $is_author = false; 
    14431445                                !empty ($_REQUEST[$name]) ? $should_be_author = true : $should_be_author = false; 
     
    14601462                        $this->addOwner($user); 
    14611463                    } 
    1462            } 
    14631464                } 
     1465            } 
    14641466            $this->refresh(); 
    14651467        } 
     
    15791581     * Load requested content class 
    15801582     */ 
    1581     require_once ('classes/Content/'.$class_name.'/'.$class_name.'.php'); 
     1583    require_once ('classes/Content/' . $class_name . '/' . $class_name . '.php'); 
    15821584} 
    15831585 
  • trunk/wifidog-auth/wifidog/classes/Content/Avatar/Avatar.php

    r1070 r1090  
    6262     * @param string $content_id Content id 
    6363     * 
    64      * @return void 
    65      * 
    66      * @access protected 
    67      */ 
     64     * @return void     */ 
    6865    protected function __construct($content_id) 
    6966    { 
    7067        parent :: __construct($content_id); 
    71         $this->setIsTrivialContent(true); 
    7268    } 
    7369 
     70    /** When a content object is set as Simple, it means that is is used merely to contain it's own data.  No title, description or other metadata will be set or displayed, during display or administration 
     71     * @return true or false */ 
     72    public function isSimpleContent() { 
     73        return true; 
     74    } 
     75     
    7476    /** 
    7577     * Shows the administration interface for Avatar 
     
    137139     * 
    138140     * @return void 
    139      * 
    140      * @access public 
    141141     */ 
    142142    public function processAdminUI() 
     
    151151     * 
    152152     * @return string The HTML fragment for this interface 
    153      * 
    154      * @access public 
    155153     */ 
    156154    public function getUserUI() 
     
    173171     * 
    174172     * @return void 
    175      * 
    176      * @access private 
     173 
    177174     */ 
    178175    private function refresh() 
  • trunk/wifidog-auth/wifidog/classes/Content/ContentGroup/ContentGroup.php

    r1088 r1090  
    4848 */ 
    4949require_once ('classes/Content/ContentGroup/ContentGroupElement.php'); 
     50require_once ('classes/ContentTypeFilter.php'); 
    5051 
    5152/** 
     
    5960class ContentGroup extends Content { 
    6061 
    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     ); 
    77  
    78     protected $is_artistic_content; 
    79     protected $is_locative_content; 
    80  
    81     // is_expandable is ONLY for internal use, it use normally only set by the constructor 
    82     private $is_expandable = true; 
    83     // this is the actual publicly available status ( so if is_expandable == true it CANNOT be true ) 
    84     private $expand_status = false; 
    85     private $temporary_display_num_elements; 
    86  
    87     private $content_selection_mode; 
    88     private $content_group_row; 
    89  
    90     protected function __construct($content_id) { 
    91         // Define globals 
    92         global $db; 
    93  
    94         // Init values 
    95         $row = null; 
    96  
    97         parent :: __construct($content_id); 
    98  
    99         $content_id = $db->escapeString($content_id); 
    100  
    101         $sql = "SELECT * FROM content_group WHERE content_group_id='$content_id'"; 
    102         $db->execSqlUniqueRes($sql, $row, false); 
    103         if ($row == null) { 
    104             /*Since the parent Content exists, the necessary data in content_group had not yet been created */ 
    105             $sql = "INSERT INTO content_group (content_group_id) VALUES ('$content_id')"; 
    106             $db->execSqlUpdate($sql, false); 
    107             $sql = "SELECT * FROM content_group WHERE content_group_id='$content_id'"; 
    108             $db->execSqlUniqueRes($sql, $row, false); 
    109             if ($row == null) { 
    110                 throw new Exception(_("The content with the following id could not be found in the database: ") . $content_id); 
    111             } 
    112  
    113         } 
    114  
    115         $this->content_group_row = $row; 
    116  
    117         // These are for internal use only ( private and protected methods ) for dealing with expanding content 
    118         $this->setTemporaryDisplayNumElements(null); 
    119     } 
    120  
    121     /** Is the content group artistic in nature? 
    122      * @return true or false */ 
    123     public function isArtisticContent() { 
    124         if ($this->content_group_row['is_artistic_content'] == 't') { 
    125             $retval = true; 
    126         } else { 
    127             $retval = false; 
    128         } 
    129         return $retval; 
    130     } 
    131  
    132     /** Set if the content group is artistic in nature, 
    133      * @param $is_artistic_content true or false*/ 
    134     public function setIsArtisticContent($is_artistic_content) { 
    135         if ($is_artistic_content != $this->isArtisticContent()) /* Only update database if there is an actual change */ { 
    136             $is_artistic_content ? $is_artistic_content_sql = 'TRUE' : $is_artistic_content_sql = 'FALSE'; 
    137  
    138             global $db; 
    139             $db->execSqlUpdate("UPDATE content_group SET is_artistic_content = $is_artistic_content_sql WHERE content_group_id = '$this->id'", false); 
    140             $this->refresh(); 
    141         } 
    142  
    143     } 
    144  
    145     /** Does the content shown or generated by the content group directly related to where it is viewed from? 
    146      * @return true or false */ 
    147     public function isLocativeContent() { 
    148         if ($this->content_group_row['is_locative_content'] == 't') { 
    149             $retval = true; 
    150         } else { 
    151             $retval = false; 
    152         } 
    153         return $retval; 
    154     } 
    155  
    156     /** Set if the content group is locative 
    157      * @param $is_locative_content true or false 
    158      * */ 
    159     public function setIsLocativeContent($is_locative_content) { 
    160         if ($is_locative_content != $this->isLocativeContent()) /* Only update database if there is an actual change */ { 
    161             $is_locative_content ? $is_locative_content_sql = 'TRUE' : $is_locative_content_sql = 'FALSE'; 
    162  
    163             global $db; 
    164             $db->execSqlUpdate("UPDATE content_group SET is_locative_content = $is_locative_content_sql WHERE content_group_id = '$this->id'", false); 
    165             $this->refresh(); 
    166         } 
    167  
    168     } 
    169  
    170     /** In what order is the content displayed to the user 
    171     * @return string, a key of CONTENT_SELECTION_MODES */ 
    172     public function getContentOrderingMode() { 
    173         return $this->content_group_row['content_ordering_mode']; 
    174     } 
    175  
    176     /** In what order is the content displayed to the user 
    177      * @param $content_ordering_mode One of the CONTENT_ORDERING_MODES constants defined in the class 
    178      * @return true if successfull 
    179      * */ 
    180     protected function setContentOrderingMode($content_ordering_mode, & $errormsg = null) { 
    181         $retval = false; 
    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 */ { 
    183             global $db; 
    184             $content_ordering_mode = $db->escapeString($content_ordering_mode); 
    185             $db->execSqlUpdate("UPDATE content_group SET content_ordering_mode = '$content_ordering_mode' WHERE content_group_id = '$this->id'", false); 
    186             $this->refresh(); 
    187             $retval = true; 
    188         } 
    189         elseif (!isset ($this->CONTENT_ORDERING_MODES[$content_ordering_mode])) { 
    190             $errormsg = _("Invalid content selection mode (must be part of CONTENT_ORDERING_MODES)"); 
    191             $retval = false; 
    192         } else { 
    193             /* Successfull, but nothing modified */ 
    194             $retval = true; 
    195         } 
    196         return $retval; 
    197     } 
    198  
    199     /** When does the content rotate? 
    200     * @return string, a key of CONTENT_SELECTION_MODES */ 
    201     public function getContentChangesOnMode() { 
    202         return $this->content_group_row['content_changes_on_mode']; 
    203     } 
    204  
    205     /** When does the content rotate? 
    206      * @param $content_changes_on_mode One of the content_changes_on_modeS constants defined in the class 
    207      * @return true if successfull 
    208      * */ 
    209     protected function setContentChangesOnMode($content_changes_on_mode, & $errormsg = null) { 
    210         $retval = false; 
    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 */ { 
    212             global $db; 
    213             $content_changes_on_mode = $db->escapeString($content_changes_on_mode); 
    214             $db->execSqlUpdate("UPDATE content_group SET content_changes_on_mode = '$content_changes_on_mode' WHERE content_group_id = '$this->id'", false); 
    215             $this->refresh(); 
    216             $retval = true; 
    217         } 
    218         elseif (!isset ($this->CONTENT_CHANGES_ON_MODES[$content_changes_on_mode])) { 
    219             $errormsg = _("Invalid content selection mode (must be part of CONTENT_CHANGES_ON_MODES)"); 
    220             $retval = false; 
    221         } else { 
    222             /* Successfull, but nothing modified */ 
    223             $retval = true; 
    224         } 
    225         return $retval; 
    226     } 
    227  
    228     /** Can the same content be shown twice 
    229      * @return 'YES', 'NO', 'ONCE_PER_NODE' */ 
    230     public function getAllowRepeat() { 
    231         return $this->content_group_row['allow_repeat']; 
    232     } 
    233  
    234     /** When does the content rotate? 
    235      * @param $allow_repeat One of the allow_repeatS constants defined in the class 
    236      * @return true if successfull 
    237      * */ 
    238     protected function setAllowRepeat($allow_repeat, & $errormsg = null) { 
    239         $retval = false; 
    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 */ { 
    241             global $db; 
    242             $allow_repeat = $db->escapeString($allow_repeat); 
    243             $db->execSqlUpdate("UPDATE content_group SET allow_repeat = '$allow_repeat' WHERE content_group_id = '$this->id'", false); 
    244             $this->refresh(); 
    245             $retval = true; 
    246         } 
    247         elseif (!isset ($this->ALLOW_REPEAT_MODES[$allow_repeat])) { 
    248             $errormsg = _("Invalid content selection mode (must be part of ALLOW_REPEAT_MODES)"); 
    249             $retval = false; 
    250         } else { 
    251             /* Successfull, but nothing modified */ 
    252             $retval = true; 
    253         } 
    254         return $retval; 
    255     } 
    256  
    257     /** How many element should be picked for display at once? 
    258     * @return integer */ 
    259     public function getDisplayNumElements() { 
    260         if ($this->temporary_display_num_elements == null) 
    261             return $this->content_group_row['display_num_elements']; 
    262         else 
    263             return $this->temporary_display_num_elements; 
    264     } 
    265  
    266     /** How many element should be picked for display at once? 
    267     * @param $display_num_elements integer, must be greater than zero. 
    268     * @return true if successfull 
    269     * */ 
    270     protected function setDisplayNumElements($display_num_elements, & $errormsg = null) { 
    271         $retval = false; 
    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 */ { 
    273             global $db; 
    274             $display_num_elements = $db->escapeString($display_num_elements); 
    275             $db->execSqlUpdate("UPDATE content_group SET display_num_elements = '$display_num_elements' WHERE content_group_id = '$this->id'", false); 
    276             $this->refresh(); 
    277             $retval = true; 
    278         } 
    279         elseif ($display_num_elements <= 0) { 
    280             $errormsg = _("You must display at least one element"); 
    281             $retval = false; 
    282         } else { 
    283             /* Successfull, but nothing modified */ 
    284             $retval = true; 
    285         } 
    286         return $retval; 
    287     } 
    288  
    289     /** 
    290      * This will a temporary limit ( NOT ACTUALLY STORED IN DATABASE ) 
    291      * Use getDisplayNumElements to get the number of elements that can be shown 
    292      * at once 
    293      */ 
    294     private function setTemporaryDisplayNumElements($temporary_num_elements) { 
    295         $this->temporary_display_num_elements = $temporary_num_elements; 
    296     } 
    297  
    298     public function getAdminUI($subclass_admin_interface = null, $title = null) { 
    299         $html = ''; 
    300         $html .= "<fieldset class='admin_element_group'>\n"; 
    301         $html .= "<legend>" . sprintf(_("%s configuration"), get_class($this)) . "</legend>\n"; 
    302  
    303         /* is_artistic_content */ 
    304         $html .= "<li class='admin_element_item_container'>\n"; 
    305         $html .= "<div class='admin_element_label'>Is artistic content?: </div>\n"; 
    306         $html .= "<div class='admin_element_data'>\n"; 
    307         $name = "content_group_" . $this->id . "_is_artistic_content"; 
    308         $this->isArtisticContent() ? $checked = 'CHECKED' : $checked = ''; 
    309         $html .= "<input type='checkbox' name='$name' $checked>\n"; 
    310         $html .= "</div>\n"; 
    311         $html .= "</li>\n"; 
    312  
    313         /* is_locative_content */ 
    314         $html .= "<li class='admin_element_item_container'>\n"; 
    315         $html .= "<div class='admin_element_label'>" . ("Is locative content?") . ": </div>\n"; 
    316         $html .= "<div class='admin_element_data'>\n"; 
    317         $name = "content_group_" . $this->id . "_is_locative_content"; 
    318         $this->isLocativeContent() ? $checked = 'CHECKED' : $checked = ''; 
    319         $html .= "<input type='checkbox' name='$name' $checked>\n"; 
    320         $html .= "</div>\n"; 
    321         $html .= "</li>\n"; 
    322  
    323         /* content_ordering_mode */ 
    324         $html .= "<li class='admin_element_item_container'>\n"; 
    325         $html .= "<div class='admin_element_label'>" . _("In what order should the content displayed?") . ": </div>\n"; 
    326         $html .= "<div class='admin_element_data'>\n"; 
    327         $name = "content_group_" . $this->id . "_content_ordering_mode"; 
    328  
    329         $i = 0; 
    330         $tab = null; 
    331         foreach ($this->CONTENT_ORDERING_MODES as $select_mode_id => $select_mode_descr) { 
    332             $tab[$i][0] = $select_mode_id; 
    333             $tab[$i][1] = $select_mode_descr; 
    334             $i++; 
    335         } 
    336         $html .= FormSelectGenerator :: generateFromArray($tab, $this->getContentOrderingMode(), $name, null, false); 
    337         $html .= "</div>\n"; 
    338         $html .= "</li>\n"; 
    339  
    340         /*content_changes_on_mode */ 
    341         $html .= "<li class='admin_element_item_container'>\n"; 
    342         $html .= "<div class='admin_element_label'>" . _("When does the content rotate?") . ": </div>\n"; 
    343         $html .= "<div class='admin_element_data'>\n"; 
    344         $name = "content_group_" . $this->id . "_content_changes_on_mode"; 
    345         $i = 0; 
    346         $tab = null; 
    347         foreach ($this->CONTENT_CHANGES_ON_MODES as $select_mode_id => $select_mode_descr) { 
    348             $tab[$i][0] = $select_mode_id; 
    349             $tab[$i][1] = $select_mode_descr; 
    350             $i++; 
    351         } 
    352         $html .= FormSelectGenerator :: generateFromArray($tab, $this->getContentChangesOnMode(), $name, null, false); 
    353         $html .= "</div>\n"; 
    354         $html .= "</li>\n"; 
    355  
    356         /* allow_repeat*/ 
    357         $html .= "<li class='admin_element_item_container'>\n"; 
    358         $html .= "<div class='admin_element_label'>" . _("Can content be shown more than once to the same user?") . ": </div>\n"; 
    359         $html .= "<div class='admin_element_data'>\n"; 
    360         $name = "content_group_" . $this->id . "_allow_repeat"; 
    361         $i = 0; 
    362         $tab = null; 
    363         foreach ($this->ALLOW_REPEAT_MODES as $select_mode_id => $select_mode_descr) { 
    364             $tab[$i][0] = $select_mode_id; 
    365             $tab[$i][1] = $select_mode_descr; 
    366             $i++; 
    367         } 
    368         $html .= FormSelectGenerator :: generateFromArray($tab, $this->getAllowRepeat(), $name, null, false); 
    369         $html .= "</div>\n"; 
    370         $html .= "</li>\n"; 
    371  
    372         /*display_num_elements*/ 
    373         $html .= "<li class='admin_element_item_container'>\n"; 
    374         $html .= "<div class='admin_element_label'>" . ("Pick how many elements for each display?") . ": </div>\n"; 
    375         $html .= "<div class='admin_element_data'>\n"; 
    376         $name = "content_group_" . $this->id . "_display_num_elements"; 
    377         $value = $this->getDisplayNumElements(); 
    378         $html .= "<input type='text' size='2' value='$value' name='$name'>\n"; 
    379         $html .= "</div>\n"; 
    380         $html .= "</li>\n"; 
    381         $html .= "</fieldset>\n"; 
    382  
    383         $html .= "<li class='admin_element_item_container'>\n"; 
    384         $html .= "<fieldset class='admin_element_group'>\n"; 
    385         $html .= "<legend>" . sprintf(_("%s display element list"), get_class($this)) . "</legend>\n"; 
    386  
    387         /* content_group_element*/ 
    388  
    389         $html .= "<ul class='admin_element_list'>\n"; 
    390         foreach ($this->getElements() as $element) { 
    391             $html .= "<li class='admin_element_item_container'>\n"; 
    392             $html .= $element->getAdminUI(null, sprintf(_("%s %d"), get_class($element), $element->getDisplayOrder())); 
    393             $html .= "<div class='admin_element_tools'>\n"; 
    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()) . "'>"; 
    396             $html .= "</div>\n"; 
    397             $html .= "</li>\n"; 
    398         } 
    399         $html .= "<li class='admin_element_item_container'>\n"; 
    400         $html .= self :: getNewContentUI("content_group_{$this->id}_new_element") . "<br>"; 
    401         $html .= "</li>\n"; 
    402         $html .= "<li class='admin_element_item_container'>\n"; 
    403         $html .= self :: getSelectExistingContentUI("content_group_{$this->id}_existing_element", "AND content_id != '$this->id'"); 
    404         $html .= "</li>\n"; 
    405         $html .= "</ul>\n"; 
    406         $html .= "</fieldset>\n"; 
    407         $html .= "</li>\n"; 
    408         $html .= $subclass_admin_interface; 
    409         return parent :: getAdminUI($html, $title); 
    410     } 
    411  
    412     function processAdminUI() { 
    413         // Init values 
    414         $errmsg = null; 
    415  
    416         if ($this->isOwner(User :: getCurrentUser()) || User :: getCurrentUser()->isSuperAdmin()) { 
    417             parent :: processAdminUI(); 
    418  
    419             /* is_artistic_content */ 
    420             $name = "content_group_" . $this->id . "_is_artistic_content"; 
    421             !empty ($_REQUEST[$name]) ? $this->setIsArtisticContent(true) : $this->setIsArtisticContent(false); 
    422  
    423             /* is_locative_content */ 
    424             $name = "content_group_" . $this->id . "_is_locative_content"; 
    425             !empty ($_REQUEST[$name]) ? $this->setIsLocativeContent(true) : $this->setIsLocativeContent(false); 
    426  
    427             /* content_ordering_mode */ 
    428             $name = "content_group_" . $this->id . "_content_ordering_mode"; 
    429             $this->setContentOrderingMode(FormSelectGenerator :: getResult($name, null)); 
    430  
    431             /*content_changes_on_mode */ 
    432             $name = "content_group_" . $this->id . "_content_changes_on_mode"; 
    433             $this->setContentChangesOnMode(FormSelectGenerator :: getResult($name, null)); 
    434  
    435             /* allow_repeat*/ 
    436             $name = "content_group_" . $this->id . "_allow_repeat"; 
    437             $this->setAllowRepeat(FormSelectGenerator :: getResult($name, null)); 
    438  
    439             /*display_num_elements*/ 
    440             $name = "content_group_" . $this->id . "_display_num_elements"; 
    441             $this->setDisplayNumElements($_REQUEST[$name]); 
    442  
    443             /* content_group_element */ 
    444             foreach ($this->getElements() as $element) { 
    445                 $name = "content_group_" . $this->id . "_element_" . $element->GetId() . "_erase"; 
    446                 if (!empty ($_REQUEST[$name]) && $_REQUEST[$name] == true) { 
    447                     $element->delete($errmsg); 
    448                 } else { 
    449                     $element->processAdminUI(); 
    450                 } 
    451             } 
    452  
    453             // The two following calls will either add a new element or add an existing one ( depending on what button the user clicked 
    454             /* We explicitely call the ContentGroupElement version of processNewContentUI */ 
    455             ContentGroupElement :: processNewContentUI("content_group_{$this->id}_new_element", $this); 
    456             // Last parameters allows for existing content ( if any was selected ) 
    457             ContentGroupElement :: processNewContentUI("content_group_{$this->id}_existing_element", $this, true); 
    458         } 
    459     } 
    460  
    461     /** Is this Content element displayable at this hotspot 
    462      * @param $node Node, optionnal 
    463      * @return true or false */ 
    464     public function isDisplayableAt($node) { 
    465         $old_curent_node = Node :: getCurrentNode(); 
    466         Node :: setCurrentNode($node); 
    467  
    468         if (count($this->getDisplayElements()) > 0) { 
    469             $retval = true; 
    470         } else { 
    471             $retval = false; 
    472         } 
    473  
    474         if ($old_curent_node != null) { 
    475             Node :: setCurrentNode($old_curent_node); 
    476         } 
    477  
    478         return $retval; 
    479     } 
    480  
    481     /**Get the next element or elements to be displayed, depending on the display mode 
    482     * @return an array of ContentGroupElement or an empty arrray */ 
    483     function getDisplayElements() { 
    484         // Define globals 
    485         global $db; 
    486  
    487         // Init values 
    488         $retval = array (); 
    489         $user = User :: getCurrentUser(); 
    490         $redisplay_rows = null; 
    491         $last_order_row = null; 
    492         $element_rows = null; 
    493  
    494         if ($user) { 
    495             $user_id = $user->getId(); 
    496         } else { 
    497             $user_id = ''; 
    498         } 
    499         $node = Node :: getCurrentNode(); 
    500         if ($node) { 
    501             $node_id = $node->getId(); 
    502         } else { 
    503             $node_id = ''; 
    504         } 
    505         $display_num_elements = $this->getDisplayNumElements(); 
    506  
    507         /** First, find if we have content to display again because we haven't passed the rotation period */ 
    508         /*  'ALWAYS' => "Content always rotates" 
    509          *  'NEXT_DAY' => "Content rotates once per day" 
    510          *  'NEXT_LOGIN' => "Content rotates once per session" 
    511          *  'NEXT_NODE' => "Content rotates each time you change node"*/ 
    512         $content_changes_on_mode = $this->getContentChangesOnMode(); 
    513  
    514         $redisplay_objects = array (); 
    515         if ($content_changes_on_mode != 'ALWAYS') { 
    516             $sql = "SELECT content_group_element_id FROM content_group_element \n"; 
    517             $sql .= "JOIN content_display_log ON (content_group_element_id=content_id) \n"; 
    518             $sql .= " WHERE content_group_id='$this->id' \n"; 
    519  
    520             if ($content_changes_on_mode == 'NEXT_DAY') { 
    521                 $sql .= "AND date_trunc('day', last_display_timestamp) = date_trunc('day', CURRENT_DATE) \n"; 
    522             } 
    523             if ($content_changes_on_mode == 'NEXT_LOGIN') { 
    524                 /**@todo Must fix, this will fail if the user never really connected from a hotspot... */ 
    525                 $sql .= "AND last_display_timestamp > (SELECT timestamp_in FROM connections WHERE user_id='$user_id' ORDER BY timestamp_in DESC LIMIT 1) \n"; 
    526             } 
    527             if ($content_changes_on_mode == 'NEXT_NODE') { 
    528                 /** We find the close time of the last connection from another node */ 
    529                 $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"; 
    530             } 
    531             /* There usually won't be more than one, but if there is, we want the most recents */ 
    532             $sql .= " ORDER BY last_display_timestamp DESC "; 
    533             $db->execSql($sql, $redisplay_rows, false); 
    534             $redisplay_objects = array (); 
    535             if ($redisplay_rows != null) { 
    536                 foreach ($redisplay_rows as $redisplay_row) { 
    537                     $object = self :: getObject($redisplay_row['content_group_element_id']); 
    538                     if ($object->isDisplayableAt(Node :: GetCurrentNode()) == true) /** Only content available at this hotspot are considered */ 
    539                         { 
    540                         $redisplay_objects[] = $object; 
    541                     } 
    542                 } 
    543             } 
    544             /* Pick the proper number of elements to be re-displayed */ 
    545             $redisplay_objects = array_slice($redisplay_objects, 0, $display_num_elements); 
    546  
    547         } 
    548  
    549         $new_object