[ PHPXref.com ] [ Generated: Sun Jul 20 19:12:06 2008 ] [ Oscailt 3.00 ]
[ Index ]     [ Variables ]     [ Functions ]     [ Classes ]     [ Constants ]     [ Statistics ]

title

Body

[close]

/html/ -> editregions.php (source)

   1  <?php
   2  /************************************************************************/

   3  /* Oscailt                                                              */

   4  /* Indepenent Media Centre Content Management System                    */

   5  /* ==================================================================== */

   6  /* Copyright (c)2003-2005 by Independent Media Centre Ireland           */

   7  /* http://www.indymedia.ie                                              */

   8  /* Development List: oscailt@lists.indymedia.org                        */

   9  /* See contributions.txt for the list of contributors                   */

  10  /*                                                                      */

  11  /* This program is free software. You can redistribute it and/or modify */

  12  /* it under the terms of the GNU General Public License as published by */

  13  /* the Free Software Foundation. http://www.gnu.org/copyleft/gpl.html   */

  14  /*                                                                      */

  15  /* This program is distributed in the hope that it will be useful,      */

  16  /* but WITHOUT ANY WARRANTY; without even the implied warranty of       */

  17  /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the        */

  18  /* GNU General Public License for more details.                         */

  19  /************************************************************************/

  20  
  21  require_once ("oscailt_init.inc");
  22  $OSCAILT_SCRIPT = "editregions.php";
  23  addToPageTitle("Manage Regions");
  24  
  25  function writeRegionList()
  26  {
  27     global $regionList;
  28     ?>
  29     <table align=center>
  30     <tr class=admin>
  31        <th class=admin colspan=6 align=center>Regions</td>
  32  
  33     </tr>
  34     <tr class=admin>
  35        <th class=admin>&nbsp;Name&nbsp;</th>
  36        <th class=admin>&nbsp;Active&nbsp;</th>
  37        <th class=admin>&nbsp;Protected&nbsp;</th>
  38  
  39        <th class=admin>&nbsp;Associated Stories&nbsp;</th>
  40        <th class=admin>&nbsp;Edit&nbsp;</th>
  41        <th class=admin>&nbsp;Delete&nbsp;</th>
  42     </tr>
  43     <?
  44     $regionList->reset();
  45     $regions = $regionList->getRegions();
  46     for($i=0;$i<count($regions);$i++)
  47     {
  48        $region=$regions[$i];
  49        ?>
  50        <tr class=admin>
  51           <td class=admin>&nbsp;<?=$region->region_name?>&nbsp;</td>
  52           <td class=admin align=center><?
  53           if($region->active==true) echo("<img src='graphics/active.gif'>");
  54           else echo("<img src='graphics/inactive.gif'>");
  55  
  56  
  57           ?></td>
  58           <td class=admin align=center><?
  59  
  60           if($region->excluded==true) echo("<img src='graphics/excluded.gif'>");
  61  
  62           else echo("<img src='graphics/included.gif'>");
  63  
  64           ?></td>
  65  
  66           <td class=admin align=center>&nbsp;<?=$region->getStoryCount()?>&nbsp;</td>
  67  
  68  
  69           <td class=admin align=center><a href="editregions.php?subpage=edit&region_id=<?=$region->region_id?>"><img src='graphics/edit.gif' border=0></a></td>
  70  
  71  
  72           <td class=admin align=center><a href="editregions.php?subpage=delete&region_id=<?=$region->region_id?>"><img src='graphics/delete.gif'  border=0></a></td>
  73  
  74  
  75        </tr>
  76        <?
  77     }
  78     ?>
  79     <tr>
  80        <form action="editregions.php" method=post>
  81        <input type=hidden name=subpage value="edit">
  82        <td colspan=6 align=center><input type=submit value="Create New Region"></td>
  83  
  84        </form>
  85     </tr>
  86     </table>
  87     <?
  88  }
  89  
  90  
  91  
  92  
  93  
  94  function writeError($error)
  95  {
  96     ?><BR><BR><font class=error><B><?=$error?></B></font><BR><BR><?
  97  }
  98  
  99  
 100  function writeEditBox()
 101  {
 102     $region = new Region();
 103     $region->region_id=$_REQUEST['region_id'];
 104     if($region->region_id != null) $region->load();
 105     ?>
 106     <table class=admin align=center width=300>
 107  
 108     <form action="editregions.php" method=post>
 109     <input type=hidden name=subpage value="edit">
 110     <?
 111        if($region->region_id != null)
 112        {
 113           ?><input type=hidden name=region_id value="<?=$region->region_id?>"><?
 114        }
 115     ?>
 116     <tr class=admin>
 117        <th class=admin colspan=4>
 118        <?
 119        if($region->region_id != null) echo("Edit ".$region->region_name);
 120        else echo("Create New Region");
 121        ?>
 122        </th>
 123     </tr>
 124     <tr class=admin>
 125        <td class=admin>&nbsp;<B>Name</B>&nbsp;</td>
 126        <td class=admin colspan=3><input name=region_name value="<?=$region->region_name?>"></td>
 127     </tr>
 128     <tr class=admin>
 129        <td class=admin colspan=4>
 130        Deactivating a region will prevent new stories from being
 131  
 132        published using this region except by editors. It will still be available for
 133  
 134        filtering and searching existing stories.
 135  
 136        </td>
 137     </tr>
 138     <tr class=admin>
 139        <td class=admin><B>Active</B></td>
 140        <td class=admin colspan=3 align=right><input type=checkbox name=active <? if($region->active==true) echo("checked"); ?>></td>
 141  
 142     </tr>
 143  
 144     <tr class=admin>
 145  
 146        <td class=admin colspan=4>
 147  
 148        Making a region protected will make all stories published with this region become invisible to anybody who doesn't have the right permissions
 149  
 150        </td>
 151  
 152     </tr>
 153  
 154     <tr class=admin>
 155  
 156        <td class=admin><B>Protected</B></td>
 157  
 158        <td class=admin colspan=3 align=right><input type=checkbox name=excluded <? if($region->excluded==true) echo("checked"); ?>></td>
 159  
 160     </tr>
 161     <tr>
 162        <td colspan=4 align=center>
 163        <input type=submit name=cancel value="&lt;&lt; Cancel">
 164        <input type=submit name=save value="Save &gt;&gt;">
 165        </td>
 166     </tr>
 167     </form>
 168     </table>
 169     <?
 170  }
 171  
 172  
 173  function writeConfirmDeleteBox()
 174  {
 175     $region = new Region();
 176     $region->region_id=$_REQUEST['region_id'];
 177     $region->load();
 178     ?>
 179     <table align=center>
 180     <form action="editregions.php" method=post>
 181     <input type=hidden name=subpage value="delete">
 182     <input type=hidden name=region_id value="<?=$region->region_id?>"><?
 183     ?>
 184     <tr>
 185        <td colspan=2 align=center><img src="graphics/caution.gif" align=middle><BR><BR><B>Are you sure you wish to delete <?=$region->region_name?>?</B><BR><BR></td>
 186     </tr>
 187     <tr>
 188        <td align=right><input type=submit name=cancel value="&lt;&lt; Cancel"></td>
 189        <td ><input type=submit name=confirm value="Delete &gt;&gt;"></td>
 190     </tr>
 191     </form>
 192     </table>
 193     <?
 194  }
 195  
 196  
 197  ob_start();
 198  
 199  
 200  
 201  if($editor_session->isSessionOpen())
 202  {
 203     writeAdminHeader();
 204     if($editor_session->editor->allowedReadAccessTo("editregions"))
 205     {
 206        if($_REQUEST['subpage']=="delete" && $_REQUEST['confirm']!=null)
 207        {
 208           $region = new Region();
 209           $region->region_id=$_REQUEST['region_id'];
 210           $region->load();
 211           if($region->region_id != null)
 212           {
 213              if($region->getStoryCount()==0)
 214              {
 215                 if($editor_session->editor->allowedWriteAccessTo("editregions"))
 216                 {
 217                    $region->delete();
 218                 }
 219                 else $editor_session->writeNoWritePermissionError();
 220              }
 221              else
 222              {
 223                 writeError("All stories associated with '$region->region_name' must be deleted or reassigned<BR>before '$region->region_name' can be deleted");
 224              }
 225           }
 226           writeRegionList();
 227        }
 228        else if($_REQUEST['subpage']=="delete" && $_REQUEST['cancel']!=null)
 229        {
 230           writeRegionList();
 231        }
 232        else if($_REQUEST['subpage']=="delete")
 233        {
 234           writeConfirmDeleteBox();
 235        }
 236        else if($_REQUEST['subpage']=="edit" && $_REQUEST['save']!=null)
 237        {
 238           $region= new Region();
 239           $region->region_id=$_REQUEST['region_id'];
 240           if($_REQUEST["active"]=="yes" || $_REQUEST["active"]=="on"  || $_REQUEST["active"]=="true") $region->active = true;
 241           else $region->active = false;
 242           if($_REQUEST["excluded"]=="yes" || $_REQUEST["excluded"]=="on"  || $_REQUEST["excluded"]=="true") $region->excluded = true;
 243  
 244           else $region->excluded = false;
 245  
 246           $region->region_name=cleanseTitleField($_REQUEST['region_name']);
 247           if($region->region_name==null || $region->region_name=="")
 248           {
 249              writeError("Please Specify Name");
 250              writeEditBox();
 251           }
 252           else if($region->region_id==null && $regionList->getRegionByName($region->region_name)!=null)
 253           {
 254              writeError("A region with this name already exists!");
 255              writeEditBox();
 256           }
 257           else
 258           {
 259              if($editor_session->editor->allowedWriteAccessTo("editregions"))
 260              {
 261                 $region->save();
 262                 writeRegionList();
 263              }
 264              else
 265              {
 266                 $editor_session->writeNoWritePermissionError();
 267                 writeEditBox();
 268              }
 269           }
 270        }
 271        else if($_REQUEST['subpage']=="edit" && $_REQUEST['cancel']==null)
 272        {
 273           writeEditBox();
 274        }
 275        else
 276        {
 277           writeRegionList();
 278        }
 279     }
 280     else $editor_session->writeNoReadPermissionError();
 281  }
 282  else $editor_session->writeNoSessionError();
 283  
 284  
 285  
 286  
 287  
 288  
 289  
 290  include_once ("adminfooter.inc");
 291  
 292  
 293  
 294  ?>
 295  
 296  


[ Powered by PHPXref - Served by Debian GNU/Linux ]