r2182 - warn about martian user autotags
authorDenis Ovsienko <infrastation@yandex.ru>
Fri, 29 Aug 2008 14:34:37 +0000 (14:34 +0000)
committerDenis Ovsienko <infrastation@yandex.ru>
Fri, 29 Aug 2008 14:34:37 +0000 (14:34 +0000)
inc/code.php
inc/database.php

index 5748519e53cd727dab7efa23d2a5cfdde2defb20..1ee19d580e9243d6cc9b1353a715b740a8c8d84b 100644 (file)
@@ -774,7 +774,28 @@ function findAutoTagWarnings ($expr)
                                        (
                                                'header' => 'line ' . $expr['lineno'],
                                                'class' => 'warning',
-                                               'text' => "IPv4 network with ID '${recid}' does not exist"
+                                               'text' => "IPv4 network with ID '${recid}' does not exist."
+                                       ));
+                               case (mb_ereg_match ('^\$userid_', $expr['load'])):
+                                       $recid = mb_ereg_replace ('^\$userid_', '', $expr['load']);
+                                       if (recordExists ($recid, 'user'))
+                                               return array();
+                                       return array (array
+                                       (
+                                               'header' => 'line ' . $expr['lineno'],
+                                               'class' => 'warning',
+                                               'text' => "User account with ID '${recid}' does not exist."
+                                       ));
+                               case (mb_ereg_match ('^\$username_', $expr['load'])):
+                                       global $accounts;
+                                       $recid = mb_ereg_replace ('^\$username_', '', $expr['load']);
+                                       if (isset ($accounts[$recid]))
+                                               return array();
+                                       return array (array
+                                       (
+                                               'header' => 'line ' . $expr['lineno'],
+                                               'class' => 'warning',
+                                               'text' => "User account with name '${recid}' does not exist."
                                        ));
                                default:
                                        return array();
index e45ee706dbdda3c4b69da831121899ced384dcf7..dd7dcaa09c6caabe9b9756975d1d638825eaf443 100644 (file)
@@ -3060,12 +3060,14 @@ function recordExists ($id = 0, $realm = 'object')
        $table = array
        (
                'object' => 'RackObject',
-               'ipv4net' => 'IPRanges'
+               'ipv4net' => 'IPRanges',
+               'user' => 'UserAccount',
        );
        $idcol = array
        (
                'object' => 'id',
-               'ipv4net' => 'id'
+               'ipv4net' => 'id',
+               'user' => 'user_id',
        );
        $query = 'select count(*) from ' . $table[$realm] . ' where ' . $idcol[$realm] . ' = ' . $id;
        if (($result = useSelectBlade ($query, __FUNCTION__)) == NULL)