/**
  * 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;
 }
 /**
  * Auto-generate the alias if it has not been set yet
  * @param mixed
  * @param object
  * @return string
  */
 public function generateAlias($varValue, DataContainer $dc)
 {
     $autoAlias = false;
     // Generate alias if there is none
     if (!strlen($varValue)) {
         $autoAlias = true;
         $varValue = standardize($dc->activeRecord->title);
     }
     $objAlias = \Photoalbums2AlbumModel::findBy(array($dc->table . ".id!=?", $dc->table . ".alias=?"), array($dc->id, $varValue));
     // Check whether the albums alias exists
     if ($objAlias !== null && !$autoAlias) {
         throw new Exception(sprintf($GLOBALS['TL_LANG']['ERR']['aliasExists'], $varValue));
     }
     // Add ID to alias
     if ($objAlias != null && $autoAlias) {
         $varValue .= '-' . $dc->id;
         $varValue = $this->generateAlias($varValue, $dc);
     }
     return $varValue;
 }