/**
  * Run method with main page logic
  * 
  * Read in list of albums and the latest photos for each album. Pagination enabled.
  * Populate template with data and display results in the page.
  * @access public
  */
 public function run()
 {
     $PAGINATION_LIMIT = 10;
     $session = Session::getInstance();
     $user = $session->getUser();
     $albumDAO = AlbumDAO::getInstance();
     $photoDAO = PhotoDAO::getInstance();
     $page = isset($_GET["page"]) && is_numeric($_GET["page"]) ? intval($_GET["page"]) : 1;
     if ($page < 1) {
         $page = 1;
     }
     $count = $paginator = $paginator_page = null;
     $album = $photo_info_array = null;
     $title = "";
     $count = $albumDAO->count();
     $paginator = new Paginator($count, $PAGINATION_LIMIT);
     $paginator_page = $paginator->getPage($page);
     $album_array = $albumDAO->all(array("limit" => $paginator_page));
     $photo_info_array = array();
     foreach ($album_array as $album) {
         $count = $photoDAO->countByAlbum($album);
         if ($count > 0) {
             $tmp_paginator = new Paginator($count, 1);
             $tmp_paginator_page = $paginator->getPage($page);
             // Only get latest item
             list($latest_photo) = $photoDAO->allByAlbum($album, array("order" => "id DESC", "limit" => $tmp_paginator_page));
             $photo_info_array[] = array($count, $latest_photo);
         }
     }
     $this->template->render(array("title" => "Album List", "main_page" => "album_list_tpl.php", "session" => $session, "album_array" => $album_array, "photo_info_array" => $photo_info_array, "paginator_page" => $paginator_page));
 }
Exemple #2
0
 final function __construct()
 {
     $this->request = Request::getInstance();
     $this->response = Response::getInstance();
     $this->session = Session::getInstance();
     $this->onConstruct();
 }
 /**
  * Add access permission for a record to the backend user
  *
  * @param int     $id
  * @param string $accessField
  * @param string $permissionField
  *
  * @return bool If current record in a new record
  */
 protected function addNewRecordPermissions($id, $accessField, $permissionField)
 {
     /** @type \BackendUser|object $user */
     $user = \BackendUser::getInstance();
     $session = \Session::getInstance();
     $db = \Database::getInstance();
     $groups = deserialize($user->groups);
     $newRecords = $session->get('new_records');
     if (is_array($newRecords['tl_iso_group']) && in_array($id, $newRecords['tl_iso_group'])) {
         if ($user->inherit == 'custom' || empty($groups)) {
             // Add permissions on user level
             $objUser = $db->prepare("SELECT id, {$accessField}, {$permissionField} FROM tl_user WHERE id=?")->execute($user->id);
             $this->addCreatePermission($id, $permissionField, $accessField, 'tl_user', $objUser);
         } elseif (!empty($groups) && is_array($groups)) {
             // Add permissions on group level
             $objGroups = $db->execute("\n                    SELECT id, {$accessField}, {$permissionField}\n                    FROM tl_user_group\n                    WHERE " . $db->findInSet('id', $groups));
             while ($objGroups->next()) {
                 if ($this->addCreatePermission($id, $permissionField, $accessField, 'tl_user_group', $objGroups)) {
                     break;
                 }
             }
         }
         return true;
     }
     return false;
 }
 /**
  * Run method with main page logic
  * 
  * Populate template and display form for creating a new album entry. For POST request,
  * validate form data and save information to database. Available to admins only
  * @access public
  */
 public function run()
 {
     $session = Session::getInstance();
     $user = $session->getUser();
     if (!$user || !$user->isAdmin()) {
         $session->setMessage("Do not have permission to access", Session::MESSAGE_ERROR);
         header("Location: " . BASE_URL);
         return;
     }
     $albumDAO = AlbumDAO::getInstance();
     $album = null;
     $form_errors = array();
     $form_values = array("title" => "");
     if (!empty($_POST)) {
         $form_values["title"] = isset($_POST["title"]) ? trim($_POST["title"]) : "";
         if (empty($form_values["title"])) {
             $form_errors["title"] = "No title specified";
         }
         if (empty($form_errors)) {
             $album = new Album();
             $album->setTitle($form_values["title"]);
             if ($albumDAO->insert($album)) {
                 $session->setMessage("Album saved");
                 header("Location: edit_album.php?id={$album->id}");
                 return;
             } else {
                 $session->setMessage("Album not saved");
             }
         }
     }
     $this->template->render(array("title" => "Create Album", "session" => $session, "main_page" => "create_album_tpl.php", "album" => $album, "form_values" => $form_values, "form_errors" => $form_errors));
 }
Exemple #5
0
 public function __construct()
 {
     $this->session = Session::getInstance();
     $this->user = User::getInstance();
     $this->user->auth('*****@*****.**', 'tenant');
     $this->vu = VoteUtils::getInstance();
 }
 /**
  * Generate the module
  * @return string
  */
 public function generate()
 {
     $this->arrModules = array();
     // enable collapsing legends
     $session = \Session::getInstance()->get('fieldset_states');
     foreach ($this->getModules() as $k => $arrGroup) {
         list($k, $hide) = explode(':', $k, 2);
         if (isset($session['iso_be_overview_legend'][$k])) {
             $arrGroup['collapse'] = !$session['iso_be_overview_legend'][$k];
         } elseif ($hide == 'hide') {
             $arrGroup['collapse'] = true;
         }
         $this->arrModules[$k] = $arrGroup;
     }
     // Open module
     if (\Input::get('mod') != '') {
         return $this->getModule(\Input::get('mod'));
     } elseif (\Input::get('table') != '') {
         foreach ($this->arrModules as $arrGroup) {
             if (isset($arrGroup['modules'])) {
                 foreach ($arrGroup['modules'] as $strModule => $arrConfig) {
                     if (is_array($arrConfig['tables']) && in_array(\Input::get('table'), $arrConfig['tables'])) {
                         \Controller::redirect($this->addToUrl('mod=' . $strModule));
                     }
                 }
             }
         }
     }
     return parent::generate();
 }
 /** Performs actual login with login object **/
 function login($contractor)
 {
     $contractor->Password = "";
     $session = Session::getInstance();
     // Set session login object
     $session->setUserLogin($contractor);
 }
 public function isValid()
 {
     global $cfg;
     $db = Database::getInstance($cfg['MVC']['dsn']);
     $rules = $db->getAll("SELECT vrclassname, description, fieldname, \r\n\t\t\tfieldvalidators.modulename FROM fieldvalidators, formfields \r\n\t\t\tWHERE formfields.ruleid = fieldvalidators.ruleid\r\n\t\t\tAND formname = '{$this->formName}'");
     //This statement has been removed from the where clause:
     //modulename = '{$this->fieldData['moduleName']}' AND
     $invalidFields = array();
     $sess = Session::getInstance();
     // Validate the submitted fields
     foreach ($rules as $rule) {
         MVCUtils::includeValidator($rule['vrclassname'], $rule['modulename']);
         eval("\$validatorObj = new {$rule['vrclassname']}(\$this->fieldData);");
         $vResult = $validatorObj->isValid($this->fieldData[$rule['fieldname']]);
         if ($vResult !== true) {
             //Put the errors:
             // a) straight into the errors array for backwards compatibility
             // b) into a sub array, whose key is the submitted value for
             //    errorFormName, otherwise use the form name
             $invalidFields[$rule['fieldname']] = $vResult;
             if (!$this->errorFormName) {
                 $invalidFields[$this->formName][$rule['fieldname']] = $vResult;
             } else {
                 $invalidFields[$this->errorFormName][$rule['fieldname']] = $vResult;
             }
         }
         if ($sess->keyExists('auth_user')) {
             BasicLogger::logMessage($sess->getValue('auth_user'), self::module, "debug");
         }
     }
     if (!checkdate($this->fieldData['month'], $this->fieldData['day'], $this->fieldData['year']) || !is_numeric($this->fieldData['month']) || !is_numeric($this->fieldData['day']) || !is_numeric($this->fieldData['year'])) {
         $invalidFields[$this->formName]['form'] = "Invalid Date";
     }
     return $invalidFields;
 }
 function __construct()
 {
     parent::__construct();
     $this->session = Session::getInstance();
     $this->project = $this->session->getProject();
     $this->menu = array(Messages::getString('General.Logout') => "logout.php") + $this->menu;
 }
Exemple #10
0
 public function __construct($options)
 {
     $this->options = array_merge($this->options, $options);
     $this->Session = Session::getInstance();
     $this->db = Orm::loadModel('Users');
     $this->options['salt'] = Configure::get('globals.salt');
 }
Exemple #11
0
 /**
  * Вывод каптчи:
  */
 public function indexAction(Application $application, Template $template)
 {
     $kvs = KVS::getInstance();
     /*
     		if ($kvs -> exists(__CLASS__, 'captcha_ban', $_SERVER['REMOTE_ADDR']))
     			return false;
     		$kvs -> set(__CLASS__, 'captcha', $_SERVER['REMOTE_ADDR'], $kvs -> get(__CLASS__, 'captcha', $_SERVER['REMOTE_ADDR']) + 1);
     		$kvs -> expire(__CLASS__, 'captcha', $_SERVER['REMOTE_ADDR'], 5);
     
     		if ($kvs -> get(__CLASS__, 'captcha', $_SERVER['REMOTE_ADDR']) > 10) {
     			$kvs -> set(__CLASS__, 'captcha_ban', $_SERVER['REMOTE_ADDR'], true);
     			$kvs -> expire(__CLASS__, 'captcha_ban', $_SERVER['REMOTE_ADDR'], 60 * 15);
     			return false;
     		}
     */
     if (!isset($_GET['key'])) {
         return false;
     }
     /*
     		if (!preg_match('~^http://1chan\.ru/~i', $_SERVER['HTTP_REFERER']))
     		    return false;
     */
     $session = Session::getInstance();
     if ($session->instantGet('captcha_' . $_GET['key'], false)) {
         $captcha = new KCAPTCHA();
         $session->instantSet('captcha_' . $_GET['key'], $captcha->getKeyString());
     }
     return false;
 }
Exemple #12
0
 static function Clear()
 {
     $session = Session::getInstance();
     $session->set('_PROMPT_', false);
     echo "Setting Avy to Stop Listening!\n";
     // Set Avy to Listening mode
 }
 /**
  * Run method with main page logic
  * 
  * Read in the specified event from the database.
  * Populate template and display event details in the page. Allow admin preview of un-approved event
  * @access public
  */
 public function run()
 {
     $session = Session::getInstance();
     $user = $session->getUser();
     $eventDAO = EventDAO::getInstance();
     $attendDAO = AttendanceDAO::getInstance();
     $title = "";
     $event = $attending = $attend_array = null;
     $attend_count = null;
     if (!empty($_GET["id"]) && is_numeric($_GET["id"])) {
         $id = intval($_GET["id"]);
         $event = $eventDAO->load($id, array("joins" => true));
         // Check if event is approved
         if ($event && $event->status == Event::APPROVED_STATUS) {
             $title .= " - {$event->title}";
             if ($user) {
                 $attending = $attendDAO->loadExists($event, $user);
             }
             $attend_count = $attendDAO->countByEvent($event);
             $attend_array = $attendDAO->allByEvent($event, array("joins" => true, "order" => "id DESC"));
         } else {
             if ($event && $session->getUser() && $session->getUser()->isAdmin()) {
                 $title .= " - {$event->title}";
                 $attending = $attendDAO->loadExists($event, $user);
                 $attend_count = $attendDAO->countByEvent($event);
                 $attend_array = $attendDAO->allByEvent($event, array("joins" => true, "order" => "id DESC"));
             } else {
                 $event = null;
             }
         }
     }
     $this->template->render(array("title" => "Event Details" . $title, "main_page" => "view_event_tpl.php", "session" => $session, "event" => $event, "attending" => $attending, "attend_array" => $attend_array, "attend_count" => $attend_count));
 }
Exemple #14
0
 private function init()
 {
     $this->session = Session::getInstance();
     $this->request = Request::getInstance();
     $this->router = Router::getInstance();
     $this->view = View::getInstance();
 }
 public function build()
 {
     $sessio = Session::getInstance()->get('my_name');
     if (!empty($sessio)) {
         $this->setLayout('error/errorlogin.tpl');
     } else {
         $info = $this->getParams();
         if (isset($info['url_arguments'][0])) {
             $this->setLayout('error/error404.tpl');
         } else {
             $s = Session::getInstance()->get('email');
             if (empty($s)) {
                 $this->setLayout('error/error404.tpl');
             } else {
                 $this->setLayout('project/welcome.tpl');
                 $u = Session::getInstance()->get('username');
                 $b = Session::getInstance()->get('birth');
                 $e = Session::getInstance()->get('email');
                 $p = Session::getInstance()->get('password');
                 $obj = $this->getClass('MainModel');
                 $obj->insertar($u, $b, $e, $p);
                 $this->assign('username', $u);
                 Session::getInstance()->delete('username');
                 Session::getInstance()->delete('birth');
                 Session::getInstance()->delete('email');
                 Session::getInstance()->delete('password');
             }
         }
     }
 }
 /**
  * @param Message $message
  *
  * @return string
  */
 public function run(Message $message)
 {
     $emailMissing = \Session::getInstance()->get('AVISOTA_SEND_PREVIEW_TO_EMAIL_EMPTY') ? \Session::getInstance()->get('AVISOTA_SEND_PREVIEW_TO_EMAIL_EMPTY') : false;
     \Session::getInstance()->remove('AVISOTA_SEND_PREVIEW_TO_EMAIL_EMPTY');
     $template = new \TwigTemplate('avisota/send/send_preview_to_email', 'html5');
     return $template->parse(array('message' => $message, 'emailMissing' => $emailMissing));
 }
Exemple #17
0
 public function __construct()
 {
     $this->session = Session::getInstance();
     $this->su = ScreenUtils::getInstance();
     $this->user = User::getInstance();
     $this->user->auth('*****@*****.**', 'tenant');
 }
 /**
  * Run method with main page logic
  * 
  * Read in the specified article from the database.
  * Populate template and display article in the page
  * @access public
  */
 public function run()
 {
     $session = Session::getInstance();
     $user = $session->getUser();
     /*
     if ($user == null || !$user->validUser ()) {
         header ("Location: " . BASE_URL);
         return;
     }
     */
     $articleDAO = ArticleDAO::getInstance();
     $tagDAO = ArticleTagDAO::getInstance();
     $article = $articletags = null;
     $title = "";
     if (!empty($_GET["id"]) && is_numeric($_GET["id"])) {
         $article_id = intval($_GET["id"]);
         $article = $articleDAO->load($article_id, array("joins" => true));
         if ($article) {
             $title .= "{$article->getTitle()}";
             $articletags = $tagDAO->allArticleTags($article, array("order" => "name"));
         }
     }
     //print_r ($articletags);
     $this->template->render(array("title" => "Article - " . $title, "main_page" => "view_article_tpl.php", "session" => $session, "article" => $article, "articletags" => $articletags));
 }
 public function build()
 {
     $info = $this->getParams();
     if (!isset($info['url_arguments'][0])) {
         $sessio = Session::getInstance()->get('my_name');
         if (!empty($sessio)) {
             $this->setLayout('error/errorlogin.tpl');
         } else {
             $this->setLayout('project/main.tpl');
             $s = FALSE;
             Session::getInstance()->set('login', $s);
             if (Filter::getString('usernamelogin') && Filter::getString('passwordlogin')) {
                 $var = $this->validator(Filter::getString('usernamelogin'), Filter::getString('passwordlogin'));
                 if ($var == true) {
                     $userName = Filter::getString('usernamelogin');
                     Session::getInstance()->set('my_name', $userName);
                     $s = TRUE;
                     Session::getInstance()->set('login', $s);
                     $this->assign('loguejat', $s);
                     header('Location: http://g4.local/home');
                 } else {
                     $this->assign('errorMessage', "The username or/and password were incorrect, try again");
                     $this->setLayout('project/main.tpl');
                 }
             }
         }
     } else {
         $this->setLayout('error/error404.tpl');
     }
 }
 /**
  * Run method with main page logic
  * 
  * Read in list of the latest published articles. Pagination enabled.
  * Populate template and display results in the page.
  * @access public
  */
 public function run()
 {
     $PAGINATION_LIMIT = 10;
     $session = Session::getInstance();
     $user = $session->getUser();
     /*
     if ($user == null || !$user->validUser ()) {
         header ("Location: " . BASE_URL);
         return;
     }
     */
     $articleDAO = ArticleDAO::getInstance();
     $tagDAO = ArticleTagDAO::getInstance();
     $page = isset($_GET["page"]) && is_numeric($_GET["page"]) ? intval($_GET["page"]) : 1;
     if ($page < 1) {
         $page = 1;
     }
     $count = $paginator = $paginator_page = null;
     $article = $articletags_array = null;
     $title = "";
     $count = $articleDAO->countPublished(true);
     $paginator = new Paginator($count, $PAGINATION_LIMIT);
     $paginator_page = $paginator->getPage($page);
     $article_array = $articleDAO->allPublished(true, array("order" => "{$articleDAO->getTableName()}.postDate DESC, {$articleDAO->getTableName()}.id DESC", "limit" => $paginator_page, "joins" => true));
     foreach ($article_array as $article) {
         $articletags_array[] = $tagDAO->allArticleTags($article, array("order" => "name"));
     }
     $this->template->render(array("title" => "Latests Articles", "main_page" => "article_list_tpl.php", "session" => $session, "article_array" => $article_array, "articletags_array" => $articletags_array, "paginator_page" => $paginator_page));
 }
Exemple #21
0
 public function init($inmueble, $pagina)
 {
     if (!Session::getInstance()->usuario) {
         return '/admin/ingresar';
     }
     $this->inmuebleCodigo = $inmueble;
     $this->inmueble = new Inmuebles();
     $this->inmueble->codigo = $inmueble;
     $this->inmueble->queryAll();
     if (!$this->inmueble->found()) {
         return true;
     }
     $this->paginaCodigo = $pagina;
     $this->pagina = new Inmuebles_Paginas();
     $this->pagina->inmueble_id = $this->inmueble->id;
     $this->pagina->codigo = $pagina;
     $this->pagina->queryAll();
     if (!$this->pagina->found()) {
         return true;
     }
     if ('fotos' !== $this->pagina->tipo) {
         return "/admin/inmuebles/{$inmueble}/paginas/{$pagina}/editar";
     }
     $this->datos = Inmuebles_Paginas_Datos::allPairs(array('inmueble_pagina_id' => $this->pagina->id));
     return true;
 }
Exemple #22
0
 /**
  * ---
  */
 public function __construct()
 {
     $this->db = Db::getInstance();
     $this->request = Request::getInstance();
     $this->response = Response::getInstance();
     $this->session = Session::getInstance();
 }
Exemple #23
0
 public function __construct()
 {
     $this->session = Session::getInstance();
     $this->log = Log::getInstance();
     $this->loadEmbedSettings();
     $this->procUtils = ProcUtils::getInstance();
 }
Exemple #24
0
 public function init()
 {
     if (!Session::getInstance()->usuario) {
         return '/admin/ingresar';
     }
     return true;
 }
 function __construct()
 {
     parent::__construct();
     $this->session = Session::getInstance();
     $this->project = $this->session->getProject();
     $this->menu = array("Logout" => "logout.php") + $this->menu;
 }
Exemple #26
0
 public function __construct()
 {
     $this->session = Session::getInstance();
     $this->user = User::getInstance();
     $this->webDBUtils = WebDBUtils::getInstance();
     $this->log = Log::getInstance();
 }
Exemple #27
0
 /**
  * Initialize the object
  * @param string
  */
 public function __construct($strTable)
 {
     $this->import('Session');
     $this->intGroupId = (int) \Session::getInstance()->get('iso_products_gid');
     // Check if the group exists
     if ($this->intGroupId > 0) {
         $objGroup = \Isotope\Model\Group::findByPk($this->intGroupId);
         if (null === $objGroup) {
             if (\BackendUser::getInstance()->isAdmin || !is_array(\BackendUser::getInstance()->iso_groups)) {
                 $this->intGroupId = 0;
             } elseif (!\BackendUser::getInstance()->isAdmin) {
                 $this->intGroupId = (int) \Database::getInstance()->prepare("SELECT id FROM " . \Isotope\Model\Group::getTable() . " WHERE id IN ('" . implode("','", \BackendUser::getInstance()->iso_groups) . "') ORDER BY " . \Database::getInstance()->findInSet('id', \BackendUser::getInstance()->iso_groups))->limit(1)->execute()->id;
             }
         }
     }
     // Redirect if the product was not found
     if (isset($_GET['id'])) {
         $objProduct = \Database::getInstance()->prepare("SELECT id FROM " . $strTable . " WHERE id=?")->limit(1)->execute(\Input::get('id', true));
         if (!$objProduct->numRows) {
             \Controller::redirect(preg_replace('/(&amp;)?id=[^&]*/i', '', \Environment::get('request')));
         }
     }
     $arrClipboard = $this->Session->get('CLIPBOARD');
     // Cut all records
     if ($arrClipboard[$strTable]['mode'] == 'cutAll' && \Input::get('act') != 'cutAll') {
         \Controller::redirect(\Backend::addToUrl('&act=cutAll'));
     }
     parent::__construct($strTable);
 }
 /**
  * Check permissions for that entry
  * @return void
  */
 public static function check()
 {
     $session = \Session::getInstance()->getData();
     if (\Input::get('act') == 'delete' && in_array(\Input::get('id'), static::getUndeletableIds())) {
         \System::log('Product type ID ' . \Input::get('id') . ' is used in an order and can\'t be deleted', __METHOD__, TL_ERROR);
         \Controller::redirect('contao/main.php?act=error');
     } elseif (\Input::get('act') == 'deleteAll' && is_array($session['CURRENT']['IDS'])) {
         $arrDeletable = array_diff($session['CURRENT']['IDS'], static::getUndeletableIds());
         if (count($arrDeletable) != count($session['CURRENT']['IDS'])) {
             $session['CURRENT']['IDS'] = array_values($arrDeletable);
             \Session::getInstance()->setData($session);
             \Message::addInfo($GLOBALS['TL_LANG']['MSC']['undeletableRecords']);
         }
     }
     // Disable variants if no such attributes are available
     \Controller::loadDataContainer('tl_iso_product');
     $blnVariants = false;
     foreach ($GLOBALS['TL_DCA']['tl_iso_product']['fields'] as $strName => $arrConfig) {
         $objAttribute = $GLOBALS['TL_DCA']['tl_iso_product']['attributes'][$strName];
         if (null !== $objAttribute && $objAttribute->isVariantOption()) {
             $blnVariants = true;
             break;
         }
     }
     if (!$blnVariants) {
         \System::loadLanguageFile('explain');
         unset($GLOBALS['TL_DCA']['tl_iso_producttype']['subpalettes']['variants']);
         $GLOBALS['TL_DCA']['tl_iso_producttype']['fields']['variants']['input_field_callback'] = function ($dc) {
             // Make sure variants are disabled in this product type (see #1114)
             \Database::getInstance()->prepare("UPDATE " . $dc->table . " SET variants='' WHERE id=?")->execute($dc->id);
             return '<br><p class="tl_info">' . $GLOBALS['TL_LANG']['XPL']['noVariantAttributes'] . '</p>';
         };
     }
 }
 /**
  * Generate the content element
  */
 public function compile()
 {
     global $container;
     /** @var SubscriptionManager $subscriptionManager */
     $subscriptionManager = $container['avisota.subscription'];
     /** @var EventDispatcher $eventDispatcher */
     $eventDispatcher = $container['event-dispatcher'];
     $token = (array) \Input::get('token');
     if (count($token)) {
         $subscriptions = $subscriptionManager->confirmByToken($token);
         \Session::getInstance()->set('AVISOTA_LAST_SUBSCRIPTIONS', $subscriptions);
         if ($this->avisota_activation_confirmation_page) {
             $event = new GetPageDetailsEvent($this->avisota_activation_confirmation_page);
             $eventDispatcher->dispatch(ContaoEvents::CONTROLLER_GET_PAGE_DETAILS, $event);
             $event = new GenerateFrontendUrlEvent($event->getPageDetails());
             $eventDispatcher->dispatch(ContaoEvents::CONTROLLER_GENERATE_FRONTEND_URL, $event);
             $event = new RedirectEvent($event->getUrl());
             $eventDispatcher->dispatch(ContaoEvents::CONTROLLER_REDIRECT, $event);
         }
         $this->Template->confirmed = $subscriptions;
     } else {
         if ($this->avisota_activation_redirect_page) {
             $event = new GetPageDetailsEvent($this->avisota_activation_redirect_page);
             $eventDispatcher->dispatch(ContaoEvents::CONTROLLER_GET_PAGE_DETAILS, $event);
             $event = new GenerateFrontendUrlEvent($event->getPageDetails());
             $eventDispatcher->dispatch(ContaoEvents::CONTROLLER_GENERATE_FRONTEND_URL, $event);
             $event = new RedirectEvent($event->getUrl());
             $eventDispatcher->dispatch(ContaoEvents::CONTROLLER_REDIRECT, $event);
         }
     }
 }
 /**
  * Run method with main page logic
  * 
  * Read in album information and photos associated with an album from the database.
  * Populate template and display results in the page. Pagination possible
  * @access public
  */
 public function run()
 {
     $PAGINATION_LIMIT = 10;
     $session = Session::getInstance();
     $user = $session->getUser();
     $albumDAO = AlbumDAO::getInstance();
     $photoDAO = PhotoDAO::getInstance();
     $album = $photo_array = $photo_count = $paginator_page = $queryVars = null;
     $title = "";
     $page = isset($_GET["page"]) && is_numeric($_GET["page"]) ? intval($_GET["page"]) : 1;
     if ($page < 1) {
         $page = 1;
     }
     $id = isset($_GET["id"]) && is_numeric($_GET["id"]) ? intval($_GET["id"]) : 0;
     if ($id <= 0) {
         header("Location: " . BASE_URL);
         return;
     }
     $album = $albumDAO->load($id, array("joins" => true));
     if ($album) {
         $title = $album->getTitle();
         $count = $photoDAO->countByAlbum($album);
         $paginator = new Paginator($count, $PAGINATION_LIMIT);
         $paginator_page = $paginator->getPage($page);
         $photo_array = $photoDAO->allByAlbum($album, array("limit" => $paginator_page));
         $queryVars = array("id" => $id);
     }
     $this->template->render(array("title" => "View Album - {$title}", "session" => $session, "album" => $album, "photo_array" => $photo_array, "paginator_page" => $paginator_page, "queryVars" => $queryVars, "main_page" => "view_album_tpl.php"));
 }