self::ATTRIBUTE_GIVENNAME,
self::ATTRIBUTE_MAIL,
),
- /**
- * Derived attributes are calculated based on other attribute values.
- */
'derived' => array(
self::ATTRIBUTE_GIVENNAME => array(
+ 'base' => self::ATTRIBUTE_GIVENNAME,
+ 'order' => 0,
'desc' => 'Given name.',
),
self::ATTRIBUTE_MIDDLENAMES => array(
+ 'base' => self::ATTRIBUTE_GIVENNAME,
+ 'order' => 1,
'desc' => 'Additional names separated from the given name by whitespace.',
),
),
- /**
- * Default values for attributes without a value.
- */
'defaults' => array(
),
- /**
- * Locked attributes. These are fixed after the object has been stored
- * once. They may not be modified again.
- */
'locked' => array(
+ self::ATTRIBUTE_MAIL,
),
- /**
- * The object classes representing this object.
- */
'object_classes' => array(
self::OBJECTCLASS_INETORGPERSON,
),
);
/**
+ * Return the filter string to retrieve this object type.
+ *
+ * @static
+ *
+ * @return string The filter to retrieve this object type from the server
+ * database.
+ */
+ public static function getFilter()
+ {
+ return '(&(' . self::ATTRIBUTE_OC . '=' . self::OBJECTCLASS_INETORGPERSON . '))';
+ }
+
+ /**
* Derive an attribute value.
*
* @param string $attr The attribute to derive.
*
* @return mixed The value of the attribute.
*/
- protected function derive($attr)
+ protected function derive($attr, $separator = '$')
{
switch ($attr) {
- case self::ATTRIBUTE_ID:
- $result = split(',', $this->uid);
- if (substr($result[0], 0, 3) == 'cn=') {
- return substr($result[0], 3);
- } else {
- return $result[0];
- }
case self::ATTRIBUTE_GIVENNAME:
case self::ATTRIBUTE_MIDDLENAMES:
- $gn = $this->_get(self::ATTRIBUTE_GIVENNAME);
- if (empty($gn)) {
- return;
- }
- list($a[self::ATTRIBUTE_GIVENNAME],
- $a[self::ATTRIBUTE_MIDDLENAMES]) = explode(' ', $gn, 2);
- if (empty($a[$attr])) {
- return;
- }
- return $a[$attr];
+ return $this->getField($attr, ' ', 2);
default:
return parent::derive($attr);
}
*
* @return mixed The value of the attribute.
*/
- protected function collapse($attr, &$info)
+ protected function collapse($key, $attributes, &$info, $separator = '$')
{
- switch ($attr) {
+ switch ($key) {
case self::ATTRIBUTE_GIVENNAME:
- case self::ATTRIBUTE_MIDDLENAMES:
- if (!isset($info[self::ATTRIBUTE_MIDDLENAMES])
- && !isset($info[self::ATTRIBUTE_GIVENNAME])) {
- return;
- }
-
- if (isset($info[self::ATTRIBUTE_MIDDLENAMES])) {
- $givenname = isset($info[self::ATTRIBUTE_GIVENNAME]) ? $info[self::ATTRIBUTE_GIVENNAME] : '';
- $info[self::ATTRIBUTE_GIVENNAME] = $givenname . isset($info[self::ATTRIBUTE_MIDDLENAMES]) ? ' ' . $info[self::ATTRIBUTE_MIDDLENAMES] : '';
- unset($info[self::ATTRIBUTE_MIDDLENAMES]);
- }
+ parent::collapse($key, $attributes, $info, ' ');
+ break;
default:
- return parent::derive($attr);
+ parent::collapse($key, $attributes, $info, $separator);
+ break;
}
}
*/
public static function generateId($info)
{
- $id_mapfields = array('givenName', 'sn');
- $id_format = '%s %s';
+ $id_mapfields = array(self::ATTRIBUTE_GIVENNAME,
+ self::ATTRIBUTE_SN);
+ $id_format = self::ATTRIBUTE_CN . '=' . '%s %s';
$fieldarray = array();
foreach ($id_mapfields as $mapfield) {
* @var array
*/
static public $init_attributes = array(
- /**
- * Derived attributes are calculated based on other attribute values.
- */
'derived' => array(
),
- /**
- * Default values for attributes without a value.
- */
'defaults' => array(
),
- /**
- * Locked attributes. These are fixed after the object has been stored
- * once. They may not be modified again.
- */
'locked' => array(
self::ATTRIBUTE_MAIL,
),
- /**
- * The object classes representing this object.
- */
'object_classes' => array(
self::OBJECTCLASS_KOLABINETORGPERSON,
),
);
/**
- * Derive an attribute value.
- *
- * @param string $attr The attribute to derive.
- *
- * @return mixed The value of the attribute.
- */
- protected function derive($attr)
- {
- switch ($attr) {
- case self::ATTRIBUTE_ID:
- $result = split(',', $this->uid);
- if (substr($result[0], 0, 3) == self::ATTRIBUTE_CN . '=') {
- return substr($result[0], 3);
- } else {
- return $result[0];
- }
- default:
- return parent::derive($attr);
- }
- }
-
- /**
- * Generates an ID for the given information.
- *
- * @param array $info The data of the object.
- *
- * @static
- *
- * @return string|PEAR_Error The ID.
- */
- public static function generateId($info)
- {
- $id_mapfields = array(self::ATTRIBUTE_GIVENNAME,
- self::ATTRIBUTE_SN);
- $id_format = '%s %s';
-
- $fieldarray = array();
- foreach ($id_mapfields as $mapfield) {
- if (isset($info[$mapfield])) {
- $fieldarray[] = $info[$mapfield];
- } else {
- $fieldarray[] = '';
- }
- }
-
- return trim(vsprintf($id_format, $fieldarray), " \t\n\r\0\x0B,");
- }
-
- /**
* Returns the set of search operations supported by this object type.
*
* @return array An array of supported search operations.
);
/**
- * Derive an attribute value.
- *
- * @param string $attr The attribute to derive.
- *
- * @return mixed The value of the attribute.
- */
- protected function derive($attr)
- {
- switch ($attr) {
- case self::ATTRIBUTE_ID:
- $result = split(',', $this->uid);
- if (substr($result[0], 0, 3) == 'cn=') {
- return substr($result[0], 3);
- } else {
- return $result[0];
- }
- default:
- return parent::derive($attr);
- }
- }
-
- /**
- * Generates an ID for the given information.
- *
- * @param array $info The data of the object.
+ * Return the filter string to retrieve this object type.
*
* @static
*
- * @return string|PEAR_Error The ID.
+ * @return string The filter to retrieve this object type from the server
+ * database.
*/
- public static function generateId($info)
+ public static function getFilter()
{
- $id_mapfields = array('givenName', 'sn');
- $id_format = '%s %s';
-
- $fieldarray = array();
- foreach ($id_mapfields as $mapfield) {
- if (isset($info[$mapfield])) {
- $fieldarray[] = $info[$mapfield];
- } else {
- $fieldarray[] = '';
- }
- }
-
- return trim(vsprintf($id_format, $fieldarray), " \t\n\r\0\x0B,");
+ return '(&(' . self::ATTRIBUTE_OC . '=' . self::OBJECTCLASS_ORGANIZATIONALPERSON . '))';
}
-
}
\ No newline at end of file