contributions/usermanagement.notifications/behaviour/commands/notifications/markallasread.cmd.php
Go to the documentation of this file.00001 <?php 00002 /** 00003 * Mark all notifications of user as read 00004 */ 00005 class MarkallasreadNotificationsCommand extends CommandChain { 00006 /** 00007 * Returns title of command. 00008 */ 00009 public function get_name() { 00010 return 'markallasread'; 00011 } 00012 00013 /** 00014 * Returns a description of this command 00015 */ 00016 public function get_description() { 00017 return tr('Mark all 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 $user = Users::get_current_user(); 00028 if ($user) { 00029 Load::models('notifications'); 00030 $params = array('read_through' => Notifications::READ_MARK_ALL); 00031 $notifications = Notifications::create_unread_user_adapter($user->id); 00032 $notifications->find(); 00033 while($notifications->fetch()) { 00034 $this->append(CommandsFactory::create_command(clone($notifications), 'markread', $params)); 00035 } 00036 } 00037 return $ret; 00038 } 00039 }