【问题标题】:Send an email when a new record is created via admin generator通过管理员生成器创建新记录时发送电子邮件
【发布时间】:2010-06-24 09:07:03
【问题描述】:

我使用 symfony 管理生成器创建了一个用于运动员管理的 Web 应用程序。最后一个客户的要求之一是添加一个功能,以在数据库中插入具有相同号码的运动员时通知用户并向管理员发送电子邮件。到目前为止,Athlete 表的列号有一个唯一约束,但客户端希望运动员可以插入。

为了实现这一点,我试图扩展编辑/新操作以实现客户要求。

代码如下:

public function executeEdit(sfWebRequest $request)
    {
        $user = $this->getUser();

        if(! $user->hasCredential('admin'))
        {

            $clube_id = $user->getAttribute('id');
            $atleta_id = $request->getParameter('id');
            $atleta = Doctrine::getTable('Atleta')->find($atleta_id);

            if($clube_id != $atleta->clube_id)
                $this->forward404();        

        }

        if($request->get('post'))
        {
            // check if the inserted athlete BI already exists; if so, display a message to the user and send an email to the system admins
            $atleta_id = $request->getParameter('id');
            $atletaBIExiste = Doctrine::getTable('Atleta')->findDuplicateAthleteBI($atleta_id);

            if($atletaBIExiste)
            {
                // display a notice message to the user
                $this->getUser()->setFlash('error', 'Athlete already exists');

                // send an email to the system administrator
            }
        }


        return parent::executeEdit($request);
    }

这是我的问题:当我执行编辑操作时,我只想在 HTTP 为 POST 时检查重复的运动员编号,但似乎从来没有。我已经向输出发送了一些异常以验证哪种类型是 HTTP 请求,并且它似乎始终是 GET。

【问题讨论】:

    标签: symfony1 notifications admin-generator


    【解决方案1】:

    您将遇到的问题是,当您在编辑页面上点击保存时,信息不会发布到编辑操作,而是发布到名为更新的操作。

    看看缓存中的actions.class.php文件就知道了。

    【讨论】:

    • 您好!感谢您的帮助!最好的问候!
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2021-03-05
    • 1970-01-01
    • 2021-09-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多