Page 1 of 1
[solved] login functionality + custom content
Posted: Wed May 07, 2008 9:35 pm
by rattyraiz
Sorry if this has been addressed but I have watched vids on the wiki and searched forum.
Here is my issue or need:
-I have about ~2000 already created u/p's that I need to upload (Already setup FrontEndUsers and see how to batch ul - no problem)
--With that said there are about 20 diff pdf docs that I have uploaded or plan to ul to the site
-Each one of these logins needs its own specific combination to download of the documents (assume all 2k are diff) on the front end
eg user1 logs in and sees that he has been marked to see (or simply has perms) to dl pdf's 12&3 and so forth
I understand that this will require a ton of manual work but I was curious as to the best approach for this. Essentially I am setting this up for a client and they are ok with a process to go through each account, I am just trying to figure the best combo of modules etc to get some steps together for them. Any feedback is greatly appreciated!!
ratty
Re: login functionality + custom content
Posted: Wed May 07, 2008 9:43 pm
by calguy1000
So let me see if I can understand you correctly.
Each of the login accounts will be able to access a different set of documents.
i.e:
User1 has access to document 1, 3, and 5
User2 has access to document 1, 5, 6, and 7
User3 has access to document 2, and 6
if this is the case... and there's no limit to the number of documents that users may have access to, it's going to be difficult.
Well, one way to do it is to create a text field or text area property in FEU, and assign that to the user group
and then for each user, supply a list of the files that they have access to.
ie: 1, 3, 5 (if all of your pdfs have a common naming scheme) or doc1.pdf, doc3.pdf, doc5.pdf
but again, it's pretty ugly.
Re: login functionality + custom content
Posted: Wed May 07, 2008 9:51 pm
by rattyraiz
Thanks for the quick response. I guess I am confused by what you mean by "limit" below. There will be about 20 documents but each of the 2k logins may have a different combination of those documents they can grab...so I think you follow me correctly.
Again I do not mind giving them a manual way to edit each user perms I am just a bit confused on the best approach on how to do this in cmsms and presenting it on the end side to users. With that said is your response below still fit this? Thanks!
Re: login functionality + custom content
Posted: Wed May 07, 2008 9:57 pm
by calguy1000
yes, if you created a property called 'allowd_docs' of type textarea in FEU, then associated that property with the appropriate FEU group(s). then you could edit that property for each user and put in content like:
doc1.pdf,doc3.pdf,doc4.pdf
Then, in the appropriate page you could use some smarty magic to explode that data into an array (not quite sure on the smarty magic yet, but wouldn't be hard to find)....
then process a foreach with the array created above and build links to the appropriate documents.
i.e (something like this):
Code: Select all
{$ccuser->property('allowed_docs','allowed_docs'}
{assign var='docs' value=','|explode:$allowed_docs}
{foreach from=$docs item='onedoc'}
<a href="uploads/docs/{$onedoc}">{$onedoc}</a>
{/foreach}
Re: login functionality + custom content
Posted: Wed May 07, 2008 10:04 pm
by rattyraiz
sweet, thanks much man!
Re: login functionality + custom content
Posted: Wed May 07, 2008 10:40 pm
by rattyraiz
One quick follow-up and I am done...
What is the point of the explode array here? Would it be easier to simply do an if else statement checking to see if the text field contains?
eg if allowed_docs contains doc1 link1 else etc? Not sure how to write that really but you get the point.
Re: login functionality + custom content
Posted: Thu May 08, 2008 1:43 am
by calguy1000
well, the explode would split up the text field into an array of values that you could just cycle through.
Doing a test on each case to see if the user is authorized to view that file would be
a) ugly, a whole lot of if/else stuff
b) expensive, text searching the same data numerous times is not the most efficient way of doing things
Re: login functionality + custom content
Posted: Thu May 08, 2008 4:34 am
by rattyraiz
gotcha.
well all i could find on smarty explode was
http://www.phpinsider.com/smarty-forum/ ... be76a791c6
which is exactly how you have it...not sure what I am doing wrong but all its returning is the text from the property box, so I am missing something here - obvious I am sure.
Code: Select all
{if $ccuser->loggedin()}
{$ccuser->property('allowed_docs','allowed_docs')}
{assign var='docs' value=','|explode:$allowed_docs}
{foreach from=$docs item='onedoc'}
<a href="uploads/docs/{$onedoc}">{$onedoc}</a>
{/foreach}
{/if}
so I am guessing the array is not even being created...
Re: [solved] login functionality + custom content
Posted: Sat May 10, 2008 1:22 am
by rattyraiz
In case someone else runs into this here was the explode code that worked
Code: Select all
{if $ccuser->loggedin()}
{assign var=docs value=','|explode:$ccuser->property('allowed_docs')}
{foreach from=$docs item='onedoc'}
<a href="uploads/docs/{$onedoc}">{$onedoc}</a>
{/foreach}
{/if}
Re: [solved] login functionality + custom content
Posted: Mon May 12, 2008 6:08 pm
by Pierre M.
Thank you for sharing this.
Note @all : the number of users is not strictly limited but the maximum number of documents in an autorized combination set is limited because the list of the documents's names in the set must fit in a textfield/area.
Pierre M.