Rev 1116 | Rev 1130 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 1116 | Rev 1121 | ||
---|---|---|---|
Line 24... | Line 24... | ||
24 | // phpcs:enable PSR1.Files.SideEffects |
24 | // phpcs:enable PSR1.Files.SideEffects |
25 | 25 | ||
26 | class OIDplusPagePublicFreeOID extends OIDplusPagePluginPublic { |
26 | class OIDplusPagePublicFreeOID extends OIDplusPagePluginPublic { |
27 | 27 | ||
28 | /** |
28 | /** |
29 | * @param $with_ns |
29 | * @param bool $with_ns |
30 | * @return string |
30 | * @return string|null |
31 | * @throws OIDplusException |
31 | * @throws OIDplusException |
32 | */ |
32 | */ |
33 | private static function getFreeRootOid($with_ns) { |
33 | private static function getFreeRootOid(bool $with_ns)/*: ?string*/ { |
- | 34 | if (!in_array('ViaThinkSoft\OIDplus\OIDplusOid',OIDplus::getEnabledObjectTypes())) { |
|
- | 35 | return null; |
|
- | 36 | } else { |
|
34 | return ($with_ns ? 'oid:' : '').OIDplus::config()->getValue('freeoid_root_oid'); |
37 | $res = ($with_ns ? 'oid:' : '').OIDplus::config()->getValue('freeoid_root_oid'); |
- | 38 | return !empty($res) ? $res : null; |
|
- | 39 | } |
|
35 | } |
40 | } |
36 | 41 | ||
37 | /** |
42 | /** |
38 | * @param $email |
43 | * @param $email |
39 | * @param $getId |
44 | * @param bool $getId |
40 | * @return bool|mixed|null |
45 | * @return bool|null |
41 | * @throws OIDplusException |
46 | * @throws OIDplusException |
42 | */ |
47 | */ |
43 | public static function alreadyHasFreeOid($email, $getId = false){ |
48 | public static function alreadyHasFreeOid($email, bool $getId = false)/*: ?bool*/ { |
44 | $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).'.%')); |
45 | while ($row = $res->fetch_array()) { |
50 | while ($row = $res->fetch_array()) { |
46 | return $getId ? $row['id'] : true; |
51 | return $getId ? $row['id'] : true; |
47 | } |
52 | } |
48 | return $getId ? null : false; |
53 | return $getId ? null : false; |