public function Sort() { $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(); }