Commit f903f11a authored by Côme Chilliet's avatar Côme Chilliet
Browse files

Fixed #4783 ease use of templates through webservice

parent b280f9f1
......@@ -162,6 +162,9 @@ class plugin
$ldap = $config->get_ldap_link();
$ldap->cat($this->dn);
$this->attrs = $ldap->fetch();
if (empty($this->attrs)) {
throw new Exception('Could not open dn');
}
}
/* Set the template flag according to the existence of objectClass fdTemplate */
......
......@@ -101,7 +101,7 @@ class template
}
$attributes[$class] = array('name' => $this->tabObject->by_name[$class], 'attrs' => array());
foreach ($this->attributes[$class] as $attr) {
$plugin->attributesAccess[$attr]->serializeAttribute($attributes[$class]['attrs']);
$plugin->attributesAccess[$attr]->serializeAttribute($attributes[$class]['attrs'], FALSE);
}
}
......@@ -111,8 +111,12 @@ class template
function deserialize($values)
{
foreach ($values as $class => $class_values) {
$this->tabObject->by_object[$class]->deserializeValues($class_values);
$result = $this->tabObject->by_object[$class]->deserializeValues($class_values, FALSE);
if ($result !== TRUE) {
return $result;
}
}
return TRUE;
}
function save_object()
......
......@@ -974,13 +974,19 @@ class simplePlugin extends plugin
return $this->attributesAccess[$field]->foreignKeyCheck($value, $source);
}
function deserializeValues($values) {
/* Walk through attributes */
foreach ($this->attributesAccess as $ldapName => &$attr) {
/* Load values */
$attr->deserializeValue($values);
function deserializeValues($values, $checkAcl = TRUE) {
foreach ($values as $name => $value) {
if (isset($this->attributesAccess[$name])) {
if (!$checkAcl || $this->acl_is_writeable($this->attributesAccess[$name]->getAcl())) {
$this->attributesAccess[$name]->setValue($value);
} else {
return sprintf(_('You don\'t have sufficient rights to edit field "%s"'), $name);
}
} else {
return sprintf(_('Unknown field "%s"'), $name);
}
}
unset($attr);
return TRUE;
}
/* Returns TRUE if this attribute should be asked in the creation by template dialog */
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment