Ejemplo n.º 1
0
Archivo: update.php Proyecto: rjha/sc
    if ($fhandler->hasErrors()) {
        throw new UIException($fhandler->getErrors());
    }
    $listId = $fvalues["list_id"];
    $itemId = $fvalues["item_id"];
    $loginId = Login::getLoginIdInSession();
    $flag = intval($fvalues["is_new"]);
    $listDao = new \com\indigloo\sc\dao\Lists();
    $name = $fvalues["new-list-name"];
    if ($flag == 1 && empty($listId)) {
        // create new list
        if (!Util::isAlphaNumeric($name)) {
            $error = "Bad name : only letters and numbers are allowed!";
            throw new UIException(array($error));
        }
        $listId = $listDao->create($loginId, $name, $itemId);
        $pListId = PseudoId::encode($listId);
    } else {
        // Add to existing list
        // this can also be defaults lists
        // so we should get listId from addItem call
        $listId = $listDao->addItem($loginId, $listId, $itemId);
        $pListId = PseudoId::encode($listId);
    }
    $listUrl = ListHtml::getPubLink($pListId);
    $message = sprintf("success! items added to list %s", $listUrl);
    $gWeb->store(Constants::FORM_MESSAGES, array($message));
    header("Location: " . $qUrl);
} catch (UIException $ex) {
    $gWeb->store(Constants::STICKY_MAP, $fvalues);
    $gWeb->store(Constants::FORM_ERRORS, $ex->getMessages());