/*
+---------------------------------------------------------------+
| e107 website system
|
| ©Steve Dunstan 2001-2002
| http://e107.org
| jalist@e107.org
|
| Released under the terms and conditions of the
| GNU General Public License (http://gnu.org).
+---------------------------------------------------------------+
*/
//$ec_dir = e_PLUGIN."calendar_menu/";
$lan_file = $ec_dir."languages/".e_LANGUAGE.".php";
include(file_exists($lan_file) ? $lan_file : e_PLUGIN."calendar_menu/languages/English.php");
$datearray = getdate();
$current_day = $datearray['mday'];
$current_month = $datearray['mon'];
$current_year = $datearray['year'];
// get first and last days of month in unix format---------------------------------------------------
$monthstart= mktime(0,0,0,$current_month,1,$current_year);
$firstdayarray = getdate($monthstart);
$monthend = mktime(0,0,0,$current_month+1,0,$current_year);
$lastdayarray = getdate($monthend);
// ----------------------------------------------------------------------------------------------------------
// get events from current month----------------------------------------------------------------------
$sql -> db_Select("event", "*", "(event_start>='$monthstart' AND event_start<= '$monthend') OR (event_rec_y='$current_month')");
$events = $sql -> db_Rows();
while($row = $sql -> db_Fetch()){
extract($row);
$evf = getdate($event_start);
$tmp = $evf['mday'];
$event_true[$tmp] = $event_category;
}
// -----------------------------------------------------------------------------------------------------------
// set up arrays for calender display ------------------------------------------------------------------
$week = Array(EC_LAN_25,EC_LAN_19,EC_LAN_20,EC_LAN_21,EC_LAN_22,EC_LAN_23,EC_LAN_24);
$months = Array(EC_LAN_0,EC_LAN_1,EC_LAN_2,EC_LAN_3,EC_LAN_4,EC_LAN_5,EC_LAN_6,EC_LAN_7,EC_LAN_8,EC_LAN_9,EC_LAN_10,EC_LAN_11);
$calendar_title = $months[$datearray[mon]-1]." ".$current_year;
// -----------------------------------------------------------------------------------------------------------
$text = "";
if($events){
$text .= EC_LAN_26 . ": ".$events;
}else{
$text .= EC_LAN_27;
}
$start = $monthstart;
$text .= "
";
foreach($week as $day){
$text .= "| ".$day." | ";
}
$text .= " ";
$thismonth = $datearray['mon'];
$thisday = $datearray['mday'];
for($c=0; $c<$firstdayarray['wday']; $c++){
$text .= "
| ";
}
$loop = $firstdayarray['wday'];
for($c=1; $c<=31; $c++){
$dayarray = getdate($start+($c*84460));
if($dayarray['mon'] == $thismonth){
if($thisday == $c){
$text .= "";
}else{
$text .=" | ";
}
if($event_true[($c)]){
$sql -> db_Select("event_cat", "*", "event_cat_id='".$event_true[($c)]."' ");
$icon = $sql -> db_Fetch();
extract($icon);
$img = " ";
}else{
$img = " ";
}
$linkut = mktime(0 ,0 ,0 ,$dayarray['mon'], $c, $datearray['year']);
$text .="$img $c";
if($thisday == $c){
}
$text .= " | \n";
$loop++;
if($loop == 7){
$loop = 0;
$text .= " ";
}
}
}
for($a=($loop+1); $a<=7; $a++){
$text .="| | ";
}
$text .= "
";
$ns -> tablerender($calendar_title, $text);
?>
|
// Area Identification
$caption = 'Faction(s) Information';
// Form processing follows here
if ($_POST && !$error){ // Form processing requested
switch($_GET['cmd']){
case 'changesic':
case 'assignsic':
if ($_POST['m_final']){ // means we need to do something
$result = $GLOBALS['services']->sql_query('UPDATE factions SET faction_sic='.$_POST['m_final'].' WHERE faction_id='.$_GET['id']);
if ($GLOBALS['services']->sql_affectedrows($result) < 0){ // query failed
$error = error_layout('There was a problem getting data from the database: '.
join(' ',$GLOBALS['services']->sql_error($result)));
break;
} else { $successful = 1; }
}
break;
case 'changeco':
case 'assignco':
if ($_POST['m_final']){ // means we need to do something
$result = $GLOBALS['services']->sql_query('UPDATE factions SET faction_co='.$_POST['m_final'].' WHERE faction_id='.$_GET['id']);
if ($GLOBALS['services']->sql_affectedrows($result) < 0){ // query failed
$error = error_layout('There was a problem getting data from the database: '.
join(' ',$GLOBALS['services']->sql_error($result)));
break;
} else { $successful = 1; }
}
break;
default:
break;
}
}
// Display processing follows here
if (!$_SESSION['uobject']){
// This person has not logged in yet.
$text .= NOTLOGGEDINMSG;
} else if ($_GET['cmd'] == 'removesic'){
if (!$successful){
$text .= 'Please verify that you want to remove following pilot from the Second-in-Command position for the '.$faction->name.':';
$text .= '
';
$text .= '[ X ] '.$pilot['nick'].'';
$text .= $error;
$text .= $_SESSION['out']->formStart();
$text .= $_SESSION['out']->formHidden('m_final',$pilot['nick_id']);
$text .= $_SESSION['out']->formEnd('REMOVE SIC');
$text .= '
';
} else {
$squad = $pinfo->squad;
$array = $GLOBALS['services']->sql_autofetch('SELECT nick FROM nick WHERE nick_id='.$_POST['m_final']);
$text .= 'You have successfully removed the following Pilot as your Commanding Officer:';
$text .= '
';
$text .= '[ X ] '.$array['nick'].'';
$text .= '
';
$text .= 'To go back to viewing your faction information, click here.';
}
} else if ($_GET['cmd'] == 'assignsic' || $_GET['cmd'] == 'changesic'){
$caption .= '-- Assign/Change The SIC';
if (!$faction){ $faction = new Faction_Class($_GET['id']); }
if (!$successful){
if ($faction->co) { $codata = $GLOBALS['services']->sql_autofetch('SELECT nick.nick, nick.nick_id
FROM nick WHERE nick="'.$faction->co.'"'); }
if ($faction->sic) { $sicdata = $GLOBALS['services']->sql_autofetch('SELECT nick.nick, nick.nick_id
FROM nick WHERE nick="'.$faction->sic.'"'); }
if ($_POST['m_pilot'] != ""){ $pinfo = $GLOBALS['services']->sql_query('SELECT nick.nick, nick.nick_id
FROM nick, onweb
WHERE onweb.nick_id = nick.nick_id AND
onweb.faction ='.$_GET['id'].' AND
nick.nick LIKE "%'.$_POST['m_pilot'].'%" AND
nick.nick_id NOT IN ( '.(($faction->co)? $codata['nick_id'] : '0').','.
(($faction->sic)? $sicdata['nick_id'] : '0').')'); }
if ($_POST['m_final'] != "" || ($pinfo && $GLOBALS['services']->sql_numrows($pinfo) == 1)){ // There was only one result so show it.
// Now display text
$pilot = $GLOBALS['services']->sql_fetchrow($pinfo);
if (!$pilot){ $pilot = $GLOBALS['services']->sql_autofetch('SELECT nick,nick_id FROM nick WHERE nick_id='.$_POST['m_final']); }
$text .= 'Please verify that you want the following pilot in charge of '.$faction->name.':';
$text .= '
';
$text .= '[ X ] '.$pilot['nick'].'';
$text .= $error;
$text .= $_SESSION['out']->formStart();
$text .= $_SESSION['out']->formHidden('m_final',$pilot['nick_id']);
$text .= $_SESSION['out']->formEnd('ASSIGN SIC');
$text .= '
';
} else if ($GLOBALS['services']->sql_numrows($pinfo) > 1){
$text .= 'Please select the pilot you want the in charge of '.$faction->name.':';
$text .= '
';
$text .= $error;
$text .= $_SESSION['out']->formStart();
while($array = $GLOBALS['services']->sql_fetchrow($pinfo)){
$options[] = Array($array['nick_id'],$array['nick']);
}
$text .= $_SESSION['out']->formLine('Assign SIC: ','select','m_final',$_POST['m_final'],$options);
$text .= $_SESSION['out']->formEnd('ASSIGN SIC');
} else {
$text .= 'Please choose who you would like to assign as the Second-In-Command for the following Faction:';
$text .= '
';
$text .= '[ X ] '.$faction->name.'';
$text .= '
';
$text .= $error;
$text .= $_SESSION['out']->formStart();
$text .= $_SESSION['out']->formLine('Assign SIC: ','text','m_pilot',$_POST['m_pilot'],Array('size'=>34));
$text .= $_SESSION['out']->formEnd('ASSIGN SIC');
}
} else {
$squad = $pinfo->squad;
$array = $GLOBALS['services']->sql_autofetch('SELECT nick FROM nick WHERE nick_id='.$_POST['m_final']);
$text .= 'You have successfully assigned the following Pilot as your Second-In-Command:';
$text .= '
';
$text .= '[ X ] '.$array['nick'].'';
$text .= '
';
$text .= 'To go back to viewing your faction information, click here.';
}
} else if ($_GET['cmd'] == 'assignco' || $_GET['cmd'] == 'changeco'){
$caption .= '-- Assign/Change The CO';
if (!$faction){ $faction = new Faction_Class($_GET['id']); }
if (!$successful){
if ($faction->co) { $codata = $GLOBALS['services']->sql_autofetch('SELECT nick.nick, nick.nick_id
FROM nick WHERE nick="'.$faction->co.'"'); }
if ($faction->sic) { $sicdata = $GLOBALS['services']->sql_autofetch('SELECT nick.nick, nick.nick_id
FROM nick WHERE nick="'.$faction->sic.'"'); }
if ($_POST['m_pilot'] != ""){ $pinfo = $GLOBALS['services']->sql_query('SELECT nick.nick, nick.nick_id
FROM nick, onweb
WHERE onweb.nick_id = nick.nick_id AND
onweb.faction ='.$_GET['id'].' AND
nick.nick LIKE "%'.$_POST['m_pilot'].'%" AND
nick.nick_id NOT IN ( '.(($faction->co)? $codata['nick_id'] : '0').','.
(($faction->sic)? $sicdata['nick_id'] : '0').')'); }
if ($_POST['m_final'] != "" || ($pinfo && $GLOBALS['services']->sql_numrows($pinfo) == 1)){ // There was only one result so show it.
// Now display text
$pilot = $GLOBALS['services']->sql_fetchrow($pinfo);
if (!$pilot){ $pilot = $GLOBALS['services']->sql_autofetch('SELECT nick,nick_id FROM nick WHERE nick_id='.$_POST['m_final']); }
$text .= 'Please verify that you want the following pilot in charge of '.$faction->name.':';
$text .= '
';
$text .= '[ X ] '.$pilot['nick'].'';
$text .= $error;
$text .= $_SESSION['out']->formStart();
$text .= $_SESSION['out']->formHidden('m_final',$pilot['nick_id']);
$text .= $_SESSION['out']->formEnd('ASSIGN CO');
$text .= '
';
} else if ($GLOBALS['services']->sql_numrows($pinfo) > 1){
$text .= 'Please select the pilot you want the in charge of '.$faction->name.':';
$text .= '
';
$text .= $error;
$text .= $_SESSION['out']->formStart();
while($array = $GLOBALS['services']->sql_fetchrow($pinfo)){
$options[] = Array($array['nick_id'],$array['nick']);
}
$text .= $_SESSION['out']->formLine('Assign CO: ','select','m_final',$_POST['m_final'],$options);
$text .= $_SESSION['out']->formEnd('ASSIGN CO');
} else {
$text .= 'Please choose who you would like to assign as the Commanding Officer for the following Faction:';
$text .= '
';
$text .= '[ X ] '.$faction->name.'';
$text .= '
';
$text .= $error;
$text .= $_SESSION['out']->formStart();
$text .= $_SESSION['out']->formLine('Assign CO: ','text','m_pilot',$_POST['m_pilot'],Array('size'=>34));
$text .= $_SESSION['out']->formEnd('ASSIGN CO');
}
} else {
$squad = $pinfo->squad;
$array = $GLOBALS['services']->sql_autofetch('SELECT nick FROM nick WHERE nick_id='.$_POST['m_final']);
$text .= 'You have successfully assigned the following Pilot as your Commanding Officer:';
$text .= '
';
$text .= '[ X ] '.$array['nick'].'';
$text .= '
';
$text .= 'To go back to viewing your faction information, click here.';
}
} else {
// Default display
// If an ID is passed, then they are wanting to view a specific squad. If not, then only the
// squads their pilots are part of.
if ($_GET['id']){ // Only shows information for the ID passed
$result = $GLOBALS['services']->sql_query('SELECT faction,faction_abbrev,faction_id FROM factions ORDER BY faction');
while($array = $GLOBALS['services']->sql_fetchrow($result)){
if ($_GET['id'] != $array['faction_id']){
$menutext .= ' [ '.$array['faction'].' ('.$array['faction_abbrev'].') ] ';
} else {
$menutext .= ' [ '.$array['faction'].' ('.$array['faction_abbrev'].') ] ';
}
}
$text .= 'Here is the information on the faction you requested:
';
// First need to make sure this is a valid squad
if ($GLOBALS['services']->sql_numrows($GLOBALS['services']->sql_query('SELECT * FROM factions WHERE faction_id='.$_GET['id'])) < 1){
// Invalid squad ID
$text .= error_layout('This is not a valid faction.');
} else {
$faction = new Faction_Class($_GET['id']);
$text .= $faction->displayFaction($_SESSION['uobject']);
}
} else { // displays a random faction
$result = $GLOBALS['services']->sql_query('SELECT faction,faction_abbrev,faction_id FROM factions ORDER BY faction');
// figure out what Id to display
$rand = rand(1,$GLOBALS['services']->sql_numrows($result));
while($array = $GLOBALS['services']->sql_fetchrow($result)){
if ($rand != $array['faction_id']){
$menutext .= ' [ '.$array['faction'].' ('.$array['faction_abbrev'].') ] ';
} else {
$menutext .= ' [ '.$array['faction'].' ('.$array['faction_abbrev'].') ] ';
$faction = new Faction_Class($array['faction_id']);
$text .= $faction->displayFaction($_SESSION['uobject']);
}
}
}
}
// A fix for the fact that we never know what faction is being looked at until after the page is processed.
$atext = 'Factions: '.$menutext.' ';
$atext .= (($_SESSION['uobject'] && $_SESSION['uobject']->isAdmin())? '[ CREATE ]' : '');
$atext .= ' ';
$text = $atext.$text;
// Fix caption
$caption =''.$caption.' ';
if ($_GET['cmd']){
$caption .= '[ « ]';
}
$caption .= '[ ^ ] ';
// Display main Box
$ns->gen_tablerend($caption,$text);
?>
|
// Seconday area for holding things like the search tools and linked pilots info
// Do we have linked pilots?
if ($_SESSION['uobject'] && $_SESSION['uobject']->hasLinkedPilots()){
$ns->tablerender("Linked Pilots",$_SESSION['uobject']->displayPilots());
}
?>
|
// Display external template
require_once(FOOTERF);
?> |