Massacls Action


See also:
Parent Action: PageAdminAction
Documentation: MassaclsActionInfo.


This is the development page for the Massacls action.
 


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

Read ACL:
Write ACL:
Comments ACL:



The Protocoll


write ACL updated for HeinrichHeine

write ACL updated for KurtTocholsky

Seiten - Administration



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.

  1. <?php
  2.   if (isset($_GET['action'])) //we have to show the input form
  3.     {
  4.       //We show only a form without any data, so no security checks are possible.
  5.      
  6.       //First of all, put all the id_xxx=on into string for easier use
  7.       $ids = '';
  8.       reset($_GET);
  9.       while(list($key,$val)=each($_GET))
  10.         if ($val == 'on' && substr($key,0,3) == 'id_')
  11.           $ids .=  substr($key,3).'|';
  12.      
  13.       //Perhaps it is usefull to use the same as in acls.php
  14.         echo $this->FormOpen()
  15.         ?>
  16.         <table border="0" cellspacing="0" cellpadding="0">
  17.             <tr>
  18.                 <td valign="top" style="padding-right: 20px">
  19.                     <strong>Read ACL:</strong><br />
  20.                     <textarea name="read_acl" rows="4" cols="20"></textarea>
  21.                 <td>
  22.                 <td valign="top" style="padding-right: 20px">
  23.                     <strong>Write ACL:</strong><br />
  24.                     <textarea name="write_acl" rows="4" cols="20"></textarea>
  25.                 <td>
  26.                 <td valign="top" style="padding-right: 20px">
  27.                     <strong>Comments ACL:</strong><br />
  28.                     <textarea name="comment_acl" rows="4" cols="20"></textarea>
  29.                 <td>
  30.             </tr>
  31.             <tr>
  32.                 <td colspan="3">
  33.                     <br />
  34.                     <input type="hidden" name="action" value="massacls"/>
  35.                     <input type="hidden" name="ids" value="<?php echo $ids;?>"/>
  36.                     <input type="submit" value="Store ACLs" style="width: 120px" accesskey="s" />
  37.                     <input type="button" value="Cancel" onclick="history.back();" style="width: 120px" />
  38.                 </td>
  39.             </tr>
  40.             <tr>
  41.                 <td colspan="3">
  42.                 <br /><h4>Syntax:</h4><br />
  43.                     * = Everyone<br />
  44.                     + = Registered users<br />
  45.                     Or enter individual user WikiNames, one per line<br />
  46.                     --------------------------------------<br />
  47.                     Note: Any of these items can be negated with a !<br />
  48.                     !* = No one<br />
  49.                     !+ = Anonymous users<br />
  50.                     !JohnDoe = JohnDoe will be denied access.<br />
  51.                     <br />
  52.                     <em>Be aware that the ACLs are tested in the order specified.</em>
  53.                     <br/ >So be sure to specify * on a separate line
  54.                     <br /><b>after</b> negating any users--not before.
  55.                     <br/ >Otherwise, the * everyone condition will always give access
  56.                     <br/ >before the list of users that should not have access is tested.
  57.                 <td>
  58.             </tr>
  59.         </table>
  60.         <?php
  61.         print($this->FormClose());
  62.      
  63.     }
  64.   else if (isset($_POST['action']) && $this->IsAdmin($this->GetUser())) // we have to do the acl change action
  65.     {
  66.       function mySaveACL($page, $tag, $acl, $acls)
  67.         {
  68.           $posted = $_POST[$acl.'_acl'];
  69.           //$default = $page->GetConfigValue('default_'.$acl.'_acl');
  70.          
  71.           if (trim($posted != ''))
  72.             if ($posted != $acls[$acl.'_acl'])
  73.               {
  74.                 //if ($posted == $default)
  75.                 //  $posted = '';
  76.                 $page->SaveACL($tag, $acl, $page->TrimACLs($posted));
  77.                 print ('<p>'.$acl.' ACL updated for <a href="'.$page->Href('',$tag, '').'">'.$tag.'</a></p>');
  78.               }
  79.         }
  80.        
  81.       foreach (explode('|',$_POST['ids']) as $id)
  82.         if ($id != '')
  83.           {
  84.             $page = $this->LoadPageById($id);
  85.             $tag = $page['tag'];
  86.          
  87.             $acls = $this->LoadAllACLs($tag,0);
  88.             mySaveACL($this, $tag, 'read', $acls);
  89.             mySaveACL($this, $tag, 'write', $acls);
  90.             mySaveACL($this, $tag, 'comment', $acls);
  91.           }
  92.     }
  93.   else
  94.     print ('<p>What are you doing here?</a></p>');
  95.  
  96.  print ('<p><a href="'.$this->Href('','','').'">Seiten - Administration</a></p>');
  97. ?>


Feel free to make it secure and better!


CategoryDevelopmentActions
There are no comments on this page.
Valid XHTML :: Valid CSS: :: Powered by WikkaWiki