Ejemplo n.º 1
0
 /**
  * Update category
  * 
  * @param int   $id             Id of category to update
  * @param array $request_data   Datas   
  * @return int 
  *
  * @url	PUT category/{id}
  */
 function put($id, $request_data = NULL)
 {
     if (!DolibarrApiAccess::$user->rights->categorie->creer) {
         throw new RestException(401);
     }
     $result = $this->category->fetch($id);
     if (!$result) {
         throw new RestException(404, 'category not found');
     }
     if (!DolibarrApi::_checkAccessToResource('category', $this->category->id)) {
         throw new RestException(401, 'Access not allowed for login ' . DolibarrApiAccess::$user->login);
     }
     foreach ($request_data as $field => $value) {
         $this->category->{$field} = $value;
     }
     if ($this->category->update(DolibarrApiAccess::$user)) {
         return $this->get($id);
     }
     return false;
 }
Ejemplo n.º 2
0
        $error = $exception->getMessage();
    }
    if (empty($error)) {
        header('Location: ' . str_replace('index.php', '', $_SERVER['SCRIPT_NAME']) . 'home/' . $categorie->getCategory() . '/' . urlencode($topic->getTitre()));
        exit;
    }
}
//Supression d'un topic
if (isset($_POST['remove'], $_GET['id'])) {
    $manager = new Categorie($link);
    $topic = $manager->selectById($_GET['id']);
    $id = $topic->getId();
    $manager->delete($id);
    header('Location: ' . str_replace('index.php', '', $_SERVER['SCRIPT_NAME']) . 'home/' . $topic->getCategory()->getCategory());
    exit;
}
//modification d'un topic
if (isset($_POST['validate'])) {
    $manager = new Categorie($link);
    $topic = $manager->selectById($_GET['id']);
    try {
        $topic->setTitre($_POST['titreTopic']);
    } catch (Exception $e) {
        $error = $e->getMessage();
    }
    if (empty($error)) {
        $manager->update($topic);
        header('Location:' . str_replace('index.php', '', $_SERVER['SCRIPT_NAME']) . '/home/' . $topic->getCategory()->getCategory());
        exit;
    }
}
Ejemplo n.º 3
0
{
  if (!in_array ($old_cat, $new_cats_meres))
    {
      $asupprimer[] = new Categorie ($db, $old_cat);
    }
}

foreach ($new_cats_meres as $new_cat)
{
  if (!in_array ($new_cat, $old_cats_meres))
    {
      $aajouter[] = new Categorie ($db, $new_cat);
    }
}

$res = $cat->update ();
if ($res < 0)
{
  print "<p>Impossible de modifier la categorie ".$cat->label.".</p>";
}
else
{
  print "<p>La categorie ".$cat->label." a ete modifiee avec succes.</p>";

  foreach ($asupprimer as $old_mere)
    {
      $res = $old_mere->del_fille ($cat);
      if ($res < 0)
	{
	  print "<p>Impossible d'enlever la categorie de \"".$old_mere->label."\" ($res).</p>\n";
	}
Ejemplo n.º 4
0
    $categorie->visible = $_POST["visible"];
    if ($_POST['catMere'] != "-1") {
        $categorie->id_mere = $_POST['catMere'];
    } else {
        $categorie->id_mere = "";
    }
    if (!$categorie->label) {
        $_GET["action"] = 'create';
        $mesg = $langs->trans("ErrorFieldRequired", $langs->transnoentities("Label"));
    }
    if (!$categorie->description) {
        $_GET["action"] = 'create';
        $mesg = $langs->trans("ErrorFieldRequired", $langs->transnoentities("Description"));
    }
    if (!$categorie->error) {
        if ($categorie->update($user) > 0) {
            header('Location: ' . DOL_URL_ROOT . '/categories/viewcat.php?id=' . $categorie->id . '&type=' . $type);
            exit;
        } else {
            $mesg = $categorie->error;
        }
    } else {
        $mesg = $categorie->error;
    }
}
/*
 * View
 */
llxHeader("", "", $langs->trans("Categories"));
print_fiche_titre($langs->trans("ModifCat"));
dol_htmloutput_errors($mesg);
Ejemplo n.º 5
0
    $pubblicato_uk = "f";
    if (isset($_POST["pubblicato_eur"]) and $_POST["pubblicato_eur"] == "t") {
        $pubblicato_eur = "t";
    }
    if (isset($_POST["pubblicato_uk"]) and $_POST["pubblicato_uk"] == "t") {
        $pubblicato_uk = "t";
    }
    $object = new Categorie();
    if (isset($_POST["insert"]) and $_POST["insert"] == "si") {
        $object->add($fk_classe, $categoria, $categoria_ita, $categoria_ted, $pubblicato_eur, $pubblicato_uk);
        //recupero l'ultimo id inserito
        $db = new Db();
        $id = $db->get_last_id();
    } elseif (isset($_POST["update"]) and $_POST["update"] == "si") {
        $id = aggiusta_post($_GET["id"]);
        $object->update($id, $fk_classe, $categoria, $categoria_ita, $categoria_ted, $pubblicato_eur, $pubblicato_uk);
        //upload dei file
        update_file("pr_categoria", "categorie_dettaglio.php?errore=file&id=" . $id, $id);
    }
    print "<script language='Javascript'>window.location.replace('categorie_dettaglio.php?id=" . $id . "&ins=si');</script>";
}
$fkclasse = "";
$categoria = "";
$categoria_ita = "";
$categoria_ted = "";
$pubblicato_eur = "";
$pubblicato_uk = "";
if (isset($_GET["id"]) and $_GET["id"] != "") {
    $id = aggiusta_post($_GET["id"]);
    $fkclasse = $array["cat_fkclasse"];
    $categoria = $array["cat_categoria"];