gn36/phpbb-oo-posting-api
Composer 安装命令:
composer require gn36/phpbb-oo-posting-api
包简介
Helper classes for creating/modifying posts, topics and PMs in phpBB to be added to vendor by other extensions.
README 文档
README
This repository contains an API for simple creation and editing of posts and PMs in phpBB. It adds classes for post, topic, and pm. These classes can be integrated in an extension. The classes take care of all necessary parameter handling in the background so that only the forum_id, title and text of the new post must be set and the classes handle the rest. Any available bbcode can be used regularly in the text. For PMs, recipients can be set easily.
Warning: Development is still at an early stage and major bugs may still be present in this api. Currently, only the post and privmsg classes are ready for use, which means, no handling of attachments and no handling of polls. PMs can also not be loaded for editing currently.
Installation
Add gn36/phpbb-oo-posting-api to your extensions composer dependencies and install using composer.
Use
To create a new topic in the forum with forum_id = 1:
$post = new \Gn36\OoPostingApi\post();
$post->forum_id = 1;
$post->post_subject = 'Subject of the new topic';
$post->post_text = 'The text of the first post. [b]This is bold![/b]';
// This is optional: Change the author id. Default is current user.
$post->poster_id = ANONYMOUS; // Create a guest post (could be any user id)
// This is only necessary for guests if you want a name to appear at the post
$post->post_username = 'I am a guest';
// Submit
$post->submit();
To create a reply in the topic with topic_id = 1:
$post = new \Gn36\OoPostingApi\post();
$post->topic_id = 1;
$post->post_subject = 'Subject of the new post';
$post->post_text = 'The text of the reply. [i]This can also contain bbcodes.[/i]';
$post->submit();
To edit a post with post_id = 1:
$post = \Gn36\OoPostingApi\post::get(1);
$post->post_text = 'This is the new post text';
// This will also change the topic title if you edit the first post:
$post->post_subject = 'This is the new post title';
$post->submit();
To create a new pm to the user with user_id = 2 and the group with group_id = 5:
$pm = new \Gn36\OoPostingApi\privmsg();
$pm->to(2); // Send to user with id 2
$pm->to('g', 5); // Send to group with id 5
$pm->message_subject = 'The subject of the pm';
$pm->message_text = 'This is the text.
Again [b]bold[/b] and [color=red]any other[/color] bbcode are allowed.';
$pm->submit();
To reply to a pm with the message_id = 11:
//reply_to(11, false) disables quoting the original text
$pm = \Gn36\OoPostingApi\privmsg::reply_to(11);
$pm->message_text .= 'The original message will be quoted and this text appears below.
You could also replace the original text, but if you do so, consider passing a second parameter to privmsg::reply_to, so it does not load the original text at all.';
// Nothing else needed, recipients are set automatically:
$pm->submit();
Development
If you find a bug, please report it on https://github.com/gn36/phpbb-oo-posting-api
Automated Testing
We will use automated unit tests including functional tests in the future to prevent regressions. Check out our travis build below:
License
gn36/phpbb-oo-posting-api 适用场景与选型建议
gn36/phpbb-oo-posting-api 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 241 次下载、GitHub Stars 达 2, 最近一次更新时间为 2015 年 07 月 05 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 gn36/phpbb-oo-posting-api 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 gn36/phpbb-oo-posting-api 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 241
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 2
- 点击次数: 22
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: GPL-2.0
- 更新时间: 2015-07-05