MCPcopy Create free account
hub / github.com/EqualifyEverything/equalify / update_alerts

Function update_alerts

actions/toggle_integration_status.php:168–222  ·  view source on GitHub ↗

* Update Alerts * @param string newstatus * @param string integration_uri */

($new_status, $integration_uri)

Source from the content-addressed store, hash-verified

166 * @param string integration_uri
167 */
168function update_alerts($new_status, $integration_uri) {
169
170 // Get active sites.
171 $sites_filter = array(
172 array(
173 'name' => 'status',
174 'value' => 'active'
175 )
176 );
177 $active_sites = DataAccess::get_db_rows(
178 'sites', $sites_filter, 1, 10000
179 );
180
181 // Create active sites to alerts filter.
182 $site_ids = NULL;
183 if(!empty($active_sites['content'])){
184 $site_ids = array();
185 foreach ($active_sites['content'] as $site){
186 array_push(
187 $site_ids,
188 array(
189 'name' => 'site_id',
190 'value' => $site->id,
191 'operator' => '=',
192 'condition' => 'OR'
193 )
194 );
195 }
196 }
197
198 // Create filter to select alerts with the current
199 // integration and active sites.
200 $alerts_filters = array(
201 array(
202 'name' => 'source',
203 'value' => $integration_uri
204 ),
205 array(
206 'name' => 'site_id',
207 'value' => $site_ids
208 )
209 );
210
211 // Now let's update fields.
212 $updated_fields = array(
213 array(
214 'name' => 'archived',
215 'value' => $new_status
216 )
217 );
218 DataAccess::update_db_rows(
219 'alerts', $updated_fields, $alerts_filters
220 );
221
222}

Callers 1

Calls 2

get_db_rowsMethod · 0.80
update_db_rowsMethod · 0.80

Tested by

no test coverage detected