Feat : ajout d'un argument id_document dans les options possibles de l'appel du formulaire bigform qui permet de faire la mise à jour du fichier de ce document à la place d'en créer un nouveau
This commit is contained in:
parent
40d61b2988
commit
b2232a9323
2 changed files with 23 additions and 13 deletions
|
@ -53,16 +53,19 @@ function formulaires_bigform_verifier_dist($objet, $id_objet, $mode = 'auto', $a
|
|||
|
||||
function formulaires_bigform_traiter_dist($objet = 'article', $id_objet = 0, $mode = 'auto', $args = []) {
|
||||
|
||||
$options_secu = [];
|
||||
$options = [];
|
||||
if (array_key_exists('proteger', $args)) {
|
||||
$options_secu['proteger'] = true;
|
||||
$options['proteger'] = true;
|
||||
}
|
||||
if (array_key_exists('obfusquer', $args)) {
|
||||
$options_secu['obfusquer'] = true;
|
||||
$options['obfusquer'] = true;
|
||||
}
|
||||
if (array_key_exists('id_document', $args) && intval($args['id_document'])) {
|
||||
$options['id_document'] = intval($args['id_document']);
|
||||
}
|
||||
|
||||
$bigform = charger_fonction('bigform_traiter','inc');
|
||||
$T = $bigform($id_objet,$objet,$mode, $options_secu);
|
||||
$T = $bigform($id_objet,$objet,$mode, $options);
|
||||
|
||||
pipeline('bigform_post_insertion', [
|
||||
'args' => [
|
||||
|
|
|
@ -10,24 +10,31 @@ if (!defined('_ECRIRE_INC_VERSION')){
|
|||
* @param $id_objet
|
||||
* @param $objet
|
||||
* @param $mode
|
||||
* @param array $options_secu['secu' => false, 'obfusquer' => false;]
|
||||
* @param array $options['secu' => false, 'obfusquer' => false, 'id_document' => ID du document pour lequel on va remplacer le fichier]
|
||||
* @return array tableau des id_document $Tid_doc
|
||||
*/
|
||||
function inc_bigform_traiter_dist($id_objet, $objet = 'article', $mode = 'auto', $options_secu = false) {
|
||||
function inc_bigform_traiter_dist($id_objet, $objet = 'article', $mode = 'auto', $options = false) {
|
||||
include_spip('inc/joindre_document');
|
||||
include_spip('inc/autoriser');
|
||||
|
||||
$proteger = false;
|
||||
$obfusquer = false;
|
||||
if (is_array($options_secu)) {
|
||||
if (array_key_exists('proteger', $options_secu)) {
|
||||
$proteger = $options_secu['proteger'];
|
||||
$id_document = 'new';
|
||||
if (is_array($options)) {
|
||||
if (array_key_exists('proteger', $options)) {
|
||||
$proteger = $options['proteger'];
|
||||
}
|
||||
if (array_key_exists('obfusquer', $options_secu)) {
|
||||
$obfusquer = $options_secu['obfusquer'];
|
||||
if (array_key_exists('obfusquer', $options)) {
|
||||
$obfusquer = $options['obfusquer'];
|
||||
}
|
||||
if (array_key_exists('id_document', $options)
|
||||
&& $options['id_document'] == intval($options['id_document'])
|
||||
&& intval($options['id_document'])
|
||||
) {
|
||||
$id_document = $options['id_document'];
|
||||
}
|
||||
} else {
|
||||
if ($options_secu) {
|
||||
if ($options) {
|
||||
$proteger = true;
|
||||
}
|
||||
}
|
||||
|
@ -81,7 +88,7 @@ function inc_bigform_traiter_dist($id_objet, $objet = 'article', $mode = 'auto',
|
|||
$autorisation_temp = true;
|
||||
}
|
||||
$ajouter_document = charger_fonction('ajouter_documents', 'action');
|
||||
$Tid_doc = $ajouter_document('new', $files, $objet, $id_objet, $mode);
|
||||
$Tid_doc = $ajouter_document($id_document, $files, $objet, $id_objet, $mode);
|
||||
if ($autorisation_temp) {
|
||||
autoriser_exception('associerdocuments', $type, $id_objet, false);
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue