Advanced search  

News:

cpg1.5.48 Security release - upgrade mandatory!
The Coppermine development team is releasing a security update for Coppermine in order to counter a recently discovered vulnerability. It is important that all users who run version cpg1.5.46 or older update to this latest version as soon as possible.
[more]

Pages: [1]   Go Down

Author Topic: User Galleries as Root Categories  (Read 13931 times)

0 Members and 1 Guest are viewing this topic.

pkulak

  • Coppermine newbie
  • Offline Offline
  • Posts: 14
    • PKulak.com
User Galleries as Root Categories
« on: May 02, 2004, 11:18:12 am »

I only have two users, so I modified index.php so that their user galleries show up just as if they were categories. I'm not going to post a guide yet. I'll do that if someone actually wants to try it since the guide takes as long as the hack. You can check it out here:

http://www.pkulak.com/photos/
« Last Edit: August 25, 2004, 08:51:43 pm by GauGau »
Logged
"To do any good at all, just believing you are right and you motives are good isn't enough." - Ursula K. Le Guin

photoman13

  • Coppermine regular visitor
  • **
  • Offline Offline
  • Posts: 96
Re: HACK: User Galleries as Root Categories
« Reply #1 on: May 02, 2004, 12:52:43 pm »

I would love to see your hack for this... :)

also if you have normal admin created Galleries (Noticed you don't have any on that site) will they be effected in any way?

Thanks
Logged

pkulak

  • Coppermine newbie
  • Offline Offline
  • Posts: 14
    • PKulak.com
Re: HACK: User Galleries as Root Categories
« Reply #2 on: May 02, 2004, 08:01:09 pm »

Here we go.

1. Add the following code in index.php:
Code: [Select]
   // Display the user categories if we're at the top.
    if (empty($parent)) {
       $sql = "SELECT user_id + " . FIRST_USER_CAT . " AS catID,
                      user_name
               FROM {$CONFIG['TABLE_USERS']}
               ORDER BY user_name";
       $users = db_fetch_rowset(db_query($sql));
       
       foreach ($users as $user) {
          $sql = "SELECT COUNT(*)
                  FROM {$CONFIG['TABLE_ALBUMS']}
                  WHERE category = {$user[0]}";
          $album = mysql_fetch_array(db_query($sql));
         
          $sql = "SELECT COUNT(*)
                  FROM {$CONFIG['TABLE_ALBUMS']} JOIN {$CONFIG['TABLE_PICTURES']}
                       ON {$CONFIG['TABLE_ALBUMS']}.aid = {$CONFIG['TABLE_PICTURES']}.aid
                  WHERE {$CONFIG['TABLE_ALBUMS']}.category = {$user[0]}";
          $picture = mysql_fetch_array(db_query($sql));
   
          $cat_data[] = array("<a href=\"index.php?cat={$user[0]}\">{$user[1]}'s Photos</a>","","{$album[0]}","{$picture[0]}", 'cat_albums' => list_cat_albums($user[0]) );
       }
    }
right before
Code: [Select]
}
// List all categories
function get_cat_list(&$breadcrumb, &$cat_data, &$statistics)
Basicaly, you want that if statement to be the last thing in the get_subcat_data() function.

2. That's really it, just a few little things to tidy up. First, there is no need to
have the User Galleries category show up anymore. Change the following SQL:
Code: [Select]
SELECT cid, name, description FROM {$CONFIG['TABLE_CATEGORIES']} WHERE parent = '$parent'  ORDER BY pos
to
Code: [Select]
SELECT cid, name, description FROM {$CONFIG['TABLE_CATEGORIES']} WHERE parent = '$parent' AND cid <> 1 ORDER BY pos
3. Next we need to have the stats reflecting our changes. Change this code block:
Code: [Select]
$result = db_query("SELECT count(*) FROM {$CONFIG['TABLE_CATEGORIES']} WHERE 1");
$nbEnr = mysql_fetch_array($result);
$cat_count = $nbEnr[0] - $HIDE_USER_CAT;
mysql_free_result($result);
to
Code: [Select]
$result = db_query("SELECT count(*) FROM {$CONFIG['TABLE_CATEGORIES']} WHERE 1");
$nbEnr = mysql_fetch_array($result);
$totalCats = $nbEnr[0];
$result = db_query("SELECT count(*) FROM {$CONFIG['TABLE_USERS']} WHERE 1");
$nbEnr = mysql_fetch_array($result);
$totalUsers = $nbEnr[0];
$cat_count = $totalCats - $HIDE_USER_CAT - 1 + $totalUsers;
mysql_free_result($result);
And you're done. The only thing left would be to add a row to your config table and turn
this into something you can turn on and off. To borrow from a bad textbook,
I'll leave that as an exercise to the reader.

I can always just post my index.php file. If you have 1.2.1 and haven't modified yours you can just replace it.
« Last Edit: May 03, 2004, 12:18:11 am by pkulak »
Logged
"To do any good at all, just believing you are right and you motives are good isn't enough." - Ursula K. Le Guin

jpepin

  • Coppermine newbie
  • Offline Offline
  • Posts: 10
    • http://www.pepinonline.com
Re: HACK: User Galleries as Root Categories
« Reply #3 on: May 16, 2004, 08:45:31 pm »

Will this work without doing the database mods?  I'm getting this error:

There was an error while processing a database query

Logged

rostros

  • Coppermine novice
  • *
  • Offline Offline
  • Posts: 49
Re: HACK: User Galleries as Root Categories
« Reply #4 on: June 04, 2004, 12:52:56 pm »

great Mod, One problem it displays all the users albums on the main page ??? even though you set the options in config to only display 2rows and 2 colloumns ?
Logged

comic

  • Coppermine newbie
  • Offline Offline
  • Posts: 8
Re: HACK: User Galleries as Root Categories
« Reply #5 on: July 06, 2004, 10:53:15 am »

Will this work without doing the database mods?  I'm getting this error:

There was an error while processing a database query



I'm getting the same error on coppermine v1.3.0. The statement that is offending is the first sql query (I commented it out and didn't get the same error, though ofcause it didn't work). I tried it on 1.2.1 too on another site and got the same error there too :/

Some experimenting gives that the following code is giving the error:
          $sql = "SELECT COUNT(*)
                  FROM {$CONFIG['TABLE_ALBUMS']} JOIN {$CONFIG['TABLE_PICTURES']}
                       ON {$CONFIG['TABLE_ALBUMS']}.aid = {$CONFIG['TABLE_PICTURES']}.aid
                  WHERE {$CONFIG['TABLE_ALBUMS']}.category = {$user[0]}";
          $picture = mysql_fetch_array(db_query($sql));


Anyone?
« Last Edit: July 06, 2004, 07:26:21 pm by comic »
Logged

kalasdojan

  • Coppermine newbie
  • Offline Offline
  • Posts: 2
Re: [CPG1.2.1]: HACK: User Galleries as Root Categories
« Reply #6 on: August 22, 2004, 07:21:04 pm »

How do I make this work in CPG 1.3x? I get a MySQL-error after changing the index.php-file.
Help appreciated!
//daniel.
Logged

Joachim Müller

  • Dev Team member
  • Coppermine addict
  • ****
  • Offline Offline
  • Gender: Male
  • Posts: 47843
  • aka "GauGau"
    • gaugau.de
Re: [CPG1.2.1]: HACK: User Galleries as Root Categories
« Reply #7 on: August 23, 2004, 12:56:15 am »

How do I make this work in CPG 1.3x? I get a MySQL-error after changing the index.php-file.
That's why the thread is labelled
Quote
[CPG1.2.1]: HACK: User Galleries as Root Categories
If you need it, you will have to adjust the code. Mods are user contributions, they come as-is.

GauGau
Logged

comic

  • Coppermine newbie
  • Offline Offline
  • Posts: 8
Re: User Galleries as Root Categories
« Reply #8 on: October 27, 2004, 01:46:10 am »

Ok now I go it working, I like the hack vey much, but realized that many usergalleries will make a very very long page. For example a few (ie 50) users will work fine on one page, but when you have several hundreds you would like to have some tabs and display 50 users at every page. Anyone has an idea how to do that?

I presume I should hack index.php with something similar as the function list_cat_albums for starting the userlist. Then probaby another file with a similar functionality as thumbnails.php which answers the call for another page of users.

Even when you don't have the time, please give some directions and I will try for myself . . . .

thanks,
Comic
Logged

crashtd

  • Coppermine newbie
  • Offline Offline
  • Posts: 4
Re: User Galleries as Root Categories
« Reply #9 on: January 09, 2005, 04:32:05 am »

Ok now I go it working, I like the hack vey much, but realized that many usergalleries will make a very very long page. For example a few (ie 50) users will work fine on one page, but when you have several hundreds you would like to have some tabs and display 50 users at every page. Anyone has an idea how to do that?

I presume I should hack index.php with something similar as the function list_cat_albums for starting the userlist. Then probaby another file with a similar functionality as thumbnails.php which answers the call for another page of users.

Even when you don't have the time, please give some directions and I will try for myself . . . .

thanks,
Comic

comic what did you do to get this to work on 1.3?
Logged

partypics

  • Contributor
  • Coppermine novice
  • ***
  • Offline Offline
  • Posts: 24
Re: User Galleries as Root Categories
« Reply #10 on: January 10, 2005, 08:30:24 pm »

If you just want to see a list of your users on the first page (not all of their albums) you can achieve it by modifying your index.php :
find this
Code: [Select]
if (isset($HTTP_GET_VARS['cat'])) {
    $cat = (int)$HTTP_GET_VARS['cat'];
}
and replace it with this:
Code: [Select]
if (isset($HTTP_GET_VARS['cat'])) {
    $cat = (int)$HTTP_GET_VARS['cat'];
}
else {
$cat = USER_GAL_CAT;
}
That's if you don't have any other categories except User Galleries.
Logged

crashtd

  • Coppermine newbie
  • Offline Offline
  • Posts: 4
Re: User Galleries as Root Categories
« Reply #11 on: January 14, 2005, 11:50:50 pm »

If you just want to see a list of your users on the first page (not all of their albums) you can achieve it by modifying your index.php :
find this
Code: [Select]
if (isset($HTTP_GET_VARS['cat'])) {
    $cat = (int)$HTTP_GET_VARS['cat'];
}
and replace it with this:
Code: [Select]
if (isset($HTTP_GET_VARS['cat'])) {
    $cat = (int)$HTTP_GET_VARS['cat'];
}
else {
$cat = USER_GAL_CAT;
}
That's if you don't have any other categories except User Galleries.


but that doesn't work when you want to display the user galleries and the admin created galleries does it?
Logged

partypics

  • Contributor
  • Coppermine novice
  • ***
  • Offline Offline
  • Posts: 24
Re: User Galleries as Root Categories
« Reply #12 on: January 15, 2005, 02:27:13 pm »

It doesn't. you will only see User Galleries
Logged

ToddW

  • Coppermine newbie
  • Offline Offline
  • Posts: 17
Re: User Galleries as Root Categories
« Reply #13 on: February 27, 2005, 06:14:48 am »

So did someone figure out how to limit it to two rows and work for 1.3 ?
Logged

Charles Scott

  • Coppermine regular visitor
  • **
  • Offline Offline
  • Gender: Male
  • Posts: 62
    • Holiday Confusion
Re: User Galleries as Root Categories
« Reply #14 on: April 01, 2005, 03:47:53 am »

pkulak, this works perfectly. Now the real question. What if I want to have my categories display normally and also have the user albums display like your mod makes it do?

How do I get the best of both worlds?
Logged

Joachim Müller

  • Dev Team member
  • Coppermine addict
  • ****
  • Offline Offline
  • Gender: Male
  • Posts: 47843
  • aka "GauGau"
    • gaugau.de
MOVED: User Galleries as sub-categories
« Reply #15 on: April 07, 2005, 07:43:48 am »

A reply to this thread has been moved to the Feature requests board as requested.

http://forum.coppermine-gallery.net/index.php?topic=16675.0
Logged

HaVaNa7

  • Coppermine newbie
  • Offline Offline
  • Posts: 8
Re: User Galleries as Root Categories
« Reply #16 on: April 19, 2005, 02:24:28 am »

For CPG 1.3 i have found a very simple way to show user galleries as root.

Yoh have to do three simple steps:

1)Upload a redirect script in your web space and point it to http://www.yoururl.com/index.php?cat=1

use this:
Code: [Select]
<?php
///////////////////////////////////////////////////////////////////////////
// Free Redirection Script By Only PHP www.onlyphp.com
///////////////////////////////////////////////////////////////////////////

$SETUP[siteurl] = "http://www.yoursite.com/index.php?cat=1";

if (
$url) {

$lines_array file($url);
$lines_string implode(''$lines_array);
eregi("<head>(.*)</head>"$lines_string$head);


?>

<html>

<head>
<title>Redirecting Now...</title>
<script LANGUAGE="JavaScript">
  var VersionString = navigator.appVersion

  if (navigator.appName == "Netscape") {
    if (VersionString.substring(0,1) >= 1) {
  // Netscape 3.0 (or later) browsers go to this location:
  location = "<?php echo $url?>"
  }
    }

  if (navigator.appName == "Microsoft Internet Explorer") {
    if (VersionString.substring(0,1) >= 1) {
  // Microsoft Internet Explorer users go to this location:
  location = "<?php echo $url?>";
  }
    }

  </script>
</head>

<body bgcolor=white>

  <p>You're Being Redirected To The Page Requested <a href="<?php echo $url?>">If you don't want to wait or it doesn't open please click here...</a>
  </body>


</html>




<?php
exit();

} else {

header("Location: $SETUP[siteurl]");
exit();

}


2)Modify Theme.php in your theme dir and modify theese lines:

Code: [Select]
<!-- BEGIN album_list -->
                        <a href="{ALB_LIST_TGT}" title="{ALB_LIST_TITLE}">{ALB_LIST_LNK}</a> ::
<!-- END album_list -->

in:

Code: [Select]
<!-- BEGIN album_list -->
                        <a href="http://yoursite.com/coppermine/index.php?cat=1" title="{ALB_LIST_TITLE}">{ALB_LIST_LNK}</a>
<!-- END album_list -->

3)

in functions.inc.php in include folder modify thees lines:

Code: [Select]
}else{ //Dont bother just add the Home link to breadcrumb
                $breadcrumb = '<a href=index.php?cat=1>'.$lang_list_categories['home'].'</a>';
                $BREADCRUMB_TEXT = $lang_list_categories['home'];
        }

in:

Code: [Select]
}else{ //Dont bother just add the Home link to breadcrumb
                $breadcrumb = '<a href=index.php?cat=1>'.$lang_list_categories['home'].'</a>';
                $BREADCRUMB_TEXT = $lang_list_categories['home'];
        }

and:

Code: [Select]
 $breadcrumb_array = array_reverse($breadcrumb_array);
                $breadcrumb = '<a href=index.php?cat=1>'.$lang_list_categories['home'].'</a>';
                $BREADCRUMB_TEXT = $lang_list_categories['home'];

in:

Code: [Select]
 $breadcrumb_array = array_reverse($breadcrumb_array);
                $breadcrumb = '<a href=index.php?cat=1>'.$lang_list_categories['home'].'</a>';
                $BREADCRUMB_TEXT = $lang_list_categories['home'];

Ok, done!

It seems to work well...
« Last Edit: April 19, 2005, 12:49:28 pm by HaVaNa7 »
Logged

ant eater

  • Coppermine newbie
  • Offline Offline
  • Posts: 2
Re: User Galleries as Root Categories
« Reply #17 on: September 11, 2005, 08:10:16 pm »

i achieved this by simply adding a line and it works like a charm  :D

possibly not the best solution but here it goes:

find this around line 703 on index.php:
Code: [Select]
            case 'alblist':
                list_albums();
                flush();
                break;

replace it with:
Code: [Select]
            case 'alblist':
                list_albums();
            if ($cat == "0"){ list_users(); }
                flush();
                break;

that will show the list of users in the index.

regards.
Logged
Pages: [1]   Go Up
 

Page created in 0.038 seconds with 18 queries.