Two questions

pande

Joined: 2005-05-08
Posts: 56
Posted: Tue, 2005-05-24 15:47

Hi guys, I have 2 questions considering G2:

1. I've succeeded in adapting the Matrix template layout to my wishes. One of them was to remove the First and Last link on every full photo page, because I don't see the need of jumping to the first or last photo of an album when you want to see them all :) But now, when you enter the second photo or the one before the last one, there is no previous or next link, because First or Last was supposed to get you to that one... Any way of fixing this?

2. Second, the last couple of months/years, using my old photosystem, I used a .htaccess & .htpassword for my users... Now I don't want them to register again... can I manually add their usernames and (hashed) passwords in the G2 database without causing any problems... and does it matter which ID I give them, or is everything fine just as long as it isn't already in the list?

Thx!

 
valiant

Joined: 2003-01-04
Posts: 32509
Posted: Tue, 2005-05-24 16:16

@2.:
You should use the G2 API to add users, as creating a user is not just inserting a row into a single table (you'd have to add him to default groups and insert a row into another table (entity).
better use the API.
it's quite easy...

<?php
include('embed.php);
$ret = GalleryEmbed::init(array('fullInit' => true));
if ($ret->isError()) {
    die($ret->getAsHtml());
}

/* somehow get a list of your htpass users, assume $userlist is this list */
foreach ($userlist as $userdata) {
    list ($ret, $user) = GalleryCoreApi::newFactoryInstance('GalleryEntity', 'GalleryUser');
    if ($ret->isError()) {
        die($ret->getAsHtml());
    }
    if (!isset($user)) {
        die($ret->getAsHtml());
    }
    $ret = $user->create($userdata['userName']);
    if ($ret->isError()) {
        if (!($ret->getErrorCode() & ERROR_COLLISION)) {
            /* username already exists in G2, you could change here the new users name, i just bail out here */
            die($ret->getAsHtml());
        } else {
            die($ret->getAsHtml());
        }
    } else {
        /*  set userdata if you have some */
//        $user->setEmail($userdata['email']);
//                    $user->setFullName($userdata['fullName']);
            $user->setFullName($userdata['userName']); /* set the fullName to user name if nothing else is available, or leave it out */
//                    $user->setLanguage($userdata['language']);
/* if you copy the hashed password,make sure the same hash algorithm was used (md5 in hexadecimal format) */
//                    $user->changePassword($userdata['password1']); /* for clear type password */
// $user->sethashedPassword($userdata['hashedPassword']); /* for hashed passwords */

        $ret = $user->save();
        if ($ret->isError()) {
           die($ret->getAsHtml());
        }
    }
}

$ret = GalleryEmbed::done();
if ($ret->isError()) {
   die($ret->getAsHtml());
}
?>
 
valiant

Joined: 2003-01-04
Posts: 32509
Posted: Tue, 2005-05-24 16:18

ps: better backup your G2 before you do such things :)

 
mindless
mindless's picture

Joined: 2004-01-04
Posts: 8601
Posted: Tue, 2005-05-24 16:20

@1:
{if isset($layout.navigator.first) && !isset($layout.navigator.back)}
... and change "first" to "previous".
same for last/next.

 
pande

Joined: 2005-05-08
Posts: 56
Posted: Fri, 2005-05-27 09:40

Hi guys,

Thanks for your quick response!

@2: I know a bit of coding, but I don't know what API is, and I don't even know if the code you put above is an already existing file or something I should create, so I better shouldn't mess with that; I'll just let them register again. :)

@1: Of course I did understand your solution, but it's not working. I've tried several other replacements as well, like back instead of previous and replacing all the "first" to "previous", but no luck... The first/last text link just dissapears and the grey stroke they are in gets smaller...

This is what I supposedly was to do according to your answer, right?

  {if isset($layout.navigator.previous) || isset($layout.navigator.back)}
  <div>
    {if isset($layout.navigator.first)}
   <a href="{g->url params=$layout.navigator.first.urlParams}">
      {if isset($layout.navigator.first.item.thumbnail)}
	{g->image item=$layout.navigator.first.item image=$layout.navigator.first.item.thumbnail
		  maxSize=40 class="giThumbnail"}
      {/if}
      {g->text text="&amp;&amp; first"}
    </a>
    {/if}
 
valiant

Joined: 2003-01-04
Posts: 32509
Posted: Fri, 2005-05-27 09:44

API -> google -> wikipedia -> http://en.wikipedia.org/wiki/Application_programming_interface

@code: no, this code doesn't exist in G2. i wrote it for you. there a few comments in it, where you need to customize it.
but letting them register again is also a solution ... :)

 
pande

Joined: 2005-05-08
Posts: 56
Posted: Fri, 2005-05-27 09:52

btw:

Is there a way in Gallery of logging/keeping track which users have logged in or something like that?

Probably been asked before, but the search doesn't seem to be working

Fatal error: Call to a member function on a non-object in /usr/www/website/gallery.menalto.com/includes/advblocks.php on line 72
 
valiant

Joined: 2003-01-04
Posts: 32509
Posted: Fri, 2005-05-27 09:59

no, there's no "who's online" box or something like a list of who has been online when for the last time.

of course we could introduce something like that and there already exists a feature request for a who's online list. and we of course we welcome any user contribution if you think you can code it yourself :)