This commit is contained in:
Laurent Destailleur 2012-02-21 00:18:48 +01:00
parent 9e731a1c9f
commit f71073c3b5
3 changed files with 110 additions and 41 deletions

View File

@ -116,15 +116,16 @@ class Notify
}
/**
* \brief Check if notification are active for couple action/company.
* If yes, send mail and save trace into llx_notify.
* \param action Code of action in llx_c_action_trigger (new usage) or Id of action in llx_c_action_trigger (old usage)
* \param socid Id of third party
* \param texte Message to send
* \param objet_type Type of object the notification deals on (facture, order, propal, order_supplier...). Just for log in llx_notify.
* \param objet_id Id of object the notification deals on
* \param file Attach a file
* \return int <0 if KO, or number of changes if OK
* Check if notification are active for couple action/company.
* If yes, send mail and save trace into llx_notify.
*
* @param string $action Code of action in llx_c_action_trigger (new usage) or Id of action in llx_c_action_trigger (old usage)
* @param int $socid Id of third party
* @param string $texte Message to send
* @param string $objet_type Type of object the notification deals on (facture, order, propal, order_supplier...). Just for log in llx_notify.
* @param int $objet_id Id of object the notification deals on
* @param string $file Attach a file
* @return int <0 if KO, or number of changes if OK
*/
function send($action, $socid, $texte, $objet_type, $objet_id, $file="")
{
@ -200,17 +201,21 @@ class Notify
$replyto = $conf->notification->email_from;
$mailfile = new CMailFile($subject,
$mailfile = new CMailFile(
$subject,
$sendto,
$replyto,
$message,
array($file),
array($mimefile),
array($filename[count($filename)-1]),
'', '', 0, $msgishtml
);
'',
'',
0,
$msgishtml
);
if ( $mailfile->sendfile() )
if ($mailfile->sendfile())
{
$sendto = htmlentities($sendto);

View File

@ -38,40 +38,99 @@ class RssParser
protected $_lastfetchdate; // Last successful fetch
protected $_rssarray=array();
// Accessors
/**
* getFormat
*
* @return string
*/
public function getFormat() {
return $this->_format;
}
/**
* getUrlRss
*
* @return string
*/
public function getUrlRss() {
return $this->_urlRSS;
}
/**
* getLanguage
*
* @return string
*/
public function getLanguage() {
return $this->_language;
}
/**
* getGenerator
*
* @return string
*/
public function getGenerator() {
return $this->_generator;
}
/**
* getCopyright
*
* @return string
*/
public function getCopyright() {
return $this->_copyright;
}
/**
* getLastBuildDate
*
* @return string
*/
public function getLastBuildDate() {
return $this->_lastbuilddate;
}
/**
* getImageUrl
*
* @return string
*/
public function getImageUrl() {
return $this->_imageurl;
}
/**
* getLink
*
* @return string
*/
public function getLink() {
return $this->_link;
}
/**
* getTitle
*
* @return string
*/
public function getTitle() {
return $this->_title;
}
/**
* getDescription
*
* @return string
*/
public function getDescription() {
return $this->_description;
}
/**
* getLastFetchDate
*
* @return string
*/
public function getLastFetchDate() {
return $this->_lastfetchdate;
}
/**
* getItems
*
* @return string
*/
public function getItems() {
return $this->_rssarray;
}
@ -96,11 +155,11 @@ class RssParser
/**
* Parse rss URL
*
* @param urlRSS Url to parse
* @param maxNb Max nb of records to get (0 for no limit)
* @param cachedelay 0=No cache, nb of seconds we accept cache files (cachedir must also be defined)
* @param cachedir Directory where to save cache file
* @return int <0 if KO, >0 if OK
* @param string $urlRSS Url to parse
* @param int $maxNb Max nb of records to get (0 for no limit)
* @param int $cachedelay 0=No cache, nb of seconds we accept cache files (cachedir must also be defined)
* @param strnig $cachedir Directory where to save cache file
* @return int <0 if KO, >0 if OK
*/
public function parser($urlRSS, $maxNb=0, $cachedelay=60, $cachedir='')
{
@ -371,7 +430,7 @@ class RssParser
/**
* Triggered when opened tag is found
*
* @param string $p
* @param string $p Start
* @param string $element Tag
* @param array &$attrs Attributes of tags
* @return void
@ -383,10 +442,12 @@ class RssParser
// check for a namespace, and split if found
$ns = false;
if (strpos($element, ':' )) {
if (strpos($element, ':'))
{
list($ns, $el) = explode(':', $element, 2);
}
if ( $ns and $ns != 'rdf' ) {
if ( $ns and $ns != 'rdf' )
{
$this->current_namespace = $ns;
}
@ -458,7 +519,7 @@ class RssParser
// if tags are inlined, then flatten
$attrs_str = join(' ', array_map('map_attrs', array_keys($attrs), array_values($attrs)));
$this->append_content("<$element $attrs_str>" );
$this->append_content("<$element $attrs_str>");
array_unshift($this->stack, $el);
}
@ -489,7 +550,7 @@ class RssParser
/**
* Triggered when CDATA is found
*
* @param string $p
* @param string $p P
* @param string $text Tag
* @return void
*/
@ -499,7 +560,8 @@ class RssParser
{
$this->append_content($text);
}
else {
else
{
$current_el = join('_', array_reverse($this->stack));
$this->append($current_el, $text);
}
@ -508,7 +570,7 @@ class RssParser
/**
* Triggered when closed tag is found
*
* @param string $p
* @param string $p P
* @param string $el Tag
* @return void
*/
@ -516,7 +578,7 @@ class RssParser
{
$el = strtolower($el);
if ( $el == 'item' or $el == 'entry' )
if ($el == 'item' or $el == 'entry')
{
$this->items[] = $this->current_item;
$this->current_item = array();

View File

@ -34,9 +34,9 @@ abstract class Stats
/**
* Return nb of entity by month for several years
*
* @param endyear Start year
* @param startyear End year
* @return array Array of values
* @param int $endyear Start year
* @param int $startyear End year
* @return array Array of values
*/
function getNbByMonthWithPrevYear($endyear,$startyear)
{
@ -71,9 +71,9 @@ abstract class Stats
/**
* Return amount of entity by month for several years
*
* @param endyear Start year
* @param startyear End year
* @return array Array of values
* @param int $endyear Start year
* @param int $startyear End year
* @return array Array of values
*/
function getAmountByMonthWithPrevYear($endyear,$startyear)
{
@ -108,8 +108,8 @@ abstract class Stats
/**
* Return nb of elements by year
*
* @param sql SQL request
* @return array
* @param string $sql SQL request
* @return array
*/
function _getNbByYear($sql)
{
@ -138,8 +138,8 @@ abstract class Stats
/**
* Return nb of elements, total amount and avg amount each year
*
* @param sql SQL request
* @return array Array with nb, total amount, average for each year
* @param string $sql SQL request
* @return array Array with nb, total amount, average for each year
*/
function _getAllByYear($sql)
{
@ -220,8 +220,9 @@ abstract class Stats
/**
* Renvoie le nombre d'element par mois pour une annee donnee
*
* @param year Year
* @param sql SQL
* @param int $year Year
* @param string $sql SQL
* @return array
*/
function _getAmountByMonth($year, $sql)
{
@ -265,8 +266,9 @@ abstract class Stats
/**
* Renvoie le montant moyen par mois pour une annee donnee
*
* @param year Year
* @param sql SQL
* @param int $year Year
* @param string $sql SQL
* @return array
*/
function _getAverageByMonth($year, $sql)
{