Elgg  Version 1.11
AdminNotices.php
Go to the documentation of this file.
1 <?php
2 namespace Elgg\Database;
3 
15 class AdminNotices {
31  function add($id, $message) {
32  if ($id && $message) {
34  return false;
35  }
36 
37  // need to handle when no one is logged in
38  $old_ia = elgg_set_ignore_access(true);
39 
40  $admin_notice = new \ElggObject();
41  $admin_notice->subtype = 'admin_notice';
42  // admins can see ACCESS_PRIVATE but no one else can.
43  $admin_notice->access_id = ACCESS_PRIVATE;
44  $admin_notice->admin_notice_id = $id;
45  $admin_notice->description = $message;
46 
47  $result = $admin_notice->save();
48 
49  elgg_set_ignore_access($old_ia);
50 
51  return (bool)$result;
52  }
53 
54  return false;
55  }
56 
69  function delete($id) {
70  if (!$id) {
71  return false;
72  }
73  $result = true;
75  'metadata_name' => 'admin_notice_id',
76  'metadata_value' => $id,
77  'distinct' => false,
78  ));
79 
80  if ($notices) {
81  // in case a bad plugin adds many, let it remove them all at once.
82  foreach ($notices as $notice) {
83  $result = ($result && $notice->delete());
84  }
85  return $result;
86  }
87  return false;
88  }
89 
97  function find($limit = 10) {
99  'type' => 'object',
100  'subtype' => 'admin_notice',
101  'limit' => $limit,
102  'distinct' => false,
103  ));
104  }
105 
114  function exists($id) {
115  $old_ia = elgg_set_ignore_access(true);
117  'type' => 'object',
118  'subtype' => 'admin_notice',
119  'metadata_name_value_pair' => array('name' => 'admin_notice_id', 'value' => $id),
120  'distinct' => false,
121  ));
122  elgg_set_ignore_access($old_ia);
123 
124  return ($notice) ? true : false;
125  }
126 }
elgg_admin_notice_exists($id)
Check if an admin notice is currently active.
Definition: admin.php:118
exists($id)
Check if an admin notice is currently active.
elgg_get_entities_from_metadata(array $options=array())
interfaces
Definition: metadata.php:255
find($limit=10)
Get admin notices.
$notices
Definition: admin.php:16
$limit
Definition: userpicker.php:31
elgg_set_ignore_access($ignore=true)
Set if Elgg&#39;s access system should be ignored.
Definition: access.php:43
add($id, $message)
Write a persistent message to the admin view.
const ACCESS_PRIVATE
Definition: elgglib.php:1954
if(!$collection_name) $id
Definition: add.php:17