したがって、次のコードを含む cron ジョブがあります。
class UGCJReminder extends UGCronJob {
/**
* return the cron description
*/
protected function getDescription()
{
return Yii::t('userGroupsModule.cron', 'manda email para os usuarios cadastrados para cadastrar suas atividades');
}
/**
* return the cron table model name
*/
protected function getCronTable()
{
return 'UserGroupsCron';
}
/**
* return the cron name
*/
protected function getName()
{
return 'reminder';
}
/**
* returns the number of days that have to pass before performing this cron job
*/
protected function getLapse()
{
return 1;
}
/**
* return the model
*/
protected function getModel()
{
return new UserGroupsUser;
}
/**
* return the action method
*/
protected function getAction()
{
Yii::import('ext.yii-mail.YiiMailMessage');
$message = new YiiMailMessage;
$message->setBody('Message', 'text/html');
$message->subject = 'Lembrete';
$message->addTo('my-email');
$message->from = Yii::app()->params['adminEmail'];
return Yii::app()->mail->send($message);
}
/**
* return the action criteria
*/
protected function getCriteria()
{
return new CDbCriteria;
}
/**
* return the interested database fields
*/
protected function getColumns()
{
return array('email' => UserGroupsUser::ACTIVE);
#return NULL;
}
}
UserGroups (Yii モジュール) が要求するドキュメントの他のすべての変更を行い、cron リストには、私の cron がインストールされ、実行されていることが示されます。ただし、1 日に複数回実行されるため、1 日に 1 回だけ実行する必要があります。それで、私は何を間違っていますか?
この問題の別の解決策も受け入れます (1 日の決まった時間にメールを送信する)。私は Yii を使用していることを考慮してください。そのため、フレームワーク内でこれを行う方法が必要です (たとえば、拡張機能を使用)。
PS: 良いドキュメント ソースを知っていれば (Usergroups、Cron-tab、および Yii 自体は、これらすべてがどのように機能するかをドキュメント化するのにそれほど強力ではないため)、これらすべてについて、私はまだ興味があります。