function handler_ajax_todo_uncheck($page) { S::assert_xsrf_token(); if (Json::has('todo_id')) { XDB::execute('UPDATE todo SET checked = 0 WHERE uid = {?} AND todo_id = {?}', S::user()->id(), Json::i('todo_id')); if (XDB::affectedRows() != 1) { $page->jsonAssign('error', "Impossible de décocher la tâche"); } } else { $page->jsonAssign('error', "Requête invalide"); } return PL_JSON; }
function handler_ajax_comment($page) { S::assert_xsrf_token(); $g = Group::fromId(Json::i('gid')); if ($g) { $user = Json::has('uid') ? new User(Json::i('uid')) : S::user(); if ($user->isMe(S::user()) || S::user()->hasRights($g, Rights::admin()) || S::user()->isWeb()) { $comments = Json::t('comments'); $user->comments($g, $comments); $page->jsonAssign('uid', $user->id()); } } else { $page->jsonAssign('error', "Ce groupe n'existe pas"); } return PL_JSON; }
function handler_ajax_modify($page) { S::assert_xsrf_token(); if (!S::user()->hasRights(Group::from('qdj'), Rights::admin())) { return PL_FORBIDDEN; } $qdj = new QDJ(Json::i('id')); $page->jsonAssign('success', false); if (Json::has('date')) { $date = Json::t('date'); if (!$date) { $qdj->date(false); $page->jsonAssign('success', true); } else { try { $qdj->date(new FrankizDateTime($date)); $page->jsonAssign('success', true); } catch (Exception $e) { } } } else { if (Json::has('delete')) { if (Json::b('delete')) { $qdj->delete(); $page->jsonAssign('success', true); } } } return PL_JSON; }
function handler_ajax_minimodules_layout($page) { $layout = FrankizMiniModule::emptyLayout(); foreach (array_keys($layout) as $col) { if (Json::has($col)) { $layout[$col] = Json::v($col); } } if (!S::user()->layoutMinimodules($layout)) { $page->jsonAssign('error', "Le réagencement des minimodules n'a pas pu se faire"); } return PL_JSON; }