0 Members and 1 Guest are viewing this topic.

Private Albums - some code changes to make it work again
« on: November 23, 2017, 07:18:37 PM »
Hello,

My understanding of how Private Albums work is as follows:
- the membership level for the member should allow private albums (set by the Administrator)
- in order for a member to allow others to see their private albums, the other member must be on their buddy list or hot list
- album passwords (used in past version of osDate) are no longer used.

However, the functionality does not seem to be currently supported.

Here are the list changes I made to osDateEvo v1.2 and the "default" templates to get this working again:

template/default/usersnap.tpl
1. Unhide the Album selector and remove the password input field.

Change from

Code: [Select]
<div style="width:100%; padding-bottom: 6px; text-align:center; display:none">
<form action="uploadsnaps.php" name="select_album"  method="post">
<input type="hidden" name="type" value="{$type}" />
{lang mkey='album_hdr'}:&nbsp;&nbsp;
<select name="album_id" onChange="this.form.submit();">
{foreach from=$useralbums item=album}
<option value="{$album.id}" {if $album.id==$album_id} selected {/if}>{$album.name|stripslashes}</option>
{/foreach}
</select>
&nbsp;&nbsp;{lang mkey='or'}&nbsp;{lang mkey='addnew'}:&nbsp;
<input name="album_name" size="20" maxlength="30" type="text" class="textinput" />
&nbsp;
{lang mkey='signup_password'}&nbsp;
<input name="album_passwd" type="password" class="textinput" size="12"/>
&nbsp;<input type="submit" name="createalbum" value="{lang mkey='submit'}" class="formbutton" />
</form>
</div>

To

Code: [Select]
<div style="width:100%; padding-bottom: 6px; text-align:center;">
<form action="uploadsnaps.php" name="select_album"  method="post">
<input type="hidden" name="type" value="{$type}" />
{lang mkey='album_hdr'}:&nbsp;&nbsp;
<select name="album_id" onChange="this.form.submit();">
{foreach from=$useralbums item=album}
<option value="{$album.id}" {if $album.id==$album_id} selected {/if}>$album.name|stripslashes}</option>
{/foreach}
</select>
&nbsp;&nbsp;{lang mkey='or'}&nbsp;{lang mkey='addnew'}:&nbsp;
<input name="album_name" size="20" maxlength="30" type="text" class="textinput" />
&nbsp;
&nbsp;<input type="submit" name="createalbum" value="{lang mkey='submit'}" class="formbutton" />
</form>
</div>

template/default/userpicgallery.tpl

2. Hide the password from the other member (note: this works even if the other member leaves the password blank but it is confusing to leave it there). Also, if the member is adding a new Album this template is shown so showing a password is also confusing).

Comment out the following code:
Code: [Select]
{if $albumpasswd > 0 }
{if $smarty.session.UserId != $userid }
&nbsp;&nbsp;&nbsp;
{lang mkey='signup_password'}&nbsp;
<input name="album_passwd" type="password" class="textinput" size="15"/>
{else}
<input name="album_passwd" type="hidden" value='' size="15"/>
{/if}
{/if} *}

uploadsnaps.php

3. The password does not need to be saved (this is optional. It will not affect functionality if not done).

Change from
Code: [Select]
$osDB->query('insert into ! (username, name, passwd) values (?, ?, ?)', array( USERALBUMS_TABLE, $_SESSION['UserName'], $_POST['album_name'], md5($_POST['album_passwd'])) );

To
Code: [Select]
$osDB->query('insert into ! (username, name) values (?, ?)', array( USERALBUMS_TABLE, $_SESSION['UserName'], $_POST['album_name']) );


Admin/showpics.php

4. On the Admin side fix the following bug (this is an actual bug as there is no user id in the USERALBUMS_TABLE).

Change from
Code: [Select]
$albs = $osDB->getAll('select id, name from ! order by name', array( USERALBUMS_TABLE ) );

To
Code: [Select]
$albs = $osDB->getAll('select ua.id as id, ua.name as name from ! ua, ! u where u.id = ? and u.username = ua.username order by ua.name', array( USERALBUMS_TABLE, USER_TABLE, $_REQUEST['userid'] ) );


template/default/Admin/userpics.tpl

5. Hide the password field on the page

Change from
Code: [Select]
<td >{lang mkey='album_hdr'}:&nbsp;&nbsp;
<select name="album_id">
{foreach from=$useralbums item=album}
<option value="{$album.id}" {if $album.id== $data[$smarty.section.sec.index].album_id} selected {/if}>{$album.name|stripslashes}
</option>
{/foreach}
</select>
&nbsp;&nbsp;{lang mkey='or'}&nbsp;{lang mkey='addnew'}:&nbsp;
<input name="album_name" size="12" maxlength="25" type="text"  class="textinput"/>
&nbsp;
{lang mkey='signup_password'}&nbsp;
<input name="album_passwd" type="password" class="textinput" size="12"/>
{if $data[$smarty.section.sec.index].picture ne ''} &nbsp;<input type="submit" name="changealbum" value="{lang mkey='change_album'}" class="formbutton"/>
{/if}
</td>

To
Code: [Select]
<td >{lang mkey='album_hdr'}:&nbsp;&nbsp;
<select name="album_id">
{foreach from=$useralbums item=album}
<option value="{$album.id}" {if $album.id== $data[$smarty.section.sec.index].album_id} selected {/if}>{$album.name|stripslashes}
</option>
{/foreach}
</select>
&nbsp;&nbsp;{lang mkey='or'}&nbsp;{lang mkey='addnew'}:&nbsp;
<input name="album_name" size="12" maxlength="25" type="text"  class="textinput"/>
&nbsp;
{if $data[$smarty.section.sec.index].picture ne ''} &nbsp;<input type="submit" name="changealbum" value="{lang mkey='change_album'}" class="formbutton"/>
{/if}
</td>


Admin/saveuserpics.php

6. Password does not need to be saved (optional)

Change from
Code: [Select]
$osDB->query('insert into ! (username, name, passwd) values (?, ?, ?)', array( USERALBUMS_TABLE, $userinfo['username'], $_POST['album_name'], md5($_POST['album_passwd'])) );

To
Code: [Select]
$osDB->query('insert into ! (username, name) values (?, ?)', array( USERALBUMS_TABLE, $userinfo['username'], $_POST['album_name']) );


I am not really sure why this functionality was disabled - so perhaps I am missing a use case / test case. However, the functionally on the default installation with the default template seem to be working again for me.

Good luck.
« Last Edit: November 23, 2017, 10:58:35 PM by Pharg »
PHPStorm, MAMP Pro, Sequel Pro
Currently converting my 2.1.6 site to osDateEvo 1.2

*

Pharg

  • *****
  • 2,913
    • OsDateFourm
  • osDate Version: osDateEvo v1.2
Re: Private Albums - some code changes to make it work again
« Reply #1 on: November 23, 2017, 08:18:17 PM »
Hi arievaul,

Thanks for the share and update, will look at it soon. :)

It was disabled for 2 reasons, needing to share passwords was a bad idea and the album script stopped working.
Regards,
Pharg ( Phill )

REMEMBER: ALWAYS BACKUP BEFORE YOU MAKE ANY CHANGES!!

osDateEvo v1.2 | PHP: 5.3.42 & PHP: 5.6.18 | MySQL: 5.5.35

*

Pharg

  • *****
  • 2,913
    • OsDateFourm
  • osDate Version: osDateEvo v1.2
Re: Private Albums - some code changes to make it work again
« Reply #2 on: November 23, 2017, 08:30:28 PM »
Hi arieaul,

Here is the Friends mod https://www.osdateforum.com/addons-modules-7/(free)-friends-mod-cbg/

It's functions can open up if in friends list can view private albums can be add do away with the password system.
Regards,
Pharg ( Phill )

REMEMBER: ALWAYS BACKUP BEFORE YOU MAKE ANY CHANGES!!

osDateEvo v1.2 | PHP: 5.3.42 & PHP: 5.6.18 | MySQL: 5.5.35

*

Pharg

  • *****
  • 2,913
    • OsDateFourm
  • osDate Version: osDateEvo v1.2
Re: Private Albums - some code changes to make it work again
« Reply #3 on: November 23, 2017, 10:55:28 PM »
Hi arievaul,

I have tested this and it looks great and works fine, think I need to add the friends mod to use as people that
can view the private photos if in friends list only.

Thanks for the nice fix :)
« Last Edit: November 23, 2017, 10:59:28 PM by Pharg »
Regards,
Pharg ( Phill )

REMEMBER: ALWAYS BACKUP BEFORE YOU MAKE ANY CHANGES!!

osDateEvo v1.2 | PHP: 5.3.42 & PHP: 5.6.18 | MySQL: 5.5.35

Re: Private Albums - some code changes to make it work again
« Reply #4 on: November 23, 2017, 11:10:52 PM »
Hi Phill,

Thank you for looking at this (and fixing the typo  :) ). In the meantime, I am glad to have the private pics back.

I think the Friends module is the way to go - it also adds a 'social network' element to the site by building up a trusted network. It would be a great foundation for other add ons.

PHPStorm, MAMP Pro, Sequel Pro
Currently converting my 2.1.6 site to osDateEvo 1.2