コード例 #1
0
ファイル: toggle_favorite.php プロジェクト: rratcliffe/fsen
if (!fse_try_to_login()) {
    $ret_info->detail = t('Not signed in');
    echo $json->encode($ret_info);
    exit(0);
}
if (!in_array($domain_handle, ProjectInfo::$mDomainList)) {
    $ret_info->detail = t('Bad request');
    echo $json->encode($ret_info);
    exit(0);
}
if (!preg_match("/^[a-f0-9]{32}\$/", $section_id)) {
    $ret_info->detail = 'Bad section';
    echo $json->encode($ret_info);
    exit(0);
}
$action_id = DocSectionManager::checkActionComment($domain_handle, $section_id, $_SESSION['FSEInfo']['fse_id'], DocSectionManager::COMMENT_ACTION_FAVORITE);
if ($action_id == false) {
    DocSectionManager::newComment($domain_handle, $section_id, $_SESSION['FSEInfo']['fse_id'], DocSectionManager::COMMENT_ACTION_FAVORITE, NULL, NULL);
    $ret_info->status = 'favorited';
    $ret_info->detail = t('Your favorite stored.');
    $ret_info->section_info = DocSectionManager::getSectionInfo($domain_handle, $section_id);
} else {
    $ret_info->status = 'canceled';
    $ret_info->detail = t('Your favorite canceled.');
    $ret_info->section_info = DocSectionManager::cancelComment($domain_handle, $section_id, $action_id);
}
echo $json->encode($ret_info);
exit(0);
?>

コード例 #2
0
ファイル: new_comment.php プロジェクト: rratcliffe/fsen
}
$ret_info = new ReturnInfo();
$ret_info->status = 'error';
$ret_info->detail = t('N/A');
if (!fse_try_to_login()) {
    $ret_info->detail = t('Not signed in.');
    echo $json->encode($ret_info);
    exit(0);
}
if ($_SESSION[$form_token_name] != $form_token) {
    $ret_info->detail = t('Bad request or session expired.');
    echo $json->encode($ret_info);
    exit(0);
}
//unset ($_SESSION [$form_token_name]);
$comment = DocSectionManager::newComment($domain_handle, $section_id, $_SESSION['FSEInfo']['fse_id'], $comment_action, $comment_body, $comment_reply_to);
if ($comment == false) {
    $ret_info->status = 'error';
    $ret_info->detail = t('Bad comment');
    echo $json->encode($ret_info);
    exit(0);
}
$author_info = $_SESSION['FSEInfo'];
if (!isset($fse_info['avatar_url'])) {
    $author_info['avatar_url'] = get_url_from_file_id($author_info['avatar_file_id']);
}
$uh = Loader::helper('concrete/urls');
$bt = BlockType::getByHandle('document_section');
$delete_action = $uh->getBlockTypeToolsURL($bt) . '/delete_comment.php';
if (preg_match("/^[0-9a-f]{32}\$/", $comment['replied_author_id'])) {
    $replied_name_info = FSEInfo::getNameInfo($comment['replied_author_id']);