Example #1
0
$ref = GETPOST('ref', 'alpha');
$action = GETPOST('action', 'alpha');
// Security check
if ($user->societe_id) {
    $socid = $user->societe_id;
}
$result = restrictedArea($user, 'ficheinter', $id, 'fichinter');
$object = new Fichinter($db);
$result = $object->fetch($id, $ref);
/*
 * Ajout d'un nouveau contact
 */
if ($action == 'addcontact' && $user->rights->ficheinter->creer) {
    if ($result > 0 && $id > 0) {
        $contactid = GETPOST('userid', 'int') ? GETPOST('userid', 'int') : GETPOST('contactid', 'int');
        $result = $object->add_contact($contactid, GETPOST('type', 'int'), GETPOST('source', 'alpha'));
    }
    if ($result >= 0) {
        header("Location: " . $_SERVER['PHP_SELF'] . "?id=" . $object->id);
        exit;
    } else {
        if ($object->error == 'DB_ERROR_RECORD_ALREADY_EXISTS') {
            $langs->load("errors");
            $mesg = $langs->trans("ErrorThisContactIsAlreadyDefinedAsThisType");
        } else {
            $mesg = $object->error;
        }
        setEventMessage($mesg, 'errors');
    }
} else {
    if ($action == 'swapstatut' && $user->rights->ficheinter->creer) {
Example #2
0

/*
 * Ajout d'un nouveau contact
 */

if ($_POST["action"] == 'addcontact' && $user->rights->ficheinter->creer)
{

	$result = 0;
	$fichinter = new Fichinter($db);
	$result = $fichinter->fetch($_GET["id"]);

    if ($result > 0 && $_GET["id"] > 0)
    {
  		$result = $fichinter->add_contact($_POST["contactid"], $_POST["type"], $_POST["source"]);
    }

	if ($result >= 0)
	{
		Header("Location: contact.php?id=".$fichinter->id);
		exit;
	}
	else
	{
		if ($fichinter->error == 'DB_ERROR_RECORD_ALREADY_EXISTS')
		{
			$langs->load("errors");
			$mesg = '<div class="error">'.$langs->trans("ErrorThisContactIsAlreadyDefinedAsThisType").'</div>';
		}
		else