LSrelation : Add create action button

This commit is contained in:
Benjamin Renard 2017-08-02 12:00:11 +02:00
parent 9b90dadaee
commit 486f33ccf9
6 changed files with 139 additions and 66 deletions

View file

@ -41,6 +41,28 @@ if(LSsession :: startLSsession()) {
$form = $object -> getForm('create',urldecode($_GET['load'])); $form = $object -> getForm('create',urldecode($_GET['load']));
} }
else { else {
if (isset($_GET['LSrelation']) && isset($_GET['relatedLSobject']) && isset($_GET['relatedLSobjectDN'])) {
if (LSsession :: loadLSobject($_GET['relatedLSobject']) && LSsession :: loadLSclass('LSrelation')) {
$obj = new $_GET['relatedLSobject']();
if ($obj -> loadData(urldecode($_GET['relatedLSobjectDN']))) {
$relation = new LSrelation($obj, $_GET['LSrelation']);
if ($relation -> exists()) {
$attr = $relation -> getRelatedEditableAttribute();
if (isset($object -> attrs[$attr])) {
$value = $relation -> getRelatedKeyValue();
if (is_array($value)) $value=$value[0];
$object -> attrs[$attr] -> data = array($value);
}
else {
LSerror :: addErrorCode('LSrelations_06',array('relation' => $relation -> getName(),'LSobject' => $obj -> getType()));
}
}
}
else {
LSerror :: addErrorCode('LSsession_24');
}
}
}
$form = $object -> getForm('create'); $form = $object -> getForm('create');
} }
@ -116,5 +138,3 @@ else {
LSsession :: setTemplate('login.tpl'); LSsession :: setTemplate('login.tpl');
} }
LSsession :: displayTemplate(); LSsession :: displayTemplate();
?>

View file

@ -37,10 +37,28 @@ class LSrelation {
} }
} }
public function exists(&$obj=null,$relationName=null) {
if ($obj && $relationName) {
return (isset($obj->config['LSrelation'][$relationName]) && is_array($obj->config['LSrelation'][$relationName]));
}
else {
return is_array($this -> config);
}
}
public function getName() {
return $this -> relationName;
}
public function canEdit() { public function canEdit() {
return LSsession :: relationCanEdit($this -> obj -> getValue('dn'),$this -> obj -> getType(),$this -> relationName); return LSsession :: relationCanEdit($this -> obj -> getValue('dn'),$this -> obj -> getType(),$this -> relationName);
} }
public function canCreate() {
return LSsession :: canCreate($this -> config['LSobject']);
}
public function listRelatedObjects() { public function listRelatedObjects() {
if (LSsession :: loadLSobject($this -> config['LSobject'])) { if (LSsession :: loadLSobject($this -> config['LSobject'])) {
$objRel = new $this -> config['LSobject'](); $objRel = new $this -> config['LSobject']();
@ -242,6 +260,13 @@ class LSrelation {
'url' => 'select.php?LSobject='.$relationConf['LSobject'].'&multiple=1'.($relation -> getRelatedEditableAttribute()?'&editableAttr='.$relation -> getRelatedEditableAttribute():''), 'url' => 'select.php?LSobject='.$relationConf['LSobject'].'&multiple=1'.($relation -> getRelatedEditableAttribute()?'&editableAttr='.$relation -> getRelatedEditableAttribute():''),
'action' => 'modify' 'action' => 'modify'
); );
if ($relation -> canCreate()) {
$return['actions'][] = array(
'label' => _('New'),
'url' => 'create.php?LSobject='.$relationConf['LSobject'].'&LSrelation='.$relationName.'&relatedLSobject='.$object->getType().'&relatedLSobjectDN='.urlencode($object -> getValue('dn')),
'action' => 'create'
);
}
} }
$list = $relation -> listRelatedObjects(); $list = $relation -> listRelatedObjects();
@ -424,17 +449,20 @@ class LSrelation {
* Error Codes * Error Codes
**/ **/
LSerror :: defineError('LSrelations_01', LSerror :: defineError('LSrelations_01',
_("LSrelation : The function %{function} for action '%{action}' on the relation %{relation} is unknow.") _("LSrelation : The function %{function} for action '%{action}' on the relation %{relation} is unknown.")
); );
LSerror :: defineError('LSrelations_02', LSerror :: defineError('LSrelations_02',
_("LSrelation : Relation %{relation} of object type %{LSobject} unknow.") _("LSrelation : Relation %{relation} of object type %{LSobject} unknown.")
); );
LSerror :: defineError('LSrelations_03', LSerror :: defineError('LSrelations_03',
_("LSrelation : Error during relation update of the relation %{relation}.") _("LSrelation : Error during relation update of the relation %{relation}.")
); );
LSerror :: defineError('LSrelations_04', LSerror :: defineError('LSrelations_04',
_("LSrelation : Object type %{LSobject} unknow (Relation : %{relation}).") _("LSrelation : Object type %{LSobject} unknown (Relation : %{relation}).")
); );
LSerror :: defineError('LSrelations_05', LSerror :: defineError('LSrelations_05',
_("LSrelation : Incomplete configuration for LSrelation %{relation} of object type %{LSobject} for action : %{action}.") _("LSrelation : Incomplete configuration for LSrelation %{relation} of object type %{LSobject} for action : %{action}.")
); );
LSerror :: defineError('LSrelations_06',
_("LSrelation : Invalid editable attribute for LSrelation %{relation} with LSobject %{LSobject}.")
);

View file

@ -2454,6 +2454,9 @@ class LSsession {
LSerror :: defineError('LSsession_23', LSerror :: defineError('LSsession_23',
_("LSsession : view function %{func} for LSaddon %{addon} doet not exist.") _("LSsession : view function %{func} for LSaddon %{addon} doet not exist.")
); );
LSerror :: defineError('LSsession_24',
_("LSsession : invalid related object's DN pass in parameter.")
);
} }
/** /**

View file

@ -7,8 +7,8 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: LdapSaisie\n" "Project-Id-Version: LdapSaisie\n"
"Report-Msgid-Bugs-To: \n" "Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2017-06-15 18:19+0200\n" "POT-Creation-Date: 2017-08-02 11:53+0200\n"
"PO-Revision-Date: 2017-06-15 18:21+0100\n" "PO-Revision-Date: 2017-08-02 11:56+0100\n"
"Last-Translator: Benjamin Renard <brenard@zionetrix.net>\n" "Last-Translator: Benjamin Renard <brenard@zionetrix.net>\n"
"Language-Team: LdapSaisie <ldapsaisie-users@lists.labs.libre-entreprise." "Language-Team: LdapSaisie <ldapsaisie-users@lists.labs.libre-entreprise."
"org>\n" "org>\n"
@ -22,7 +22,7 @@ msgstr ""
#: view.php:44 modify.php:54 #: view.php:44 modify.php:54
#: includes/class/class.LSformElement_supannCompositeAttribute.php:106 #: includes/class/class.LSformElement_supannCompositeAttribute.php:106
#: includes/class/class.LSrelation.php:241 #: includes/class/class.LSrelation.php:259
#: includes/class/class.LSformElement_select_object.php:68 #: includes/class/class.LSformElement_select_object.php:68
#: includes/class/class.LSformElement_supannLabeledValue.php:62 #: includes/class/class.LSformElement_supannLabeledValue.php:62
#: includes/class/class.LSsearchEntry.php:163 #: includes/class/class.LSsearchEntry.php:163
@ -33,7 +33,7 @@ msgstr "Modifier"
msgid "Copy" msgid "Copy"
msgstr "Copier" msgstr "Copier"
#: view.php:60 modify.php:111 includes/class/class.LSrelation.php:198 #: view.php:60 modify.php:111 includes/class/class.LSrelation.php:216
#: includes/class/class.LSform.php:218 #: includes/class/class.LSform.php:218
#: includes/class/class.LSformElement_select_object.php:69 #: includes/class/class.LSformElement_select_object.php:69
#: includes/class/class.LSformElement_select_object.php:85 #: includes/class/class.LSformElement_select_object.php:85
@ -78,15 +78,15 @@ msgstr "Voir"
msgid "Import" msgid "Import"
msgstr "Importer" msgstr "Importer"
#: create.php:53 #: create.php:75
msgid "Data entry form" msgid "Data entry form"
msgstr "Masque de saisie" msgstr "Masque de saisie"
#: create.php:59 #: create.php:81
msgid "Object has been added." msgid "Object has been added."
msgstr "L'objet a été ajouté." msgstr "L'objet a été ajouté."
#: create.php:98 #: create.php:120 includes/class/class.LSrelation.php:265
msgid "New" msgid "New"
msgstr "Nouveau" msgstr "Nouveau"
@ -813,6 +813,10 @@ msgid "LSsession : view function %{func} for LSaddon %{addon} doet not exist."
msgstr "" msgstr ""
"LSsession : la fonction de vue %{func} du LSaddon %{addon} n'existe pas." "LSsession : la fonction de vue %{func} du LSaddon %{addon} n'existe pas."
#: includes/class/class.LSsession.php:2458
msgid "LSsession : invalid related object's DN pass in parameter."
msgstr "LSsession : DN d'objet en relation incorrect dans les paramètres."
#: includes/class/class.LSldapObject.php:470 #: includes/class/class.LSldapObject.php:470
msgid "The attribute %{attr} is not valid." msgid "The attribute %{attr} is not valid."
msgstr "L'attribut %{attr} n'est pas valide." msgstr "L'attribut %{attr} n'est pas valide."
@ -1084,81 +1088,81 @@ msgstr "LSldap : Erreur durant la suppression des attributs vides."
msgid "LSldap : Error while changing the DN of the object." msgid "LSldap : Error while changing the DN of the object."
msgstr "LSldap : Erreur pendant la modification du DN de l'objet." msgstr "LSldap : Erreur pendant la modification du DN de l'objet."
#: includes/class/class.LSrelation.php:51 #: includes/class/class.LSrelation.php:69
#: includes/class/class.LSrelation.php:58 #: includes/class/class.LSrelation.php:76
msgid "listing related objects" msgid "listing related objects"
msgstr "énumaration des objets liés" msgstr "énumaration des objets liés"
#: includes/class/class.LSrelation.php:85 #: includes/class/class.LSrelation.php:103
#: includes/class/class.LSrelation.php:91 #: includes/class/class.LSrelation.php:109
msgid "getting key value" msgid "getting key value"
msgstr "récupération de la valeur clé" msgstr "récupération de la valeur clé"
#: includes/class/class.LSrelation.php:116 #: includes/class/class.LSrelation.php:134
#: includes/class/class.LSrelation.php:123 #: includes/class/class.LSrelation.php:141
#: includes/class/class.LSrelation.php:156 #: includes/class/class.LSrelation.php:174
msgid "checking right on relation with specific object" msgid "checking right on relation with specific object"
msgstr "vérification des droits sur la relation avec un objet en particulier" msgstr "vérification des droits sur la relation avec un objet en particulier"
#: includes/class/class.LSrelation.php:132 #: includes/class/class.LSrelation.php:150
msgid "deleting" msgid "deleting"
msgstr "suppression" msgstr "suppression"
#: includes/class/class.LSrelation.php:139 #: includes/class/class.LSrelation.php:157
msgid "removing relation with specific object" msgid "removing relation with specific object"
msgstr "suppression de la relation avec un object en particulier" msgstr "suppression de la relation avec un object en particulier"
#: includes/class/class.LSrelation.php:149 #: includes/class/class.LSrelation.php:167
msgid "renaming" msgid "renaming"
msgstr "renommage" msgstr "renommage"
#: includes/class/class.LSrelation.php:168 #: includes/class/class.LSrelation.php:186
msgid "updating" msgid "updating"
msgstr "mise à jour" msgstr "mise à jour"
#: includes/class/class.LSrelation.php:174 #: includes/class/class.LSrelation.php:192
msgid "updating relations" msgid "updating relations"
msgstr "mise à jour des relations" msgstr "mise à jour des relations"
#: includes/class/class.LSrelation.php:196 includes/class/class.LSform.php:216 #: includes/class/class.LSrelation.php:214 includes/class/class.LSform.php:216
#: remove.php:49 #: remove.php:49
msgid "Do you really want to delete" msgid "Do you really want to delete"
msgstr "Voulez-vous vraiment supprimer" msgstr "Voulez-vous vraiment supprimer"
#: includes/class/class.LSrelation.php:197 #: includes/class/class.LSrelation.php:215
msgid "Warning" msgid "Warning"
msgstr "Attention" msgstr "Attention"
#: includes/class/class.LSrelation.php:225 #: includes/class/class.LSrelation.php:243
#: includes/class/class.LSrelation.php:339 #: includes/class/class.LSrelation.php:364
msgid "No object." msgid "No object."
msgstr "Aucun objet." msgstr "Aucun objet."
#: includes/class/class.LSrelation.php:427 #: includes/class/class.LSrelation.php:452
msgid "" msgid ""
"LSrelation : The function %{function} for action '%{action}' on the relation " "LSrelation : The function %{function} for action '%{action}' on the relation "
"%{relation} is unknow." "%{relation} is unknown."
msgstr "" msgstr ""
"LSrelation : La fonction %{function} pour l'action '%{action}' sur la " "LSrelation : La fonction %{function} pour l'action '%{action}' sur la "
"relation %{relation} est inconnue." "relation %{relation} est inconnue."
#: includes/class/class.LSrelation.php:430 #: includes/class/class.LSrelation.php:455
msgid "LSrelation : Relation %{relation} of object type %{LSobject} unknow." msgid "LSrelation : Relation %{relation} of object type %{LSobject} unknown."
msgstr "" msgstr ""
"LSrelation : La relation %{relation} du type d'objet %{LSobject} est " "LSrelation : La relation %{relation} du type d'objet %{LSobject} est "
"inconnue." "inconnue."
#: includes/class/class.LSrelation.php:433 #: includes/class/class.LSrelation.php:458
msgid "LSrelation : Error during relation update of the relation %{relation}." msgid "LSrelation : Error during relation update of the relation %{relation}."
msgstr "LSsession : Erreur durant la mise à jour de la relation %{relation}" msgstr "LSsession : Erreur durant la mise à jour de la relation %{relation}"
#: includes/class/class.LSrelation.php:436 #: includes/class/class.LSrelation.php:461
msgid "LSrelation : Object type %{LSobject} unknow (Relation : %{relation})." msgid "LSrelation : Object type %{LSobject} unknown (Relation : %{relation})."
msgstr "" msgstr ""
"LSsession : La fonction de mise à jour de la relation %{relation} est " "LSsession : La fonction de mise à jour de la relation %{relation} est "
"inconnue." "inconnue."
#: includes/class/class.LSrelation.php:439 #: includes/class/class.LSrelation.php:464
msgid "" msgid ""
"LSrelation : Incomplete configuration for LSrelation %{relation} of object " "LSrelation : Incomplete configuration for LSrelation %{relation} of object "
"type %{LSobject} for action : %{action}." "type %{LSobject} for action : %{action}."
@ -1166,6 +1170,14 @@ msgstr ""
"LSrelation : Configuration incomplète de la LSrelation %{relation} du type " "LSrelation : Configuration incomplète de la LSrelation %{relation} du type "
"d'objet %{LSobject} pour l'action : %{action}." "d'objet %{LSobject} pour l'action : %{action}."
#: includes/class/class.LSrelation.php:467
msgid ""
"LSrelation : Invalid editable attribute for LSrelation %{relation} with "
"LSobject %{LSobject}."
msgstr ""
"LSrelation : Attribut éditable invalide pour la LSrelation %{relation} du "
"type d'objet %{LSobject}."
#: includes/class/class.LSformElement_password.php:134 #: includes/class/class.LSformElement_password.php:134
msgid "Generate a password." msgid "Generate a password."
msgstr "Générer un mot de passe." msgstr "Générer un mot de passe."

View file

@ -8,7 +8,7 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: PACKAGE VERSION\n" "Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n" "Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2017-06-15 18:19+0200\n" "POT-Creation-Date: 2017-08-02 11:53+0200\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n" "Language-Team: LANGUAGE <LL@li.org>\n"
@ -19,7 +19,7 @@ msgstr ""
#: view.php:44 modify.php:54 #: view.php:44 modify.php:54
#: includes/class/class.LSformElement_supannCompositeAttribute.php:106 #: includes/class/class.LSformElement_supannCompositeAttribute.php:106
#: includes/class/class.LSrelation.php:241 #: includes/class/class.LSrelation.php:259
#: includes/class/class.LSformElement_select_object.php:68 #: includes/class/class.LSformElement_select_object.php:68
#: includes/class/class.LSformElement_supannLabeledValue.php:62 #: includes/class/class.LSformElement_supannLabeledValue.php:62
#: includes/class/class.LSsearchEntry.php:163 #: includes/class/class.LSsearchEntry.php:163
@ -30,7 +30,7 @@ msgstr ""
msgid "Copy" msgid "Copy"
msgstr "" msgstr ""
#: view.php:60 modify.php:111 includes/class/class.LSrelation.php:198 #: view.php:60 modify.php:111 includes/class/class.LSrelation.php:216
#: includes/class/class.LSform.php:218 #: includes/class/class.LSform.php:218
#: includes/class/class.LSformElement_select_object.php:69 #: includes/class/class.LSformElement_select_object.php:69
#: includes/class/class.LSformElement_select_object.php:85 #: includes/class/class.LSformElement_select_object.php:85
@ -75,15 +75,15 @@ msgstr ""
msgid "Import" msgid "Import"
msgstr "" msgstr ""
#: create.php:53 #: create.php:75
msgid "Data entry form" msgid "Data entry form"
msgstr "" msgstr ""
#: create.php:59 #: create.php:81
msgid "Object has been added." msgid "Object has been added."
msgstr "" msgstr ""
#: create.php:98 #: create.php:120 includes/class/class.LSrelation.php:265
msgid "New" msgid "New"
msgstr "" msgstr ""
@ -707,6 +707,10 @@ msgstr ""
msgid "LSsession : view function %{func} for LSaddon %{addon} doet not exist." msgid "LSsession : view function %{func} for LSaddon %{addon} doet not exist."
msgstr "" msgstr ""
#: includes/class/class.LSsession.php:2458
msgid "LSsession : invalid related object's DN pass in parameter."
msgstr ""
#: includes/class/class.LSldapObject.php:470 #: includes/class/class.LSldapObject.php:470
msgid "The attribute %{attr} is not valid." msgid "The attribute %{attr} is not valid."
msgstr "" msgstr ""
@ -920,80 +924,86 @@ msgstr ""
msgid "LSldap : Error while changing the DN of the object." msgid "LSldap : Error while changing the DN of the object."
msgstr "" msgstr ""
#: includes/class/class.LSrelation.php:51 #: includes/class/class.LSrelation.php:69
#: includes/class/class.LSrelation.php:58 #: includes/class/class.LSrelation.php:76
msgid "listing related objects" msgid "listing related objects"
msgstr "" msgstr ""
#: includes/class/class.LSrelation.php:85 #: includes/class/class.LSrelation.php:103
#: includes/class/class.LSrelation.php:91 #: includes/class/class.LSrelation.php:109
msgid "getting key value" msgid "getting key value"
msgstr "" msgstr ""
#: includes/class/class.LSrelation.php:116 #: includes/class/class.LSrelation.php:134
#: includes/class/class.LSrelation.php:123 #: includes/class/class.LSrelation.php:141
#: includes/class/class.LSrelation.php:156 #: includes/class/class.LSrelation.php:174
msgid "checking right on relation with specific object" msgid "checking right on relation with specific object"
msgstr "" msgstr ""
#: includes/class/class.LSrelation.php:132 #: includes/class/class.LSrelation.php:150
msgid "deleting" msgid "deleting"
msgstr "" msgstr ""
#: includes/class/class.LSrelation.php:139 #: includes/class/class.LSrelation.php:157
msgid "removing relation with specific object" msgid "removing relation with specific object"
msgstr "" msgstr ""
#: includes/class/class.LSrelation.php:149 #: includes/class/class.LSrelation.php:167
msgid "renaming" msgid "renaming"
msgstr "" msgstr ""
#: includes/class/class.LSrelation.php:168 #: includes/class/class.LSrelation.php:186
msgid "updating" msgid "updating"
msgstr "" msgstr ""
#: includes/class/class.LSrelation.php:174 #: includes/class/class.LSrelation.php:192
msgid "updating relations" msgid "updating relations"
msgstr "" msgstr ""
#: includes/class/class.LSrelation.php:196 includes/class/class.LSform.php:216 #: includes/class/class.LSrelation.php:214 includes/class/class.LSform.php:216
#: remove.php:49 #: remove.php:49
msgid "Do you really want to delete" msgid "Do you really want to delete"
msgstr "" msgstr ""
#: includes/class/class.LSrelation.php:197 #: includes/class/class.LSrelation.php:215
msgid "Warning" msgid "Warning"
msgstr "" msgstr ""
#: includes/class/class.LSrelation.php:225 #: includes/class/class.LSrelation.php:243
#: includes/class/class.LSrelation.php:339 #: includes/class/class.LSrelation.php:364
msgid "No object." msgid "No object."
msgstr "" msgstr ""
#: includes/class/class.LSrelation.php:427 #: includes/class/class.LSrelation.php:452
msgid "" msgid ""
"LSrelation : The function %{function} for action '%{action}' on the relation " "LSrelation : The function %{function} for action '%{action}' on the relation "
"%{relation} is unknow." "%{relation} is unknown."
msgstr "" msgstr ""
#: includes/class/class.LSrelation.php:430 #: includes/class/class.LSrelation.php:455
msgid "LSrelation : Relation %{relation} of object type %{LSobject} unknow." msgid "LSrelation : Relation %{relation} of object type %{LSobject} unknown."
msgstr "" msgstr ""
#: includes/class/class.LSrelation.php:433 #: includes/class/class.LSrelation.php:458
msgid "LSrelation : Error during relation update of the relation %{relation}." msgid "LSrelation : Error during relation update of the relation %{relation}."
msgstr "" msgstr ""
#: includes/class/class.LSrelation.php:436 #: includes/class/class.LSrelation.php:461
msgid "LSrelation : Object type %{LSobject} unknow (Relation : %{relation})." msgid "LSrelation : Object type %{LSobject} unknown (Relation : %{relation})."
msgstr "" msgstr ""
#: includes/class/class.LSrelation.php:439 #: includes/class/class.LSrelation.php:464
msgid "" msgid ""
"LSrelation : Incomplete configuration for LSrelation %{relation} of object " "LSrelation : Incomplete configuration for LSrelation %{relation} of object "
"type %{LSobject} for action : %{action}." "type %{LSobject} for action : %{action}."
msgstr "" msgstr ""
#: includes/class/class.LSrelation.php:467
msgid ""
"LSrelation : Invalid editable attribute for LSrelation %{relation} with "
"LSobject %{LSobject}."
msgstr ""
#: includes/class/class.LSformElement_password.php:134 #: includes/class/class.LSformElement_password.php:134
msgid "Generate a password." msgid "Generate a password."
msgstr "" msgstr ""