Subversion Repositories oidplus

Rev

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

Rev 1121 Rev 1130
Line 38... Line 38...
38
                        return !empty($res) ? $res : null;
38
                        return !empty($res) ? $res : null;
39
                }
39
                }
40
        }
40
        }
41
 
41
 
42
        /**
42
        /**
43
         * @param $email
43
         * @param string $email
44
         * @param bool $getId
44
         * @param bool $getId
45
         * @return bool|null
45
         * @return bool|null
46
         * @throws OIDplusException
46
         * @throws OIDplusException
47
         */
47
         */
48
        public static function alreadyHasFreeOid($email, bool $getId = false)/*: ?bool*/ {
48
        public static function alreadyHasFreeOid(string $email, bool $getId = false)/*: ?bool*/ {
49
                $res = OIDplus::db()->query("select id from ###objects where ra_email = ? and id like ? order by ".OIDplus::db()->natOrder('id'), array($email, self::getFreeRootOid(true).'.%'));
49
                $res = OIDplus::db()->query("select id from ###objects where ra_email = ? and id like ? order by ".OIDplus::db()->natOrder('id'), array($email, self::getFreeRootOid(true).'.%'));
50
                while ($row = $res->fetch_array()) {
50
                while ($row = $res->fetch_array()) {
51
                        return $getId ? $row['id'] : true;
51
                        return $getId ? $row['id'] : true;
52
                }
52
                }
53
                return $getId ? null : false;
53
                return $getId ? null : false;
Line 142... Line 142...
142
                                $ra_name = $ra->raName();
142
                                $ra_name = $ra->raName();
143
                        }
143
                        }
144
 
144
 
145
                        // 2. step: Add the new OID to the database
145
                        // 2. step: Add the new OID to the database
146
 
146
 
147
                        $url = isset($params['url']) ? $params['url'] : '';
147
                        $url = $params['url'] ?? '';
148
                        $title = isset($params['title']) ? $params['title'] : '';
148
                        $title = $params['title'] ?? '';
149
 
149
 
150
                        $root_oid = self::getFreeRootOid(false);
150
                        $root_oid = self::getFreeRootOid(false);
151
                        $new_oid = OIDplusOid::parse('oid:'.$root_oid)->appendArcs($this->freeoid_max_id()+1)->nodeId(false);
151
                        $new_oid = OIDplusOid::parse('oid:'.$root_oid)->appendArcs($this->freeoid_max_id()+1)->nodeId(false);
152
 
152
 
153
                        OIDplus::logger()->log("[INFO]OID(oid:$root_oid)+OIDRA(oid:$root_oid)!", "Child OID '$new_oid' added automatically by '$email' (RA Name: '$ra_name')");
153
                        OIDplus::logger()->log("[INFO]OID(oid:$root_oid)+OIDRA(oid:$root_oid)!", "Child OID '$new_oid' added automatically by '$email' (RA Name: '$ra_name')");