From 4fd00c50be31aa69fe4c984882180f1d7fec5ed1 Mon Sep 17 00:00:00 2001 From: FHenry Date: Fri, 27 Apr 2012 10:32:01 +0200 Subject: [PATCH 1/4] Feature Clone project (357) Fix variable date property name, to be compliant with varaible naming convention (create) Add feature to shift task date when change project start date (option) Add project start/end date on Project->Task View --- htdocs/langs/en_US/projects.lang | 4 ++++ htdocs/langs/fr_FR/projects.lang | 4 ++++ htdocs/projet/class/project.class.php | 4 ++-- htdocs/projet/class/task.class.php | 5 +++-- htdocs/projet/fiche.php | 32 ++++++++++++++++++++++----- htdocs/projet/tasks/document.php | 4 +--- 6 files changed, 40 insertions(+), 13 deletions(-) diff --git a/htdocs/langs/en_US/projects.lang b/htdocs/langs/en_US/projects.lang index ead787d3d84..75082f8012c 100644 --- a/htdocs/langs/en_US/projects.lang +++ b/htdocs/langs/en_US/projects.lang @@ -85,6 +85,10 @@ TaskIsNotAffectedToYou=Task not allocated to you ErrorTimeSpentIsEmpty=Time spent is empty ThisWillAlsoRemoveTasks=This action will also delete all tasks of project (%s tasks at the moment) and all inputs of time spent. IfNeedToUseOhterObjectKeepEmpty=If some objects (invoice, order, ...), belonging to another third party, must be linked to the project to create, keep this empty to have the project being multi third parties. +CloneProject=Clone project (associated task will be duplicated too) +ConfirmCloneProject=Are you sure to clone this project ? +ProjectReportDate=Change task date according project start date +ErrorShiftTaskDate=Impossible to shift task date according to new project start date ##### Types de contacts ##### TypeContact_project_internal_PROJECTLEADER=Project leader TypeContact_project_external_PROJECTLEADER=Project leader diff --git a/htdocs/langs/fr_FR/projects.lang b/htdocs/langs/fr_FR/projects.lang index 6722ac6bb1d..0c3a21e4cdb 100644 --- a/htdocs/langs/fr_FR/projects.lang +++ b/htdocs/langs/fr_FR/projects.lang @@ -85,6 +85,10 @@ TaskIsNotAffectedToYou=Tâche qui ne vous est pas affectée ErrorTimeSpentIsEmpty=Le temps consommé n'est pas renseigné ThisWillAlsoRemoveTasks=Cette opération détruira également les tâches du projet (%s tâches actuellement) et le suivi des consommés. IfNeedToUseOhterObjectKeepEmpty=Si des objets (facture, commande, ...), appartenant à un autre tiers que celui choisi, doivent être liés au projet à créer, laisser vide afin de laisser le projet multi-tiers. +CloneProject=Cloner le projet (les taches associées sont dupliquées également) +ConfirmCloneProject=Êtes-vous sûr de vouloir cloner ce projet ? +ProjectReportDate=Reporter les dates des taches en fonction de la date de départ. +ErrorShiftTaskDate=Une erreur c'est produite dans le report des dates des taches. ##### Types de contacts ##### TypeContact_project_internal_PROJECTLEADER=Chef de projet TypeContact_project_external_PROJECTLEADER=Chef de projet diff --git a/htdocs/projet/class/project.class.php b/htdocs/projet/class/project.class.php index 435c59d395d..d838f61b869 100644 --- a/htdocs/projet/class/project.class.php +++ b/htdocs/projet/class/project.class.php @@ -52,7 +52,7 @@ class Project extends CommonObject /** * Constructor * - * @param DoliDB $db Database handler + * @param DoliDB $DB Database handler */ function __construct($db) { @@ -707,7 +707,7 @@ class Project extends CommonObject { global $user, $langs, $conf; - $now = dol_now(); + $now = mktime(); // Charge tableau des produits prodids $prodids = array(); diff --git a/htdocs/projet/class/task.class.php b/htdocs/projet/class/task.class.php index 6aefb92ec6c..b93598b600f 100644 --- a/htdocs/projet/class/task.class.php +++ b/htdocs/projet/class/task.class.php @@ -64,7 +64,7 @@ class Task extends CommonObject /** * Constructor * - * @param DoliDB $db Database handler + * @param DoliDB $DB Database handler */ function __construct($db) { @@ -305,6 +305,7 @@ class Task extends CommonObject */ function delete($user, $notrigger=0) { + global $conf, $langs; $error=0; @@ -391,7 +392,7 @@ class Task extends CommonObject $this->db->commit(); - return 1; + return 1; } } diff --git a/htdocs/projet/fiche.php b/htdocs/projet/fiche.php index f84dca56cbe..e57f24c5878 100644 --- a/htdocs/projet/fiche.php +++ b/htdocs/projet/fiche.php @@ -117,7 +117,6 @@ if ($action == 'add' && $user->rights->projet->creer) $db->begin(); $project = new Project($db); - $project->ref = GETPOST('ref','alpha'); $project->title = GETPOST('title','alpha'); $project->socid = GETPOST('socid','int'); @@ -246,6 +245,7 @@ if ($action == 'builddoc' && $user->rights->projet->creer) } } + if ($action == 'confirm_validate' && GETPOST('confirm') == 'yes') { $project = new Project($db); @@ -315,6 +315,24 @@ if ($action == 'confirm_clone' && $user->rights->projet->creer && GETPOST('confi } } +if ($action == 'confirm_clone' && $user->rights->projet->creer && GETPOST('confirm') == 'yes') +{ + $idtoclone=$id; + $project = new Project($db); + $project->fetch($idtoclone); + $result=$project->createFromClone($idtoclone,true,true,true,true); + if ($result <= 0) + { + $mesg='
'.$project->error.'
'; + } + else + { + $id=$result; + $action='edit'; + $comefromclone=true; + } +} + /* * View @@ -353,7 +371,7 @@ if ($action == 'create' && $user->rights->projet->creer) { require_once(DOL_DOCUMENT_ROOT ."/core/modules/project/".$conf->global->PROJECT_ADDON.".php"); $modProject = new $obj; - $defaultref = $modProject->getNextValue($soc,$project); + $defaultref = $modProject->getNextValue($soc,$project); } if (is_numeric($defaultref) && $defaultref <= 0) $defaultref=''; @@ -459,7 +477,11 @@ else $ret=$form->form_confirm($_SERVER["PHP_SELF"]."?id=".$project->id,$langs->trans("DeleteAProject"),$text,"confirm_delete",'','',1); if ($ret == 'html') print '
'; } +<<<<<<< OURS // Clone confirmation +======= + // Clone confirmation +>>>>>>> THEIRS if ($action == 'clone') { $ret=$form->form_confirm($_SERVER["PHP_SELF"]."?id=".$project->id,$langs->trans("CloneProject"),$langs->trans("ConfirmCloneProject"),"confirm_clone",'','',1); @@ -486,9 +508,7 @@ else // Customer print ''.$langs->trans("Company").''; - $text=$form->select_company($project->societe->id,'socid','',1,1); - $texthelp=$langs->trans("IfNeedToUseOhterObjectKeepEmpty"); - print $form->textwithtooltip($text.' '.img_help(),$texthelp,1); + print $form->select_company($project->societe->id,'socid','',1,1); print ''; // Visibility @@ -562,7 +582,7 @@ else // Date start print ''.$langs->trans("DateStart").''; - print dol_print_date($project->date_start,'day'); + print dol_print_date($project->date_start,'day'); print ''; // Date end diff --git a/htdocs/projet/tasks/document.php b/htdocs/projet/tasks/document.php index 8762f3cf271..ae5ce5a0b9c 100644 --- a/htdocs/projet/tasks/document.php +++ b/htdocs/projet/tasks/document.php @@ -125,7 +125,6 @@ if (! empty($project_ref) && ! empty($withproject)) } } -// Find upload dir after retreive is task if necessary if ($id > 0 || ! empty($ref)) { if ($object->fetch($id,$ref) > 0) @@ -141,7 +140,6 @@ if ($id > 0 || ! empty($ref)) dol_print_error($db); } } - /* * View */ @@ -283,4 +281,4 @@ else llxFooter(); $db->close(); -?> \ No newline at end of file +?> From 7aada2c44264e37531fda24ed07225054a71f4ad Mon Sep 17 00:00:00 2001 From: FHenry Date: Fri, 27 Apr 2012 10:54:18 +0200 Subject: [PATCH 2/4] correct debug code and alfa --- htdocs/projet/fiche.php | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/htdocs/projet/fiche.php b/htdocs/projet/fiche.php index e57f24c5878..8b0146a08f1 100644 --- a/htdocs/projet/fiche.php +++ b/htdocs/projet/fiche.php @@ -117,6 +117,7 @@ if ($action == 'add' && $user->rights->projet->creer) $db->begin(); $project = new Project($db); + $project->ref = GETPOST('ref','alpha'); $project->title = GETPOST('title','alpha'); $project->socid = GETPOST('socid','int'); @@ -477,11 +478,8 @@ else $ret=$form->form_confirm($_SERVER["PHP_SELF"]."?id=".$project->id,$langs->trans("DeleteAProject"),$text,"confirm_delete",'','',1); if ($ret == 'html') print '
'; } -<<<<<<< OURS + // Clone confirmation -======= - // Clone confirmation ->>>>>>> THEIRS if ($action == 'clone') { $ret=$form->form_confirm($_SERVER["PHP_SELF"]."?id=".$project->id,$langs->trans("CloneProject"),$langs->trans("ConfirmCloneProject"),"confirm_clone",'','',1); From dc42e16ff1f079ba134fb3486c683a20698195be Mon Sep 17 00:00:00 2001 From: FHenry Date: Mon, 30 Apr 2012 13:49:29 +0200 Subject: [PATCH 3/4] Secure URL use to CheckRead and Unsubcribe with security key in configuration screen --- htdocs/admin/mailing.php | 44 ++++++++++++++++--- htdocs/comm/mailing/fiche.php | 4 +- .../modules/mailings/modules_mailings.php | 7 ++- htdocs/langs/en_US/mails.lang | 1 + htdocs/langs/fr_FR/mails.lang | 1 + 5 files changed, 48 insertions(+), 9 deletions(-) diff --git a/htdocs/admin/mailing.php b/htdocs/admin/mailing.php index a0f0f095019..bab078a418c 100644 --- a/htdocs/admin/mailing.php +++ b/htdocs/admin/mailing.php @@ -34,6 +34,8 @@ if (!$user->admin) $action = GETPOST('action','alpha'); + + /* * Actions */ @@ -45,13 +47,36 @@ if ($action == 'setvalue' && $user->admin) $mailfrom = GETPOST('MAILING_EMAIL_FROM','alpha'); $mailerror = GETPOST('MAILING_EMAIL_ERRORSTO','alpha'); $checkread = GETPOST('value','alpha'); + $checkread_key = GETPOST('MAILING_EMAIL_UNSUBSCRIBE_KEY','alpha'); + + $res=dolibarr_set_const($db, "MAILING_EMAIL_FROM",$mailfrom,'chaine',0,'',$conf->entity); if (! $res > 0) $error++; $res=dolibarr_set_const($db, "MAILING_EMAIL_ERRORSTO",$mailerror,'chaine',0,'',$conf->entity); if (! $res > 0) $error++; - //$res=dolibarr_set_const($db, "MAILING_EMAIL_UNSUBSCRIBE",$checkread,'chaine',0,'',$conf->entity); - //if (! $res > 0) $error++; + if ($checkread=='on') + { + $res=dolibarr_set_const($db, "MAILING_EMAIL_UNSUBSCRIBE",1,'chaine',0,'',$conf->entity); + if (! $res > 0) $error++; + } + else if ($checkread=='off') + { + $res=dolibarr_set_const($db, "MAILING_EMAIL_UNSUBSCRIBE",0,'chaine',0,'',$conf->entity); + if (! $res > 0) $error++; + } + + //Create temporary encryption key if nedded + if (($conf->global->MAILING_EMAIL_UNSUBSCRIBE==1) && (empty($checkread_key))) + { + $chars = "abcdef(ghijklmnopqrstuvwxyz;!ABCDEFGH,IJKLMNOPQRSTUVWXYZ01_23456789"; + mt_srand(10000000*(double)microtime()); + for ($i = 0, $str = '', $lc = strlen($chars)-1; $i < 30; $i++) { + $checkread_key .= $chars[mt_rand(0, $lc)]; + } + } + $res=dolibarr_set_const($db, "MAILING_EMAIL_UNSUBSCRIBE_KEY",$checkread_key,'chaine',0,'',$conf->entity); + if (! $res > 0) $error++; if (! $error) { @@ -104,24 +129,31 @@ print ''; -/* + $var=!$var; print ''; print $langs->trans("ActivateCheckRead").''; if ($conf->global->MAILING_EMAIL_UNSUBSCRIBE==1) { - print ''; + print ''; print img_picto($langs->trans("Enabled"),'switch_on'); print ''; + $readonly=''; } else { - print ''; + print ''; print img_picto($langs->trans("Disabled"),'switch_off'); print ''; + $readonly='disabled="disabled"'; } print ''; -*/ + +$var=!$var; +print ''; +print $langs->trans("ActivateCheckReadKey").''; +print ''; +print ''; print ''; diff --git a/htdocs/comm/mailing/fiche.php b/htdocs/comm/mailing/fiche.php index bcea8ad2a22..b2f875583f4 100644 --- a/htdocs/comm/mailing/fiche.php +++ b/htdocs/comm/mailing/fiche.php @@ -64,7 +64,7 @@ if ($conf->global->MAILING_EMAIL_UNSUBSCRIBE) $substitutionarray, array( '__CHECK_READ__' => 'CheckMail', - '__UNSUSCRIBE__' => 'Unsuscribe' + '__UNSUSCRIBE__' => 'Unsubscribe' ) ); } @@ -89,7 +89,7 @@ if ($conf->global->MAILING_EMAIL_UNSUBSCRIBE) $substitutionarrayfortest, array( '__CHECK_READ__' => 'TESTCheckMail', - '__UNSUSCRIBE__' => 'TESTCheckMail' + '__UNSUSCRIBE__' => 'TESTUnsubscribe' ) ); } diff --git a/htdocs/core/modules/mailings/modules_mailings.php b/htdocs/core/modules/mailings/modules_mailings.php index 75032bbab9e..53729e812e3 100644 --- a/htdocs/core/modules/mailings/modules_mailings.php +++ b/htdocs/core/modules/mailings/modules_mailings.php @@ -143,6 +143,8 @@ class MailingTargets // This can't be abstract as it is used for some method */ function add_to_target($mailing_id, $cibles) { + global $conf; + $this->db->begin(); // Insert emailing targest from array into database @@ -162,7 +164,10 @@ class MailingTargets // This can't be abstract as it is used for some method $sql .= "'".$this->db->escape($cibles[$i]['other'])."',"; $sql .= "'".$this->db->escape($cibles[$i]['source_url'])."',"; $sql .= "'".$this->db->escape($cibles[$i]['source_id'])."',"; - $sql .= "'".$this->db->escape(md5($cibles[$i]['email'].';'.$cibles[$i]['name'].';'.$mailing_id))."',"; + if ($conf->global->MAILING_EMAIL_UNSUBSCRIBE==1) + { + $sql .= "'".$this->db->escape(md5($cibles[$i]['email'].';'.$cibles[$i]['name'].';'.$mailing_id.';'.$conf->global->MAILING_EMAIL_UNSUBSCRIBE_KEY))."',"; + } $sql .= "'".$this->db->escape($cibles[$i]['source_type'])."')"; $result=$this->db->query($sql); if ($result) diff --git a/htdocs/langs/en_US/mails.lang b/htdocs/langs/en_US/mails.lang index d5deed6ec64..a252859f964 100644 --- a/htdocs/langs/en_US/mails.lang +++ b/htdocs/langs/en_US/mails.lang @@ -77,6 +77,7 @@ CheckRead=Read Receipt YourMailUnsubcribeOK=The email %s is correctly unsubcribe from mailing list MailtoEMail=Hyper link to email ActivateCheckRead=Activate Read receipt and unsubcribe tag +ActivateCheckReadKey=Key use to encrypt URL use for Read Receipt and unsubcribe function # Libelle des modules de liste de destinataires mailing MailingModuleDescContactCompanies=Contacts of all third parties (customer, prospect, supplier, ...) diff --git a/htdocs/langs/fr_FR/mails.lang b/htdocs/langs/fr_FR/mails.lang index 45b5dd24263..11b0aa4e0e1 100644 --- a/htdocs/langs/fr_FR/mails.lang +++ b/htdocs/langs/fr_FR/mails.lang @@ -77,6 +77,7 @@ CheckRead=Accusé de lecture YourMailUnsubcribeOK=L'adresse e-mail %s est bien désincrite de la liste. MailtoEMail=Ecrire a e-mail (lien) ActivateCheckRead=Activer les tags d'accusé de lecture et de désincription +ActivateCheckReadKey=Clef de sécurité utilisée pour l'encryption des URL utilisées dans les fonctions d'accusé de lecture et de désincription # Libelle des modules de liste de destinataires mailing MailingModuleDescContactCompanies=Contacts de tiers (prospects, clients, fournisseurs...) From fca02bf91847a10b6912853a13d5d8e63be6516d Mon Sep 17 00:00:00 2001 From: FHenry Date: Mon, 30 Apr 2012 13:53:16 +0200 Subject: [PATCH 4/4] Remove space --- htdocs/admin/mailing.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/htdocs/admin/mailing.php b/htdocs/admin/mailing.php index bab078a418c..da844ed9934 100644 --- a/htdocs/admin/mailing.php +++ b/htdocs/admin/mailing.php @@ -49,8 +49,6 @@ if ($action == 'setvalue' && $user->admin) $checkread = GETPOST('value','alpha'); $checkread_key = GETPOST('MAILING_EMAIL_UNSUBSCRIBE_KEY','alpha'); - - $res=dolibarr_set_const($db, "MAILING_EMAIL_FROM",$mailfrom,'chaine',0,'',$conf->entity); if (! $res > 0) $error++; $res=dolibarr_set_const($db, "MAILING_EMAIL_ERRORSTO",$mailerror,'chaine',0,'',$conf->entity);