mambax7 /
extcal
| 1 | <?php |
||
| 2 | /* |
||
| 3 | * You may not change or alter any portion of this comment or credits |
||
| 4 | * of supporting developers from this source code or any supporting source code |
||
| 5 | * which is considered copyrighted (c) material of the original comment or credit authors. |
||
| 6 | * |
||
| 7 | * This program is distributed in the hope that it will be useful, |
||
| 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
||
| 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
||
| 10 | */ |
||
| 11 | |||
| 12 | /** |
||
| 13 | * @copyright {@link https://xoops.org/ XOOPS Project} |
||
| 14 | * @license {@link http://www.gnu.org/licenses/gpl-2.0.html GNU GPL 2 or later} |
||
| 15 | * @package extcal |
||
| 16 | * @since |
||
| 17 | * @author XOOPS Development Team, |
||
| 18 | * |
||
| 19 | * L'utilisation de ce formulaire d'adminitration suppose |
||
| 20 | * que la classe correspondante de la table a été générées avec classGenerator |
||
| 21 | **/ |
||
| 22 | |||
| 23 | use XoopsModules\Extcal; |
||
| 24 | |||
| 25 | require_once __DIR__ . '/../../../class/uploader.php'; |
||
| 26 | require_once __DIR__ . '/../../../class/mail/phpmailer/class.phpmailer.php'; // First we require the PHPMailer libary in our script |
||
| 27 | // require_once __DIR__ . '/../class/Utility.php'; |
||
| 28 | require_once __DIR__ . '/constantes.php'; |
||
| 29 | require_once __DIR__ . '/../../../class/template.php'; |
||
| 30 | |||
| 31 | /******************************************************************** |
||
| 32 | * |
||
| 33 | ******************************************************************* |
||
| 34 | * @param $mode |
||
| 35 | * @param $event_id |
||
| 36 | * @param $member_uid |
||
| 37 | * @param $subject |
||
| 38 | * @param $tplMessage |
||
| 39 | */ |
||
| 40 | function sendMail2member($mode, $event_id, $member_uid, $subject, $tplMessage) |
||
| 41 | { |
||
| 42 | //mode = 0 pas d'entete |
||
| 43 | //mode = 1 format text |
||
| 44 | //mode = 2: format html |
||
| 45 | |||
| 46 | global $xoopsConfig, $xoopsDB; |
||
| 47 | // $t = print_r($xoopsConfig, true); |
||
| 48 | // echo "<pre>{$t}</pre>"; |
||
| 49 | /* |
||
| 50 | $member_uid = 1; |
||
| 51 | $event_id = 393; |
||
| 52 | $message = "Bonne journée à tous"; |
||
| 53 | $newStatus = 1; |
||
| 54 | $oldStatus = 0; |
||
| 55 | |||
| 56 | */ |
||
| 57 | |||
| 58 | //l'utilisateur ne pas etre notifié par mail |
||
| 59 | //if ($mode == 0) exit; |
||
| 60 | //------------------------------------------------------- |
||
| 61 | $tblMember = $xoopsDB->prefix('extcal_eventmember'); |
||
| 62 | $tblNotMember = $xoopsDB->prefix('extcal_eventnotmember'); |
||
| 63 | $tblUsers = $xoopsDB->prefix('users'); |
||
| 64 | $tblEvent = $xoopsDB->prefix('extcal_event'); |
||
| 65 | |||
| 66 | //-------------------------------------------------------------- |
||
| 67 | //Recuperation des données event,user et member |
||
| 68 | //Recuperation des données de l'evennement |
||
| 69 | $eventHandler = Extcal\Helper::getInstance()->getHandler(_EXTCAL_CLN_EVENT); |
||
| 70 | $obj = $eventHandler->getEvent($event_id); |
||
| 71 | $event = $eventHandler->objectToArray($obj); |
||
| 72 | $eventHandler->formatEventDate($event, _MD_EXTCAL_FORMAT_DATE); |
||
| 73 | |||
| 74 | $submiter_uid = $event['event_submitter']; |
||
| 75 | // Extcal\Utility::echoArray($event,'event'); |
||
| 76 | //-------------------------------------------------------------- |
||
| 77 | //Recuperation des données du user createur de l'evennement |
||
| 78 | $sql = <<<__sql__ |
||
| 79 | SELECT if(tu.name='', tu.uname, tu.name) AS name, tu.uname, tu.email |
||
| 80 | FROM {$tblUsers} tu |
||
| 81 | WHERE tu.uid = {$submiter_uid}; |
||
| 82 | __sql__; |
||
| 83 | |||
| 84 | $rst = $xoopsDB->query($sql); |
||
| 85 | $submiter = $xoopsDB->fetchArray($rst); |
||
| 86 | // echo "{$sql}<br>"; |
||
| 87 | // Extcal\Utility::echoArray($submiter,'submiter'); |
||
| 88 | //-------------------------------------------------------------- |
||
| 89 | //Recuperation des données du membre inscrit |
||
| 90 | $sql = <<<__sql__ |
||
| 91 | SELECT if(tu.name='', tu.uname, tu.name) AS name, tu.uname, tu.email |
||
| 92 | FROM {$tblUsers} tu |
||
| 93 | WHERE tu.uid = {$member_uid}; |
||
| 94 | __sql__; |
||
| 95 | |||
| 96 | $rst = $xoopsDB->query($sql); |
||
| 97 | $acteur = $xoopsDB->fetchArray($rst); |
||
| 98 | //echo "{$sql}<br>"; |
||
| 99 | // Extcal\Utility::echoArray($acteur,'acteur'); |
||
| 100 | //-------------------------------------------------------------- |
||
| 101 | //Recuperation des données des membres présents |
||
| 102 | $sql = <<<__sql__ |
||
| 103 | SELECT tu.uid, if(tu.name='', tu.uname, tu.name) AS name, tu.uname, tu.email, |
||
| 104 | tm.status |
||
| 105 | FROM {$tblMember} tm, |
||
| 106 | {$tblUsers} tu |
||
| 107 | WHERE tm.uid = tu.uid |
||
| 108 | AND tm.event_id = {$event_id} |
||
| 109 | __sql__; |
||
| 110 | |||
| 111 | $rst = $xoopsDB->query($sql); |
||
| 112 | $members = []; |
||
| 113 | while (false !== ($row = $xoopsDB->fetchArray($rst))) { |
||
| 114 | $row['status'] = _MD_EXTCAL_PRESENT; |
||
| 115 | $members[$row['uid']] = $row; |
||
| 116 | } |
||
| 117 | |||
| 118 | //-------------------------------------------------------------- |
||
| 119 | //Recuperation des données des membres absents |
||
| 120 | $sql = <<<__sql__ |
||
| 121 | SELECT tu.uid, if(tu.name='', tu.uname, tu.name) AS name, tu.uname, tu.email, |
||
| 122 | tm.status |
||
| 123 | FROM {$tblNotMember} tm, |
||
| 124 | {$tblUsers} tu |
||
| 125 | WHERE tm.uid = tu.uid |
||
| 126 | AND tm.event_id = {$event_id} |
||
| 127 | __sql__; |
||
| 128 | |||
| 129 | $rst = $xoopsDB->query($sql); |
||
| 130 | while (false !== ($row = $xoopsDB->fetchArray($rst))) { |
||
| 131 | $row['status'] = _MD_EXTCAL_ABSENT; |
||
| 132 | $members[$row['uid']] = $row; |
||
| 133 | } |
||
| 134 | |||
| 135 | // Extcal\Utility::echoArray($members,'members'); |
||
| 136 | // exit; |
||
| 137 | |||
| 138 | //-------------------------------------------------------------- |
||
| 139 | //Message et sujet du mail |
||
| 140 | $action = ''; //a voir JJD |
||
| 141 | $message = sprintf($tplMessage, $acteur['name']); |
||
| 142 | //$subject .= ' (' . rand(1, 100) . ')'; |
||
| 143 | $subject .= ' - ' . $acteur['name']; |
||
| 144 | //-------------------------------------------------------------- |
||
| 145 | //Chargement du template dans le dossier de langue |
||
| 146 | //$f = _EXTCAL_PATH_LG . $xoopsConfig['language'] . '\mail_inscription.html'; |
||
| 147 | //$tpl = new tpl($f); |
||
| 148 | $tpl = new \XoopsTpl(); |
||
| 149 | |||
| 150 | $tpl->assign('dateAction', date(_MD_EXTCAL_FORMAT_DATE)); |
||
| 151 | $tpl->assign('submiter', $submiter); |
||
| 152 | $tpl->assign('event', $event); |
||
| 153 | $tpl->assign('acteur', $acteur); |
||
| 154 | $tpl->assign('members', $members); |
||
| 155 | $tpl->assign('action', $action); |
||
| 156 | $tpl->assign('subject', $subject); |
||
| 157 | $tpl->assign('message', $message); |
||
| 158 | $tpl->assign('xoopsConfig', $xoopsConfig); |
||
| 159 | $tpl->assign('br', '<br>'); |
||
| 160 | |||
| 161 | //-------------------------------------------------------------- |
||
| 162 | $destinataires = []; |
||
| 163 | $destinataires[$submiter['email']] = $submiter['email']; |
||
| 164 | $destinataires[$acteur['email']] = $acteur['email']; |
||
| 165 | // while (list($k, $row) = each($members)) { |
||
| 166 | foreach ($members as $k => $row) { |
||
| 167 | $destinataires[$row['email']] = $row['email']; |
||
| 168 | } |
||
| 169 | |||
| 170 | // Extcal\Utility::echoArray($destinataires); |
||
| 171 | // exit; |
||
| 172 | |||
| 173 | $mail_fromName = $xoopsConfig['sitename']; |
||
| 174 | $mail_fromemail = $xoopsConfig['adminmail']; |
||
| 175 | $mail_subject = $subject; |
||
| 176 | |||
| 177 | $bEcho = false; |
||
| 178 | $mode = _EXTCAL_HEADER_HTML; |
||
| 179 | $sep = '|'; |
||
| 180 | |||
| 181 | $template = 'extcal_mail_member_text.tpl'; |
||
| 182 | if (_EXTCAL_HEADER_HTML == $mode) { |
||
| 183 | $template = 'extcal_mail_member_html.tpl'; |
||
| 184 | } |
||
| 185 | $mail_body = $tpl->fetch('db:' . $template); |
||
| 186 | |||
| 187 | extcal_SendMail($destinataires, $mail_fromName, $mail_fromemail, $mail_subject, $mail_body, $bEcho = false, $mode = 0, $sep = '|'); |
||
| 188 | |||
| 189 | //Prépartion de l'envoi |
||
| 190 | |||
| 191 | //-------------------------------------------------------------- |
||
| 192 | } |
||
| 193 | |||
| 194 | /***************************************************************** |
||
| 195 | **************************************************************** |
||
| 196 | * @param $destinataires |
||
| 197 | * @param $mail_fromname |
||
| 198 | * @param $mail_fromemail |
||
| 199 | * @param $mail_subject |
||
| 200 | * @param $mail_body |
||
| 201 | * @param bool $bEcho |
||
| 202 | * @param int $mode |
||
| 203 | * @param string $sep |
||
| 204 | */ |
||
| 205 | function extcal_SendMail( |
||
| 206 | $destinataires, |
||
| 207 | $mail_fromname, |
||
| 208 | $mail_fromemail, |
||
| 209 | $mail_subject, |
||
| 210 | $mail_body, |
||
| 211 | $bEcho = false, |
||
| 212 | $mode = 0, |
||
|
0 ignored issues
–
show
|
|||
| 213 | $sep = '|' |
||
| 214 | ) { |
||
| 215 | global $ModName, $signature, $mail_admin, $xoopsConfig, $xoopsDB, $xoopsModule; |
||
| 216 | |||
| 217 | //$bEcho=false; |
||
| 218 | //echo "<hr>function hermesMail<hr>"; |
||
| 219 | |||
| 220 | // $destinataires = array('[email protected]','[email protected]','[email protected]'); |
||
| 221 | //$mail_fromname = "test jjd hermes"; |
||
| 222 | if ('' == $mail_fromname) { |
||
| 223 | $mail_fromname = $mail_fromemail; |
||
| 224 | } |
||
| 225 | |||
| 226 | //$mail_fromemail = "[email protected]"; |
||
| 227 | //$mail_subject = "test hemes"; |
||
| 228 | //$mail_body = getContentTestMail(); |
||
| 229 | //----------------------------- |
||
| 230 | if (!is_array($destinataires)) { |
||
| 231 | $destinataires = explode($sep, $destinataires); |
||
| 232 | } |
||
| 233 | $header = extcal_getHeader(1, $mail_fromemail); |
||
| 234 | //----------------------------- |
||
| 235 | $myts = \MyTextSanitizer::getInstance(); |
||
| 236 | //$xoopsMailer = getMailer(); |
||
| 237 | $xoopsMailer = xoops_getMailer(); |
||
| 238 | |||
| 239 | //$xoopsMailer->setToUsers($destinataires[$i]); |
||
| 240 | |||
| 241 | // while (list($k, $v) = each($destinataires)) { |
||
| 242 | foreach ($destinataires as $k => $v) { |
||
| 243 | //for ( $i = 0, $iMax = count($destinataires); $i < $iMax; ++$i) { |
||
| 244 | //$xoopsMailer->setToUsers($destinataires[$i]); |
||
| 245 | $xoopsMailer->setToEmails($v); |
||
| 246 | //echo "setToUsers : {$destinataires[$i]}<br>"; |
||
| 247 | } |
||
| 248 | |||
| 249 | $xoopsMailer->multimailer->isHTML(true); |
||
| 250 | $xoopsMailer->setFromName($myts->oopsStripSlashesGPC($mail_fromname)); |
||
| 251 | |||
| 252 | $xoopsMailer->setFromEmail($myts->oopsStripSlashesGPC($mail_fromemail)); |
||
| 253 | |||
| 254 | $xoopsMailer->setSubject($myts->oopsStripSlashesGPC($mail_subject)); |
||
| 255 | $xoopsMailer->setBody($myts->oopsStripSlashesGPC($mail_body)); |
||
| 256 | //$xoopsMailer->encodeBody($mail_body); |
||
| 257 | |||
| 258 | $xoopsMailer->useMail(); |
||
| 259 | |||
| 260 | //function $xoopsMailer->sendMail($email, $subject, $body, $headers) |
||
| 261 | $xoopsMailer->send($bEcho); |
||
| 262 | |||
| 263 | if ($bEcho) { |
||
| 264 | Extcal\Utility::extEcho($xoopsMailer->getSuccess()); |
||
| 265 | Extcal\Utility::extEcho($xoopsMailer->getErrors()); |
||
| 266 | } |
||
| 267 | /* |
||
| 268 | |||
| 269 | echo "<hr>mail_fromname : {$mail_fromname}<br>" |
||
| 270 | ."mail_fromemail : {$mail_fromemail}<br>" |
||
| 271 | ."mail_subject : {$mail_subject}<br>" |
||
| 272 | ."mail_body : {$mail_body}<br><hr>"; |
||
| 273 | */ |
||
| 274 | //--------------------------- |
||
| 275 | /* |
||
| 276 | |||
| 277 | $adresse = "[email protected]"; |
||
| 278 | $bolOk = mail($adresse, "test envoi mail", "test envoi envoi mail via php"); |
||
| 279 | $r= (($bolOk) ? " => Succés" : "Echec"); |
||
| 280 | echo "<hr>==> <b>{$r}</b> de l'envoi du mail a: ==> {$adresse}<br>" ; |
||
| 281 | */ |
||
| 282 | } |
||
| 283 | |||
| 284 | /**************************************************************************** |
||
| 285 | * |
||
| 286 | *************************************************************************** |
||
| 287 | * @param $mode |
||
| 288 | * @param $emailSender |
||
| 289 | * |
||
| 290 | * @return string |
||
| 291 | */ |
||
| 292 | function extcal_getHeader($mode, $emailSender) |
||
| 293 | { |
||
| 294 | //mode = 0 pas d'entete |
||
| 295 | //mode = 1 format text |
||
| 296 | //mode = 2: format html |
||
| 297 | |||
| 298 | global $xoopsConfig; |
||
| 299 | |||
| 300 | // $t = print_r($xoopsConfig, true); |
||
| 301 | // echo "<pre>{$t}</pre>"; |
||
| 302 | |||
| 303 | //------------------------------------------------------ |
||
| 304 | $d = date('d-m-Y h:m:h', time()); |
||
| 305 | //----------------------------------------------------------- |
||
| 306 | //defini l'expediteur du mail |
||
| 307 | if ('' == $emailSender) { |
||
| 308 | if ('' == $xoopsConfig['adminmail']) { |
||
| 309 | $emailSender = "webmaster@{$_SERVER['SERVER_NAME']}"; |
||
| 310 | } else { |
||
| 311 | $emailSender = $xoopsConfig['adminmail']; |
||
| 312 | } |
||
| 313 | } |
||
| 314 | //----------------------------------------------------------- |
||
| 315 | $header = []; |
||
| 316 | $header[] = "From: {$emailSender}"; |
||
| 317 | $header[] = "Reply-To: {$emailSender}"; |
||
| 318 | $header[] = 'X-Mailer: PHP/' . PHP_VERSION; |
||
| 319 | |||
| 320 | if (_EXTCAL_HEADER_HTML == $mode) { |
||
| 321 | $header[] = 'MIME-Version: 1.0'; |
||
| 322 | $header[] = 'Content-type: text/html; charset=iso-8859-1'; |
||
| 323 | } else { |
||
| 324 | //bin rien a prori |
||
| 325 | } |
||
| 326 | $header[] = ''; |
||
| 327 | |||
| 328 | //$sHeader = implode("\r\n", $header); |
||
| 329 | $sHeader = implode("\r\n", $header); |
||
| 330 | |||
| 331 | return $sHeader; |
||
| 332 | } |
||
| 333 |
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.