home *** CD-ROM | disk | FTP | other *** search
/ ftp.f-secure.com / 2014.06.ftp.f-secure.com.tar / ftp.f-secure.com / support / hotfix / fsav-server / FSAVSRV900_HF07.fsfix / iuwebui / forms / tree_fsma / templates.php < prev   
PHP Script  |  2010-09-07  |  6KB  |  157 lines

  1. <?php 
  2.     include ("..\common\commonphp.php");
  3.  
  4.     $Page_Settings = array(    array(oid => '1.3.6.1.4.1.2213.20.1.100.40.20', type => GLOBAL_TBL));
  5.     
  6.     $oid_base = '1.3.6.1.4.1.2213.20.1';
  7.     
  8.     $Page_Affected_Settings = array(
  9.         '100.50.120', 
  10.  
  11.         '200.10.10.210', '200.10.10.260', '200.10.20.210', '200.10.20.260', 
  12.         '200.10.50.210', '200.10.50.220', '200.10.60.210', '200.10.60.260', 
  13.         '200.20.10.210', '200.20.10.260', '200.20.20.210', '200.20.20.260', 
  14.         '200.20.50.210', '200.20.50.220', '200.20.60.210', '200.20.60.260', 
  15.         '200.30.10.210', '200.30.10.260', '200.30.20.210', '200.30.20.260', 
  16.         '200.30.50.210', '200.30.50.220', '200.30.60.210', '200.30.60.260', 
  17.  
  18.         '300.10.20.340', '300.10.50.200', '300.30.10.140', '300.30.20.140', 
  19.         '300.30.50.200'
  20.     );
  21.  
  22.     $tab_name = "tabFSMATemplates";
  23.     
  24.     $AFFECTED = array();
  25.     
  26.     if(!isset($_POST[SUBMIT_TABLE]))
  27.     {
  28.         /* first load of the page */
  29.         readSettings(&$Page_Settings);
  30.         foreach($Page_Affected_Settings as $entry)
  31.         {
  32.             settings_get_str($oid_base . '.' . $entry, &$value);
  33.             if($value != '')
  34.                 $AFFECTED[$value] = 1;
  35.         }
  36.         // not allowed to remove defaults
  37.         $PageDefSettings = array();
  38.         settings_get_default_table($Page_Settings[0][oid], &$PageDefSettings);        
  39.         foreach($PageDefSettings as $entry)
  40.             if($entry[1] != '')
  41.                 $AFFECTED[$entry[1]] = 2;
  42.     //    print_r($AFFECTED);
  43.     }
  44.     else 
  45.     {
  46.         if($_POST[RESTORE_TABLE] == 1)
  47.         {
  48.             readDefaultSettings(&$Page_Settings);
  49.         }
  50.         else
  51.         {
  52.             readSettings(&$Page_Settings);
  53.             if($_POST[REMOVE_ITEM] != -1)
  54.             {
  55.                 foreach ($Page_Settings[0][value] as $next_row) 
  56.                     $sortarr[] = $next_row[1];
  57.                 array_multisort($sortarr, $Page_Settings[0][value]);
  58.                  unset($Page_Settings[0][value][$_POST[REMOVE_ITEM]]);
  59.             }
  60.             writeSettings($Page_Settings);
  61.         }
  62.         exit(0);
  63.     }
  64.     show_form_management($tab_name);
  65.     foreach ($Page_Settings[0][value] as $next_row) 
  66.         $sortarr[] = $next_row[1];
  67.     array_multisort($sortarr, $Page_Settings[0][value]);
  68. ?>
  69.  
  70. <script language="javascript">
  71.     
  72.     var templates = new Array();
  73.     var templatesReserved = new Array();
  74. <?php 
  75.     $index = 0;
  76.     foreach($AFFECTED as $key => $entry)
  77.         echo "templatesReserved[" . $index++ . "] = ".EscapeJSCodeString($key).";\n";
  78.     $index = 0;
  79.     foreach($Page_Settings[0][value] as $entry)
  80.         echo "templates[" . $index++ . "] = ".EscapeJSCodeString($entry[1]).";\n";
  81. ?>
  82.     tabFSMATemplates_remove_hit = function(item_index)
  83.     {
  84.         if(have_such_entry_simple(templatesReserved, templates[item_index]))
  85.         {    
  86.             show_webui_message_box(localized_strings.Warning, localized_strings.RemoveTemplateConfirmation, 0);
  87.             return;
  88.         }
  89.         refreshed = true;
  90.         document.form_<?php echo $tab_name;?>.REMOVE_ITEM.value = item_index;
  91.         dojo.byId("tabFSMATemplates_submitit").click();
  92.     }
  93. </script>
  94.  
  95.  
  96. <form method="POST" action='<?php echo "{$_SERVER['PHP_SELF']}?{$_SERVER['QUERY_STRING']}";?>' id="form_<?php echo $tab_name;?>" name="form_<?php echo $tab_name;?>" style="padding: 0; margin: 0;">
  97.     <input type="hidden" name="RESTORE_TABLE" value="0">
  98.     <input type="hidden" name="SUBMIT_TABLE" value="0">
  99.     <input type="hidden" name="APPLY_SETTINGS" value="0">
  100.     <input type="hidden" name="REMOVE_ITEM" value="-1">
  101.     
  102.     <button style='display:none' type='submit' id='tabFSMATemplates_submitit'></button>
  103.  
  104.     <?php show_action_menu('Templates', $tab_name); ?>
  105.     <table border=0 cellspacing="5" cellpadding="0">
  106.         <tr valign=top>
  107.             <td valign="top" style="padding: 5px;">
  108.  
  109.             <table style="table-layout:fixed;" border=0 cellpadding=0 cellspacing=0 bordercolorlight=D4D0C8>
  110.                 <tr>
  111.                     <td width="10px"><div class="table_stats_heading"><img src="../pics/layout/corner_up_left.gif" alt="" class="left_top"/></div></td>
  112.                     <td align="left"><div class="table_stats_heading"><span><?php echo $Page_Settings[0][lock] . fsloc('Name')?></span></div></td>
  113.                     <td align="left" width=370><div class="table_stats_heading"><span><?=fsloc('Subject')?></span></div></td>
  114.                     <td align="right" nowrap><div class="table_stats_heading"><span><?php echo ($global_can_edit && !isset($Page_Settings[0][lock]) ? "<a href='javascript:;' onClick='EnableTemplateDialog(\"NewItem\", \"\");'>" . fsloc('Add new item...') . "</a>" : ' ');?></span></div></td>
  115.                     <td width="10px"><div class="table_stats_heading"><img src="../pics/layout/corner_up_right.gif" alt="" class="right_top"/></div></td>
  116.                 </tr>
  117. <?php    
  118.         $index = 0;
  119.         $editable_as_word = $global_can_edit && !isset($Page_Settings[0][lock]) ? 'Edit' : 'View';
  120.         $tr_type = '';
  121.         foreach($Page_Settings[0][value] as $entry)
  122.         {
  123.             $tr_type = ($tr_type == '_odd') ? '_even' : '_odd';
  124.             $remove_text = ' ';
  125.             $oper_mode = $editable_as_word . 'ItemDefault';
  126.             $font_color = $entry[0] ? '' : ' color: #999999; ';
  127.                 
  128.             if($AFFECTED[$entry[1]] != 2 && $global_can_edit && !isset($Page_Settings[0][lock]))
  129.             {
  130.                 $remove_text = "<a href='javascript:;' onClick='javascript: tabFSMATemplates_remove_hit({$index});'>" . fsloc('remove') . "</a>";
  131.                 $oper_mode = isset($AFFECTED[$entry[1]]) ? 'EditItemLimited' : 'EditItemFull';
  132.             }
  133.             echo "
  134.                     <tr class='tr_setting$tr_type' style='height: 45px;'>
  135.                     <td></td>
  136.                     <td style='padding-left: 5px;'>
  137.                         <a href='javascript:;' 
  138.                                 onClick='javascript: EnableTemplateDialog(\"{$oper_mode}\", ".EscapeJSCodeString($entry[1]).");' 
  139.                                 title='".htmlspecialchars($entry[4], ENT_QUOTES)."'>
  140.                             ".htmlspecialchars($entry[1])."
  141.                         </a>
  142.                     </td>
  143.                     <td style='padding-left: 10px; $font_color'>".htmlspecialchars($entry[2])."</td>
  144.                     <td align='right' style='padding-left: 5px; $font_color'>$remove_text</td>
  145.                     <td> </td>
  146.                 </tr>
  147.             ";    
  148.             $index++;
  149.         }
  150. ?>
  151.  
  152.             </table>
  153.             </td>
  154.         </tr>
  155.         <?php show_action_buttons($tab_name, true, true); ?>
  156.     </table>
  157. </form>