remove old readme
[atutor.git] / mods / _standard / photos / index_admin.php
1 <?php
2 /***********************************************************************/
3 /* ATutor                                                                                                                          */
4 /***********************************************************************/
5 /* Copyright (c) 2002-2010                                             */
6 /* Inclusive Design Institute                                          */
7 /* http://atutor.ca                                                                                                        */
8 /*                                                                                                                                         */
9 /* This program is free software. You can redistribute it and/or           */
10 /* modify it under the terms of the GNU General Public License             */
11 /* as published by the Free Software Foundation.                                           */
12 /***********************************************************************/
13 // $Id$
14
15 define('AT_INCLUDE_PATH', '../../../include/');
16 require (AT_INCLUDE_PATH.'vitals.inc.php');
17 include (AT_INCLUDE_PATH.'../mods/_core/file_manager/filemanager.inc.php');     //clr_dir()
18 //include (AT_INCLUDE_PATH.'lib/filemanager.inc.php');  //clr_dir()
19 include (AT_PA_INCLUDE.'lib.inc.php');
20 include (AT_PA_INCLUDE.'classes/PhotoAlbum.class.php');
21 //$_custom_css = $_base_path . AT_PA_BASENAME . 'module.css'; // use a custom stylesheet
22 admin_authenticate(AT_ADMIN_PRIV_PHOTO_ALBUM);
23
24 //init
25 $aid = intval($_REQUEST['aid']);
26 $pa = new PhotoAlbum($aid);
27
28 //handle edit/delete
29 if (isset($_POST['edit'])){
30         //open up the edit page
31         header('Location: admin/edit_album.php?id='.$aid);
32 } elseif (isset($_POST['delete'])){
33         //handle confirmation 
34         if ($_POST['submit_no']) {
35                 $msg->addFeedback('CANCELLED');
36                 Header('Location: index_admin.php');
37                 exit;
38         }
39         if ($_POST['submit_yes']) {
40                 //delete
41                 $pa->deleteAlbum();
42                 $msg->addFeedback('ACTION_COMPLETED_SUCCESSFULLY');
43                 Header('Location: index_admin.php');
44                 exit;
45         }
46         //printing out the confirmation box
47         $hidden_vars['aid'] = $aid;
48         $hidden_vars['delete'] = 'delete';
49         $msg->addConfirm(array('PA_DELETE_ALBUM', AT_print($info['name'], 'photo_albums.name')), $hidden_vars); 
50 }
51
52 //paginator settings
53 $page = intval($_GET['p']);
54 $albums_count = sizeof($pa->getAllAlbums());
55 $last_page = ceil($albums_count/AT_PA_ADMIN_ALBUMS_PER_PAGE);
56
57 if (!$page || $page < 0) {
58         $page = 1;
59 } elseif ($page > $last_page){
60         $page = $last_page;
61 }
62 $count  = (($page-1) * AT_PA_ADMIN_ALBUMS_PER_PAGE) + 1;
63 $offset = ($page-1) * AT_PA_ADMIN_ALBUMS_PER_PAGE;
64
65 //get details
66 $albums = $pa->getAllAlbums($offset);
67
68 require (AT_INCLUDE_PATH.'header.inc.php');
69 $msg->printConfirm();
70 $savant->assign('albums', $albums);
71 $savant->assign('page', $page);
72 $savant->assign('num_rows', $photos_count);
73 $savant->display('photos/admin/pa_index.tmpl.php');
74 require (AT_INCLUDE_PATH.'footer.inc.php'); 
75 ?>