Schritt 1: Frontend
Öffne die Datei profile.php und suche nach
$edit_profile_form_param[]
Ich denke hier erkennst du schon selbst, wie das Formular zustande kommt. Je nachdem wo du nun deine weiteren Felder haben möchtest, musst du deinen neuen Code entsprechend einfügen. Ich füge die neuen Felder hier exemplarisch einfach mal hinter die benutzerdefinierten Felder ein. D.h. suche nach
$edit_profile_form_param[] = array('text', 'disk_usage', cpg_fetch_icon('disk_usage', 2) . $lang_register_php['disk_usage']);
und davor kommt dann der neue Code.
Ein Feld für einzeilige Texteingabe sieht z.B. so aus:
$edit_profile_form_param[] = array('input', 'custom_input_1', 'Textfeld 1', 255);
für eine mehrzeilige Texteingabe so:
$edit_profile_form_param[] = array('textarea', 'custom_area_1', 'Textblock 1', 255);
Für die Radio-Buttons und die Dateiupload-Felder müssen wir erst noch neue Typen in der Funktion make_form definieren. Machen wir später, wenn der Rest soweit funktioniert.
Schritt 2: Backend
Damit Coppermine etwas mit den Erweiterungen anzufangen weiß, suchen wir
$profile6 = $superCage->post->getEscaped('user_profile6');
und fügen danach für alle oben hinzugefügten Formularfelder eine ähnliche Zeile ein, z.B.
$custom_input_1 = $superCage->post->getEscaped('custom_input_1');
$custom_input_2 = $superCage->post->getEscaped('custom_input_2');
$custom_input_3 = $superCage->post->getEscaped('custom_input_3');
// usw. bis 13
$custom_area_1 = $superCage->post->getEscaped('custom_area_1');
Dann suchen wir die Zeile
$sql = "UPDATE {$CONFIG['TABLE_USERS']} SET user_profile1 = '$profile1', user_profile2 = '$profile2', user_profile3 = '$profile3', user_profile4 = '$profile4', user_profile5 = '$profile5', user_profile6 = '$profile6'" . (($CONFIG['allow_email_change'] || GALLERY_ADMIN_MODE) && !$error ? ", user_email = '$email'" : "") . " WHERE user_id = '" . USER_ID . "'";
und fügen unsere Werte hinzu. Sieht dann in etwa so aus:
$sql = "UPDATE {$CONFIG['TABLE_USERS']} SET user_profile1 = '$profile1', user_profile2 = '$profile2', user_profile3 = '$profile3', user_profile4 = '$profile4', user_profile5 = '$profile5', user_profile6 = '$profile6', custom_input_1 = '$custom_input_1', custom_input_2 = '$custom_input_2', custom_input_3 = '$custom_input_3', custom_area_1 = '$custom_area_1'" . (($CONFIG['allow_email_change'] || GALLERY_ADMIN_MODE) && !$error ? ", user_email = '$email'" : "") . " WHERE user_id = '" . USER_ID . "'";
(ich habe jetzt nicht alle 13 Felder eingefügt, sondern nur die ersten 3).
Schritt 3: Datenbankfelder hinzufügen
Der bisherige Code würde nur eine Fehlermeldung produzieren, da es die benötigten Felder in der Datenbank noch nicht gibt. Öffne dafür ein Tool wie z.B. phpMyAdmin und füge die Felder mit folgender Abfrage hinzu:
ALTER TABLE `cpg15x_users` ADD COLUMN `custom_input_1` VARCHAR(255) NOT NULL default '';
ALTER TABLE `cpg15x_users` ADD COLUMN `custom_input_2` VARCHAR(255) NOT NULL default '';
ALTER TABLE `cpg15x_users` ADD COLUMN `custom_input_3` VARCHAR(255) NOT NULL default '';
-- usw. bis 13
ALTER TABLE `cpg15x_users` ADD COLUMN `custom_area_1` VARCHAR(255) NOT NULL default '';
Schritt 4: Daten im Profilbearbeitungsmodus anzeigen
Suche
$sql = "SELECT user_name, user_email, user_group, user_active, UNIX_TIMESTAMP(user_regdate) AS user_regdate, group_name, " . "user_profile1, user_profile2, user_profile3, user_profile4, user_profile5, user_profile6, user_group_list, " . "COUNT(pid) AS pic_count, SUM(total_filesize) AS disk_usage, group_quota " . "FROM {$CONFIG['TABLE_USERS']} AS u " . "INNER JOIN {$CONFIG['TABLE_USERGROUPS']} AS g ON user_group = group_id " . "LEFT JOIN {$CONFIG['TABLE_PICTURES']} AS p ON p.owner_id = u.user_id " . "WHERE user_id ='" . USER_ID . "' " . "GROUP BY user_id ";
und ersetze es durch
$sql = "SELECT u.*, user_name, user_email, user_group, user_active, UNIX_TIMESTAMP(user_regdate) AS user_regdate, group_name, " . "user_profile1, user_profile2, user_profile3, user_profile4, user_profile5, user_profile6, user_group_list, " . "COUNT(pid) AS pic_count, SUM(total_filesize) AS disk_usage, group_quota " . "FROM {$CONFIG['TABLE_USERS']} AS u " . "INNER JOIN {$CONFIG['TABLE_USERGROUPS']} AS g ON user_group = group_id " . "LEFT JOIN {$CONFIG['TABLE_PICTURES']} AS p ON p.owner_id = u.user_id " . "WHERE user_id ='" . USER_ID . "' " . "GROUP BY user_id ";
(durch den Stern (*) wählen wir alle Felder aus, das müssen wir also nicht weiter beachten).
Suche
'user_profile6' => $user_data['user_profile6'],
und füge darunter folgendes ein:
'custom_input_1' => $user_data['custom_input_1'],
'custom_input_2' => $user_data['custom_input_2'],
'custom_input_3' => $user_data['custom_input_3'],
// usw. bis 13
'custom_area_1' => $user_data['custom_area_1'],
Schritt 5: Daten im öffentlichen Profil anzeigen
Suche
if ($CONFIG['user_profile6_name'] != '') {
$display_profile_form_param[] = array('text', 'user_profile6', $CONFIG['user_profile6_name']);
}
unter füge darunter folgendes ein:
$display_profile_form_param[] = array('text', 'custom_input_1', 'Textfeld 1');
$display_profile_form_param[] = array('text', 'custom_input_2', 'Textfeld 2');
$display_profile_form_param[] = array('text', 'custom_input_3', 'Textfeld 3');
// usw.
$display_profile_form_param[] = array('text', 'custom_area_1', 'Textblock 1');
Suche
'user_profile6' => bb_decode($user_data['user_profile6']),
und füge darunter folgendes ein:
'custom_input_1' => $user_data['custom_input_1'],
'custom_input_2' => $user_data['custom_input_2'],
'custom_input_3' => $user_data['custom_input_3'],
// usw. bis 13
'custom_area_1' => bb_decode($user_data['custom_area_1']),
Das kannst du erstmal abarbeiten und bescheid geben, falls irgendwas nicht wie erwartet funktioniert.