Location: PHPKode > projects > OpenBizMap > obm2007.1/mydata/script/sys_request.txt
<?php
/*
OpenDataBag - Data Web Interface
Copyright (C) 2004 Nawara

This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
*/

//get my bags
$mybags_array=array();

if(defined('cfg_guestbag'))
  $mybags_array[cfg_guestbag][check_access(cfg_guestbag)]='99991231';

set_access('access',1);
$result_array=search('bagaccess user=['.USERNAME.']');
for($ii=0;$ii<count($result_array);$ii++)
{
  $variable_array=array();
  $variable_array['Bag']['value']=read($result_array[$ii],'Bag');
  $variable_array['Access']['value']=read($result_array[$ii],'Access');
  $variable_array['sysValidTo']['value']=read($result_array[$ii],'sysValidTo');
  if(!isset($mybags_array[$variable_array['Bag']['value']][$variable_array['Access']['value']]) or $mybags_array[$variable_array['Bag']['value']][$variable_array['Access']['value']]<$variable_array['sysValidTo']['value'])
    $mybags_array[$variable_array['Bag']['value']][$variable_array['Access']['value']]=$variable_array['sysValidTo']['value'];
}

echo '<div class="supergroup">';

echo '<h2>';
myecho('My access');
echo '</h2>';

echo '<table>';

echo '<td class="label">';
  myecho('Bag');
echo '</td>';

echo '<td class="label">';
  myecho('My Access');
echo '</td>';

echo '<td class="label">';
  myecho('Guest access');
echo '</td class="label">';

echo '<td class="label">';
  myecho('User access');
echo '</td>';

echo '<td class="label">';
  myecho('Owner access');
echo '</td>';


reset($mybags_array);
while(list($key,$val)=each($mybags_array))
{
  $access=check_access($key);

  $expires1=0;
  $expires2=0;
  $expires3=0;

  if(isset($val[1]))
    if($val[1]=='99991231')
      $expires1=99999;
    else
      $expires1=(round(0.5+(mktime(0,0,0,substr($val[1],4,2),substr($val[1],6,2),substr($val[1],0,4))-time())/3600/24));

  if(isset($val[2]))
    if($val[2]=='99991231')
      $expires2=99999;
    else
      $expires2=(round(0.5+(mktime(0,0,0,substr($val[2],4,2),substr($val[2],6,2),substr($val[2],0,4))-time())/3600/24));

  if(isset($val[3]))
    if($val[3]=='99991231')
      $expires3=99999;
    else
      $expires3=(round(0.5+(mktime(0,0,0,substr($val[3],4,2),substr($val[3],6,2),substr($val[3],0,4))-time())/3600/24));

  echo '<tr>';

  echo '<td>';
    $show_value=trim($key);
    $show_mode=CFG_SHOW;
    include(cfg_data_path.'/script/fld_.txt');
  echo '</td>';

  echo '<td class="label">';
    if($access==1)
    {
      echo '<span>';
      myecho('Guest (Read only)');
      echo '</span>';
    }
    if($access==2)
    {
      echo '<span style="color:#080">';
      myecho('User (Read, Write)');
      echo '</span>';
    }
    if($access==3)
    {
      echo '<span style="color:#f00">';
      myecho('Owner (All rights)');
      echo '</span>';
    }

  echo '</td>';

  echo '<td class="label">';
    if($expires1==1)
    {
      echo '<span style="color:#f00">';
      myecho('Expires today');
      echo '</span>';
    }
    elseif($expires1==99999)
    {
      echo '<span style="color:#080">';
      myecho('Never expires');
      echo '</span>';
    }
    elseif($expires1>1)
    {
      echo '<span style="color:#080">';
      myecho('Granted for next %1 days',$expires1);
      echo '</span>';
    }
    else
      echo '<span style="color:#aaa"></span>';
  echo '</td>';

  echo '<td class="label">';
    if($expires2==1)
    {
      echo '<span style="color:#f00">';
      myecho('Expires today');
      echo '</span>';
    }
    elseif($expires2==99999)
    {
      echo '<span style="color:#080">';
      myecho('Never expires');
      echo '</span>';
    }
    elseif($expires2>1)
    {
      echo '<span style="color:#080">';
      myecho('Granted for next %1 days',$expires2);
      echo '</span>';
    }
    else
      echo '<span style="color:#aaa"></span>';
  echo '</td>';

  echo '<td class="label">';
    if($expires3==1)
    {
      echo '<span style="color:#f00">';
      myecho('Expires today');
      echo '</span>';
    }
    elseif($expires3==99999)
    {
      echo '<span style="color:#080">';
      myecho('Never expires');
      echo '</span>';
    }
    elseif($expires3>1)
    {
      echo '<span style="color:#080">';
      myecho('Granted for next %1 days',$expires3);
      echo '</span>';
    }
    else
      echo '<span style="color:#aaa"></span>';
  echo '</td>';

  echo '</tr>';

}
echo '</table>';
echo '</div>';

echo '<div class="supergroup">';

echo('<form action="index.php#actual" onsubmit="var tmp=prompt(\'Comment. Why do you request that access?\', this.odb_sys_comment.value); if(tmp==null){return false;}else{this.odb_sys_comment.value=tmp;}" method="post">');
  echo('<input name="odb_run" type="hidden" value="request"></input>'.$context_inputs);
  echo('<input name="odb_search" type="hidden" value="'.$search.'"></input>');
  echo('<input name="odb_trans" type="hidden" value="'.rand(10000000,99999999).'"></input>');

echo '<h2>';
myecho('Access Request Form');
echo '</h2>';


echo '<table>';

  echo '<tr>';
    echo '<td class="label">&nbsp;';
    echo '</td>';
    echo '<td class="label">&nbsp;';
    echo '</td>';
  echo '</tr>';

  echo '<tr>';
    echo '<td class="label" style="width: 100px;">';
      myecho('Username');
    echo '</td>';
    echo '<td class="label">';
      echo USERNAME;
    echo '</td>';
  echo '</tr>';

  echo '<tr>';
    echo '<td class="label">';
      myecho('Bag');
    echo '</td>';
    echo '<td class="input">';
      $show_name='odb_reqbag';
      $variable_name='MyBag';
      echo('<input class="fld_" name="'.$show_name.'" id="'.$show_name.'" type="text" title="'.$show_value.'" onkeydown="new AutoSuggestControl(this, \''.$variable_name.'\', new RemoteStateSuggestions());" value="'.$show_value.'"/>');
    echo '</td>';
  echo '</tr>';

  echo '<tr>';
    echo '<td class="label">';
      myecho('Access');
    echo '</td>';
    echo '<td>';
      echo '<select name="odb_access">';
      echo '<option value="1"></option>';
      echo '<option value="1">Guest (Read only)</option>';
      echo '<option value="2">User (Read, Write)</option>';
      echo '<option value="3">Owner (All rights)</option>';
      echo '</select>';
    echo '</td>';
  echo '</tr>';

  echo '<tr>';
    echo '<td class="label">';
      myecho('Access period');
    echo '</td>';
    echo '<td>';
      echo '<select name="odb_days">';
      echo '<option value="1"></option>';
      echo '<option value="1">1 day</option>';
      echo '<option value="3">3 days</option>';
      echo '<option value="7">7 days</option>';
      echo '<option value="30">30 days</option>';
      echo '</select>';
    echo '</td>';
  echo '</tr>';

  echo '<tr>';
    echo '<td colspan="2" style="text-align: right;">';
      echo('<input class="submit" type="submit" value="OK" />');
    echo '</td>';
  echo '</tr>';

echo '</table>';



echo '</form>';
echo '</div>';

?>
Return current item: OpenBizMap