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

View File

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

View File

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