Forum

Thread tagged as: Question, Members

Members App - Is this possible?

Hi,

I would like to use the Members App do do the following but I need to know if it is possible?

  1. Client registers via a form
  2. Administrator approves client and client is notified via email
  3. Administrator uploads documents specific to that client to download and client is notified via email
  4. Client downloads files and signs
  5. Client uploads signed files and administrator is notified via email
  6. Administrator downloads signed files

There will be multiple clients that will need to be created by the Administrator for which the above process would apply.

Thanks in advance,

Andy

Andy Knight

Andy Knight 1 points

  • 7 years ago
Drew McLellan

Drew McLellan 2638 points
Perch Support

  1. Client registers via a form

Yes

  1. Administrator approves client and client is notified via email

Yes

  1. Administrator uploads documents specific to that client to download and client is notified via email

Yes, but not automatically. You'd need to write some code.

  1. Client downloads files and signs

Yes.

  1. Client uploads signed files and administrator is notified via email

You could do that with the Forms app

  1. Administrator downloads signed files

And this.

Great, thanks Drew....

Hi Drew,

I have now mostly implemented a similar version of this but can see a way for individual logged in members to see a list of their 'own' files.

How would I go about setting up the ability for an administrator to upload documents specific to a member? Or can I in some way only display assets to a specific member for example?

Thanks, Andy

Drew McLellan

Drew McLellan 2638 points
Perch Support

You'd need to do it by tag. Give each unique set a tag and also apply that same tag to the member. When displaying the list, check that the two tags match.

Hi Drew,

Thanks. How would I check that the tags match?

Andy

Drew McLellan

Drew McLellan 2638 points
Perch Support

Either by filtering the region based on the tag (only returning matches) or using a <perch:if> in the template, depending on your needs.

Hi Drew,

Sorry, this just isn't clicking in my head...

This is what I have on my page:

<?php
                if (perch_member_logged_in()) {
            ?>  

                <div class="row">
                    <div class="col-sm-6">
                        <h3>User details:</h3>
                        <h2><?php echo perch_member_get('first_name');?> <?php echo perch_member_get('last_name');?></h2>
                        <h3><?php echo perch_member_get('email');?></h3>
                        <a href="logout.php" class="btn btn-default">Log out</a>
                    </div>
                    <div class="col-sm-6">

                        <?php
                            perch_content_create('Downloads', array(
                                'template'   => 'downloads.html',
                                'sort' => 'date',
                                'sort-order' => 'ASC'
                            ));
                        ?>

                        <?php
                        perch_content_custom('Downloads', array(
                                'template'=>'downloads.html'
                        )); 
                    ?>

                    </div>
                </div>

            <?php
                } else {
                    perch_members_login_form(); 
                }
            ?>

How can I filter the downloads based on who is logged in? I can add tags to members via the admin area but how do I add tags to the downloads?

Here is the code for the downloads template:

<perch:repeater id="downloads" label="Downloads">

    <a href="<perch:content id="download" type="file" label="Download" order="1" />"><perch:content type="text" id="desc" label="Title" order="1" required="true" title="true" /></a>

</perch:repeater>

Thanks Drew.

Drew McLellan

Drew McLellan 2638 points
Perch Support

I can add tags to members via the admin area but how do I add tags to the downloads?

You just need to add a field in the template for them:

<perch:repeater id="downloads" label="Downloads">
    <perch:content id="tag" type="text" label="Member tag" suppress="true" />

    <perch:member has-tag="{tag}">
    <a href="<perch:content id="download" type="file" label="Download" order="1" />"><perch:content type="text" id="desc" label="Title" order="1" required="true" title="true" /></a>
    </perch:member>

</perch:repeater>

Hi Drew,

I have updated the template to match the above but the downloads seem to display regardless of the members tag.

i.e. I have two members each with different tags but both can see any file I upload to the region even with different tags in place.

Any ideas?

Thanks again, Andy

Drew McLellan

Drew McLellan 2638 points
Perch Support

Can you show me the debug output?

Sure:

Debug Message
SELECT u.*, r.* FROM perch2_users u, perch2_user_roles r WHERE u.roleID=r.roleID AND u.userEnabled=1 AND u.userID=1 AND u.userHash='506479de8b29b24ee0f75d85eb859bfc' LIMIT 1
UPDATE perch2_users SET userHash='4d98bb2c7494b28d90c69d947136a1b8' WHERE userID=1
SELECT p.privKey FROM perch2_user_privileges p
SELECT * FROM (SELECT DISTINCT settingID, settingValue FROM perch2_settings WHERE userID=1 OR userID=0 ORDER BY userID DESC) AS settings GROUP BY settingID
SELECT * FROM perch2_content_regions WHERE regionID=5 LIMIT 1
SELECT * FROM perch2_pages WHERE pageID='2' LIMIT 1
SELECT * FROM perch2_content_items WHERE regionID=5 AND itemRev=36 ORDER BY itemOrder ASC
SELECT * FROM perch2_content_items WHERE regionID=5 AND itemRev=36 ORDER BY itemOrder ASC
Using template: /templates/content/downloads.html
Form not posted or did not validate
Queries: 9
Drew McLellan

Drew McLellan 2638 points
Perch Support

Is that from your page?

Its from the region, the following is from the page:


Debug Message SELECT u.*, r.* FROM perch2_users u, perch2_user_roles r WHERE u.roleID=r.roleID AND u.userEnabled=1 AND u.userID=1 AND u.userHash='962bac485d63bd5c71a8f02a1ac2eff2' LIMIT 1 UPDATE perch2_users SET userHash='743f23246ad0620558f29e3f8dbb43e5' WHERE userID=1 SELECT p.privKey FROM perch2_user_privileges p SELECT * FROM (SELECT DISTINCT settingID, settingValue FROM perch2_settings WHERE userID=1 OR userID=0 ORDER BY userID DESC) AS settings GROUP BY settingID SELECT * FROM perch2_pages WHERE pageID=2 LIMIT 1 SELECT * FROM perch2_content_regions WHERE pageID=2 AND regionPage!='*' ORDER BY regionOrder ASC SELECT COUNT(*) FROM perch2_content_items WHERE itemJSON!='' AND regionID=5 AND itemRev=36 Queries: 8

So I added

define('PERCH_DEBUG', true);

to the config file and then logged in to admin, navigated to Pages > Members to get this output.

Drew McLellan

Drew McLellan 2638 points
Perch Support

I need it from the page on your website - not within Perch.

Sorry Drew,


Debug Message SELECT * FROM perch2_pages WHERE pagePath='/members/index.php' LIMIT 1 SELECT DISTINCT settingID, settingValue FROM perch2_settings WHERE userID=0 SELECT * FROM perch2_members WHERE memberAuthType='native' AND memberEmail='test@test.com' AND memberStatus='active' AND (memberExpires IS NULL OR memberExpires>'2014-12-30 15:58:20') LIMIT 1 Password is ok. SELECT * FROM perch2_members WHERE memberAuthType='native' AND memberAuthID='2' LIMIT 1 log them in SELECT t.tag FROM perch2_members_tags t, perch2_members_member_tags mt WHERE t.tagID=mt.tagID AND mt.memberID='2' AND (mt.tagExpires IS NULL OR mt.tagExpires>'2014-12-30 15:58:00') INSERT INTO perch2_members_sessions(sessionID,sessionExpires,sessionHttpFootprint,memberID,sessionData) VALUES('890d778879bf624121473979d984b446330fa7b4','2015-01-04 15:58:20','cd20cbb671f1fc73c65abcdf3ddda185545866b3','2','a:11:{s:10:\"first_name\";s:4:\"Test\";s:9:\"last_name\";s:4:\"User\";s:8:\"memberID\";s:1:\"2\";s:14:\"memberAuthType\";s:6:\"native\";s:12:\"memberAuthID\";s:1:\"2\";s:11:\"memberEmail\";s:13:\"test@test.com\";s:12:\"memberStatus\";s:6:\"active\";s:13:\"memberCreated\";s:19:\"2014-12-30 00:00:00\";s:13:\"memberExpires\";N;s:4:\"tags\";b:0;s:5:\"token\";s:40:\"96f155e928315e119c1bcbe059aae371636dcdfa\";}') DELETE FROM perch2_members_sessions WHERE sessionExpires < '2014-12-30 15:58:20' SELECT * FROM perch2_members_sessions WHERE sessionID='890d778879bf624121473979d984b446330fa7b4' AND sessionHttpFootprint='cd20cbb671f1fc73c65abcdf3ddda185545866b3' AND sessionExpires>'2014-12-30 15:58:20' LIMIT 1 User is logged in Array ( [all] => login ) SELECT regionKey, regionHTML FROM perch2_content_regions WHERE regionPage='/members/index.php' OR regionPage='*' ORDER BY regionPage DESC

and here is a member with a tag

Debug Message
SELECT * FROM perch2_pages WHERE pagePath='/members/index.php' LIMIT 1
SELECT DISTINCT settingID, settingValue FROM perch2_settings WHERE userID=0
SELECT * FROM perch2_members WHERE memberAuthType='native' AND memberEmail='andy@rifledesign.co.uk' AND memberStatus='active' AND (memberExpires IS NULL OR memberExpires>'2014-12-30 16:05:23') LIMIT 1
Password is ok.
SELECT * FROM perch2_members WHERE memberAuthType='native' AND memberAuthID='1' LIMIT 1
log them in
SELECT t.tag FROM perch2_members_tags t, perch2_members_member_tags mt WHERE t.tagID=mt.tagID AND mt.memberID='1' AND (mt.tagExpires IS NULL OR mt.tagExpires>'2014-12-30 16:05:00')
INSERT INTO perch2_members_sessions(sessionID,sessionExpires,sessionHttpFootprint,memberID,sessionData) VALUES('59c99a2c7dd29b208c3a52940cefa9e19f780252','2015-01-04 16:05:23','cd20cbb671f1fc73c65abcdf3ddda185545866b3','1','a:11:{s:10:\"first_name\";s:4:\"Andy\";s:9:\"last_name\";s:6:\"Knight\";s:8:\"memberID\";s:1:\"1\";s:14:\"memberAuthType\";s:6:\"native\";s:12:\"memberAuthID\";s:1:\"1\";s:11:\"memberEmail\";s:22:\"andy@rifledesign.co.uk\";s:12:\"memberStatus\";s:6:\"active\";s:13:\"memberCreated\";s:19:\"2014-12-22 00:00:00\";s:13:\"memberExpires\";N;s:4:\"tags\";a:1:{i:0;s:3:\"bbb\";}s:5:\"token\";s:40:\"ca3a9f2edf8f19d6427251ac189f4818b3532239\";}')
DELETE FROM perch2_members_sessions WHERE sessionExpires < '2014-12-30 16:05:23'
SELECT * FROM perch2_members_sessions WHERE sessionID='59c99a2c7dd29b208c3a52940cefa9e19f780252' AND sessionHttpFootprint='cd20cbb671f1fc73c65abcdf3ddda185545866b3' AND sessionExpires>'2014-12-30 16:05:23' LIMIT 1
User is logged in
Array
(
    [all] => login
)
SELECT regionKey, regionHTML FROM perch2_content_regions WHERE regionPage='/members/index.php' OR regionPage='*' ORDER BY regionPage DESC
Drew McLellan

Drew McLellan 2638 points
Perch Support

Ok, thanks.

Do the links always show, or never show?

Hi Drew,

Happy New Year!

In answer to your question, the links always show.

Thanks.

Drew McLellan

Drew McLellan 2638 points
Perch Support

If you view source on the page, do you get any template tags left in the output?

Hi Drew, seems like I do. See below:

<div class="col-sm-6"> <a href="4630">Test text document</a>
  </perch:member>
  <a href="86572">Test JPEG</a>
  </perch:member>
</div>

Any idea why there are </perch:member> in the output?

Drew McLellan

Drew McLellan 2638 points
Perch Support

No, but that's a clear indication that something's gone wrong. I'm looking into it.