function category_getById($index)
{
    return category_get($index, false, false);
}
$rest->get('/category/', function () use($rest) {
    global $req;
    include_once API_ROOT . "/category.inc";
    $page = $req->get("page");
    if ($page == null) {
        category_all(null);
    } else {
        // If page = 1 the value will be 0, if page = 2 the value will be 1, ...
        $from = --$page * RESULTS_PER_PAGE;
        category_all($from);
    }
});
// Get Specific Item Category
$rest->get('/category/:id', function ($id) use($rest) {
    include_once API_ROOT . "/category.inc";
    category_get($id);
});
// Add Item Category
$rest->post('/category/', function () use($rest) {
    include_once API_ROOT . "/category.inc";
    category_add();
});
// Edit Item Category
$rest->put('/category/:id', function ($id) use($rest) {
    include_once API_ROOT . "/category.inc";
    category_edit($id);
});
// Delete Item Category
$rest->delete('/category/:id', function ($id) use($rest) {
    include_once API_ROOT . "/category.inc";
    category_delete($id);
Beispiel #3
0
function task_display_form()
{
    if (isset($_POST['task_id'])) {
        $task_id = $_POST['task_id'];
    } else {
        if (isset($_GET['id'])) {
            $task_id = $_GET['id'];
        } else {
            $task_id = NULL;
        }
    }
    if ($task_id !== NULL) {
        //Get existing task
        $task = task_get($_SESSION['user_id'], $task_id);
        // preprint($task);
    }
    //get all available categories
    $categories = category_get($_SESSION['user_id']);
    echo '<form method="post" class="form-horizontal" ' . (!isset($task[0]) ? ' action="' . SITE_URL . '/?p=mytasks"' : "") . '>
		' . (isset($task[0]['id']) ? '<input type="hidden" name="task_id" value="' . $task[0]['id'] . '">' : "") . '
		<div class="form-group">
			<label for="task_category_id_select" class="col-sm-2 control-label">
				' . _("Category") . '
			</label>
			<div class="col-sm-10">
				<select name="task_category_id" id="task_category_id_select" class="form-control">';
    if (!empty($categories)) {
        foreach ($categories as $cat) {
            echo '<option value="' . $cat['id'] . '" ' . (isset($task[0]['task_category_id']) && $task[0]['task_category_id'] == $cat['id'] ? 'selected="selected" ' : "") . '>' . $cat['name'] . '</option>';
        }
    }
    echo '
					<option value="NULL"> - ' . _("New (untitled) category") . ' - </option>
				</select>
			</div>
		</div>
		<div class="form-group">
			<label for="name_text" class="col-sm-2 control-label">
				' . _("Name") . '
			</label>
			<div class="col-sm-10">
				<input id="name_text" class="form-control" type="text" name="name" 
						value="' . (isset($task[0]['name']) ? $task[0]['name'] : "") . '"
						placeholder="' . _("Enter task name") . '" required="required">
			</div>
		</div>
		<div class="form-group">
			<label for="description_textarea" class="col-sm-2 control-label">
				' . _("Description") . '
			</label>
			<div class="col-sm-10">
				<textarea id="description_textarea" class="form-control" name="description" placeholder="' . _("Enter task description") . '">' . (isset($task[0]['description']) ? $task[0]['description'] : "") . '</textarea>
			</div>
		</div>

		<div class="col-sm-10 col-sm-offset-2">
			<input type="submit" class="btn" name="save_task" value="' . _("Save") . '">
		</div>
	</form>';
}
Beispiel #4
0
function category_get_user_privilege($user_id, $task_id)
{
    $category = category_get($user_id, $task_id);
    if (!empty($category)) {
        return TRUE;
    }
    return FALSE;
}