Форумы / Cotonti / Extensions / Pages for guests - new plugin

Allow guests to submit pages, protected with CAPTCHA

foxhound
#1 21.01.2012 15:43

I am trying to make my first "own" plugin, I am using the com4guest plugin as a base (dont worry, when released I will credit them for all the original work).
I have no idea wether this will even work, I am simply trying.

Right now I am stuck, I need to give guests write acces to pages (so they can actually submit a page) and I read to be able to do that I need to change the database value. I have been looking at the database for a while but have no idea what value it is and where it is.
So, if anyone here knows how to change this value in the database and can share the info with me that would be appreciated.

When all works guests should be able to submit pages and the CAPTCHA will prevent spammerts to misuse this feature. If a dev reads this and already knows this will never work feel free to tell me to not futher waist my time :)

 

I am making this plugin since a new site we have has registration disabled (except for staff), however we allow guests to comment on news and pages and it would be nice if guests could also submit pages.

 

PS: this is for Genoa!

<img src="http://www.armaholic.com/datas/thumbs/green-sea-battalion-uniforms-version-03-preview_4.jpg" alt="green-sea-battalion-uniforms-version-03-" />
Отредактировано: foxhound (21.01.2012 16:10, 12 лет назад)
fade2k
#2 21.01.2012 20:29

Hmm, I'd look at pages and comments for guests for relevent db information + permission info. It might be wise to record names / emails / websites with page submissions too. Although, I don't have a use for something like this - I don't understand why one can't just change permissions to allow guests to submit pages in general (or for page comments for that matter!).

- Be Kind, Please Rewind -
ez
#3 21.01.2012 21:18

@foxhound:
The rights for pages are actually all in the sed_auth table..

I quickly looked:
`sed_auth` (`auth_id`, `auth_groupid`, `auth_code`, `auth_option`, `auth_rights`, `auth_rights_lock`, `auth_setbyuserid`)
 

You probably need to unlock the group by changing the auth_rights_lock value...
And then you can probably change the rights via the admin panel....
The default grp_id for guests is '1'...

So try to change that auth_rights_lock for 1 article category and see if your red cross for the 'W' part dissapear in admin panel.

ow yeah its binary so calculate the new value by using this:
    $mn['R'] = 1;
    $mn['W'] = 2;
    $mn['1'] = 4;
    $mn['2'] = 8;
    $mn['3'] = 16;
    $mn['4'] = 32;
    $mn['5'] = 64;
    $mn['A'] = 128;

you prob need to clear bit 'W' so substract 2 from the value in the database !

By the way,,, i havent looked where the default locking for pages come from... yet...
 

Small update on the locking.... i found it..
It is HARDCODED inside a function to make new pagecategories locked...

its in functions.admin.php look for function called: sed_structure_newcat

look at this bit:

               if ($v['id']==1)
                {
                    $ins_auth = 5;
                    $ins_lock = 250;
                }

That is your default locking (red crosses thing.... in admin panel) change $ins_lock value (prob to 248) and new cats can be unlocked for guests to WRITE ub.

Good luck !

 

p.s. I couldnt believe that this is hardcoded.... not very friendly
 

==- I say: Keep it EZ -==
Отредактировано: ez (21.01.2012 21:36, 12 лет назад)
foxhound
#4 30.01.2012 21:23

Thanks for the info EZ, I had some time to further dig into this and thanks to your help I did manage to get a lot further now.
Guests can now submit pages without a problem. I found the correct sql code to use for that now.

But, I cant get my CAPTCHA to work, the page will be submitted even though the code has not even been entered. This is what I have in my page.add.tpl:

		<tr>
			<td colspan="3" class="valid">
			<!-- IF {PHP.usr_can_publish} -->
			<input name="rpublish" type="submit" class="submit" value="{PHP.L.Publish}" onclick="this.value='OK';return true" /><input type="submit" value="{PHP.L.Putinvalidationqueue}" />
			<!-- ELSE -->
			{PHP.L.User}: {PAGE_OWNER} {PAGE_VERIFY_IMG}: {PAGE_VERIFY} <input type="submit" value="{PHP.L.Submit}" />
			<!-- ENDIF -->
			</td>
		</tr>

The whole verify thing is completely ignored. I guess it has to do with the fact that the "submit" is folowed no matter a valid CAPTCHA code or not.
Can anyone tell me how I can change this?

In the original comments4guest plugin the "submit" is part of a "form" in which the verify tags were placed, but, with page.add there is no form. Just the submit button.

Any thoughts?
 

<img src="http://www.armaholic.com/datas/thumbs/green-sea-battalion-uniforms-version-03-preview_4.jpg" alt="green-sea-battalion-uniforms-version-03-" />
ez
#5 31.01.2012 07:39

Your answer lies in the captcha code... did you installed captcha manager and the right captcha ?.

Also maybe captcha was not used for pages ???

So you should check the hooks used with captcha on the page.add stuff

==- I say: Keep it EZ -==
foxhound
#6 31.01.2012 21:12

I am using math captha on that site and the captcha manager is installed even though I am not sure its required sine I use only 1 captcha.

[quote]Also maybe captcha was not used for pages ???[/quote]

Originally no, thats what I am making :)
Unless you mean something else.

[quote]So you should check the hooks used with captcha on the page.add stuff[/quote]

I have no idea what I am doing with those hooks, right now I have this (and tried many different "names").

In page4guests.validate.php:

/* ====================
[BEGIN_SED_EXTPLUGIN]
Code=pages4guests
Part=validation
File=pages4guests.validate
Hooks=page.add
Tags=
Order=10
[END_SED_EXTPLUGIN]

==================== */

page4guests.tags.php

/* ====================
[BEGIN_SED_EXTPLUGIN]
Code=pages4guests
Part=page.tags
File=pages4guests.tags
Hooks=page.add.tags
Tags=page.add.tpl: {PAGE_OWNER}, {PAGE_VERIFY_IMG}, {PAGE_VERIFY}
Order=10
[END_SED_EXTPLUGIN]
==================== */


Maybe I should change Part=validation in page4guests.validate.php to Part=submit? But again, I have no idea what I am doing :)
<img src="http://www.armaholic.com/datas/thumbs/green-sea-battalion-uniforms-version-03-preview_4.jpg" alt="green-sea-battalion-uniforms-version-03-" />
ez
#7 31.01.2012 21:20

I should really have to dive into pages combined with captcha... but i cant :(  I have very little time...

Sorry, I hope other devs can help you with this

==- I say: Keep it EZ -==
foxhound
#8 02.02.2012 19:04

Well, thanks anyway for the help EZ, I appreciate it. No plugin for this than. I guess I just enable page submission for guests by default and the admins can sort the spam.

<img src="http://www.armaholic.com/datas/thumbs/green-sea-battalion-uniforms-version-03-preview_4.jpg" alt="green-sea-battalion-uniforms-version-03-" />