Changeset 26077


Ignore:
Timestamp:
Dec 22, 2013, 2:26:22 PM (10 years ago)
Author:
Eric
Message:

Piwigo 2.6 compliance - Step 2:
Using new pwg_mail function

File:
1 edited

Legend:

Unmodified
Added
Removed
  • extensions/UserAdvManager/trunk/include/functions.inc.php

    r25092 r26077  
    12811281    );
    12821282
    1283     UAM_mail_notification_admins($subject, $content);
     1283    //UAM_mail_notification_admins($subject, $content);
     1284    pwg_mail_notification_admins($subject, $content, true);
    12841285  }
    12851286        elseif ((isset($conf_UAM['CONFIRM_MAIL']) and $conf_UAM['CONFIRM_MAIL'] == 'true') and $confirm)
     
    12881289    if (isset($conf_UAM['ADD_GALLERY_URL_TO_EMAILS']) and $conf_UAM['ADD_GALLERY_URL_TO_EMAILS'] == 'true')
    12891290    {
    1290       pwg_mail($email, array(
    1291         'subject' => $subject,
    1292          'content' => (isset($infos1) ? $infos1_perso.l10n_args($infos1)."\n\n" : "").(isset($infos2) ? $infos2_perso.l10n_args($infos2)."\n\n" : "").get_absolute_root_url(),
    1293       ));
     1291      $content = (isset($infos1) ? $infos1_perso.l10n_args($infos1)."\n\n" : "").(isset($infos2) ? $infos2_perso.l10n_args($infos2)."\n\n" : "").get_absolute_root_url();
     1292
     1293      pwg_mail(
     1294        array(
     1295          'name' => stripslashes($username),
     1296          'email' => $email,
     1297          ),
     1298        array(
     1299          'content' => $content,
     1300          'content_format' => 'text/plain',
     1301          'subject' => $subject,
     1302          )
     1303        );
    12941304    }
    12951305    // Do not add gallery URL at the end of the email
    12961306    elseif (isset($conf_UAM['ADD_GALLERY_URL_TO_EMAILS']) and $conf_UAM['ADD_GALLERY_URL_TO_EMAILS'] == 'false')
    12971307    {
    1298       pwg_mail($email, array(
    1299         'subject' => $subject,
    1300          'content' => (isset($infos1) ? $infos1_perso.l10n_args($infos1)."\n\n" : "").(isset($infos2) ? $infos2_perso.l10n_args($infos2)."\n\n" : ""),
    1301       ));
     1308      $content = (isset($infos1) ? $infos1_perso.l10n_args($infos1)."\n\n" : "").(isset($infos2) ? $infos2_perso.l10n_args($infos2)."\n\n" : "");
     1309
     1310      pwg_mail(
     1311        array(
     1312          'name' => stripslashes($username),
     1313          'email' => $email,
     1314          ),
     1315        array(
     1316          'content' => $content,
     1317          'content_format' => 'text/plain',
     1318          'subject' => $subject,
     1319          )
     1320        );
    13021321    }
    13031322    // By default do not add gallery URL at the end of the email
    13041323    else
    13051324    {
    1306       pwg_mail($email, array(
    1307         'subject' => $subject,
    1308          'content' => (isset($infos1) ? $infos1_perso.l10n_args($infos1)."\n\n" : "").(isset($infos2) ? $infos2_perso.l10n_args($infos2)."\n\n" : ""),
    1309       ));
     1325      $content = (isset($infos1) ? $infos1_perso.l10n_args($infos1)."\n\n" : "").(isset($infos2) ? $infos2_perso.l10n_args($infos2)."\n\n" : "");
     1326
     1327      pwg_mail(
     1328        array(
     1329          'name' => stripslashes($username),
     1330          'email' => $email,
     1331          ),
     1332        array(
     1333          'content' => $content,
     1334          'content_format' => 'text/plain',
     1335          'subject' => $subject,
     1336          )
     1337        );
    13101338    }
    13111339        }
     
    13131341// ----------------------------------
    13141342switch_lang_back();
    1315 }
    1316 
    1317 
    1318 /**
    1319  * Function called from SendMail2User in functions.inc.php to notify admins on user registration validation with validation key
    1320  *
    1321  * @param:
    1322  *   - keyargs_subject: mail subject on l10n_args format
    1323  *   - keyargs_content: mail content on l10n_args format
    1324  *
    1325  * @return boolean (Ok or not)
    1326  */
    1327 function UAM_mail_notification_admins($keyargs_subject, $keyargs_content)
    1328 {
    1329   global $conf, $user;
    1330 
    1331   // Check arguments
    1332   if (empty($keyargs_subject) or empty($keyargs_content))
    1333   {
    1334     return false;
    1335   }
    1336 
    1337   $return = true;
    1338 
    1339   $admins = array();
    1340 
    1341   $query = '
    1342 SELECT
    1343     u.username AS username,
    1344     u.mail_address AS mail_address
    1345   FROM '.USERS_TABLE.' AS u
    1346     JOIN '.USER_INFOS_TABLE.' AS i ON i.user_id = id
    1347   WHERE i.status in (\'webmaster\',  \'admin\')
    1348     AND mail_address IS NOT NULL
    1349     AND i.user_id = id
    1350   ORDER BY username
    1351 ;';
    1352 
    1353   $datas = pwg_query($query);
    1354   if (!empty($datas))
    1355   {
    1356     while ($admin = pwg_db_fetch_assoc($datas))
    1357     {
    1358       if (!empty($admin['mail_address']))
    1359       {
    1360         array_push($admins, format_email($admin['username'], $admin['mail_address']));
    1361       }
    1362     }
    1363   }
    1364 
    1365   if (count($admins) > 0)
    1366   {
    1367     $content = l10n_args($keyargs_content)."\n";
    1368 
    1369     $return = pwg_mail(
    1370       implode(', ', $admins),
    1371       array(
    1372         'subject' => '['.$conf['gallery_title'].'] '.l10n_args($keyargs_subject),
    1373         'content' => $content,
    1374         'content_format' => 'text/plain',
    1375         'email_format' => 'text/plain',
    1376         )
    1377       );
    1378   }
    1379 
    1380   return $return;
    13811343}
    13821344
     
    15321494  if (isset($conf_UAM['ADD_GALLERY_URL_TO_EMAILS']) and $conf_UAM['ADD_GALLERY_URL_TO_EMAILS'] == 'true')
    15331495  {
    1534     pwg_mail($email, array(
    1535       'subject' => $subject,
    1536       'content' => ($infos1."\n\n").(isset($infos2) ? l10n_args($infos2)."\n\n" : "").get_absolute_root_url(),
    1537     ));
     1496    $content = ($infos1."\n\n").(isset($infos2) ? l10n_args($infos2)."\n\n" : "").get_absolute_root_url();
     1497
     1498    pwg_mail(
     1499      array(
     1500        'name' => stripslashes($username),
     1501        'email' => $email,
     1502        ),
     1503      array(
     1504        'content' => $content,
     1505        'content_format' => 'text/plain',
     1506        'subject' => $subject,
     1507        )
     1508      );
    15381509  }
    15391510  // Do not add gallery URL at the end of the email
    15401511  elseif (isset($conf_UAM['ADD_GALLERY_URL_TO_EMAILS']) and $conf_UAM['ADD_GALLERY_URL_TO_EMAILS'] == 'false')
    15411512  {
    1542     pwg_mail($email, array(
    1543       'subject' => $subject,
    1544       'content' => ($infos1."\n\n").(isset($infos2) ? l10n_args($infos2)."\n\n" : ""),
    1545     ));
     1513    $content = ($infos1."\n\n").(isset($infos2) ? l10n_args($infos2)."\n\n" : "");
     1514
     1515    pwg_mail(
     1516      array(
     1517        'name' => stripslashes($username),
     1518        'email' => $email,
     1519        ),
     1520      array(
     1521        'content' => $content,
     1522        'content_format' => 'text/plain',
     1523        'subject' => $subject,
     1524        )
     1525      );
    15461526  }
    15471527  // By default do not add gallery URL at the end of the email
    15481528  else
    15491529  {
    1550     pwg_mail($email, array(
    1551       'subject' => $subject,
    1552       'content' => ($infos1."\n\n").(isset($infos2) ? l10n_args($infos2)."\n\n" : ""),
    1553     ));
     1530    $content = ($infos1."\n\n").(isset($infos2) ? l10n_args($infos2)."\n\n" : "");
     1531
     1532    pwg_mail(
     1533      array(
     1534        'name' => stripslashes($username),
     1535        'email' => $email,
     1536        ),
     1537      array(
     1538        'content' => $content,
     1539        'content_format' => 'text/plain',
     1540        'subject' => $subject,
     1541        )
     1542      );
    15541543  }
    15551544
     
    16351624  if (isset($conf_UAM['ADD_GALLERY_URL_TO_EMAILS']) and $conf_UAM['ADD_GALLERY_URL_TO_EMAILS'] == 'true')
    16361625  {
    1637     pwg_mail($email, array(
    1638       'subject' => $subject,
    1639       'content' => $infos1.get_absolute_root_url(),
    1640     ));
     1626    $content = $infos1.get_absolute_root_url();
     1627
     1628    pwg_mail(
     1629      array(
     1630        'name' => stripslashes($username),
     1631        'email' => $email,
     1632        ),
     1633      array(
     1634        'content' => $content,
     1635        'content_format' => 'text/plain',
     1636        'subject' => $subject,
     1637        )
     1638      );
    16411639  }
    16421640  // Do not add gallery URL at the end of the email
    16431641  elseif (isset($conf_UAM['ADD_GALLERY_URL_TO_EMAILS']) and $conf_UAM['ADD_GALLERY_URL_TO_EMAILS'] == 'false')
    16441642  {
    1645     pwg_mail($email, array(
    1646       'subject' => $subject,
    1647       'content' => $infos1,
    1648     ));
     1643    $content = $infos1;
     1644
     1645    pwg_mail(
     1646      array(
     1647        'name' => stripslashes($username),
     1648        'email' => $email,
     1649        ),
     1650      array(
     1651        'content' => $content,
     1652        'content_format' => 'text/plain',
     1653        'subject' => $subject,
     1654        )
     1655      );
    16491656  }
    16501657  // By default do not add gallery URL at the end of the email
    16511658  else
    16521659  {
    1653     pwg_mail($email, array(
    1654       'subject' => $subject,
    1655       'content' => $infos1,
    1656     ));
     1660    $content = $infos1;
     1661
     1662    pwg_mail(
     1663      array(
     1664        'name' => stripslashes($username),
     1665        'email' => $email,
     1666        ),
     1667      array(
     1668        'content' => $content,
     1669        'content_format' => 'text/plain',
     1670        'subject' => $subject,
     1671        )
     1672      );
    16571673  }
    16581674
     
    17611777  if (isset($conf_UAM['ADD_GALLERY_URL_TO_EMAILS']) and $conf_UAM['ADD_GALLERY_URL_TO_EMAILS'] == 'true')
    17621778  {
    1763     pwg_mail($email, array(
    1764       'subject' => $subject,
    1765       'content' => ($custom_txt.l10n_args($infos1)."\n\n".l10n_args($infos2)."\n\n").get_absolute_root_url(),
    1766     ));
     1779    $content = ($custom_txt.l10n_args($infos1)."\n\n".l10n_args($infos2)."\n\n").get_absolute_root_url();
     1780
     1781    pwg_mail(
     1782      array(
     1783        'name' => stripslashes($username),
     1784        'email' => $email,
     1785        ),
     1786      array(
     1787        'content' => $content,
     1788        'content_format' => 'text/plain',
     1789        'subject' => $subject,
     1790        )
     1791      );
    17671792  }
    17681793  // Do not add gallery URL at the end of the email
    17691794  elseif (isset($conf_UAM['ADD_GALLERY_URL_TO_EMAILS']) and $conf_UAM['ADD_GALLERY_URL_TO_EMAILS'] == 'false')
    17701795  {
    1771     pwg_mail($email, array(
    1772       'subject' => $subject,
    1773       'content' => ($custom_txt.l10n_args($infos1)."\n\n".l10n_args($infos2)."\n\n"),
    1774     ));
     1796    $content = ($custom_txt.l10n_args($infos1)."\n\n".l10n_args($infos2)."\n\n");
     1797
     1798    pwg_mail(
     1799      array(
     1800        'name' => stripslashes($username),
     1801        'email' => $email,
     1802        ),
     1803      array(
     1804        'content' => $content,
     1805        'content_format' => 'text/plain',
     1806        'subject' => $subject,
     1807        )
     1808      );
    17751809  }
    17761810  // By default do not add gallery URL at the end of the email
    17771811  else
    17781812  {
    1779     pwg_mail($email, array(
    1780       'subject' => $subject,
    1781       'content' => ($custom_txt.l10n_args($infos1)."\n\n".l10n_args($infos2)."\n\n"),
    1782     ));
     1813    $content = ($custom_txt.l10n_args($infos1)."\n\n".l10n_args($infos2)."\n\n");
     1814
     1815    pwg_mail(
     1816      array(
     1817        'name' => stripslashes($username),
     1818        'email' => $email,
     1819        ),
     1820      array(
     1821        'content' => $content,
     1822        'content_format' => 'text/plain',
     1823        'subject' => $subject,
     1824        )
     1825      );
    17831826  }
    17841827
     
    18491892    // -------------------------------------------------------
    18501893    $patterns[] = '#\[username\]#i';
    1851     $replacements[] = $result['username'];
     1894    $replacements[] = stripslashes($result['username']);
    18521895    $patterns[] = '#\[mygallery\]#i';
    18531896    $replacements[] = $conf['gallery_title'];
     
    18651908    // ----------------------------------------------------------------
    18661909    $patterns[] = '#\[username\]#i';
    1867     $replacements[] = $result['username'];
     1910    $replacements[] = stripslashes($result['username']);
    18681911    $patterns[] = '#\[mygallery\]#i';
    18691912    $replacements[] = $conf['gallery_title'];
     
    18881931  if (isset($conf_UAM['ADD_GALLERY_URL_TO_EMAILS']) and $conf_UAM['ADD_GALLERY_URL_TO_EMAILS'] == 'true')
    18891932  {
    1890     pwg_mail($result['mail_address'], array(
    1891       'subject' => $subject,
    1892       'content' => (l10n_args($infos)."\n\n".$custom_txt).get_absolute_root_url(),
    1893     ));
     1933    $content = (l10n_args($infos)."\n\n".$custom_txt).get_absolute_root_url();
     1934
     1935    pwg_mail(
     1936      array(
     1937        'name' => stripslashes($result['username']),
     1938        'email' => $result['mail_address'],
     1939        ),
     1940      array(
     1941        'content' => $content,
     1942        'content_format' => 'text/plain',
     1943        'subject' => $subject,
     1944        )
     1945      );
    18941946  }
    18951947  // Do not add gallery URL at the end of the email
    18961948  elseif (isset($conf_UAM['ADD_GALLERY_URL_TO_EMAILS']) and $conf_UAM['ADD_GALLERY_URL_TO_EMAILS'] == 'false')
    18971949  {
    1898     pwg_mail($result['mail_address'], array(
    1899       'subject' => $subject,
    1900       'content' => (l10n_args($infos)."\n\n".$custom_txt),
    1901     ));
     1950    $content = (l10n_args($infos)."\n\n".$custom_txt);
     1951
     1952    pwg_mail(
     1953      array(
     1954        'name' => stripslashes($result['username']),
     1955        'email' => $result['mail_address'],
     1956        ),
     1957      array(
     1958        'content' => $content,
     1959        'content_format' => 'text/plain',
     1960        'subject' => $subject,
     1961        )
     1962      );
    19021963  }
    19031964  // By defaukt do not add gallery URL at the end of the email
    19041965  else
    19051966  {
    1906     pwg_mail($result['mail_address'], array(
    1907       'subject' => $subject,
    1908       'content' => (l10n_args($infos)."\n\n".$custom_txt),
    1909     ));
     1967    $content = (l10n_args($infos)."\n\n".$custom_txt);
     1968
     1969    pwg_mail(
     1970      array(
     1971        'name' => stripslashes($result['username']),
     1972        'email' => $result['mail_address'],
     1973        ),
     1974      array(
     1975        'content' => $content,
     1976        'content_format' => 'text/plain',
     1977        'subject' => $subject,
     1978        )
     1979      );
    19101980  }
    19111981
     
    20552125
    20562126    pwg_query($query);
    2057 
    2058 //    $query = '
    2059 //INSERT INTO '.USER_INFOS_TABLE.'
    2060 //  (user_id, level)
    2061 //VALUES
    2062 //  ('.$user_id.', "'.$conf_UAM['NO_VALID_LEVEL'].'")
    2063 //;';
    2064 //
    2065 //    pwg_query($query);
    20662127  }
    20672128}
Note: See TracChangeset for help on using the changeset viewer.