Exemple #1
0
foreach ($request['dn'] as $dn) {
    # Check if the entry exists.
    if (!$dn || !$app['server']->dnExists($dn)) {
        system_message(array('title' => _('Entry does not exist'), 'body' => sprintf('%s (%s/%s)', _('The entry does not exist and will be ignored'), $dn), 'type' => 'error'));
        continue;
    }
    $request['page'][$counter] = new MassRender($app['server']->getIndex(), 'none');
    $request['page'][$counter]->setDN($dn);
    $request['page'][$counter]->accept(true);
    $template = $request['page'][$counter]->getTemplate();
    # Mark our attributes to edit as shown.
    foreach ($template->getAttributes(true) as $attribute) {
        if ($attribute->isInternal()) {
            continue;
        }
        if (in_array_ignore_case($attribute->getName(), $request['attrs']) || in_array('*', $request['attrs'])) {
            $attribute->show();
            # Get a list of our columns (we are not interested in these attribute values)
            if (!isset($attrcols[$attribute->getName()])) {
                $attrcols[$attribute->getName()] = $attribute;
            }
        }
    }
    $counter++;
}
usort($attrcols, 'sortAttrs');
if (!count($request['page'])) {
    header('Location: index.php');
}
# We'll render this forms Title with the first DN's object.
$request['page'][0]->drawTitle(_('Bulk edit the following DNs'));
Exemple #2
0
 protected function drawFormValueObjectClassAttribute($attribute, $i)
 {
     if (DEBUGTMP) {
         printf('<font size=-2>%s</font><br />', __METHOD__);
     }
     $val = $attribute->getValue($i);
     /* It seems that openLDAP allows us to remove additional structural objectclasses
        however other LDAP servers, dont remove them (even if we ask them to). */
     # Do we have our internal attributes.
     $internal = $this->template->getAttribute('structuralobjectclass');
     if ($internal) {
         $structural = in_array_ignore_case($val, $internal->getValues());
         # We'll work it out the traditional way.
     } else {
         # If this schema structural?
         $schema_object = $val ? $this->getServer()->getSchemaObjectClass($val) : false;
         $structural = is_object($schema_object) && $schema_object->getType() == 'structural';
     }
     if ($structural) {
         $this->draw('FormReadOnlyValue', $attribute, $i);
         printf(' <small>(<acronym title="%s">%s</acronym>)</small>', _('This is a structural ObjectClass and cannot be removed.'), _('structural'));
     } else {
         $this->draw('FormReadWriteValue', $attribute, $i);
     }
 }
Exemple #3
0
 /**
  * Add an entry in the tree view ; the entry is added in the
  * children array of its parent
  *
  * @param dn DN to add
  * @param string $dn the dn of the entry to create
  */
 public function addEntry($dn)
 {
     if (DEBUG_ENABLED && (($fargs = func_get_args()) || ($fargs = 'NOARGS'))) {
         debug_log('Entered (%%)', 33, 0, __FILE__, __LINE__, __METHOD__, $fargs);
     }
     $server = $this->getServer();
     $dnlower = $this->indexDN($dn);
     # @todo Temporarily removed, some non-ascii char DNs that do exist, fail here for some reason?
     #if (! ($server->dnExists($dn)))
     #	return;
     if (isset($this->entries[$dnlower])) {
         debug_dump_backtrace('Calling add entry to an entry that ALREADY exists?', 1);
     }
     if (DEBUG_ENABLED) {
         debug_log('New ENTRY (%s).', 64, 0, __FILE__, __LINE__, __METHOD__, $dn);
     }
     $tree_factory = new TreeItem($server->getIndex(), $dn);
     $tree_factory->setObjectClasses($server->getDNAttrValue($dn, 'objectClass'));
     if (($isleaf = $server->getDNAttrValue($dn, 'hassubordinates')) && !strcasecmp($isleaf[0], 'false')) {
         $tree_factory->setLeaf();
     }
     $this->entries[$dnlower] = $tree_factory;
     # Is this entry in a base entry?
     if (in_array_ignore_case($dn, $server->getBaseDN(null))) {
         $this->entries[$dnlower]->setBase();
         # If the parent entry is not in the tree, we add it. This routine will in itself
         # recall this method until we get to the top of the tree (the base).
     } else {
         $parent_dn = $server->getContainer($dn);
         if (DEBUG_ENABLED) {
             debug_log('Parent DNs (%s)', 64, 0, __FILE__, __LINE__, __METHOD__, $parent_dn);
         }
         if ($parent_dn) {
             $parent_entry = $this->getEntry($parent_dn);
             if (!$parent_entry) {
                 $this->addEntry($parent_dn);
                 $parent_entry = $this->getEntry($parent_dn);
             }
             # Update this DN's parent's children list as well.
             $parent_entry->addChild($dn);
         }
     }
 }
 /**
  * Returns true if the specified attribute is configured as unique
  * in config.php.
  * Attributes are configured as hidden in config.php thus:
  * <code>
  *	$servers->setValue('unique','attrs',array('mail','uid','uidNumber'));
  * </code>
  *
  * @param string $attr The name of the attribute to test.
  * @return boolean
  */
 public function isAttrUnique($attr)
 {
     if (DEBUG_ENABLED && (($fargs = func_get_args()) || ($fargs = 'NOARGS'))) {
         debug_log('Entered (%%)', 17, 0, __FILE__, __LINE__, __METHOD__, $fargs);
     }
     # Should this attribute value be unique
     if (in_array_ignore_case($attr, $this->getValue('unique', 'attrs'))) {
         return true;
     } else {
         return false;
     }
 }
 /**
  * Return if this objectClass is related to $oclass
  *
  * @param array ObjectClasses that this attribute may be related to
  */
 public function isRelated($oclass)
 {
     if (DEBUG_ENABLED && (($fargs = func_get_args()) || ($fargs = 'NOARGS'))) {
         debug_log('Entered (%%)', 9, 0, __FILE__, __LINE__, __METHOD__, $fargs);
     }
     # If I am in the array, we'll just return false
     if (in_array_ignore_case($this->name, $oclass)) {
         return false;
     }
     $server = $_SESSION[APPCONFIG]->getServer($this->server_id);
     foreach ($oclass as $object_class) {
         $oc = $server->getSchemaObjectClass($object_class);
         if ($oc->isStructural() && in_array_ignore_case($this->getName(), $oc->getParents())) {
             return true;
         }
     }
     return false;
 }
$request['dn'] = get_request('dn', 'REQUEST');
if (!$request['dn']) {
    system_message(array('title' => _('No entry selected'), 'body' => _('No entry was selected to delete'), 'type' => 'warn'), 'index.php');
}
if (!is_array($request['dn'])) {
    $request['dn'] = array($request['dn']);
}
$request['children'] = array();
$request['parent'] = array();
foreach ($request['dn'] as $dn) {
    # Check if the entry exists.
    if (!$dn || !$app['server']->dnExists($dn)) {
        system_message(array('title' => _('Entry does not exist'), 'body' => sprintf('%s (%s/%s)', _('The entry does not exist and will be ignored'), $dn), 'type' => 'error'));
    }
    # We search all children, not only the visible children in the tree
    if (!in_array_ignore_case($dn, $request['children'])) {
        $request['children'] = array_merge($request['children'], $app['server']->getContainerContents($dn, null, 0, '(objectClass=*)', LDAP_DEREF_NEVER));
        array_push($request['parent'], $dn);
    }
}
printf('<h3 class="title">%s</h3>', _('Mass Delete'));
printf('<h3 class="subtitle">%s: <b>%s</b></h3>', _('Server'), $app['server']->getName());
echo "\n";
echo '<center>';
echo '<table class="forminput" border="0">';
if (count($request['parent']) == 1) {
    printf('<tr><td colspan="4"><b>%s</b></td></tr>', _('Are you sure you want to permanently delete this object?'));
} else {
    printf('<tr><td colspan="4"><b>%s</b></td></tr>', _('Are you sure you want to permanently delete these objects?'));
}
echo '<tr><td colspan="4">&nbsp;</td></tr>';
 /** DATE ATTRIBUTE RENDERING **/
 protected function drawJavaScriptDateAttribute($attribute)
 {
     if (DEBUGTMP) {
         printf('<font size=-2>%s</font><br />', __METHOD__);
     }
     printf('<!-- START: DATE ATTRIBUTE %s (%s)-->', __METHOD__, $attribute->getName());
     echo "\n";
     $this->drawJavaScriptAttribute($attribute);
     static $drawn = false;
     # This JS may have been rendered by multiple Date attributes
     if (!$drawn) {
         printf('<script type="text/javascript" src="%sjscalendar/lang/calendar-en.js"></script>', JSDIR);
         printf('<script type="text/javascript" src="%sjscalendar/calendar-setup.js"></script>', JSDIR);
         printf('<script type="text/javascript" src="%sdate_selector.js"></script>', JSDIR);
         $drawn = true;
     }
     $config = array();
     $config['date'] = array_change_key_case($_SESSION[APPCONFIG]->getValue('appearance', 'date_attrs'));
     $config['time'] = array_change_key_case($_SESSION[APPCONFIG]->getValue('appearance', 'date_attrs_showtime'));
     $config['format'] = $_SESSION[APPCONFIG]->getValue('appearance', 'date');
     if (isset($config['date'][$attribute->getName()])) {
         $config['format'] = $config['date'][$attribute->getName()];
     }
     for ($i = 0; $i <= $attribute->getValueCount(); $i++) {
         printf('<script type="text/javascript">defaults[\'new_values_%s_%s\'] = \'%s\';</script>', $attribute->getName(), $i, $config['format']);
         if (in_array_ignore_case($attribute->getName(), array_keys($config['time'])) && $config['time'][$attribute->getName()]) {
             printf('<script type="text/javascript">defaults[\'f_time_%s_%s\'] = \'%s\';</script>', $attribute->getName(), $i, 'true');
         }
         echo "\n";
     }
     printf('<!-- END: DATE ATTRIBUTE %s (%s)-->', __METHOD__, $attribute->getName());
     echo "\n";
 }
Exemple #8
0
 /**
  * Get available attributes
  */
 public function getAvailAttrs()
 {
     if (DEBUG_ENABLED && (($fargs = func_get_args()) || ($fargs = 'NOARGS'))) {
         debug_log('Entered (%%)', 5, 0, __FILE__, __LINE__, __METHOD__, $fargs);
     }
     $attributes = array();
     $server = $this->getServer();
     # Initialise the Attribute Factory.
     $attribute_factory = new AttributeFactory();
     if (in_array_ignore_case('extensibleobject', $this->getObjectClasses())) {
         foreach ($server->SchemaAttributes() as $sattr) {
             $attribute = $attribute_factory->newAttribute($sattr->getName(), array('values' => array()), $server->getIndex(), null);
             array_push($attributes, $attribute);
         }
     } else {
         $attrs = array();
         foreach ($this->getObjectClasses() as $oc) {
             $soc = $server->getSchemaObjectClass($oc);
             $attrs = array_merge($attrs, $soc->getMustAttrNames(true), $soc->getMayAttrNames(true));
             $attrs = array_unique($attrs);
         }
         foreach ($attrs as $attr) {
             if (is_null($this->getAttribute($attr))) {
                 $attribute = $attribute_factory->newAttribute($attr, array('values' => array()), $server->getIndex(), null);
                 array_push($attributes, $attribute);
             }
         }
     }
     masort($attributes, 'name');
     return $attributes;
 }
 } elseif (is_url_string($val)) {
     printf('<a href="%s" target="new"><img style="vertical-align: center" src="images/dc.png" /></a>&nbsp;', htmlspecialchars($val));
 }
 if ($ldapserver->isMultiLineAttr($attr, $val)) {
     printf('<textarea class="val" rows="3" cols="50" name="%s" id="%s">%s</textarea>', $input_name, $input_id, htmlspecialchars($val));
 } else {
     printf('<input type="text" class="val" name="%s" id="%s" value="%s" />&nbsp;', $input_name, $input_id, htmlspecialchars($val));
 }
 /* draw a link for popping up the entry browser if this is the type of attribute
    that houses DNs. */
 if ($ldapserver->isDNAttr($attr)) {
     draw_chooser_link("edit_form.{$input_id}", false);
 }
 echo '<br />';
 # If this is a gidNumber on a non-PosixGroup entry, lookup its name and description for convenience
 if (!strcasecmp($attr, 'gidNumber') && !in_array_ignore_case('posixGroup', $ldapserver->getDNAttr($dn, 'objectClass'))) {
     $gid_number = $val;
     $search_group_filter = "(&(objectClass=posixGroup)(gidNumber={$val}))";
     $group = $ldapserver->search(null, null, $search_group_filter, array('dn', 'description'));
     if (count($group) > 0) {
         echo '<br />';
         $group = array_pop($group);
         $group_dn = $group['dn'];
         $group_name = explode('=', get_rdn($group_dn));
         $group_name = $group_name[1];
         $href = sprintf('template_engine.php?server_id=%s&amp;dn=%s', $ldapserver->server_id, urlencode($group_dn));
         echo '<small>';
         printf('<a href="%s">%s</a>', $href, htmlspecialchars($group_name));
         $description = isset($group['description']) ? $group['description'] : null;
         if ($description) {
             printf(' (%s)', htmlspecialchars($description));