[ Index ]

krapohl.info

title

Body

[close]

/ -> pnadminapi.php (source)

   1  <?php
   2  @define('__POSTCALENDAR__','PostCalendar');
   3  /**
   4   *  $Id: pnadminapi.php,v 1.1 2004/02/11 17:25:28 larsneo Exp $
   5   *
   6   *  PostCalendar::PostNuke Events Calendar Module
   7   *  Copyright (C) 2002  The PostCalendar Team
   8   *  http://postcalendar.tv
   9   *  
  10   *  This program is free software; you can redistribute it and/or modify
  11   *  it under the terms of the GNU General Public License as published by
  12   *  the Free Software Foundation; either version 2 of the License, or
  13   *  (at your option) any later version.
  14   *  
  15   *  This program is distributed in the hope that it will be useful,
  16   *  but WITHOUT ANY WARRANTY; without even the implied warranty of
  17   *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  18   *  GNU General Public License for more details.
  19   *  
  20   *  You should have received a copy of the GNU General Public License
  21   *  along with this program; if not, write to the Free Software
  22   *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  23   *
  24   *  To read the license please read the docs/license.txt or visit
  25   *  http://www.gnu.org/copyleft/gpl.html
  26   *
  27   */
  28  
  29  //=========================================================================
  30  //  Require utility classes
  31  //=========================================================================
  32  $pcModInfo = pnModGetInfo(pnModGetIDFromName(__POSTCALENDAR__));
  33  $pcDir = pnVarPrepForOS($pcModInfo['directory']);
  34  require_once("modules/$pcDir/common.api.php");
  35  unset($pcModInfo,$pcDir);
  36  
  37  function postcalendar_adminapi_buildHourSelect($args) 
  38  {
  39      extract($args);
  40      $time24hours = pnModGetVar(__POSTCALENDAR__,'time24hours');
  41      
  42      if(!isset($hour)){
  43          $hour = $time24hours ? date('H') : date('h'); 
  44      }
  45      
  46      $output =& new pnHTML();
  47      $output->SetInputMode(_PNH_VERBATIMINPUT);
  48      
  49      $options = array();
  50      if($time24hours) {
  51          for($i = 0; $i < 24; $i++) {
  52              $sel = false;
  53              if($i == $hour) {
  54                  $sel = true;
  55              }
  56              $options[$i]['id']       = $i;
  57              $options[$i]['selected'] = $sel;
  58              $options[$i]['name']     = $i < 10 ? '0'.$i : $i;  
  59          }
  60      } else {
  61          for($i = 0; $i < 12; $i++) {
  62              $sel = false;
  63              if($i == $hour) {
  64                  $sel = true;
  65              }
  66              $options[$i]['id']       = $i+1;
  67              $options[$i]['selected'] = $sel;
  68              $options[$i]['name']     = $i+1 < 10 ? '0'.$i+1 : $i+1;     
  69          }
  70      }
  71      
  72      $output->FormSelectMultiple('pc_hour',$options);
  73      return $output->GetOutput();
  74  }
  75  function postcalendar_adminapi_getAdminListEvents($args) 
  76  {
  77      extract($args);
  78      list($dbconn) = pnDBGetConn();
  79      $pntable = pnDBGetTables();
  80      $events_table = $pntable['postcalendar_events'];
  81      
  82      $sql = "SELECT pc_eid,
  83                     pc_title, 
  84                     pc_time 
  85              FROM   $events_table
  86              WHERE  pc_eventstatus = '".pnVarPrepForStore($type)."' ";
  87      if($sort == 'time') {
  88          $sql .= "ORDER BY pc_time ";
  89      } elseif($sort == 'title') {
  90          $sql .= "ORDER BY pc_title ";
  91      }
  92      if($sdir == 0) {
  93          $sql .= "DESC ";
  94      } elseif($sdir == 1) {
  95          $sql .= "ASC ";
  96      }
  97      $sql .= "LIMIT  $offset,$offset_increment";
  98      
  99      return $dbconn->Execute($sql);
 100  }
 101  
 102  function postcalendar_adminapi_buildAdminList($args) 
 103  {
 104      extract($args);
 105      $output =& new pnHTML();
 106      $output->SetInputMode(_PNH_VERBATIMINPUT);
 107      pnThemeLoad(pnUserGetTheme());
 108      // get the theme globals :: is there a better way to do this?
 109      global $bgcolor1, $bgcolor2, $bgcolor3, $bgcolor4, $bgcolor5;
 110      global $textcolor1, $textcolor2;
 111      
 112      $formUrl = pnModUrl(__POSTCALENDAR__,'admin','adminevents');
 113      $output->FormStart($formUrl);
 114      $output->Text('<table border="0" cellpadding="1" cellspacing="0" width="100%" bgcolor="'.$bgcolor2.'"><tr><td>');
 115      $output->Text('<table border="0" cellpadding="5" cellspacing="0" width="100%" bgcolor="'.$bgcolor1.'"><tr><td>');
 116          $output->Text('<center><font size="4"><b>'.$title.'</b></font></center>');
 117      $output->Text('</td></tr></table>');    
 118      $output->Text('</td></tr></table>');
 119      
 120      $output->Linebreak();
 121      
 122      $output->Text('<table border="0" cellpadding="1" cellspacing="0" width="100%" bgcolor="'.$bgcolor2.'"><tr><td>');
 123      $output->Text('<table border="0" cellpadding="5" cellspacing="0" width="100%" bgcolor="'.$bgcolor1.'">');
 124          if(!$result || $result->EOF) {
 125              $output->Text('<tr><td width="100%" bgcolor="'.$bgcolor1.'" align="center"><b>'._PC_NO_EVENTS.'</b></td></tr>');
 126          } else {
 127              $output->Text('<tr><td bgcolor="'.$bgcolor1.'" align="center"><b>'._PC_EVENTS.'</b></td></tr>');
 128              $output->Text('<table border="0" cellpadding="2" cellspacing="0" width="100%" bgcolor="'.$bgcolor1.'">');
 129              
 130              // build sorting urls
 131              if(!isset($sdir)) { $sdir = 1; } 
 132              else { $sdir = $sdir ? 0 : 1; }
 133              
 134              $title_sort_url = pnModUrl(__POSTCALENDAR__,'admin',$function,array('offset'=>$offset,'sort'=>'title','sdir'=>$sdir));
 135              $time_sort_url = pnModUrl(__POSTCALENDAR__,'admin',$function,array('offset'=>$offset,'sort'=>'time','sdir'=>$sdir));
 136              $output->Text('<tr><td>select</td><td><a href="'.$title_sort_url.'">title</a></td><td><a href="'.$time_sort_url.'">timestamp</a><td></tr>');   
 137              // output the queued events
 138              $count=0;
 139              for(; !$result->EOF; $result->MoveNext()) {
 140                  list($eid,$title,$timestamp) = $result->fields;
 141                  $output->Text('<tr>');
 142                      $output->Text('<td align="center" valign="top">');
 143                          $output->FormCheckbox('pc_event_id[]', false, $eid);
 144                      $output->Text('</td>');
 145                      $output->Text('<td  align="left" valign="top" width="100%">');
 146                          $output->URL(pnModURL(__POSTCALENDAR__,'admin','edit',array('pc_event_id'=>$eid)),
 147                                        pnVarPrepHTMLDisplay(postcalendar_removeScriptTags($title)));
 148                      $output->Text('</td>');
 149                      $output->Text('<td  align="left" valign="top" nowrap>');
 150                          $output->Text($timestamp);
 151                      $output->Text('</td>');
 152                  $output->Text('</tr>');
 153                  
 154                  $count++;
 155              }
 156              $output->Text('</table>');     
 157          }
 158      $output->Text('</td></tr></table>');
 159      if($result->NumRows()) {
 160      $output->Linebreak();
 161      
 162      // action to take?
 163      $output->Text('<table border="0" cellpadding="1" cellspacing="0" width="100%" bgcolor="'.$bgcolor2.'"><tr><td>');
 164      $output->Text('<table border="0" cellpadding="5" cellspacing="0" width="100%" bgcolor="'.$bgcolor1.'"><tr>');
 165          $output->Text('<td align="left" valign="middle">');
 166              
 167              $seldata[0]['id'] = _ADMIN_ACTION_VIEW;
 168              $seldata[0]['selected'] = 1;
 169              $seldata[0]['name'] = _PC_ADMIN_ACTION_VIEW;
 170              
 171              $seldata[1]['id'] = _ADMIN_ACTION_APPROVE;
 172              $seldata[1]['selected'] = 0;
 173              $seldata[1]['name'] = _PC_ADMIN_ACTION_APPROVE;
 174              
 175              $seldata[2]['id'] = _ADMIN_ACTION_HIDE;
 176              $seldata[2]['selected'] = 0;
 177              $seldata[2]['name'] = _PC_ADMIN_ACTION_HIDE;
 178              
 179              $seldata[3]['id'] = _ADMIN_ACTION_DELETE;
 180              $seldata[3]['selected'] = 0;
 181              $seldata[3]['name'] = _PC_ADMIN_ACTION_DELETE;
 182              
 183              $output->FormSelectMultiple('action', $seldata);
 184              $output->FormHidden('thelist',$function);
 185              $output->FormSubmit(_PC_PERFORM_ACTION);
 186          $output->Text('</td>');
 187      $output->Text('</tr></table>');    
 188      $output->Text('</td></tr></table>');
 189      $output->Linebreak();
 190      
 191      // start previous next links
 192      $output->Text('<table border="0" cellpadding="1" cellspacing="0" width="100%" bgcolor="'.$bgcolor2.'"><tr><td>');
 193      $output->Text('<table border="0" cellpadding="5" cellspacing="0" width="100%" bgcolor="'.$bgcolor1.'"><tr>');
 194      if($offset > 1) {
 195          $output->Text('<td align="left">');
 196          $next_link = pnModUrl(__POSTCALENDAR__,'admin',$function,array('offset'=>$offset-$offset_increment,'sort'=>$sort,'sdir'=>$sdir));
 197          $output->Text('<a href="'.$next_link.'"><< '._PC_PREV.' '.$offset_increment.'</a>');
 198          $output->Text('</td>');
 199      } else {
 200          $output->Text('<td align="left"><< '._PC_PREV.'</td>');
 201      }
 202      if($result->NumRows() >= $offset_increment) {
 203          $output->Text('<td align="right">');
 204          $next_link = pnModUrl(__POSTCALENDAR__,'admin',$function,array('offset'=>$offset+$offset_increment,'sort'=>$sort,'sdir'=>$sdir));
 205          $output->Text('<a href="'.$next_link.'">'._PC_NEXT.' '.$offset_increment.' >></a>');
 206          $output->Text('</td>');
 207      } else {
 208          $output->Text('<td align="right">'._PC_NEXT.' >></td>');
 209      }
 210      $output->Text('</tr></table>');   
 211      } 
 212      $output->Text('</td></tr></table>');
 213      // end previous next links
 214      $output->FormEnd();
 215      
 216      return $output->GetOutput();
 217  }
 218  
 219  function postcalendar_adminapi_buildMinSelect($args) 
 220  {
 221      extract($args);
 222      
 223      if(!isset($min)){
 224          $min = date('i'); 
 225      }
 226      
 227      $output =& new pnHTML();
 228      $output->SetInputMode(_PNH_VERBATIMINPUT);
 229      
 230      $options = array();
 231      for ($i = 0; $i <= 45; $i+5) {
 232          $options[$i]['id']       = $i;
 233          $options[$i]['selected'] = false;
 234          $options[$i]['name']     = $i < 10 ? '0'.$i+1 : $i+1;            
 235      }
 236      
 237      $output->FormSelectMultiple('pc_min',$options);
 238      return $output->GetOutput();
 239  }
 240  
 241  function postcalendar_adminapi_buildAMPMSelect($args) 
 242  {   
 243      extract($args);
 244      
 245      $output =& new pnHTML();
 246      $output->SetInputMode(_PNH_VERBATIMINPUT);
 247      
 248      $options = array();
 249      if(pnModGetVar(__POSTCALENDAR__,'time24hours')) {
 250          return false;
 251      } else {
 252          $options[0]['id']        = 'AM';
 253          $options[0]['selected']  = '';
 254          $options[0]['name']      = 'AM';
 255          $options[1]['id']        = 'PM';
 256          $options[1]['selected']  = '';
 257          $options[1]['name']      = 'PM';
 258      }
 259      
 260      $output->FormSelectMultiple('pc_ampm',$options);
 261      return $output->GetOutput();
 262  }
 263  
 264  function postcalendar_adminapi_waiting($args) 
 265  {   $output =& new pnHTML();
 266      $output = "waiting<br />";
 267      return $output->GetOutput();
 268  }
 269  
 270  function postcalendar_adminapi_updateCategories($args) 
 271  {
 272      extract($args);
 273      if(!isset($updates)) {
 274          return false;
 275      }
 276      list($dbconn) = pnDBGetConn();
 277      foreach($updates as $update) {
 278          $result = $dbconn->Execute($update);
 279          if($result === false) {
 280              return false;
 281          }
 282      }
 283      return true;
 284  }
 285  function postcalendar_adminapi_deleteCategories($args) 
 286  {
 287      extract($args);
 288      if(!isset($delete)) {
 289          return false;
 290      }
 291      list($dbconn) = pnDBGetConn();
 292      $result = $dbconn->Execute($delete);
 293      if($result === false) {
 294          return false;
 295      }
 296      return true;
 297  }
 298  function postcalendar_adminapi_addCategories($args) 
 299  {
 300      extract($args);
 301      if(!isset($name)) {
 302          return false;
 303      }
 304      list($dbconn) = pnDBGetConn();
 305      $pntable = pnDBGetTables();
 306      
 307      $name = pnVarPrepForStore($name);
 308      $desc = pnVarPrepForStore($desc);
 309      $color = pnVarPrepForStore($color);
 310      
 311      $result = $dbconn->Execute("INSERT INTO $pntable[postcalendar_categories] 
 312                                  (pc_catid,pc_catname,pc_catdesc,pc_catcolor)
 313                                  VALUES ('','$name','$desc','$color')");
 314      if($result === false) {
 315          return false;
 316      }
 317      return true;
 318  }
 319  
 320  ?>


Generated: Wed Feb 16 22:40:07 2005 Cross-referenced by PHPXref 0.6