4images Forum & Community

4images Modifications / Modifikationen => Mods & Plugins (Releases & Support) => Topic started by: Rembrandt on July 30, 2012, 06:50:20 AM

Title: [Mod] Category from a certain Date display and hide again
Post by: Rembrandt on July 30, 2012, 06:50:20 AM
Hi!

This Mod allows you a Category from a certain date display and hide again.
The desire for the Modification comes from here: http://www.4homepages.de/forum/index.php?topic=30858.0

1.)  Copy the File "install_hiddencat.php" from the Attachment in your Gallery "root", login as Admin, and call it to (this includes only the "cat_hidden_start" SQL query).

2.)  search in admin/categories.php, section ($action == "savecat") :

  $cat_order = (isset($HTTP_POST_VARS['cat_order'])) ? intval($HTTP_POST_VARS['cat_order']) : 0;

insert below:

// ###################### Start Mod Hidden Category #################################################################
  $cat_hidden_end = (trim($HTTP_POST_VARS['cat_hidden_end']) != "") ? "UNIX_TIMESTAMP('".trim($HTTP_POST_VARS['cat_hidden_end'])."')" : "";
  $cat_hidden_start = (trim($HTTP_POST_VARS['cat_hidden_start']) != "") ? "UNIX_TIMESTAMP('".trim($HTTP_POST_VARS['cat_hidden_start'])."')" : "";
// ###################### End Mod Hidden Category ###################################################################

2.1) search:

    $sql = "INSERT INTO ".CATEGORIES_TABLE."
            (cat_name, cat_description, cat_parent_id, cat_order, auth_viewcat, auth_viewimage, auth_download, auth_upload, auth_directupload, auth_vote, auth_sendpostcard, auth_readcomment, auth_postcomment)
            VALUES
            ('$cat_name', '$cat_description', $cat_parent_id, $cat_order, $auth_viewcat, $auth_viewimage, $auth_download, $auth_upload, $auth_directupload, $auth_vote, $auth_sendpostcard, $auth_readcomment, $auth_postcomment)";

and replace:

// ######## Mod Hidden Category view INSERT ##########
    $sql = "INSERT INTO ".CATEGORIES_TABLE."
            (cat_name, cat_description, cat_parent_id, cat_order,cat_hidden_end, cat_hidden_start, auth_viewcat, auth_viewimage, auth_download, auth_upload, auth_directupload, auth_vote, auth_sendpostcard, auth_readcomment, auth_postcomment)
            VALUES
            ('$cat_name', '$cat_description', $cat_parent_id,$cat_order, $cat_hidden_end, $cat_hidden_start, $auth_viewcat, $auth_viewimage, $auth_download, $auth_upload, $auth_directupload, $auth_vote, $auth_sendpostcard, $auth_readcomment, $auth_postcomment)";

2.2.) search:

$permission_headline = $lang['permissions'];

insert above:

//######################### Start Mod Hidden Category ###############################################
  $title = $lang['cat_hidden_end'].$lang['date_desc'].$lang['date_format'];
  $cat_hidden_end = (!empty($cat_row['cat_hidden_end'])) ? $cat_row['cat_hidden_end'] : time();
  show_date_input_row($title, "cat_hidden_end", format_date("Y-m-d H:i",$cat_hidden_end), $textinput_size);
  $title2 = $lang['cat_hidden_start'].$lang['cat_hidden_desc'];
  show_date_input_row($title2, "cat_hidden_start", 0, $textinput_size);
//######################### End Mod Hidden Category #################################################

2.3) search in section ($action == "updatecat") :

$cat_order = (isset($HTTP_POST_VARS['cat_order'])) ? intval($HTTP_POST_VARS['cat_order']) : 0;

insert below:

// ###################### Start Mod Hidden Category #################################################################
  $cat_hidden_end = (trim($HTTP_POST_VARS['cat_hidden_end']) != "") ? "UNIX_TIMESTAMP('".trim($HTTP_POST_VARS['cat_hidden_end'])."')" : time();
  $cat_hidden_start = (trim($HTTP_POST_VARS['cat_hidden_start']) > 0 ) ? "UNIX_TIMESTAMP('".trim($HTTP_POST_VARS['cat_hidden_start'])."')" : "0";
// ###################### End Mod Hidden Category ###################################################################

2.4) search:

    $sql = "UPDATE ".CATEGORIES_TABLE."
            SET cat_name = '$cat_name', cat_description = '$cat_description', cat_parent_id = $cat_parent_id, cat_order = $cat_order, cat_hits = $cat_hits, auth_viewcat = $auth_viewcat, auth_viewimage = $auth_viewimage, auth_download = $auth_download, auth_upload = $auth_upload, auth_directupload = $auth_directupload, auth_vote = $auth_vote, auth_sendpostcard = $auth_sendpostcard, auth_readcomment = $auth_readcomment, auth_postcomment = $auth_postcomment

and replace:

// ######## Mod Hidden Category view SET ##########
$sql = "UPDATE ".CATEGORIES_TABLE."
        SET cat_name = '$cat_name', cat_description = '$cat_description', cat_parent_id = $cat_parent_id, cat_order = $cat_order, cat_hits = $cat_hits, cat_hidden_end = $cat_hidden_end, cat_hidden_start = $cat_hidden_start, auth_viewcat = $auth_viewcat, auth_viewimage = $auth_viewimage, auth_download = $auth_download, auth_upload = $auth_upload, auth_directupload = $auth_directupload, auth_vote = $auth_vote, auth_sendpostcard = $auth_sendpostcard, auth_readcomment = $auth_readcomment, auth_postcomment = $auth_postcomment

2.5) search in section ($action == "editcat") :

$sql = "SELECT cat_name, cat_description, cat_parent_id, cat_hits, cat_order, auth_viewcat, auth_viewimage, auth_download, auth_upload, auth_directupload, auth_vote, auth_sendpostcard, auth_readcomment, auth_postcomment

and replace:

// ######## Mod Hidden Category view SELECT ##########
$sql = "SELECT cat_name, cat_description, cat_parent_id, cat_hits, cat_order, cat_hidden_end, cat_hidden_start, auth_viewcat, auth_viewimage, auth_download, auth_upload, auth_directupload, auth_vote, auth_sendpostcard, auth_readcomment, auth_postcomment

2.6) search:

show_input_row($lang['field_hits'], "cat_hits", $cat_row['cat_hits'], 5);

insert below:

//######################### Start Mod Hidden Category ###############################################
  $title = $lang['cat_hidden_end'].$lang['date_desc'].$lang['date_format'];
  $cat_hidden_end = (!empty($cat_row['cat_hidden_end'])) ? $cat_row['cat_hidden_end'] : time();
  show_date_input_row($title, "cat_hidden_end", format_date("Y-m-d H:i",$cat_hidden_end), $textinput_size);
  $title2 = $lang['cat_hidden_start'].$lang['cat_hidden_desc'];
  $cat_hidden_start = (!empty($cat_row['cat_hidden_start'])) ? format_date("Y-m-d H:i",$cat_row['cat_hidden_start']) : "0";
  show_date_input_row($title2, "cat_hidden_start", $cat_hidden_start, $textinput_size);
//######################### End Mod Hidden Category #################################################

 
3.)  search in lang/your/lang/ admin.php:

//--- Categories --------------------------------------
//-----------------------------------------------------

insert below:
(deutsch)

$lang['cat_hidden_end'] = "Kategorie anzeigen ab:";
$lang['cat_hidden_start'] = "Kategorie verstecken ab:";
$lang['cat_hidden_desc'] = "<br><span class=\"smalltext\">'0' Deaktiviert die Funktion!</span>";

(english)

$lang['cat_hidden_end'] = "View Categorie from:";
$lang['cat_hidden_start'] = "Hide Categorie:";
$lang['cat_hidden_desc'] = "<br><span class=\"smalltext\">'0' Disables the function!</span>";


4.)  search in global.php:

    $cat_parent_cache[$row['cat_parent_id']][] = $row['cat_id'];
  }
  $site_db->free_result();

insert below:

//#################### Start Mod Cat hidden ################################################## 
  $current_date = time();
  $sql = "SELECT cat_id, cat_hidden_end, cat_hidden_start, auth_viewcat
          FROM ".CATEGORIES_TABLE."
          WHERE cat_hidden_start <> 0
          ORDER BY ".$config['cat_order']." " .$config['cat_sort'];
  $result = $site_db->query($sql);
 
  while ($row = $site_db->fetch_array($result)) {
    if ($row['cat_hidden_end'] > $current_date || $row['cat_hidden_start'] < $current_date){
      $cat_cache[$row['cat_id']]['auth_viewcat'] = "9";
    }
  }
//#################### End Mod Cat hidden ###################################################


Now login as Admin and go to the ACP Add/Edit Categories, and you can see the effect.

mfg Andi
Title: Re: [Mod] Category from a certain Date display and hide again
Post by: Scarala on July 30, 2012, 09:04:10 AM
Hello Rembrandt,

beautyful Mod, thats wat i needed.

But there are two little mistakes in the code:

2.4 must be:

2.4) search:

SET cat_name = '$cat_name', cat_description = '$cat_description', cat_parent_id = $cat_parent_id, cat_order = $cat_order, cat_hits = $cat_hits, auth_viewcat = $auth_viewcat, auth_viewimage = $auth_viewimage, auth_download = $auth_download, auth_upload = $auth_upload, auth_directupload = $auth_directupload, auth_vote = $auth_vote, auth_sendpostcard = $auth_sendpostcard, auth_readcomment = $auth_readcomment, auth_postcomment = $auth_postcomment

and replace:

SET cat_name = '$cat_name', cat_description = '$cat_description', cat_parent_id = $cat_parent_id, cat_order = $cat_order, cat_hits = $cat_hits,cat_hidden_end = $c

if there is the // ######## Mod Hidden Category view SET ########## in the replacement, there is an DB Error.

and 3.) must be

3.) search in lang/your/lang/ admin.php:
//--- Categories --------------------------------------
//-----------------------------------------------------

insert below:
(deutsch)
$lang['hidden_end'] = "Kategorie anzeigen ab:";

(english)
$lang['hidden_end'] = "View Categorie from:";

because in your code you request $lang['hidden_end'] and not $lang['cat_hidden_end']

Title: Re: [Mod] Category from a certain Date display and hide again
Post by: Rembrandt on July 30, 2012, 09:34:56 AM
Danke für die hinweise, aber ich lasse die Kommentarzeilen drinnen, wenn du später einmal genau an den stellen eine Änderung vornimmst und du nicht aufpasst entfernst du dir die alte Modifikation und wunderst dich später warum der eine oder andere Mod plötzlich nicht mehr funktioniert. :)

Bei dem lang File habe ich die Änderung auch in der categorie.php vorgenommen, besser ist es das Kind beim Namen nennen also "cat_hidden_end"

mfg Andi
Title: Re: [Mod] Category from a certain Date display and hide again
Post by: Scarala on July 30, 2012, 10:42:09 AM
Neuen fehler entdeckt:

unter 2.4)

replace:
// ######## Mod Hidden Category view SET ##########
$sql = "UPDATE ".CATEGORIES_TABLE."
        SET cat_name = '$cat_name', cat_description = '$cat_description', cat_parent_id = $cat_parent_id, cat_order = $cat_order, cat_hits = $cat_hits,cat_contest_end = $cat_contest_end, auth_viewcat = $auth_viewcat, auth_viewimage = $auth_viewimage, auth_download = $auth_download, auth_upload = $auth_upload, auth_directupload = $auth_directupload, auth_vote = $auth_vote, auth_sendpostcard = $auth_sendpostcard, auth_readcomment = $auth_readcomment, auth_postcomment = $auth_postcomment


steht
Code: [Select]
cat_contest_end = $cat_contest_end, das muss
Code: [Select]
cat_hidden_end = $cat_hidden_end,sein.
Title: Re: [Mod] Category from a certain Date display and hide again
Post by: Rembrandt on July 30, 2012, 10:50:23 AM
*grmbl* ja danke, wenns noch fehler gibt fliegt der schei**** von server  :evil:
aber so bekomme ich wenigstens feedback, denn ansonsten schreiben die Leute die sich die Mods einbauen nicht einmal was.... :|
Title: Re: [Mod] Category from a certain Date display and hide again
Post by: Scarala on July 30, 2012, 12:48:40 PM
Bei mir läufts jetzt fehlerfrei in allen bereichen. Nochmal vielen dank für desen tollen MOD.

PS:
von mir wirds immer rückmeldungen geben, wenn ich probleme finde.
Title: Re: [Mod] Category from a certain Date display and hide again
Post by: Loda on July 30, 2012, 02:50:43 PM
auch ich habe es getestet... und es läuft!
prima! und danke..
jetzt kommt bei mir die Frage auf:
kann man die Kategorie auch wieder automatisch "verstecken" ?
nur als Gedanke.. sollst jetzt keine extra aufgabe sein..  :mrgreen:
Title: Re: [Mod] Category from a certain Date display and hide again
Post by: Rembrandt on July 30, 2012, 04:08:53 PM
...kann man die Kategorie auch wieder automatisch "verstecken" ?
nur als Gedanke.. .
na lol, ich habe es mir ja gedacht....
bei meinen ursprünglicher code habe ich es auch so vorgesehen..
Title: Re: [Mod] Category from a certain Date display and hide again
Post by: Scarala on August 02, 2012, 12:40:03 PM
@ rembrandt:

Denn bring den Code doch mit in den ersten Post... Einmal code nur für Startdatum und einmal Code für Start- und Enddatum... Gibt da sicher inige interessenten...
Title: Re: [Mod] Category from a certain Date display and hide again
Post by: Saschilys on August 02, 2012, 12:54:12 PM
@ rembrandt:

Denn bring den Code doch mit in den ersten Post... Einmal code nur für Startdatum und einmal Code für Start- und Enddatum... Gibt da sicher inige interessenten...

Jep, hier z.B.
Title: Re: [Mod] Category from a certain Date display and hide again
Post by: Rembrandt on August 02, 2012, 07:42:01 PM
so... jetzt gibt es eine zweite Version im ersten Post...

mfg Andi
Title: Re: [Mod] Category from a certain Date display and hide again
Post by: Scarala on August 03, 2012, 06:37:45 AM
Quote
Version II


This is the same modification as above, plus the start date.

Ist Version II nicht plus end date?
Title: Re: [Mod] Category from a certain Date display and hide again
Post by: Rembrandt on August 03, 2012, 06:52:07 AM
 ja?
Title: Re: [Mod] Category from a certain Date display and hide again
Post by: Loda on August 03, 2012, 09:15:03 AM
...kann man die Kategorie auch wieder automatisch "verstecken" ?
nur als Gedanke.. .
na lol, ich habe es mir ja gedacht....
bei meinen ursprünglicher code habe ich es auch so vorgesehen..

danke lieber Andi!
funktioniert einwandfrei!
Title: Re: [Mod] Category from a certain Date display and hide again
Post by: Rembrandt on August 03, 2012, 09:23:48 AM
na Bitte  :) 

mfg Andi
Title: Re: [Mod] Category from a certain Date display and hide again
Post by: Scarala on August 03, 2012, 12:31:07 PM
ja?

Ach so, du hast oben nur enddate und unten start und enddate...

denn stimmt aber oben der bezug auf mein anderes Posting nicht... Denn solltest du oben dazu schreiben, das oben enddate und unten start- und enddate sind...
Title: Re: [Mod] Category from a certain Date display and hide again
Post by: Rembrandt on August 03, 2012, 12:43:40 PM
nene, das ist das verwirrende an den Mod.
 zu beginn ist die Kategorie versteck, dann kommt erst "verstecken ende" und dann wieder "verstecken start".
nicht erst "verstecken start" und dann "verstecken ende".

mfg Andi

Edit ich habe den ersten Mod gelöscht, damit es nicht zu Missverständnissen kommt...

 
Title: Re: [Mod] Category from a certain Date display and hide again
Post by: Scarala on August 06, 2012, 07:47:56 AM
Gute idee ^^ ;)