Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master
Fetching contributors…

Cannot retrieve contributors at this time

file 303 lines (286 sloc) 16.43 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303
<?php
/**
* @version 1.5.1 $Id: install.mspseniors.php
* @package Joomla 1.5.x
* @subpackage MSP-seniors
* @copyright (C) 2009 Miami Solution Providers Inc (http://www.causewaycomputer.com)
* @license GNU/GPL
*/

// no direct access
defined('_JEXEC') or die('Restricted access');

$action = $_REQUEST['action'];

switch($action) {
case 'add':
case 'edit':
add_edit();
break;
case 'save':
save();
break;
case 'publish':
publish();
break;
case 'unpublish':
unpublish();
break;
case 'delete':
delete();
break;
default:
display();
break;
}

function display() {
include_once(JPATH_BASE.DS."components".DS."com_mspseniors".DS."includes".DS."admin.mspheader.php");
###############
global $mainframe;
$limit1 = 0;
$limit2 = 0;
$pa = 0;
if($_REQUEST['limit'] > 0) {
$limit2 = $_REQUEST['limit'];
}
else {
$limit2 = $mainframe->getCfg('list_limit');
}
if($_REQUEST['page'] > 0) {
$pa = $_REQUEST['page'];
}
else {
$pa = 1;
}
$limit1 = $limit2 * ($pa-1);
$database =& JFactory::getDBO();

$database->setQuery("select count(*) as tot from `#__".MSP_TABLE_PREFIX_SCHOOL."` where 1");
$cnt = $database->loadObject();
$total_page = ceil($cnt->tot/$limit2);

$database->setQuery("select * from `#__".MSP_TABLE_PREFIX_SCHOOL."` where 1 order by `date` desc, `id` desc limit ".$limit1.",".$limit2."");
$items = $database->loadObjectList();
?>
<div>
<div>&nbsp;</div>
<table width="100%" cellpadding="0" cellspacing="0"><tr><td><h1>Manage Schools</h1></td><td align="right"><a href="index.php?option=<?php echo $_REQUEST['option']; ?>&task=<?php echo $_REQUEST['task']; ?>&action=add&page=<?php echo $_REQUEST['page']; ?>&limit=<?php echo $_REQUEST['limit']; ?>" title="Add New School"><img src="images/new_f2.png" border="0" alt="Edit" /></a></td></tr></table>
</div>
<div>&nbsp;</div>
<div id="editcell">
<table class="adminlist">
<thead>
<tr>
<th width="5">#</th>
<th class="title">Name</th>
<th class="title">Email</th>
<th class="title">About</th>
<th class="title">Location</th>
<th class="title">Website</th>
<th class="title">Comment</th>
<th nowrap="nowrap">Published</th>
<th width="5" nowrap="nowrap">ID</th>
<th class="title">Edit</th>
<th class="title">Delete</th>
</tr>
</thead>
<tfoot>
<tr>
<td colspan="19">
<script type="text/JavaScript">
<!--
function MM_jumpMenu(targ,selObj,restore){ //v3.0
eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
if (restore) selObj.selectedIndex=0;
}
//-->
</script>
<del class="container"><div class="pagination">

<div class="limit">Display #:
<select name="limit" id="limit" class="inputbox" size="1" onchange="MM_jumpMenu('parent',this,0)">
<option value="index.php?option=<?php echo $_REQUEST['option']; ?>&task=<?php echo $_REQUEST['task']; ?>&page=1&limit=5" <?php if ($limit2 == '5') : ?>selected="selected"<?php endif; ?>>5</option>
<option value="index.php?option=<?php echo $_REQUEST['option']; ?>&task=<?php echo $_REQUEST['task']; ?>&page=1&limit=10" <?php if ($limit2 == '10') : ?>selected="selected"<?php endif; ?>>10</option>
<option value="index.php?option=<?php echo $_REQUEST['option']; ?>&task=<?php echo $_REQUEST['task']; ?>&page=1&limit=15" <?php if ($limit2 == '15') : ?>selected="selected"<?php endif; ?>>15</option>
<option value="index.php?option=<?php echo $_REQUEST['option']; ?>&task=<?php echo $_REQUEST['task']; ?>&page=1&limit=20" <?php if ($limit2 == '20') : ?>selected="selected"<?php endif; ?>>20</option>
<option value="index.php?option=<?php echo $_REQUEST['option']; ?>&task=<?php echo $_REQUEST['task']; ?>&page=1&limit=25" <?php if ($limit2 == '25') : ?>selected="selected"<?php endif; ?>>25</option>
<option value="index.php?option=<?php echo $_REQUEST['option']; ?>&task=<?php echo $_REQUEST['task']; ?>&page=1&limit=30" <?php if ($limit2 == '30') : ?>selected="selected"<?php endif; ?>>30</option>
<option value="index.php?option=<?php echo $_REQUEST['option']; ?>&task=<?php echo $_REQUEST['task']; ?>&page=1&limit=50" <?php if ($limit2 == '50') : ?>selected="selected"<?php endif; ?>>50</option>
<option value="index.php?option=<?php echo $_REQUEST['option']; ?>&task=<?php echo $_REQUEST['task']; ?>&page=1&limit=100" <?php if ($limit2 == '100') : ?>selected="selected"<?php endif; ?>>100</option>
<option value="index.php?option=<?php echo $_REQUEST['option']; ?>&task=<?php echo $_REQUEST['task']; ?>&page=1&limit=999999" <?php if ($limit2 == '999999') : ?>selected="selected"<?php endif; ?>>all</option>
</select> | Page:
<select name="page" id="page" class="inputbox" size="1" onchange="MM_jumpMenu('parent',this,0)">
<?php for($i=1;$i<=$total_page;$i++) { ?>
<option value="index.php?option=<?php echo $_REQUEST['option']; ?>&task=<?php echo $_REQUEST['task']; ?>&page=<?php echo $i; ?>&limit=<?php echo $limit2; ?>" <?php if ($i == $pa) : ?>selected="selected"<?php endif; ?>><?php echo $i; ?></option>
<?php } ?>
</select>
</div>
</div></del> </td>
</tr>
</tfoot>
<tbody>
<?php
$cnt = 1;
foreach ($items as $item) {

?>
<tr class="row<?php echo ($cnt%2); ?>">
<td valign="top"><?php echo $cnt; ?></td>
<td valign="top"><?php echo $item->schoolname.' '.$item->contactname; ?><?php if($item->status=='2') { ?><img src="images/new_f2.png" border="0" alt="New School" height="16" width="16" /><?php } ?></td>
<td align="center" valign="top"><?php echo $item->email; ?></td>
<td align="center" valign="top"><?php echo $item->about; ?></td>
<td align="center" valign="top"><?php echo $item->location; ?></td>
<td align="center" valign="top"><?php echo $item->website; ?></td>
<td valign="top"><?php echo $item->comment; ?></td>
<td align="center" valign="top">
<?php if($item->status == 1) { ?>
<a href="index.php?option=<?php echo $_REQUEST['option']; ?>&task=<?php echo $_REQUEST['task']; ?>&action=unpublish&id=<?php echo $item->id; ?>&page=<?php echo $_REQUEST['page']; ?>&limit=<?php echo $_REQUEST['limit']; ?>" title="Unpublish Item"><img src="images/tick.png" border="0" alt="Published" /></a>
<?php } else { ?>
<a href="index.php?option=<?php echo $_REQUEST['option']; ?>&task=<?php echo $_REQUEST['task']; ?>&action=publish&id=<?php echo $item->id; ?>&page=<?php echo $_REQUEST['page']; ?>&limit=<?php echo $_REQUEST['limit']; ?>" title="Publish Item"><img src="images/publish_x.png" border="0" alt="Unpublished" /></a>
<?php } ?> </td>
<td align="center" valign="top"><?php echo $item->id; ?></td>
<td align="center" valign="top"><a href="index.php?option=<?php echo $_REQUEST['option']; ?>&task=<?php echo $_REQUEST['task']; ?>&action=edit&id=<?php echo $item->id; ?>&page=<?php echo $_REQUEST['page']; ?>&limit=<?php echo $_REQUEST['limit']; ?>" title="Edit Item"><img src="images/edit_f2.png" border="0" alt="Edit" /></a></td>
<td align="center" valign="top"><a href="index.php?option=<?php echo $_REQUEST['option']; ?>&task=<?php echo $_REQUEST['task']; ?>&action=delete&id=<?php echo $item->id; ?>&page=<?php echo $_REQUEST['page']; ?>&limit=<?php echo $_REQUEST['limit']; ?>" title="Delete Item" onclick="javascript:if(confirm('Delete School #<?php echo $item->id; ?>. Are you sure?')){return true;}else{return false;}"><img src="images/delete_f2.png" border="0" alt="Delete" /></a></td>
</tr>
<?php
$cnt++;
}
if($cnt == 1) {
?>
<tr><td colspan="19">No Schools Found.</td></tr>
<?php
}
?>
</tbody>
</table>
</div>
<?php
include_once(JPATH_BASE.DS."components".DS."com_mspseniors".DS."includes".DS."admin.mspfooter.php");
###############
}

function publish() {
$database =& JFactory::getDBO();
$database->setQuery("update `#__".MSP_TABLE_PREFIX_SCHOOL."` set `status`='1' where `id`='".$_REQUEST['id']."'");
$database->query();
header("location:index.php?option=".$_REQUEST['option']."&task=".$_REQUEST['task']."&page=".$_REQUEST['page']."&limit=".$_REQUEST['limit']."&result=true");
exit();
}

function unpublish() {
$database =& JFactory::getDBO();
$database->setQuery("update `#__".MSP_TABLE_PREFIX_SCHOOL."` set `status`='0' where `id`='".$_REQUEST['id']."'");
$database->query();
header("location:index.php?option=".$_REQUEST['option']."&task=".$_REQUEST['task']."&page=".$_REQUEST['page']."&limit=".$_REQUEST['limit']."&result=true");
exit();
}

function delete() {
$database =& JFactory::getDBO();
$database->setQuery("delete from `#__".MSP_TABLE_PREFIX_SCHOOL."` where `id`='".$_REQUEST['id']."'");
$database->query();
header("location:index.php?option=".$_REQUEST['option']."&task=".$_REQUEST['task']."&page=".$_REQUEST['page']."&limit=".$_REQUEST['limit']."&result=true");
exit();
}

function add_edit() {
include_once(JPATH_BASE.DS."components".DS."com_mspseniors".DS."includes".DS."admin.mspheader.php");
###############
if($_REQUEST['id'] > 0) {
$database =& JFactory::getDBO();
$database->setQuery("select * from `#__".MSP_TABLE_PREFIX_SCHOOL."` where `id`='".$_REQUEST['id']."'");
$row = $database->loadObject();
}
###############
?>
<div>
<div><h1><?php echo ucfirst(strtolower($_REQUEST['action'])); ?> School</h1></div>
<div>&nbsp;</div>
</div>
<fieldset class="adminform">
<legend>Details</legend>
<script type="text/javascript">
function submitFormRS() {
var f = document.adminFormRS;
if(trim(f.schoolname.value) == '') {
alert("Please enter a School name.");
f.schoolname.focus();
return false;
}
if(trim(f.contactname.value) == '') {
alert("Please enter Contact name.");
f.lname.focus();
return false;
}
if(trim(f.email.value) == '') {
alert("Please enter email address.");
f.email.focus();
return false;
}
if((/^[a-zA-Z0-9._-]+@([a-zA-Z0-9.-]+\.)+[a-zA-Z.]{2,5}$/).exec(f.email.value)==null) {
alert("Please enter valid email");
f.email.focus();
return false;
}
f.submit();
}
function cancelFormRS() {
location.href='index.php?option=<?php echo $_REQUEST['option']; ?>&task=<?php echo $_REQUEST['task']; ?>&page=<?php echo $_REQUEST['page']; ?>&limit=<?php echo $_REQUEST['limit']; ?>';
}
function trim(str, chars) {
return ltrim(rtrim(str, chars), chars);
}
function ltrim(str, chars) {
chars = chars || "\\s";
return str.replace(new RegExp("^[" + chars + "]+", "g"), "");
}
function rtrim(str, chars) {
chars = chars || "\\s";
return str.replace(new RegExp("[" + chars + "]+$", "g"), "");
}
</script>
<form action="index.php" method="post" name="adminFormRS" id="adminFormRS" onsubmit="return submitFormRS();">
<input type="hidden" name="option" id="option" value="<?php echo $_REQUEST['option']; ?>" />
<input type="hidden" name="task" id="task" value="<?php echo $_REQUEST['task']; ?>" />
<input type="hidden" name="action" id="action" value="save" />
<input type="hidden" name="id" id="id" value="<?php echo $row->id; ?>" />
<input type="hidden" name="page" id="page" value="<?php echo $_REQUEST['page']; ?>" />
<input type="hidden" name="limit" id="limit" value="<?php echo $_REQUEST['limit']; ?>" />
<table class="admintable" style="width:50%;">
<tr><td colspan="3" style="text-align:right;" class="key"><span style="color:red;">*</span> fields are mandatory.</td></tr>
<tr><td class="key">School Name:<span style="color:red;">*</span></td><td colspan="2"><input name="schoolname" id="schoolname" type="text" maxlength="50" style="width:100%;" value="<?php echo $row->schoolname; ?>" /></td></tr>
<tr><td class="key">Contact Name:<span style="color:red;">*</span></td><td colspan="2"><input name="contactname" id="contactname" type="text" maxlength="50" style="width:100%;" value="<?php echo $row->contactname; ?>" /></td></tr>
<tr><td class="key">Email Address:<span style="color:red;">*</span></td><td colspan="2"><input name="email" id="email" type="text" maxlength="100" style="width:100%;" value="<?php echo $row->email; ?>" /></td></tr>
<tr><td class="key">About Submitter:</td><td colspan="2"><input name="about" id="about" type="text" style="width:100%;" value="<?php echo $row->about; ?>" /></td></tr>
<tr><td class="key">Location:</td><td colspan="2"><input name="location" id="location" type="text" maxlength="255" style="width:100%;" value="<?php echo $row->location; ?>" /></td></tr>
<tr><td class="key">Address1:</td><td colspan="2"><input name="address1" id="address1" type="text" maxlength="255" style="width:100%;" value="<?php echo $row->address1; ?>" /></td></tr>
<tr><td class="key">Address2:</td><td colspan="2"><input name="address2" id="address2" type="text" maxlength="255" style="width:100%;" value="<?php echo $row->address2; ?>" /></td></tr>
<tr><td class="key">City:</td><td colspan="2"><input name="city" id="city" type="text" maxlength="255" style="width:100%;" value="<?php echo $row->city; ?>" /></td></tr>
<tr><td class="key">Zip</td><td colspan="2"><input name="zip" id="zip" type="text" maxlength="255" style="width:100%;" value="<?php echo $row->zip; ?>" /></td></tr>
<tr><td class="key">Phone Number:</td><td colspan="2"><input name="location" id="location" type="text" maxlength="255" style="width:100%;" value="<?php echo $row->location; ?>" /></td></tr>
<tr><td class="key">Website:</td><td><input name="website" id="website" type="text" maxlength="255" style="width:100%;" value="<?php echo $row->website; ?>" /></td></tr>
<tr><td class="key">Date of Posting:<br />( yyyy-mm-dd )</td><td><input name="posting_date" id="posting_date" type="text" maxlength="255" style="width:100%;" value="<?php echo ($row->date ? $row->date : date('Y-m-d')); ?>" /></td></tr>
<tr><td colspan="3" class="key" style="text-align:left;">Comments:</td></tr>
<tr><td colspan="3"><textarea name="comments" id="comments" style="width:100%; height:150px;"><?php echo $row->comment; ?></textarea></td></tr>
<tr><td colspan="3" style="text-align:center;"><input type="button" value="Submit New School" class="button" style="width:auto;" onClick="return submitFormRS();" /> <input type="button" value="Cancel" class="button" style="width:auto;" onClick="return cancelFormRS();" /></td></tr>
</table>
</form>
</fieldset>
<?php
###############
include_once(JPATH_BASE.DS."components".DS."com_mspseniors".DS."includes".DS."admin.mspfooter.php");
###############
}

function save() {
foreach($_POST as $key=>$value) {
$_POST[$key] = addslashes($value);
}
$database =& JFactory::getDBO();
$postingArr = explode("-",$_POST['posting_date']);
$mktime = mktime(12, 0, 0, $postingArr[1], $postingArr[2], $postingArr[0]);
if(date('Y', $mktime) > 1979) {
$date = date('Y-m-d', $mktime);
}
else {
$date = date('Y-m-d');
}
if($_POST['id']>0) {
$database->setQuery("update `#__".MSP_TABLE_PREFIX_SCHOOL."` set `schoolname`='".$_POST['schoolname']."', `contactname`='".$_POST['contactname']."', `address1`='".$_POST['address1']."', `address2`='".$_POST['address2']."', `city`='".$_POST['city']."',`state`='".$_POST['state']."', `zip`='".$_POST['zip']."', `phone`='".$_POST['phone']."', `about`='".$_POST['about']."', `location`='".$_POST['location']."', `website`='".$_POST['website']."', `email`='".$_POST['email']."', `comment`='".$_POST['comments']."', `date`='".$date."' where `id`='".$_POST['id']."'");
}
else {
$database->setQuery("insert into `#__".MSP_TABLE_PREFIX_SCHOOL."`(`id`,`schoolname`, `contactname`, `address1`, `address2`, `city`, `state`, `zip`, `phone`, `about`, `website`, `email`, `comment`, `date`, `status`) values('','".$_POST['schoolname']."', '".$_POST['contactname']."', '".$_POST['address1']."', '".$_POST['address2']."', '".$_POST['city']."', '".$_POST['state']."', '".$_POST['zip']."', '".$_POST['phone']."', '".$_POST['about']."', '".$_POST['website']."', '".$_POST['email']."', '".$_POST['comments']."', '".$date."', '1')");
}
$database->query();
header("location:index.php?option=".$_REQUEST['option']."&task=".$_REQUEST['task']."&page=".$_REQUEST['page']."&limit=".$_REQUEST['limit']."&result=true");
exit();
}
?>
Something went wrong with that request. Please try again.