1<?php
2// ===================================================================================================
3//                           _  __     _ _
4//                          | |/ /__ _| | |_ _  _ _ _ __ _
5//                          | ' </ _` | |  _| || | '_/ _` |
6//                          |_|\_\__,_|_|\__|\_,_|_| \__,_|
7//
8// This file is part of the Kaltura Collaborative Media Suite which allows users
9// to do with audio, video, and animation what Wiki platfroms allow them to do with
10// text.
11//
12// Copyright (C) 2006-2017  Kaltura Inc.
13//
14// This program is free software: you can redistribute it and/or modify
15// it under the terms of the GNU Affero General Public License as
16// published by the Free Software Foundation, either version 3 of the
17// License, or (at your option) any later version.
18//
19// This program is distributed in the hope that it will be useful,
20// but WITHOUT ANY WARRANTY; without even the implied warranty of
21// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
22// GNU Affero General Public License for more details.
23//
24// You should have received a copy of the GNU Affero General Public License
25// along with this program.  If not, see <http://www.gnu.org/licenses/>.
26//
27// @ignore
28// ===================================================================================================
29
30
31/**
32 * @namespace
33 */
34namespace Kaltura\Client\Service;
35
36/**
37 * Add & Manage CategoryUser - membership of a user in a category
38 * @package Kaltura
39 * @subpackage Client
40 */
41class CategoryUserService extends \Kaltura\Client\ServiceBase
42{
43	function __construct(\Kaltura\Client\Client $client = null)
44	{
45		parent::__construct($client);
46	}
47
48	/**
49	 * activate CategoryUser
50	 *
51	 * @return \Kaltura\Client\Type\CategoryUser
52	 */
53	function activate($categoryId, $userId)
54	{
55		$kparams = array();
56		$this->client->addParam($kparams, "categoryId", $categoryId);
57		$this->client->addParam($kparams, "userId", $userId);
58		$this->client->queueServiceActionCall("categoryuser", "activate", "KalturaCategoryUser", $kparams);
59		if ($this->client->isMultiRequest())
60			return $this->client->getMultiRequestResult();
61		$resultXml = $this->client->doQueue();
62		$resultXmlObject = new \SimpleXMLElement($resultXml);
63		$this->client->checkIfError($resultXmlObject->result);
64		$resultObject = \Kaltura\Client\ParseUtils::unmarshalObject($resultXmlObject->result, "KalturaCategoryUser");
65		$this->client->validateObjectType($resultObject, "\\Kaltura\\Client\\Type\\CategoryUser");
66		return $resultObject;
67	}
68
69	/**
70	 * Add new CategoryUser
71	 *
72	 * @return \Kaltura\Client\Type\CategoryUser
73	 */
74	function add(\Kaltura\Client\Type\CategoryUser $categoryUser)
75	{
76		$kparams = array();
77		$this->client->addParam($kparams, "categoryUser", $categoryUser->toParams());
78		$this->client->queueServiceActionCall("categoryuser", "add", "KalturaCategoryUser", $kparams);
79		if ($this->client->isMultiRequest())
80			return $this->client->getMultiRequestResult();
81		$resultXml = $this->client->doQueue();
82		$resultXmlObject = new \SimpleXMLElement($resultXml);
83		$this->client->checkIfError($resultXmlObject->result);
84		$resultObject = \Kaltura\Client\ParseUtils::unmarshalObject($resultXmlObject->result, "KalturaCategoryUser");
85		$this->client->validateObjectType($resultObject, "\\Kaltura\\Client\\Type\\CategoryUser");
86		return $resultObject;
87	}
88
89	/**
90	 *
91	 * @return \Kaltura\Client\Type\BulkUpload
92	 */
93	function addFromBulkUpload($fileData, \Kaltura\Client\Type\BulkUploadJobData $bulkUploadData = null, \Kaltura\Client\Type\BulkUploadCategoryUserData $bulkUploadCategoryUserData = null)
94	{
95		$kparams = array();
96		$kfiles = array();
97		$this->client->addParam($kfiles, "fileData", $fileData);
98		if ($bulkUploadData !== null)
99			$this->client->addParam($kparams, "bulkUploadData", $bulkUploadData->toParams());
100		if ($bulkUploadCategoryUserData !== null)
101			$this->client->addParam($kparams, "bulkUploadCategoryUserData", $bulkUploadCategoryUserData->toParams());
102		$this->client->queueServiceActionCall("categoryuser", "addFromBulkUpload", "KalturaBulkUpload", $kparams, $kfiles);
103		if ($this->client->isMultiRequest())
104			return $this->client->getMultiRequestResult();
105		$resultXml = $this->client->doQueue();
106		$resultXmlObject = new \SimpleXMLElement($resultXml);
107		$this->client->checkIfError($resultXmlObject->result);
108		$resultObject = \Kaltura\Client\ParseUtils::unmarshalObject($resultXmlObject->result, "KalturaBulkUpload");
109		$this->client->validateObjectType($resultObject, "\\Kaltura\\Client\\Type\\BulkUpload");
110		return $resultObject;
111	}
112
113	/**
114	 * Copy all memeber from parent category
115	 *
116	 */
117	function copyFromCategory($categoryId)
118	{
119		$kparams = array();
120		$this->client->addParam($kparams, "categoryId", $categoryId);
121		$this->client->queueServiceActionCall("categoryuser", "copyFromCategory", null, $kparams);
122		if ($this->client->isMultiRequest())
123			return $this->client->getMultiRequestResult();
124		$resultXml = $this->client->doQueue();
125		$resultXmlObject = new \SimpleXMLElement($resultXml);
126		$this->client->checkIfError($resultXmlObject->result);
127	}
128
129	/**
130	 * reject CategoryUser
131	 *
132	 * @return \Kaltura\Client\Type\CategoryUser
133	 */
134	function deactivate($categoryId, $userId)
135	{
136		$kparams = array();
137		$this->client->addParam($kparams, "categoryId", $categoryId);
138		$this->client->addParam($kparams, "userId", $userId);
139		$this->client->queueServiceActionCall("categoryuser", "deactivate", "KalturaCategoryUser", $kparams);
140		if ($this->client->isMultiRequest())
141			return $this->client->getMultiRequestResult();
142		$resultXml = $this->client->doQueue();
143		$resultXmlObject = new \SimpleXMLElement($resultXml);
144		$this->client->checkIfError($resultXmlObject->result);
145		$resultObject = \Kaltura\Client\ParseUtils::unmarshalObject($resultXmlObject->result, "KalturaCategoryUser");
146		$this->client->validateObjectType($resultObject, "\\Kaltura\\Client\\Type\\CategoryUser");
147		return $resultObject;
148	}
149
150	/**
151	 * Delete a CategoryUser
152	 *
153	 */
154	function delete($categoryId, $userId)
155	{
156		$kparams = array();
157		$this->client->addParam($kparams, "categoryId", $categoryId);
158		$this->client->addParam($kparams, "userId", $userId);
159		$this->client->queueServiceActionCall("categoryuser", "delete", null, $kparams);
160		if ($this->client->isMultiRequest())
161			return $this->client->getMultiRequestResult();
162		$resultXml = $this->client->doQueue();
163		$resultXmlObject = new \SimpleXMLElement($resultXml);
164		$this->client->checkIfError($resultXmlObject->result);
165	}
166
167	/**
168	 * Get CategoryUser by id
169	 *
170	 * @return \Kaltura\Client\Type\CategoryUser
171	 */
172	function get($categoryId, $userId)
173	{
174		$kparams = array();
175		$this->client->addParam($kparams, "categoryId", $categoryId);
176		$this->client->addParam($kparams, "userId", $userId);
177		$this->client->queueServiceActionCall("categoryuser", "get", "KalturaCategoryUser", $kparams);
178		if ($this->client->isMultiRequest())
179			return $this->client->getMultiRequestResult();
180		$resultXml = $this->client->doQueue();
181		$resultXmlObject = new \SimpleXMLElement($resultXml);
182		$this->client->checkIfError($resultXmlObject->result);
183		$resultObject = \Kaltura\Client\ParseUtils::unmarshalObject($resultXmlObject->result, "KalturaCategoryUser");
184		$this->client->validateObjectType($resultObject, "\\Kaltura\\Client\\Type\\CategoryUser");
185		return $resultObject;
186	}
187
188	/**
189	 * Index CategoryUser by userid and category id
190	 *
191	 * @return int
192	 */
193	function index($userId, $categoryId, $shouldUpdate = true)
194	{
195		$kparams = array();
196		$this->client->addParam($kparams, "userId", $userId);
197		$this->client->addParam($kparams, "categoryId", $categoryId);
198		$this->client->addParam($kparams, "shouldUpdate", $shouldUpdate);
199		$this->client->queueServiceActionCall("categoryuser", "index", null, $kparams);
200		if ($this->client->isMultiRequest())
201			return $this->client->getMultiRequestResult();
202		$resultXml = $this->client->doQueue();
203		$resultXmlObject = new \SimpleXMLElement($resultXml);
204		$this->client->checkIfError($resultXmlObject->result);
205		$resultObject = (int)\Kaltura\Client\ParseUtils::unmarshalSimpleType($resultXmlObject->result);
206		return $resultObject;
207	}
208
209	/**
210	 * List all categories
211	 *
212	 * @return \Kaltura\Client\Type\CategoryUserListResponse
213	 */
214	function listAction(\Kaltura\Client\Type\CategoryUserFilter $filter = null, \Kaltura\Client\Type\FilterPager $pager = null)
215	{
216		$kparams = array();
217		if ($filter !== null)
218			$this->client->addParam($kparams, "filter", $filter->toParams());
219		if ($pager !== null)
220			$this->client->addParam($kparams, "pager", $pager->toParams());
221		$this->client->queueServiceActionCall("categoryuser", "list", "KalturaCategoryUserListResponse", $kparams);
222		if ($this->client->isMultiRequest())
223			return $this->client->getMultiRequestResult();
224		$resultXml = $this->client->doQueue();
225		$resultXmlObject = new \SimpleXMLElement($resultXml);
226		$this->client->checkIfError($resultXmlObject->result);
227		$resultObject = \Kaltura\Client\ParseUtils::unmarshalObject($resultXmlObject->result, "KalturaCategoryUserListResponse");
228		$this->client->validateObjectType($resultObject, "\\Kaltura\\Client\\Type\\CategoryUserListResponse");
229		return $resultObject;
230	}
231
232	/**
233	 * Update CategoryUser by id
234	 *
235	 * @return \Kaltura\Client\Type\CategoryUser
236	 */
237	function update($categoryId, $userId, \Kaltura\Client\Type\CategoryUser $categoryUser, $override = false)
238	{
239		$kparams = array();
240		$this->client->addParam($kparams, "categoryId", $categoryId);
241		$this->client->addParam($kparams, "userId", $userId);
242		$this->client->addParam($kparams, "categoryUser", $categoryUser->toParams());
243		$this->client->addParam($kparams, "override", $override);
244		$this->client->queueServiceActionCall("categoryuser", "update", "KalturaCategoryUser", $kparams);
245		if ($this->client->isMultiRequest())
246			return $this->client->getMultiRequestResult();
247		$resultXml = $this->client->doQueue();
248		$resultXmlObject = new \SimpleXMLElement($resultXml);
249		$this->client->checkIfError($resultXmlObject->result);
250		$resultObject = \Kaltura\Client\ParseUtils::unmarshalObject($resultXmlObject->result, "KalturaCategoryUser");
251		$this->client->validateObjectType($resultObject, "\\Kaltura\\Client\\Type\\CategoryUser");
252		return $resultObject;
253	}
254}
255