Skip to content

Commit

Permalink
Added Feature: sSendEmail. You are able to send invitations, reminder…
Browse files Browse the repository at this point in the history
…s and custom messenges with lsrc, to participants of a specific survey.

Updated Feature: the .csv Files have been changed slightly.

git-svn-id: file:///Users/Shitiz/Downloads/lssvn/source/limesurvey181@6582 b72ed6b6-b9f8-46b5-92b4-906544132732
  • Loading branch information
Tim Wahrendorff committed Mar 24, 2009
1 parent 1a75c12 commit 6d83353
Show file tree
Hide file tree
Showing 9 changed files with 378 additions and 60 deletions.
7 changes: 1 addition & 6 deletions admin/remotecontrol/lsrc.config.php
Expand Up @@ -55,18 +55,13 @@


### Variables
// Since this variable isn't per default in Limesurveys config.php any more, we need to set it ourselfs
//(the setting in LS config-defaults.php is not working for lsrc... no idea why)
// set the LS installation Dir relative to document root
//$relativeurl = "/limesource/limesurvey"; //default: "/limesurvey" //TODO: delete if no errors occure while commented

// path to the wsdl definition for this server... normally it is in the same directory, so you don't need to change it.
$wsdl= $homedir."/remotecontrol/lsrc.wsdl"; //default: $homedir."/lsrc/lsrc.wsdl";

/**
* These are the Dirs where the prepared survey csv's are or have to be.
* one for the core surveys,
* one for addable modules,
* one for addable groups,
* one for addable questions
*/
$coreDir = "./surveys/";
Expand Down
342 changes: 303 additions & 39 deletions admin/remotecontrol/lsrc.helper.php

Large diffs are not rendered by default.

71 changes: 65 additions & 6 deletions admin/remotecontrol/lsrc.server.php
Expand Up @@ -105,12 +105,17 @@ function sChangeSurvey($sUser, $sPass, $table, $key, $value, $where, $mode='0')
* $emailText = Text of custom mails
*
*/
function sSendEmail($sUser, $sPass, $iVid, $type, $maxemails='', $subject='', $emailText='')
function sSendEmail($sUser, $sPass, $iVid, $type, $maxLsrcEmails='', $subject='', $emailText='')
{
global $sitename, $siteadminemail;
include("lsrc.config.php");
$lsrcHelper = new lsrcHelper();
$lsrcHelper->debugLsrc("wir sind in ".__FUNCTION__." Line ".__LINE__.", START OK ");

// wenn maxmails ber den lsrc gegeben wird das nurtzen, ansonsten die default werte aus der config.php
if($maxLsrcEmails!='')
$maxemails = $maxLsrcEmails;

if(!$lsrcHelper->checkUser($sUser, $sPass))
{
throw new SoapFault("Authentication: ", "User or password wrong");
Expand All @@ -126,21 +131,75 @@ function sSendEmail($sUser, $sPass, $iVid, $type, $maxemails='', $subject='', $e

if($type=='custom' && $subject!='' && $emailText!='')
{
//GET SURVEY DETAILS not working here... don't know why...
//$thissurvey=getSurveyInfo($iVid);
$from = $siteadminemail;

$lsrcHelper->debugLsrc("wir sind in ".__FUNCTION__." Line ".__LINE__.", Admin Email: $from ; survey: $iVid ; dump: ".print_r($thissurvey)."");
$emquery = "SELECT firstname, lastname, email, token, tid, language";
if ($ctfieldcount > 7) {$emquery .= ", attribute_1, attribute_2";}
//if ($ctfieldcount > 7) {$emquery .= ", attribute_1, attribute_2";}

$emquery .= " FROM ".db_table_name("tokens_{$surveyid}")." WHERE ((completed ='N') or (completed='')) AND ((sent ='N') or (sent='')) AND token !='' AND email != '' $SQLemailstatuscondition";
$emquery .= " FROM ".db_table_name("tokens_{$iVid}")." WHERE email != '' ";

if (isset($tokenid)) {$emquery .= " and tid='{$tokenid}'";}
$tokenoutput .= "\n\n<!-- emquery: $emquery -->\n\n";
$emresult = db_select_limit_assoc($emquery,$maxemails);
$emcount = $emresult->RecordCount();

MailTextMessage();
if ($emcount > 0)
{
$mailsSend = 0;
while ($emrow = $emresult->FetchRow())
{
if (MailTextMessage($emailText, $subject, $emrow['email'] , $from, $sitename, $ishtml=false, getBounceEmail($iVid)))
{
$mailsSend++;
}
else
{
//$tokenoutput .= ReplaceFields($clang->gT("Email to {FIRSTNAME} {LASTNAME} ({EMAIL}) failed. Error Message:")." ".$maildebug."<br />", $fieldsarray);
if($n==1)
$failedAddresses .= ",".$to;
else
{
$failedAddresses = $to;
$n=1;
}

}
}

}
else
{
return "No Mails to send";
}
// if ($ctcount > $emcount)
// {
// $lefttosend = $ctcount-$maxemails;
//
// }else{$lefttosend = 0;}

// if($maxemails>0)
// {
// $returnValue = "".$mailsSend." Mails send. ".$lefttosend." Mails left to send";
// if(isset($failedAddresses))
// $returnValue .= "\nCould not send to: ".$failedAddresses;
// return $returnValue;
// }

if(isset($mailsSend))
{
$returnValue = "".$mailsSend." Mails send. ";
if(isset($failedAddresses))
$returnValue .= "\nCould not send to: ".$failedAddresses;
return $returnValue;
}
}

if($type=='invite' || $type=='remind')
{
$emailSenderReturn = $lsrcHelper->emailSender($iVid, $type, $maxemails);
$emailSenderReturn = $lsrcHelper->emailSender($iVid, $type, $maxLsrcEmails);

return $emailSenderReturn;
// if($maxemails != '')
Expand Down Expand Up @@ -801,7 +860,7 @@ function sImportMatrix($sUser, $sPass, $iVid, $qText, $qHelp, $sItems, $sMod='Ma
* or if the question should be added to the last group in survey
*/
$newGroup=0;

global $connect ;
global $dbprefix ;
$ADODB_FETCH_MODE = ADODB_FETCH_ASSOC;
Expand Down
4 changes: 2 additions & 2 deletions admin/remotecontrol/lsrc.testclient.php
Expand Up @@ -253,7 +253,7 @@ function soapCheck ($path2wsdl)
try
{

$sReturn = $client->sImportMatrix($user, $pass, $iVid, $qText, $qHelp, $items, "Matrix5", $mandatory,0);
$sReturn = $client->sImportMatrix($user, $pass, $iVid, $qText, $qHelp, $items, "Matrix5", $mandatory);
}
catch (SoapFault $fault)
{
Expand All @@ -275,7 +275,7 @@ function soapCheck ($path2wsdl)
try
{

$sReturn = $client->sImportFreetext($user, $pass, $iVid, $qTitle, $qText, $qHelp, "Freitext", $mandatory,0);
$sReturn = $client->sImportFreetext($user, $pass, $iVid, $qTitle, $qText, $qHelp, "Freitext", $mandatory);
}
catch (SoapFault $fault)
{
Expand Down
6 changes: 3 additions & 3 deletions admin/remotecontrol/lsrc_orig.wsdl
Expand Up @@ -232,12 +232,12 @@
<message name="sImportMatrixRequest">
<part name="sUser" type="xsd:string"></part>
<part name="sPass" type="xsd:string"></part>
<part name="iVid" type="xsd:int"></part>
<part name="sMod" type="xsd:string"></part>
<part name="iVid" type="xsd:int"></part>
<part name="sTitle" type="xsd:string"></part>
<part name="sQuestion" type="xsd:string"></part>
<part name="sItems" type="xsd:string"></part>
<part name="sMandatory" type="xsd:string"></part>
<part name="sMod" type="xsd:string"></part>
<part name="sMandatory" type="xsd:string"></part>
</message>
<message name="sImportMatrixResponse">
<part name="return" type="xsd:string"></part>
Expand Down
2 changes: 1 addition & 1 deletion admin/remotecontrol/surveys/Exkursion.csv
Expand Up @@ -8,7 +8,7 @@
# SURVEYS TABLE
#
"sid","owner_id","admin","active","startdate","expires","adminemail","private","faxto","format","template","url","language","additional_languages","datestamp","usecookie","notification","allowregister","attribute1","attribute2","allowsave","printanswers","autonumber_start","autoredirect","allowprev","ipaddr","useexpiry","usestartdate","refurl","datecreated","listpublic","htmlemail","tokenanswerspersistence","usecaptcha","bounce_email"
"35732","1","Tim Wahrendorff","N","2008-12-04","2008-12-04","wahrendorff@his.de","Y","","G","default","www.his.de","de","","N","N","0","N","","","N","N","0","N","Y","N","N","N","N","2008-12-04","N","Y","N","D","wahrendorff@his.de"
"35732","1","Tim Wahrendorff","N","2008-12-04","2008-12-04","wahrendorff@his.de","Y","","G","hisinone","www.his.de","de","","N","N","0","N","","","N","N","0","N","Y","N","N","N","N","2008-12-04","N","Y","N","D","wahrendorff@his.de"

#
# GROUPS TABLE
Expand Down
2 changes: 1 addition & 1 deletion admin/remotecontrol/surveys/Seminar.csv
Expand Up @@ -8,7 +8,7 @@
# SURVEYS TABLE
#
"sid","owner_id","admin","active","startdate","expires","adminemail","private","faxto","format","template","url","language","additional_languages","datestamp","usecookie","notification","allowregister","attribute1","attribute2","allowsave","printanswers","autonumber_start","autoredirect","allowprev","ipaddr","useexpiry","usestartdate","refurl","datecreated","listpublic","htmlemail","tokenanswerspersistence","usecaptcha","bounce_email"
"35732","1","Tim Wahrendorff","N","2008-12-04","2008-12-04","wahrendorff@his.de","Y","","G","default","www.his.de","de","","N","N","0","N","","","N","N","0","N","Y","N","N","N","N","2008-12-04","N","Y","N","D","wahrendorff@his.de"
"35732","1","Tim Wahrendorff","N","2008-12-04","2008-12-04","wahrendorff@his.de","Y","","G","hisinone","www.his.de","de","","N","N","0","N","","","N","N","0","N","Y","N","N","N","N","2008-12-04","N","Y","N","D","wahrendorff@his.de"

#
# GROUPS TABLE
Expand Down
2 changes: 1 addition & 1 deletion admin/remotecontrol/surveys/Uebung.csv
Expand Up @@ -8,7 +8,7 @@
# SURVEYS TABLE
#
"sid","owner_id","admin","active","startdate","expires","adminemail","private","faxto","format","template","url","language","additional_languages","datestamp","usecookie","notification","allowregister","attribute1","attribute2","allowsave","printanswers","autonumber_start","autoredirect","allowprev","ipaddr","useexpiry","usestartdate","refurl","datecreated","listpublic","htmlemail","tokenanswerspersistence","usecaptcha","bounce_email"
"35732","1","Tim Wahrendorff","N","2008-12-04","2008-12-04","wahrendorff@his.de","Y","","G","default","www.his.de","de","","N","N","0","N","","","N","N","0","N","Y","N","N","N","N","2008-12-04","N","Y","N","D","wahrendorff@his.de"
"35732","1","Tim Wahrendorff","N","2008-12-04","2008-12-04","wahrendorff@his.de","Y","","G","hisinone","www.his.de","de","","N","N","0","N","","","N","N","0","N","Y","N","N","N","N","2008-12-04","N","Y","N","D","wahrendorff@his.de"

#
# GROUPS TABLE
Expand Down
2 changes: 1 addition & 1 deletion admin/remotecontrol/surveys/Vorlesung.csv
Expand Up @@ -8,7 +8,7 @@
# SURVEYS TABLE
#
"sid","owner_id","admin","active","startdate","expires","adminemail","private","faxto","format","template","url","language","additional_languages","datestamp","usecookie","notification","allowregister","attribute1","attribute2","allowsave","printanswers","autonumber_start","autoredirect","allowprev","ipaddr","useexpiry","usestartdate","refurl","datecreated","listpublic","htmlemail","tokenanswerspersistence","usecaptcha","bounce_email"
"35732","1","Tim Wahrendorff","N","2008-12-04","2008-12-04","wahrendorff@his.de","Y","","G","default","www.his.de","de","","N","N","0","N","","","N","N","0","N","Y","N","N","N","N","2008-12-04","N","Y","N","D","wahrendorff@his.de"
"35732","1","Tim Wahrendorff","N","2008-12-04","2008-12-04","wahrendorff@his.de","Y","","G","hisinone","www.his.de","de","","N","N","0","N","","","N","N","0","N","Y","N","N","N","N","2008-12-04","N","Y","N","D","wahrendorff@his.de"

#
# GROUPS TABLE
Expand Down

0 comments on commit 6d83353

Please sign in to comment.