Location: PHPKode > projects > Nuke Modules CVS > modules/PostCalendar/pnadmin.php
<?php
// $Id: pnadmin.php,v 1.17.2.2 2002/06/05 20:00:23 epsilon7 Exp $
/********************************************************/
/* PostCalendar                                         */
/* Version 2.6,  see changes.txt for details            */
/* Originally by Rob Sutton (Events Calendar)           */
/* Development continued by                             */
/*                                                      */
/*  The PostCalendar Development Team                   */
/*     Mahmood Al-Yousif - hide@address.com          */
/*     Craig Hamlin - hide@address.com             */
/*     HotBird - hide@address.com                        */
/*     Roger Raymond - hide@address.com                 */
/*                                                      */
/* This program is opensource so you can do whatever    */
/* you want with it. However, I'm happy about any       */
/* clever idea or nifty change you might have or have   */
/* done, send them to                                   */
/* hide@address.com                                 */
/*                                                      */
/* Any new versions can be found at                     */
/* http://www.bahraini.tv first                         */
/********************************************************/


   
/**
 * the main administration function
 * This function is the default function, and is called whenever the
 * module is initiated without defining arguments.  As such it can
 * be used for a number of things, but most commonly it either just
 * shows the module menu and returns or calls whatever the module
 * designer feels should be the default function (often this is the
 * view() function)
 */
function PostCalendar_admin_main()
{
    $output = new pnHTML();

    if (!pnSecAuthAction(0, 'PostCalendar::Item', '::', ACCESS_EDIT)) {
        $output->Text(_POSTCALENDAR_NOAUTH);
        return $output->GetOutput();
    }

    $output->SetInputMode(_PNH_VERBATIMINPUT);
    $output->Text(PostCalendar_admin_listqueued());
    
    return $output->GetOutput();
}

function PostCalendar_admin_listapproved($e='')
{
    $output = new pnHTML();
    $output->SetInputMode(_PNH_VERBATIMINPUT);
    $output->Text(PostCalendar_adminmenu());
    
    if(!empty($e)) {
        $output->Text($e);
        $output->Linebreak(2);
    }
    // Security check - important to do this as early as possible to avoid
    // potential security holes or just too much wasted processing
    if (!pnSecAuthAction(0, 'PostCalendar::Item', '::', ACCESS_EDIT)) {
        $output->Text(_POSTCALENDAR_NOAUTH);
        return $output->GetOutput();
    }
    
    $offset_increment = pnModGetVar('PostCalendar','listhowmanyevents');
    if(!isset($offset_increment)) $offset_increment = 15;
    
    $offset = pnVarCleanFromInput('offset');
    if(!isset($offset)) {
        $offset = 0;
    } 
    
    pnModDBInfoLoad('PostCalendar');
    list($dbconn) = pnDBGetConn();
    $pntable = pnDBGetTables();
    
    $events_table = $pntable['postcalendar_events'];
    $events_column = &$pntable['postcalendar_events_column'];
    
    pnThemeLoad(pnUserGetTheme());
    // get the theme globals :: is there a better way to do this?
    global $bgcolor1, $bgcolor2, $bgcolor3, $bgcolor4, $bgcolor5;
    global $textcolor1, $textcolor2;
    
    
    
    $sql = "SELECT $events_column[eid],
                   $events_column[title], 
                   $events_column[time] 
            FROM   $events_table
            WHERE  $events_column[eventstatus] = 1
            ORDER BY $events_column[time]
            LIMIT  $offset,$offset_increment";
            
    $result = $dbconn->Execute($sql);
    
    $output->FormStart(pnModUrl('PostCalendar','admin','adminevents'));
    
    $output->Text('<table border="0" cellpadding="1" cellspacing="0" width="100%" bgcolor="'.$bgcolor2.'"><tr><td>');
    $output->Text('<table border="0" cellpadding="5" cellspacing="0" width="100%" bgcolor="'.$bgcolor1.'"><tr><td>');
        $output->Text('<center><font size="4"><b>'._PC_APPROVED_ADMIN.'</b></font></center>');
    $output->Text('</td></tr></table>');    
    $output->Text('</td></tr></table>');
    
    $output->Linebreak();
    
    $output->Text('<table border="0" cellpadding="1" cellspacing="0" width="100%" bgcolor="'.$bgcolor2.'"><tr><td>');
    $output->Text('<table border="0" cellpadding="5" cellspacing="0" width="100%" bgcolor="'.$bgcolor1.'">');
        if(!$result->NumRows()) {
            $output->Text('<tr><td width="100%" bgcolor="'.$bgcolor1.'" align="center"><b>'._PC_NO_EVENTS.'</b></td></tr>');
        } else {
            $output->Text('<tr><td bgcolor="'.$bgcolor1.'" align="center"><b>'._PC_EVENTS.'</b></td></tr>');
                       
            $output->Text('<table border="0" cellpadding="2" cellspacing="0" width="100%" bgcolor="'.$bgcolor1.'">');
            $output->Text('<tr><td>select</td><td>title</td><td>timestamp<td></tr>');   
            // output the queued events
            $count=0;
            for(; !$result->EOF; $result->MoveNext()) {
                list($eid,$title,$timestamp) = $result->fields;
                $output->Text('<tr>');
                    $output->Text('<td align="center" valign="top">');
                        $output->FormCheckbox('pc_event_id[]', false, $eid);
                    $output->Text('</td>');
                    $output->Text('<td  align="left" valign="top" width="100%">');
                        $output->Text($title);
                    $output->Text('</td>');
                    $output->Text('<td  align="left" valign="top" nowrap>');
                        $output->Text($timestamp);
                    $output->Text('</td>');
                $output->Text('</tr>');
                
                $count++;
            }
            $output->Text('</table>');     
        }
    $output->Text('</td></tr></table>');
    if($result->NumRows()) {
    $output->Linebreak();
    
    // action to take?
    $output->Text('<table border="0" cellpadding="1" cellspacing="0" width="100%" bgcolor="'.$bgcolor2.'"><tr><td>');
    $output->Text('<table border="0" cellpadding="5" cellspacing="0" width="100%" bgcolor="'.$bgcolor1.'"><tr>');
        $output->Text('<td align="left" valign="middle">');
            $seldata[0]['id'] = _ACTION_APPROVE;
            $seldata[0]['selected'] = 0;
            $seldata[0]['name'] = _PC_ACTION_APPROVE;
            $seldata[1]['id'] = _ACTION_DELETE;
            $seldata[1]['selected'] = 0;
            $seldata[1]['name'] = _PC_ACTION_DELETE;
            //$seldata[2]['id'] = _ACTION_EDIT;
            //$seldata[2]['selected'] = 0;
            //$seldata[2]['name'] = _PC_ACTION_EDIT;
            $seldata[2]['id'] = _ACTION_VIEW;
            $seldata[2]['selected'] = 1;
            $seldata[2]['name'] = _PC_ACTION_VIEW;
            
            $output->FormSelectMultiple('action', $seldata);
            $output->FormHidden('thelist','listapproved');
            $output->FormSubmit(_PC_PERFORM_ACTION);
        $output->Text('</td>');
    $output->Text('</tr></table>');    
    $output->Text('</td></tr></table>');
    $output->Linebreak();
    
    // start previous next links
    $output->Text('<table border="0" cellpadding="1" cellspacing="0" width="100%" bgcolor="'.$bgcolor2.'"><tr><td>');
    $output->Text('<table border="0" cellpadding="5" cellspacing="0" width="100%" bgcolor="'.$bgcolor1.'"><tr>');
    if($offset > 1) {
        $output->Text('<td align="left">');
        $next_link = pnModUrl('PostCalendar','admin','listapproved',array('offset'=>$offset-$offset_increment));
        $output->Text('<a href="'.$next_link.'"><< Prev '.$offset_increment.'</a>');
        $output->Text('</td>');
    } else {
        $output->Text('<td align="left"><< Prev</td>');
    }
    if($result->NumRows() >= $offset_increment) {
        $output->Text('<td align="right">');
        $next_link = pnModUrl('PostCalendar','admin','listapproved',array('offset'=>$offset+$offset_increment));
        $output->Text('<a href="'.$next_link.'">Next '.$offset_increment.' >></a>');
        $output->Text('</td>');
    } else {
        $output->Text('<td align="right">Next >></td>');
    }
    $output->Text('</tr></table>');   
    } 
    $output->Text('</td></tr></table>');
    // end previous next links
    
    
    $output->FormEnd();
    
    return $output->GetOutput();

}

function PostCalendar_admin_listhidden($e='')
{
    $output = new pnHTML();
    $output->SetInputMode(_PNH_VERBATIMINPUT);
    $output->Text(PostCalendar_adminmenu());
    
    if(!empty($e)) {
        $output->Text($e);
        $output->Linebreak(2);
    }
    
    // Security check - important to do this as early as possible to avoid
    // potential security holes or just too much wasted processing
    if (!pnSecAuthAction(0, 'PostCalendar::Item', '::', ACCESS_EDIT)) {
        $output->Text(_POSTCALENDAR_NOAUTH);
        return $output->GetOutput();
    }
    
    $offset_increment = pnModGetVar('PostCalendar','listhowmanyevents');
    if(!isset($offset_increment)) $offset_increment = 15;
    
    $offset = pnVarCleanFromInput('offset');
    if(!isset($offset)) {
        $offset = 0;
    } 
    
    pnModDBInfoLoad('PostCalendar');
    list($dbconn) = pnDBGetConn();
    $pntable = pnDBGetTables();
    
    $events_table = $pntable['postcalendar_events'];
    $events_column = &$pntable['postcalendar_events_column'];
    
    pnThemeLoad(pnUserGetTheme());
    // get the theme globals :: is there a better way to do this?
    global $bgcolor1, $bgcolor2, $bgcolor3, $bgcolor4, $bgcolor5;
    global $textcolor1, $textcolor2;
    
    
    
    $sql = "SELECT $events_column[eid],
                   $events_column[title], 
                   $events_column[time] 
            FROM   $events_table
            WHERE  $events_column[eventstatus] = -1
            ORDER BY $events_column[time]
            LIMIT  $offset,$offset_increment";
            
    $result = $dbconn->Execute($sql);
    
    $output->FormStart(pnModUrl('PostCalendar','admin','adminevents'));
    
    $output->Text('<table border="0" cellpadding="1" cellspacing="0" width="100%" bgcolor="'.$bgcolor2.'"><tr><td>');
    $output->Text('<table border="0" cellpadding="5" cellspacing="0" width="100%" bgcolor="'.$bgcolor1.'"><tr><td>');
        $output->Text('<center><font size="4"><b>'._PC_HIDDEN_ADMIN.'</b></font></center>');
    $output->Text('</td></tr></table>');    
    $output->Text('</td></tr></table>');
    
    $output->Linebreak();
    
    $output->Text('<table border="0" cellpadding="1" cellspacing="0" width="100%" bgcolor="'.$bgcolor2.'"><tr><td>');
    $output->Text('<table border="0" cellpadding="5" cellspacing="0" width="100%" bgcolor="'.$bgcolor1.'">');
        if(!$result->NumRows()) {
            $output->Text('<tr><td width="100%" bgcolor="'.$bgcolor1.'" align="center"><b>'._PC_NO_EVENTS.'</b></td></tr>');
        } else {
            $output->Text('<tr><td bgcolor="'.$bgcolor1.'" align="center"><b>'._PC_EVENTS.'</b></td></tr>');
                       
            $output->Text('<table border="0" cellpadding="2" cellspacing="0" width="100%" bgcolor="'.$bgcolor1.'">');
            $output->Text('<tr><td>select</td><td>title</td><td>timestamp<td></tr>');   
            // output the queued events
            $count=0;
            for(; !$result->EOF; $result->MoveNext()) {
                list($eid,$title,$timestamp) = $result->fields;
                $output->Text('<tr>');
                    $output->Text('<td align="center" valign="top">');
                        $output->FormCheckbox('pc_event_id[]', false, $eid);
                    $output->Text('</td>');
                    $output->Text('<td  align="left" valign="top" width="100%">');
                        $output->Text($title);
                    $output->Text('</td>');
                    $output->Text('<td  align="left" valign="top" nowrap>');
                        $output->Text($timestamp);
                    $output->Text('</td>');
                $output->Text('</tr>');
                
                $count++;
            }
            $output->Text('</table>');     
        }
    $output->Text('</td></tr></table>');
    if($result->NumRows()) {
    $output->Linebreak();
    
    // action to take?
    $output->Text('<table border="0" cellpadding="1" cellspacing="0" width="100%" bgcolor="'.$bgcolor2.'"><tr><td>');
    $output->Text('<table border="0" cellpadding="5" cellspacing="0" width="100%" bgcolor="'.$bgcolor1.'"><tr>');
        $output->Text('<td align="left" valign="middle">');
            $seldata[0]['id'] = _ACTION_APPROVE;
            $seldata[0]['selected'] = 0;
            $seldata[0]['name'] = _PC_ACTION_APPROVE;
            $seldata[1]['id'] = _ACTION_DELETE;
            $seldata[1]['selected'] = 0;
            $seldata[1]['name'] = _PC_ACTION_DELETE;
            //$seldata[2]['id'] = _ACTION_EDIT;
            //$seldata[2]['selected'] = 0;
            //$seldata[2]['name'] = _PC_ACTION_EDIT;
            $seldata[2]['id'] = _ACTION_VIEW;
            $seldata[2]['selected'] = 1;
            $seldata[2]['name'] = _PC_ACTION_VIEW;
            
            $output->FormSelectMultiple('action', $seldata);
            $output->FormHidden('thelist','listhidden');
            $output->FormSubmit(_PC_PERFORM_ACTION);
        $output->Text('</td>');
    $output->Text('</tr></table>');    
    $output->Text('</td></tr></table>');
    $output->Linebreak();
    
    // start previous next links
    $output->Text('<table border="0" cellpadding="1" cellspacing="0" width="100%" bgcolor="'.$bgcolor2.'"><tr><td>');
    $output->Text('<table border="0" cellpadding="5" cellspacing="0" width="100%" bgcolor="'.$bgcolor1.'"><tr>');
    if($offset > 1) {
        $output->Text('<td align="left">');
        $next_link = pnModUrl('PostCalendar','admin','listhidden',array('offset'=>$offset-$offset_increment));
        $output->Text('<a href="'.$next_link.'"><< Prev '.$offset_increment.'</a>');
        $output->Text('</td>');
    } else {
        $output->Text('<td align="left"><< Prev</td>');
    }
    if($result->NumRows() >= $offset_increment) {
        $output->Text('<td align="right">');
        $next_link = pnModUrl('PostCalendar','admin','listhidden',array('offset'=>$offset+$offset_increment));
        $output->Text('<a href="'.$next_link.'">Next '.$offset_increment.' >></a>');
        $output->Text('</td>');
    } else {
        $output->Text('<td align="right">Next >></td>');
    }
    $output->Text('</tr></table>'); 
    }   
    $output->Text('</td></tr></table>');
    // end previous next links
    
    
    $output->FormEnd();
    
    return $output->GetOutput();

}

function PostCalendar_admin_listqueued($e='')
{
    $output = new pnHTML();
    $output->SetInputMode(_PNH_VERBATIMINPUT);
    $output->Text(PostCalendar_adminmenu());
    
    if(!empty($e)) {
        $output->Text($e);
        $output->Linebreak(2);
    }
    
    // Security check - important to do this as early as possible to avoid
    // potential security holes or just too much wasted processing
    if (!pnSecAuthAction(0, 'PostCalendar::Item', '::', ACCESS_EDIT)) {
        $output->Text(_POSTCALENDAR_NOAUTH);
        return $output->GetOutput();
    }
    
    $offset_increment = pnModGetVar('PostCalendar','listhowmanyevents');
    if(!isset($offset_increment)) $offset_increment = 15;
    
    $offset = pnVarCleanFromInput('offset');
    if(!isset($offset)) {
        $offset = 0;
    } 
    
    pnModDBInfoLoad('PostCalendar');
    list($dbconn) = pnDBGetConn();
    $pntable = pnDBGetTables();
    
    $events_table = $pntable['postcalendar_events'];
    $events_column = &$pntable['postcalendar_events_column'];
    
    pnThemeLoad(pnUserGetTheme());
    // get the theme globals :: is there a better way to do this?
    global $bgcolor1, $bgcolor2, $bgcolor3, $bgcolor4, $bgcolor5;
    global $textcolor1, $textcolor2;
    
    $sql = "SELECT $events_column[eid],
                   $events_column[title], 
                   $events_column[time] 
            FROM   $events_table
            WHERE  $events_column[eventstatus] = 0
            ORDER BY $events_column[time]
            LIMIT  $offset,$offset_increment";
            
    $result = $dbconn->Execute($sql);
    
    $output->FormStart(pnModUrl('PostCalendar','admin','adminevents'));
    
    $output->Text('<table border="0" cellpadding="1" cellspacing="0" width="100%" bgcolor="'.$bgcolor2.'"><tr><td>');
    $output->Text('<table border="0" cellpadding="5" cellspacing="0" width="100%" bgcolor="'.$bgcolor1.'"><tr><td>');
        $output->Text('<center><font size="4"><b>'._PC_QUEUED_ADMIN.'</b></font></center>');
    $output->Text('</td></tr></table>');    
    $output->Text('</td></tr></table>');
    
    $output->Linebreak();
    
    $output->Text('<table border="0" cellpadding="1" cellspacing="0" width="100%" bgcolor="'.$bgcolor2.'"><tr><td>');
    $output->Text('<table border="0" cellpadding="5" cellspacing="0" width="100%" bgcolor="'.$bgcolor1.'">');
        if($result && !$result->NumRows()) {
            $output->Text('<tr><td width="100%" bgcolor="'.$bgcolor1.'" align="center"><b>'._PC_NO_SUBMISSIONS.'</b></td></tr>');
        } else {
            $output->Text('<tr><td bgcolor="'.$bgcolor1.'" align="center"><b>'._PC_NEW_SUBMISSIONS.'</b></td></tr>');
                       
            $output->Text('<table border="0" cellpadding="2" cellspacing="0" width="100%" bgcolor="'.$bgcolor1.'">');
            $output->Text('<tr><td>select</td><td>title</td><td>timestamp<td></tr>');   
            // output the queued events
            $count=0;
            for(; !$result->EOF; $result->MoveNext()) {
                list($eid,$title,$timestamp) = $result->fields;
                $output->Text('<tr>');
                    $output->Text('<td align="center" valign="top">');
                        $output->FormCheckbox('pc_event_id[]', false, $eid);
                    $output->Text('</td>');
                    $output->Text('<td  align="left" valign="top" width="100%">');
                        $output->Text($title);
                    $output->Text('</td>');
                    $output->Text('<td  align="left" valign="top" nowrap>');
                        $output->Text($timestamp);
                    $output->Text('</td>');
                $output->Text('</tr>');
                
                $count++;
            }
            $output->Text('</table>');     
        }
    $output->Text('</td></tr></table>');
    if($result->NumRows()) {
    $output->Linebreak();
    // action to take?
    $output->Text('<table border="0" cellpadding="1" cellspacing="0" width="100%" bgcolor="'.$bgcolor2.'"><tr><td>');
    $output->Text('<table border="0" cellpadding="5" cellspacing="0" width="100%" bgcolor="'.$bgcolor1.'"><tr>');
        $output->Text('<td align="left" valign="middle">');
            $seldata[0]['id'] = _ACTION_APPROVE;
            $seldata[0]['selected'] = 0;
            $seldata[0]['name'] = _PC_ACTION_APPROVE;
            $seldata[1]['id'] = _ACTION_DELETE;
            $seldata[1]['selected'] = 0;
            $seldata[1]['name'] = _PC_ACTION_DELETE;
            //$seldata[2]['id'] = _ACTION_EDIT;
            //$seldata[2]['selected'] = 0;
            //$seldata[2]['name'] = _PC_ACTION_EDIT;
            $seldata[2]['id'] = _ACTION_VIEW;
            $seldata[2]['selected'] = 1;
            $seldata[2]['name'] = _PC_ACTION_VIEW;
            
            $output->FormSelectMultiple('action', $seldata);
            $output->FormHidden('thelist','listqueued');
            $output->FormSubmit(_PC_PERFORM_ACTION);
        $output->Text('</td>');
    $output->Text('</tr></table>');    
    $output->Text('</td></tr></table>');
    $output->Linebreak();
    
    
    // start previous next links
    $output->Text('<table border="0" cellpadding="1" cellspacing="0" width="100%" bgcolor="'.$bgcolor2.'"><tr><td>');
    $output->Text('<table border="0" cellpadding="5" cellspacing="0" width="100%" bgcolor="'.$bgcolor1.'"><tr>');
    if($offset > 1) {
        $output->Text('<td align="left">');
        $next_link = pnModUrl('PostCalendar','admin','listqueued',array('offset'=>$offset-$offset_increment));
        $output->Text('<a href="'.$next_link.'"><< Prev '.$offset_increment.'</a>');
        $output->Text('</td>');
    } else {
        $output->Text('<td align="left"><< Prev</td>');
    }
    if($result->NumRows() >= $offset_increment) {
        $output->Text('<td align="right">');
        $next_link = pnModUrl('PostCalendar','admin','listqueued',array('offset'=>$offset+$offset_increment));
        $output->Text('<a href="'.$next_link.'">Next '.$offset_increment.' >></a>');
        $output->Text('</td>');
    } else {
        $output->Text('<td align="right">Next >></td>');
    }
    $output->Text('</tr></table>'); 
    }   
    $output->Text('</td></tr></table>');
    // end previous next links
    
    $output->FormEnd();
    
    return $output->GetOutput();

}



function PostCalendar_admin_adminevents()
{
    $output = new pnHTML();
    $output->SetInputMode(_PNH_VERBATIMINPUT);
    
    if (!pnSecAuthAction(0, 'PostCalendar::Item', '::', ACCESS_ADMIN)) {
        $output->Text(_POSTCALENDAR_NOAUTH);
        return $output->GetOutput();
    }
    
    if (!pnModAPILoad('PostCalendar', 'user')) {
        $output->Text(_PC_API_LOAD_FAILED);
        return $output->GetOutput();
    }
    
    list($action,$pc_event_id,$thelist) = pnVarCleanFromInput('action','pc_event_id','thelist');
    
    if(!isset($pc_event_id)) {
        $output->SetOutputMode(_PNH_RETURNOUTPUT);
            $e  = $output->Text('<table border="0" width="100%" cellpadding="1" cellspacing="0"><tr><td bgcolor="red">');
            $e .= $output->Text('<table border="0" width="100%" cellpadding="1" cellspacing="0"><tr><td bgcolor="pink">');
            $e .= $output->Text('<center><b>'._PC_NO_EVENT_SELECTED.'</b></center>'); 
            $e .= $output->Text('</td></td></table>');
            $e .= $output->Text('</td></td></table>');
        $output->SetOutputMode(_PNH_KEEPOUTPUT);
            
        switch($thelist) {
            case 'listqueued' :
                $output->Text(PostCalendar_admin_listqueued($e));
                break;
                
            case 'listhidden' :
                $output->Text(PostCalendar_admin_listhidden($e));
                break;
                
            case 'listapproved' :
                $output->Text(PostCalendar_admin_listapproved($e));
                break;
        }
        return $output->GetOutput();     
    }
    
    // main menu
    $output->Text(PostCalendar_adminmenu());
    
    switch ($action) {
        
        case _ACTION_APPROVE :
            $output->FormStart(pnModUrl('PostCalendar','admin','approveevents'));
            $output->Text(_PC_APPROVE_ARE_YOU_SURE.' ');
            $output->FormSubmit(_PC_ADMIN_YES);
            $output->Linebreak(2);
            foreach($pc_event_id as $eid) {
                $output->Text(pnModAPIFunc('PostCalendar','user','eventDetail',array('eid'=>$eid,'nopop'=>true)));
                $output->Linebreak(2);
                $output->FormHidden('pc_eid[]',$eid);
            }
            $output->Text(_PC_APPROVE_ARE_YOU_SURE.' ');
            $output->FormSubmit(_PC_ADMIN_YES);
            $output->FormEnd();
            break;
            
        case _ACTION_EDIT :
            foreach($pc_event_id as $eid) {
                $output->Text('edit : '.$eid);
            }
            break;
            
        case _ACTION_DELETE :
            $output->FormStart(pnModUrl('PostCalendar','admin','deleteevents'));
            $output->Text(_PC_DELETE_ARE_YOU_SURE.' ');
            $output->FormSubmit(_PC_ADMIN_YES);
            $output->Linebreak(2);
            foreach($pc_event_id as $eid) {
                $output->Text(pnModAPIFunc('PostCalendar','user','eventDetail',array('eid'=>$eid,'nopop'=>true)));
                $output->Linebreak(2);
                $output->FormHidden('pc_eid[]',$eid);
            }
            $output->Text(_PC_DELETE_ARE_YOU_SURE.' ');
            $output->FormSubmit(_PC_ADMIN_YES);
            $output->FormEnd();
            
            break;
            
        case _ACTION_VIEW :
            foreach($pc_event_id as $eid) {
                $output->Text(pnModAPIFunc('PostCalendar','user','eventDetail',array('eid'=>$eid,'nopop'=>true)));
                $output->Linebreak(2);
            }
            break;
    
    }
    
    
    return $output->GetOutput();
}

function PostCalendar_admin_approveevents()
{
    $pc_eid = pnVarCleanFromInput('pc_eid');
    $output = new pnHTML();
    $output->SetInputMode(_PNH_VERBATIMINPUT);
    $output->Text(PostCalendar_adminmenu());
    $approve_list = '';
    foreach($pc_eid as $eid) {
        if(!empty($approve_list)) {
            $approve_list .= ',';
        }
        $approve_list .= $eid;
    }
    
    pnModDBInfoLoad('PostCalendar');
    list($dbconn) = pnDBGetConn();
    $pntable = pnDBGetTables();
    $events_table = $pntable['postcalendar_events'];
    $events_column = &$pntable['postcalendar_events_column'];
    
    $sql = "UPDATE $events_table
            SET $events_column[eventstatus] = "._EVENT_APPROVED."
            WHERE $events_column[eid] IN ($approve_list)";

    $dbconn->Execute($sql);
    if ($dbconn->ErrorNo() != 0) {
        $output->Text(_PC_ADMIN_EVENT_ERROR);
    } else {
        $output->Text(_PC_ADMIN_EVENTS_APPROVED);
    }
    
    return $output->GetOutput(); 
}

function PostCalendar_admin_deleteevents()
{
    $pc_eid = pnVarCleanFromInput('pc_eid');
    $output = new pnHTML();
    $output->SetInputMode(_PNH_VERBATIMINPUT);
    $output->Text(PostCalendar_adminmenu());
    $event_list = '';
    foreach($pc_eid as $eid) {
        if(!empty($event_list)) {
            $event_list .= ',';
        }
        $event_list .= $eid;
    }
    
    pnModDBInfoLoad('PostCalendar');
    list($dbconn) = pnDBGetConn();
    $pntable = pnDBGetTables();
    $events_table = $pntable['postcalendar_events'];
    $events_column = &$pntable['postcalendar_events_column'];
    
    $sql = "UPDATE $events_table
            SET $events_column[eventstatus] = "._EVENT_HIDDEN."
            WHERE $events_column[eid] IN ($event_list)";

    $dbconn->Execute($sql);
    if ($dbconn->ErrorNo() != 0) {
        $output->Text(_PC_ADMIN_EVENT_ERROR);
    } else {
        $output->Text(_PC_ADMIN_EVENTS_DELETED);
    }
    
    return $output->GetOutput(); 
}

function PostCalendar_admin_new($args)
{   
    $output = new pnHTML();
    $output->SetInputMode(_PNH_VERBATIMINPUT);
    
    // check permissions
    if (!pnSecAuthAction(0, 'PostCalendar::', '::', ACCESS_EDIT)) {
        $output->Text(_POSTCALENDARNOAUTH);
        return $output->GetOutput();
    }
    
    pnThemeLoad(pnUserGetTheme());
    // get the theme globals :: is there a better way to do this?
    global $bgcolor1, $bgcolor2, $bgcolor3, $bgcolor4, $bgcolor5;
    global $textcolor1, $textcolor2;
    
    // is this an update of an event?
    $IS_UPDATE2 = pnVarCleanFromInput('IS_UPDATE2');
    if(!isset($IS_UPDATE2)) $IS_UPDATE2 = false;
    $pc_event_id = pnVarCleanFromInput('pc_event_id');
    $uname = pnVarCleanFromInput('uname');
    if(isset($pc_event_id)) {
        $IS_UPDATE = true;
    } else {
        $IS_UPDATE = false;
    }
    
    extract($args);
    if(!isset($Date)) {
        $Date = date('m/d/Y');
    }
    list($month,$day,$year) = explode('/',$Date);
    
    // lets get the module's information
    $modinfo = pnModGetInfo(pnModGetIDFromName('PostCalendar'));
    
    $time24hours            = pnModGetVar('PostCalendar','time24hours');
    $useinternationaldates  = pnModGetVar('PostCalendar','useinternationaldates');
    $displaytopics          = pnModGetVar('PostCalendar','displaytopics');
    
    
    // categories - make this dynamic the next release!!!
    $category1 = pnModGetVar('PostCalendar','category1');
    $category2 = pnModGetVar('PostCalendar','category2');
    $category3 = pnModGetVar('PostCalendar','category3');
    $category4 = pnModGetVar('PostCalendar','category4');
    $category5 = pnModGetVar('PostCalendar','category5');
    
    if (!pnModAPILoad('PostCalendar', 'user')) {
        $output->Text(_PC_API_LOAD_FAILED);
        return $output->GetOutput();
    }

    // get DB information
    pnModDBInfoLoad('PostCalendar');
    list($dbconn) = pnDBGetConn();
    $pntable = pnDBGetTables();
    
    // link to the events tables
    $events_table = $pntable['postcalendar_events'];
    $events_column = &$pntable['postcalendar_events_column'];
    
    // main menu
    $output->Text(PostCalendar_adminmenu());
    
    // are we previewing or committing the event?
    $preview = pnVarCleanFromInput('preview') ? true : false;
    $commit  = pnVarCleanFromInput('commit') ? true : false;
    
    if(!$IS_UPDATE) {
    list($event_id,
         $event_subject,
         $event_desc,
         $event_topic,
         $event_startday,
         $event_startmonth,
         $event_startyear,
         $event_starttimeh,
         $event_starttimem,
         $event_startampm,
         $event_endday,
         $event_endmonth,
         $event_endyear,
         $event_endtimeh,
         $event_endtimem,
         $event_endampm,
         $event_location,
         $event_contname,
         $event_conttel,
         $event_contemail,
         $event_website,
         $event_fee,
         $event_recurrtype,
         $event_recurrfreq,
         $event_recurrspec,
         $event_allday,
         $event_category,
         $event_status)  = pnVarCleanFromInput('event_id',
                                               'event_subject',
                                               'event_desc',
                                               'event_topic',
                                               'event_startday',
                                               'event_startmonth',
                                               'event_startyear',
                                               'event_starttimeh',
                                               'event_starttimem',
                                               'event_startampm',
                                               'event_endday',
                                               'event_endmonth',
                                               'event_endyear',
                                               'event_endtimeh',
                                               'event_endtimem',
                                               'event_endampm',
                                               'event_location',
                                               'event_contname',
                                               'event_conttel',
                                               'event_contemail',
                                               'event_website',
                                               'event_fee',
                                               'event_recurrtype',
                                               'event_recurrfreq',
                                               'event_recurrspec',
                                               'event_allday',
                                               'event_category',
                                               'event_status');
    } else {
        $sql = "SELECT  $events_column[title],
                        $events_column[hometext],
                        $events_column[topic],
                        $events_column[informant],
                        $events_column[eventDate],
                        $events_column[endDate],
                        $events_column[recurrtype],
                        $events_column[recurrspec],
                        $events_column[recurrfreq],
                        $events_column[startTime],
                        $events_column[endTime],
                        $events_column[alldayevent],
                        $events_column[barcolor],
                        $events_column[location],
                        $events_column[conttel],
                        $events_column[contname],
                        $events_column[contemail],
                        $events_column[website],
                        $events_column[fee],
                        $events_column[eventstatus]
                FROM    $events_table
                WHERE   $events_column[eid] = $pc_event_id[0]
                LIMIT 1";
        
        $result = $dbconn->Execute($sql);
        for(; !$result->EOF; $result->MoveNext()) {
            list($event_subject,$event_desc,$event_topic,$uname,
                 $eventDate,$endDate,$event_recurrtype,$event_recurrspec,$event_recurrfreq,
                 $startTime,$endTime,$event_allday,$event_category,$event_location,$event_conttel,
                 $event_contname,$event_contemail,$event_website,$event_fee,$event_status) = $result->fields;
               
            list($event_startyear,$event_startmonth,$event_startday) = explode('-',$eventDate);
            list($event_endyear,$event_endmonth,$event_endday)       = explode('-',$endDate);
            list($event_starttimeh,$event_starttimem,$trash)         = explode(':',$startTime);
            list($event_endtimeh,$event_endtimem,$trash)             = explode(':',$endTime);
            
            $event_id = $pc_event_id[0];
                 
             if(!$time24hours) {
                $event_startampm    = $event_starttimeh < 12 ? _AM_VAL : _PM_VAL;
                $event_endampm      = $event_endtimeh   < 12 ? _AM_VAL : _PM_VAL;
             }
        }
        
    }
    if(!isset($uname)) {  
        if (pnUserLoggedIn()) {
            $uname = pnUserGetVar('uname');
        } else {
            $uname = pnConfigGetVar('anonymous');
        }
    }
    if(!isset($event_recurrtype)) {
        $event_recurrtype = -1;
    }
    $output->FormStart(pnModUrl('PostCalendar','admin','new'));
    $output->tabindex=1;
    if($preview) {
        // check for required
        $required_vars = array('event_subject','event_desc');
        $required_name = array(_PC_EVENT_TITLE,_PC_EVENT_DESC);
        $error_msg = '';
        $output->SetOutputMode(_PNH_RETURNOUTPUT);
        for ($r=0; $r<count($required_vars); $r++) {
            if(empty($$required_vars[$r]) || !preg_match('/\S/i',$$required_vars[$r])) {
                $error_msg .= $output->Text('<b>'.$required_name[$r].'</b> is a required field.');
                $error_msg .= $output->Linebreak(); 
            }
        }
        if($time24hours) {
            $startTime = $event_starttimeh.':'.$event_starttimem;
            $endTime =   $event_endtimeh.':'.$event_endtimem;
        } else {
            if($event_startampm == _AM_VAL) {
                $event_starttimeh = $event_starttimeh == 12 ? '00' : $event_starttimeh;
            } else {
                $event_starttimeh =  $event_starttimeh != 12 ? $event_starttimeh+=12 : $event_starttimeh;
            }
            if($event_endampm == _AM_VAL) {
                $event_endtimeh = $event_endtimeh == 12 ? '00' : $event_endtimeh;
            } else {
                $event_endtimeh =  $event_endtimeh != 12 ? $event_endtimeh+=12 : $event_endtimeh;
            }
            $startTime = $event_starttimeh.':'.$event_starttimem;
            $endTime =   $event_endtimeh.':'.$event_endtimem;
        }
        $sdate = strtotime($event_startyear.'-'.$event_startmonth.'-'.$event_startday.' '.$startTime);
        $edate = strtotime($event_endyear.'-'.$event_endmonth.'-'.$event_endday.' '.$endTime);
        
        // *** removed so it is editable *** //
        //$tdate = strtotime(date('Y-m-d'));
        //if($sdate < $tdate) {
        //    $error_msg .= $output->Text('Your start date is prior to today\'s date');
        //    $error_msg .= $output->Linebreak(); 
        //}
        
        if($edate < $sdate) {
            $error_msg .= $output->Text('Your start date is greater that your end date');
            $error_msg .= $output->Linebreak(); 
        }
        if(!checkdate($event_startmonth,$event_startday,$event_startyear)) {
            $error_msg .= $output->Text('Your start date is invalid');
            $error_msg .= $output->Linebreak(); 
        }
        if(!checkdate($event_endmonth,$event_endday,$event_endyear)) {
            $error_msg .= $output->Text('Your end date is invalid'); 
            $error_msg .= $output->Linebreak();
        }
        
        $output->SetOutputMode(_PNH_KEEPOUTPUT);
        if(!empty($error_msg)) {
            $preview = false;
            $output->Text('<table border="0" width="100%" cellpadding="1" cellspacing="0"><tr><td bgcolor="red">');
            $output->Text('<table border="0" width="100%" cellpadding="1" cellspacing="0"><tr><td bgcolor="pink">');
                $output->Text('<center><b>There are errors with your submission.  These are outlined below.</b></center>'); 
                $output->Linebreak();
                $output->Text($error_msg);
            $output->Text('</td></td></table>');
            $output->Text('</td></td></table>');
            $output->Linebreak(2);
        } else {
            $output->Text(pnModAPIFunc('PostCalendar','user','eventPreview',array('event_subject'=>$event_subject,
                                                                                  'event_desc'=>$event_desc,
                                                                                  'event_topic'=>$event_topic,
                                                                                  'event_startday'=>$event_startday,
                                                                                  'event_startmonth'=>$event_startmonth,
                                                                                  'event_startyear'=>$event_startyear,
                                                                                  'event_starttimeh'=>$event_starttimeh,
                                                                                  'event_starttimem'=>$event_starttimem,
                                                                                  'event_startampm'=>$event_startampm,
                                                                                  'event_endday'=>$event_endday,
                                                                                  'event_endmonth'=>$event_endmonth,
                                                                                  'event_endyear'=>$event_endyear,
                                                                                  'event_endtimeh'=>$event_endtimeh,
                                                                                  'event_endtimem'=>$event_endtimem,
                                                                                  'event_endampm'=>$event_endampm,
                                                                                  'event_location'=>$event_location,
                                                                                  'event_contname'=>$event_contname,
                                                                                  'event_conttel'=>$event_conttel,
                                                                                  'event_contemail'=>$event_contemail,
                                                                                  'event_website'=>$event_website,
                                                                                  'event_fee'=>$event_fee,
                                                                                  'event_recurrtype'=>$event_recurrtype,
                                                                                  'event_recurrfreq'=>$event_recurrfreq,
                                                                                  'event_recurrspec'=>$event_recurrspec,
                                                                                  'event_allday'=>$event_allday,
                                                                                  'event_category'=>$event_category,
                                                                                  'uname'=>$uname)));
            $output->Linebreak();
            $output->Text('<input type="submit" name="commit" value="'._PC_EVENT_SUBMIT.'">');
            $output->Linebreak(2);
        }
    }
    
    if($commit) {
               
        // set up some vars for the insert statement
        $startDate = $event_startyear.'-'.$event_startmonth.'-'.$event_startday;
        $endDate =   $event_endyear.'-'.$event_endmonth.'-'.$event_endday;
        
        if(!isset($event_allday)) { $event_allday = 0; }
        if($time24hours) {
            $startTime = $event_starttimeh.':'.$event_starttimem.':00';
            $endTime =   $event_endtimeh.':'.$event_endtimem.':00';
        } else {
            if($event_startampm == _AM_VAL) {
                $event_starttimeh = $event_starttimeh == 12 ? '00' : $event_starttimeh;
            } else {
                $event_starttimeh = $event_starttimeh != 12 ? $event_starttimeh+=12 : $event_starttimeh;
            }
            $startTime = $event_starttimeh.':'.$event_starttimem.':00';
            if($event_endampm == _AM_VAL) {
                $event_endtimeh = $event_endtimeh == 12 ? '00' : $event_endtimeh;
            } else {
                $event_endtimeh =  $event_endtimeh != 12 ? $event_endtimeh+=12 : $event_endtimeh;
            }
            $endTime =   $event_endtimeh.':'.$event_endtimem.':00';
        }
        
        // prepare the vars for the insert statement        
        list($pevent_subject,$pevent_desc,$pevent_topic,
             $puname,$pstartDate,$pendDate,$pevent_recurrtype,
             $pevent_recurrfreq,$pstartTime,$pendTime,$pevent_allday,
             $pevent_location,$pevent_conttel,
             $pevent_contname,$pevent_contemail,$pevent_website,
             $pevent_fee,$pevent_status,$pevent_category) = pnVarPrepForStore($event_subject,$event_desc,$event_topic,
                                                                $uname,$startDate,$endDate,$event_recurrtype,
                                                                $event_recurrfreq,$startTime,$endTime,$event_allday,
                                                                $event_location,$event_conttel,
                                                                $event_contname,$event_contemail,$event_website,
                                                                $event_fee,$event_status,$event_category);
        
        if(!$IS_UPDATE2) {
        $sql = "INSERT INTO $events_table (
                    $events_column[title],
                    $events_column[time],
                    $events_column[hometext],
                    $events_column[topic],
                    $events_column[informant],
                    $events_column[eventDate],
                    $events_column[endDate],
                    $events_column[recurrtype],
                    $events_column[recurrfreq],
                    $events_column[startTime],
                    $events_column[endTime],
                    $events_column[alldayevent],
                    $events_column[barcolor],
                    $events_column[location],
                    $events_column[conttel],
                    $events_column[contname],
                    $events_column[contemail],
                    $events_column[website],
                    $events_column[fee],
                    $events_column[eventstatus])
                VALUES ('$pevent_subject', 
                        NOW(),
                        '$pevent_desc',
                         $pevent_topic,
                        '$puname',
                        '$pstartDate',
                        '$pendDate',
                         $pevent_recurrtype,
                         $pevent_recurrfreq,
                        '$pstartTime',
                        '$pendTime',
                         $pevent_allday,
                        '$pevent_category',
                        '$pevent_location',
                        '$pevent_conttel',
                        '$pevent_contname',
                        '$pevent_contemail',
                        '$pevent_website',
                        '$pevent_fee',
                         $pevent_status)";
        } else {
            $sql = "UPDATE $events_table SET
                    $events_column[title]       = '$pevent_subject',
                    $events_column[time]        = NOW(),
                    $events_column[hometext]    = '$pevent_desc',
                    $events_column[topic]       = $pevent_topic,
                    $events_column[informant]   = '$puname',
                    $events_column[eventDate]   = '$pstartDate',
                    $events_column[endDate]     = '$pendDate',
                    $events_column[recurrtype]  = $pevent_recurrtype,
                    $events_column[recurrfreq]  = $pevent_recurrfreq,
                    $events_column[startTime]   = '$pstartTime',
                    $events_column[endTime]     = '$pendTime',
                    $events_column[alldayevent] = $pevent_allday,
                    $events_column[barcolor]    = '$pevent_category',
                    $events_column[location]    = '$pevent_location',
                    $events_column[conttel]     = '$pevent_conttel',
                    $events_column[contname]    = '$pevent_contname',
                    $events_column[contemail]   = '$pevent_contemail',
                    $events_column[website]     = '$pevent_website',
                    $events_column[fee]         = '$pevent_fee',
                    $events_column[eventstatus] = $pevent_status
                    WHERE $events_column[eid]  = $event_id";
        }
        //$output->Text($sql);
        
        $dbconn->Execute($sql);
        if ($dbconn->ErrorNo() != 0) {
            $output->Text(_PC_EVENT_SUBMISSION_FAILED);
            $output->Linebreak(2);
        } else {
            $output->Text(_PC_EVENT_SUBMISSION_SUCCESS);
            $output->Linebreak(2);
            // clear the sql prepared vars 
            unset($pevent_subject,$pevent_desc,$pevent_topic,
                  $puname,$pstartDate,$pendDate,$pevent_recurrtype,
                  $pevent_recurrfreq,$pstartTime,$pendTime,$pevent_allday,
                  $pevent_barcolor,$pevent_location,$pevent_conttel,
                  $pevent_contname,$pevent_contemail,$pevent_website,
                  $pevent_fee,$pevent_status,$pevent_category);
            // clear the form vars
            $event_subject=$event_desc=$event_topic=
            $uname=$event_startday=$event_startmonth=$event_startyear=
            $event_endday=$event_endmonth=$event_endyear=$event_recurrtype=
            $event_recurrfreq=$event_starttimeh=$event_starttimem=$event_startampm=
            $event_endtimeh=$event_endtimem=$event_allday=$event_endampm=
            $event_barcolor=$event_location=$event_conttel=
            $event_contname=$event_contemail=$event_website=
            $event_fee=$event_status=$event_category = null;
        }
             
    }
    
    if(!$IS_UPDATE && !$IS_UPDATE2) {    
        $output->Text('<center>'._PC_SUBMISSION_FORM.'</center>');
    } else {
        $output->Text('<center>'._PC_UPDATE_FORM.'</center>');
    }
    
    $output->Linebreak(2);
    $output->Text(_PC_INTRO);
    $output->Linebreak(2);
    $output->Text(_PC_DISCLAIMER);
    $output->Linebreak(2);
    
    if(!$IS_UPDATE && !$IS_UPDATE2) {
        $output->Text('<font class="pn-normal"><b>'._PC_YOURNAME.':</b> ');
        $output->Text('<a class="pn-normal" href="user.php">' . $uname . '</a>');
        $output->Text(' [ <a class="pn-normal" href="user.php?module=NS-User&op=logout">' . _PC_LOGOUT . '</a> ]');
    } else {
        $output->Text('<font class="pn-normal"><b>'._PC_SUBMITTED_BY.':</b> ');
        $output->Text($uname);
    }
    $output->Linebreak(2);
    
    $output->TableStart(null,null,0,null);
        $output->TableRowStart();
            $output->TableColStart(1,'left');    
            $output->BoldText(_PC_EVENT_STATUS);
            $output->TableColEnd();
        $output->TableRowEnd();
        
        $output->TableRowStart();
            $output->TableColStart(1,'left');
            
            $output->FormCheckbox('event_status', $event_status == _EVENT_QUEUED, _EVENT_QUEUED, 'radio');
            $output->Text(_PC_EVENT_STATUS_QUEUED);
            
            $output->FormCheckbox('event_status', $event_status == _EVENT_APPROVED, _EVENT_APPROVED, 'radio');
            $output->Text(_PC_EVENT_STATUS_APPROVED);
            
            $output->FormCheckbox('event_status', $event_status == _EVENT_HIDDEN, _EVENT_HIDDEN, 'radio');
            $output->Text(_PC_EVENT_STATUS_HIDDEN);
            $output->Linebreak(2);
            
            $output->TableColEnd();
        $output->TableRowEnd();
    $output->TableEnd();
    
    $output->Text('<b>'._PC_EVENT_TITLE.'</b> ('._PC_BE_DESCRIPTIVE.')');
    $output->Text(' '._PC_REQUIRED);
    $output->Linebreak();
    // subject (title)
    $output->FormText('event_subject', $event_subject, 50, 80);
    $output->Linebreak();
    $output->Text('<font class="pn-normal">('._PC_BADTITLES.')</font>');
    $output->Linebreak(2);
    $output->BoldText(_PC_EVENT_DESC);
    $output->Text(' '._PC_REQUIRED);
    $output->Linebreak();
    $output->FormTextArea('event_desc', $event_desc, 6, 50);
    $output->Linebreak(2);
    
    if($displaytopics) {
        // topic select
        $output->BoldText(_PC_TOPIC.' ');
    
        $topics_table = $pntable['topics'];
        $topics_column = &$pntable['topics_column'];
        $sql = "SELECT $topics_column[topicid], $topics_column[topictext], $topics_column[topicname]
                FROM $topics_table
                ORDER BY $topics_column[topictext]";
        $topiclist = $dbconn->Execute($sql);
    
        $topic_count = 0;
        $topic_data = array();
        while(list($topicid,$topictext,$topicname) = $topiclist->fields) {
            if (pnSecAuthAction(0, 'Topics::Topic', "$topicname::$topicid", ACCESS_COMMENT)) {
	            $selected = $event_topic == $topicid ? true : false;
                $topic_data[$topic_count]['id']         = pnVarPrepForStore($topicid);
                $topic_data[$topic_count]['selected']   = $selected;
                $topic_data[$topic_count]['name']       = pnVarPrepForDisplay($topictext);
            }
            $topic_count++;
            $topiclist->MoveNext();
        }
        $output->FormSelectMultiple('event_topic', $topic_data);
        $output->Linebreak(2);
    } else {
        if(!isset($topicid)) $topicid=1;
        $output->FormHidden('event_topic',$topicid);
    }
    
    $stimes = pnModAPIFunc('PostCalendar','user','buildTimeSelect',array('hselected'=>$event_starttimeh,'mselected'=>$event_starttimem));
    $etimes = pnModAPIFunc('PostCalendar','user','buildTimeSelect',array('hselected'=>$event_endtimeh,'mselected'=>$event_endtimem));
    
    $output->TableStart(null,null,0,null);
        $output->TableRowStart();
            $output->TableColStart(5,'left');
            $output->FormCheckbox('event_allday', $event_allday, '1');
            $output->BoldText(_PC_EVENT_ALLDAY);
            $output->Linebreak(2);
            $output->TableColEnd();
        $output->TableRowEnd();
            
        $output->TableRowStart();
        
            $output->TableColStart(1,'right');
                $output->BoldText(_PC_EVENT_BEGINS);
            $output->TableColEnd();
            $output->TableColStart(1,'left');
            // start date
            if($useinternationaldates) {
                $sel_data = pnModAPIFunc('PostCalendar','user','buildDaySelect',array('pc_day'=>$day,'selected'=>$event_startday));
                $output->FormSelectMultiple('event_startday', $sel_data);
                $sel_data = pnModAPIFunc('PostCalendar','user','buildMonthSelect',array('pc_month'=>$month,'selected'=>$event_startmonth));
                $output->FormSelectMultiple('event_startmonth', $sel_data);
             } else {
                $sel_data = pnModAPIFunc('PostCalendar','user','buildMonthSelect',array('pc_month'=>$month,'selected'=>$event_startmonth));
                $output->FormSelectMultiple('event_startmonth', $sel_data);
                $sel_data = pnModAPIFunc('PostCalendar','user','buildDaySelect',array('pc_day'=>$day,'selected'=>$event_startday));
                $output->FormSelectMultiple('event_startday', $sel_data);
            }
                $sel_data = pnModAPIFunc('PostCalendar','user','buildYearSelect',array('pc_year'=>$year,'selected'=>$event_startyear));
                $output->FormSelectMultiple('event_startyear', $sel_data);   
                
            $output->TableColEnd();
            $output->TableColStart(1,'left');
                $output->BoldText(_PC_EVENT_AT);
            $output->TableColEnd();
            $output->TableColStart();
                $output->FormSelectMultiple('event_starttimeh', $stimes['h']);
                $output->Text(' : ');
                $output->FormSelectMultiple('event_starttimem', $stimes['m']);
            $output->TableColEnd();
            
            if(!$time24hours) {
                $output->TableColStart(1,'left');
                $output->Text(' ');
                $ampm = array();
                
                $ampm[0]['id']          = pnVarPrepForStore(_AM_VAL);
                $ampm[0]['selected']    = $event_startampm == _AM_VAL;
                $ampm[0]['name']        = pnVarPrepForDisplay(_PC_AM);
                
                $ampm[1]['id']          = pnVarPrepForStore(_PM_VAL);
                $ampm[1]['selected']    = $event_startampm == _PM_VAL;
                $ampm[1]['name']        = pnVarPrepForDisplay(_PC_PM);
                $output->FormSelectMultiple('event_startampm', $ampm);
            $output->TableColEnd();
            }
            
        $output->TableRowEnd();
        
        $output->TableRowStart();
            $output->TableColStart(1,'right');
                $output->BoldText(_PC_EVENT_ENDS);
            $output->TableColEnd();
            $output->TableColStart(1,'left');
            // end date
            if($useinternationaldates) {
                $sel_data = pnModAPIFunc('PostCalendar','user','buildDaySelect',array('pc_day'=>$day,'selected'=>$event_endday));
                $output->FormSelectMultiple('event_endday', $sel_data);
                $sel_data = pnModAPIFunc('PostCalendar','user','buildMonthSelect',array('pc_month'=>$month,'selected'=>$event_endmonth));
                $output->FormSelectMultiple('event_endmonth', $sel_data);
            } else {
                $sel_data = pnModAPIFunc('PostCalendar','user','buildMonthSelect',array('pc_month'=>$month,'selected'=>$event_endmonth));
                $output->FormSelectMultiple('event_endmonth', $sel_data);
                $sel_data = pnModAPIFunc('PostCalendar','user','buildDaySelect',array('pc_day'=>$day,'selected'=>$event_endday));
                $output->FormSelectMultiple('event_endday', $sel_data);
            }
                $sel_data = pnModAPIFunc('PostCalendar','user','buildYearSelect',array('pc_year'=>$year,'selected'=>$event_endyear));
                $output->FormSelectMultiple('event_endyear', $sel_data);
            
            $output->TableColEnd();
            $output->TableColStart(1,'left');
                $output->BoldText(_PC_EVENT_AT);
            $output->TableColEnd();
            $output->TableColStart(1,'left');
                $output->FormSelectMultiple('event_endtimeh', $etimes['h']);
                $output->Text(' : ');
                $output->FormSelectMultiple('event_endtimem', $etimes['m']);
            $output->TableColEnd();
            
            if(!$time24hours) {
                $output->TableColStart(1,'left');
                $output->Text(' ');
                $ampm = array();
                $ampm[0]['id']          = pnVarPrepForStore(1);
                $ampm[0]['selected']    = $event_endampm == 1;
                $ampm[0]['name']        = pnVarPrepForDisplay(_PC_AM);
                $ampm[1]['id']          = pnVarPrepForStore(2);
                $ampm[1]['selected']    = $event_endampm == 2;
                $ampm[1]['name']        = pnVarPrepForDisplay(_PC_PM);
                $output->FormSelectMultiple('event_endampm', $ampm);
            $output->TableColEnd();
            }
        $output->TableRowEnd();
        
    $output->TableEnd();

    $output->TableStart(null,null,0,null);
        $output->TableRowStart();
            $output->TableColStart(5,'left');
                $output->BoldText(_PC_EVENT_CATEGORY);
            $output->TableColEnd();
        $output->TableRowEnd();
        $output->TableRowStart();
            $output->TableColStart(1,'left');
            $moddir = pnVarPrepForOS($modinfo['directory']);
            $output->TableStart();
                $output->SetOutputMode(_PNH_RETURNOUTPUT);
                
                $row[0]['content']  = $output->FormCheckbox('event_category',$event_category=='r','r','radio');
                $row[0]['align']    = 'left';
                $row[0]['valign']   = 'middle';
                $row[1]['content']  = '<img src="modules/'.$moddir.'/pnimages/ballr.gif"> '.$category1;
                $row[1]['align']    = 'left';
                $row[1]['valign']   = 'middle';
                
                $output->SetOutputMode(_PNH_KEEPOUTPUT);
                $output->TableAddRow($row);
                
                $output->SetOutputMode(_PNH_RETURNOUTPUT);
                
                $row[0]['content']  = $output->FormCheckbox('event_category',$event_category=='g','g','radio');
                $row[0]['align']    = 'left';
                $row[0]['valign']   = 'middle';
                $row[1]['content']  = '<img src="modules/'.$moddir.'/pnimages/ballg.gif"> '.$category2;
                $row[1]['align']    = 'left';
                $row[1]['valign']   = 'middle';
                
                $output->SetOutputMode(_PNH_KEEPOUTPUT);
                $output->TableAddRow($row);
                
                $output->SetOutputMode(_PNH_RETURNOUTPUT);
                
                $row[0]['content']  = $output->FormCheckbox('event_category',$event_category=='b','b','radio');
                $row[0]['align']    = 'left';
                $row[0]['valign']   = 'middle';
                $row[1]['content']  = '<img src="modules/'.$moddir.'/pnimages/ballb.gif"> '.$category3;
                $row[1]['align']    = 'left';
                $row[1]['valign']   = 'middle';
                
                $output->SetOutputMode(_PNH_KEEPOUTPUT);
                $output->TableAddRow($row);
                
                $output->SetOutputMode(_PNH_RETURNOUTPUT);
                
                $row[0]['content']  = $output->FormCheckbox('event_category',$event_category=='w','w','radio');
                $row[0]['align']    = 'left';
                $row[0]['valign']   = 'middle';
                $row[1]['content']  = '<img src="modules/'.$moddir.'/pnimages/ballw.gif"> '.$category4;
                $row[1]['align']    = 'left';
                $row[1]['valign']   = 'middle';
                $output->SetOutputMode(_PNH_KEEPOUTPUT);
                $output->TableAddRow($row);
                
                $output->SetOutputMode(_PNH_RETURNOUTPUT);
                
                $row[0]['content']  = $output->FormCheckbox('event_category',$event_category=='y','y','radio');
                $row[0]['align']    = 'left';
                $row[0]['valign']   = 'middle';
                $row[1]['content']  = '<img src="modules/'.$moddir.'/pnimages/bally.gif"> '.$category5;
                $row[1]['align']    = 'left';
                $row[1]['valign']   = 'middle';
                $output->SetOutputMode(_PNH_KEEPOUTPUT);
                $output->TableAddRow($row);  
            $output->TableEnd();
            
            $output->TableColEnd();
        $output->TableRowEnd();
    $output->TableEnd();

    $output->TableStart(null,null,0,null);
        $output->TableRowStart();
            $output->TableColStart(1,'left');
            $output->BoldText(_PC_EVENT_RECURRTYPE);
            $output->Linebreak();
            
            $output->FormCheckbox('event_recurrtype', $event_recurrtype<0, '-1', 'radio');
            $output->Text(_PC_EVENT_RECURRTYPE_NONE);
            
            $output->Linebreak();
            
            $output->FormCheckbox('event_recurrtype', $event_recurrtype==0, '0', 'radio');
            $output->Text(_PC_EVENT_RECURRTYPE_DAILY);
            
            $output->Linebreak();
            
            $output->FormCheckbox('event_recurrtype', $event_recurrtype==1, '1', 'radio');
            $output->Text(_PC_EVENT_RECURRTYPE_WEEKLY);
                        
            $output->Linebreak();
            
            $output->FormCheckbox('event_recurrtype', $event_recurrtype==2, '2', 'radio');
            $output->Text(_PC_EVENT_RECURRTYPE_MONTHLY);
            
            $output->Linebreak();
            
            $output->FormCheckbox('event_recurrtype', $event_recurrtype==3, '3', 'radio');
            $output->Text(_PC_EVENT_RECURRTYPE_YEARLY);
            
            $output->Linebreak(2);
            $output->TableColEnd();
        $output->TableRowEnd();
        
        $output->TableRowStart();
            $output->TableColStart(1,'left');
            $output->BoldText(_PC_EVENT_RECURRFREQ);
            $output->Linebreak();
            
            $output->FormCheckbox('event_recurrfreq', $event_recurrfreq==0, '0', 'radio');
            $output->Text(_PC_EVENT_RECURRFREQ_DAY);
            
            $output->Linebreak();
            
            $output->FormCheckbox('event_recurrfreq', $event_recurrfreq==1, '1', 'radio');
            $output->Text(_PC_EVENT_RECURRFREQ_DATE);
            
            $output->Linebreak(2);
            $output->TableColEnd();
        $output->TableRowEnd();
    $output->TableEnd();
    
    $output->TableStart(null,null,0,null);
        $output->TableRowStart();
            $output->TableColStart(1,'left');
            
            $output->TableStart();
                $output->SetOutputMode(_PNH_RETURNOUTPUT);
                $row[0]['content']  = _PC_EVENT_LOCATION.' : ';
                $row[0]['align']    = 'right';
                $row[0]['valign']   = 'middle';
                $row[1]['content']  = $output->FormText('event_location',$event_location,50,80);
                $row[1]['align']    = 'left';
                $row[1]['valign']   = 'middle';
                $output->SetOutputMode(_PNH_KEEPOUTPUT);
                $output->TableAddRow($row);
                
                $output->SetOutputMode(_PNH_RETURNOUTPUT);
                $row[0]['content']  = _PC_EVENT_CONTNAME.' : ';
                $row[0]['align']    = 'right';
                $row[0]['valign']   = 'middle';
                $row[1]['content']  = $output->FormText('event_contname',$event_contname,50,80);
                $row[1]['align']    = 'left';
                $row[1]['valign']   = 'middle';
                $output->SetOutputMode(_PNH_KEEPOUTPUT);
                $output->TableAddRow($row);
                
                $output->SetOutputMode(_PNH_RETURNOUTPUT);
                $row[0]['content']  = _PC_EVENT_CONTTEL.' : ';
                $row[0]['align']    = 'right';
                $row[0]['valign']   = 'middle';
                $row[1]['content']  = $output->FormText('event_conttel',$event_conttel,50,80);
                $row[1]['align']    = 'left';
                $row[1]['valign']   = 'middle';
                $output->SetOutputMode(_PNH_KEEPOUTPUT);
                $output->TableAddRow($row);
                
                $output->SetOutputMode(_PNH_RETURNOUTPUT);
                $row[0]['content']  = _PC_EVENT_CONTEMAIL.' : ';
                $row[0]['align']    = 'right';
                $row[0]['valign']   = 'middle';
                $row[1]['content']  = $output->FormText('event_contemail',$event_contemail,50,80);
                $row[1]['align']    = 'left';
                $row[1]['valign']   = 'middle';
                $output->SetOutputMode(_PNH_KEEPOUTPUT);
                $output->TableAddRow($row);
                
                $output->SetOutputMode(_PNH_RETURNOUTPUT);
                $row[0]['content']  = _PC_EVENT_WEBSITE.' : ';
                $row[0]['align']    = 'right';
                $row[0]['valign']   = 'middle';
                $row[1]['content']  = $output->FormText('event_website',$event_website,50,80);
                $row[1]['align']    = 'left';
                $row[1]['valign']   = 'middle';
                $output->SetOutputMode(_PNH_KEEPOUTPUT);
                $output->TableAddRow($row);  
                
                $output->SetOutputMode(_PNH_RETURNOUTPUT);
                $row[0]['content']  = _PC_EVENT_FEE.' : ';
                $row[0]['align']    = 'right';
                $row[0]['valign']   = 'middle';
                $row[1]['content']  = $output->FormText('event_fee',$event_fee,50,80);
                $row[1]['align']    = 'left';
                $row[1]['valign']   = 'middle';
                $output->SetOutputMode(_PNH_KEEPOUTPUT);
                $output->TableAddRow($row);  
            $output->TableEnd();
            
            $output->TableColEnd();
        $output->TableRowEnd();
    $output->TableEnd();
    
    $output->Text('<input type="submit" tabindex="'.$output->tabindex++.'" name="preview" value="'._PC_EVENT_PREVIEW.'">');
    if($preview) {
        $output->Text('<input type="submit" tabindex="'.$output->tabindex++.'" name="commit" value="'._PC_EVENT_SUBMIT.'">');
    }
    if($IS_UPDATE || $IS_UPDATE2) {
        $output->FormHidden('IS_UPDATE2',1);
        $output->FormHidden('event_id',$event_id);
        $output->FormHidden('uname',$uname);
    }
    $output->FormEnd();
    
    return $output->GetOutput();
}

function PostCalendar_admin_modifyconfig()
{   
    $output = new pnHTML();

    if (!pnSecAuthAction(0, 'PostCalendar::Item', '::', ACCESS_ADD)) {
        $output->Text(_PostCalendarNOAUTH);
        return $output->GetOutput();
    }

    $output->SetInputMode(_PNH_VERBATIMINPUT);
    $output->Text(PostCalendar_adminmenu());
    
    $output->FormStart(pnModUrl('PostCalendar','admin','updateconfig'));
    $output->Text('<table border="0" cellpadding="0" cellspacing="5">');
    
    $settings = array();
    $output->SetOutputMode(_PNH_RETURNOUTPUT);
    $i=0;
    
    // global PostCalendar config options
    $settings[$i][] = $output->Text(_PC_ALLOW_DIRECT_SUBMIT);
    $settings[$i++][] = $output->FormCheckBox('allowdirectsubmit', pnModGetVar('PostCalendar','allowdirectsubmit'));
    
    $settings[$i][] = $output->Text(_PC_LIST_HOW_MANY);
    $settings[$i++][] = $output->FormText('listhowmanyevents', pnModGetVar('PostCalendar','listhowmanyevents'),5);
    
    $settings[$i][] = $output->Text(_PC_TIME24HOURS);
    $settings[$i++][] = $output->FormCheckBox('time24hours', pnModGetVar('PostCalendar','time24hours'));
    
    $settings[$i][] = $output->Text(_PC_EVENTS_IN_NEW_WINDOW);
    $settings[$i++][] = $output->FormCheckBox('eventsopeninnewwindow', pnModGetVar('PostCalendar','eventsopeninnewwindow'));
    
    $settings[$i][] = $output->Text(_PC_INTERNATIONAL_DATES);
    $settings[$i++][] = $output->FormCheckBox('useinternationaldates', pnModGetVar('PostCalendar','useinternationaldates'));
    
    $settings[$i][] = $output->Text(_PC_DISPLAY_TOPICS);
    $settings[$i++][] = $output->FormCheckBox('displaytopics', pnModGetVar('PostCalendar','displaytopics'));

    $settings[$i][] = $output->Text(_PC_FIRST_DAY_OF_WEEK);
        $options = array();
        $selected = pnModGetVar('PostCalendar','firstdayofweek');
        $options[0]['id']       = '0';
        $options[0]['selected'] = ($selected == 0);
        $options[0]['name']     = _PC_SUNDAY;
        $options[1]['id']       = '1';
        $options[1]['selected'] = ($selected == 1);
        $options[1]['name']     = _PC_MONDAY;
        $options[2]['id']       = '2';
        $options[2]['selected'] = ($selected == 2);
        $options[2]['name']     = _PC_SATURDAY;
    $settings[$i++][] = $output->FormSelectMultiple('firstdayofweek', $options);
    
    $settings[$i][] = $output->Text(_PC_DAY_HIGHLIGHT_COLOR);
    $settings[$i++][] = $output->FormText('dayhighlightcolor', pnModGetVar('PostCalendar','dayhighlightcolor'));
    
    // categories
    
    $settings[$i][] = $output->Text(_PC_CATEGORY_ONE);
    $settings[$i++][] = $output->FormText('category1', pnModGetVar('PostCalendar','category1'));
    
    $settings[$i][] = $output->Text(_PC_CATEGORY_TWO);
    $settings[$i++][] = $output->FormText('category2', pnModGetVar('PostCalendar','category2'));
    
    $settings[$i][] = $output->Text(_PC_CATEGORY_THREE);
    $settings[$i++][] = $output->FormText('category3', pnModGetVar('PostCalendar','category3'));
    
    $settings[$i][] = $output->Text(_PC_CATEGORY_FOUR);
    $settings[$i++][] = $output->FormText('category4', pnModGetVar('PostCalendar','category4'));
    
    $settings[$i][] = $output->Text(_PC_CATEGORY_FIVE);
    $settings[$i++][] = $output->FormText('category5', pnModGetVar('PostCalendar','category5'));
    
    $settings[$i][] = $output->Text(_PC_DISPLAY_BALLS);
    $settings[$i++][] = $output->FormCheckBox('displayballs', pnModGetVar('PostCalendar','displayballs'));
    
    $settings[$i][] = $output->Text(_PC_SHOW_TIME_ON_EVENTS);
    $settings[$i++][] = $output->FormCheckBox('showtimeonevents', pnModGetVar('PostCalendar','showtimeonevents'));
    
    $settings[$i][] = $output->Text(_PC_USE_JS_POPUPS);
    $settings[$i++][] = $output->FormCheckBox('usepopups', pnModGetVar('PostCalendar','usepopups'));
        
    // day view settings
    $settings[$i][] = $output->Text(_PC_DO_APPOINTMENTS);
    $settings[$i++][] = $output->FormCheckBox('doappointments', pnModGetVar('PostCalendar','doappointments'));
    
    $settings[$i][] = $output->Text(_PC_TIMES);
    $settings[$i++][] = $output->FormCheckBox('times', pnModGetVar('PostCalendar','times'));
    
    // month view settings
    $settings[$i][] = $output->Text(_PC_MONTH_TABLE_BORDER);
    $settings[$i++][] = $output->FormText('monthtableborder', pnModGetVar('PostCalendar','monthtableborder'),5);
    
    $settings[$i][] = $output->Text(_PC_MONTH_TABLE_CELL_PADDING);
    $settings[$i++][] = $output->FormText('monthtablecellspacing', pnModGetVar('PostCalendar','monthtablecellspacing'),5);
    
    $settings[$i][] = $output->Text(_PC_MONTH_TABLE_CELL_SPACING);
    $settings[$i++][] = $output->FormText('monthtablecellpadding', pnModGetVar('PostCalendar','monthtablecellpadding'),5);
    
    // year view settings
    $settings[$i][] = $output->Text(_PC_YEAR_TABLE_BORDER);
    $settings[$i++][] = $output->FormText('yeartableborder', pnModGetVar('PostCalendar','yeartableborder'),5);
    
    $settings[$i][] = $output->Text(_PC_YEAR_TABLE_CELL_SPACING);
    $settings[$i++][] = $output->FormText('yeartablecellspacing', pnModGetVar('PostCalendar','yeartablecellspacing'),5);
    
    $settings[$i][] = $output->Text(_PC_YEAR_TABLE_CELL_PADDING);
    $settings[$i++][] = $output->FormText('yeartablecellpadding', pnModGetVar('PostCalendar','yeartablecellpadding'),5);
    
    $settings[$i][] = $output->Text(_PC_SHOW_EVENTS_IN_YEAR);
    $settings[$i++][] = $output->FormCheckBox('showeventsinyear', pnModGetVar('PostCalendar','showeventsinyear'));
    
    $settings[$i][] = $output->Text(_PC_NUM_COLS_IN_YEAR_VIEW);
    $settings[$i++][] = $output->FormText('numcolsinyearview', pnModGetVar('PostCalendar','numcolsinyearview'),5);
    
    $output->SetOutputMode(_PNH_KEEPOUTPUT);
    
    // Add row
    for($i = 0 ; $i < count($settings) ; $i++) {
        $output->TableAddRow($settings[$i], 'left');
    }
    
    $output->Text('</table>');
    $output->FormSubmit(_PC_ADMIN_SUBMIT);
    $output->FormEnd();
    
    return $output->GetOutput();
}

function PostCalendar_admin_updateconfig()
{
    $output = new pnHTML();

    if (!pnSecAuthAction(0, 'PostCalendar::', '::', ACCESS_ADMIN)) {
        $output->Text(_POSTCALENDAR_NOAUTH);
        return $output->GetOutput();
    }

    $output->SetInputMode(_PNH_VERBATIMINPUT);
    
    list($time24hours,
         $eventsopeninnewwindow,
         $useinternationaldates,
         $firstdayofweek,
         $doappointments,
         $textevents,
         $times,
         $dayhighlightcolor,
         $monthtableborder,
         $monthtablecellspacing,
         $monthtablecellpadding,
         $yeartableborder,
         $yeartablecellspacing,
         $yeartablecellpadding,
         $category1,
         $category2,
         $category3,
         $category4,
         $category5,
         $displayballs,
         $eventoverview,
         $showtimeonevents,
         $usepopups,
         $showeventsinyear,
         $numcolsinyearview,
         $allowdirectsubmit,
         $listhowmanyevents,
         $displaytopics)     = pnVarCleanFromInput('time24hours',
                                                   'eventsopeninnewwindow',
                                                   'useinternationaldates',
                                                   'firstdayofweek',
                                                   'doappointments',
                                                   'textevents',
                                                   'times',
                                                   'dayhighlightcolor',
                                                   'monthtableborder',
                                                   'monthtablecellspacing',
                                                   'monthtablecellpadding',
                                                   'yeartableborder',
                                                   'yeartablecellspacing',
                                                   'yeartablecellpadding',
                                                   'category1',
                                                   'category2',
                                                   'category3',
                                                   'category4',
                                                   'category5',
                                                   'displayballs',
                                                   'eventoverview',
                                                   'showtimeonevents',
                                                   'usepopups',
                                                   'showeventsinyear',
                                                   'numcolsinyearview',
                                                   'allowdirectsubmit',
                                                   'listhowmanyevents',
                                                   'displaytopics');
                                                   
    // make sure we enter something into the DB                                               
    if(!isset($time24hours))                    { $time24hours = '0'; }
    if(!isset($eventsopeninnewwindow))          { $eventsopeninnewwindow='0'; }
    if(!isset($useinternationaldates))          { $useinternationaldates='0'; }
    if(!isset($firstdayofweek))                 { $firstdayofweek='0'; }
    if(!isset($doappointments))                 { $doappointments='0'; }
    if(!isset($textevents))                     { $textevents='0'; }
    if(!isset($times))                          { $times = array('08:00:00','10:00:00','12:00:00','14:00:00','16:00:00','18:00:00','20:00:00','22:00:00'); }
    if(!isset($dayhighlightcolor))              { $dayhighlightcolor = 'red'; }
    if(!isset($monthtableborder))               { $monthtableborder='0'; }
    if(!isset($monthtablecellspacing))          { $monthtablecellspacing='0'; }
    if(!isset($monthtablecellpadding))          { $monthtablecellpadding='0'; }
    if(!isset($yeartableborder))                { $yeartableborder='0'; }
    if(!isset($yeartablecellspacing))           { $yeartablecellspacing='0'; }
    if(!isset($yeartablecellpadding))           { $yeartablecellpadding='0'; }
    if(!isset($category1))                      { $category1='none'; }
    if(!isset($category2))                      { $category2='none'; }
    if(!isset($category3))                      { $category3='none'; }
    if(!isset($category4))                      { $category4='none'; }
    if(!isset($category5))                      { $category5='none'; }
    if(!isset($displayballs))                   { $displayballs='0'; }
    if(!isset($eventoverview))                  { $eventoverview='0'; }
    if(!isset($showtimeonevents))               { $showtimeonevents='0'; }
    if(!isset($usepopups))                      { $usepopups='0'; }
    if(!isset($showeventsinyear))               { $showeventsinyear='0'; }
    if(!isset($numcolsinyearview))              { $numcolsinyearview='4'; }
    if(!isset($allowdirectsubmit))              { $allowdirectsubmit='0'; }
    if(!isset($listhowmanyevents))              { $listhowmanyevents='15'; }
    if(!isset($displaytopics))                  { $displaytopics='0'; }
    
    pnModSetVar('PostCalendar','time24hours',$time24hours);
    pnModSetVar('PostCalendar','eventsopeninnewwindow',$eventsopeninnewwindow);
    pnModSetVar('PostCalendar','useinternationaldates',$useinternationaldates);
    pnModSetVar('PostCalendar','firstdayofweek',$firstdayofweek);
    pnModSetVar('PostCalendar','doappointments',$doappointments);
    pnModSetVar('PostCalendar','textevents',$textevents);
    pnModSetVar('PostCalendar','times',$times);
    pnModSetVar('PostCalendar','dayhighlightcolor',$dayhighlightcolor);
    pnModSetVar('PostCalendar','monthtableborder',$monthtableborder);
    pnModSetVar('PostCalendar','monthtablecellspacing',$monthtablecellspacing);
    pnModSetVar('PostCalendar','monthtablecellpadding',$monthtablecellpadding);
    pnModSetVar('PostCalendar','yeartableborder',$yeartableborder);
    pnModSetVar('PostCalendar','yeartablecellspacing',$yeartablecellspacing);
    pnModSetVar('PostCalendar','yeartablecellpadding',$yeartablecellpadding);
    pnModSetVar('PostCalendar','category1',$category1);
    pnModSetVar('PostCalendar','category2',$category2);
    pnModSetVar('PostCalendar','category3',$category3);
    pnModSetVar('PostCalendar','category4',$category4);
    pnModSetVar('PostCalendar','category5',$category5);
    pnModSetVar('PostCalendar','displayballs',$displayballs);
    pnModSetVar('PostCalendar','eventoverview',$eventoverview);
    pnModSetVar('PostCalendar','showtimeonevents',$showtimeonevents);  
    pnModSetVar('PostCalendar','usepopups',$usepopups);
    pnModSetVar('PostCalendar','showeventsinyear',$showeventsinyear);
    pnModSetVar('PostCalendar','numcolsinyearview',$numcolsinyearview);
    pnModSetVar('PostCalendar','allowdirectsubmit',$allowdirectsubmit);
    pnModSetVar('PostCalendar','listhowmanyevents',$listhowmanyevents);
    pnModSetVar('PostCalendar','displaytopics',$displaytopics);

     
    $output->Text('<center>'._PC_UPDATED.'</center>');
    $output->Linebreak();   
    
    $output->Text(PostCalendar_admin_listqueued());
   
    return $output->GetOutput();
}

function PostCalendar_admin_upgradeoldtables()
{   $output = new pnHTML();

    pnThemeLoad(pnUserGetTheme());
    // get the theme globals :: is there a better way to do this?
    global $bgcolor1, $bgcolor2, $bgcolor3, $bgcolor4, $bgcolor5;
    global $textcolor1, $textcolor2;
    
    if (!pnSecAuthAction(0, 'PostCalendar::', '::', ACCESS_ADMIN)) {
        $output->Text(_POSTCALENDAR_NOAUTH);
        return $output->GetOutput();
    }

    $output->SetInputMode(_PNH_VERBATIMINPUT);
    $output->Text(PostCalendar_adminmenu());
    $output->FormStart(pnModURL('PostCalendar','admin','performupgrade'));
    
    $output->Text('<table border="0" cellpadding="1" cellspacing="0" width="100%"><tr><td bgcolor="'.$bgcolor2.'">');
    $output->Text('<table border="0" cellpadding="5" cellspacing="0" width="100%"><tr><td bgcolor="'.$bgcolor1.'">');
            $output->Text('This will grab your old events information to populate your PostCalendar v3.0 tables. ');
            $output->Text('By default, the upgrade will look for the tables $prefix_events and $prefix_events_queue ');
            $output->Text('in your database.  If you have moved these, please provide their new location below. ');
            $output->Linebreak(2);
            $output->Text('To use the default tables, just submit the form as is.');
            $output->Linebreak(2);
            $output->Text('OPTIONAL TABLE NAMES');
            $output->Linebreak(2);
            $output->Text('events table');
            $output->Linebreak();
            $output->FormText('newtable',null,50,100);
            $output->Linebreak(2);
            $output->Text('events queue table');
            $output->Linebreak();
            $output->FormText('newqueue',null,50,100);
            $output->Linebreak(2);
            $output->FormSubmit('Let\'s do it!');
    $output->Text('</td></tr></table>');    
    $output->Text('</td></tr></table>');
    
    $output->FormEnd();
    
    return $output->GetOutput();
}



function PostCalendar_admin_performupgrade()
{   $output = new pnHTML();

    pnThemeLoad(pnUserGetTheme());
    // get the theme globals :: is there a better way to do this?
    global $bgcolor1, $bgcolor2, $bgcolor3, $bgcolor4, $bgcolor5;
    global $textcolor1, $textcolor2;
    
    if (!pnSecAuthAction(0, 'PostCalendar::', '::', ACCESS_ADMIN)) {
        $output->Text(_POSTCALENDAR_NOAUTH);
        return $output->GetOutput();
    }
    
    list($newtable,$newqueue) = pnVarCleanFromInput('newtable','newqueue');
    
    pnModDBInfoLoad('PostCalendar');
    list($dbconn) = pnDBGetConn();
    $pntable = pnDBGetTables();
    $prefix = pnConfigGetVar('prefix');
    $events_table  = $pntable['postcalendar_events'];
    $events_column = $pntable['postcalendar_events_column'];
    
    /*******************************
     * 2.0 - 2.1 tables
     ******************************/
    if(!empty($newtable)) {
        $event_table = $newtable;
    } else {
        $event_table = $prefix.'_events';
    }
    
    if(!empty($newqueue)) {
        $event_queue = $newqueue;
    } else {
        $event_queue = $prefix.'_events_queue';
    }
    
    $event_table_cols = array('eid'=>$event_table.'.eid',
                              'aid'=>$event_table.'.aid',
                              'title'=>$event_table.'.title',
                              'time'=>$event_table.'.time',
                              'hometext'=>$event_table.'.hometext',
                              'comments'=>$event_table.'.comments',
                              'counter'=>$event_table.'.counter',
                              'topic'=>$event_table.'.topic',
                              'informant'=>$event_table.'.informant',
                              'eventDate'=>$event_table.'.eventDate',
                              'endDate'=>$event_table.'.endDate',
                              'recurrtype'=>$event_table.'.recurrtype',
                              'recurrspec'=>$event_table.'.recurrspec',
                              'startTime'=>$event_table.'.startTime',
                              'endTime'=>$event_table.'.endTime',
                              'alldayevent'=>$event_table.'.alldayevent',
                              'barcolor'=>$event_table.'.barcolor');
    
    $event_queue_cols = array('qid'=>$event_queue.'.qid',
                              'uid'=>$event_queue.'.uid',
                              'uname'=>$event_queue.'.uname',
                              'title'=>$event_queue.'.title',
                              'story'=>$event_queue.'.story',
                              'timestamp'=>$event_queue.'.timestamp',
                              'topic'=>$event_queue.'.topic',
                              'eventDate'=>$event_queue.'.eventDate',
                              'endDate'=>$event_queue.'.endDate',
                              'recurrtype'=>$event_queue.'.recurrtype',
                              'recurrspec'=>$event_queue.'.recurrspec',
                              'startTime'=>$event_queue.'.startTime',
                              'endTime'=>$event_queue.'.endTime',
                              'alldayevent'=>$event_queue.'.alldayevent',
                              'barcolor'=>$event_queue.'.barcolor');
    
    // determine the version they have
    $sqltest = "SELECT $event_table.fee FROM $event_table LIMIT 1";
    $dbconn->Execute($sqltest);
    if($dbconn->ErrorNo() == 0) {
        // they have v2.5x compatible tables (assumption)
        $up='2.5+';
        $do=2.5;
        // add the additional columns for 2.5x
        $event_table_cols['location']   = $event_table.'.location';
        $event_table_cols['conttel']    = $event_table.'.conttel';
        $event_table_cols['contname']   = $event_table.'.contname';
        $event_table_cols['contemail']  = $event_table.'.contemail';
        $event_table_cols['website']    = $event_table.'.website';
        $event_table_cols['fee']        = $event_table.'.fee';
        
        $event_queue_cols['location']   = $event_queue.'.location';
        $event_queue_cols['conttel']    = $event_queue.'.conttel';
        $event_queue_cols['contname']   = $event_queue.'.contname';
        $event_queue_cols['contemail']  = $event_queue.'.contemail';
        $event_queue_cols['website']    = $event_queue.'.website';
        $event_queue_cols['fee']        = $event_queue.'.fee';
    } else {
        // they have v2.x compatible tables (assumption)
        $up='2.0 - 2.1+';
        $do=2.0;
    }
    
    
    $sql = "SELECT count(1) FROM $event_table";
    $result = $dbconn->Execute($sql);
    if($dbconn->ErrorNo() == 0) {
        list($event_count) = $result->fields;
    }
    
    $sql = "SELECT count(1) FROM $event_queue";
    $result = $dbconn->Execute($sql);
    if($dbconn->ErrorNo() == 0) {
        list($queue_count) = $result->fields;
    }
    
    $output->SetInputMode(_PNH_VERBATIMINPUT);
    $output->Text(PostCalendar_adminmenu());
    
    $output->Text('<table border="0" cellpadding="1" cellspacing="0" width="100%"><tr><td bgcolor="'.$bgcolor2.'">');
    $output->Text('<table border="0" cellpadding="5" cellspacing="0" width="100%"><tr><td bgcolor="'.$bgcolor1.'">');
        $output->Text('Upgrading from PostCalendar '.$up);
        $output->Linebreak();
        $output->Text('Events : '.$event_count);
        $output->Linebreak();
        $output->Text('Queued : '.$queue_count);
    $output->Text('</td></tr></table>');    
    $output->Text('</td></tr></table>');
    $output->Linebreak(2);
    
    switch ($do) {
    
        case 2.5 :
            $sql1 = "SELECT $event_table_cols[eid],
                            $event_table_cols[aid],
                            $event_table_cols[time],
                            $event_table_cols[title],
                            $event_table_cols[hometext],
                            $event_table_cols[comments],
                            $event_table_cols[counter],
                            $event_table_cols[topic],
                            $event_table_cols[informant],
                            $event_table_cols[eventDate],
                            $event_table_cols[endDate],
                            $event_table_cols[recurrtype],
                            $event_table_cols[recurrspec],
                            $event_table_cols[startTime],
                            $event_table_cols[endTime],
                            $event_table_cols[alldayevent],
                            $event_table_cols[barcolor],
                            $event_table_cols[location],
                            $event_table_cols[conttel],
                            $event_table_cols[contname],
                            $event_table_cols[contemail],
                            $event_table_cols[website],
                            $event_table_cols[fee]
                     FROM   $event_table
                     WHERE  1";
                     
            $sql2 = "SELECT $event_queue_cols[qid],
                            $event_queue_cols[uid], 
                            $event_queue_cols[uname],
                            $event_queue_cols[title],
                            $event_queue_cols[story],
                            $event_queue_cols[timestamp],
                            $event_queue_cols[topic],
                            $event_queue_cols[eventDate],
                            $event_queue_cols[endDate],
                            $event_queue_cols[recurrtype],
                            $event_queue_cols[recurrspec],
                            $event_queue_cols[startTime],
                            $event_queue_cols[endTime],
                            $event_queue_cols[alldayevent],
                            $event_queue_cols[barcolor],
                            $event_queue_cols[location],
                            $event_queue_cols[conttel],
                            $event_queue_cols[contname],
                            $event_queue_cols[contemail],
                            $event_queue_cols[website],
                            $event_queue_cols[fee]
                     FROM   $event_queue
                     WHERE  1";

            $event_result = $dbconn->Execute($sql1);
            if($dbconn->ErrorNo() != 0) {
                $output->Linebreak();
                $output->Text('Event SQL Failed');
                return $output->GetOutput();
            }
            for(; !$event_result->EOF; $event_result->MoveNext()) {
                list($eid,$aid,$time,$title,$hometext,$comment,$counter,$topic,$informant,$eventDate,$endDate,
                     $recurrtype,$recurrspec,$startTime,$endTime,$alldayevent,$barcolor,
                     $location,$conttel,$contname,$contemail,$website,$fee) = $event_result->fields;
                // prep for store     
                list($eid,$aid,$time,$title,$hometext,$comment,$counter,$topic,$informant,$eventDate,$endDate,
                     $recurrtype,$recurrspec,$startTime,$endTime,$alldayevent,$barcolor,
                     $location,$conttel,$contname,$contemail,$website,$fee) = pnVarPrepForStore($eid,
                            $aid,$time,$title,$hometext,$comment,$counter,$topic,$informant,$eventDate,$endDate,
                            $recurrtype,$recurrspec,$startTime,$endTime,$alldayevent,$barcolor,
                            $location,$conttel,$contname,$contemail,$website,$fee);
                
                // build the inserts
                $insert1 = "INSERT INTO $events_table
                           ($events_column[aid],$events_column[time],
                            $events_column[title],$events_column[hometext],
                            $events_column[comments],$events_column[counter],
                            $events_column[topic],$events_column[informant],
                            $events_column[eventDate],$events_column[endDate],
                            $events_column[recurrtype],$events_column[recurrspec],
                            $events_column[recurrfreq],$events_column[startTime],
                            $events_column[endTime],$events_column[alldayevent],
                            $events_column[barcolor],$events_column[location],
                            $events_column[conttel],$events_column[contname],
                            $events_column[contemail],$events_column[website],
                            $events_column[fee],$events_column[eventstatus])
                           VALUES 
                           (0,'$time','$title','$hometext',$comment,$counter,
                            $topic,'$informant','$eventDate','$endDate',
                            $recurrtype,'$recurrspec',0,'$startTime',
                            '$endTime',$alldayevent,'$barcolor','$location',
                            '$conttel','$contname','$contemail','$website','$fee',1)";
           
                $dbconn->Execute($insert1);
                if($dbconn->ErrorNo() != 0) {
                    $output->Linebreak();
                    $output->Text('Event INSERT Failed');
                    $output->Linebreak();
                    $output->Text($dbconn->ErrorMsg());
                    return $output->GetOutput();
                }
            }
            $output->Text('Your old events have been inserted successfully.  Congratulations!');
            $output->Linebreak();
            
            $queue_result = $dbconn->Execute($sql2);
            if($dbconn->ErrorNo() != 0) {
                $output->Linebreak();
                $output->Text('Queue SQL Failed');
                return $output->GetOutput();
            }  
            for(; !$queue_result->EOF; $queue_result->MoveNext()) {
                list($qid,$uid,$uname,$title,$story,$timestamp,$topic,$eventDate,$endDate,
                     $recurrtype,$recurrspec,$startTime,$endTime,$alldayevent,$barcolor,
                     $location,$conttel,$contname,$contemail,$website,$fee) = $queue_result->fields;
                // prep for store
                list($qid,$uid,$uname,$title,$story,$timestamp,$topic,$eventDate,$endDate,
                     $recurrtype,$recurrspec,$startTime,$endTime,$alldayevent,$barcolor,
                     $location,$conttel,$contname,$contemail,$website,$fee) = pnVarPrepForStore($qid,
                            $uid,$uname,$title,$story,$timestamp,$topic,$eventDate,$endDate,
                            $recurrtype,$recurrspec,$startTime,$endTime,$alldayevent,$barcolor,
                            $location,$conttel,$contname,$contemail,$website,$fee);
                            
                // build the inserts
                $insert2 = "INSERT INTO $events_table
                           ($events_column[aid],$events_column[time],
                            $events_column[title],$events_column[hometext],
                            $events_column[comments],$events_column[counter],
                            $events_column[topic],$events_column[informant],
                            $events_column[eventDate],$events_column[endDate],
                            $events_column[recurrtype],$events_column[recurrspec],
                            $events_column[recurrfreq],$events_column[startTime],
                            $events_column[endTime],$events_column[alldayevent],
                            $events_column[barcolor],$events_column[location],
                            $events_column[conttel],$events_column[contname],
                            $events_column[contemail],$events_column[website],
                            $events_column[fee],$events_column[eventstatus])
                           VALUES 
                           (0,'$timestamp','$title','$story',0,0,$topic,
                            '$uname','$eventDate','$endDate',$recurrtype,
                            '$recurrspec',0,'$startTime','$endTime',$alldayevent,
                            '$barcolor','$location','$conttel','$contname',
                            '$contemail','$website','$fee',0)";
                            
                $dbconn->Execute($insert2);
                if($dbconn->ErrorNo() != 0) {
                    $output->Linebreak();
                    $output->Text('Queue INSERT Failed');
                    $output->Linebreak();
                    $output->Text($dbconn->ErrorMsg());
                    return $output->GetOutput();
                }
            }
            $output->Text('Your old queued events have been inserted successfully.  Congratulations!');
            $output->Linebreak();
        break;
        
        case 2.0 :
            $sql1 = "SELECT $event_table_cols[eid],
                            $event_table_cols[aid],
                            $event_table_cols[time],
                            $event_table_cols[title],
                            $event_table_cols[hometext],
                            $event_table_cols[comments],
                            $event_table_cols[counter],
                            $event_table_cols[topic],
                            $event_table_cols[informant],
                            $event_table_cols[eventDate],
                            $event_table_cols[endDate],
                            $event_table_cols[recurrtype],
                            $event_table_cols[recurrspec],
                            $event_table_cols[startTime],
                            $event_table_cols[endTime],
                            $event_table_cols[alldayevent],
                            $event_table_cols[barcolor]
                     FROM   $event_table
                     WHERE  1";
                     
            $sql2 = "SELECT $event_queue_cols[qid],
                            $event_queue_cols[uid],
                            $event_queue_cols[uname],
                            $event_queue_cols[title],
                            $event_queue_cols[story],
                            $event_queue_cols[timestamp],
                            $event_queue_cols[topic],
                            $event_queue_cols[eventDate],
                            $event_queue_cols[endDate],
                            $event_queue_cols[recurrtype],
                            $event_queue_cols[recurrspec],
                            $event_queue_cols[startTime],
                            $event_queue_cols[endTime],
                            $event_queue_cols[alldayevent],
                            $event_queue_cols[barcolor]
                     FROM   $event_queue
                     WHERE  1";
            
            $event_result = $dbconn->Execute($sql1);
            if($dbconn->ErrorNo() != 0) {
                $output->Linebreak();
                $output->Text('Event SQL Failed');
                $output->Linebreak();
                $output->Text($dbconn->ErrorMsg());
                return $output->GetOutput();
            }
            for(; !$event_result->EOF; $event_result->MoveNext()) {
                list($eid,$aid,$time,$title,$hometext,$comment,$counter,$topic,$informant,$eventDate,$endDate,
                     $recurrtype,$recurrspec,$startTime,$endTime,$alldayevent,$barcolor) = $event_result->fields;
                // prep for store     
                list($eid,$aid,$time,$title,$hometext,$comment,$counter,$topic,$informant,$eventDate,$endDate,
                     $recurrtype,$recurrspec,$startTime,$endTime,$alldayevent,$barcolor) = pnVarPrepForStore($eid,
                            $aid,$time,$title,$hometext,$comment,$counter,$topic,$informant,$eventDate,$endDate,
                            $recurrtype,$recurrspec,$startTime,$endTime,$alldayevent,$barcolor);
                
                // build the inserts
                $insert1 = "INSERT INTO $events_table
                           ($events_column[aid],$events_column[time],
                            $events_column[title],$events_column[hometext],
                            $events_column[comments],$events_column[counter],
                            $events_column[topic],$events_column[informant],
                            $events_column[eventDate],$events_column[endDate],
                            $events_column[recurrtype],$events_column[recurrspec],
                            $events_column[recurrfreq],$events_column[startTime],
                            $events_column[endTime],$events_column[alldayevent],
                            $events_column[barcolor],$events_column[location],
                            $events_column[conttel],$events_column[contname],
                            $events_column[contemail],$events_column[website],
                            $events_column[fee],$events_column[eventstatus])
                           VALUES 
                           (0,'$time','$title','$hometext',$comment,$counter,
                            $topic,'$informant','$eventDate','$endDate',
                            $recurrtype,'$recurrspec',0,'$startTime',
                            '$endTime',$alldayevent,'','','','','','','',1)";
           
                $dbconn->Execute($insert1);
                if($dbconn->ErrorNo() != 0) {
                    $output->Linebreak();
                    $output->Text('Event INSERT Failed');
                    $output->Linebreak();
                    $output->Text($dbconn->ErrorMsg());
                    return $output->GetOutput();
                }
            }
            $output->Text('Your old events have been inserted successfully.  Congratulations!');
            $output->Linebreak();
            
            $queue_result = $dbconn->Execute($sql2);
            if($dbconn->ErrorNo() != 0) {
                $output->Linebreak();
                $output->Text('Queue SQL Failed');
                return $output->GetOutput();
            }
            for(; !$queue_result->EOF; $queue_result->MoveNext()) {
                list($qid,$uid,$uname,$title,$story,$timestamp,$topic,$eventDate,$endDate,
                     $recurrtype,$recurrspec,$startTime,$endTime,$alldayevent,$barcolor) = $queue_result->fields;
                // prep for store
                list($qid,$uid,$uname,$title,$story,$timestamp,$topic,$eventDate,$endDate,
                     $recurrtype,$recurrspec,$startTime,$endTime,$alldayevent,$barcolor) = pnVarPrepForStore($qid,
                            $uid,$uname,$title,$story,$timestamp,$topic,$eventDate,$endDate,
                            $recurrtype,$recurrspec,$startTime,$endTime,$alldayevent,$barcolor);
                            
                // build the inserts
                $insert2 = "INSERT INTO $events_table
                           ($events_column[aid],$events_column[time],
                            $events_column[title],$events_column[hometext],
                            $events_column[comments],$events_column[counter],
                            $events_column[topic],$events_column[informant],
                            $events_column[eventDate],$events_column[endDate],
                            $events_column[recurrtype],$events_column[recurrspec],
                            $events_column[recurrfreq],$events_column[startTime],
                            $events_column[endTime],$events_column[alldayevent],
                            $events_column[barcolor],$events_column[location],
                            $events_column[conttel],$events_column[contname],
                            $events_column[contemail],$events_column[website],
                            $events_column[fee],$events_column[eventstatus])
                           VALUES 
                           (0,'$timestamp','$title','$story',0,0,$topic,
                            '$uname','$eventDate','$endDate',$recurrtype,
                            '$recurrspec',0,'$startTime','$endTime',$alldayevent,
                            '$barcolor','$location','$conttel','$contname',
                            '$contemail','$website','$fee',0)";
                            
                $dbconn->Execute($insert2);
                if($dbconn->ErrorNo() != 0) {
                    $output->Linebreak();
                    $output->Text('Queue INSERT Failed');
                    $output->Linebreak();
                    $output->Text($dbconn->ErrorMsg());
                    return $output->GetOutput();
                }
            }
            $output->Text('Your old queued events have been inserted successfully.  Congratulations!');
            $output->Linebreak();
        break;
    }
    
    return $output->GetOutput();
}

/**
 * Main administration menu
 */
function PostCalendar_adminmenu()
{
    pnThemeLoad(pnUserGetTheme());
    // get the theme globals :: is there a better way to do this?
    global $bgcolor1, $bgcolor2, $bgcolor3, $bgcolor4, $bgcolor5;
    global $textcolor1, $textcolor2;
    
    if(!defined('_AM_VAL'))         define('_AM_VAL',           1);
    if(!defined('_PM_VAL'))         define('_PM_VAL',           2);
    if(!defined('_EVENT_APPROVED')) define('_EVENT_APPROVED',   1);
    if(!defined('_EVENT_QUEUED'))   define('_EVENT_QUEUED',     0);
    if(!defined('_EVENT_HIDDEN'))   define('_EVENT_HIDDEN',    -1);
    if(!defined('_ACTION_APPROVE')) define('_ACTION_APPROVE',   0);
    if(!defined('_ACTION_DELETE'))  define('_ACTION_DELETE',    1);
    if(!defined('_ACTION_EDIT'))    define('_ACTION_EDIT',      2);
    if(!defined('_ACTION_VIEW'))    define('_ACTION_VIEW',      3);

    // Create output object - this object will store all of our output so that
    // we can return it easily when required
    $output = new pnHTML();
    $output->SetInputMode(_PNH_VERBATIMINPUT);
        
    // lets get the module's information
    $modinfo      = pnModGetInfo(pnModGetIDFromName('PostCalendar'));
    
    if (!pnModAPILoad('PostCalendar', 'user')) {
        $output->Text(_LOADFAILED);
        return $output->GetOutput();
    }
    
    $output->Text(pnGetStatusMsg());
    //$output->Linebreak();

    // Start options menu
    $output->SetInputMode(_PNH_VERBATIMINPUT);
    $output->SetOutputMode(_PNH_RETURNOUTPUT);
    $postcal_admin_link = $output->URL(pnModURL('PostCalendar','admin',''),_POSTCALENDAR);
    $output->SetOutputMode(_PNH_KEEPOUTPUT);
    
    // all done
    $output->FormStart(pnModUrl('PostCalendar','user','view'));
    $output->tabindex=1000;
    $output->Text('<table border="0" cellpadding="1" cellspacing="0" width="100%" bgcolor="'.$bgcolor2.'"><tr><td>');
    $output->Text('<table border="0" cellpadding="5" cellspacing="0" width="100%" bgcolor="'.$bgcolor1.'">');
        $output->Text('<tr>');
            $output->Text('<td width="10" align="left" valign="top">');
            $output->Text('<center><img src="modules/'.$modinfo['directory'].'/pnimages/admin.gif"></center>');
            $output->Text('</td>');
            
            $output->Text('<td align="center" valign="top">');
            $output->Text('<font class="pn-logo">'.$postcal_admin_link.'</font>');
            $output->Linebreak(2);
            
            $output->URL(pnModURL('PostCalendar','admin','new'),_PC_CREATE_EVENT);
            $output->Text(' | ');
            $output->URL(pnModURL('PostCalendar','admin','listapproved'), _PC_VIEW_APPROVED);
            $output->Text(' | ');
            $output->URL(pnModURL('PostCalendar','admin','listhidden'), _PC_VIEW_HIDDEN);
            $output->Text(' | ');
            $output->URL(pnModURL('PostCalendar','admin','listqueued'), _PC_VIEW_QUEUED);
            $output->Linebreak();
            $output->URL(pnModURL('PostCalendar','admin','modifyconfig'),_EDIT_PC_CONFIG);
            $output->Text(' | ');
            $output->URL(pnModURL('PostCalendar','admin','upgradeoldtables'),_PC_UPGRADE_TABLES);
            $output->Text('</td>');
         $output->Text('</tr>');
    $output->Text('</table>');    
    $output->Text('</td></tr></table>');
    $output->FormEnd();
    $output->Linebreak();
    
    // Return the output that has been generated by this function
    return $output->GetOutput();
}

?>
Return current item: Nuke Modules CVS