2009-06-30 10:41:18 +00:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* Displays a form to allow the user to modify group members.
|
|
|
|
*
|
|
|
|
* @package phpLDAPadmin
|
2009-07-01 06:09:17 +00:00
|
|
|
* @subpackage Page
|
2009-06-30 10:41:18 +00:00
|
|
|
*/
|
2009-07-01 06:09:17 +00:00
|
|
|
|
2009-06-30 10:41:18 +00:00
|
|
|
/**
|
|
|
|
*/
|
|
|
|
|
|
|
|
require './common.php';
|
|
|
|
|
2009-07-01 06:09:17 +00:00
|
|
|
# The DN we are working with
|
|
|
|
$request = array();
|
|
|
|
$request['dn'] = get_request('dn','GET');
|
|
|
|
$request['attr'] = get_request('attr','GET');
|
2009-06-30 10:41:18 +00:00
|
|
|
|
2009-07-01 06:09:17 +00:00
|
|
|
$request['page'] = new TemplateRender($app['server']->getIndex(),get_request('template','REQUEST',false,'none'));
|
|
|
|
$request['page']->setDN($request['dn']);
|
|
|
|
$request['page']->accept(true);
|
|
|
|
$request['template'] = $request['page']->getTemplate();
|
2009-06-30 10:41:18 +00:00
|
|
|
|
2009-07-01 06:09:17 +00:00
|
|
|
if (! is_null($request['dn']))
|
|
|
|
$rdn = get_rdn($request['dn']);
|
2009-06-30 10:41:18 +00:00
|
|
|
else
|
|
|
|
$rdn = null;
|
|
|
|
|
|
|
|
# Get all current group members
|
2009-07-01 06:09:17 +00:00
|
|
|
$current_members = $app['server']->getDNAttrValue($request['dn'],$request['attr']);
|
2009-06-30 11:52:55 +00:00
|
|
|
usort($current_members,'pla_compare_dns');
|
2009-06-30 10:41:18 +00:00
|
|
|
|
|
|
|
# Loop through all base dn's and search possible member entries
|
2009-07-01 06:09:17 +00:00
|
|
|
$query = array();
|
2009-06-30 10:41:18 +00:00
|
|
|
|
2009-07-01 06:09:17 +00:00
|
|
|
# Get all entries that can be added to the group
|
|
|
|
if (preg_match("/^".$request['attr']."$/i",$_SESSION[APPCONFIG]->getValue('modify_member','posixgroupattr'))) {
|
|
|
|
$query['filter'] = $_SESSION[APPCONFIG]->getValue('modify_member','posixfilter');
|
|
|
|
$attr = $_SESSION[APPCONFIG]->getValue('modify_member','posixattr');
|
2009-06-30 10:46:00 +00:00
|
|
|
|
2009-07-01 06:09:17 +00:00
|
|
|
} else {
|
|
|
|
$query['filter'] = $_SESSION[APPCONFIG]->getValue('modify_member','filter');
|
|
|
|
$attr = $_SESSION[APPCONFIG]->getValue('modify_member','attr');
|
2009-06-30 10:41:18 +00:00
|
|
|
}
|
|
|
|
|
2009-07-01 06:09:17 +00:00
|
|
|
$query['attrs'] = array($attr);
|
2009-06-30 10:41:18 +00:00
|
|
|
|
2009-07-01 06:09:17 +00:00
|
|
|
$possible_values = array();
|
|
|
|
foreach ($app['server']->getBaseDN() as $base) {
|
|
|
|
$query['base'] = $base;
|
2009-06-30 10:41:18 +00:00
|
|
|
|
2009-07-01 06:09:17 +00:00
|
|
|
$possible_values = array_merge($possible_values,$app['server']->query($query,null));
|
|
|
|
}
|
2009-06-30 10:41:18 +00:00
|
|
|
|
2009-07-01 06:09:17 +00:00
|
|
|
usort($possible_values,'pla_compare_dns');
|
2009-06-30 10:41:18 +00:00
|
|
|
|
2009-07-01 06:09:17 +00:00
|
|
|
$request['page']->drawTitle(sprintf('%s <b>%s</b>',_('Modify group'),get_rdn($request['dn'])));
|
|
|
|
$request['page']->drawSubTitle();
|
2009-06-30 10:41:18 +00:00
|
|
|
|
|
|
|
printf('%s <b>%s</b> %s <b>%s</b>:',
|
2009-07-01 06:09:17 +00:00
|
|
|
_('There are'),count($current_members),_('members in group'),htmlspecialchars(get_rdn($request['dn'])));
|
2009-06-30 10:41:18 +00:00
|
|
|
|
2009-06-30 11:52:55 +00:00
|
|
|
$possible_members = array();
|
2009-07-01 06:09:17 +00:00
|
|
|
for ($i=0;$i<count($possible_values);$i++) {
|
|
|
|
if (preg_match("/^".$request['attr']."$/i",$_SESSION[APPCONFIG]->getValue('modify_member','posixgroupattr')))
|
2009-07-27 07:18:25 +00:00
|
|
|
$possible_members[$i] = $possible_values[$i][$_SESSION[APPCONFIG]->getValue('modify_member','posixattr')][0];
|
2009-06-30 10:41:18 +00:00
|
|
|
else
|
2009-07-01 06:09:17 +00:00
|
|
|
$possible_members[$i] = $possible_values[$i][$_SESSION[APPCONFIG]->getValue('modify_member','attr')];
|
2009-06-30 10:41:18 +00:00
|
|
|
}
|
|
|
|
|
2009-07-01 06:09:17 +00:00
|
|
|
# Show only user that are not already in group.
|
|
|
|
$possible_members = array_diff($possible_members,$current_members);
|
2009-06-30 11:52:55 +00:00
|
|
|
usort($possible_members,'pla_compare_dns');
|
2009-06-30 10:41:18 +00:00
|
|
|
|
2009-07-01 06:09:17 +00:00
|
|
|
/* Draw form with select boxes, left for all possible members and
|
|
|
|
* right one for those that belong to group */
|
2009-06-30 10:41:18 +00:00
|
|
|
|
|
|
|
# Modifications will be sent to update_confirm which takes care of rest of the processing
|
|
|
|
echo '<br />';
|
|
|
|
echo '<br />';
|
2009-08-22 11:30:50 +00:00
|
|
|
|
|
|
|
printf('<script type="text/javascript" language="javascript" src="%smodify_member.js"></script>',JSDIR);
|
2009-06-30 10:46:00 +00:00
|
|
|
echo '<form action="cmd.php" method="post" class="add_value" name="member">';
|
2009-07-01 06:09:17 +00:00
|
|
|
if ($_SESSION[APPCONFIG]->getValue('confirm','update'))
|
|
|
|
echo '<input type="hidden" name="cmd" value="update_confirm" />';
|
|
|
|
else
|
|
|
|
echo '<input type="hidden" name="cmd" value="update" />';
|
2009-06-30 10:41:18 +00:00
|
|
|
|
|
|
|
echo '<table class="modify_members">';
|
|
|
|
|
|
|
|
echo '<tr>';
|
2009-07-08 10:10:57 +00:00
|
|
|
printf('<td><img src="%s/ldap-user.png" alt="Users" /> %s</td>',IMGDIR,_('Available members'));
|
|
|
|
printf('<td><img src="%s/ldap-uniquegroup.png" alt="Members" /> %s</td>',IMGDIR,_('Group members'));
|
2009-06-30 10:41:18 +00:00
|
|
|
echo '</tr>';
|
|
|
|
|
|
|
|
# Generate select box from all possible members
|
|
|
|
echo '<tr>';
|
|
|
|
echo '<td>';
|
|
|
|
echo '<select name="notmembers" size="10" multiple>';
|
|
|
|
|
|
|
|
foreach ($possible_members as $possible)
|
|
|
|
printf('<option>%s</option>',$possible);
|
|
|
|
|
|
|
|
echo '</select>';
|
|
|
|
echo '</td>';
|
|
|
|
|
|
|
|
# Generate select box from all current members
|
|
|
|
echo '<td>';
|
|
|
|
echo '<select name="members" size="10" multiple>';
|
|
|
|
|
|
|
|
foreach ($current_members as $current)
|
|
|
|
printf('<option>%s</option>',$current);
|
|
|
|
|
|
|
|
echo '</select>';
|
|
|
|
echo '</td>';
|
|
|
|
|
|
|
|
echo '</tr>';
|
|
|
|
|
|
|
|
# Show buttons which move users from left to right and vice versa
|
|
|
|
echo '<tr>';
|
|
|
|
echo '<td>';
|
|
|
|
printf('<input type="button" onClick="one2two()" value="%s >>" /> <input type="button" onClick="all2two()" value="%s >>" />',
|
|
|
|
_('Add selected'),_('Add all'));
|
|
|
|
echo '</td>';
|
|
|
|
echo '<td>';
|
|
|
|
printf('<input type="button" onClick="two2one()" value="<< %s" /> <input type="button" onClick="all2one()" value="<< %s" />',
|
|
|
|
_('Remove selected'),('Remove all'));
|
|
|
|
echo '</td>';
|
|
|
|
echo '</tr>';
|
|
|
|
|
|
|
|
echo '<tr><td colspan="2">';
|
|
|
|
|
|
|
|
# Hidden attributes for update_confirm.php
|
2009-07-01 06:09:17 +00:00
|
|
|
printf('<input type="hidden" name="server_id" value="%s" />',$app['server']->getIndex());
|
|
|
|
printf('<input type="hidden" name="dn" value="%s" />',rawurlencode($request['dn']));
|
|
|
|
printf('<input type="hidden" name="attr" value="%s" />',$request['attr']);
|
2009-06-30 10:41:18 +00:00
|
|
|
|
2009-07-01 06:09:17 +00:00
|
|
|
/* Generate array of input text boxes from current members.
|
|
|
|
* update_confirm.php will see this as old_values[member-attribute][item] */
|
|
|
|
for ($i=0; $i<count($current_members); $i++)
|
2009-06-30 10:41:18 +00:00
|
|
|
printf('<input type="hidden" name="old_values[%s][%s]" value="%s" />',
|
2009-07-01 06:09:17 +00:00
|
|
|
htmlspecialchars($request['attr']),$i,htmlspecialchars($current_members[$i]));
|
|
|
|
|
|
|
|
/* Javascript generates array of input text boxes from new members.
|
2009-06-30 10:41:18 +00:00
|
|
|
* update_confirm.php will see this as new_values[member-attribute][item]
|
2009-07-01 06:09:17 +00:00
|
|
|
* Input text boxes will be generated to div=dnu */
|
2009-06-30 10:41:18 +00:00
|
|
|
echo '<div id="dnu">';
|
2009-07-01 06:09:17 +00:00
|
|
|
printf('<input type="hidden" name="new_values[%s][]" value="" />',htmlspecialchars($request['attr']));
|
2009-06-30 10:41:18 +00:00
|
|
|
echo '</div>';
|
|
|
|
|
|
|
|
# Submit values to update_confirm.php and when clicked, run addSelected
|
2009-08-22 11:30:50 +00:00
|
|
|
printf('<input type="submit" name="save" value="%s" onClick="update_new_values(\'%s\')" />',_('Save changes'),$request['attr']);
|
2009-06-30 10:41:18 +00:00
|
|
|
echo '</td></tr>';
|
|
|
|
|
|
|
|
echo '</table>';
|
|
|
|
echo '</form>';
|
|
|
|
echo '</body></html>';
|
|
|
|
?>
|