Changeset 858 in ExiteCMS


Ignore:
Timestamp:
09/29/07 21:51:40 (4 years ago)
Author:
hverton
Message:

Added language selection and language detection
When adding a new member as sponsor, the member will be added to the 'Sponsors' user_group
Added missing index.php to the new cache directories

Location:
trunk
Files:
2 added
13 edited

Legend:

Unmodified
Added
Removed
  • trunk

    • Property svn:ignore
      •  

        old new  
        11Copy of config.php 
         2config.backup.php 
        23config.php 
  • trunk/administration/adverts.php

    r834 r858  
    8484                                $action = "list"; 
    8585                            } 
    86                         }  
     86                        } 
    8787                    } else { 
    8888                        $errormessage = $locale['921']; // ad not found in the database 
     
    106106    switch($action) { 
    107107        case "add": 
    108             if (isNum($_POST['new_sponsor'])) $result = dbquery("UPDATE ".$db_prefix."users SET user_sponsor = '1' WHERE user_id = '".$_POST['new_sponsor']."'"); 
     108            if (isNum($_POST['new_sponsor'])) { 
     109                $result = dbquery("UPDATE ".$db_prefix."users SET user_sponsor = '1' WHERE user_id = '".$_POST['new_sponsor']."'"); 
     110                // add the new sponsor to the sponsors usergroup 
     111                $result = dbquery("SELECT group_id FROM ".$db_prefix."user_groups WHERE group_ident = 'wE01'"); 
     112                if ($result) { 
     113                    $data = dbarray($result); 
     114                    $result = dbquery("SELECT user_groups FROM ".$db_prefix."users WHERE user_id = '".$_POST['new_sponsor']."'"); 
     115                    if ($result) { 
     116                        $data2 = dbarray($result); 
     117                        $result = dbquery("UPDATE ".$db_prefix."users SET user_groups = '".$data2['user_groups'].".".$data['group_id']."' WHERE user_id = '".$_POST['new_sponsor']."'"); 
     118                    } 
     119                } 
     120            } 
    109121            $action = "list"; 
    110122            break; 
     
    240252            $result = dbquery("DELETE FROM ".$db_prefix."adverts WHERE adverts_userid = '$id'"); 
    241253            $result = dbquery("UPDATE ".$db_prefix."users SET user_sponsor = '0' WHERE user_id = '$id'"); 
     254 
     255            // remove the sponsor to the sponsors usergroup 
     256            $result = dbquery("SELECT group_id FROM ".$db_prefix."user_groups WHERE group_ident = 'wE01'"); 
     257            if ($result) { 
     258                $group_id = dbarray($result); 
     259                $group_id = '.'.$group_id['group_id']; 
     260                $result = dbquery("SELECT user_groups FROM ".$db_prefix."users WHERE user_id = '$id'"); 
     261                if ($result) { 
     262                    $data2 = dbarray($result); 
     263                    $result = dbquery("UPDATE ".$db_prefix."users SET user_groups = '".str_replace($group_id, '', $data2['user_groups'])."' WHERE user_id = '$id'"); 
     264                } 
     265            } 
     266 
    242267            $errortitle = $locale['476']; 
    243268            $errormessage = $locale['910']; 
  • trunk/administration/settings_languages.php

    r834 r858  
    7777$variables['settings2'] = $settings2; 
    7878 
    79 $variables['locale_files'] = makefilelist(PATH_LOCALE, ".|..", true, "folders"); 
     79$variables['locales'] = array(); 
     80$result = dbquery("SELECT locale_name FROM ".$db_prefix."locale WHERE locale_active = '1' ORDER BY locale_name"); 
     81while ($data = dbarray($result)) { 
     82    $variables['locales'][] = $data['locale_name']; 
     83} 
    8084 
    8185// define the admin body panel 
  • trunk/administration/tools/update_geoip.php

    r697 r858  
    11<?php  
    2 require_once dirname(__FILE__)."/../../maincore.php"; 
     2require_once dirname(__FILE__)."/../../includes/core_functions.php"; 
    33 
    44// webmaster or CGI tool only! 
  • trunk/administration/upgrade/rev00850.php

    r857 r858  
    3737 
    3838// add the language settings admin module to the admin table and give all webmasters access 
    39 $commands[] = array('type' => 'db', 'value' => "INSERT INTO TABLE ##PREFIX##admin (admin_rights, admin_image, admin_title, admin_link, admin_page) VALUES ('S7', 'settings_lang.gif', 'Language Setiings', 'settings_language.php', '3')"); 
     39$commands[] = array('type' => 'db', 'value' => "INSERT INTO ##PREFIX##admin (admin_rights, admin_image, admin_title, admin_link, admin_page) VALUES ('S7', 'settings_lang.gif', 'Language Setiings', 'settings_language.php', '3')"); 
    4040$commands[] = array('type' => 'db', 'value' => "UPDATE ##PREFIX##users SET user_rights = CONCAT(user_rights, '.S7') WHERE user_level = 103"); 
    4141 
  • trunk/administration/user_groups.php

    r834 r858  
    6868        $title = $locale['408']; 
    6969        $variables['message'] = $locale['411']; 
     70    } elseif ($status == "dels") { 
     71        $title = $locale['408']; 
     72        $variables['message'] = $locale['419']; 
    7073    } 
    7174    // define the message panel variables 
     
    200203} elseif (isset($_POST['delete'])) { 
    201204 
     205    $result = dbquery("SELECT group_ident FROM ".$db_prefix."user_groups WHERE group_id = '$group_id'"); 
     206    if ($result) { 
     207        $data = dbarray($result); 
     208        if ($data['group_ident'] != "") { 
     209            redirect(FUSION_SELF.$aidlink."&status=dels"); 
     210        } 
     211    } 
    202212    if (dbcount("(*)", "users", "user_groups REGEXP('^\\\.{$group_id}$|\\\.{$group_id}\\\.|\\\.{$group_id}$')") != 0) { 
    203213        redirect(FUSION_SELF.$aidlink."&status=deln"); 
  • trunk/edit_profile.php

    r834 r858  
    3838    $error = ""; $set_avatar = ""; 
    3939    $variables['update_profile'] = true; 
    40      
     40 
     41    $result = dbquery("SELECT locale_code, locale_name FROM ".$db_prefix."locale WHERE locale_id = '".$_POST['user_locale']."'"); 
     42    if ($data = dbarray($result)) { 
     43        if ($data['locale_name'] != $settings['locale']) { 
     44            die('setting locale cookie: '.$data['locale_code']); 
     45            setcookie("locale", $data['locale_code'], time() + 31536000, "/", "", "0"); 
     46        } 
     47    } 
    4148    $username = trim(eregi_replace(" +", " ", $_POST['user_name'])); 
    4249    if ($username == "" || $_POST['user_email'] == "" || $_POST['user_fullname'] == "" ) { 
     
    207214$variables['this_userdata'] = $this_userdata; 
    208215 
     216$variables['locales'] = array(); 
     217$result = dbquery("SELECT locale_id, locale_name FROM ".$db_prefix."locale WHERE locale_active = '1' ORDER BY locale_name"); 
     218while ($data = dbarray($result)) { 
     219    $data['selected'] = $data['locale_name'] == $settings['locale']; 
     220    $variables['locales'][] = $data; 
     221} 
     222 
    209223// define the search body panel variables 
    210224$template_panels[] = array('type' => 'body', 'name' => 'edit_profile', 'template' => 'main.edit_profile.tpl', 'locale' => array(PATH_LOCALE.LOCALESET."members-profile.php", PATH_LOCALE.LOCALESET."user_fields.php")); 
  • trunk/includes/core_functions.php

    r845 r858  
    107107define ("BASEDIR", strstr(substr(strstr($settings['siteurl'], '://'),3), '/')); 
    108108 
     109// locale detection - step 1 - check if there's a locale cookie set 
     110if (isset($_COOKIE['locale'])) { 
     111    // check if we (still) support this language. If so, update the locale setting 
     112    $result = dbquery("SELECT * FROM ".$db_prefix."locale WHERE locale_code = '".$_COOKIE['locale']."' AND locale_active = '1'"); 
     113    if ($data = dbarray($result)) { 
     114        $settings['locale'] = $data['locale_name']; 
     115        define("LOCALESET", $settings['locale']."/"); 
     116    } 
     117} 
     118 
     119// locale detection - step 2 - check the browsers accepted languages 
     120if (!defined('LOCALESET') && isset($_SERVER['HTTP_ACCEPT_LANGUAGE']) && !empty($_SERVER['HTTP_ACCEPT_LANGUAGE'])) { 
     121    // check which languages are supported by the users browser 
     122    $temp = explode(",", $_SERVER['HTTP_ACCEPT_LANGUAGE']); 
     123    foreach($temp as $lng) { 
     124        $thislng = explode(";", $lng); 
     125        // check if we support this language 
     126        $result = dbquery("SELECT * FROM ".$db_prefix."locale WHERE locale_code = '".$thislng[0]."' AND locale_active = '1'"); 
     127        if ($data = dbarray($result)) { 
     128            // if so, set the locale 
     129            $settings['locale'] = $data['locale_name']; 
     130            define("LOCALESET", $settings['locale']."/"); 
     131            break; 
     132        } 
     133    } 
     134    // if not found, loop again on languages only 
     135    if (!defined('LOCALESET')) { 
     136        foreach($temp as $lng) { 
     137            $thislng = explode(";", $lng); 
     138            $thislng = explode("-", $thislng); 
     139            // check if we support this language 
     140            $result = dbquery("SELECT * FROM ".$db_prefix."locale WHERE locale_code = '".$thislng[0]."' AND locale_active = '1'"); 
     141            if ($data = dbarray($result)) { 
     142                // if so, set the locale 
     143                $settings['locale'] = $data['locale_name']; 
     144                define("LOCALESET", $settings['locale']."/"); 
     145                break; 
     146            } 
     147        } 
     148    } 
     149} 
     150 
     151// locale detection - step 3 - use the website's default 
     152if (!defined('LOCALESET')) { 
     153    define("LOCALESET", $settings['locale']."/"); 
     154} 
     155 
    109156// URL path definitions relative to BASEDIR 
    110 define("LOCALESET", $settings['locale']."/"); 
    111157define("ADMIN", BASEDIR."administration/"); 
    112158define("IMAGES", BASEDIR."images/"); 
     
    144190 
    145191// Browser window dimensions (assume 1024x768 if no cookies found) 
    146 define("BROWSER_WIDTH", isset($_COOKIE['width'])?$_COOKIE['width']:1024); 
    147 define("BROWSER_HEIGHT", isset($_COOKIE['height'])?$_COOKIE['height']:768); 
     192define("BROWSER_WIDTH", isset($_COOKIE['width']) ? $_COOKIE['width'] : 1024); 
     193define("BROWSER_HEIGHT", isset($_COOKIE['height']) ? $_COOKIE['height'] : 768); 
    148194 
    149195// Initialise the $locale array 
     
    172218 
    173219// image types we support 
    174 $imagetypes = array( 
    175     ".bmp", 
    176     ".gif", 
    177     ".iff", 
    178     ".jpg", 
    179     ".jpeg", 
    180     ".png", 
    181     ".psd", 
    182     ".tiff", 
    183     ".wbmp" 
    184 ); 
     220$imagetypes = array(".bmp",".gif",".iff",".jpg",".jpeg",".png",".psd",".tiff",".wbmp"); 
    185221 
    186222// image types we can generate a thumbnail from 
    187 $thumbtypes = array( 
    188     ".gif", 
    189     ".jpg", 
    190     ".jpeg", 
    191     ".png", 
    192 ); 
     223$thumbtypes = array(".gif",".jpg",".jpeg",".png",); 
    193224 
    194225// debug function, handy to print a standard debug text 
     
    761792        } 
    762793        if ($data['user_status'] == 0) {     
    763             if (isset($_POST['remember_me'])) { 
    764                 setcookie("remember_me", "yes", time() + 31536000, "/", "", "0"); 
    765                 $cookie_exp = time() + 3600*24*30; 
    766             } else { 
    767                 setcookie("remember_me", "yes", time() - 7200, "/", "", "0"); 
    768                 $cookie_exp = time() + 60*30; 
    769             } 
     794            $cookie_exp = time() + 60*30; 
    770795            header("P3P: CP='NOI ADM DEV PSAi COM NAV OUR OTRo STP IND DEM'"); 
    771796            setcookie("userinfo", $cookie_value, $cookie_exp, "/", "", "0"); 
  • trunk/includes/templates/admin.settings_languages.tpl

    r843 r858  
    2525            <td width='50%' class='tbl'> 
    2626                <select name='localeset' class='textbox'> 
    27                     {foreach from=$locale_files item=file} 
     27                    {foreach from=$locales item=file} 
    2828                    <option value='{$file}'{if $settings2.locale == $file} selected{/if}>{$file}</option> 
    2929                    {/foreach} 
  • trunk/includes/templates/main.edit_profile.tpl

    r843 r858  
    8484                </td> 
    8585                <td class='tbl'> 
    86                     <input type='radio' name='user_hide_email' value='1' {if $this_userdata.user_hide_email == "1"}checked{/if} />{$locale.u007} 
    87                     <input type='radio' name='user_hide_email' value='0' {if $this_userdata.user_hide_email == "0"}checked{/if} />{$locale.u008} 
     86                    <input type='radio' name='user_hide_email' value='1' {if $this_userdata.user_hide_email == "1"}checked="checked"{/if} />{$locale.u007} 
     87                    <input type='radio' name='user_hide_email' value='0' {if $this_userdata.user_hide_email == "0"}checked="checked"{/if} />{$locale.u008} 
    8888                </td> 
    8989            </tr> 
     
    9393                </td> 
    9494                <td class='tbl'> 
    95                     <input type='radio' name='user_newsletters' value='1' {if $this_userdata.user_newsletters == "1"}checked{/if} />{$locale.u037} 
    96                     <input type='radio' name='user_newsletters' value='2' {if $this_userdata.user_newsletters == "2"}checked{/if} />{$locale.u038} 
    97                     <input type='radio' name='user_newsletters' value='0' {if $this_userdata.user_newsletters == "0"}checked{/if} />{$locale.u039} 
     95                    <input type='radio' name='user_newsletters' value='1' {if $this_userdata.user_newsletters == "1"}checked="checked"{/if} />{$locale.u037} 
     96                    <input type='radio' name='user_newsletters' value='2' {if $this_userdata.user_newsletters == "2"}checked="checked"{/if} />{$locale.u038} 
     97                    <input type='radio' name='user_newsletters' value='0' {if $this_userdata.user_newsletters == "0"}checked="checked"{/if} />{$locale.u039} 
    9898                </td> 
    9999            </tr> 
     
    103103                </td> 
    104104                <td class='tbl'> 
    105                     <input type='radio' name='user_forum_fullscreen' value='1' {if $this_userdata.user_forum_fullscreen == "1"}checked{/if} />{$locale.u007} 
    106                     <input type='radio' name='user_forum_fullscreen' value='0' {if $this_userdata.user_forum_fullscreen == "0"}checked{/if} />{$locale.u008} 
     105                    <input type='radio' name='user_forum_fullscreen' value='1' {if $this_userdata.user_forum_fullscreen == "1"}checked="checked"{/if} />{$locale.u007} 
     106                    <input type='radio' name='user_forum_fullscreen' value='0' {if $this_userdata.user_forum_fullscreen == "0"}checked="checked"{/if} />{$locale.u008} 
    107107                </td> 
    108108            </tr> 
     
    123123                    {if $field == "D"} 
    124124                    <select name='user_day' class='textbox'> 
    125                         <option> </option> 
     125                        <option>&nbsp;</option> 
    126126                        {section name=d start=1 loop=32} 
    127                             <option{if $smarty.section.d.index == $user_day} selected{/if}>{$smarty.section.d.index}</option> 
     127                            <option{if $smarty.section.d.index == $user_day} selected="selected"{/if}>{$smarty.section.d.index}</option> 
    128128                        {/section} 
    129129                    </select> 
    130130                    {elseif $field == "M"} 
    131131                    <select name='user_month' class='textbox'> 
    132                         <option> </option> 
     132                        <option>&nbsp;</option> 
    133133                        {section name=m start=1 loop=13} 
    134                             <option{if $smarty.section.m.index == $user_month} selected{/if}>{$smarty.section.m.index}</option> 
     134                            <option{if $smarty.section.m.index == $user_month} selected="selected"{/if}>{$smarty.section.m.index}</option> 
    135135                        {/section} 
    136136                    </select> 
    137137                    {elseif $field == "Y"} 
    138138                    <select name='user_year' class='textbox'> 
    139                         <option> </option> 
     139                        <option>&nbsp;</option> 
    140140                        {section name=y start=1900 loop=$smarty.now|date_format:"%Y"} 
    141                             <option{if $smarty.section.y.index == $user_year} selected{/if}>{$smarty.section.y.index}</option> 
     141                            <option{if $smarty.section.y.index == $user_year} selected="selected"{/if}>{$smarty.section.y.index}</option> 
    142142                        {/section} 
    143143                    </select> 
     
    185185                <td class='tbl'> 
    186186                    <input type='text' name='user_web' value='{$this_userdata.user_web}' maxlength='100' class='textbox' style='width:200px;' /> 
     187                </td> 
     188            </tr> 
     189            <tr> 
     190                <td class='tbl'> 
     191                    {$locale.u028} 
     192                </td> 
     193                <td class='tbl'> 
     194                    <select name='user_locale' class='textbox' style='width:200px;'> 
     195                        {section name=locales loop=$locales} 
     196                            <option value='{$locales[locales].locale_id}'{if $locales[locales].selected} selected="selected"{/if}>{$locales[locales].locale_name}</option> 
     197                        {/section} 
     198                    </select> 
    187199                </td> 
    188200            </tr> 
     
    206218                    <select name='user_offset' class='textbox'> 
    207219                    {section name=offset loop=$settings.timezones} 
    208                         <option{if $this_userdata.user_offset == $settings.timezones[offset]} selected{/if}>{$settings.timezones[offset]}</option> 
     220                        <option{if $this_userdata.user_offset == $settings.timezones[offset]} selected="selected"{/if}>{$settings.timezones[offset]}</option> 
    209221                    {/section} 
    210222                    </select> 
     
    234246                </td> 
    235247                <td class='tbl'> 
    236                     <textarea name='user_sig' rows='5' class='textbox' style='width:295px'>{$this_userdata.user_sig}</textarea><br> 
    237                     <input type='button' value='b' class='button' style='font-weight:bold;width:25px;' onClick="addText('user_sig', '[b]', '[/b]');"> 
    238                     <input type='button' value='i' class='button' style='font-style:italic;width:25px;' onClick="addText('user_sig', '[i]', '[/i]');"> 
    239                     <input type='button' value='u' class='button' style='text-decoration:underline;width:25px;' onClick="addText('user_sig', '[u]', '[/u]');"> 
    240                     <input type='button' value='url' class='button' style='width:30px;' onClick="addText('user_sig', '[url]', '[/url]');"> 
    241                     <input type='button' value='mail' class='button' style='width:35px;' onClick="addText('user_sig', '[mail]', '[/mail]');"> 
    242                     <input type='button' value='img' class='button' style='width:30px;' onClick="addText('user_sig', '[img]', '[/img]');"> 
    243                     <input type='button' value='center' class='button' style='width:45px;' onClick="addText('user_sig', '[center]', '[/center]');"> 
    244                     <input type='button' value='small' class='button' style='width:40px;' onClick="addText('user_sig', '[small]', '[/small]');"> 
     248                    <textarea name='user_sig' rows='5' cols='80' class='textbox' style='width:295px'>{$this_userdata.user_sig}</textarea><br /> 
     249                    <input type='button' value='b' class='button' style='font-weight:bold;width:25px;' onclick="addText('user_sig', '[b]', '[/b]');" /> 
     250                    <input type='button' value='i' class='button' style='font-style:italic;width:25px;' onclick="addText('user_sig', '[i]', '[/i]');" /> 
     251                    <input type='button' value='u' class='button' style='text-decoration:underline;width:25px;' onclick="addText('user_sig', '[u]', '[/u]');" /> 
     252                    <input type='button' value='url' class='button' style='width:30px;' onclick="addText('user_sig', '[url]', '[/url]');" /> 
     253                    <input type='button' value='mail' class='button' style='width:35px;' onclick="addText('user_sig', '[mail]', '[/mail]');" /> 
     254                    <input type='button' value='img' class='button' style='width:30px;' onclick="addText('user_sig', '[img]', '[/img]');" /> 
     255                    <input type='button' value='center' class='button' style='width:45px;' onclick="addText('user_sig', '[center]', '[/center]');" /> 
     256                    <input type='button' value='small' class='button' style='width:40px;' onclick="addText('user_sig', '[small]', '[/small]');" /> 
    245257                </td> 
    246258            </tr> 
     
    264276    </form> 
    265277{/if} 
    266 {literal}<script language='JavaScript'> 
     278{literal}<script type='text/javascript'> 
    267279// 
    268280// calculate the offset between browser and server time 
  • trunk/locale/English/admin/settings.php

    r843 r858  
    1515$locale['412'] = "Site footer:"; 
    1616$locale['413'] = "Site opening page:"; 
    17 $locale['414'] = "Site locale:"; 
     17$locale['414'] = "Default site locale:"; 
    1818$locale['415'] = "Site theme:"; 
    1919$locale['416'] = "Latest News Layout:"; 
  • trunk/locale/English/admin/user_groups.php

    r416 r858  
    2020$locale['417'] = "No"; 
    2121$locale['418'] = "Yes"; 
     22$locale['419'] = "This group is either a built-in group, or belongs to a module. These groups can not be deleted"; 
    2223// Edit/Delete Options 
    2324$locale['420'] = "User Groups"; 
  • trunk/locale/English/user_fields.php

    r790 r858  
    2727$locale['u026'] = "Newsletters format:"; 
    2828$locale['u027'] = "Browser Time"; 
     29$locale['u028'] = "Language"; 
    2930// profile panel info 
    3031$locale['u030'] = "Panel state:"; 
Note: See TracChangeset for help on using the changeset viewer.