在 CakePHP 中处理记录编辑并获得批准的推荐方法?
我无法找到任何有关在 CakePHP 中处理记录编辑并获得批准的最佳方法的信息。
具体来说,我需要允许用户编辑记录中的数据,但在管理员批准更改之前,编辑的数据不应覆盖原始记录数据。我可以将编辑后的记录放在一个新表中,然后在批准它们时覆盖原始记录,但我想知道是否有更简单的方法,因为可以这么说,这个想法似乎与蛋糕哲学不太相符。
I haven't been able to find any information regarding the best way to handle record editing with approval in CakePHP.
Specifically, I need to allow users to edit data in a record, but the edited data should not overwrite the original record data until administrators have approved the change. I could put the edited records in a new table and then overwrite the originals when I approve them but I wonder if there is an easier way since this idea doesn't seem to play well with the cake philosophy so to speak.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您将需要在某个地方存储该数据,直到管理员批准为止。
我不确定这比使用新编辑和原始帖子 ID 创建另一个表更容易。然后,当管理员批准编辑时,脚本会使用编辑后的版本覆盖旧记录。
You are going to need somewhere to store that data until an administrator can approve it.
I'm not sure how this can be easier than creating another table with the new edits and the original post id. Then when an administrator approves the edit, the script overwrites the old record with the edited version.
我正在研究类似的设置,并将草稿记录存储在同一个表中,但在记录上设置一个名为“草稿”的标志。此外,原始记录有一个“draft_id”字段,其中存储了草稿记录的 id。
然后在模型中,当显示引擎加载原始记录时,它会正常显示。但是,当编辑或预览操作尝试加载记录时,它会检查“draft_id”字段,然后加载其他记录(如果已设置)。
“草稿”标志也用于防止列表和其他组查找类型操作抓取草稿记录。这也可以通过更高级的 SQL 查询来解决,但我不太擅长 SQL。
I'm working on a similar setup and I'm going with storing the draft record in the same table but with a flag set on the record called "draft". Also, the original record has a "draft_id" field that has the id of the draft record stored in it.
Then in the model when the original record is loaded by the display engine it shows it normally. But when the edit or preview actions try to load the record, it checks the "draft_id" field and then loads the other record if it's set.
The "draft" flag is used to keep list and other group find type actions from grabbing the draft records too. This might also be solved by a more advanced SQL query but I'm not quite that good with SQL.