contributions/usermanagement.notifications/behaviour/commands/notifications/markread.cmd.php
Go to the documentation of this file.00001 <?php 00002 /** 00003 * Mark notification as read 00004 */ 00005 class MarkreadNotificationsCommand extends CommandChain { 00006 /** 00007 * Returns title of command. 00008 */ 00009 public function get_name() { 00010 return 'markread'; 00011 } 00012 00013 /** 00014 * Returns a description of this command 00015 */ 00016 public function get_description() { 00017 return tr('Mark as read', 'notifications'); 00018 } 00019 00020 /** 00021 * Do it 00022 * 00023 * @see core/behaviour/base/CommandTransactional#do_execute() 00024 */ 00025 protected function do_execute() { 00026 $ret = new Status(); 00027 /* @var $notification DAONotifications */ 00028 $notification = $this->get_instance(); 00029 if ($notification->is_active()) { 00030 $update_params = array( 00031 'read_through' => Notifications::READ_UNKNOWN, 00032 'read_action' => new DBNull() 00033 ); 00034 Arr::clean($update_params, $this->get_params()); 00035 $this->append(CommandsFactory::create_command($notification, 'status', Notifications::STATUS_READ)); 00036 $this->append(CommandsFactory::create_command($notification, 'update', $update_params)); 00037 00038 // Confirm email, if click came from email 00039 if ($update_params['read_through'] == Notifications::READ_MAIL) { 00040 $user = $notification->get_user(); 00041 Users::confirm_email($user); 00042 } 00043 } 00044 return $ret; 00045 } 00046 }