通过管理生成器创建新记录时发送电子邮件

时间:2010-06-24 09:07:04

标签: symfony1 notifications admin-generator

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

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

以下是代码:

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。

1 个答案:

答案 0 :(得分:2)

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

查看缓存中的actions.class.php文件,您将看到它。

相关问题