Skip to content

Commit 7beb07c

Browse files
committed
* Disabled changing var names of locked profile fields
* Fixed and added more update routines for older TBB2s * Fixed potential bug causing invalid vCards
1 parent 2562e5e commit 7beb07c

4 files changed

Lines changed: 31 additions & 18 deletions

File tree

modules/AdminProfileFields.class.php

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ public function executeMe() {
4242
case 'AddField':
4343
$p = Functions::getSGValues($_POST['p'],array('fieldName','fieldRegexVerification','fieldLink','fieldData','fieldType','fieldVarName'),'');
4444
$c = Functions::getSGValues($_POST['c'],array('fieldIsRequired','fieldShowRegistration','fieldShowMemberlist'),0);
45-
45+
4646
$errors = array();
4747

4848
if(!in_array($p['fieldType'],array(PROFILE_FIELD_TYPE_SELECTMULTI,PROFILE_FIELD_TYPE_SELECTSINGLE,PROFILE_FIELD_TYPE_TEXT,PROFILE_FIELD_TYPE_TEXTAREA)))
@@ -52,15 +52,15 @@ public function executeMe() {
5252

5353
if(isset($_GET['doit'])) {
5454
$c = Functions::getSGValues($_POST['c'],array('fieldIsRequired','fieldShowRegistration','fieldShowMemberlist'),0);
55-
55+
5656
$this->modules['DB']->queryParams('SELECT "fieldID" FROM '.TBLPFX.'profile_fields WHERE "fieldVarName"=$1',array($p['fieldVarName']));
5757
if(trim($p['fieldVarName']) == '' || $this->modules['DB']->numRows() > 0) $errors[] = $this->modules['Language']->getString('error_existing_field_variable_name');
5858

5959
if(count($errors) == 0) {
6060
$fieldData = array();
6161
if(trim($p['fieldData']) != '')
6262
$fieldData = explode("\n",Functions::str_replace("\r",'',trim($p['fieldData'])));
63-
63+
6464
$this->modules['DB']->queryParams('
6565
INSERT INTO
6666
'.TBLPFX.'profile_fields
@@ -85,7 +85,7 @@ public function executeMe() {
8585
$p['fieldLink'],
8686
$p['fieldVarName']
8787
));
88-
88+
8989
Functions::myHeader(INDEXFILE.'?action=AdminProfileFields&'.MYSID);
9090
}
9191
}
@@ -105,11 +105,10 @@ public function executeMe() {
105105

106106
$this->modules['DB']->queryParams('SELECT * FROM '.TBLPFX.'profile_fields WHERE "fieldID"=$1', array($fieldID));
107107
($this->modules['DB']->getAffectedRows() == 0) ? die('Cannot load data: profile field') : $fieldData = $this->modules['DB']->fetchArray();
108-
//if($fieldData['fieldIsLocked'] == 1) die('Cannot edit field: locked field');
109-
108+
110109
$errors = array();
111110

112-
$p = Functions::getSGValues($_POST['p'],array('fieldName','fieldRegexVerification','fieldLink','fieldType','fieldVarName'),'',$fieldData);
111+
$p = Functions::getSGValues($_POST['p'],array('fieldName','fieldRegexVerification','fieldLink','fieldType','fieldVarName','fieldIsLocked'),'',$fieldData);
113112
$c = Functions::getSGValues($_POST['c'],array('fieldIsRequired','fieldShowRegistration','fieldShowMemberlist'),0,$fieldData);
114113

115114
$p['fieldData'] = isset($_POST['p']['fieldData']) ? $_POST['p']['fieldData'] : implode("\n",unserialize($fieldData['fieldData']));
@@ -124,12 +123,12 @@ public function executeMe() {
124123

125124
$this->modules['DB']->queryParams('SELECT "fieldID" FROM '.TBLPFX.'profile_fields WHERE "fieldVarName"=$1 AND "fieldID"<>$2',array($p['fieldVarName'],$fieldID));
126125
if(trim($p['fieldVarName']) == '' || $this->modules['DB']->numRows() > 0) $errors[] = $this->modules['Language']->getString('error_existing_field_variable_name');
127-
126+
128127
if(count($errors) == 0) {
129128
$fieldData = array();
130129
if(trim($p['fieldData']) != '')
131130
$fieldData = explode("\n",Functions::str_replace("\r",'',trim($p['fieldData'])));
132-
131+
133132
$this->modules['DB']->queryParams('
134133
UPDATE
135134
'.TBLPFX.'profile_fields
@@ -157,7 +156,7 @@ public function executeMe() {
157156
$fieldID,
158157
$p['fieldVarName']
159158
));
160-
159+
161160
Functions::myHeader(INDEXFILE.'?action=AdminProfileFields&'.MYSID);
162161
}
163162
}

modules/ViewProfile.class.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,7 @@ public function executeMe() {
322322
while($curResult = $this->modules['DB']->fetchArray())
323323
$fieldsData[$curResult['fieldVarName']] = $curResult;
324324
//Start building the vCard
325-
$vCard = "BEGIN:VCARD\nVERSION:3.0\nN:;;;;\nFN:" . ($fieldsData['realName'] ? $fieldsData['realName']['fieldValue'] : '') . "\nNICKNAME:" . $profileData['userNick'] . "\n" . (($profileData['userHideEmailAddress'] != '1') ? 'EMAIL;TYPE=internet:' . $profileData['userEmailAddress'] . "\n" : '') . 'URL:' . $fieldsData['homepage']['fieldValue'] . "\nCLASS:" . (($this->modules['Config']->getValue('guests_enter_board') != '1') ? 'PRIVATE' : 'PUBLIC') . "\nX-GENERATOR:Tritanium Bulletin Board 2\nEND:VCARD";
325+
$vCard = "BEGIN:VCARD\nVERSION:3.0\nN:;;;;\nFN:" . (isset($fieldsData['realName']) ? $fieldsData['realName']['fieldValue'] : '') . "\nNICKNAME:" . $profileData['userNick'] . "\n" . (($profileData['userHideEmailAddress'] != '1') ? 'EMAIL;TYPE=internet:' . $profileData['userEmailAddress'] . "\n" : '') . 'URL:' . $fieldsData['homepage']['fieldValue'] . "\nCLASS:" . (($this->modules['Config']->getValue('guests_enter_board') != '1') ? 'PRIVATE' : 'PUBLIC') . "\nX-GENERATOR:Tritanium Bulletin Board 2\nEND:VCARD";
326326
header('Content-Disposition: attachment; filename=' . $profileData['userNick'] . '.vcf');
327327
header('Content-Length: ' . strlen($vCard));
328328
header('Content-Type: text/x-vCard; charset=UTF-8; name=' . $profileData['userNick'] . '.vcf');

templates/std/templates/AdminProfileFieldsEditField.tpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
</tr>
1313
<tr>
1414
<td class="CellStd"><span class="FontNorm">{$modules.Language->getString('field_variable_name')}:</span><br/><span class="FontSmall">{$modules.Language->getString('field_variable_name_info')}</span></td>
15-
<td class="CellAlt"><input class="FormText" type="text" size="40" name="p[fieldVarName]" value="{$p.fieldVarName}"/></td>
15+
<td class="CellAlt"><input class="FormText" type="text" size="40" name="p[fieldVarName]" value="{$p.fieldVarName}"{if $p.fieldIsLocked == 1} disabled="disabled"{/if}/></td>
1616
</tr>
1717
<tr>
1818
<td class="CellStd"><span class="FontNorm">{$modules.Language->getString('field_type')}:</span></td>

update/0.2.2.update

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -42,17 +42,18 @@ $this->DB->query('
4242
ADD "userAuthDownload" tinyint(1) unsigned NOT NULL default \'2\' AFTER "userAuthUpload"
4343
');
4444

45+
//Update configs
4546
$this->DB->queryParams('
4647
UPDATE
4748
'.TBLPFX.'config
4849
SET
4950
"configValue"=$1
5051
WHERE
51-
"configName"=$2',
52-
array(
52+
"configName"=$2
53+
',array(
5354
'std',
5455
'standard_tpl'
55-
);
56+
));
5657

5758
$this->DB->queryParams('
5859
INSERT INTO '.TBLPFX.'config SET
@@ -63,6 +64,7 @@ $this->DB->queryParams('
6364
'1'
6465
));
6566

67+
//Update session locations
6668
$this->DB->query('
6769
ALTER TABLE '.TBLPFX.'sessions
6870
CHANGE "sessionLastLocation" "sessionLastLocation" VARCHAR(255) NOT NULL DEFAULT \'ForumIndex\'
@@ -74,12 +76,13 @@ $this->DB->queryParams('
7476
SET
7577
"sessionLastLocation"=$1
7678
WHERE
77-
"sessionLastLocation"=$2',
78-
array(
79+
"sessionLastLocation"=$2
80+
',array(
7981
'ForumIndex',
8082
'forumindex'
81-
);
83+
));
8284

85+
//Update profile fields
8386
$this->DB->queryParams('
8487
UPDATE
8588
'.TBLPFX.'profile_fields
@@ -97,4 +100,15 @@ $this->DB->queryParams('
97100
'Homepage'
98101
));
99102

103+
$this->DB->queryParams('
104+
UPDATE
105+
'.TBLPFX.'profile_fields
106+
SET
107+
"fieldData"=$1
108+
WHERE
109+
"fieldData"=\'\'
110+
',array(
111+
serialize(array())
112+
));
113+
100114
$nextUpdateFile = '';

0 commit comments

Comments
 (0)