try to fix canvas within members module

This commit is contained in:
Grand Philippe 2012-10-02 18:27:41 +02:00
parent 079ea61582
commit 085923dc64

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,8 +692,27 @@ llxHeader('',$langs->trans("Member"),$help_url);
$countrynotdefined=$langs->trans("ErrorSetACountryFirst").' ('.$langs->trans("SeeAbove").')'; $countrynotdefined=$langs->trans("ErrorSetACountryFirst").' ('.$langs->trans("SeeAbove").')';
if ($action == 'create') 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')
{
/* ************************************************************************** */ /* ************************************************************************** */
/* */ /* */
/* Fiche creation */ /* Fiche creation */
@ -864,10 +898,10 @@ if ($action == 'create')
print "</form>\n"; print "</form>\n";
} }
if ($action == 'edit') if ($action == 'edit')
{ {
/******************************************** /********************************************
* *
* Fiche en mode edition * Fiche en mode edition
@ -1100,10 +1134,10 @@ if ($action == 'edit')
print '</form>'; print '</form>';
print '</div>'; print '</div>';
} }
if ($rowid && $action != 'edit') if ($rowid && $action != 'edit')
{ {
dol_htmloutput_mesg($mesg); dol_htmloutput_mesg($mesg);
/* ************************************************************************** */ /* ************************************************************************** */
@ -1593,9 +1627,9 @@ if ($rowid && $action != 'edit')
print '</div>'; print '</div>';
print "<br>\n"; print "<br>\n";
}
} }
llxFooter(); llxFooter();
$db->close(); $db->close();