/** * Sort out protected archives * @param array * @return array */ protected function sortOutProtected($arrArchives) { if (BE_USER_LOGGED_IN || !is_array($arrArchives) || empty($arrArchives)) { return $arrArchives; } $this->import('FrontendUser', 'User'); $objArchives = \SermonArchiveModel::findMultipleByIds($arrArchives); $arrArchives = array(); if ($objArchives !== null) { while ($objArchives->next()) { if ($objArchives->protected) { if (!FE_USER_LOGGED_IN) { continue; } $groups = deserialize($objArchives->groups); if (!is_array($groups) || empty($groups) || count(array_intersect($groups, $this->User->groups)) < 1) { continue; } } $arrArchives[] = $objArchives->id; } } return $arrArchives; }
/** * Return the IDs of the allowed sermon archives as array * @return array */ public function getAllowedArchives() { if ($this->User->isAdmin) { $objArchive = SermonArchiveModel::findAll(); } else { $objArchive = SermonArchiveModel::findMultipleByIds($this->User->sermoner); } $return = array(); if ($objArchive !== null) { while ($objArchive->next()) { $return[$objArchive->id] = $objArchive->title; } } return $return; }