applications/dashboard/controllers/class.utilitycontroller.php
public function Sort() {
      $this->Permission('Garden.Settings.Manage');
      
      $Session = Gdn::Session();
      $TransientKey = GetPostValue('TransientKey', '');
      $Target = GetPostValue('Target', '');
      if ($Session->ValidateTransientKey($TransientKey)) {
         $TableID = GetPostValue('TableID', FALSE);
         if ($TableID) {
            $Rows = GetPostValue($TableID, FALSE);
            if (is_array($Rows)) {
               try {
                  $Table = str_replace('Table', '', $TableID);
                  $TableModel = new Gdn_Model($Table);
                  foreach ($Rows as $Sort => $ID) {
                     $TableModel->Update(array('Sort' => $Sort), array($Table.'ID' => $ID));
                  }
               } catch (Exception $ex) {
                  $this->Form->AddError($ex->getMessage());
               }
            }
         }
      }
      if ($this->DeliveryType() != DELIVERY_TYPE_BOOL)
         Redirect($Target);
         
      $this->Render();
   }
public function Sort() {
      $this->Permission('Garden.Settings.Manage');
      
      $Session = Gdn::Session();
      $TransientKey = GetPostValue('TransientKey', '');
      $Target = GetPostValue('Target', '');
      if ($Session->ValidateTransientKey($TransientKey)) {
         $TableID = GetPostValue('TableID', FALSE);
         if ($TableID) {
            $Rows = GetPostValue($TableID, FALSE);
            if (is_array($Rows)) {
               try {
                  $Table = str_replace('Table', '', $TableID);
                  $TableModel = new Gdn_Model($Table);
                  foreach ($Rows as $Sort => $ID) {
                     $TableModel->Update(array('Sort' => $Sort), array($Table.'ID' => $ID));
                  }
               } catch (Exception $ex) {
                  $this->Form->AddError($ex->getMessage());
               }
            }
         }
      }
      if ($this->DeliveryType() != DELIVERY_TYPE_BOOL)
         Redirect($Target);
         
      $this->Render();
   }
public function Sort ( ) { $ this -> Permission ( 'Garden.Settings.Manage' ) ; $ Session = Gdn :: Session ( ) ; $ TransientKey = GetPostValue ( 'TransientKey' , '' ) ; $ Target = GetPostValue ( 'Target' , '' ) ; if ( $ Session -> ValidateTransientKey ( $ TransientKey ) ) { $ TableID = GetPostValue ( 'TableID' , FALSE ) ; if ( $ TableID ) { $ Rows = GetPostValue ( $ TableID , FALSE ) ; if ( is_array ( $ Rows ) ) { try { $ Table = str_replace ( 'Table' , '' , $ TableID ) ; $ TableModel = new Gdn_Model ( $ Table ) ; foreach ( $ Rows as $ Sort => $ ID ) { $ TableModel -> Update ( array ( 'Sort' => $ Sort ) , array ( $ Table . 'ID' => $ ID ) ) ; } } catch ( Exception $ ex ) { $ this -> Form -> AddError ( $ ex -> getMessage ( ) ) ; } } } } if ( $ this -> DeliveryType ( ) != DELIVERY_TYPE_BOOL ) Redirect ( $ Target ) ; $ this -> Render ( ) ; }
Set the sort order for data on an arbitrary database table.

Expect post values TransientKey, Target (redirect URL), Table (database table name),
and TableID (an array of sort order => unique ID).

@since 2.0.0
@access public
Set the sort order for data on an arbitrary database table .