Wiki source for MassaclsAction


Show raw source

=====Massacls Action=====

>>==See also:==
Parent Action: PageAdminAction
Documentation: MassaclsActionInfo.>>

This is the development page for the Massacls action.::c::

The Masaacls Action is a part of the PageAdminAction.

====User view====
After sending the data from the PageAdminAction, a form was created to input the needed acl data.
If a field left empty, the value did'nt change

""
<table cellspacing="0" cellpadding="0" border="0">
<tbody>
<tr><td valign="top" style="padding-right: 20px;">
<strong>Read ACL:</strong>
<br>
<textarea cols="20" rows="4" name="read_acl"></textarea>
</td><td></td>
<td valign="top" style="padding-right: 20px;">
<strong>Write ACL:</strong>
<br>
<textarea cols="20" rows="4" name="write_acl"></textarea>
</td><td></td>
<td valign="top" style="padding-right: 20px;">
<strong>Comments ACL:</strong>
<br>
<textarea cols="20" rows="4" name="comment_acl"></textarea>
</td>
</tr>
<tr>
<td colspan="3">
<br>
<input type="submit" accesskey="s" style="width: 120px;" value="Store ACLs">
<input type="button" style="width: 120px;" onclick="history.back();" value="Cancel">
</td>
</tr>
</tbody>
</table>
""

====The Protocoll====

""
<p>write ACL updated for HeinrichHeine </p>
<p>write ACL updated for KurtTocholsky</p>

<p><a href="http://localhost/wikka/wikka.php?wakka=PageAdministration">
Seiten - Administration</a></p>
""

====The Code====
After sending this form to Massacls the changes where made and a small protocol is shown:

**The sourcecode is the first draft and in an alpha-status. **
**It works, not more, documentation and some changes for translation etc. will following.**

%%(php;1)
<?php
if (isset($_GET['action'])) //we have to show the input form
{
//We show only a form without any data, so no security checks are possible.

//First of all, put all the id_xxx=on into string for easier use
$ids = '';
reset($_GET);
while(list($key,$val)=each($_GET))
if ($val == 'on' && substr($key,0,3) == 'id_')
$ids .= substr($key,3).'|';

//Perhaps it is usefull to use the same as in acls.php
echo $this->FormOpen()
?>
<table border="0" cellspacing="0" cellpadding="0">
<tr>
<td valign="top" style="padding-right: 20px">
<strong>Read ACL:</strong><br />
<textarea name="read_acl" rows="4" cols="20"></textarea>
<td>
<td valign="top" style="padding-right: 20px">
<strong>Write ACL:</strong><br />
<textarea name="write_acl" rows="4" cols="20"></textarea>
<td>
<td valign="top" style="padding-right: 20px">
<strong>Comments ACL:</strong><br />
<textarea name="comment_acl" rows="4" cols="20"></textarea>
<td>
</tr>
<tr>
<td colspan="3">
<br />
<input type="hidden" name="action" value="massacls"/>
<input type="hidden" name="ids" value="<?php echo $ids;?>"/>
<input type="submit" value="Store ACLs" style="width: 120px" accesskey="s" />
<input type="button" value="Cancel" onclick="history.back();" style="width: 120px" />
</td>
</tr>
<tr>
<td colspan="3">
<br /><h4>Syntax:</h4><br />
* = Everyone<br />
+ = Registered users<br />
Or enter individual user WikiNames, one per line<br />
--------------------------------------<br />
Note: Any of these items can be negated with a !<br />
!* = No one<br />
!+ = Anonymous users<br />
!JohnDoe = JohnDoe will be denied access.<br />
<br />
<em>Be aware that the ACLs are tested in the order specified.</em>
<br/ >So be sure to specify * on a separate line
<br /><b>after</b> negating any users--not before.
<br/ >Otherwise, the * everyone condition will always give access
<br/ >before the list of users that should not have access is tested.
<td>
</tr>
</table>
<?php
print($this->FormClose());

}
else if (isset($_POST['action']) && $this->IsAdmin($this->GetUser())) // we have to do the acl change action
{
function mySaveACL($page, $tag, $acl, $acls)
{
$posted = $_POST[$acl.'_acl'];
//$default = $page->GetConfigValue('default_'.$acl.'_acl');

if (trim($posted != ''))
if ($posted != $acls[$acl.'_acl'])
{
//if ($posted == $default)
// $posted = '';
$page->SaveACL($tag, $acl, $page->TrimACLs($posted));
print ('<p>'.$acl.' ACL updated for <a href="'.$page->Href('',$tag, '').'">'.$tag.'</a></p>');
}
}

foreach (explode('|',$_POST['ids']) as $id)
if ($id != '')
{
$page = $this->LoadPageById($id);
$tag = $page['tag'];

$acls = $this->LoadAllACLs($tag,0);
mySaveACL($this, $tag, 'read', $acls);
mySaveACL($this, $tag, 'write', $acls);
mySaveACL($this, $tag, 'comment', $acls);
}
}
else
print ('<p>What are you doing here?</a></p>');

print ('<p><a href="'.$this->Href('','','').'">Seiten - Administration</a></p>');
?>
%%

Feel free to make it secure and better!

----
CategoryDevelopmentActions
Valid XHTML :: Valid CSS: :: Powered by WikkaWiki