diff --git a/htdocs/install/mysql/migration/3.5.0-3.6.0.sql b/htdocs/install/mysql/migration/3.5.0-3.6.0.sql index 4d85adb9782..6a189c4c756 100755 --- a/htdocs/install/mysql/migration/3.5.0-3.6.0.sql +++ b/htdocs/install/mysql/migration/3.5.0-3.6.0.sql @@ -24,4 +24,5 @@ ALTER TABLE `llx_opensurvey_sondage` DROP INDEX `idx_id_sondage_admin` ; ALTER TABLE `llx_opensurvey_sondage` DROP COLUMN `id_sondage_admin` ; ALTER TABLE `llx_opensurvey_sondage` DROP COLUMN `canedit` ; ALTER TABLE `llx_opensurvey_sondage` ADD COLUMN `allow_spy` TINYINT( 1 ) UNSIGNED NOT NULL AFTER `allow_comments` ; -ALTER TABLE `llx_opensurvey_sondage` DROP `origin` ; \ No newline at end of file +ALTER TABLE `llx_opensurvey_sondage` DROP `origin` ; +ALTER TABLE `llx_opensurvey_sondage` ADD `fk_user_creat` INT( 11 ) UNSIGNED NOT NULL AFTER `nom_admin` ; \ No newline at end of file diff --git a/htdocs/install/mysql/tables/llx_opensurvey_sondage.sql b/htdocs/install/mysql/tables/llx_opensurvey_sondage.sql index ce4add9e9f5..db1231588f3 100644 --- a/htdocs/install/mysql/tables/llx_opensurvey_sondage.sql +++ b/htdocs/install/mysql/tables/llx_opensurvey_sondage.sql @@ -20,6 +20,7 @@ CREATE TABLE llx_opensurvey_sondage ( commentaires text, mail_admin VARCHAR(128), nom_admin VARCHAR(64), + fk_user_creat INT(11) UNSIGNED NOT NULL, titre TEXT, date_fin DATETIME, format VARCHAR(2), diff --git a/htdocs/opensurvey/card.php b/htdocs/opensurvey/card.php index 474d7db85f4..1fac0c16ed8 100644 --- a/htdocs/opensurvey/card.php +++ b/htdocs/opensurvey/card.php @@ -211,10 +211,17 @@ if ($action == 'edit') else print dol_htmlentities($object->titre); print ''; -// Auteur +// Author print '
| '. $langs->trans("Ref").' | '. $langs->trans("Title") .' | '. $langs->trans("Type") .' | '. $langs->trans("Author") .' | '. $langs->trans("ExpireDate") .' | '. $langs->trans("NbOfVoters") .' | '."\n"; -$sql = "SELECT id_sondage, mail_admin, format, date_fin, titre, nom_admin"; +$sql = "SELECT id_sondage, fk_user_creat, u.login, format, date_fin, titre, nom_admin"; $sql.= " FROM ".MAIN_DB_PREFIX."opensurvey_sondage as p"; +$sql.= " LEFT OUTER JOIN ".MAIN_DB_PREFIX."user u ON u.rowid = p.fk_user_creat"; // Count total nb of records $nbtotalofrecords = 0; if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) @@ -98,7 +99,20 @@ while ($i < min($num,$limit)) $type=($obj->format=='A')?'classic':'date'; print img_picto('',dol_buildpath('/opensurvey/img/'.($type == 'classic'?'chart-32.png':'calendar-32.png'),1),'width="16"',1); print ' '.$langs->trans($type=='classic'?"TypeClassic":"TypeDate"); - print ''.dol_htmlentities($obj->nom_admin).' | '; + print ''; + + // Author + if ($obj->fk_user_creat) { + $userstatic = new User($db); + $userstatic->id = $obj->fk_user_creat; + $userstatic->login = $obj->login; + + print $userstatic->getLoginUrl(1); + } else { + print dol_htmlentities($obj->nom_admin); + } + + print ' | '; print ''.dol_print_date($db->jdate($obj->date_fin),'day');
if ($db->jdate($obj->date_fin) < time()) { print ' '.img_warning(); }
diff --git a/htdocs/opensurvey/public/studs.php b/htdocs/opensurvey/public/studs.php
index 9eac7face2c..162643cf149 100644
--- a/htdocs/opensurvey/public/studs.php
+++ b/htdocs/opensurvey/public/studs.php
@@ -133,18 +133,25 @@ if (isset($_POST["boutonp"]))
$_SESSION["savevoter"]=$nom.','.(empty($_SESSION["savevoter"])?'':$_SESSION["savevoter"]); // Save voter
$listofvoters=explode(',',$_SESSION["savevoter"]);
- if (! empty($object->mailsonde))
+ if ($object->mailsonde)
{
- include_once DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php';
- $cmailfile=new CMailFile("[".MAIN_APPLICATION_TITLE."] ".$langs->trans("Poll").': '.$object->titre, $object->mail_admin, $conf->global->MAIN_MAIL_EMAIL_FROM, $nom." has filled a line.\nYou can find your poll at the link:\n".getUrlSondage($numsondage));
- $result=$cmailfile->sendfile();
- if ($result)
- {
-
+ if ($object->fk_user_creat) {
+ $userstatic = new User($db);
+ $userstatic->fetch($object->fk_user_creat);
+
+ $email = $userstatic->email;
+ } else {
+ $email = $object->mail_admin;
}
- else
- {
-
+
+ //Linked user may not have an email set
+ if ($email) {
+ include_once DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php';
+
+ $body = $langs->trans('EmailSomeoneVoted', $nom, getUrlSondage($numsondage, true));
+
+ $cmailfile=new CMailFile("[".MAIN_APPLICATION_TITLE."] ".$langs->trans("Poll").': '.$object->titre, $email, $conf->global->MAIN_MAIL_EMAIL_FROM, $body);
+ $result=$cmailfile->sendfile();
}
}
}
@@ -728,21 +735,6 @@ if ($object->allow_comments) {
print ' '; -/* -// Define $urlwithroot -$urlwithouturlroot=preg_replace('/'.preg_quote(DOL_URL_ROOT,'/').'$/i','',trim($dolibarr_main_url_root)); -$urlwithroot=$urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file -//$urlwithroot=DOL_MAIN_URL_ROOT; // This is to use same domain name than current - -$message=''; -$url=$urlwithouturlroot.dol_buildpath('/opensurvey/public/studs.php',1).'?sondage='.$numsondage; -$urlvcal=''.$url.''; -$message.=img_picto('','object_globe.png').' '.$langs->trans("UrlForSurvey").': '.$urlvcal; - -print ' |
| '. $langs->trans("Description") .' | '."\n"; print ' | |||||||
| '. $langs->trans("OpenSurveyYourName") .' | '; - -print ' | '."\n"; - -if (! $_SESSION["nom"] && (GETPOST('creation_sondage_date') || GETPOST('creation_sondage_autre'))) -{ - setEventMessage($langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("OpenSurveyYourName")), 'errors'); -} - -print '|||||||
| '. $langs->trans("OpenSurveyYourEMail") .' | '; - -print ' | '."\n"; - -if (!$_SESSION["adresse"] && (GETPOST('creation_sondage_date') || GETPOST('creation_sondage_autre'))) -{ - setEventMessage($langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("OpenSurveyYourEMail")), 'errors'); -} elseif ($erreur_adresse && (GETPOST('creation_sondage_date') || GETPOST('creation_sondage_autre'))) -{ - $langs->load('errors'); - setEventMessage($langs->trans("ErrorBadEMail", $adresse), 'errors'); -} print '|||||||
| '. $langs->trans("ExpireDate") .' | '; |