/** * Finds IPs from the table by a given field and field value * * @param string $field * @param int $value * @return array */ protected function findIpsByField($field, $value) { $enableFields = EnableFieldsUtility::enableFields(self::TABLE); $ips = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows('ip', self::TABLE, $field . ' = ' . intval($value) . ' ' . $enableFields); if (empty($ips)) { return array(); } $finalIps = array(); foreach ($ips as $record) { $finalIps[] = $record['ip']; } return $finalIps; }
/** * @test * @expectedException InvalidArgumentException */ public function enableFieldsUtilityThrowsException() { EnableFieldsUtility::enableFields('UnknownTable'); }
/** * Finds entities with IP authentication * * @param string $table * @return array * @throws \RuntimeException */ protected function findEntitiesWithIpAuthentication($table) { $enableFields = EnableFieldsUtility::enableFields($table); $entities = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows('uid,pid', $table, 'tx_aoeipauth_ip > 0' . $enableFields); if (empty($entities)) { return array(); } // Enrich with IPs $finalEntities = array(); foreach ($entities as $entity) { $uid = $entity['uid']; if (self::TABLE_GROUP == $table) { $matchedIps = $this->getIpService()->findIpsByFeGroupId($uid); } elseif (self::TABLE_USER == $table) { $matchedIps = $this->getIpService()->findIpsByFeUserId($uid); } else { throw new \RuntimeException('Cannot load entries for unknown table.', 1390299890); } // Skip groups that do not find a corresponding ip if (empty($matchedIps)) { continue; } // Inject the matched ips to the group $entity['tx_aoeipauth_ip'] = $matchedIps; $finalEntities[] = $entity; } return $finalEntities; }
/** * Returns content elements that depend on logged in users/user groups * TODO: this will not consider: * a) content that is displayed here but is only referenced, and * b) content that is on the page but not used * (not actually linked to the page) * * @param int $uid fe_groups uid * @param int $languageUid * @return array */ public function findUserCustomizedContentByPageId($uid, $languageUid) { $enableFields = EnableFieldsUtility::enableFields(self::CONTENT_TABLE); $ttContent = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows('uid,pid', self::CONTENT_TABLE, 'fe_group > 0 AND sys_language_uid = ' . intval($languageUid) . ' AND pid = ' . intval($uid) . ' ' . $enableFields); return $ttContent; }