/** * @param int $id - ID of the album * @param bool $auto_title */ protected function albumPrepare($id, $auto_title = true) { if (strpos($id, ':') !== false) { list($id, $hash) = explode(':', $id); $this->frontend_rights_user = (int) substr($hash, 16, -16); $hash = substr($hash, 0, 16) . substr($hash, -16); } $album_model = new photosAlbumModel(); $album = $album_model->getById($id); $this->setAlbum($album); // album not found or incorrect hash if (!$album || isset($hash) && $hash !== $album['hash']) { $this->where[] = '0'; return; } $this->frontend_base_url = $album['full_url']; if ($auto_title) { $this->addTitle($album['name']); } $count_model = new photosAlbumCountModel(); $this->update_count = array('model' => $album_model, 'id' => $id, 'count' => (int) $count_model->getCount($id)); if ($album['type']) { $this->setHash('/search/' . $album['conditions']); $this->prepare(false, false); $params_model = new photosAlbumParamsModel(); $params = $params_model->get($album['id']); if (isset($params['order']) && $params['order'] == 'rate') { $this->order_by = 'p.rate DESC, p.id DESC'; } while ($album['parent_id'] && $album['type']) { $album = $album_model->getByid($album['parent_id']); if ($album['type']) { $this->setHash('/search/' . $album['conditions']); $this->prepare(true, false); } else { $this->joins['photos_album_photos'] = array('table' => 'photos_album_photos', 'alias' => 'ap'); $this->where[] = "ap.album_id = " . (int) $album['id']; } } } else { $this->joins['photos_album_photos'] = array('table' => 'photos_album_photos', 'alias' => 'ap'); $this->where[] = "ap.album_id = " . (int) $id; $this->order_by = 'ap.sort ASC'; } }