Elxis CMS Forum

Extensions => Components => Topic started by: CREATIVE Options on June 15, 2011, 14:49:02

Title: IOS Downloads - Listing for more than one usergroup
Post by: CREATIVE Options on June 15, 2011, 14:49:02
I have start a modification on IOS Downloads so a listing can be accessed from 2 user groups.

Steps:
1. Add a custom field in DB "access2" in ***_downloads_files

DELETED OLD CODE FROM CREATIVE OPTIONS
Title: Re: IOS Downloads - Listing for more than one usergroup
Post by: datahell on June 15, 2011, 22:15:45
You confused the download access with the add new listing access. You only need to add a second download access.

downloads.class.php
Line 400: public $access = '29'; //download access
Add bellow:
public $access2 = '29'; //download access

admin.downloads.php
line 671: $lists['access'] = mosAdminMenus::Access($row);
Add bellow:
$ac = $row->access;
$row->access = $row->access2;
$lists['access2'] = mosAdminMenus::Access($row);
$row->access = $ac;
unset($ac);

line 937: $row->access = ''.intval($row->access).'';
Add bellow:
$row->access2 = ''.intval($row->access2).'';

admin.downloads.html.php
line 965:
<tr>
   <td valign="top"><?php echo $adminLanguage->A_ACCESS; ?></td>
   <td><?php echo $lists['access']; ?></td>
</tr>

Add bellow:
<tr>
   <td valign="top"><?php echo $adminLanguage->A_ACCESS; ?></td>
   <td><?php echo $lists['access2']; ?></td>
</tr>

downloads.php
line 747, add access2:
$database->setQuery("SELECT id, file, downloads, access, access2 FROM....

line 755:
if (!in_array($row->access, explode(',',$my->allowed))) {
Convert it to:
if (!in_array($row->access, explode(',',$my->allowed)) && !in_array($row->access2, explode(',',$my->allowed))) {

If you want to also edit listings from frontend you have also to make similar changes as for the admin area.

downloads.html.php
line 459:
."\n AND access IN (".$my->allowed.")";
convert it to:
."\n AND ((access IN (".$my->allowed.")) OR (access2 IN (".$my->allowed.")))";

line 547:
if (in_array($row->access, explode(',',$my->allowed))) {
convert it to:
if (in_array($row->access, explode(',',$my->allowed)) || in_array($row->access2, explode(',',$my->allowed))) {

line 616:
."\n AND access IN (".$my->allowed.")";
convert it to:
."\n AND ((access IN (".$my->allowed.")) OR (access2 IN (".$my->allowed.")))";

line 825:
if (!in_array($row->access, explode(',',$my->allowed))) {
convert it to:
if (!in_array($row->access, explode(',',$my->allowed)) && !in_array($row->access2, explode(',',$my->allowed))) {

line 839:
if (in_array($row->access, explode(',',$my->allowed))) {
convert it to:
if (in_array($row->access, explode(',',$my->allowed)) || in_array($row->access2, explode(',',$my->allowed))) {

If you want to also edit listings from frontend you have also to make similar changes as for the admin area.

WARNING: access and access2 should at least of the same level. If for example you provide access = 18 (registered) and access2 = 29 (public frontend) guests will be able to download the file (because of the OR operator used to check access)! So you must set both access elements to at least user group 18 (registered) if you want to restrict access only to registered users and above.
Title: Re: IOS Downloads - Listing for more than one usergroup
Post by: CREATIVE Options on June 15, 2011, 23:22:33
Thank you Datahell,

I will apply them ASAP, and I will get back.
Title: Re: IOS Downloads - Listing for more than one usergroup
Post by: CREATIVE Options on June 16, 2011, 20:28:43
Hmm...

doesn't work.

Setting 1st group "Professionals"

Setting 2nd group "Students"

And return:

Access 1= "Students"
&
Access 2 = "Public Front end"

Any idea ?

[attachment deleted by admin]
Title: Re: IOS Downloads - Listing for more than one usergroup
Post by: datahell on June 16, 2011, 22:22:01
This is an exercise for you: find the problem by your self!  ;D
Title: Re: IOS Downloads - Listing for more than one usergroup
Post by: CREATIVE Options on June 16, 2011, 23:08:45
LOL
Title: Re: IOS Downloads - Listing for more than one usergroup
Post by: wbread on June 17, 2011, 00:40:29
datahell  ;D

can approach the issue is from the other side
make two listings with its own settings as a category on the forum
Title: Re: IOS Downloads - Listing for more than one usergroup
Post by: CREATIVE Options on June 17, 2011, 08:05:31
No because, It's customer's website who upload every month ~10 - 15 files for different access level.
Title: Re: IOS Downloads - Listing for more than one usergroup
Post by: datahell on July 11, 2011, 21:23:44
Done!
Title: Re: IOS Downloads - Listing for more than one usergroup
Post by: wbread on July 11, 2011, 22:12:52
This is an exercise for you: find the problem by your self!  ;D
Done!
just perfect
came as something past and found the answer under your nose, ;D?