index.php
changeset 906 c949e82b8f49
parent 900 c5409416b61b
child 907 44851d7e9bda
equal deleted inserted replaced
905:1e40b33f2e3e 906:c949e82b8f49
   327       $template->header();
   327       $template->header();
   328       echo '<div class="menu_nojs" style="width: 150px; padding: 0;"><ul style="display: block;"><li><div class="label">' . $lang->get('ajax_lbl_moreoptions_nojs') . '</div><div style="clear: both;"></div></li>'.$template->toolbar_menu.'</ul></div>';
   328       echo '<div class="menu_nojs" style="width: 150px; padding: 0;"><ul style="display: block;"><li><div class="label">' . $lang->get('ajax_lbl_moreoptions_nojs') . '</div><div style="clear: both;"></div></li>'.$template->toolbar_menu.'</ul></div>';
   329       $template->footer();
   329       $template->footer();
   330       break;
   330       break;
   331     case 'protect':
   331     case 'protect':
   332       if (!isset($_REQUEST['level'])) die_friendly('Invalid request', '<p>No protection level specified</p>');
   332       if ( isset($_POST['level']) && isset($_POST['reason']) )
   333       require_once(ENANO_ROOT.'/includes/pageutils.php');
   333       {
   334       if(!empty($_POST['reason']))
   334         $level = intval($_POST['level']);
   335       {
   335         if ( !in_array($level, array(PROTECT_FULL, PROTECT_SEMI, PROTECT_NONE)) )
   336         if(!preg_match('#^([0-2]*){1}$#', $_POST['level'])) die_friendly('Error protecting page', '<p>Request validation failed</p>');
   336         {
   337         PageUtils::protect($paths->page_id, $paths->namespace, intval($_POST['level']), $_POST['reason']);
   337           $errors[] = 'bad level';
       
   338         }
       
   339         $reason = trim($_POST['reason']);
       
   340         if ( empty($reason) )
       
   341         {
       
   342           $errors[] = $lang->get('onpage_protect_err_need_reason');
       
   343         }
   338         
   344         
   339         die_friendly($lang->get('page_protect_lbl_success_title'), '<p>' . $lang->get('page_protect_lbl_success_body', array( 'page_link' => makeUrl($paths->page) )) . '</p>');
   345         $page = new PageProcessor($paths->page_id, $paths->namespace);
       
   346         $result = $page->protect_page($level, $reason);
       
   347         if ( $result['success'] )
       
   348         {
       
   349           redirect(makeUrl($paths->page), $lang->get('page_protect_lbl_success_title'), $lang->get('page_protect_lbl_success_body', array('page_link' => makeUrl($paths->page, false, true))), 3);
       
   350         }
       
   351         else
       
   352         {
       
   353           $errors[] = $lang->get('page_err_' . $result['error']);
       
   354         }
   340       }
   355       }
   341       $template->header();
   356       $template->header();
   342       ?>
   357       ?>
   343       <form action="<?php echo makeUrl($paths->page, 'do=protect'); ?>" method="post">
   358       <form action="<?php echo makeUrl($paths->page, 'do=protect'); ?>" method="post">
   344         <input type="hidden" name="level" value="<?php echo $_REQUEST['level']; ?>" />
   359         <h3><?php echo $lang->get('onpage_protect_heading'); ?></h3>
   345         <?php if(isset($_POST['reason'])) echo '<p style="color: red;">' . $lang->get('page_protect_err_need_reason') . '</p>'; ?>
   360         <p><?php echo $lang->get('onpage_protect_msg_select_level'); ?></p>
   346         <p><?php echo $lang->get('page_protect_lbl_reason'); ?></p>
   361         
   347         <p><input type="text" name="reason" size="40" /><br />
   362         <?php
   348            <?php echo $lang->get('page_protect_lbl_level'); ?> <b><?php
   363         if ( !empty($errors) )
   349              switch($_REQUEST['level'])
   364         {
   350              {
   365           echo '<ul><li>' . implode('</li><li>', $errors) . '</li></ul>';
   351                case '0':
   366         }
   352                  echo $lang->get('page_protect_lbl_level_none');
   367         ?>
   353                  break;
   368         
   354                case '1':
   369         <div class="protectlevel" style="line-height: 22px; margin-left: 17px;">
   355                  echo $lang->get('page_protect_lbl_level_full');
   370           <label>
   356                  break;
   371             <input type="radio" name="level" value="<?php echo PROTECT_FULL; ?>" />
   357                case '2':
   372             <?php echo gen_sprite(cdnPath . '/images/protect-icons.png', 22, 22, 0, 0); ?>
   358                  echo $lang->get('page_protect_lbl_level_semi');
   373             <?php echo $lang->get('onpage_protect_btn_full'); ?>
   359                  break;
   374           </label>
   360                default:
   375         </div>
   361                  echo 'None;</b> Warning: request validation will fail after clicking submit<b>';
   376         <div class="protectlevel_hint" style="font-size: smaller; margin-left: 68px;">
   362              }
   377           <?php echo $lang->get('onpage_protect_btn_full_hint'); ?>
   363            ?></b></p>
   378         </div>
   364         <p><input type="submit" value="<?php echo htmlspecialchars($lang->get('page_protect_btn_submit')) ?>" style="font-weight: bold;" /></p> 
   379         
       
   380         <div class="protectlevel" style="line-height: 22px; margin-left: 17px;">
       
   381           <label>
       
   382             <input type="radio" name="level" value="<?php echo PROTECT_SEMI; ?>" />
       
   383             <?php echo gen_sprite(cdnPath . '/images/protect-icons.png', 22, 22, 22, 0); ?>
       
   384             <?php echo $lang->get('onpage_protect_btn_semi'); ?>
       
   385           </label>
       
   386         </div>
       
   387         <div class="protectlevel_hint" style="font-size: smaller; margin-left: 68px;">
       
   388           <?php echo $lang->get('onpage_protect_btn_semi_hint'); ?>
       
   389         </div>
       
   390         
       
   391         <div class="protectlevel" style="line-height: 22px; margin-left: 17px;">
       
   392           <label>
       
   393             <input type="radio" name="level" value="<?php echo PROTECT_NONE; ?>" />
       
   394             <?php echo gen_sprite(cdnPath . '/images/protect-icons.png', 22, 22, 44, 0); ?>
       
   395             <?php echo $lang->get('onpage_protect_btn_none'); ?>
       
   396           </label>
       
   397         </div>
       
   398         <div class="protectlevel_hint" style="font-size: smaller; margin-left: 68px;">
       
   399           <?php echo $lang->get('onpage_protect_btn_none_hint'); ?>
       
   400         </div>
       
   401         
       
   402         <table style="margin-left: 1em;" cellspacing="10">
       
   403           <tr>
       
   404             <td valign="top">
       
   405               <?php echo $lang->get('onpage_protect_lbl_reason'); ?>
       
   406             </td>
       
   407             <td>
       
   408               <input type="text" name="reason" size="40" /><br />
       
   409               <small><?php echo $lang->get('onpage_protect_lbl_reason_hint'); ?></small>
       
   410             </td>
       
   411           </tr>
       
   412         </table>
       
   413                               
       
   414         <p>
       
   415           <input type="submit" value="<?php echo htmlspecialchars($lang->get('page_protect_btn_submit')) ?>" style="font-weight: bold;" />
       
   416           <a class="abutton" href="<?php echo makeUrl($paths->page, false, true); ?>"><?php echo $lang->get('etc_cancel'); ?></a>
       
   417         </p> 
   365       </form>
   418       </form>
   366       <?php
   419       <?php
   367       $template->footer();
   420       $template->footer();
   368       break;
   421       break;
   369     case 'rename':
   422     case 'rename':