home *** CD-ROM | disk | FTP | other *** search
/ Chip 2004 April / CMCD0404.ISO / Software / Freeware / Programare / groupoffice-com-2.01 / controls / acl_control.inc next >
Text File  |  2004-03-08  |  6KB  |  147 lines

  1. <?php
  2. /*////////////////////////////////////////////////////////////////////////////////
  3.  
  4.  
  5.  
  6.  
  7. THIS CONTROL IS DEPRECATED PLEASE USE THE CLASS NAMED acl FROM classes/controls.class.inc
  8.  
  9.  
  10.  
  11.  
  12. ////////////////////////////////////////////////////////////////////////////////*/
  13.  
  14. //////////////////////////////////////////////////////////////////////////////////
  15. // Put this anywhere inside a form and set $acl_control_acl_id.                    //
  16. // The acl will automatically be updated after submission.                         //
  17. //////////////////////////////////////////////////////////////////////////////////
  18.  
  19. $acl_control_columns = isset($acl_control_columns) ? $acl_control_columns :3;
  20. $acl_control_acl_id = isset($acl_control_acl_id) ? $acl_control_acl_id : 0;
  21. $acl_control_set_acl = isset($acl_control_set_acl) ? $acl_control_set_acl : false;
  22. $selected_groups_name = "selected_groups_".$acl_control_acl_id;
  23. $selected_users_name = "selected_users_".$acl_control_acl_id;
  24.  
  25. ${$selected_groups_name} = isset(${$selected_groups_name}) ? ${$selected_groups_name} : array();
  26. ${$selected_users_name} = isset(${$selected_users_name}) ? ${$selected_users_name} : array();
  27.  
  28. if ($acl_control_set_acl == 'true')
  29. {
  30.     $GO_SECURITY->clear_acl($acl_control_acl_id);
  31.     for ($i=0;$i<count(${$selected_groups_name});$i++)
  32.     {
  33.         $GO_SECURITY->add_group_to_acl(${$selected_groups_name}[$i],$acl_control_acl_id);
  34.     }
  35.  
  36.     for ($i=0;$i<count(${$selected_users_name});$i++)
  37.     {
  38.         $GO_SECURITY->add_user_to_acl(${$selected_users_name}[$i],$acl_control_acl_id);
  39.     }
  40. }
  41.  
  42. echo '<input type="hidden" name="acl_control_acl_id" value="'.$acl_control_acl_id.'" />';
  43. echo '<input type="hidden" name="acl_control_set_acl" value="true" />';
  44. ?>
  45.  
  46. <table border="0" cellpadding="0" cellspacing="0">
  47. <tr>
  48.        <td colspan="3"><b><?php echo $acl_control_auth_groups; ?><b></td>
  49. </tr>
  50.  
  51. <?php
  52. if (isset($acl_control_read_only) && $acl_control_read_only)
  53. {
  54.     $disabled = "disabled";
  55. }else
  56. {
  57.     $disabled = "";
  58. }
  59.  
  60. require_once($GO_CONFIG->class_path."groups.class.inc");
  61. $groups = new groups;
  62. $groups->get_authorised_groups($GO_SECURITY->user_id);
  63. $i=0;
  64. echo "<tr>\n";
  65. while ($groups->next_record())
  66. {
  67.     if ($i==$acl_control_columns)
  68.     {
  69.         echo "</tr>\n<tr>";
  70.         $i=0;
  71.     }
  72.  
  73.     if ((!$acl_control_set_acl && in_array($groups->f("id"), ${$selected_groups_name})) || ($acl_control_acl_id > 0 && $GO_SECURITY->group_in_acl($groups->f("id"),$acl_control_acl_id)))
  74.     {
  75.         echo "<td><table cellpadding=\"0\" cellspacing=\"0\" border=\"0\"><tr><td><input type=\"checkbox\" name=\"".$selected_groups_name."[]\" value=\"".$groups->f("id")."\" checked ".$disabled." /></td>";
  76.     }else
  77.     {
  78.         echo "<td><table cellpadding=\"0\" cellspacing=\"0\" border=\"0\"><tr><td><input type=\"checkbox\" name=\"".$selected_groups_name."[]\" value=\"".$groups->f("id")."\" ".$disabled." /></td>";
  79.     }
  80.     echo "<td><a class=\"normal\" href=\"javascript:popup('".$GO_CONFIG->control_url."group.php?group_id=".$groups->f("id")."&name=".urlencode($groups->f("name"))."','350','350')\" title=\"".$strShowGroup."\">".$groups->f("name")."</a></td></tr></table></td>\n";
  81.     $i++;
  82. }
  83. echo "</tr>\n";
  84.  
  85. echo "<tr><td colspan=\"3\"><br /><b>".$acl_control_auth_users."</b></td></tr>";
  86. echo "<tr>\n";
  87. if (!isset($acl_control_hide_self) || !$acl_control_hide_self)
  88. {
  89.     if (isset($acl_control_select_self) && $acl_control_select_self)
  90.     {
  91.         echo "<input type=\"hidden\" name=\"".$selected_users_name."[]\" value=\"".$GO_SECURITY->user_id."\" />";
  92.         echo "<td><table cellpadding=\"0\" cellspacing=\"0\" border=\"0\"><tr><td><input type=\"checkbox\" name=\"dummy\" value=\"".$GO_SECURITY->user_id."\" checked disabled /></td>";
  93.         echo "<td>".show_profile($GO_SECURITY->user_id,$_SESSION['GO_SESSION']['name'])."</td></tr></table></td>\n";
  94.     }else
  95.     {
  96.         if ((!$acl_control_set_acl && in_array($GO_SECURITY->user_id, ${$selected_users_name})) || ($acl_control_acl_id > 0 && $GO_SECURITY->user_in_acl($GO_SECURITY->user_id,$acl_control_acl_id)))
  97.         {
  98.             echo "<td><table cellpadding=\"0\" cellspacing=\"0\" border=\"0\"><tr><td><input type=\"checkbox\" name=\"".$selected_users_name."[]\" value=\"".$GO_SECURITY->user_id."\" checked ".$disabled." /></td>";
  99.             echo "<td>".show_profile($GO_SECURITY->user_id,$_SESSION['GO_SESSION']['name'])."</td></tr></table></td>\n";
  100.         }else
  101.         {
  102.             echo "<td><table cellpadding=\"0\" cellspacing=\"0\" border=\"0\"><tr><td><input type=\"checkbox\" name=\"".$selected_users_name."[]\" value=\"".$GO_SECURITY->user_id."\" ".$disabled." /></td>";
  103.             echo "<td>".show_profile($GO_SECURITY->user_id,$_SESSION['GO_SESSION']['name'])."</td></tr></table></td>\n";
  104.  
  105.         }
  106.     }
  107.         $i=1;
  108. }else
  109. {
  110.         $i=0;
  111. }
  112. require_once($GO_CONFIG->class_path."users.class.inc");
  113. $users = new users();
  114. $count = $users->get_users('name', 'ASC');
  115.  
  116. while ($users->next_record())
  117. {
  118.     if ($i==$acl_control_columns)
  119.     {
  120.             echo "</tr><tr>\n";
  121.             $i=0;
  122.     }
  123.  
  124.     if (!$GO_SECURITY->has_permission($GO_SECURITY->user_id, $users->f('acl_id')) || $users->f("id") == $GO_SECURITY->user_id)
  125.     {
  126.         $count--;
  127.     }else
  128.     {
  129.         if ((!$acl_control_set_acl && in_array($users->f("id"), ${$selected_users_name})) || ($acl_control_acl_id > 0 && $GO_SECURITY->user_in_acl($users->f("id"),$acl_control_acl_id)))
  130.         {
  131.             echo "<td><table cellpadding=\"0\" cellspacing=\"0\" border=\"0\"><tr><td><input type=\"checkbox\" name=\"".$selected_users_name."[]\" value=\"".$users->f("id")."\" checked ".$disabled." /></td>";
  132.             echo "<td>".show_profile($users->f("id"),$users->f("name"))."</td></tr></table></td>\n";
  133.         }else
  134.         {
  135.             echo "<td><table cellpadding=\"0\" cellspacing=\"0\" border=\"0\"><tr><td><input type=\"checkbox\" name=\"".$selected_users_name."[]\" value=\"".$users->f("id")."\" ".$disabled." /></td>";
  136.             echo "<td>".show_profile($users->f("id"),$users->f("name"))."</td></tr></table></td>\n";
  137.         }
  138.         $i++;
  139.     }
  140. }
  141.  
  142. if ($count == 0 && isset($acl_control_hide_self))
  143.         echo "<td colspan=\"3\"><br /><small>".$acl_control_no_contacts."</small></td>";
  144.  
  145. echo "</tr></table>";
  146. ?>
  147.