Esempio n. 1
0
     break;
 case "POST":
     // add new
     if (isset($_POST["name"]) and !isset($_POST["newname"])) {
         $name = strip_tags($_POST["name"]);
         $nameCount = $lists->verifListExist($name);
         if (strlen($name) < 3 or strlen($name) > 30) {
             echo "errorListLength";
         } else {
             if (empty($name) or $name === "undefined") {
                 echo "emptyName";
             } else {
                 if ($nameCount !== 0) {
                     echo "alreadyExists";
                 } else {
                     $lists->create($name);
                 }
             }
         }
     }
     // update
     if (isset($_POST["name"]) and isset($_POST["newname"])) {
         $name = strip_tags($_POST["name"]);
         $newname = strip_tags($_POST["newname"]);
         $newNameCount = $lists->verifListExist($newname);
         if (strlen($newname) < 3 or strlen($newname) > 30) {
             echo "errorListLengthNew";
         } else {
             if (empty($newname) or $newname === "undefined") {
                 echo "emptyNewName";
             } else {
Esempio n. 2
0
<?php

require_once '../util/database.php';
require_once '../models/List.php';
require_once '../models/SharedList.php';
if (isset($_SESSION['id'])) {
    $user_id = $_SESSION['id'];
    $list = new Lists();
    if (isset($_POST['add_new_list'])) {
        $list_name = ucwords(strtolower(rtrim($_POST['list_name'])));
        $editable = isset($_POST['list_permission_check']) ? 1 : 0;
        $list->create($user_id, $list_name, $editable);
        if ($list_name != "") {
            $list->save();
            View::render('dashboard.php');
        } else {
            $_SESSION['error_message'] = "Please enter a list name";
            View::render('dashboard.php');
        }
    }
    if (isset($_POST['list_option'])) {
        $list_id = $_POST['list_id'];
        switch ($_POST['list_option']) {
            case 'save':
                $new_name = ucwords(strtolower(rtrim($_POST['list_name'])));
                $editable = $_POST['list_permission'];
                saveList($list, $new_name, $editable, $list_id, $user_id);
                echo $new_name;
                break;
            case 'delete':
                deleteList($list, $list_id, $user_id);