4images Forum & Community

4images Modifications / Modifikationen => Mods & Plugins (Releases & Support) => Topic started by: V@no on April 27, 2005, 04:29:11 AM

Title: [MOD] Apply permission to sub-categories from their parent category
Post by: V@no on April 27, 2005, 04:29:11 AM
With this mod you will be able apply category permissions including it's sub-categories.

----------- [ Installation ] ---------------
Step 1
Open admin/categories.php
Find:
Code: [Select]
  $auth_postcomment = $HTTP_POST_VARS['auth_postcomment'];Insert below:
Code: [Select]
/*
  MOD SUBCAT PERM FROM PARENT
  BEGIN INSERT
*/
  $subcats = (isset($HTTP_POST_VARS['subcats']) && $HTTP_POST_VARS['subcats']) ? 1 : 0;
/*
  MOD SUBCAT PERM FROM PARENT
  END INSERT
*/


Step 1.1
Find:
Code: [Select]
    $msg = ($result) ? $lang['cat_edit_success'] : $lang['cat_edit_error'];Insert above:
(for 4images v1.7/1.7.1 only!)
Code: [Select]
/*
  MOD SUBCAT PERM FROM PARENT
  BEGIN INSERT
*/
    if ($subcats)
    {
      function get_subcategories_id($cat_id = 0)
      {
        global $subcat_ids, $cat_parent_cache;
     
        if (!isset($cat_parent_cache[$cat_id]))
        {
          return false;
        }
        foreach ($cat_parent_cache[$cat_id] as $key => $val)
        {
          $subcat_ids[] = $val;
          get_subcategories_id($val);
        }
        return $subcat_ids;
      }
      $subcat_ids = array();
      $subcat_ids = get_subcategories_id($cat_id);
      if (!empty($subcat_ids))
      {
        $sql = "UPDATE ".CATEGORIES_TABLE."
                SET 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
                WHERE cat_id IN (".implode($subcat_ids, ",").")";
        $result = $site_db->query($sql);
      }
    }
/*
  MOD SUBCAT PERM FROM PARENT
  END INSERT
*/

(for 4images v1.7.2 and newer)
Code: [Select]
/*
  MOD SUBCAT PERM FROM PARENT
  BEGIN INSERT
*/
    if ($subcats)
    {
      $subcat_ids = array();
      $subcat_ids = get_subcategories_id($cat_id);
      if (!empty($subcat_ids))
      {
        $sql = "UPDATE ".CATEGORIES_TABLE."
                SET 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
                WHERE cat_id IN (".implode($subcat_ids, ",").")";
        $result = $site_db->query($sql);
      }
    }
/*
  MOD SUBCAT PERM FROM PARENT
  END INSERT
*/

Step 1.2
Find:
Code: [Select]
  show_form_footer($lang['save_changes'], $lang['reset'], 2, $lang['back']);Insert above:
Code: [Select]
/*
  MOD SUBCAT PERM FROM PARENT
  BEGIN INSERT
*/
  show_radio_row("Apply to all subcategories", "subcats", $subcats);
/*
  MOD SUBCAT PERM FROM PARENT
  END INSERT
*/



That's all.
Now when you edit category permissions, you should see a new option Apply to all subcategories
Title: Re: [MOD] Apply permission to sub-categories from their parent category
Post by: suprdave71 on April 27, 2005, 05:18:32 AM
Fantastic! I can't wait to try this.
Title: Re: [MOD] Apply permission to sub-categories from their parent category
Post by: om6acw on April 27, 2005, 06:00:50 AM
Super Vano :!:  :D
Title: Re: [MOD] Apply permission to sub-categories from their parent category
Post by: suprdave71 on April 27, 2005, 06:11:30 AM
Well, shoot. I got a Bad SQL Query right off the bat. I do have a shared database with phpBB2 -- could that be the reason?

Quote
You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near ' auth_terms = WHERE cat_id IN (293,4,5,307,14,
Error editing category

I have no idea what this means! I'm using version 1.7 of 4images if that means anything also.
Title: Re: [MOD] Apply permission to sub-categories from their parent category
Post by: V@no on April 27, 2005, 06:14:40 AM
my bad, forgot remove some extra fields I have in my code... its fixed now, redo Step 1.1
Title: Re: [MOD] Apply permission to sub-categories from their parent category
Post by: suprdave71 on April 27, 2005, 06:24:04 AM
my bad, forgot remove some extra fields I have in my code... its fixed now, redo Step 1.1

Beauty. What a time saver! Thanks for the quick fix, dude. You rock as usual.

Dave
Title: Re: [MOD] Apply permission to sub-categories from their parent category
Post by: Candace on May 18, 2005, 01:47:49 PM
I get the option now, but my save changes button has now vanished?
Title: Re: [MOD] Apply permission to sub-categories from their parent category
Post by: V@no on May 18, 2005, 02:51:32 PM
I get the option now, but my save changes button has now vanished?
restore backups and try again.
I have no idea what possible could cause your "save" button to dissapier...
Title: Re: [MOD] Apply permission to sub-categories from their parent category
Post by: Candace on May 18, 2005, 03:06:56 PM
I did it wrong, It works now, thanks
Title: Re: [MOD] Apply permission to sub-categories from their parent category
Post by: udaman on August 29, 2005, 12:27:09 AM
Code: [Select]
  $auth_postcomment = $HTTP_POST_VARS['auth_postcomment'];
I have the above code in two differnet places in my admin/categories.php

Should I use the following code in both places?

Code: [Select]
/*
  MOD SUBCAT PERM FROM PARENT
  BEGIN INSERT
*/
  $subcats = (isset($HTTP_POST_VARS['subcats']) && $HTTP_POST_VARS['subcats']) ? 1 : 0;
/*
  MOD SUBCAT PERM FROM PARENT
  END INSERT
*/

Any help will be greatly appreciated. Thanks.
Title: Re: [MOD] Apply permission to sub-categories from their parent category
Post by: Xyu BAM on August 29, 2005, 05:20:39 AM
probably only below
Code: [Select]
if ($action == "updatecat") { (second item)
Title: Re: [MOD] Apply permission to sub-categories from their parent category
Post by: udaman on August 29, 2005, 08:32:13 AM
Works! Thank you for your help.
Title: Re: [MOD] Apply permission to sub-categories from their parent category
Post by: bibabobu on November 07, 2005, 05:27:13 PM
Really thanks for that MOD!

WORKS PERFECT WITHOUT HAVING TROUBLE!!!

 :D
Title: Re: [MOD] Apply permission to sub-categories from their parent category
Post by: garett on November 13, 2005, 03:48:53 PM
Is there a mod that allow to do almost the same thing with users group on categories.

I explain myself :

on my site, I have about 12 main categories with for some of it 30 subcategories (on several levels). When I create a new group, I apply the same permissions than main categories to their subcategories. It should be really optimized if there was somme "apply to subcategories" actions (for the groupe) on this page.

Have you seen a mod like that somewhere?
Title: Re: [MOD] Apply permission to sub-categories from their parent category
Post by: Maniac on December 29, 2005, 04:13:13 AM
THANK YOU - Exactly what I was looking for... :D
Title: Re: [MOD] Apply permission to sub-categories from their parent category
Post by: kief24 on February 22, 2006, 03:02:01 PM
Is it possible to set (change) permissions for all categories (at once) ?
Title: Re: [MOD] Apply permission to sub-categories from their parent category
Post by: Threnody on February 23, 2006, 06:48:32 PM
V@no,

This is great MOD, thanks so much for sharing it!  I just know this will be a real time saver!  :)

namaste,
Threnody
Title: Re: [MOD] Apply permission to sub-categories from their parent category
Post by: wallpapers on February 23, 2006, 07:59:24 PM
This is a perfect mod  :D
and it work also perfect  :lol:

thx v@no :mrgreen:
Title: Re: [MOD] Apply permission to sub-categories from their parent category
Post by: lemccoy on February 23, 2006, 08:39:29 PM
Is it possible to set (change) permissions for all categories (at once) ?

This is a great mod, easy install and works great.  I also am interested in above. 
Title: Re: [MOD] Apply permission to sub-categories from their parent category
Post by: V@no on February 24, 2006, 12:39:36 AM
Is it possible to set (change) permissions for all categories (at once) ?
Not with this mod.
If you are interested, I can provide you with MySQL query that you can run in phpmyadmin...
Title: Re: [MOD] Apply permission to sub-categories from their parent category
Post by: kief24 on February 24, 2006, 07:57:59 AM
Is it possible to set (change) permissions for all categories (at once) ?
Not with this mod.
If you are interested, I can provide you with MySQL query that you can run in phpmyadmin...

yes, i am very interested :)

thx
Title: Re: [MOD] Apply permission to sub-categories from their parent category
Post by: V@no on February 25, 2006, 01:11:50 AM
Ok, here it is:[qcode]UPDATE 4images_categories SET
auth_viewcat = xx,
auth_viewimage = xx,
auth_download = xx,
auth_upload = xx,
auth_directupload = xx,
auth_vote = xx,
auth_sendpostcard = xx,
auth_readcomment = xx,
auth_postcomment = xx[/qcode]
The xx is one of the following:
These are default settings, but to make sure double check in includes/constants.php:
Code: [Select]
// Permission levels
define('AUTH_ALL', 0);
define('AUTH_USER', 2);
define('AUTH_ACL', 3);
define('AUTH_ADMIN', 9);


You can remove auth_xxx from the query if you DON'T want to update that permission.
Title: Re: [MOD] Apply permission to sub-categories from their parent category
Post by: kief24 on February 25, 2006, 08:26:48 AM
that worked just perfect ! thx a lot !!  :D
Title: Re: [MOD] Apply permission to sub-categories from their parent category
Post by: yerpo on February 25, 2006, 10:47:12 AM
Works like a charm. Luckily I didn't go changing each directory's permissions before seeing this  :mrgreen:
Title: Re: [MOD] Apply permission to sub-categories from their parent category
Post by: yerpo on March 11, 2006, 05:46:21 PM
Does this mod work in version 1.7.2? It was very useful and I don't know why you didn't include it in the new version.
Title: Re: [MOD] Apply permission to sub-categories from their parent category
Post by: ktwenrick on March 12, 2006, 12:07:15 AM
doesnt work in 1.7.2 i get an error

Fatal error: Cannot redeclare get_subcategories_id() (previously declared in /gallery/admin/categories.php:333) in /gallery/admin/categories.php on line 645
Title: Re: [MOD] Apply permission to sub-categories from their parent category
Post by: V@no on March 12, 2006, 01:23:44 AM
From Step 1.1 of this mod remove
Code: [Select]
      function get_subcategories_id($cat_id = 0)
      {
        global $subcat_ids, $cat_parent_cache;
     
        if (!isset($cat_parent_cache[$cat_id]))
        {
          return false;
        }
        foreach ($cat_parent_cache[$cat_id] as $key => $val)
        {
          $subcat_ids[] = $val;
          get_subcategories_id($val);
        }
        return $subcat_ids;
      }
v1.7.2 already has this function.
Title: Re: [MOD] Apply permission to sub-categories from their parent category
Post by: wallpapers on April 13, 2006, 06:58:47 AM
From Step 1.1 of this mod remove
Code: [Select]
      function get_subcategories_id($cat_id = 0)
      {
        global $subcat_ids, $cat_parent_cache;
     
        if (!isset($cat_parent_cache[$cat_id]))
        {
          return false;
        }
        foreach ($cat_parent_cache[$cat_id] as $key => $val)
        {
          $subcat_ids[] = $val;
          get_subcategories_id($val);
        }
        return $subcat_ids;
      }
v1.7.2 already has this function.

Thanks V@no this works perfect :lol:
Title: Re: [MOD] Apply permission to sub-categories from their parent category
Post by: fitterashes on April 14, 2006, 10:05:09 PM
Ok, here it is:[qcode]UPDATE 4images_categories SET
auth_viewcat = xx,
auth_viewimage = xx,
auth_download = xx,
auth_upload = xx,
auth_directupload = xx,
auth_vote = xx,
auth_sendpostcard = xx,
auth_readcomment = xx,
auth_postcomment = xx[/qcode]
The xx is one of the following:
  • 0 = All
  • 2 = Only registered members
  • 3 = Private
  • 9 = Admins only

is it possible to define categories to apply the changes ?
ex : UPDATE 4images_categories 200 to 500 SET [...]

(yeah i don't know anything about sql requests)
Title: Re: [MOD] Apply permission to sub-categories from their parent category
Post by: fitterashes on April 14, 2006, 10:31:11 PM
Ok, I answer myself  :D

Code: [Select]
UPDATE 4images_categories SET
auth_viewcat = x,
auth_viewimage = x,
auth_download = x,
auth_upload = x,
auth_directupload = x,
auth_vote = x,
auth_sendpostcard = x,
auth_readcomment = x,
auth_postcomment = x

WHERE cat_id=Y

or WHERE cat_id>Y etc...
Title: Re: [MOD] Apply permission to sub-categories from their parent category
Post by: Gwydion on April 25, 2006, 05:33:09 PM
Easy to "install", works great - thanks!
Title: Re: [MOD] Apply permission to sub-categories from their parent category
Post by: Mindze on May 02, 2006, 02:15:11 PM
PERFECT :)
Title: Fatal Error
Post by: koikonut on May 06, 2006, 07:44:18 AM
Quote
Fatal error: Cannot redeclare get_subcategories_id() (previously declared in /www/htdocs/v110298/galerie/admin/categories.php:331) in /www/htdocs/v110298/galerie/admin/categories.php on line 669

:-(

I have version 1.7.2 of the Script.What can I do?

Thx for helping
Title: Re: [MOD] Apply permission to sub-categories from their parent category
Post by: V@no on May 06, 2006, 04:10:45 PM
From Step 1.1 of this mod remove
Code: [Select]
function get_subcategories_id($cat_id = 0)
 {
 global $subcat_ids, $cat_parent_cache;
 
 if (!isset($cat_parent_cache[$cat_id]))
 {
 return false;
 }
 foreach ($cat_parent_cache[$cat_id] as $key => $val)
 {
 $subcat_ids[] = $val;
 get_subcategories_id($val);
 }
 return $subcat_ids;
 }
v1.7.2 already has this function.
Title: Re: [MOD] Apply permission to sub-categories from their parent category
Post by: lukasinoooo on May 27, 2006, 04:34:27 PM
I have problem in 1.72v

Step 1
Open admin/categories.php
Find:
Code:
  $auth_postcomment = $HTTP_POST_VARS['auth_postcomment'];

i found two
  $auth_postcomment = $HTTP_POST_VARS['auth_postcomment'];

in if ($action == "updatecat") and if ($action == "savecat") {

when insert   $subcats = (isset($HTTP_POST_VARS['subcats']) && $HTTP_POST_VARS['subcats']) ? 1 : 0; ?

in 1.72v doesn't work  :?
Title: Re: [MOD] Apply permission to sub-categories from their parent category
Post by: Gwydion on August 24, 2006, 07:18:56 PM
Applied it to 1.7.2 without step 1.1. No error message but subcategories are not changed either.
Any ideas? I checked the code twice and am pretty sure I made no mistake with copy-paste.
Title: Re: [MOD] Apply permission to sub-categories from their parent category
Post by: V@no on August 25, 2006, 04:43:36 AM
well, if you didnt do all the steps, then what are you complaining about? :roll:
Title: Re: [MOD] Apply permission to sub-categories from their parent category
Post by: Gwydion on August 26, 2006, 03:28:49 PM
Ah, misread .. thought the whole 1.1. had to be skipped. My bad.
Thanks for fixing it on page 1. :)
Title: Re: [MOD] Apply permission to sub-categories from their parent category
Post by: medo007 on September 17, 2006, 04:16:53 PM
Great mode! It works perfectly!  :D
Thanks
Title: Re: [MOD] Apply permission to sub-categories from their parent category
Post by: paburmester on October 02, 2006, 10:54:53 PM
Can this works with 1.7.3 ?
Title: Re: [MOD] Apply permission to sub-categories from their parent category
Post by: LGeneration on July 26, 2007, 11:14:34 AM
Zu früh gefreut :( Habe alles nach Anleitung gemacht, habe Version 1.7.3 (Link: klick (http://www.larasgeneration.de/4images/index.php)).
Im Admin Menü erscheint zwar das Feld "Apply to all subcategories", aber es funktioniert einfach nicht. Er übernimmt die Änderungen nicht für die Subkategorien :?
Title: Re: [MOD] Apply permission to sub-categories from their parent category
Post by: XxJakeBluesxX on February 05, 2008, 04:47:37 PM
Zu früh gefreut :( Habe alles nach Anleitung gemacht, habe Version 1.7.3 (Link: klick (http://www.larasgeneration.de/4images/index.php)).
Im Admin Menü erscheint zwar das Feld "Apply to all subcategories", aber es funktioniert einfach nicht. Er übernimmt die Änderungen nicht für die Subkategorien :?

Bei mir geht es auch nicht trotz des Feldes "Apply to all subcategories" (Version 1.7.6). Kann mal einer eine funktionierende und angepasste categories.php zum Download bereitstellen oder den Code posten?
Title: Re: [MOD] Apply permission to sub-categories from their parent category
Post by: silentg on June 26, 2008, 04:26:06 PM
Add this to your language file: admin.php

Find:
Quote
$lang['save_changes'] = "Save changes";

Insert it below:
Quote
$lang['sub_categories_permission'] = "Apply To All Subcategories";
Title: Re: [MOD] Apply permission to sub-categories from their parent category
Post by: silentg on June 26, 2008, 05:57:37 PM
You forgot to mention where to edit for the language code. Please fix that also.
Title: Re: [MOD] Apply permission to sub-categories from their parent category
Post by: Hagen-Roderich on July 30, 2009, 12:47:30 PM
@Ivan:
Vielleicht könntest Du noch bei Punkt 1 vermerken das man die zweite Stelle der gefundenen Zeilen (ca. 610 -612 Zeile) in der "categories.php" darunter ergänzen muss. Steht zwar schon mal weiter vorn im Thread, aber so wäre die Installation leichter.

Thanks for your work V@no and Ivan.
Title: Re: [MOD] Apply permission to sub-categories from their parent category
Post by: son_gokou on January 06, 2010, 06:46:44 PM
Great MOD!

Just one more thing I would like to do. How I go to edit some categorie, the button "NO" related to "Aplly to all subcategories" is selectect by default. How can I turn into default the button "YES" to be selected?
Title: Re: [MOD] Apply permission to sub-categories from their parent category
Post by: XxJakeBluesxX on March 30, 2010, 10:14:57 AM
Funktioniert das auch mit Version 1.7.7?
Title: Re: [MOD] Apply permission to sub-categories from their parent category
Post by: Hagen-Roderich on March 30, 2010, 02:40:54 PM
Funktioniert das auch mit Version 1.7.7?

Ich habs unter 1.7.6, entsprechend der Anleitung für 1.7.4 - 1.7.6 installiert. Danach einen manuellen Update auf 1.7.7 gemacht und der MOD läuft heut noch.
Daher gehe ich davon aus das er auch in einem "reinen" 1.7.7 läuft.
Du kannst den MOD ja vorher mit der Mobilserver Version 1.7.7 testen.
Title: Re: [MOD] Apply permission to sub-categories from their parent category
Post by: XxJakeBluesxX on March 30, 2010, 06:20:14 PM
Habe die beiden Dateien geändert. Hat prima funktioniert...  :D

Nun ist endlich Schluss mit dem schei** Spam... :mrgreen:
Title: Re: [MOD] Apply permission to sub-categories from their parent category 1.7.7
Post by: Sunny C. on July 31, 2010, 01:12:27 PM
Original Code from: V@no (http://www.4homepages.de/forum/index.php?topic=7643.0) and Ivan (http://www.4homepages.de/forum/index.php?topic=7643.msg110977#msg110977)

Changelog / Änderungen:

Dieser MOD kann die Rechte einer Kategorie mit allen Unterkategorien aktualisieren.

Läuft mit 4images 1.7.7
Work with 4images 1.7.7


Step 1
Open / Öffne: admin/categories.php

Find / Finde:
  $auth_sendpostcard = $HTTP_POST_VARS['auth_sendpostcard'];
  $auth_readcomment = $HTTP_POST_VARS['auth_readcomment'];
  $auth_postcomment = $HTTP_POST_VARS['auth_postcomment'];

Insert / Füge below / darunter:
// MOD SUBCAT PERM FROM PARENT START
  $subcats = (isset($HTTP_POST_VARS['subcats']) && $HTTP_POST_VARS['subcats']) ? 1 : 0;
// MOD SUBCAT PERM FROM PARENT END



Step 1.1
Find / Finde:
  show_table_separator($permission_headline, 2);
  foreach ($access_field_array as $key => $val) {
    show_access_select($lang[$key], $key, $val);
  }
Insert / Füge below / danach:
  // MOD SUBCAT PERM FROM PARENT START
  show_radio_row($lang['sub_categories_permission'], "subcats", $subcats);
// MOD SUBCAT PERM FROM PARENT END;

Step 1.2
Find / Finde:
    $msg = ($result) ? $lang['cat_edit_success'] : $lang['cat_edit_error'];

Insert / Füge above / davor:
// MOD SUBCAT PERM FROM PARENT START
    if ($subcats)
    {
      $subcat_ids = array();
      $subcat_ids = get_subcategories_id($cat_id);
      if (!empty($subcat_ids))
      {
        $sql = "UPDATE ".CATEGORIES_TABLE."
                SET 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
                WHERE cat_id IN (".implode($subcat_ids, ",").")";
        $result = $site_db->query($sql);
      }
    }
// MOD SUBCAT PERM FROM PARENT END



Step 1.3
Find / Finde:
  show_form_footer($lang['save_changes'], $lang['reset'], 2, $lang['back']);

Insert / Füge above / darüber:
Code: [Select]
// MOD SUBCAT PERM FROM PARENT START
  show_radio_row($lang['sub_categories_permission'], "subcats", $subcats);
// MOD SUBCAT PERM FROM PARENT END

Step 1.4
Open / Öffne lang/admin.php
Find / Finde:
* English
$lang['save_changes'] = "Save changes";
* Deutsch
$lang['save_changes'] = "Änderungen speichern";

Replace / Ersetze mit:
* English
$lang['save_changes'] = "Save changes";
$lang['sub_categories_permission'] = "Apply To All Subcategories";
* Deutsch
$lang['save_changes'] = "Änderungen speichern";
$lang['sub_categories_permission'] = "Für alle Unterkategorien übernehmen";
Title: Re: [MOD] Apply permission to sub-categories from their parent category
Post by: zakaria666 on September 11, 2010, 01:45:04 AM
Has this mod been tested?

I installed it checked my add categories inside my admin control panel and there was duplicates. Gave me errors.

Thanks any way man