23 include_once (
'FDL/Lib.Dir.php');
24 include_once (
'FDL/freedom_util.php');
29 $action->lay->set(
'FORM_SEND_OK', False);
30 $action->lay->set(
'FORM_SEND_ERROR_INVALID_ARGS', False);
31 $action->lay->set(
'FORM_SEND_ERROR_UNKNOWN', False);
32 $action->lay->set(
'FORM_SEND_ERROR_EXTERNAL_AUTH', False);
33 $action->lay->set(
'ON_ERROR_CONTACT',
$action->getParam(
'SMTP_FROM'));
36 if ($userdoc == NULL) {
37 $action->lay->set(
'FORM_SEND_ERROR_INVALID_ARGS', True);
43 if (!in_array(
'freedom', $providerList) || ($ldapUserFamId !==
false && $userdoc[
'fromid'] == $ldapUserFamId)) {
44 $action->lay->set(
'FORM_SEND_ERROR_EXTERNAL_AUTH', True);
50 $action->lay->set(
'FORM_SEND_ERROR_UNKNOWN', True);
54 $action->lay->set(
'FORM_SEND_OK', True);
65 $filter[] =
"us_login = '" . pg_escape_string($login) .
"'";
68 $filter[] =
"us_mail = '" . pg_escape_string($email) .
"'";
72 error_log(__CLASS__ .
"::" . __FUNCTION__ .
" " .
"Undefined email and login args.");
76 if (count($res) <= 0) {
77 error_log(__CLASS__ .
"::" . __FUNCTION__ .
" " .
"Empty search result");
81 if (count($res) > 1) {
82 error_log(__CLASS__ .
"::" . __FUNCTION__ .
" " .
"Result contains more than 1 element");
86 $email = $res[0][
'us_mail'];
89 error_log(__CLASS__ .
"::" . __FUNCTION__ .
" " .
"Empty us_mail for docid '" . $res[0][
'id'] .
"'");
98 include_once (
'WHAT/Class.UserToken.php');
99 include_once (
"FDL/sendmail.php");
101 $us_mail = $userdoc[
'us_mail'];
102 $us_fname = $userdoc[
'us_fname'];
103 $us_lname = $userdoc[
'us_lname'];
105 if ($us_mail ==
"") {
106 error_log(__CLASS__ .
"::" . __FUNCTION__ .
" " .
"Empty us_mail for user " . $userdoc[
'id']);
107 return "Empty us_mail for user " . $userdoc[
'id'];
114 $token->userid = $userdoc[
'id'];
115 $token->token = $token->genToken();
116 $token->setExpiration();
117 $token->expendable = 1;
118 $err = $token->add();
120 error_log(__CLASS__ .
"::" . __FUNCTION__ .
" " .
"Error token->add() : " .
$err);
123 $err = $token->modify();
125 error_log(__CLASS__ .
"::" . __FUNCTION__ .
" " .
"Error token->modify() : " .
$err);
129 $callback_token = $token->getToken();
132 if ($layout == NULL) {
133 return "error creating new Layout from $layoutPath";
136 $layout->set(
'US_MAIL', $us_mail);
137 $layout->set(
'US_FNAME', $us_fname);
138 $layout->set(
'US_LNAME', $us_lname);
139 $layout->set(
'CALLBACK_TOKEN', $callback_token);
143 $mimemail =
new Fdl_Mail_Mime(
"\r\n");
148 # $action->exitError("Error: sendmail() returned with $ret");
149 return "Error: sendmail() returned with $ret";