New: Prepare 3.4 branch

New: Add hook for agenda, info and category tabs
This commit is contained in:
Laurent Destailleur 2013-01-12 14:34:16 +01:00
parent 22dcb7ee6a
commit ec8b260bf6
8 changed files with 133 additions and 75 deletions

View File

@ -188,6 +188,7 @@ export list="
--ignore-table=$base.llx_cabinetmed_examenprescrit
--ignore-table=$base.llx_cabinetmed_motifcons
--ignore-table=$base.llx_cabinetmed_patient
--ignore-table=$base.llx_cabinetmed_societe
--ignore-table=$base.llx_publi_c_contact_list
--ignore-table=$base.llx_publi_c_dnd_list
--ignore-table=$base.llx_publi_c_method_list

View File

@ -85,84 +85,96 @@ if ($id || $ref)
if ($user->societe_id) $socid=$user->societe_id;
$result = restrictedArea($user,$objecttype,$objectid,$dbtablename,'','',$fieldid);
// Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array
include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
$hookmanager=new HookManager($db);
$hookmanager->initHooks(array('categorycard'));
/*
* Actions
*/
//Suppression d'un objet d'une categorie
if ($removecat > 0)
$parameters=array('id'=>$socid);
$reshook=$hookmanager->executeHooks('doActions',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks
$error=$hookmanager->error; $errors=array_merge($errors, (array) $hookmanager->errors);
if (empty($reshook))
{
if ($type==0 && ($user->rights->produit->creer || $user->rights->service->creer))
//Suppression d'un objet d'une categorie
if ($removecat > 0)
{
require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
$object = new Product($db);
$result = $object->fetch($id, $ref);
$elementtype = 'product';
}
if ($type==1 && $user->rights->societe->creer)
{
$object = new Societe($db);
$result = $object->fetch($objectid);
}
if ($type==2 && $user->rights->societe->creer)
{
$object = new Societe($db);
$result = $object->fetch($objectid);
}
if ($type == 3 && $user->rights->adherent->creer)
{
require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php';
$object = new Adherent($db);
$result = $object->fetch($objectid);
}
$cat = new Categorie($db);
$result=$cat->fetch($removecat);
if ($type==0 && ($user->rights->produit->creer || $user->rights->service->creer))
{
require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
$object = new Product($db);
$result = $object->fetch($id, $ref);
$elementtype = 'product';
}
if ($type==1 && $user->rights->societe->creer)
{
$object = new Societe($db);
$result = $object->fetch($objectid);
}
if ($type==2 && $user->rights->societe->creer)
{
$object = new Societe($db);
$result = $object->fetch($objectid);
}
if ($type == 3 && $user->rights->adherent->creer)
{
require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php';
$object = new Adherent($db);
$result = $object->fetch($objectid);
}
$cat = new Categorie($db);
$result=$cat->fetch($removecat);
$result=$cat->del_type($object,$elementtype);
}
$result=$cat->del_type($object,$elementtype);
}
// Add object into a category
if ($parent > 0)
{
if ($type==0 && ($user->rights->produit->creer || $user->rights->service->creer))
// Add object into a category
if ($parent > 0)
{
require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
$object = new Product($db);
$result = $object->fetch($id, $ref);
$elementtype = 'product';
}
if ($type==1 && $user->rights->societe->creer)
{
$object = new Societe($db);
$result = $object->fetch($objectid);
$elementtype = 'fournisseur';
}
if ($type==2 && $user->rights->societe->creer)
{
$object = new Societe($db);
$result = $object->fetch($objectid);
$elementtype = 'societe';
}
if ($type==3 && $user->rights->adherent->creer)
{
require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php';
$object = new Adherent($db);
$result = $object->fetch($objectid);
$elementtype = 'member';
}
$cat = new Categorie($db);
$result=$cat->fetch($parent);
if ($type==0 && ($user->rights->produit->creer || $user->rights->service->creer))
{
require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
$object = new Product($db);
$result = $object->fetch($id, $ref);
$elementtype = 'product';
}
if ($type==1 && $user->rights->societe->creer)
{
$object = new Societe($db);
$result = $object->fetch($objectid);
$elementtype = 'fournisseur';
}
if ($type==2 && $user->rights->societe->creer)
{
$object = new Societe($db);
$result = $object->fetch($objectid);
$elementtype = 'societe';
}
if ($type==3 && $user->rights->adherent->creer)
{
require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php';
$object = new Adherent($db);
$result = $object->fetch($objectid);
$elementtype = 'member';
}
$cat = new Categorie($db);
$result=$cat->fetch($parent);
$result=$cat->add_type($object,$elementtype);
if ($result >= 0)
{
$mesg='<div class="ok">'.$langs->trans("WasAddedSuccessfully",$cat->label).'</div>';
}
else
{
if ($cat->error == 'DB_ERROR_RECORD_ALREADY_EXISTS') $mesg='<div class="error">'.$langs->trans("ObjectAlreadyLinkedToCategory").'</div>';
else $mesg=$langs->trans("Error").' '.$cat->error;
$result=$cat->add_type($object,$elementtype);
if ($result >= 0)
{
$mesg='<div class="ok">'.$langs->trans("WasAddedSuccessfully",$cat->label).'</div>';
}
else
{
if ($cat->error == 'DB_ERROR_RECORD_ALREADY_EXISTS') $mesg='<div class="error">'.$langs->trans("ObjectAlreadyLinkedToCategory").'</div>';
else $mesg=$langs->trans("Error").' '.$cat->error;
}
}
}

View File

@ -115,7 +115,7 @@ class HookManager
* @param Object &$object Object to use hooks on
* @param string &$action Action code on calling page ('create', 'edit', 'view', 'add', 'update', 'delete'...)
* @return mixed For doActions,formObjectOptions: Return 0 if we want to keep standard actions, >0 if if want to stop standard actions, <0 means KO.
* For printSearchForm,printLeftBlock,printTopRightMenu,formAddObjectLine,...: Return HTML string. TODO Must always return an int and things to print into ->resprints.
* For printSearchForm,printLeftBlock,printTopRightMenu,formAddObjectLine,...: Return HTML string. TODO Must always return an int and things to print into ->resprints.
* Can also return some values into an array ->results.
* $this->error or this->errors are also defined by class called by this function if error.
*/
@ -136,6 +136,8 @@ class HookManager
{
foreach($modules as $module => $actionclassinstance)
{
//print 'class='.get_class($actionclassinstance).' method='.$method.' action='.$action;
// jump to next class if method does not exists
if (! method_exists($actionclassinstance,$method)) continue;
// test to avoid to run twice a hook, when a module implements several active contexts
@ -178,7 +180,7 @@ class HookManager
}
}
if ($method != 'doActions' && $method != 'formObjectOptions') return $this->resPrint; // TODO remove this. When there is something to print, ->resPrint is filled.
if ($method != 'doActions' && $method != 'formObjectOptions') return $this->resPrint; // TODO remove this. When there is something to print, ->resPrint is filled.
return ($error?-1:$resaction);
}

View File

@ -29,7 +29,7 @@
* \brief File that include conf.php file and commons lib like functions.lib.php
*/
if (! defined('DOL_VERSION')) define('DOL_VERSION','3.3.0-beta');
if (! defined('DOL_VERSION')) define('DOL_VERSION','3.4.0-alpha');
if (! defined('EURO')) define('EURO',chr(128));
// Define syslog constants

View File

@ -394,8 +394,9 @@ else
array('from'=>'2.9.0', 'to'=>'3.0.0'),
array('from'=>'3.0.0', 'to'=>'3.1.0'),
array('from'=>'3.1.0', 'to'=>'3.2.0'),
array('from'=>'3.2.0', 'to'=>'3.3.0')
);
array('from'=>'3.2.0', 'to'=>'3.3.0'),
array('from'=>'3.3.0', 'to'=>'3.4.0')
);
$count=0;
foreach ($migrationscript as $migarray)

View File

@ -0,0 +1,17 @@
--
-- Be carefull to requests order.
-- This file must be loaded by calling /install/index.php page
-- when current version is 3.4.0 or higher.
--
-- To rename a table: ALTER TABLE llx_table RENAME TO llx_table_new;
-- To add a column: ALTER TABLE llx_table ADD COLUMN newcol varchar(60) NOT NULL DEFAULT '0' AFTER existingcol;
-- To rename a column: ALTER TABLE llx_table CHANGE COLUMN oldname newname varchar(60);
-- To drop a column: ALTER TABLE llx_table DROP COLUMN oldname;
-- To change type of field: ALTER TABLE llx_table MODIFY COLUMN name varchar(60);
-- To restrict request to Mysql version x.y use -- VMYSQLx.y
-- To restrict request to Pgsql version x.y use -- VPGSQLx.y
-- -- VPGSQL8.2 DELETE FROM llx_usergroup_user WHERE fk_user NOT IN (SELECT rowid from llx_user);
-- -- VMYSQL4.1 DELETE FROM llx_usergroup_user WHERE fk_usergroup NOT IN (SELECT rowid from llx_usergroup);

View File

@ -37,11 +37,19 @@ $socid = GETPOST('socid','int');
if ($user->societe_id) $socid=$user->societe_id;
$result = restrictedArea($user, 'societe', $socid, '&societe');
// Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array
include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
$hookmanager=new HookManager($db);
$hookmanager->initHooks(array('agendathirdparty'));
/*
* Actions
*/
$parameters=array('id'=>$socid);
$reshook=$hookmanager->executeHooks('doActions',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks
$error=$hookmanager->error; $errors=array_merge($errors, (array) $hookmanager->errors);

View File

@ -37,12 +37,29 @@ $socid = GETPOST('socid','int');
if ($user->societe_id) $socid=$user->societe_id;
$result = restrictedArea($user, 'societe', $socid, '&societe');
// Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array
include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
$hookmanager=new HookManager($db);
$hookmanager->initHooks(array('infothirdparty'));
/*
* Actions
*/
$parameters=array('id'=>$socid);
$reshook=$hookmanager->executeHooks('doActions',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks
$error=$hookmanager->error; $errors=array_merge($errors, (array) $hookmanager->errors);
/*
* View
*/
* View
*/
llxHeader();
$help_url='EN:Module_Third_Parties|FR:Module_Tiers|ES:Empresas';
llxHeader('',$langs->trans("ThirdParty"),$help_url);
$soc = new Societe($db);
$soc->fetch($socid);