Subversion Repositories oidplus

Rev

Rev 289 | Rev 386 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 289 Rev 360
Line 186... Line 186...
186
                // using '+' or '/', e.g. "OID(x)+RA(x)" would be split to "OID(x)" and "RA(x)"
186
                // using '+' or '/', e.g. "OID(x)+RA(x)" would be split to "OID(x)" and "RA(x)"
187
                // which would result in the message being placed in the logbook of OID x,
187
                // which would result in the message being placed in the logbook of OID x,
188
                // and the logbook of the RA owning OID x.
188
                // and the logbook of the RA owning OID x.
189
                $maskcodes_ary = self::split_maskcodes($maskcodes);
189
                $maskcodes_ary = self::split_maskcodes($maskcodes);
190
                if ($maskcodes_ary === false) {
190
                if ($maskcodes_ary === false) {
191
                        throw new OIDplusException("Invalid maskcode '$maskcodes' (failed to split)");
191
                        throw new OIDplusException(_L('Invalid maskcode "%1" (failed to split)',$maskcodes));
192
                }
192
                }
193
                foreach ($maskcodes_ary as list($sevs,$maskcode)) {
193
                foreach ($maskcodes_ary as list($sevs,$maskcode)) {
194
                        // At the beginning of each mask code, you can define a severity.
194
                        // At the beginning of each mask code, you can define a severity.
195
                        // If you have a mask code with multiple components, you don't have to place the
195
                        // If you have a mask code with multiple components, you don't have to place the
196
                        // severity for each component. You can just leave it at the beginning.
196
                        // severity for each component. You can just leave it at the beginning.
Line 254... Line 254...
254
                                        case '!CRIT':
254
                                        case '!CRIT':
255
                                        case  'CRIT':
255
                                        case  'CRIT':
256
                                                $severity = 5;
256
                                                $severity = 5;
257
                                                break;
257
                                                break;
258
                                        default:
258
                                        default:
259
                                                throw new OIDplusException("Invalid maskcode '$maskcodes' (Unknown severity '$sev')");
259
                                                throw new OIDplusException(_L('Invalid maskcode "%1" (Unknown severity "%2")',$maskcodes,$sev));
260
                                }
260
                                }
261
                        }
261
                        }
262
 
262
 
263
                        // OID(x)       Save log entry into the logbook of: Object "x"
263
                        // OID(x)       Save log entry into the logbook of: Object "x"
264
                        if (preg_match('@^OID\((.+)\)$@ismU', $maskcode, $m)) {
264
                        if (preg_match('@^OID\((.+)\)$@ismU', $maskcode, $m)) {
265
                                $object_id = $m[1];
265
                                $object_id = $m[1];
266
                                $objects[] = array($severity, $object_id);
266
                                $objects[] = array($severity, $object_id);
267
                                if ($object_id == '') throw new OIDplusException("OID logger mask requires OID");
267
                                if ($object_id == '') throw new OIDplusException(_L('OID logger mask requires OID'));
268
                        }
268
                        }
269
 
269
 
270
                        // SUPOID(x)    Save log entry into the logbook of: Parent of object "x"
270
                        // SUPOID(x)    Save log entry into the logbook of: Parent of object "x"
271
                        else if (preg_match('@^SUPOID\((.+)\)$@ismU', $maskcode, $m)) {
271
                        else if (preg_match('@^SUPOID\((.+)\)$@ismU', $maskcode, $m)) {
272
                                $object_id         = $m[1];
272
                                $object_id         = $m[1];
273
                                if ($object_id == '') throw new OIDplusException("SUPOID logger mask requires OID");
273
                                if ($object_id == '') throw new OIDplusException(_L('SUPOID logger mask requires OID'));
274
                                $obj = OIDplusObject::parse($object_id);
274
                                $obj = OIDplusObject::parse($object_id);
275
                                if ($obj) {
275
                                if ($obj) {
276
                                        $parent = $obj->getParent()->nodeId();
276
                                        $parent = $obj->getParent()->nodeId();
277
                                        $objects[] = array($severity, $parent);
277
                                        $objects[] = array($severity, $parent);
278
                                } else {
278
                                } else {
279
                                        throw new OIDplusException("SUPOID logger mask: Invalid object '$object_id'");
279
                                        throw new OIDplusException(_L('SUPOID logger mask: Invalid object %1',$object_id));
280
                                }
280
                                }
281
                        }
281
                        }
282
 
282
 
283
                        // OIDRA(x)?    Save log entry into the logbook of: Logged in RA of object "x"
283
                        // OIDRA(x)?    Save log entry into the logbook of: Logged in RA of object "x"
284
                        // Remove or replace "?" by "!" if the entity does not need to be logged in
284
                        // Remove or replace "?" by "!" if the entity does not need to be logged in
285
                        else if (preg_match('@^OIDRA\((.+)\)([\?\!])$@ismU', $maskcode, $m)) {
285
                        else if (preg_match('@^OIDRA\((.+)\)([\?\!])$@ismU', $maskcode, $m)) {
286
                                $object_id         = $m[1];
286
                                $object_id         = $m[1];
287
                                $ra_need_login     = $m[2] == '?';
287
                                $ra_need_login     = $m[2] == '?';
288
                                if ($object_id == '') throw new OIDplusException("OIDRA logger mask requires OID");
288
                                if ($object_id == '') throw new OIDplusException(_L('OIDRA logger mask requires OID'));
289
                                $obj = OIDplusObject::parse($object_id);
289
                                $obj = OIDplusObject::parse($object_id);
290
                                if ($obj) {
290
                                if ($obj) {
291
                                        if ($ra_need_login) {
291
                                        if ($ra_need_login) {
292
                                                foreach (OIDplus::authUtils()->loggedInRaList() as $ra) {
292
                                                foreach (OIDplus::authUtils()->loggedInRaList() as $ra) {
293
                                                        if ($obj->userHasWriteRights($ra)) $users[] = array($severity_online, $ra->raEmail());
293
                                                        if ($obj->userHasWriteRights($ra)) $users[] = array($severity_online, $ra->raEmail());
Line 297... Line 297...
297
                                                foreach (OIDplusRA::getAllRAs() as $ra) {
297
                                                foreach (OIDplusRA::getAllRAs() as $ra) {
298
                                                        if ($obj->userHasWriteRights($ra)) $users[] = array($severity, $ra->raEmail());
298
                                                        if ($obj->userHasWriteRights($ra)) $users[] = array($severity, $ra->raEmail());
299
                                                }
299
                                                }
300
                                        }
300
                                        }
301
                                } else {
301
                                } else {
302
                                        throw new OIDplusException("OIDRA logger mask: Invalid object '$object_id'");
302
                                        throw new OIDplusException(_L('OIDRA logger mask: Invalid object "%1"',$object_id));
303
                                }
303
                                }
304
                        }
304
                        }
305
 
305
 
306
                        // SUPOIDRA(x)? Save log entry into the logbook of: Logged in RA that owns the superior object of "x"
306
                        // SUPOIDRA(x)? Save log entry into the logbook of: Logged in RA that owns the superior object of "x"
307
                        // Remove or replace "?" by "!" if the entity does not need to be logged in
307
                        // Remove or replace "?" by "!" if the entity does not need to be logged in
308
                        else if (preg_match('@^SUPOIDRA\((.+)\)([\?\!])$@ismU', $maskcode, $m)) {
308
                        else if (preg_match('@^SUPOIDRA\((.+)\)([\?\!])$@ismU', $maskcode, $m)) {
309
                                $object_id         = $m[1];
309
                                $object_id         = $m[1];
310
                                $ra_need_login     = $m[2] == '?';
310
                                $ra_need_login     = $m[2] == '?';
311
                                if ($object_id == '') throw new OIDplusException("SUPOIDRA logger mask requires OID");
311
                                if ($object_id == '') throw new OIDplusException(_L('SUPOIDRA logger mask requires OID'));
312
                                $obj = OIDplusObject::parse($object_id);
312
                                $obj = OIDplusObject::parse($object_id);
313
                                if ($obj) {
313
                                if ($obj) {
314
                                        if ($ra_need_login) {
314
                                        if ($ra_need_login) {
315
                                                foreach (OIDplus::authUtils()->loggedInRaList() as $ra) {
315
                                                foreach (OIDplus::authUtils()->loggedInRaList() as $ra) {
316
                                                        if ($obj->userHasParentalWriteRights($ra)) $users[] = array($severity_online, $ra->raEmail());
316
                                                        if ($obj->userHasParentalWriteRights($ra)) $users[] = array($severity_online, $ra->raEmail());
Line 320... Line 320...
320
                                                foreach (OIDplusRA::getAllRAs() as $ra) {
320
                                                foreach (OIDplusRA::getAllRAs() as $ra) {
321
                                                        if ($obj->userHasParentalWriteRights($ra)) $users[] = array($severity, $ra->raEmail());
321
                                                        if ($obj->userHasParentalWriteRights($ra)) $users[] = array($severity, $ra->raEmail());
322
                                                }
322
                                                }
323
                                        }
323
                                        }
324
                                } else {
324
                                } else {
325
                                        throw new OIDplusException("SUPOIDRA logger mask: Invalid object '$object_id'");
325
                                        throw new OIDplusException(_L('SUPOIDRA logger mask: Invalid object "%1"',$object_id));
326
                                }
326
                                }
327
                        }
327
                        }
328
 
328
 
329
                        // RA(x)?       Save log entry into the logbook of: Logged in RA "x"
329
                        // RA(x)?       Save log entry into the logbook of: Logged in RA "x"
330
                        // Remove or replace "?" by "!" if the entity does not need to be logged in
330
                        // Remove or replace "?" by "!" if the entity does not need to be logged in
Line 351... Line 351...
351
                                }
351
                                }
352
                        }
352
                        }
353
 
353
 
354
                        // Unexpected
354
                        // Unexpected
355
                        else {
355
                        else {
356
                                throw new OIDplusException("Unexpected logger component '$maskcode' in mask code '$maskcodes'");
356
                                throw new OIDplusException(_L('Unexpected logger component "%1" in mask code "%2"',$maskcode,$maskcodes));
357
                        }
357
                        }
358
                }
358
                }
359
 
359
 
360
                // Now write the log message
360
                // Now write the log message
361
 
361