Exemple #1
0
 /**
  * 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');
     $objArchive = \NewsArchiveModel::findMultipleByIds($arrArchives);
     $arrArchives = array();
     while ($objArchive->next()) {
         if ($objArchive->protected) {
             if (!FE_USER_LOGGED_IN) {
                 continue;
             }
             $groups = deserialize($objArchive->groups);
             if (!is_array($groups) || empty($groups) || !count(array_intersect($groups, $this->User->groups))) {
                 continue;
             }
         }
         $arrArchives[] = $objArchive->id;
     }
     return $arrArchives;
 }
Exemple #2
0
 /**
  * Return the IDs of the allowed news archives as array
  * @return array
  */
 public function getAllowedArchives()
 {
     if ($this->User->isAdmin) {
         $objArchive = NewsArchiveModel::findAll();
     } else {
         $objArchive = NewsArchiveModel::findMultipleByIds($this->User->news);
     }
     $return = array();
     if ($objArchive !== null) {
         while ($objArchive->next()) {
             $return[$objArchive->id] = $objArchive->title;
         }
     }
     return $return;
 }