Subversion Repositories oidplus

Rev

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

Rev 1130 Rev 1137
Line 409... Line 409...
409
                }
409
                }
410
                return $out;
410
                return $out;
411
        }
411
        }
412
 
412
 
413
        /**
413
        /**
414
         * @return OIDplusRA
414
         * @return OIDplusRA|null
415
         * @throws OIDplusException
415
         * @throws OIDplusException
416
         */
416
         */
417
        public function getRa(): OIDplusRA {
417
        public function getRa()/*: ?OIDplusRA*/ {
418
                return new OIDplusRA($this->getRaMail());
418
                $ra = $this->getRaMail();
-
 
419
                return $ra ? new OIDplusRA($ra) : null;
419
        }
420
        }
420
 
421
 
421
        /**
422
        /**
422
         * @param OIDplusRA|string|null $ra
423
         * @param OIDplusRA|string|null $ra
423
         * @return bool
424
         * @return bool
Line 434... Line 435...
434
                if (!$ra) {
435
                if (!$ra) {
435
                        // Admin may do everything
436
                        // Admin may do everything
436
                        if (OIDplus::authUtils()->isAdminLoggedIn()) return true;
437
                        if (OIDplus::authUtils()->isAdminLoggedIn()) return true;
437
 
438
 
438
                        // If the RA is logged in, then they can see the OID.
439
                        // If the RA is logged in, then they can see the OID.
-
 
440
                        $ownRa = $this->getRaMail();
439
                        if (OIDplus::authUtils()->isRaLoggedIn($this->getRaMail())) return true;
441
                        if ($ownRa && OIDplus::authUtils()->isRaLoggedIn($ownRa)) return true;
440
                } else {
442
                } else {
441
                        // If this OID belongs to the requested RA, then they may see it.
443
                        // If this OID belongs to the requested RA, then they may see it.
442
                        if ($this->getRaMail() == $ra) return true;
444
                        if ($this->getRaMail() == $ra) return true;
443
                }
445
                }
444
 
446
 
Line 553... Line 555...
553
                }
555
                }
554
                return null;
556
                return null;
555
        }
557
        }
556
 
558
 
557
        /**
559
        /**
558
         * @return false|string|null
560
         * @return string|null
559
         * @throws OIDplusException
561
         * @throws OIDplusException
560
         */
562
         */
561
        public function getRaMail() {
563
        public function getRaMail() {
562
                if (!OIDplus::baseConfig()->getValue('OBJECT_CACHING', true)) {
564
                if (!OIDplus::baseConfig()->getValue('OBJECT_CACHING', true)) {
563
                        $res = OIDplus::db()->query("select ra_email from ###objects where id = ?", array($this->nodeId()));
565
                        $res = OIDplus::db()->query("select ra_email from ###objects where id = ?", array($this->nodeId()));
Line 567... Line 569...
567
                } else {
569
                } else {
568
                        self::buildObjectInformationCache();
570
                        self::buildObjectInformationCache();
569
                        if (isset(self::$object_info_cache[$this->nodeId()])) {
571
                        if (isset(self::$object_info_cache[$this->nodeId()])) {
570
                                return self::$object_info_cache[$this->nodeId()][self::CACHE_RA_EMAIL];
572
                                return self::$object_info_cache[$this->nodeId()][self::CACHE_RA_EMAIL];
571
                        }
573
                        }
572
                        return false;
574
                        return null;
573
                }
575
                }
574
        }
576
        }
575
 
577
 
576
        /**
578
        /**
577
         * @return false|string|null
579
         * @return false|string|null
Line 693... Line 695...
693
        public function userHasWriteRights($ra=null): bool {
695
        public function userHasWriteRights($ra=null): bool {
694
                if ($ra instanceof OIDplusRA) $ra = $ra->raEmail();
696
                if ($ra instanceof OIDplusRA) $ra = $ra->raEmail();
695
 
697
 
696
                if (!$ra) {
698
                if (!$ra) {
697
                        if (OIDplus::authUtils()->isAdminLoggedIn()) return true;
699
                        if (OIDplus::authUtils()->isAdminLoggedIn()) return true;
-
 
700
                        $ownRa = $this->getRaMail();
698
                        return OIDplus::authUtils()->isRaLoggedIn($this->getRaMail());
701
                        return $ownRa && OIDplus::authUtils()->isRaLoggedIn($ownRa);
699
                } else {
702
                } else {
700
                        return $this->getRaMail() == $ra;
703
                        return $this->getRaMail() == $ra;
701
                }
704
                }
702
        }
705
        }
703
 
706