contributions/usermanagement.notifications/behaviour/commands/notifications/create.cmd.php
Go to the documentation of this file.00001 <?php 00002 Load::commands('generics/create'); 00003 00004 /** 00005 * Create a notifcation and send a mail, if necessary 00006 */ 00007 class CreateNotificationsCommand extends CreateCommand { 00008 protected function do_execute() { 00009 $ret = new Status(); 00010 Load::models('notifications'); 00011 $existing = Notifications::existing($this->get_params()); 00012 if (!$existing) { 00013 $ret->merge(parent::do_execute()); 00014 if ($ret->is_ok()) { 00015 $n = $this->get_result(); 00016 $cmd = CommandsFactory::create_command($n, 'mail', false); 00017 $ret->merge($cmd->execute()); 00018 } 00019 } 00020 else { 00021 $this->set_result($existing); 00022 } 00023 return $ret; 00024 } 00025 }