private function getAFattrs() { if (DEBUG_ENABLED && (($fargs = func_get_args()) || ($fargs = 'NOARGS'))) { debug_log('Entered (%%)', 129, 0, __FILE__, __LINE__, __METHOD__, $fargs); } $attribute_factory = new AttributeFactory(); $results = array(); foreach (explode(',', $this->template->getAttrDisplayOrder()) as $attr) { $results[strtolower($attr)] = $attribute_factory->newAttribute($attr, array('values' => array()), $this->getServerID()); } return $results; }
/** * Add another attribute to this template * * @return int Attribute ID */ public function addAttribute($name, $value, $source = null) { if (DEBUG_ENABLED && (($fargs = func_get_args()) || ($fargs = 'NOARGS'))) { debug_log('Entered (%%)', 5, 0, __FILE__, __LINE__, __METHOD__, $fargs); } if (!is_array($value)) { debug_dump_backtrace('Value should be an array()', 1); } $server = $this->getServer(); # Initialise the Attribute Factory. $attribute_factory = new AttributeFactory(); # If there isnt a schema item for this attribute $attribute = $attribute_factory->newAttribute($name, $value, $server->getIndex(), $source); $attrid = $this->getAttrID($attribute->getName()); if (is_null($attrid)) { array_push($this->attributes, $attribute); } else { debug_dump_backtrace(sprintf('There was a request to add an attribute (%s), but it was already defined? (%s)', $attrid, __METHOD__), true); } if ($this->getID() == 'none') { usort($this->attributes, 'sortAttrs'); } return $attribute; }
foreach ($request['template']->getAttribute('objectclass')->getValues() as $oclass_name) { # Exclude "top" if its there. if (!strcasecmp('top', $oclass_name)) { continue; } if ($soc = $app['server']->getSchemaObjectClass($oclass_name)) { $ldap['attrs']['must'] = array_merge($ldap['attrs']['must'], $soc->getMustAttrNames(true)); } } $ldap['attrs']['must'] = array_unique($ldap['attrs']['must']); /* Build a list of the attributes that this new objectClass requires, * but that the object does not currently contain */ $ldap['attrs']['need'] = array(); foreach ($ldap['attrs']['must'] as $attr) { if (is_null($request['template']->getAttribute($attr))) { array_push($ldap['attrs']['need'], $attribute_factory->newAttribute($attr, array('values' => array()), $app['server']->getIndex())); } } # Mark all the need attributes as shown foreach ($ldap['attrs']['need'] as $index => $values) { $ldap['attrs']['need'][$index]->show(); } if (count($ldap['attrs']['need']) > 0) { $request['page']->drawTitle(sprintf('%s <b>%s</b>', _('Add new objectClass to'), get_rdn($request['dn']))); $request['page']->drawSubTitle(); echo '<div style="text-align: center">'; printf('<small><b>%s: </b>%s <b>%s</b> %s %s</small>', _('Instructions'), _('In order to add these objectClass(es) to this entry, you must specify'), count($ldap['attrs']['need']), _('new attributes'), _('that this objectClass requires.')); echo '<br /><br />'; echo '<form action="cmd.php" method="post" id="entry_form">'; echo '<div>'; if ($_SESSION[APPCONFIG]->getValue('confirm', 'update')) {
/** * Add another attribute to this template * * @return int Attribute ID */ public function addAttribute($name, $value, $source = null) { if (DEBUG_ENABLED && (($fargs = func_get_args()) || ($fargs = 'NOARGS'))) { debug_log('Entered (%%)', 5, 0, __FILE__, __LINE__, __METHOD__, $fargs); } if (!is_array($value)) { debug_dump_backtrace('Value should be an array()', 1); } $server = $this->getServer(); # Initialise the Attribute Factory. $attribute_factory = new AttributeFactory(); if (preg_match('/;/', $name)) { system_message(array('title' => 'phpLDAPadmin doesnt support RFC3866.', 'body' => sprintf('%s {%s} (%s)', 'PLA might not do what you expect...', $name, is_array($value) ? serialize($value) : $value), 'type' => 'warn')); } # If there isnt a schema item for this attribute $attribute = $attribute_factory->newAttribute($name, $value, $server->getIndex(), $source); $attrid = $this->getAttrID($attribute->getName()); if (is_null($attrid)) { array_push($this->attributes, $attribute); } return $attribute; }
/** * 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; }