Merge pull request #432 from grandoc/develop

try to fix canvas within members module
This commit is contained in:
Laurent Destailleur 2012-10-02 14:10:10 -07:00
commit 883e51566f

View File

@ -52,7 +52,7 @@ $userid=GETPOST('userid','int');
$socid=GETPOST('socid','int'); $socid=GETPOST('socid','int');
// Security check // Security check
$result=restrictedArea($user,'adherent',$rowid); $result=restrictedArea($user,'adherent',$rowid,'','','fk_soc', 'rowid', $objcanvas);
if (! empty($conf->mailmanspip->enabled)) if (! empty($conf->mailmanspip->enabled))
{ {
@ -66,6 +66,17 @@ if (! empty($conf->mailmanspip->enabled))
$object = new Adherent($db); $object = new Adherent($db);
$extrafields = new ExtraFields($db); $extrafields = new ExtraFields($db);
// Get object canvas (By default, this is not defined, so standard usage of dolibarr)
$object->getCanvas($socid);
$canvas = $object->canvas?$object->canvas:GETPOST("canvas");
$objcanvas='';
if (! empty($canvas))
{
require_once DOL_DOCUMENT_ROOT.'/core/class/canvas.class.php';
$objcanvas = new Canvas($db, $action);
$objcanvas->getCanvas('adherent', 'card', $canvas);
}
$errmsg=''; $errmsgs=array(); $errmsg=''; $errmsgs=array();
if ($rowid > 0) if ($rowid > 0)
@ -104,7 +115,7 @@ $hookmanager->initHooks(array('membercard'));
* Actions * Actions
*/ */
$parameters=array('socid'=>$socid); $parameters=array('socid'=>$socid, 'objcanvas'=>$objcanvas);
$reshook=$hookmanager->executeHooks('doActions',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks $reshook=$hookmanager->executeHooks('doActions',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks
if ($action == 'setuserid' && ($user->rights->user->self->creer || $user->rights->user->user->creer)) if ($action == 'setuserid' && ($user->rights->user->self->creer || $user->rights->user->user->creer))
@ -129,6 +140,8 @@ if ($action == 'setuserid' && ($user->rights->user->self->creer || $user->rights
} }
} }
} }
else $object->canvas=$canvas;
if ($action == 'setsocid') if ($action == 'setsocid')
{ {
$error=0; $error=0;
@ -184,6 +197,7 @@ if ($action == 'confirm_create_user' && $confirm == 'yes' && $user->rights->user
$errmsg=$object->error; $errmsg=$object->error;
} }
} }
else $object->canvas=$canvas;
// Create third party from a member // Create third party from a member
if ($action == 'confirm_create_thirdparty' && $confirm == 'yes' && $user->rights->societe->creer) if ($action == 'confirm_create_thirdparty' && $confirm == 'yes' && $user->rights->societe->creer)
@ -206,6 +220,7 @@ if ($action == 'confirm_create_thirdparty' && $confirm == 'yes' && $user->rights
$errmsg=$object->error; $errmsg=$object->error;
} }
} }
else $object->canvas=$canvas;
if ($action == 'confirm_sendinfo' && $confirm == 'yes') if ($action == 'confirm_sendinfo' && $confirm == 'yes')
{ {
@ -677,6 +692,25 @@ llxHeader('',$langs->trans("Member"),$help_url);
$countrynotdefined=$langs->trans("ErrorSetACountryFirst").' ('.$langs->trans("SeeAbove").')'; $countrynotdefined=$langs->trans("ErrorSetACountryFirst").' ('.$langs->trans("SeeAbove").')';
if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action))
{
// -----------------------------------------
// When used with CANVAS
// -----------------------------------------
if (empty($object->error) && $socid)
{
$object = new Adherent($db);
$object->fetch($socid);
}
$objcanvas->assign_values($action, $socid); // Set value for templates
$objcanvas->display_canvas($action); // Show template
}
else
{
// -----------------------------------------
// When used in standard mode
// -----------------------------------------
if ($action == 'create') if ($action == 'create')
{ {
/* ************************************************************************** */ /* ************************************************************************** */
@ -875,9 +909,13 @@ if ($action == 'edit')
********************************************/ ********************************************/
$res=$object->fetch($rowid); $res=$object->fetch($rowid);
if ($res < 0) { dol_print_error($db,$object->error); exit; } if ($res < 0) {
dol_print_error($db,$object->error); exit;
}
$res=$object->fetch_optionals($object->id,$extralabels); $res=$object->fetch_optionals($object->id,$extralabels);
if ($res < 0) { dol_print_error($db); exit; } if ($res < 0) {
dol_print_error($db); exit;
}
$adht = new AdherentType($db); $adht = new AdherentType($db);
$adht->fetch($object->typeid); $adht->fetch($object->typeid);
@ -1113,13 +1151,19 @@ if ($rowid && $action != 'edit')
/* ************************************************************************** */ /* ************************************************************************** */
$res=$object->fetch($rowid); $res=$object->fetch($rowid);
if ($res < 0) { dol_print_error($db,$object->error); exit; } if ($res < 0) {
dol_print_error($db,$object->error); exit;
}
$res=$object->fetch_optionals($object->id,$extralabels); $res=$object->fetch_optionals($object->id,$extralabels);
if ($res < 0) { dol_print_error($db); exit; } if ($res < 0) {
dol_print_error($db); exit;
}
$adht = new AdherentType($db); $adht = new AdherentType($db);
$res=$adht->fetch($object->typeid); $res=$adht->fetch($object->typeid);
if ($res < 0) { dol_print_error($db); exit; } if ($res < 0) {
dol_print_error($db); exit;
}
/* /*
@ -1204,8 +1248,12 @@ if ($rowid && $action != 'edit')
// Cree un tableau formulaire // Cree un tableau formulaire
$formquestion=array(); $formquestion=array();
if ($object->email) $formquestion[]=array('type' => 'checkbox', 'name' => 'send_mail', 'label' => $label, 'value' => ($conf->global->ADHERENT_DEFAULT_SENDINFOBYMAIL?true:false)); if ($object->email) $formquestion[]=array('type' => 'checkbox', 'name' => 'send_mail', 'label' => $label, 'value' => ($conf->global->ADHERENT_DEFAULT_SENDINFOBYMAIL?true:false));
if (! empty($conf->global->ADHERENT_USE_MAILMAN)) { $formquestion[]=array('type'=>'other','label'=>$langs->transnoentitiesnoconv("SynchroMailManEnabled"),'value'=>''); } if (! empty($conf->global->ADHERENT_USE_MAILMAN)) {
if (! empty($conf->global->ADHERENT_USE_SPIP)) { $formquestion[]=array('type'=>'other','label'=>$langs->transnoentitiesnoconv("SynchroSpipEnabled"),'value'=>''); } $formquestion[]=array('type'=>'other','label'=>$langs->transnoentitiesnoconv("SynchroMailManEnabled"),'value'=>'');
}
if (! empty($conf->global->ADHERENT_USE_SPIP)) {
$formquestion[]=array('type'=>'other','label'=>$langs->transnoentitiesnoconv("SynchroSpipEnabled"),'value'=>'');
}
print $form->formconfirm("fiche.php?rowid=".$rowid,$langs->trans("ValidateMember"),$langs->trans("ConfirmValidateMember"),"confirm_valid",$formquestion,1); print $form->formconfirm("fiche.php?rowid=".$rowid,$langs->trans("ValidateMember"),$langs->trans("ConfirmValidateMember"),"confirm_valid",$formquestion,1);
} }
@ -1594,7 +1642,7 @@ if ($rowid && $action != 'edit')
print "<br>\n"; print "<br>\n";
} }
}
llxFooter(); llxFooter();