[ Index ]

PHP Cross Reference of MyBB

title

Body

[close]

/admin/modules/user/ -> group_promotions.php (source)

   1  <?php
   2  /**
   3   * MyBB 1.6
   4   * Copyright 2010 MyBB Group, All Rights Reserved
   5   *
   6   * Website: http://mybb.com
   7   * License: http://mybb.com/about/license
   8   *
   9   * $Id: group_promotions.php 5832 2012-05-24 08:08:19Z Tomm $
  10   */
  11  
  12  // Disallow direct access to this file for security reasons
  13  if(!defined("IN_MYBB"))
  14  {
  15      die("Direct initialization of this file is not allowed.<br /><br />Please make sure IN_MYBB is defined.");
  16  }
  17  
  18  $page->add_breadcrumb_item($lang->user_group_promotions, "index.php?module=user-group_promotions");
  19  
  20  $sub_tabs['usergroup_promotions'] = array(
  21      'title' => $lang->user_group_promotions,
  22      'link' => "index.php?module=user-group_promotions",
  23      'description' => $lang->user_group_promotions_desc
  24  );
  25  
  26  $sub_tabs['add_promotion'] = array(
  27      'title' => $lang->add_new_promotion,
  28      'link' => "index.php?module=user-group_promotions&amp;action=add",
  29      'description' => $lang->add_new_promotion_desc
  30  );
  31  
  32  $sub_tabs['promotion_logs'] = array(
  33      'title' => $lang->view_promotion_logs,
  34      'link' => "index.php?module=user-group_promotions&amp;action=logs",
  35      'description' => $lang->view_promotion_logs_desc
  36  );
  37  
  38  $plugins->run_hooks("admin_user_group_promotions_begin");
  39  
  40  if($mybb->input['action'] == "disable")
  41  {
  42      $plugins->run_hooks("admin_user_group_promotions_disable");
  43  
  44      if($mybb->input['no']) 
  45      { 
  46          admin_redirect("index.php?module=user-group_promotions"); 
  47      }
  48  
  49      if(!trim($mybb->input['pid']))
  50      {
  51          flash_message($lang->error_no_promo_id, 'error');
  52          admin_redirect("index.php?module=user-group_promotions");
  53      }
  54  
  55      $query = $db->simple_select("promotions", "*", "pid='".intval($mybb->input['pid'])."'");
  56      $promotion = $db->fetch_array($query);
  57  
  58      if(!$promotion['pid'])
  59      {
  60          flash_message($lang->error_invalid_promo_id, 'error');
  61          admin_redirect("index.php?module=user-group_promotions");
  62      }
  63  
  64      if($mybb->request_method == "post")
  65      {
  66          $promotion = array(
  67              "enabled" => 0
  68          );
  69  
  70          $db->update_query("promotions", $promotion, "pid = '{$mybb->input['pid']}'");
  71  
  72          $plugins->run_hooks("admin_user_group_promotions_disable_commit");
  73  
  74          // Log admin action
  75          log_admin_action($promotion['pid'], $promotion['title']);
  76  
  77          flash_message($lang->success_promo_disabled, 'success');
  78          admin_redirect("index.php?module=user-group_promotions");
  79      }
  80      else
  81      {
  82          $page->output_confirm_action("index.php?module=user-group_promotions&amp;action=disable&amp;pid={$promotion['pid']}", $lang->confirm_promo_disable); 
  83      }
  84  }
  85  
  86  if($mybb->input['action'] == "delete")
  87  {
  88      $plugins->run_hooks("admin_user_group_promotions_delete");
  89      
  90      if($mybb->input['no']) 
  91      { 
  92          admin_redirect("index.php?module=user-group_promotions"); 
  93      }
  94      
  95      if(!trim($mybb->input['pid']))
  96      {
  97          flash_message($lang->error_no_promo_id, 'error');
  98          admin_redirect("index.php?module=user-group_promotions");
  99      }
 100      
 101      $query = $db->simple_select("promotions", "*", "pid='".intval($mybb->input['pid'])."'");
 102      $promotion = $db->fetch_array($query);
 103  
 104      if(!$promotion['pid'])
 105      {
 106          flash_message($lang->error_invalid_promo_id, 'error');
 107          admin_redirect("index.php?module=user-group_promotions");
 108      }
 109      
 110      if($mybb->request_method == "post")
 111      {
 112          $db->delete_query("promotions", "pid = '{$mybb->input['pid']}'");
 113          
 114          $plugins->run_hooks("admin_user_group_promotions_delete_commit");
 115  
 116          // Log admin action
 117          log_admin_action($promotion['pid'], $promotion['title']);
 118  
 119          flash_message($lang->success_promo_deleted, 'success');
 120          admin_redirect("index.php?module=user-group_promotions");
 121      }
 122      else
 123      {
 124          $page->output_confirm_action("index.php?module=user-group_promotions&amp;action=delete&amp;pid={$mybb->input['pid']}", $lang->confirm_promo_deletion); 
 125      }
 126  }
 127  
 128  if($mybb->input['action'] == "enable")
 129  {
 130      $plugins->run_hooks("admin_user_group_promotions_enable");
 131  
 132      if(!verify_post_check($mybb->input['my_post_key']))
 133      {
 134          flash_message($lang->invalid_post_verify_key2, 'error');
 135          admin_redirect("index.php?module=user-group_promotions");
 136      }
 137  
 138      if(!trim($mybb->input['pid']))
 139      {
 140          flash_message($lang->error_no_promo_id, 'error');
 141          admin_redirect("index.php?module=user-group_promotions");
 142      }
 143      
 144      $query = $db->simple_select("promotions", "*", "pid='".intval($mybb->input['pid'])."'");
 145      $promotion = $db->fetch_array($query);
 146  
 147      if(!$promotion['pid'])
 148      {
 149          flash_message($lang->error_invalid_promo_id, 'error');
 150          admin_redirect("index.php?module=user-group_promotions");
 151      }
 152  
 153      $promotion = array(
 154          "enabled" => 1
 155      );
 156      
 157      $db->update_query("promotions", $promotion, "pid = '{$mybb->input['pid']}'");
 158      
 159      $plugins->run_hooks("admin_user_group_promotions_enable_commit");
 160  
 161      // Log admin action
 162      log_admin_action($promotion['pid'], $promotion['title']);
 163  
 164      flash_message($lang->success_promo_enabled, 'success');
 165      admin_redirect("index.php?module=user-group_promotions");
 166  }
 167  
 168  if($mybb->input['action'] == "edit")
 169  {
 170      $plugins->run_hooks("admin_user_group_promotions_edit");
 171      
 172      if(!trim($mybb->input['pid']))
 173      {
 174          flash_message($lang->error_no_promo_id, 'error');
 175          admin_redirect("index.php?module=user-group_promotions");
 176      }
 177      
 178      $query = $db->simple_select("promotions", "*", "pid = '{$mybb->input['pid']}'");
 179      $promotion = $db->fetch_array($query);
 180      
 181      if(!$promotion)
 182      {
 183          flash_message($lang->error_invalid_promo_id, 'error');
 184          admin_redirect("index.php?module=user-group_promotions");
 185      }
 186      
 187      if($mybb->request_method == "post")
 188      {
 189          if(!trim($mybb->input['title']))
 190          {
 191              $errors[] = $lang->error_no_title;
 192          }
 193  
 194          if(!trim($mybb->input['description']))
 195          {
 196              $errors[] = $lang->error_no_desc;
 197          }
 198          
 199          if(empty($mybb->input['requirements']))
 200          {
 201              $errors[] = $lang->error_no_requirements;
 202          }
 203  
 204          if(empty($mybb->input['originalusergroup']))
 205          {
 206              $errors[] = $lang->error_no_orig_usergroup;
 207          }
 208          
 209          if(!trim($mybb->input['newusergroup']))
 210          {
 211              $errors[] = $lang->error_no_new_usergroup;
 212          }
 213  
 214          if(!trim($mybb->input['usergroupchangetype']))
 215          {
 216              $errors[] = $lang->error_no_usergroup_change_type;
 217          }
 218  
 219          if(!$errors)
 220          {
 221              if(in_array('*', $mybb->input['originalusergroup']))
 222              {
 223                  $mybb->input['originalusergroup'] = '*';
 224              }
 225              else
 226              {
 227                  $mybb->input['originalusergroup'] = implode(',', array_map('intval', $mybb->input['originalusergroup']));
 228              }
 229              
 230              $update_promotion = array(
 231                  "title" => $db->escape_string($mybb->input['title']),
 232                  "description" => $db->escape_string($mybb->input['description']),
 233                  "posts" => intval($mybb->input['postcount']),
 234                  "posttype" => $db->escape_string($mybb->input['posttype']),
 235                  "registered" => intval($mybb->input['timeregistered']),
 236                  "registeredtype" => $db->escape_string($mybb->input['timeregisteredtype']),
 237                  "reputations" => intval($mybb->input['reputationcount']),
 238                  "reputationtype" => $db->escape_string($mybb->input['reputationtype']),
 239                  "referrals" => intval($mybb->input['referrals']),
 240                  "referralstype" => $db->escape_string($mybb->input['referralstype']),
 241                  "requirements" => $db->escape_string(implode(",", $mybb->input['requirements'])),
 242                  "originalusergroup" => $db->escape_string($mybb->input['originalusergroup']),
 243                  "newusergroup" => intval($mybb->input['newusergroup']),
 244                  "usergrouptype" => $db->escape_string($mybb->input['usergroupchangetype']),
 245                  "enabled" => intval($mybb->input['enabled']),
 246                  "logging" => intval($mybb->input['logging'])
 247              );
 248              
 249              $db->update_query("promotions", $update_promotion, "pid = '".intval($mybb->input['pid'])."'");
 250              
 251              $plugins->run_hooks("admin_user_group_promotions_edit_commit");
 252  
 253              // Log admin action
 254              log_admin_action($promotion['pid'], $mybb->input['title']);
 255  
 256              flash_message($lang->success_promo_updated, 'success');
 257              admin_redirect("index.php?module=user-group_promotions");
 258          }
 259      }
 260      
 261      $page->add_breadcrumb_item($lang->edit_promotion);
 262      $page->output_header($lang->user_group_promotions." - ".$lang->edit_promotion);
 263  
 264      $sub_tabs = array();
 265      $sub_tabs['edit_promotion'] = array(
 266          'title' => $lang->edit_promotion,
 267          'link' => "index.php?module=user-group_promotions&amp;action=edit",
 268          'description' => $lang->edit_promotion_desc
 269      );
 270  
 271      $page->output_nav_tabs($sub_tabs, 'edit_promotion');
 272      $form = new Form("index.php?module=user-group_promotions&amp;action=edit", "post", "edit");
 273      echo $form->generate_hidden_field("pid", $mybb->input['pid']);
 274      if($errors)
 275      {
 276          $page->output_inline_error($errors);
 277      }
 278      else
 279      {
 280          $mybb->input['title'] = $promotion['title'];
 281          $mybb->input['description'] = $promotion['description'];
 282          $mybb->input['requirements'] = explode(',', $promotion['requirements']);
 283          $mybb->input['reputationcount'] = $promotion['reputations'];
 284          $mybb->input['reputationtype'] = $promotion['reputationtype'];
 285          $mybb->input['postcount'] = $promotion['posts'];
 286          $mybb->input['posttype'] = $promotion['posttype'];
 287          $mybb->input['referrals'] = $promotion['referrals'];
 288          $mybb->input['referralstype'] = $promotion['referralstype'];
 289          $mybb->input['timeregistered'] = $promotion['registered'];
 290          $mybb->input['timeregisteredtype'] = $promotion['registeredtype'];
 291          $mybb->input['originalusergroup'] = explode(',', $promotion['originalusergroup']);
 292          $mybb->input['usergroupchangetype'] = $promotion['usergrouptype'];
 293          $mybb->input['newusergroup'] = $promotion['newusergroup'];
 294          $mybb->input['enabled'] = $promotion['enabled'];
 295          $mybb->input['logging'] = $promotion['logging'];
 296      }
 297      
 298      $form_container = new FormContainer($lang->edit_promotion);
 299      $form_container->output_row($lang->title." <em>*</em>", "", $form->generate_text_box('title', $mybb->input['title'], array('id' => 'title')), 'title');
 300      $form_container->output_row($lang->short_desc." <em>*</em>", "", $form->generate_text_box('description', $mybb->input['description'], array('id' => 'description')), 'description');
 301  
 302      $options = array(
 303          "postcount" => $lang->post_count,
 304          "reputation" => $lang->reputation,
 305          "referrals" => $lang->referrals,
 306          "timeregistered" => $lang->time_registered
 307      );
 308      
 309      $form_container->output_row($lang->promo_requirements." <em>*</em>", $lang->promo_requirements_desc, $form->generate_select_box('requirements[]', $options, $mybb->input['requirements'], array('id' => 'requirements', 'multiple' => true, 'size' => 3)), 'requirements');
 310      
 311      $options_type = array(
 312          ">" => $lang->greater_than,
 313          ">=" => $lang->greater_than_or_equal_to,
 314          "=" => $lang->equal_to,
 315          "<=" => $lang->less_than_or_equal_to,
 316          "<" => $lang->less_than
 317      );
 318      
 319      $form_container->output_row($lang->post_count, $lang->post_count_desc, $form->generate_text_box('postcount', $mybb->input['postcount'], array('id' => 'postcount'))." ".$form->generate_select_box("posttype", $options_type, $mybb->input['posttype'], array('id' => 'posttype')), 'postcount');
 320      
 321      $form_container->output_row($lang->reputation_count, $lang->reputation_count_desc, $form->generate_text_box('reputationcount', $mybb->input['reputationcount'], array('id' => 'reputationcount'))." ".$form->generate_select_box("reputationtype", $options_type, $mybb->input['reputationtype'], array('id' => 'reputationtype')), 'reputationcount');
 322      
 323      $options = array(
 324          "hours" => $lang->hours,
 325          "days" => $lang->days,
 326          "weeks" => $lang->weeks,
 327          "months" => $lang->months,
 328          "years" => $lang->years
 329      );
 330      
 331      $form_container->output_row($lang->referral_count, $lang->referral_count_desc, $form->generate_text_box('referrals', $mybb->input['referrals'], array('id' => 'referrals'))." ".$form->generate_select_box("referralstype", $options_type, $mybb->input['referralstype'], array('id' => 'referralstype')), 'referrals');
 332      
 333      $form_container->output_row($lang->time_registered, $lang->time_registered_desc, $form->generate_text_box('timeregistered', $mybb->input['timeregistered'], array('id' => 'timeregistered'))." ".$form->generate_select_box("timeregisteredtype", $options, $mybb->input['timeregisteredtype'], array('id' => 'timeregisteredtype')), 'timeregistered');
 334      
 335      $options = array();
 336      
 337      $query = $db->simple_select("usergroups", "gid, title", "gid != '1'", array('order_by' => 'title'));
 338      while($usergroup = $db->fetch_array($query))
 339      {
 340          $options[(int)$usergroup['gid']] = $usergroup['title'];
 341      }
 342  
 343      $form_container->output_row($lang->orig_user_group." <em>*</em>", $lang->orig_user_group_desc, $form->generate_select_box('originalusergroup[]', $options, $mybb->input['originalusergroup'], array('id' => 'originalusergroup', 'multiple' => true, 'size' => 5)), 'originalusergroup');
 344      
 345      unset($options['*']); // Remove the all usergroups option
 346      $form_container->output_row($lang->new_user_group." <em>*</em>", $lang->new_user_group_desc, $form->generate_select_box('newusergroup', $options, $mybb->input['newusergroup'], array('id' => 'newusergroup')), 'newusergroup');
 347  
 348      $options = array(
 349          'primary' => $lang->primary_user_group,
 350          'secondary' => $lang->secondary_user_group
 351      );
 352      
 353      $form_container->output_row($lang->user_group_change_type." <em>*</em>", $lang->user_group_change_type_desc, $form->generate_select_box('usergroupchangetype', $options, $mybb->input['usergroupchangetype'], array('id' => 'usergroupchangetype')), 'usergroupchangetype');
 354  
 355      $form_container->output_row($lang->enabled." <em>*</em>", "", $form->generate_yes_no_radio("enabled", $mybb->input['enabled'], true));
 356      
 357      $form_container->output_row($lang->enable_logging." <em>*</em>", "", $form->generate_yes_no_radio("logging", $mybb->input['logging'], true));
 358      $form_container->end();
 359  
 360      $buttons[] = $form->generate_submit_button($lang->update_promotion);
 361  
 362      $form->output_submit_wrapper($buttons);
 363      $form->end();
 364  
 365      $page->output_footer();
 366  }
 367  
 368  if($mybb->input['action'] == "add")
 369  {
 370      $plugins->run_hooks("admin_user_group_promotions_add");
 371      
 372      if($mybb->request_method == "post")
 373      {
 374          if(!trim($mybb->input['title']))
 375          {
 376              $errors[] = $lang->error_no_title;
 377          }
 378  
 379          if(!trim($mybb->input['description']))
 380          {
 381              $errors[] = $lang->error_no_desc;
 382          }
 383          
 384          if(empty($mybb->input['requirements']))
 385          {
 386              $errors[] = $lang->error_no_requirements;
 387          }
 388  
 389          if(empty($mybb->input['originalusergroup']))
 390          {
 391              $errors[] = $lang->error_no_orig_usergroup;
 392          }
 393          
 394          if(!trim($mybb->input['newusergroup']))
 395          {
 396              $errors[] = $lang->error_no_new_usergroup;
 397          }
 398          
 399          if(!trim($mybb->input['usergroupchangetype']))
 400          {
 401              $errors[] = $lang->error_no_usergroup_change_type;
 402          }
 403          
 404          if(!$errors)
 405          {
 406              if(in_array('*', $mybb->input['originalusergroup']))
 407              {
 408                  $mybb->input['originalusergroup'] = '*';
 409              }
 410              else
 411              {
 412                  $mybb->input['originalusergroup'] = implode(',', array_map('intval', $mybb->input['originalusergroup']));
 413              }
 414              
 415              $new_promotion = array(
 416                  "title" => $db->escape_string($mybb->input['title']),
 417                  "description" => $db->escape_string($mybb->input['description']),
 418                  "posts" => intval($mybb->input['postcount']),
 419                  "posttype" => $db->escape_string($mybb->input['posttype']),
 420                  "registered" => intval($mybb->input['timeregistered']),
 421                  "registeredtype" => $db->escape_string($mybb->input['timeregisteredtype']),
 422                  "reputations" => intval($mybb->input['reputationcount']),
 423                  "reputationtype" => $db->escape_string($mybb->input['reputationtype']),
 424                  "referrals" => intval($mybb->input['referrals']),
 425                  "referralstype" => $db->escape_string($mybb->input['referralstype']),
 426                  "requirements" => $db->escape_string(implode(",", $mybb->input['requirements'])),
 427                  "originalusergroup" => $db->escape_string($mybb->input['originalusergroup']),
 428                  "usergrouptype" => $db->escape_string($mybb->input['usergroupchangetype']),
 429                  "newusergroup" => intval($mybb->input['newusergroup']),
 430                  "enabled" => intval($mybb->input['enabled']),
 431                  "logging" => intval($mybb->input['logging'])
 432              );
 433              
 434              $pid = $db->insert_query("promotions", $new_promotion);
 435              
 436              $plugins->run_hooks("admin_user_group_promotions_add_commit");
 437  
 438              // Log admin action
 439              log_admin_action($pid, $mybb->input['title']);
 440              
 441              flash_message($lang->success_promo_added, 'success');
 442              admin_redirect("index.php?module=user-group_promotions");
 443          }
 444      }
 445      $page->add_breadcrumb_item($lang->add_new_promotion);
 446      $page->output_header($lang->user_group_promotions." - ".$lang->add_new_promotion);
 447      
 448      $sub_tabs['usergroup_promotions'] = array(
 449          'title' => $lang->user_group_promotions,
 450          'link' => "index.php?module=user-group_promotions"
 451      );
 452  
 453      $sub_tabs['add_promotion'] = array(
 454          'title' => $lang->add_new_promotion,
 455          'link' => "index.php?module=user-group_promotions&amp;action=add",
 456          'description' => $lang->add_new_promotion_desc
 457      );
 458  
 459      $sub_tabs['promotion_logs'] = array(
 460          'title' => $lang->view_promotion_logs,
 461          'link' => "index.php?module=user-group_promotions&amp;action=logs"
 462      );
 463  
 464      $page->output_nav_tabs($sub_tabs, 'add_promotion');
 465      $form = new Form("index.php?module=user-group_promotions&amp;action=add", "post", "add");
 466      if($errors)
 467      {
 468          $page->output_inline_error($errors);
 469      }
 470      else
 471      {
 472          $mybb->input['reputationcount'] = '0';
 473          $mybb->input['referrals'] = '0';
 474          $mybb->input['postcount'] = '0';
 475          $mybb->input['timeregistered'] = '0';
 476          $mybb->input['timeregisteredtype'] = 'days';
 477          $mybb->input['originalusergroup'] = '*';
 478          $mybb->input['newusergroup'] = '2';
 479          $mybb->input['enabled'] = '1';
 480          $mybb->input['logging'] = '1';
 481      }
 482      $form_container = new FormContainer($lang->add_new_promotion);
 483      $form_container->output_row($lang->title." <em>*</em>", "", $form->generate_text_box('title', $mybb->input['title'], array('id' => 'title')), 'title');
 484      $form_container->output_row($lang->short_desc." <em>*</em>", "", $form->generate_text_box('description', $mybb->input['description'], array('id' => 'description')), 'description');
 485  
 486      $options = array(
 487          "postcount" => $lang->post_count,
 488          "reputation" => $lang->reputation,
 489          "referrals" => $lang->referrals,
 490          "timeregistered" => $lang->time_registered
 491      );
 492      
 493      $form_container->output_row($lang->promo_requirements." <em>*</em>", $lang->promo_requirements_desc, $form->generate_select_box('requirements[]', $options, $mybb->input['requirements'], array('id' => 'requirements', 'multiple' => true, 'size' => 4)), 'requirements');
 494      
 495      $options_type = array(
 496          ">" => $lang->greater_than,
 497          ">=" => $lang->greater_than_or_equal_to,
 498          "=" => $lang->equal_to,
 499          "<=" => $lang->less_than_or_equal_to,
 500          "<" => $lang->less_than
 501      );
 502      
 503      $form_container->output_row($lang->post_count, $lang->post_count_desc, $form->generate_text_box('postcount', $mybb->input['postcount'], array('id' => 'postcount'))." ".$form->generate_select_box("posttype", $options_type, $mybb->input['posttype'], array('id' => 'posttype')), 'postcount');
 504      
 505      $form_container->output_row($lang->reputation_count, $lang->reputation_count_desc, $form->generate_text_box('reputationcount', $mybb->input['reputationcount'], array('id' => 'reputationcount'))." ".$form->generate_select_box("reputationtype", $options_type, $mybb->input['reputationtype'], array('id' => 'reputationtype')), 'reputationcount');
 506      
 507      $options = array(
 508          "hours" => $lang->hours,
 509          "days" => $lang->days,
 510          "weeks" => $lang->weeks,
 511          "months" => $lang->months,
 512          "years" => $lang->years
 513      );
 514      
 515      $form_container->output_row($lang->referral_count, $lang->referral_count_desc, $form->generate_text_box('referrals', $mybb->input['referrals'], array('id' => 'referrals'))." ".$form->generate_select_box("referralstype", $options_type, $mybb->input['referralstype'], array('id' => 'referralstype')), 'referrals');
 516      
 517      $form_container->output_row($lang->time_registered, $lang->time_registered_desc, $form->generate_text_box('timeregistered', $mybb->input['timeregistered'], array('id' => 'timeregistered'))." ".$form->generate_select_box("timeregisteredtype", $options, $mybb->input['timeregisteredtype'], array('id' => 'timeregisteredtype')), 'timeregistered');
 518      $options = array();
 519      
 520      $query = $db->simple_select("usergroups", "gid, title", "gid != '1'", array('order_by' => 'title'));
 521      while($usergroup = $db->fetch_array($query))
 522      {
 523          $options[(int)$usergroup['gid']] = $usergroup['title'];
 524      }
 525  
 526      $form_container->output_row($lang->orig_user_group." <em>*</em>", $lang->orig_user_group_desc, $form->generate_select_box('originalusergroup[]', $options, $mybb->input['originalusergroup'], array('id' => 'originalusergroup', 'multiple' => true, 'size' => 5)), 'originalusergroup');
 527  
 528      unset($options['*']);
 529      $form_container->output_row($lang->new_user_group." <em>*</em>", $lang->new_user_group_desc, $form->generate_select_box('newusergroup', $options, $mybb->input['newusergroup'], array('id' => 'newusergroup')), 'newusergroup');
 530      
 531      $options = array(
 532          'primary' => $lang->primary_user_group,
 533          'secondary' => $lang->secondary_user_group
 534      );
 535      
 536      $form_container->output_row($lang->user_group_change_type." <em>*</em>", $lang->user_group_change_type_desc, $form->generate_select_box('usergroupchangetype', $options, $mybb->input['usergroupchangetype'], array('id' => 'usergroupchangetype')), 'usergroupchangetype');
 537      
 538      $form_container->output_row($lang->enabled." <em>*</em>", "", $form->generate_yes_no_radio("enabled", $mybb->input['enabled'], true));
 539      
 540      $form_container->output_row($lang->enable_logging." <em>*</em>", "", $form->generate_yes_no_radio("logging", $mybb->input['logging'], true));
 541      $form_container->end();
 542  
 543      $buttons[] = $form->generate_submit_button($lang->update_promotion);
 544  
 545      $form->output_submit_wrapper($buttons);
 546      $form->end();
 547  
 548      $page->output_footer();
 549  }
 550  
 551  if($mybb->input['action'] == "logs")
 552  {
 553      $plugins->run_hooks("admin_user_group_promotions_logs");
 554      
 555      if($mybb->input['page'] && $mybb->input['page'] > 1)
 556      {
 557          $mybb->input['page'] = intval($mybb->input['page']);
 558          $start = ($mybb->input['page']*20)-20;
 559      }
 560      else
 561      {
 562          $mybb->input['page'] = 1;
 563          $start = 0;
 564      }
 565      
 566      $page->add_breadcrumb_item($lang->promotion_logs);
 567      $page->output_header($lang->user_group_promotions." - ".$lang->promotion_logs);
 568      
 569      $page->output_nav_tabs($sub_tabs, 'promotion_logs');
 570  
 571      $table = new Table;
 572      $table->construct_header($lang->promoted_user, array("class" => "align_center", "width" => '20%'));
 573      $table->construct_header($lang->user_group_change_type, array("class" => "align_center", "width" => '20%'));
 574      $table->construct_header($lang->orig_user_group, array("class" => "align_center", "width" => '20%'));
 575      $table->construct_header($lang->new_user_group, array("class" => "align_center", "width" => '20%'));
 576      $table->construct_header($lang->time_promoted, array("class" => "align_center", "width" => '20%'));
 577  
 578      $query = $db->query("
 579          SELECT pl.*,u.username
 580          FROM ".TABLE_PREFIX."promotionlogs pl
 581          LEFT JOIN ".TABLE_PREFIX."users u ON (u.uid=pl.uid)
 582          ORDER BY dateline DESC 
 583          LIMIT {$start}, 20
 584      ");
 585      while($log = $db->fetch_array($query))
 586      {
 587          $log['username'] = "<a href=\"index.php?module=user-view&amp;action=edit&amp;uid={$log['uid']}\">".htmlspecialchars_uni($log['username'])."</a>";
 588          
 589          if($log['type'] == "secondary" || (!empty($log['oldusergroup']) && strstr(",", $log['oldusergroup'])))
 590          {
 591              $log['oldusergroup'] = "<i>".$lang->multiple_usergroups."</i>";
 592              $log['newusergroup'] = htmlspecialchars_uni($groupscache[$log['newusergroup']]['title']);
 593          }
 594          else
 595          {
 596              $log['oldusergroup'] = htmlspecialchars_uni($groupscache[$log['oldusergroup']]['title']);
 597              $log['newusergroup'] = htmlspecialchars_uni($groupscache[$log['newusergroup']]['title']);
 598          }
 599          
 600          if($log['type'] == "secondary")
 601          {
 602              $log['type'] = $lang->secondary;
 603          }
 604          else
 605          {
 606              $log['type'] = $lang->primary;
 607          }
 608          
 609          $log['dateline'] = date($mybb->settings['dateformat'], $log['dateline']).", ".date($mybb->settings['timeformat'], $log['dateline']);
 610          $table->construct_cell($log['username']);
 611          $table->construct_cell($log['type'], array('style' => 'text-align: center;'));
 612          $table->construct_cell($log['oldusergroup'], array('style' => 'text-align: center;'));
 613          $table->construct_cell($log['newusergroup'], array('style' => 'text-align: center;'));
 614          $table->construct_cell($log['dateline'], array('style' => 'text-align: center;'));
 615          $table->construct_row();
 616      }
 617      
 618      if($table->num_rows() == 0)
 619      {
 620          $table->construct_cell($lang->no_promotion_logs, array("colspan" => "5"));
 621          $table->construct_row();
 622      }
 623      
 624      $table->output($lang->promotion_logs);
 625      
 626      $query = $db->simple_select("promotionlogs", "COUNT(plid) as promotionlogs");
 627      $total_rows = $db->fetch_field($query, "promotionlogs");
 628      
 629      echo "<br />".draw_admin_pagination($mybb->input['page'], "20", $total_rows, "index.php?module=user-group_promotions&amp;action=logs&amp;page={page}");
 630      
 631      $page->output_footer();
 632  }
 633  
 634  if(!$mybb->input['action'])
 635  {
 636      $plugins->run_hooks("admin_user_group_promotions_start");
 637      
 638      $page->output_header($lang->promotion_manager);
 639      
 640      $page->output_nav_tabs($sub_tabs, 'usergroup_promotions');
 641  
 642      $table = new Table;
 643      $table->construct_header($lang->promotion);
 644      $table->construct_header($lang->controls, array("class" => "align_center", "width" => 150));
 645  
 646      $query = $db->simple_select("promotions", "*", "", array("order_by" => "title", "order_dir" => "asc"));
 647      while($promotion = $db->fetch_array($query))
 648      {
 649          $promotion['title'] = htmlspecialchars_uni($promotion['title']);
 650          $promotion['description'] = htmlspecialchars_uni($promotion['description']);
 651          $table->construct_cell("<div><strong><a href=\"index.php?module=user-group_promotions&amp;action=edit&amp;pid={$promotion['pid']}\">{$promotion['title']}</a></strong><br /><small>{$promotion['description']}</small></div>");
 652  
 653          $popup = new PopupMenu("promotion_{$promotion['pid']}", $lang->options);
 654          $popup->add_item($lang->edit_promotion, "index.php?module=user-group_promotions&amp;action=edit&amp;pid={$promotion['pid']}");
 655          if($promotion['enabled'] == 1)
 656          {
 657              $popup->add_item($lang->disable_promotion, "index.php?module=user-group_promotions&amp;action=disable&amp;pid={$promotion['pid']}&amp;my_post_key={$mybb->post_code}", "return AdminCP.deleteConfirmation(this, '{$lang->confirm_promo_disable}')");
 658          }
 659          else
 660          {
 661              $popup->add_item($lang->enable_promotion, "index.php?module=user-group_promotions&amp;action=enable&amp;pid={$promotion['pid']}&amp;my_post_key={$mybb->post_code}");
 662          }
 663          $popup->add_item($lang->delete_promotion, "index.php?module=user-group_promotions&amp;action=delete&amp;pid={$promotion['pid']}&amp;my_post_key={$mybb->post_code}", "return AdminCP.deleteConfirmation(this, '{$lang->confirm_promo_deletion}')");
 664          $table->construct_cell($popup->fetch(), array("class" => "align_center"));
 665          $table->construct_row();
 666      }
 667      
 668      if($table->num_rows() == 0)
 669      {
 670          $table->construct_cell($lang->no_promotions_set, array("colspan" => "2"));
 671          $table->construct_row();
 672      }
 673      
 674      $table->output($lang->user_group_promotions);
 675      
 676      $page->output_footer();
 677  }
 678  ?>


Generated: Tue Oct 8 19:19:50 2013 Cross-referenced by PHPXref 0.7.1