Best way to add folder only accessible to admin

Post

Posted
Rating:
#6775 (In Topic #1757)
Avatar
Standard member
starfish is in the usergroup ‘Fan in action’
Hi,

What is the best way to add a folder of pages, that can only be accessed by the admin?  The folder contains pages to approve, delete, and/or edit submissions made to the database by site members.  Therefore, only the admin can have access.

Where should the folder be placed?  How should this be done?

Thanks so much!
Online now: No Back to the top

Post

Posted
Rating:
#6776
Avatar
Site director
Chris Graham is in the usergroup ‘Administrators’
Permissions aren't going to be able to handle that through Comcode pages. In v10 there's no way to express the idea that you can submit pages to one specific place only (in v11 there will be though).

You could add a catalogue with just title and body fields and have people submit into the catalogue. I think you could deny view access to every usergroup, but people would be able to edit their own submissions if you set the permissions like that, and they'd see it come up in the edit list.
The admin would then need to copy and paste into a real page to approve it though.

i.e. This is side-stepping the problem I mentioned by making an entirely different content type that people submit to, and you're configuring permissions against that content type.


Become a fan of Composr on Facebook or add me as a friend. Add me on on Twitter. Follow me on Minds (where I am most active). Support me on Patreon

Was I helpful?
  • If not, please let us know how we can do better (please try and propose any bigger ideas in such a way that they are fundable and scalable).
  • If so, please let others know about Composr whenever you see the opportunity or support me on Patreon.
  • If my reply is too Vulcan or expressed too much in business-strategy terms, and not particularly personal, I apologise. As a company & project maintainer, time is very limited to me, so usually when I write a reply I try and make it generic advice to all readers. I'm also naturally a joined-up thinker, so I always express my thoughts in combined business and technical terms. I recognise not everyone likes that, don't let my Vulcan-thinking stop you enjoying Composr on fun personal projects.
  • If my response can inspire a community tutorial, that's a great way of giving back to the project as a user.
Online now: No Back to the top

Post

Posted
Rating:
Item has a rating of 5 (Liked by Chris Graham)
#6777
Avatar
Standard member
starfish is in the usergroup ‘Fan in action’
Thanks for commenting, Chris!

I wanted a "testimonials" box on my main page.  I searched and couldn't find anything I liked, so I decided to create my own.

I posted a form for members in site---pages---minimodules_custom.  The form is automatically added to "Pages" in their site.

I added a table to my database.  I then created a php page (inside composr/) to fetch the data from the table.

Next, I created an iframe on my main page to format that php page into a testimonials box.

All works well.  The last thing I wanted to do is make a page that I can access from my admin panel, so that I can edit or delete the submitted posts.  I have a field in the table called "approve".  I want to change that number if I approve the submission, or delete the row if it is inappropriate.  Now I can do that by going directly into the database, but it is much cleaner to have access right in my admin panel.  Obviously, I don't want anyone else to edit the database, so only I can have the permission to access.

I searched online and found an example.  That example has six pages in a folder (create, delete, error, index, read, update).

I wasn't sure how I should add folders and specify their permissions.
 
Online now: No Back to the top

Post

Posted
Rating:
#6778
Avatar
Site director
Chris Graham is in the usergroup ‘Administrators’
Oh I see. I totally misunderstood what you were asking.

One approach would be to just put them in adminzone/pages/minimodules_custom, possibly renaming them to include a prefix (to keep it tidier, admin_testimonials_create, admin_testimonials_delete, …), and adapting any internal linkages within the scripts to also use that prefix and to link as Composr page URLs rather than directly to the PHP files. That way it is fully running as Composr pages within the Admin Zone.

To actually do it with a folder, well it's possible, but you'd want to paste all the Composr bootstrapping code from adminzone/index.php to the start of each script, minus the last do_site line (as you want to run subsequent code in the files rather than continue to load an actual normal Composr page).


Become a fan of Composr on Facebook or add me as a friend. Add me on on Twitter. Follow me on Minds (where I am most active). Support me on Patreon

Was I helpful?
  • If not, please let us know how we can do better (please try and propose any bigger ideas in such a way that they are fundable and scalable).
  • If so, please let others know about Composr whenever you see the opportunity or support me on Patreon.
  • If my reply is too Vulcan or expressed too much in business-strategy terms, and not particularly personal, I apologise. As a company & project maintainer, time is very limited to me, so usually when I write a reply I try and make it generic advice to all readers. I'm also naturally a joined-up thinker, so I always express my thoughts in combined business and technical terms. I recognise not everyone likes that, don't let my Vulcan-thinking stop you enjoying Composr on fun personal projects.
  • If my response can inspire a community tutorial, that's a great way of giving back to the project as a user.
Online now: No Back to the top

Post

Posted
Rating:
#6809
Avatar
Standard member
starfish is in the usergroup ‘Fan in action’
Thanks so much Chris!  It has taken me this long to figure it out.  For anyone else reading this, here's what I found out:

I had to add the page to the security token list, as I got a message about security tokens.

The links inside a page that were php, were a big problem (as Chris suggested).  I had to figure out other ways to do things to keep everything on one page.  I had to get rid of the first program I was going to use.  I tried a few others, again the same problem.  I finally found a script that kept most things on one page.

I was trying to create a CRUD page that could work inside Composr.  

When deleting, I used:

header('Location: ' . $_SERVER['HTTP_REFERER']);
to keep things on one page.

When I got to the edit/update portion, I was stuck.  The original script used parameters added to a php link. That wasn't going to work, as I got messages saying that the page didn't exist.  This would be true for every member "id", as that was added to the url (in other words, there is no way to add one page).  I decided to change that portion of the script to use a "Modal" to edit.  Then the problem was, as soon as ajax was added to process the modal inputs ("Save" button), the "Edit" button outside the modal (that popped up the modal box) no longer worked. So now, I had to get rid of ajax (which I thought would keep me on one page).  I then made the modal inputs inside "form" tags, to process the edits. This sent me to a php page to update the database.  

I used this to return me to the original page with refresh:

$url = $_SERVER['HTTP_REFERER'];
echo '<span http-equiv="refresh" content="1;URL=' . $url . '">';

It is finally working.  There were so many "roadblocks" along the way.

Hope this helps someone else.   

Now all I have left to do is add the link to my admin panel.  Where is the best place and method to add:
/adminzone/index.php?page=admintestimonialsindex
Online now: No Back to the top

Post

Posted
Rating:
Item has a rating of 5 (Liked by Chris Graham)
#6823
Avatar
Standard member
starfish is in the usergroup ‘Fan in action’
Just saw that the page was automatically indexed under "Tools" in the admin panel.  Brilliant, Chris!  Everytime I think I have to do something, you have already taken care of it.  I can't tell you how many times this has happened.  You are always a few steps ahead!
Online now: No Back to the top
1 guest and 0 members have just viewed this.

Statistics

Users online:

ManojSree, Vaiva, Philip, MVLipwig, Paul D, Salman, amit.nigam, Adam

Forum statistics:
  • 1,262 topics, 5,794 posts, 6,967 members
  • Our newest member is josephgross123
Birthdays:
Back to Top