NotifyallUsersCommand Class Reference
Send a notification to ALL users. More...
Inheritance diagram for
NotifyallUsersCommand:
Public Member Functions |
|
get_name () | |
Returns title of command. |
|
Protected Member Functions |
|
do_execute () | |
Do it. |
|
mass_insert ($title, $message, $source) | |
Create the insert query an run it. |
|
validate ($params) | |
Check if there are. |
Detailed Description
Send a notification to ALL users.
Definition at line 5 of file notifyall.cmd.php.
Member Function Documentation
NotifyallUsersCommand::do_execute | ( | ) | [protected] |
Do it.
- See also:
- core/behaviour/base/CommandTransactionaldo_execute()
Reimplemented from CommandTransactional.
Definition at line 18 of file notifyall.cmd.php.
00018 { 00019 $ret = new Status(); 00020 Load::models('notifications'); 00021 00022 $params = $this->get_params(); 00023 $ret->merge($this->validate($params)); 00024 if ($ret->is_ok()) { 00025 $title = Arr::get_item($params, 'title', ''); 00026 $message = Arr::get_item($params, 'message', ''); 00027 $source = Arr::get_item($params, 'source', ''); 00028 00029 $ret->merge($this->mass_insert($title, $message, $source)); 00030 } 00031 return $ret; 00032 }
NotifyallUsersCommand::get_name | ( | ) |
Returns title of command.
Reimplemented from CommandBase.
Definition at line 9 of file notifyall.cmd.php.
NotifyallUsersCommand::mass_insert | ( | $ | title, | |
$ | message, | |||
$ | source | |||
) | [protected] |
Create the insert query an run it.
Definition at line 37 of file notifyall.cmd.php.
00037 { 00038 $user = new DAOUsers(); 00039 $notification = new DAONotifications(); 00040 00041 $select = $user->create_select_query(); 00042 $select->set_fields(array( 00043 'id' => 'id_user', 00044 $notification->quote($title) => 'title', 00045 $notification->quote($message) => 'message', 00046 $notification->quote($source) => 'source', 00047 )); 00048 00049 $insert = $notification->create_insert_query(); 00050 $insert->set_fields(array( 00051 'id_user', 'title', 'message', 'source' 00052 )); 00053 $insert->set_select($select); 00054 return DB::execute($insert->get_sql(), $notification->get_table_driver()); 00055 }
NotifyallUsersCommand::validate | ( | $ | params | ) | [protected] |
Check if there are.
Definition at line 60 of file notifyall.cmd.php.
00060 { 00061 // Prepare a valid user id; 00062 $user = new DAOUsers(); 00063 $user->limit(0, 1); 00064 $user->find(DAOUsers::AUTOFETCH); 00065 $params['id_user'] = $user->id; 00066 00067 $test = new DAONotifications(); 00068 $test->read_from_array($params); 00069 return $test->validate(); 00070 }
The documentation for this class was generated from the following file:
- contributions/usermanagement.notifications/behaviour/commands/users/notifyall.cmd.php