4images Modifications / Modifikationen > Mods & Plugins (Releases & Support)
[MOD] V1.3 Let users add (sub-)categories / User erstellen (Sub-)Kategorien
KillerCookie:
Update Ticker (V1.3 - working / läuft)
NOTE: All updates till page 5, post #64 are included in this instruction!
HINWEIS: Alle Updates bis Seite 5, post #64 sind in der Anleitung berücksichtigt!
[If you got a good idea for an extension - feel free to post / Wenn du eine Idee für zusätzliche Features hast - poste bitte]
V1.0
- lots of bugs / viele Fehler
V1.1
+ added dual language support (english / german) / Script und Interface in deutsch und englisch
+ added global links and link text / Global nutzbare link und link-text variablen
- still lots of bugs :( / immernoch viele Fehler :(
V1.2
+ script is working fine now (new layout) / Script arbeitet jetzt ordentlich (neues Layout erstellt)
+ fixed error-message bug (message was dsiplayed everytime) / Fehlermeldungs-Bug behoben (Meldung wurde ständig eingeblendet)
+ added thunderstrike´s code (thx) / den Code von Thunderstrike hinzugefügt (thx)
+ script creates image and thumbnail folders now / das Script erstellt jetzt die Bilder- und Thumbnail-Ordner
+ modified and listet mawenzi´s addon in first post / mavenzi´s addon modifiziert und im ersten post aufgelistet
V1.3
+ small updates of the instructions / kleine Neuerungen der Installationsbeschreibung
+ added missing language part / fehlenden Teil in den Sprachdateien hinzugefügt
+ small code update [addcat.php] / kleine code erneuerung [addcat.php]
German:
Hallo Community,
da es bisher noch keine Möglichkeit gab Usern zu erlauben eigene Kategorien bzw. Subkategorien zu erstellen und die einzigste Methode eine Auslagerung der Admin-Funktionen war habe ich nun eine eigene Lösung gebaut. Nun kurz und schmerzlos die Features:
Features:
- Installation in weniger als 5 Minuten (!)
- PHP und HTML sauber getrennt für Template Kompatibilität
- stabil und sicher (hoffentlich ;) )
- sämtliche Daten werden fehlerlos nach den Vorgaben von 4images in die Datenbank eingetragen
- Anpassung auf persönliche Bedürfnisse problemlos machbar
- der gesamte code wurde deutsch und englisch kommentiert
English:
Hello community,
after searching for a way to let users add categories and/or subcategories i found that the only way to do that is to rip the admin functions out and make them available for the users. Because of that i made my own solution.
Features:
- Installation takes < 5 min. (!)
- PHP and HMTL are cleanly separated for for better template compatibility
- stable and secure (i hope so ;) )
- all informations are put into the database like the original functions of 4images do
- customization can be easily done
- the whole code is commented in english and german
Installation (german / english):
Step 1 / Schritt 1
Download the attached File
Lade die Datei im Anhang herunter
1.1
Put the "addcat.php" into your 4images root-folder and the "addcat.html" to your template folder
Lege die Datei "addcat.php" in dein 4images Hauptverzeichnis und die "addcat.html" in dein Template Verzeichnis
1.2
Opfen both files with the editor you like
Öffne beide Dateien mit einem Editor deiner Wahl
Step 2 / Schritt 2
[addcat.php]
Search for / suche nach
--- Code: --- // Initial value of the category hits / Startwert der Kategorie Hits
$cat_hits = '0';
// Rights for the new categorie / Rechte für die neue Kategorie
// 0 = all / alle , 2 = registered users / registrierte benutzer , 9 = admin
$auth_viewcat = '0';
$auth_viewimage = '0';
$auth_download = '0';
$auth_upload = '2';
$auth_directupload = '9';
$auth_vote = '2';
$auth_sendpostcard = '0';
$auth_readcomment = '0';
$auth_postcomment = '2';
--- End code ---
Change the values according to your needs / Ändere die Werte nach deinen Wünschen ab
Step 3 / Schritt 3
[addcat.html]
Search for / suche nach
--- Code: ---<!-- Start of Options -->
<tr>
<td class="row1"><b>{lang_addcat_which_subcat}</b></td>
<td align="right" class="row1">
<select name="cat_parent_id" size="">
<!-- At "value" enter a cat_id and next to it a cat_name / Bei "value" kann die Kategorie ID und daneben der Kategorie Name eingetragen werden -->
<option value="18">Upload</option>
<option value="your 2nd id / deine 2 id">your 2nd category name / der name deiner 2. Kategorie</option>
<option value="...">...</option>
</select>
</td>
</tr>
<!-- End of Options -->
--- End code ---
At the <option... </option> lines please enter your own values.
(The users will be able to create new categories in all categories that are listet here. You can see category ID "18" and the category name "Upload" for example. Change both values according to your needs.
- you can get the category ID and the names by opening the menu-link "Edit categories" in the admin control panel)
- you can also add or delete <option...</option> lines
In den <option... </option> Zeilen bitte die eigenen Werte eintragen
(Die Benutzer können in den hier angegebenen Kategorien neue Unterkategorien erstellen. Als Beispiel habe ich Kategorie ID "18" und den
Kategorie-Name "Upload" eingetragen. Beide Einträge müssen geändert werden.
- die Kategorie ID und den zugehörigen Name findet man im Menüpunkt "Kategorien bearbeiten" im Admin Control Panel
- man kann <option...</option> Zeilen hinzufügen oder entfernen
Step 4 / Schritt 4
Place a link to addcat.php somewhere in your templates (for example the user_logininfo) ( you can use {url_addcat} for the url and {url_addcat_text} for the link text
Platziere einen Link zur addcat.php irgendwo in deinen templates (als Beispiel hier die user_logininfo.html) (es kann {url_addcat} für die url und {url_addcat_text} für den Link-Text verwendet werden)
[user_logininfo.html]
Search for / suche nach
--- Code: ---» <a href="{url_control_panel}">{lang_control_panel}</a><br />
--- End code ---
Add after / danach einfügen
--- Code: ---» <a href="{addcat_url}">{addcat_url_text}</a></td>
--- End code ---
[The link can be found at the left side of the page in the user-menu now]
[Der Link steht nun im User-Menü auf der linken Seite, sofern man angemeldet ist]
Step 5 / Schritt 4
Open 4images\lang\deutsch\main.php / Öffne 4images\lang\deutsch\main.php
Open 4images\lang\english\main.php / Öffne 4images\lang\english\main.php
5.1
[deutsch\main.php]
Search for / Suche nach
--- Code: ---?>
--- End code ---
Add before / davor einfügen
--- Code: ---//-----------------------------------------------------
//--- Addcat MOD by Killercookie ----------------------
//-----------------------------------------------------
$lang['addcat_new_cat1'] = 'Neue Kategorie';
$lang['addcat_new_cat2'] = 'Neue Kategorie anlegen';
$lang['addcat_info'] = 'Informationen';
$lang['addcat_description'] = 'Beschreibung der Kategorie';
$lang['addcat_name'] = 'Name der Kategorie';
$lang['addcat_submit_button'] = 'Kategorie erstellen';
$lang['addcat_which_subcat'] = 'Zu welcher Kategorie hinzufügen';
$lang['addcat_error'] = 'Das Formular wurde nicht korrekt ausgefüllt, bitte erneut versuchen.';
$lang['addcat_ok'] = 'Ihre Kategorie wurde erfolgreich erstellt!';
$lang['addcat_no_rights'] = 'Sie besitzen nicht genügend Rechte zum Anzeigen der Seite!';
--- End code ---
[english\main.php]
Search for / Suche nach
--- Code: ---?>
--- End code ---
Add before / davor einfügen
--- Code: ---//-----------------------------------------------------
//--- Addcat MOD by Killercookie ----------------------
//-----------------------------------------------------
$lang['addcat_new_cat1'] = 'New category';
$lang['addcat_new_cat2'] = 'Add new category';
$lang['addcat_info'] = 'Information';
$lang['addcat_description'] = 'Category description';
$lang['addcat_name'] = 'Category name';
$lang['addcat_submit_button'] = 'Create category';
$lang['addcat_which_subcat'] = 'Add to which category';
$lang['addcat_error'] = 'The submitted information is incorrect. Please try again';
$lang['addcat_ok'] = 'Your category was created successfully!';
$lang['addcat_no_rights'] = 'You do not have the permission to display this page!';
--- End code ---
5.2
Open includes\page_header.php
Search for / Suche nach
--- Code: --- "rss_url" => "",
--- End code ---
Add after / danach einfügen
--- Code: --- "addcat_url" => ROOT_PATH."addcat.php",
"addcat_url_text" => $lang['addcat_new_cat1'],
--- End code ---
Done! / Fertig!
Addons (german / english):
Addon [1 - Show user who added the cat in cat description / Zeige den user, der die Kat. erstellt hat in der Beschreibung] by mawenzi
1. find in addcat.php / finde in addcat.php
--- Code: ---$user_access = get_permission();
--- End code ---
Add after / danach einfügen
--- Code: ---$user_name = format_text(trim($user_info['user_name']), 2);
--- End code ---
2. find in addcat.php / finde in addcat.php
--- Code: ---$new_cat_description = (isset($HTTP_POST_VARS['new_cat_description'])) ? un_htmlspecialchars(trim($HTTP_POST_VARS["new_cat_description"])) : "";
--- End code ---
Add after / danach einfügen
--- Code: ---$new_cat_description = str_replace(array("{new_cat_description}", "{user_name}"), array(format_text(trim($new_cat_description), 1, 0, 1), format_text(trim($user_info['user_name']), 2)), $lang['new_cat_description_added_by']);
--- End code ---
3. find in lang/english/main.php / finde in lang/english/main.php
--- Code: ---?>
--- End code ---
Add before / davor einfügen
--- Code: ---$lang['new_cat_description_added_by'] = "<span class=\"smalltext\">{new_cat_description} [added by : {user_name}]</span>";
--- End code ---
4. find in lang/deutsch/main.php / finde in lang/deutsch/main.php
--- Code: ---?>
--- End code ---
Add before / davor einfügen
--- Code: ---$lang['new_cat_description_added_by'] = "<span class=\"smalltext\">{new_cat_description} [hinzugefügt von: {user_name}]</span>";
--- End code ---
5. Done :) / Fertig! :)
If you have questions, problems, praise or criticism then please post in this thread.
Bei Fragen, Problemen, Anregungen, Lob oder Kritik einfach hier in den Thread posten oder mir eine PN schicken.
LG / Greets Maik
mawenzi:
@KillerCookie
... zunächst kurz und bündig : arbeitet (jedoch nicht ganz) perfekt ... :!:
... habe es unter 4images version1.7.4 getestet ...
... mit version1.7.0 dürfte es aufgrund der Funktion "create_cache_id" prinzipielle Probleme geben ...
Was mir gefällt :
... Trennung php und html für individuelle Templates, das war bei anderen Versionen von "Add_Cat" nicht der Fall ... ;)
... unkomplizierte Einstellmöglichkeiten und klare Zuweisungsmöglichkeiten, wo Kategorien erstellt werden dürfen ...
... die Installationszeit von 3min ist nicht untertrieben ...
Was ggf. noch zu ändern wäre :
... die Einführung und Auslagerung von Sprachtags in die /lang/<your_lang>/main.php ...
... Änderung des Hardcode-Links für die user_logininfo.html ...
... statt dessen Erzeugung des Link-Tags incl. sess_id in der /includes/page_header.php ...
... und Verwendung wie : » <a href="{url_addcat}">{lang_addcat}</a><br /> ... in user_logininfo.html ...
... und weiteres siehe unten ...
mawenzi:
Die erste kleine Erweiterung ... ;)
Es sollte das Recht zum Erstellen von Kategorien ja nur Usern zugewiesen werden. Doch um (als Admin oder auch User) zu erfahren, wer auf der Website die Kategorie angelegt hat, kann folgender Zusatz zur Kategorie-Beschreibung erzeugt werden.
... hier die Kategoriebeschreibung ... [added by : Username]
Was wäre dazu zu ändern :
1. finde in addcat.php
--- Code: ---$user_access = get_permission();
--- End code ---
und füge dahinter folgendes ein
--- Code: ---$user_name = $user_info['user_name'];
--- End code ---
2. finde in addcat.php
--- Code: ---$new_cat_description = strip_tags($new_cat_description);
--- End code ---
und ersetze es durch
--- Code: ---$new_cat_description = strip_tags($new_cat_description)." [added by : ".$user_name."]";
--- End code ---
3. fertig
thunderstrike:
This:
--- Quote ---$cat_parent_id = $_POST["cat_parent_id"];
$do_it = $_POST["do_it"];
$new_cat_name = $_POST["new_cat_name"];
$new_cat_description = $_POST["new_cat_description"];
--- End quote ---
for:
--- Quote ---$cat_parent_id = (isset($HTTP_POST_VARS['cat_parent_id'])) ? (intval(trim($HTTP_POST_VARS["cat_parent_id"])) : 0;
$do_it = (isset($HTTP_POST_VARS['do_it'])) ? intval(trim($HTTP_POST_VARS["do_it"])) : 0;
$new_cat_name = (isset($HTTP_POST_VARS['new_cat_name'])) ? strip_tags($HTTP_POST_VARS["new_cat_name"]) : "";
$new_cat_description = (isset($HTTP_POST_VARS['new_cat_description'])) ? strip_tags($HTTP_POST_VARS["new_cat_description"]) : "";
--- End quote ---
This:
--- Quote ---$sql = mysql_query("SELECT * FROM 4images_categories ORDER BY cat_id DESC LIMIT 1");
$result = mysql_fetch_array($sql);
--- End quote ---
for:
--- Quote ---$sql = $site_db->query("SELECT * FROM 4images_categories ORDER BY cat_id DESC LIMIT 1");
$result = $site_db->fetch_array($sql);
--- End quote ---
This:
--- Quote ---$sql = mysql_query("SELECT * FROM 4images_categories WHERE cat_parent_id='$cat_parent_id' ORDER BY cat_order DESC LIMIT 1");
$result = mysql_fetch_array($sql);
--- End quote ---
for:
--- Quote ---$sql = $site_db->query("SELECT * FROM 4images_categories WHERE cat_parent_id='$cat_parent_id' ORDER BY cat_order DESC LIMIT 1");
$result = $site_db->fetch_array($sql);
--- End quote ---
This:
--- Quote ---$msg = 'Die Kategorie "'.$new_cat_name.'" wurde erfolgreich hinzugef!';
}
else
{
$msg = 'Das Formular wurde nicht korrekt ausgeft, bitte erneut versuchen.';
--- End quote ---
--- Quote ---- all informations are put into the database like the original functions of 4images do
- customization can be easily done
- the whole code is commented in english and german
--- End quote ---
:?:
@Mawenzi:
You put MOD in publish ... no 4images SQL code or VARS code (10% is) ... is dangerus.
KillerCookie:
" - all informations are put into the database like the original functions of 4images do"
I mean that i fill out the correctly. An example: I set the cat_order dynamically and not just to "0" (this will work too but it isn´t original). All fields are filled out like you create the table with your admin cp.
Sorry for that false description of me. I´ll update my code like you suggested. I also added mutli language support.
The update will take about 10 min.
@mawenzi
I´ll add your extension to my first post, thank you.
Greets Maik
Navigation
[0] Message Index
[#] Next page
Go to full version