From 4a2610e2997aada07eb08048e85e314d214c3418 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Sun, 3 Jul 2011 08:55:46 +0000 Subject: [PATCH 01/26] Fix: uniformize code --- htdocs/societe/document.php | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/htdocs/societe/document.php b/htdocs/societe/document.php index fef3f1edb2d..ed7115063da 100644 --- a/htdocs/societe/document.php +++ b/htdocs/societe/document.php @@ -23,7 +23,7 @@ * \file htdocs/societe/document.php * \brief Tab for documents linked to third party * \ingroup societe - * \version $Id$ + * \version $Id: document.php,v 1.30 2011/07/03 08:55:46 hregis Exp $ */ require("../main.inc.php"); @@ -38,7 +38,7 @@ $langs->load('other'); $mesg = ""; // Security check -$socid = isset($_GET["socid"])?$_GET["socid"]:(! empty($_GET["id"])?$_GET["id"]:''); +$socid = (GETPOST('socid') ? GETPOST('socid') : GETPOST('id')); if ($user->societe_id > 0) { unset($_GET["action"]); @@ -61,6 +61,7 @@ if (! $sortfield) $sortfield="name"; $upload_dir = $conf->societe->dir_output . "/" . $socid ; $courrier_dir = $conf->societe->dir_output . "/courrier/" . get_exdir($socid) ; +$object = new Societe($db); /* * Actions @@ -125,14 +126,13 @@ llxHeader('',$langs->trans("ThirdParty").' - '.$langs->trans("Files"),$help_url) if ($socid > 0) { - $societe = new Societe($db); - if ($societe->fetch($socid)) + if ($object->fetch($socid)) { /* * Affichage onglets */ if ($conf->notification->enabled) $langs->load("mails"); - $head = societe_prepare_head($societe); + $head = societe_prepare_head($object); $html=new Form($db); @@ -153,30 +153,30 @@ if ($socid > 0) // Ref print ''.$langs->trans("ThirdPartyName").''; print ''; - print $form->showrefnav($societe,'socid','',($user->societe_id?0:1),'rowid','nom'); + print $form->showrefnav($object,'socid','',($user->societe_id?0:1),'rowid','nom'); print ''; // Prefix if (! empty($conf->global->SOCIETE_USEPREFIX)) // Old not used prefix field { - print ''.$langs->trans('Prefix').''.$societe->prefix_comm.''; + print ''.$langs->trans('Prefix').''.$object->prefix_comm.''; } - if ($societe->client) + if ($object->client) { print ''; print $langs->trans('CustomerCode').''; - print $societe->code_client; - if ($societe->check_codeclient() <> 0) print ' ('.$langs->trans("WrongCustomerCode").')'; + print $object->code_client; + if ($object->check_codeclient() <> 0) print ' ('.$langs->trans("WrongCustomerCode").')'; print ''; } - if ($societe->fournisseur) + if ($object->fournisseur) { print ''; print $langs->trans('SupplierCode').''; - print $societe->code_fournisseur; - if ($societe->check_codefournisseur() <> 0) print ' ('.$langs->trans("WrongSupplierCode").')'; + print $object->code_fournisseur; + if ($object->check_codefournisseur() <> 0) print ' ('.$langs->trans("WrongSupplierCode").')'; print ''; } @@ -190,7 +190,7 @@ if ($socid > 0) print ''; - if ($mesg) { print "$mesg
"; } + dol_htmloutput_mesg($mesg,$mesgs); /* * Confirmation suppression fichier @@ -208,8 +208,8 @@ if ($socid > 0) // List of document - $param='&socid='.$societe->id; - $formfile->list_of_documents($filearray,$societe,'societe',$param); + $param='&socid='.$object->id; + $formfile->list_of_documents($filearray,$object,'societe',$param); print "

"; @@ -268,12 +268,12 @@ if ($socid > 0) } else { - dol_print_error(); + accessforbidden('',0,0); } $db->close(); -llxFooter('$Date$ - $Revision$'); +llxFooter('$Date: 2011/07/03 08:55:46 $ - $Revision: 1.30 $'); ?> From 1d45ad79011a45450c6b150f27db3562a41f566a Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 3 Jul 2011 12:53:37 +0000 Subject: [PATCH 02/26] Fix: Do not show warning for event finished --- htdocs/includes/boxes/box_actions.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/includes/boxes/box_actions.php b/htdocs/includes/boxes/box_actions.php index 9d7686a0ff9..82ec7f2f43a 100644 --- a/htdocs/includes/boxes/box_actions.php +++ b/htdocs/includes/boxes/box_actions.php @@ -21,8 +21,8 @@ /** * \file htdocs/includes/boxes/box_actions.php * \ingroup actions - * \brief Module de generation de l'affichage de la box actions - * \version $Id$ + * \brief Module to build boxe for events + * \version $Id: box_actions.php,v 1.47 2011/07/03 12:53:37 eldy Exp $ */ include_once(DOL_DOCUMENT_ROOT."/includes/boxes/modules_boxes.php"); @@ -100,7 +100,7 @@ class box_actions extends ModeleBoxes { $objp = $db->fetch_object($result); $datelimite=$db->jdate($objp->dp); - if ($datelimite < ($now - $delay_warning)) $late=img_warning($langs->trans("Late")); + if ($objp->percentage >= 0 && $objp->percentage < 100 && $datelimite < ($now - $delay_warning)) $late=img_warning($langs->trans("Late")); //($langs->transnoentities("Action".$objp->code)!=("Action".$objp->code) ? $langs->transnoentities("Action".$objp->code) : $objp->label) $label=$objp->label; From c4959b8f8b8b463e5da561a3f6ebe3f45cf33657 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 3 Jul 2011 12:55:33 +0000 Subject: [PATCH 03/26] Fix: Do not show warning for event finished --- htdocs/includes/boxes/box_actions.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/includes/boxes/box_actions.php b/htdocs/includes/boxes/box_actions.php index 82ec7f2f43a..c09d95ecf16 100644 --- a/htdocs/includes/boxes/box_actions.php +++ b/htdocs/includes/boxes/box_actions.php @@ -22,7 +22,7 @@ * \file htdocs/includes/boxes/box_actions.php * \ingroup actions * \brief Module to build boxe for events - * \version $Id: box_actions.php,v 1.47 2011/07/03 12:53:37 eldy Exp $ + * \version $Id: box_actions.php,v 1.48 2011/07/03 12:55:33 eldy Exp $ */ include_once(DOL_DOCUMENT_ROOT."/includes/boxes/modules_boxes.php"); @@ -79,7 +79,7 @@ class box_actions extends ModeleBoxes { $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON a.fk_soc = s.rowid AND s.entity IN (0, ".$conf->entity.")"; $sql.= " WHERE a.fk_action = ta.id"; $sql.= " AND a.entity = ".$conf->entity; - $sql.= " AND a.percent <> 100"; + $sql.= " AND a.percent >= 0 AND a.percent < 100"; if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; if($user->societe_id) $sql.= " AND s.rowid = ".$user->societe_id; $sql.= " ORDER BY a.datec DESC"; From 518a6f64a416ca185c5c770fde24eecd0c8e8a4d Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Sun, 3 Jul 2011 13:16:46 +0000 Subject: [PATCH 04/26] Works on jQuery file upload --- htdocs/core/ajaxfileupload.php | 348 ++++++++++++++++++++++ htdocs/core/class/html.formfile.class.php | 85 +++++- htdocs/core/tpl/ajaxfileupload.tpl.php | 86 ++++++ htdocs/main.inc.php | 15 +- htdocs/societe/document.php | 30 +- 5 files changed, 550 insertions(+), 14 deletions(-) create mode 100644 htdocs/core/ajaxfileupload.php create mode 100644 htdocs/core/tpl/ajaxfileupload.tpl.php diff --git a/htdocs/core/ajaxfileupload.php b/htdocs/core/ajaxfileupload.php new file mode 100644 index 00000000000..b4de16856fd --- /dev/null +++ b/htdocs/core/ajaxfileupload.php @@ -0,0 +1,348 @@ +fk_element=$fk_element; + $this->element=$element; + + $this->options = array( + 'script_url' => $_SERVER['PHP_SELF'], + 'upload_dir' => $conf->$element->dir_output . '/' . $fk_element . '/', + 'upload_url' => DOL_URL_ROOT.'/document.php?modulepart='.$element.'&attachment=1&file=/'.$fk_element.'/', + 'param_name' => 'files', + // The php.ini settings upload_max_filesize and post_max_size + // take precedence over the following max_file_size setting: + 'max_file_size' => null, + 'min_file_size' => 1, + 'accept_file_types' => '/.+$/i', + 'max_number_of_files' => null, + 'discard_aborted_uploads' => true, + 'image_versions' => array( + // Uncomment the following version to restrict the size of + // uploaded images. You can also add additional versions with + // their own upload directories: + /* + 'large' => array( + 'upload_dir' => dirname(__FILE__).'/files/', + 'upload_url' => dirname($_SERVER['PHP_SELF']).'/files/', + 'max_width' => 1920, + 'max_height' => 1200 + ), + */ + 'thumbnail' => array( + 'upload_dir' => $conf->$element->dir_output . '/' . $fk_element . '/thumbs/', + 'upload_url' => DOL_URL_ROOT.'/document.php?modulepart='.$element.'&attachment=1&file=/'.$fk_element.'/thumbs/', + 'max_width' => 40, + 'max_height' => 40 + ) + ) + ); + if ($options) { + $this->options = array_merge_recursive($this->options, $options); + } + } + + private function get_file_object($file_name) { + $file_path = $this->options['upload_dir'].$file_name; + if (is_file($file_path) && $file_name[0] !== '.') { + $file = new stdClass(); + $file->name = $file_name; + $file->mime = dol_mimetype($file_name,'',2); + $file->size = filesize($file_path); + $file->url = $this->options['upload_url'].rawurlencode($file->name); + foreach($this->options['image_versions'] as $version => $options) { + if (is_file($options['upload_dir'].$file_name)) { + $file->{$version.'_url'} = $options['upload_url'] + .rawurlencode($file->name); + } + } + $file->delete_url = $this->options['script_url'] + .'?file='.rawurlencode($file->name).'fk_element='.$this->fk_elment.'&element='.$this->element; + $file->delete_type = 'DELETE'; + return $file; + } + return null; + } + + private function get_file_objects() { + return array_values(array_filter(array_map( + array($this, 'get_file_object'), + scandir($this->options['upload_dir']) + ))); + } + + private function create_scaled_image($file_name, $options) { + $file_path = $this->options['upload_dir'].$file_name; + $new_file_path = $options['upload_dir'].$file_name; + list($img_width, $img_height) = @getimagesize($file_path); + if (!$img_width || !$img_height) { + return false; + } + $scale = min( + $options['max_width'] / $img_width, + $options['max_height'] / $img_height + ); + if ($scale > 1) { + $scale = 1; + } + $new_width = $img_width * $scale; + $new_height = $img_height * $scale; + $new_img = @imagecreatetruecolor($new_width, $new_height); + switch (strtolower(substr(strrchr($file_name, '.'), 1))) { + case 'jpg': + case 'jpeg': + $src_img = @imagecreatefromjpeg($file_path); + $write_image = 'imagejpeg'; + break; + case 'gif': + $src_img = @imagecreatefromgif($file_path); + $write_image = 'imagegif'; + break; + case 'png': + $src_img = @imagecreatefrompng($file_path); + $write_image = 'imagepng'; + break; + default: + $src_img = $image_method = null; + } + $success = $src_img && @imagecopyresampled( + $new_img, + $src_img, + 0, 0, 0, 0, + $new_width, + $new_height, + $img_width, + $img_height + ) && $write_image($new_img, $new_file_path); + // Free up memory (imagedestroy does not delete files): + @imagedestroy($src_img); + @imagedestroy($new_img); + return $success; + } + + private function has_error($uploaded_file, $file, $error) { + if ($error) { + return $error; + } + if (!preg_match($this->options['accept_file_types'], $file->name)) { + return 'acceptFileTypes'; + } + if ($uploaded_file && is_uploaded_file($uploaded_file)) { + $file_size = filesize($uploaded_file); + } else { + $file_size = $_SERVER['CONTENT_LENGTH']; + } + if ($this->options['max_file_size'] && ( + $file_size > $this->options['max_file_size'] || + $file->size > $this->options['max_file_size']) + ) { + return 'maxFileSize'; + } + if ($this->options['min_file_size'] && + $file_size < $this->options['min_file_size']) { + return 'minFileSize'; + } + if (is_int($this->options['max_number_of_files']) && ( + count($this->get_file_objects()) >= $this->options['max_number_of_files']) + ) { + return 'maxNumberOfFiles'; + } + return $error; + } + + private function handle_file_upload($uploaded_file, $name, $size, $type, $error) { + $file = new stdClass(); + $file->name = basename(stripslashes($name)); + $file->size = intval($size); + $file->type = $type; + $error = $this->has_error($uploaded_file, $file, $error); + if (!$error && $file->name) { + if ($file->name[0] === '.') { + $file->name = substr($file->name, 1); + } + $file_path = $this->options['upload_dir'].$file->name; + $append_file = is_file($file_path) && $file->size > filesize($file_path); + clearstatcache(); + if ($uploaded_file && is_uploaded_file($uploaded_file)) { + // multipart/formdata uploads (POST method uploads) + if ($append_file) { + file_put_contents( + $file_path, + fopen($uploaded_file, 'r'), + FILE_APPEND + ); + } else { + move_uploaded_file($uploaded_file, $file_path); + } + } else { + // Non-multipart uploads (PUT method support) + file_put_contents( + $file_path, + fopen('php://input', 'r'), + $append_file ? FILE_APPEND : 0 + ); + } + $file_size = filesize($file_path); + if ($file_size === $file->size) { + $file->url = $this->options['upload_url'].rawurlencode($file->name); + foreach($this->options['image_versions'] as $version => $options) { + if ($this->create_scaled_image($file->name, $options)) { + $file->{$version.'_url'} = $options['upload_url'] + .rawurlencode($file->name); + } + } + } else if ($this->options['discard_aborted_uploads']) { + unlink($file_path); + $file->error = 'abort'; + } + $file->size = $file_size; + $file->delete_url = $this->options['script_url'] + .'?file='.rawurlencode($file->name); + $file->delete_type = 'DELETE'; + } else { + $file->error = $error; + } + return $file; + } + + public function get() { + $file_name = isset($_REQUEST['file']) ? + basename(stripslashes($_REQUEST['file'])) : null; + if ($file_name) { + $info = $this->get_file_object($file_name); + } else { + $info = $this->get_file_objects(); + } + header('Content-type: application/json'); + echo json_encode($info); + } + + public function post() { + $upload = isset($_FILES[$this->options['param_name']]) ? + $_FILES[$this->options['param_name']] : array( + 'tmp_name' => null, + 'name' => null, + 'size' => null, + 'type' => null, + 'error' => null + ); + $info = array(); + if (is_array($upload['tmp_name'])) { + foreach ($upload['tmp_name'] as $index => $value) { + $info[] = $this->handle_file_upload( + $upload['tmp_name'][$index], + isset($_SERVER['HTTP_X_FILE_NAME']) ? + $_SERVER['HTTP_X_FILE_NAME'] : $upload['name'][$index], + isset($_SERVER['HTTP_X_FILE_SIZE']) ? + $_SERVER['HTTP_X_FILE_SIZE'] : $upload['size'][$index], + isset($_SERVER['HTTP_X_FILE_TYPE']) ? + $_SERVER['HTTP_X_FILE_TYPE'] : $upload['type'][$index], + $upload['error'][$index] + ); + } + } else { + $info[] = $this->handle_file_upload( + $upload['tmp_name'], + isset($_SERVER['HTTP_X_FILE_NAME']) ? + $_SERVER['HTTP_X_FILE_NAME'] : $upload['name'], + isset($_SERVER['HTTP_X_FILE_SIZE']) ? + $_SERVER['HTTP_X_FILE_SIZE'] : $upload['size'], + isset($_SERVER['HTTP_X_FILE_TYPE']) ? + $_SERVER['HTTP_X_FILE_TYPE'] : $upload['type'], + $upload['error'] + ); + } + header('Vary: Accept'); + if (isset($_SERVER['HTTP_ACCEPT']) && + (strpos($_SERVER['HTTP_ACCEPT'], 'application/json') !== false)) { + header('Content-type: application/json'); + } else { + header('Content-type: text/plain'); + } + echo json_encode($info); + } + + public function delete() { + $file_name = isset($_REQUEST['file']) ? + basename(stripslashes($_REQUEST['file'])) : null; + $file_path = $this->options['upload_dir'].$file_name; + $success = is_file($file_path) && $file_name[0] !== '.' && unlink($file_path); + if ($success) { + foreach($this->options['image_versions'] as $version => $options) { + $file = $options['upload_dir'].$file_name; + if (is_file($file)) { + unlink($file); + } + } + } + header('Content-type: application/json'); + echo json_encode($success); + } +} + +$upload_handler = new UploadHandler(null,$fk_element,$element); + +header('Pragma: no-cache'); +header('Cache-Control: private, no-cache'); +header('Content-Disposition: inline; filename="files.json"'); + +switch ($_SERVER['REQUEST_METHOD']) { + case 'HEAD': + case 'GET': + $upload_handler->get(); + break; + case 'POST': + $upload_handler->post(); + break; + case 'DELETE': + $upload_handler->delete(); + break; + default: + header('HTTP/1.0 405 Method Not Allowed'); +} +?> \ No newline at end of file diff --git a/htdocs/core/class/html.formfile.class.php b/htdocs/core/class/html.formfile.class.php index 7c054b43622..85f1b7e05bf 100644 --- a/htdocs/core/class/html.formfile.class.php +++ b/htdocs/core/class/html.formfile.class.php @@ -22,7 +22,7 @@ * \file htdocs/core/class/html.formfile.class.php * \ingroup core * \brief File of class to offer components to list and upload files - * \version $Id: html.formfile.class.php,v 1.34 2011/06/30 13:27:20 hregis Exp $ + * \version $Id: html.formfile.class.php,v 1.35 2011/07/03 13:16:46 hregis Exp $ */ @@ -732,6 +732,89 @@ class FormFile // Fin de zone } + /** + * Show form to upload a new file with jquery fileupload + */ + function form_ajaxfileupload($object) + { + global $langs; + + print ''; + + print '
'; + print '
'; + print ''; + print ''; + print '
'; + print ''; + print ''; + print ''; + print ''; + print '
'; + print '
'; + print ''; + print '
'; + print '
'; + print '
'; + print '
'; + + // Include template + include(DOL_DOCUMENT_ROOT.'/core/tpl/ajaxfileupload.tpl.php'); + + } } diff --git a/htdocs/core/tpl/ajaxfileupload.tpl.php b/htdocs/core/tpl/ajaxfileupload.tpl.php new file mode 100644 index 00000000000..d595dec1c68 --- /dev/null +++ b/htdocs/core/tpl/ajaxfileupload.tpl.php @@ -0,0 +1,86 @@ + + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + * $Id: ajaxfileupload.tpl.php,v 1.1 2011/07/03 13:16:46 hregis Exp $ + */ +?> + + + + + + \ No newline at end of file diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php index 8fbf3a01061..7054204a43f 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -26,7 +26,7 @@ * \file htdocs/main.inc.php * \ingroup core * \brief File that defines environment for Dolibarr pages only (variables not required by scripts) - * \version $Id: main.inc.php,v 1.747 2011/07/02 05:49:56 hregis Exp $ + * \version $Id: main.inc.php,v 1.748 2011/07/03 13:16:46 hregis Exp $ */ @ini_set('memory_limit', '64M'); // This may be useless if memory is hard limited by your PHP @@ -908,6 +908,11 @@ function top_htmlhead($head, $title='', $disablejs=0, $disablehead=0, $arrayofjs print ''."\n"; // Tooltip print ''."\n"; // JNotify //print ''."\n"; // Lightbox + // jQuery fileupload + if (! empty($conf->global->MAIN_USE_JQUERY_FILEUPLOAD)) + { + print ''."\n"; + } } print ''."\n"; @@ -977,6 +982,14 @@ function top_htmlhead($head, $title='', $disablejs=0, $disablehead=0, $arrayofjs print ''."\n"; print ''."\n"; } + // File Upload + if (! empty($conf->global->MAIN_USE_JQUERY_FILEUPLOAD)) + { + print ''."\n"; + print ''."\n"; + print ''."\n"; + print ''."\n"; + } // Global js function print ''."\n"; print ''."\n"; diff --git a/htdocs/societe/document.php b/htdocs/societe/document.php index ed7115063da..e496d064662 100644 --- a/htdocs/societe/document.php +++ b/htdocs/societe/document.php @@ -23,7 +23,7 @@ * \file htdocs/societe/document.php * \brief Tab for documents linked to third party * \ingroup societe - * \version $Id: document.php,v 1.30 2011/07/03 08:55:46 hregis Exp $ + * \version $Id: document.php,v 1.31 2011/07/03 13:16:46 hregis Exp $ */ require("../main.inc.php"); @@ -200,17 +200,23 @@ if ($socid > 0) $ret=$html->form_confirm($_SERVER["PHP_SELF"].'?socid='.$_GET["id"].'&urlfile='.urldecode($_GET["urlfile"]), $langs->trans('DeleteFile'), $langs->trans('ConfirmDeleteFile'), 'confirm_deletefile', '', 0, 1); if ($ret == 'html') print '
'; } - - - // Affiche formulaire upload + $formfile=new FormFile($db); - $formfile->form_attach_new_file($_SERVER["PHP_SELF"].'?socid='.$socid,'',0,0,$user->rights->societe->creer); - - - // List of document - $param='&socid='.$object->id; - $formfile->list_of_documents($filearray,$object,'societe',$param); - + + if ($conf->global->MAIN_USE_JQUERY_FILEUPLOAD) + { + $formfile->form_ajaxfileupload($object); + } + else + { + // Affiche formulaire upload + $formfile->form_attach_new_file($_SERVER["PHP_SELF"].'?socid='.$socid,'',0,0,$user->rights->societe->creer); + + + // List of document + $param='&socid='.$object->id; + $formfile->list_of_documents($filearray,$object,'societe',$param); + } print "

"; @@ -274,6 +280,6 @@ else $db->close(); -llxFooter('$Date: 2011/07/03 08:55:46 $ - $Revision: 1.30 $'); +llxFooter('$Date: 2011/07/03 13:16:46 $ - $Revision: 1.31 $'); ?> From f9100553587d4b8100b75d39c4e2037d2faee5a7 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Sun, 3 Jul 2011 13:26:45 +0000 Subject: [PATCH 05/26] Works on jQuery file upload --- htdocs/core/ajaxfileupload.php | 2 +- htdocs/core/tpl/ajaxfileupload.tpl.php | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/core/ajaxfileupload.php b/htdocs/core/ajaxfileupload.php index b4de16856fd..db9546411ec 100644 --- a/htdocs/core/ajaxfileupload.php +++ b/htdocs/core/ajaxfileupload.php @@ -102,7 +102,7 @@ class UploadHandler } } $file->delete_url = $this->options['script_url'] - .'?file='.rawurlencode($file->name).'fk_element='.$this->fk_elment.'&element='.$this->element; + .'?file='.rawurlencode($file->name).'&fk_element='.$this->fk_element.'&element='.$this->element; $file->delete_type = 'DELETE'; return $file; } diff --git a/htdocs/core/tpl/ajaxfileupload.tpl.php b/htdocs/core/tpl/ajaxfileupload.tpl.php index d595dec1c68..5af9a455601 100644 --- a/htdocs/core/tpl/ajaxfileupload.tpl.php +++ b/htdocs/core/tpl/ajaxfileupload.tpl.php @@ -15,15 +15,15 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * - * $Id: ajaxfileupload.tpl.php,v 1.1 2011/07/03 13:16:46 hregis Exp $ + * $Id: ajaxfileupload.tpl.php,v 1.2 2011/07/03 13:26:45 hregis Exp $ */ ?> '."\n"; +} + + +print $langs->trans("BlankSubscriptionFormDesc").'

'; + +print '
'; +print ''; + +print ''; + +print ''; +print ''; +print ''; +print "\n"; +$var=true; + +// Allow public form +$var=! $var; +print ''; +print '\n"; +print ''; + +// Type +/*$var=! $var; +print ''; +print '\n"; */ + +// Amount +$var=! $var; +print ''; +print '\n"; + +// Can edit +$var=! $var; +print ''; +print '\n"; + +if ($conf->paybox->enabled || $conf->paypal->enabled) +{ + // Jump to an online payment page + $var=! $var; + print '\n"; +} + +print '
'.$langs->trans("Parameter").''.$langs->trans("Value").'
'; +print $langs->trans("EnablePublicSubscriptionForm"); +print ''; +print $form->selectyesno("MEMBER_ENABLE_PUBLIC",$conf->global->MEMBER_ENABLE_PUBLIC,1); +print "
'; +print $langs->trans("EnablePublicSubscriptionForm"); +print ''; +print $form->selectyesno("forcedate",$conf->global->MEMBER_NEWFORM_FORCETYPE,1); +print "
'; +print $langs->trans("DefaultAmount"); +print ''; +print '';; +print "
'; +print $langs->trans("CanEditAmount"); +print ''; +print $form->selectyesno("MEMBER_NEWFORM_EDITAMOUNT",$conf->global->MEMBER_NEWFORM_EDITAMOUNT,1); +print "
'; + print $langs->trans("MEMBER_NEWFORM_PAYONLINE"); + print ''; + $listofval=array(); + if ($conf->paybox->enabled) $listofval['paybox']='Paybox'; + if ($conf->paypal->enabled) $listofval['paypal']='PayPal'; + print $form->selectarray("MEMBER_NEWFORM_PAYONLINE",$listofval,$conf->global->MEMBER_NEWFORM_PAYONLINE,1); + print "
'; + +print '
'; +print ''; +print '
'; + +print ''; + +dol_fiche_end(); + + +print '
'; +//print $langs->trans('FollowingLinksArePublic').'
'; +print img_picto('','object_globe.png').' '.$langs->trans('BlankSubscriptionForm').':
'; +print ''.DOL_MAIN_URL_ROOT.'/public/members/new.php'.''; + +/* +print ''; +print ''; +print ''; +print ''; +print ''; +print '
'.$langs->trans("Description").''.$langs->trans("URL").'
'.$langs->trans("BlankSubscriptionForm").''..'
'.$langs->trans("PublicMemberList").''.img_picto('','object_globe.png').' '.''.DOL_MAIN_URL_ROOT.'/public/members/public_list.php'.'
'.$langs->trans("PublicMemberCard").''.img_picto('','object_globe.png').' '.DOL_MAIN_URL_ROOT.'/public/members/public_card.php?id=xxx'.'
'; +*/ + +$db->close(); + +llxFooter('$Date: 2011/07/03 16:00:19 $ - $Revision: 1.1 $'); +?> diff --git a/htdocs/adherents/public.php b/htdocs/adherents/public.php deleted file mode 100644 index 46d18c37c23..00000000000 --- a/htdocs/adherents/public.php +++ /dev/null @@ -1,62 +0,0 @@ - - * Copyright (C) 2006-2010 Laurent Destailleur - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ - -/** - * \file htdocs/adherents/public.php - * \ingroup member - * \brief File of main public page for member module - * \author Laurent Destailleur - * \version $Id$ - */ - -require("../main.inc.php"); - - - -/* - * View - */ - -llxHeader(); - -print_fiche_titre($langs->trans("PublicMembersArea")); - - -print ''; - -print '
'; - -print $langs->trans('FollowingLinksArePublic').'
'; -print '
'; - -print ''; -print ''; -print ''; -print ''; -print ''; -print '
'.$langs->trans("Description").''.$langs->trans("URL").'
'.$langs->trans("BlankSubscriptionForm").''.img_picto('','object_globe.png').' '.''.DOL_MAIN_URL_ROOT.'/public/members/new.php'.'
'.$langs->trans("PublicMemberList").''.img_picto('','object_globe.png').' '.''.DOL_MAIN_URL_ROOT.'/public/members/public_list.php'.'
'.$langs->trans("PublicMemberCard").''.img_picto('','object_globe.png').' '.DOL_MAIN_URL_ROOT.'/public/members/public_card.php?id=xxx'.'
'; - - -print '
'; - - -$db->close(); - -llxFooter('$Date$ - $Revision$'); -?> diff --git a/htdocs/includes/menus/init_menu_auguria.sql b/htdocs/includes/menus/init_menu_auguria.sql index dec3ccbf2b7..f9b90c48d5f 100644 --- a/htdocs/includes/menus/init_menu_auguria.sql +++ b/htdocs/includes/menus/init_menu_auguria.sql @@ -1,6 +1,6 @@ -- --- $Id: init_menu_auguria.sql,v 1.118 2011/06/29 17:55:34 eldy Exp $ --- $Revision: 1.118 $ +-- $Id: init_menu_auguria.sql,v 1.119 2011/07/03 16:00:20 eldy Exp $ +-- $Revision: 1.119 $ -- -- Menu base entries -- This file is loaded when a menu handler base is activated (auguria, etc..) @@ -263,7 +263,6 @@ insert into llx_menu (enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk insert into llx_menu (enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('$conf->adherent->enabled && $conf->export->enabled', __HANDLER__, 'left', 4501__+MAX_llx_menu__, 'members', '', 4500__+MAX_llx_menu__, '/exports/index.php?leftmenu=export', 'Datas', 1, 'members', '$user->rights->adherent->export', '', 2, 0, __ENTITY__); insert into llx_menu (enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('$conf->adherent->enabled', __HANDLER__, 'left', 4502__+MAX_llx_menu__, 'members', '', 4500__+MAX_llx_menu__, '/adherents/htpasswd.php?leftmenu=export', 'Filehtpasswd', 1, 'members', '$user->rights->adherent->export', '', 2, 1, __ENTITY__); insert into llx_menu (enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('$conf->adherent->enabled', __HANDLER__, 'left', 4503__+MAX_llx_menu__, 'members', '', 4500__+MAX_llx_menu__, '/adherents/cartes/carte.php?leftmenu=export', 'MembersCards', 1, 'members', '$user->rights->adherent->export', '', 2, 2, __ENTITY__); -insert into llx_menu (enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('$conf->adherent->enabled', __HANDLER__, 'left', 4600__+MAX_llx_menu__, 'members', '', 13__+MAX_llx_menu__, '/adherents/public.php?leftmenu=member_public', 'MemberPublicLinks', 0, 'members', '$user->rights->adherent->export', '', 2, 4, __ENTITY__); insert into llx_menu (enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('$conf->adherent->enabled', __HANDLER__, 'left', 4700__+MAX_llx_menu__, 'members', '', 13__+MAX_llx_menu__, '/adherents/type.php?leftmenu=setup&mainmenu=members', 'MembersType', 0, 'members', '$user->rights->adherent->configurer', '', 2, 5, __ENTITY__); insert into llx_menu (enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('$conf->adherent->enabled', __HANDLER__, 'left', 4701__+MAX_llx_menu__, 'members', '', 4700__+MAX_llx_menu__, '/adherents/type.php?leftmenu=setup&mainmenu=members&action=create', 'New', 1, 'members', '$user->rights->adherent->configurer', '', 2, 0, __ENTITY__); insert into llx_menu (enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('$conf->adherent->enabled', __HANDLER__, 'left', 4702__+MAX_llx_menu__, 'members', '', 4700__+MAX_llx_menu__, '/adherents/type.php?leftmenu=setup&mainmenu=members', 'List', 1, 'members', '$user->rights->adherent->configurer', '', 2, 1, __ENTITY__); diff --git a/htdocs/includes/menus/init_menu_smartphone.sql b/htdocs/includes/menus/init_menu_smartphone.sql index 8cf20414457..030c471d50b 100755 --- a/htdocs/includes/menus/init_menu_smartphone.sql +++ b/htdocs/includes/menus/init_menu_smartphone.sql @@ -1,6 +1,6 @@ -- --- $Id$ --- $Revision$ +-- $Id: init_menu_smartphone.sql,v 1.7 2011/07/03 16:00:20 eldy Exp $ +-- $Revision: 1.7 $ -- -- Menu base entries -- This file is loaded when a menu handler base is activated (auguria, etc..) @@ -281,7 +281,6 @@ insert into llx_menu (enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk insert into llx_menu (enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('$conf->adherent->enabled && $conf->export->enabled', __HANDLER__, 'left', 4501__+MAX_llx_menu__, 'members', '', 4500__+MAX_llx_menu__, '/exports/index.php?leftmenu=export', 'Datas', 1, 'members', '$user->rights->adherent->export', '', 2, 0, __ENTITY__); insert into llx_menu (enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('$conf->adherent->enabled', __HANDLER__, 'left', 4502__+MAX_llx_menu__, 'members', '', 4500__+MAX_llx_menu__, '/adherents/htpasswd.php?leftmenu=export', 'Filehtpasswd', 1, 'members', '$user->rights->adherent->export', '', 2, 1, __ENTITY__); insert into llx_menu (enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('$conf->adherent->enabled', __HANDLER__, 'left', 4503__+MAX_llx_menu__, 'members', '', 4500__+MAX_llx_menu__, '/adherents/cartes/carte.php?leftmenu=export', 'MembersCards', 1, 'members', '$user->rights->adherent->export', '', 2, 2, __ENTITY__); -insert into llx_menu (enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('$conf->adherent->enabled', __HANDLER__, 'left', 4600__+MAX_llx_menu__, 'members', '', 13__+MAX_llx_menu__, '/adherents/public.php?leftmenu=member_public', 'MemberPublicLinks', 0, 'members', '$user->rights->adherent->export', '', 2, 4, __ENTITY__); insert into llx_menu (enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('$conf->adherent->enabled', __HANDLER__, 'left', 4700__+MAX_llx_menu__, 'members', '', 13__+MAX_llx_menu__, '/adherents/index.php?leftmenu=setup&mainmenu=members', 'Setup', 0, 'members', '$user->rights->adherent->configurer', '', 2, 5, __ENTITY__); insert into llx_menu (enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('$conf->adherent->enabled', __HANDLER__, 'left', 4701__+MAX_llx_menu__, 'members', '', 4700__+MAX_llx_menu__, '/adherents/type.php?leftmenu=setup', 'MembersTypes', 1, 'members', '$user->rights->adherent->configurer', '', 2, 0, __ENTITY__); insert into llx_menu (enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('$conf->adherent->enabled', __HANDLER__, 'left', 4702__+MAX_llx_menu__, 'members', '', 4700__+MAX_llx_menu__, '/adherents/options.php?leftmenu=setup', 'MembersAttributes', 1, 'members', '$user->rights->adherent->configurer', '', 2, 1, __ENTITY__); diff --git a/htdocs/includes/menus/standard/eldy.lib.php b/htdocs/includes/menus/standard/eldy.lib.php index 79a43e43887..3cf07c4dc17 100644 --- a/htdocs/includes/menus/standard/eldy.lib.php +++ b/htdocs/includes/menus/standard/eldy.lib.php @@ -21,7 +21,7 @@ /** * \file htdocs/includes/menus/standard/eldy.lib.php * \brief Library for file eldy menus - * \version $Id: eldy.lib.php,v 1.53 2011/06/29 22:41:49 eldy Exp $ + * \version $Id: eldy.lib.php,v 1.54 2011/07/03 16:00:18 eldy Exp $ */ @@ -1301,7 +1301,6 @@ function print_left_eldy_menu($db,$menu_array_before,$menu_array_after) if ($leftmenu=="export") $newmenu->add("/adherents/htpasswd.php?leftmenu=export",$langs->trans("Filehtpasswd"),1,$user->rights->adherent->export); if ($leftmenu=="export") $newmenu->add("/adherents/cartes/carte.php?leftmenu=export",$langs->trans("MembersCards"),1,$user->rights->adherent->export); - $newmenu->add("/adherents/public.php?leftmenu=member_public",$langs->trans("MemberPublicLinks")); // Type $newmenu->add("/adherents/type.php?leftmenu=setup&mainmenu=members",$langs->trans("MembersTypes"),0,$user->rights->adherent->configurer); $newmenu->add("/adherents/type.php?leftmenu=setup&mainmenu=members&action=create",$langs->trans("New"),1,$user->rights->adherent->configurer); diff --git a/htdocs/langs/en_US/members.lang b/htdocs/langs/en_US/members.lang index ada92b09834..ee492c181b6 100644 --- a/htdocs/langs/en_US/members.lang +++ b/htdocs/langs/en_US/members.lang @@ -76,7 +76,7 @@ EditMember=Edit member SubscriptionEndDate=Subscription's end date MembersTypeSetup=Members type setup NewSubscription=New subscription -NewSubscriptionDesc=This form allows you to record your subscription as a new member of the foundation. If you want to renew your subscription being already a member, please contact foundation board instead. +NewSubscriptionDesc=This form allows you to record your subscription as a new member of the foundation. If you want to renew your subscription (if already a member), please contact foundation board instead. Subscription=Subscription Subscriptions=Subscriptions SubscriptionLate=Late @@ -109,7 +109,9 @@ ValidateMember=Validate a member ConfirmValidateMember=Are you sure you want to validate this member ? FollowingLinksArePublic=The following links are open pages not protected by any Dolibarr permission. They are not formated pages, provided as example to show how to list members database. PublicMemberList=Public member list -BlankSubscriptionForm=Subscription form +BlankSubscriptionForm=Public auto-subscription form +BlankSubscriptionFormDesc=Dolibarr can provide you a public URL to allow external visitors to ask to subscribe to the foundation. If an online payment module is enabled, a payment form will also be automatically provided. +EnablePublicSubscriptionForm=Enable the public auto-subscription form MemberPublicLinks=Public links/pages ExportDataset_member_1=Members and subscriptions ImportDataset_member_1=Members @@ -176,11 +178,14 @@ MembersStatisticsDesc=Choose statistics you want to read... MenuMembersStats=Statistics LastMemberDate=Last member date Nature=Nature -Public=Public +Public=Information are public (no=private) Exports=Exports NewMemberbyWeb=New member added. Awaiting approval NewMemberForm=New member form SubscriptionsStatistics=Statistics on subscriptions NbOfSubscriptions=Number of subscriptions AmountOfSubscriptions=Amount of subscriptions -TurnoverOrBudget=Turnover (for a company) or Budget (for a foundation) \ No newline at end of file +TurnoverOrBudget=Turnover (for a company) or Budget (for a foundation) +DefaultAmount=Default amount of subscription +CanEditAmount=Visitor can choose/edit amount of its subscription +MEMBER_NEWFORM_PAYONLINE=Jump on integrated online payment page \ No newline at end of file diff --git a/htdocs/langs/fr_FR/members.lang b/htdocs/langs/fr_FR/members.lang index 82a83d39d36..d4a3030cd43 100644 --- a/htdocs/langs/fr_FR/members.lang +++ b/htdocs/langs/fr_FR/members.lang @@ -110,7 +110,9 @@ ValidateMember=Valider un adhérent ConfirmValidateMember=Êtes-vous sûr de vouloir valider cet adhérent ? FollowingLinksArePublic=Les liens suivants sont des pages accessibles à tous et non protégées par aucune habilitation Dolibarr. Ces pages n'ont aucun formatage et sont fournies à titre d'exemple pour les associations qui veulent des scripts publics de consultation. PublicMemberList=Liste des membres publics -BlankSubscriptionForm=Formulaire inscription +BlankSubscriptionForm=Formulaire publique d'auto-inscription +BlankSubscriptionFormDesc=Dolibarr peut offrir une URL de page publique pour les visiteurs externes permettant de postuler à une adhésion. Si un un module de paiement en ligne est également actif, un formulaire de paiement sera également automatiquement proposé. +EnablePublicSubscriptionForm=Activer le formulaire publique d'autoinscription MemberPublicLinks=Liens/pages publiques ExportDataset_member_1=Adhérents et adhésions ImportDataset_member_1=Adhérents @@ -177,11 +179,14 @@ MembersStatisticsDesc=Choisissez les statistiques que vous désirez consulter... MenuMembersStats=Statistiques LastMemberDate=Date dernier adhérent Nature=Nature -Public=Public +Public=Informations publiques (no=privées) Exports=Exports NewMemberbyWeb=Nouvel Adherent ajoute. En attente de validation NewMemberForm=Nouvel Adherent form SubscriptionsStatistics=Statistiques sur les cotisations NbOfSubscriptions=Nombre de cotisations AmountOfSubscriptions=Montant de cotisations -TurnoverOrBudget=Chiffre affaire (pour société) ou Budget (asso ou collectivité) \ No newline at end of file +TurnoverOrBudget=Chiffre affaire (pour société) ou Budget (asso ou collectivité) +DefaultAmount=Montant par défaut de la cotisation +CanEditAmount=Le visiteur peut modifier/choisir le montant de sa cotisation +MEMBER_NEWFORM_PAYONLINE=Débrancher sur la page intégrée de paiement en ligne \ No newline at end of file diff --git a/htdocs/lib/member.lib.php b/htdocs/lib/member.lib.php index 96444256918..74257f9e4e0 100644 --- a/htdocs/lib/member.lib.php +++ b/htdocs/lib/member.lib.php @@ -20,7 +20,7 @@ /** * \file htdocs/lib/member.lib.php * \brief Ensemble de fonctions de base pour les adherents - * \version $Id$ + * \version $Id: member.lib.php,v 1.24 2011/07/03 16:00:19 eldy Exp $ * * Ensemble de fonctions de base de dolibarr sous forme d'include */ @@ -116,6 +116,11 @@ function member_admin_prepare_head($object) $head[$h][2] = 'attributes'; $h++; + $head[$h][0] = DOL_URL_ROOT.'/adherents/admin/public.php'; + $head[$h][1] = $langs->trans("BlankSubscriptionForm"); + $head[$h][2] = 'public'; + $h++; + // Show more tabs from modules // Entries must be declared in modules descriptor with line // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab diff --git a/htdocs/public/members/new.php b/htdocs/public/members/new.php index 51deb9696f1..d2099e5b124 100644 --- a/htdocs/public/members/new.php +++ b/htdocs/public/members/new.php @@ -22,7 +22,7 @@ * \file htdocs/public/members/new.php * \ingroup member * \brief Example of form to add a new member - * \version $Id: new.php,v 1.29 2011/06/26 21:51:34 eldy Exp $ + * \version $Id: new.php,v 1.30 2011/07/03 16:00:19 eldy Exp $ * * Note that you can add following constant to change behaviour of page * MEMBER_NEWFORM_AMOUNT Default amount for autosubscribe form @@ -45,8 +45,12 @@ require_once(DOL_DOCUMENT_ROOT."/core/class/extrafields.class.php"); require_once(DOL_DOCUMENT_ROOT."/core/class/html.formcompany.class.php"); require_once(DOL_DOCUMENT_ROOT."/lib/company.lib.php"); -// Security check -if (empty($conf->adherent->enabled)) accessforbidden('',1,1,1); +// Init vars +$errmsg=''; +$num=0; +$error=0; +$backtopage=GETPOST('backtopage'); +$action=GETPOST('action'); // Load translation files $langs->load("main"); @@ -55,12 +59,14 @@ $langs->load("companies"); $langs->load("install"); $langs->load("other"); -// Init vars -$errmsg=''; -$num=0; -$error=0; -$backtopage=GETPOST('backtopage'); -$action=GETPOST('action'); +// Security check +if (empty($conf->adherent->enabled)) accessforbidden('',1,1,1); + +if (empty($conf->global->MEMBER_ENABLE_PUBLIC)) +{ + print $langs->trans("Auto subscription form for public visitors has no be enabled"); + exit; +} // Function for page HTML header @@ -263,7 +269,7 @@ if ($action == 'added') print $langs->trans("NewMemberbyWeb"); print ''; - llxFooterVierge('$Date: 2011/06/26 21:51:34 $ - $Revision: 1.29 $'); + llxFooterVierge('$Date: 2011/07/03 16:00:19 $ - $Revision: 1.30 $'); exit; } @@ -290,7 +296,7 @@ if (! empty($conf->global->MEMBER_NEWFORM_TEXT)) print $langs->trans($conf->glob dol_htmloutput_errors($errmsg); print '
'.$langs->trans("FieldsWithAreMandatory",'*').'
'; -print $langs->trans("FieldsWithIsForPublic",'**').'
'; +//print $langs->trans("FieldsWithIsForPublic",'**').'
'; print '