Ejemplo n.º 1
0
 public function canRead($userId)
 {
     if ($this->canRead !== null) {
         return $this->canRead;
     }
     /** @noinspection PhpDynamicAsStaticMethodCallInspection */
     if (\CSocNetUser::isCurrentUserModuleAdmin()) {
         $this->canRead = true;
         return $this->canRead;
     }
     if ($comment = $this->loadLogCommentData()) {
         if (strpos($comment["EVENT_ID"], "crm_") === 0) {
             $queryLog = \CSocNetLog::getList(array(), array("ID" => intval($comment["LOG_ID"])), false, false, array("ID", "ENTITY_TYPE", "ENTITY_ID"));
             if (($log = $queryLog->fetch()) && Loader::includeModule("crm")) {
                 $userPermissions = \CCrmPerms::getUserPermissions($userId);
                 if ($log["ENTITY_TYPE"] == "CRMACTIVITY") {
                     $bindings = \CCRMActivity::getBindings($log["ENTITY_ID"]);
                     foreach ($bindings as $binding) {
                         if (\CCrmAuthorizationHelper::checkReadPermission(\CCrmOwnerType::resolveName($binding["OWNER_TYPE_ID"]), $binding["OWNER_ID"], $userPermissions)) {
                             $this->canRead = true;
                             return $this->canRead;
                         }
                     }
                 } else {
                     if (\CCrmAuthorizationHelper::checkReadPermission(\CCrmLiveFeedEntity::resolveEntityTypeID($log["ENTITY_TYPE"]), $log["ENTITY_ID"], $userPermissions)) {
                         $this->canRead = true;
                         return $this->canRead;
                     } elseif (intval($comment["LOG_ID"]) > 0 && \CSocNetLogRights::checkForUser($comment["LOG_ID"], $userId)) {
                         $this->canRead = true;
                         return $this->canRead;
                     }
                 }
             }
         } elseif (intval($comment["LOG_ID"]) > 0 && \CSocNetLogRights::checkForUser($comment["LOG_ID"], $userId)) {
             $this->canRead = true;
             return $this->canRead;
         }
     }
     $this->canRead = false;
     return $this->canRead;
 }