function KnowledgebaseEntryCreate() { $kbEntry = new KnowledgeBaseEntry(); $params = ApiV2::GetObjectFields("KnowledgeBaseEntry"); if ($kbEntry = $this->CreateFromJSON($params, json_decode($_POST["p_data"]), $kbEntry, "KnowledgeBaseEntry")) { $parent = KnowledgeBaseEntry::GetById($kbEntry->ParentId, false); if ($parent == null) { $this->ErrorFilter = "ParentId"; } else { $kbEntry->CalculateRank(); $kbEntry->EditorId = CALLER_SYSTEM_ID; $kbEntry->OwnerId = CALLER_SYSTEM_ID; $kbEntry->Edited = $kbEntry->Created = time() + 1; if (empty($kbEntry->Id)) { $kbEntry->Id = getId(32); } $kbEntry->Save(); $this->JSONOutput = APIV2::Encode(array("KnowledgeBaseEntry" => ApiV2::ClearObject($params, $kbEntry)), $this->JSONParams); } } }
function CommercialChatVoucherCreate() { global $CONFIG; $voucher = new CommercialChatVoucher("1", strtoupper(getId(16))); $params = ApiV2::GetObjectFields("CommercialChatVoucher"); if ($voucher = $this->CreateFromJSON($params, json_decode($_POST["p_data"]), $voucher, "CommercialChatVoucher")) { if (!isset($CONFIG["db"]["cct"][$voucher->TypeId])) { $this->ErrorField = "TypeId"; } else { if (empty($voucher->Id)) { $voucher->Id = strtoupper(getId(16)); } $voucher->ChatSessionsMax = $CONFIG["db"]["cct"][$voucher->TypeId]->ChatSessionsMax; $voucher->ChatTimeMax = $CONFIG["db"]["cct"][$voucher->TypeId]->ChatTimeMax * 60; if ($voucher->Save()) { $voucher->SetVoucherParams($voucher->Voided, $voucher->Paid); $this->JSONOutput = APIV2::Encode(ApiV2::ClearObject($params, $voucher), $this->JSONParams); } else { $this->ErrorField = "Id"; } } } }