forked from Wavyzz/dolibarr
New: Module mailman can subscribe/unsubscribe to ML according to
categories of member.
This commit is contained in:
16
ChangeLog
16
ChangeLog
@@ -4,16 +4,18 @@ English Dolibarr ChangeLog
|
||||
|
||||
***** ChangeLog for 3.5 compared to 3.4 *****
|
||||
For users:
|
||||
- New: [ task #877 ] Reorganize menus
|
||||
- New: [ task #858 ] Holiday module: note on manual holiday assignation
|
||||
- New: [ task #892 ] Add option in thridparty customer/supplier admin to hide non active in select_company method
|
||||
- New: [ task #531 ] Add a workload on tasks
|
||||
- New: [ task #877 ] Reorganize menus.
|
||||
- New: [ task #858 ] Holiday module: note on manual holiday assignation.
|
||||
- New: [ task #892 ] Add option in thridparty customer/supplier admin to hide non active in select_company method.
|
||||
- New: [ task #531 ] Add a workload on tasks.
|
||||
- New: Add graph of bank account input/output into input-output report page.
|
||||
- New: Add script export-bank-receipts.
|
||||
- New: Add option "filter=bank" onto script rebuild_merge_pdf.php to merge
|
||||
- New: Add option "filter=bank" onto script rebuild_merge_pdf.php to merge.
|
||||
PDF that has one payment on a specific bank account.*
|
||||
- New: [ task #901 ] Add Extrafeild on Fiche Inter
|
||||
- New: Show process id in all command line scripts
|
||||
- New: [ task #901 ] Add Extrafeild on Fiche Inter.
|
||||
- New: Show process id in all command line scripts.
|
||||
- New: Module mailman can subscribe/unsubscribe to ML according to categories of member.
|
||||
|
||||
For developers:
|
||||
- New: DolGraph can build graph with three lines.
|
||||
|
||||
|
||||
@@ -22,12 +22,12 @@
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file htdocs/adherents/admin/mailman.php
|
||||
* \file htdocs/admin/mailman.php
|
||||
* \ingroup mailmanspip
|
||||
* \brief Page to setup the module MailmanSpip (Mailman)
|
||||
*/
|
||||
|
||||
require '../../main.inc.php';
|
||||
require '../main.inc.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/mailmanspip.lib.php';
|
||||
|
||||
@@ -186,6 +186,7 @@ if (! empty($conf->global->ADHERENT_USE_MAILMAN))
|
||||
print '<script type="text/javascript">
|
||||
var i1=0;
|
||||
var i2=0;
|
||||
var i3=0;
|
||||
jQuery(document).ready(function(){
|
||||
jQuery("#exampleclick1").click(function(event){
|
||||
if (i1 == 0) { jQuery("#example1").show(); i1=1; }
|
||||
@@ -195,6 +196,10 @@ if (! empty($conf->global->ADHERENT_USE_MAILMAN))
|
||||
if (i2 == 0) { jQuery("#example2").show(); i2=1; }
|
||||
else if (i2 == 1) { jQuery("#example2").hide(); i2=0; }
|
||||
});
|
||||
jQuery("#exampleclick3").click(function(){
|
||||
if (i3 == 0) { jQuery("#example3").show(); i3=1; }
|
||||
else if (i3 == 1) { jQuery("#example3").hide(); i3=0; }
|
||||
});
|
||||
});
|
||||
</script>';
|
||||
|
||||
@@ -22,12 +22,12 @@
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file htdocs/adherents/admin/spip.php
|
||||
* \file htdocs/admin/spip.php
|
||||
* \ingroup mailmanspip
|
||||
* \brief Page to setup the module MailmanSpip (SPIP)
|
||||
*/
|
||||
|
||||
require '../../main.inc.php';
|
||||
require '../main.inc.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/mailmanspip.lib.php';
|
||||
|
||||
@@ -372,19 +372,19 @@ class Categorie
|
||||
* Link an object to the category
|
||||
*
|
||||
* @param Object $obj Object to link to category
|
||||
* @param string $type Type of category
|
||||
* @return int 1 : OK, -1 : erreur SQL, -2 : id non renseign, -3 : Already linked
|
||||
* @param string $type Type of category (member, supplier, product, customer)
|
||||
* @return int 1 : OK, -1 : erreur SQL, -2 : id not defined, -3 : Already linked
|
||||
*/
|
||||
function add_type($obj,$type)
|
||||
{
|
||||
if ($this->id == -1)
|
||||
{
|
||||
return -2;
|
||||
}
|
||||
if ($this->id == -1) return -2;
|
||||
if ($type == 'company') $type='societe';
|
||||
if ($type == 'fournisseur') $type='societe';
|
||||
|
||||
$sql = "INSERT INTO ".MAIN_DB_PREFIX."categorie_".$type." (fk_categorie, fk_".($type=='fournisseur'?'societe':$type).")";
|
||||
$sql = "INSERT INTO ".MAIN_DB_PREFIX."categorie_".$type." (fk_categorie, fk_".$type.")";
|
||||
$sql .= " VALUES (".$this->id.", ".$obj->id.")";
|
||||
|
||||
dol_syslog(get_class($this).'::add_type sql='.$sql);
|
||||
if ($this->db->query($sql))
|
||||
{
|
||||
return 1;
|
||||
@@ -956,37 +956,44 @@ class Categorie
|
||||
}
|
||||
|
||||
/**
|
||||
* Return list of categories linked to element of type $type with id $typeid
|
||||
* Return list of categories linked to element of id $id and type $typeid
|
||||
*
|
||||
* @param int $id Id of element
|
||||
* @param int $typeid Type id of link (0,1,2,3...)
|
||||
* @return array List of category objects
|
||||
* @param int $typeid Type of link (0 or 'product', 1 or 'supplier', 2 or 'customer', 3 or 'member', ...)
|
||||
* @param string $mode 'object'=Get array of categories, 'label'=Get array of category labels
|
||||
* @return mixed Array of category objects or < 0 if KO
|
||||
*/
|
||||
function containing($id,$typeid)
|
||||
function containing($id,$typeid,$mode='object')
|
||||
{
|
||||
$cats = array ();
|
||||
$cats = array();
|
||||
|
||||
$table=''; $type='';
|
||||
if ($typeid == 0) { $table='product'; $type='product'; }
|
||||
if ($typeid == 1) { $table='societe'; $type='fournisseur'; }
|
||||
if ($typeid == 2) { $table='societe'; $type='societe'; }
|
||||
if ($typeid == 3) { $table='member'; $type='member'; }
|
||||
if ($typeid == 0 || $typeid == 'product') { $typeid=0; $table='product'; $type='product'; }
|
||||
else if ($typeid == 1 || $typeid == 'supplier') { $typeid=1; $table='societe'; $type='fournisseur'; }
|
||||
else if ($typeid == 2 || $typeid == 'customer') { $typeid=2; $table='societe'; $type='societe'; }
|
||||
else if ($typeid == 3 || $typeid == 'member') { $typeid=3; $table='member'; $type='member'; }
|
||||
|
||||
$sql = "SELECT ct.fk_categorie";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."categorie_".$type." as ct";
|
||||
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."categorie as c ON ct.fk_categorie = c.rowid";
|
||||
$sql.= " WHERE ct.fk_".$table." = ".$id." AND c.type = ".$typeid;
|
||||
$sql = "SELECT ct.fk_categorie, c.label";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."categorie_".$type." as ct, ".MAIN_DB_PREFIX."categorie as c";
|
||||
$sql.= " WHERE ct.fk_categorie = c.rowid AND ct.fk_".$table." = ".$id." AND c.type = ".$typeid;
|
||||
$sql.= " AND c.entity IN (".getEntity('category',1).")";
|
||||
|
||||
dol_syslog(get_class($this).'::containing sql='.$sql);
|
||||
$res = $this->db->query($sql);
|
||||
if ($res)
|
||||
{
|
||||
while ($rec = $this->db->fetch_array($res))
|
||||
while ($obj = $this->db->fetch_object($res))
|
||||
{
|
||||
if ($mode == 'label')
|
||||
{
|
||||
$cats[] = $obj->label;
|
||||
}
|
||||
else {
|
||||
$cat = new Categorie($this->db);
|
||||
$cat->fetch($rec['fk_categorie']);
|
||||
$cat->fetch($obj->fk_categorie);
|
||||
$cats[] = $cat;
|
||||
}
|
||||
}
|
||||
|
||||
return $cats;
|
||||
}
|
||||
|
||||
@@ -1076,6 +1076,16 @@ function form_constantes($tableau,$strictw3c=0)
|
||||
print '</div>';
|
||||
//print 'http://lists.domain.com/cgi-bin/mailman/admin/%LISTE%/members/remove?adminpw=%MAILMAN_ADMINPW%&unsubscribees=%EMAIL%';
|
||||
}
|
||||
if ($const == 'ADHERENT_MAILMAN_LISTS')
|
||||
{
|
||||
print '. '.$langs->trans("Example").': <a href="#" id="exampleclick3">'.img_down().'</a><br>';
|
||||
print '<div id="example3" class="hidden">';
|
||||
print 'mymailmanlist<br>';
|
||||
print 'mymailmanlist1,mymailmanlist2<br>';
|
||||
if ($conf->categorie->enabled) print 'CATEG:Categ1:mymailmanlist1,CATEG:Categ2:mymailmanlist2<br>';
|
||||
print '</div>';
|
||||
//print 'http://lists.domain.com/cgi-bin/mailman/admin/%LISTE%/members/remove?adminpw=%MAILMAN_ADMINPW%&unsubscribees=%EMAIL%';
|
||||
}
|
||||
|
||||
print "</td>\n";
|
||||
|
||||
|
||||
@@ -32,12 +32,12 @@ function mailmanspip_admin_prepare_head()
|
||||
|
||||
return array(
|
||||
array(
|
||||
DOL_URL_ROOT.'/adherents/admin/mailman.php',
|
||||
DOL_URL_ROOT.'/admin/mailman.php',
|
||||
$langs->trans('Mailman'),
|
||||
'mailman'
|
||||
),
|
||||
array(
|
||||
DOL_URL_ROOT.'/adherents/admin/spip.php',
|
||||
DOL_URL_ROOT.'/admin/spip.php',
|
||||
$langs->trans('SPIP'),
|
||||
'spip'
|
||||
)
|
||||
|
||||
@@ -62,7 +62,7 @@ class modMailmanSpip extends DolibarrModules
|
||||
$this->requiredby = array();
|
||||
|
||||
// Config pages
|
||||
$this->config_page_url = array('mailman.php@adherents');
|
||||
$this->config_page_url = array('mailman.php');
|
||||
|
||||
// Constants
|
||||
$this->const = array();
|
||||
|
||||
@@ -314,26 +314,30 @@ class MailmanSpip
|
||||
return -1;
|
||||
}
|
||||
|
||||
if ($conf->adherent->enabled) // Synchro for members
|
||||
{
|
||||
if (! empty($conf->global->ADHERENT_MAILMAN_URL))
|
||||
{
|
||||
if ($listes == '' && ! empty($conf->global->ADHERENT_MAILMAN_LISTS))
|
||||
{
|
||||
$lists=explode(',',$conf->global->ADHERENT_MAILMAN_LISTS);
|
||||
}
|
||||
else
|
||||
{
|
||||
$lists=explode(',',$listes);
|
||||
}
|
||||
if ($listes == '' && ! empty($conf->global->ADHERENT_MAILMAN_LISTS)) $lists=explode(',',$conf->global->ADHERENT_MAILMAN_LISTS);
|
||||
else $lists=explode(',',$listes);
|
||||
|
||||
$categstatic=new Categorie($this->db);
|
||||
|
||||
foreach ($lists as $list)
|
||||
{
|
||||
// Filter on type something (ADHERENT_MAILMAN_LISTS = "filtervalue:mailinglist1,filtervalue2:mailinglist2,mailinglist3")
|
||||
// Filter on type something (ADHERENT_MAILMAN_LISTS = "mailinglist0,TYPE:typevalue:mailinglist1,CATEG:categvalue:mailinglist2")
|
||||
$tmp=explode(':',$list);
|
||||
if (! empty($tmp[1]))
|
||||
if (! empty($tmp[2]))
|
||||
{
|
||||
$list=$tmp[1];
|
||||
if ($object->element == 'member' && $object->type != $tmp[0]) // Filter on member type label
|
||||
$list=$tmp[2];
|
||||
if ($object->element == 'member' && $tmp[0] == 'TYPE' && $object->type != $tmp[1]) // Filter on member type label
|
||||
{
|
||||
dol_syslog("We ignore list ".$list." because object member type ".$object->type." does not match ".$tmp[0], LOG_DEBUG);
|
||||
dol_syslog("We ignore list ".$list." because object member type ".$object->type." does not match ".$tmp[1], LOG_DEBUG);
|
||||
continue;
|
||||
}
|
||||
if ($object->element == 'member' && $tmp[0] == 'CATEG' && ! in_array($tmp[1], $categstatic->containing($object->id, 'member', 'label'))) // Filter on member category
|
||||
{
|
||||
dol_syslog("We ignore list ".$list." because object member is not into category ".$tmp[1], LOG_DEBUG);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
@@ -356,6 +360,7 @@ class MailmanSpip
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Unsubscribe an email from all mailing-lists
|
||||
@@ -381,16 +386,13 @@ class MailmanSpip
|
||||
return -1;
|
||||
}
|
||||
|
||||
if ($conf->adherent->enabled) // Synchro for members
|
||||
{
|
||||
if (! empty($conf->global->ADHERENT_MAILMAN_UNSUB_URL))
|
||||
{
|
||||
if ($listes=='' && ! empty($conf->global->ADHERENT_MAILMAN_LISTS))
|
||||
{
|
||||
$lists=explode(',',$conf->global->ADHERENT_MAILMAN_LISTS);
|
||||
}
|
||||
else
|
||||
{
|
||||
$lists=explode(',',$listes);
|
||||
}
|
||||
if ($listes=='' && ! empty($conf->global->ADHERENT_MAILMAN_LISTS)) $lists=explode(',',$conf->global->ADHERENT_MAILMAN_LISTS);
|
||||
else $lists=explode(',',$listes);
|
||||
|
||||
foreach ($lists as $list)
|
||||
{
|
||||
// Filter on type something (ADHERENT_MAILMAN_LISTS = "filtervalue:mailinglist1,filtervalue2:mailinglist2,mailinglist3")
|
||||
@@ -423,6 +425,7 @@ class MailmanSpip
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
||||
|
||||
@@ -336,19 +336,7 @@ class Product extends CommonObject
|
||||
$result = $this->_log_price($user);
|
||||
if ($result > 0)
|
||||
{
|
||||
if ($this->update($id, $user, true, 'add') > 0)
|
||||
{
|
||||
// FIXME: not use here
|
||||
/*
|
||||
if ($this->catid > 0)
|
||||
{
|
||||
require_once DOL_DOCUMENT_ROOT .'/categories/class/categorie.class.php';
|
||||
$cat = new Categorie($this->db, $this->catid);
|
||||
$cat->add_type($this,"product");
|
||||
}
|
||||
*/
|
||||
}
|
||||
else
|
||||
if ($this->update($id, $user, true, 'add') <= 0)
|
||||
{
|
||||
$error++;
|
||||
$this->error='ErrorFailedToUpdateRecord';
|
||||
|
||||
@@ -184,17 +184,24 @@ class CategorieTest extends PHPUnit_Framework_TestCase
|
||||
print __METHOD__." catid=".$catid."\n";
|
||||
$this->assertGreaterThan(0, $catid);
|
||||
|
||||
// Category
|
||||
// Try to create product linked to category
|
||||
$localobject2=new Product($this->savdb);
|
||||
$localobject2->initAsSpecimen();
|
||||
$localobject2->ref.='-CATEG';
|
||||
$localobject2->tva_npr=1;
|
||||
$localobject2->catid=$catid;
|
||||
$result=$localobject2->create($user);
|
||||
$cat = new Categorie($this->savdb);
|
||||
$cat->id = $catid;
|
||||
$result=$cat->add_type($localobject2,"product");
|
||||
|
||||
print __METHOD__." result=".$result."\n";
|
||||
$this->assertGreaterThan(0, $result);
|
||||
|
||||
// Get list of categories for product
|
||||
$localcateg=new Categorie($this->savdb);
|
||||
$listofcateg=$localcateg->containing($localobject2->id, 'product', 'label');
|
||||
$this->assertTrue(in_array('Specimen Category for product',$listofcateg), 'Categ not found linked to product when it should');
|
||||
|
||||
return $id;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user