/**
  * __construct function.
  *
  * @access public
  * @param  object $objAlbum
  * @param  string $type
  * @return void
  */
 public function __construct($objAlbum, $type)
 {
     if (is_numeric($objAlbum)) {
         $objAlbum = \Photoalbums2AlbumModel::findByPk($objAlbum);
     }
     if (!is_object($objAlbum)) {
         return false;
     }
     $this->objAlbum = $objAlbum;
     $this->type = $type;
     $this->setPreviewImageId();
 }
 /**
  * Get all archives from photoalbums2 and return them as array
  * @return array
  */
 public function getPhotoalbums2Albums()
 {
     if (!$this->User->isAdmin && !is_array($this->User->photoalbums2s)) {
         return array();
     }
     $arrArchives = array();
     $objArchives = \Photoalbums2ArchiveModel::findAll(array('order' => 'title'));
     if ($objArchives !== null) {
         while ($objArchives->next()) {
             if ($this->User->isAdmin || $this->User->hasAccess($objArchives->id, 'photoalbums2s')) {
                 $objAlbums = \Photoalbums2AlbumModel::findBy('pid', $objArchives->id, array('order' => 'title'));
                 if ($objAlbums !== null) {
                     while ($objAlbums->next()) {
                         $arrArchives[$objArchives->title][$objAlbums->id] = $objAlbums->title;
                     }
                 }
             }
         }
     }
     return $arrArchives;
 }
 /**
  * generatePalette function.
  *
  * @access public
  * @return void
  */
 public function generatePalette()
 {
     // Get album
     $objAlbum = \Photoalbums2AlbumModel::findByPk($this->Input->get('id'));
     // Remove from palette
     if ($objAlbum->previewImageType != 'select_preview_image') {
         $this->removeFromPalette('tl_photoalbums2_album', 'default', 'previewImage');
     }
     // Remove from palette
     if ($objAlbum->imageSortType != 'custom') {
         $this->removeFromPalette('tl_photoalbums2_album', 'default', 'imageSort');
     }
 }
 /**
  * getAlbumIds function.
  *
  * @access public
  * @return array
  */
 public function getAlbumIds()
 {
     $arrAlbumIds = array();
     $objAlbums = \Photoalbums2AlbumModel::findAlbumsByMultipleArchives($this->items);
     // Return null if albums is not an object
     if ($objAlbums === null) {
         return null;
     }
     while ($objAlbums->next()) {
         $arrAlbumIds[] = $objAlbums->id;
     }
     if (isset($this->pa2AlbumSortType) && isset($this->pa2AlbumSort)) {
         $objPa2AlbumSorter = new \Pa2AlbumSorter($this->pa2AlbumSortType, $arrAlbumIds, $this->pa2AlbumSort);
         $arrAlbumIds = $objPa2AlbumSorter->getSortedIds();
         if ($arrAlbumIds === false) {
             return null;
         }
     }
     $objPa2Album = new \Pa2Album($arrAlbumIds, $this->getData());
     return $objPa2Album->getAlbumIds();
 }