public function PluginController_ThankFor_Create($Sender) { $Session = $this->Session; if (!$Session->IsValid()) { return; } //$Sender->Permission('Plugins.ThankfulPeople.Thank'); // TODO: PERMISSION THANK FOR CATEGORY $ThanksLogModel = new ThanksLogModel(); $Type = GetValue(0, $Sender->RequestArgs); $ObjectID = GetValue(1, $Sender->RequestArgs); $Field = $ThanksLogModel->GetPrimaryKeyField($Type); $UserID = $ThanksLogModel->GetObjectInserUserID($Type, $ObjectID); if ($UserID == False) { throw new Exception('Object has no owner.'); } if ($UserID == $Session->UserID) { throw new Exception('You cannot thank yourself.'); } if (!self::IsThankable($Type)) { throw new Exception("Not thankable ({$Type})."); } // Make sure that user is not trying to say thanks twice. $Count = $ThanksLogModel->GetCount(array($Field => $ObjectID, 'InsertUserID' => $Session->User->UserID)); if ($Count < 1) { $ThanksLogModel->PutThank($Type, $ObjectID, $UserID); } if ($Sender->DeliveryType() == DELIVERY_TYPE_ALL) { $Target = GetIncomingValue('Target', 'discussions'); Redirect($Target); } $ThankfulPeopleDataSet = $ThanksLogModel->GetThankfulPeople($Type, $ObjectID); $Sender->SetData('NewThankedByBox', self::ThankedByBox($ThankfulPeopleDataSet->Result(), False)); $Sender->Render(); }