/www/api/v2/xmlrpc/PublisherServiceImpl.php

https://bitbucket.org/blackriver/openx · PHP · 356 lines · 120 code · 47 blank · 189 comment · 24 complexity · f134e20ff9408d0b8f401a6da6474471 MD5 · raw file

  1. <?php
  2. /*
  3. +---------------------------------------------------------------------------+
  4. | OpenX v2.8 |
  5. | ========== |
  6. | |
  7. | Copyright (c) 2003-2009 OpenX Limited |
  8. | For contact details, see: http://www.openx.org/ |
  9. | |
  10. | This program is free software; you can redistribute it and/or modify |
  11. | it under the terms of the GNU General Public License as published by |
  12. | the Free Software Foundation; either version 2 of the License, or |
  13. | (at your option) any later version. |
  14. | |
  15. | This program is distributed in the hope that it will be useful, |
  16. | but WITHOUT ANY WARRANTY; without even the implied warranty of |
  17. | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
  18. | GNU General Public License for more details. |
  19. | |
  20. | You should have received a copy of the GNU General Public License |
  21. | along with this program; if not, write to the Free Software |
  22. | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
  23. +---------------------------------------------------------------------------+
  24. $Id: PublisherServiceImpl.php 81772 2012-09-11 00:07:29Z chris.nutting $
  25. */
  26. /**
  27. * @package OpenX
  28. * @author Andriy Petlyovanyy <apetlyovanyy@lohika.com>
  29. *
  30. */
  31. // Base class BaseLogonService
  32. require_once MAX_PATH . '/www/api/v2/common/BaseServiceImpl.php';
  33. // Publisher Dll class
  34. require_once MAX_PATH . '/lib/OA/Dll/Publisher.php';
  35. /**
  36. * The PublisherServiceImpl class extends the BaseServiceImpl class to enable
  37. * you to add, modify, delete and search the publisher object.
  38. *
  39. */
  40. class PublisherServiceImpl extends BaseServiceImpl
  41. {
  42. /**
  43. *
  44. * @var OA_Dll_Publisher $_dllPublisher
  45. */
  46. var $_dllPublisher;
  47. /**
  48. *
  49. * The PublisherServiceImpl method is the constructor for the PublisherServiceImpl class.
  50. */
  51. function PublisherServiceImpl()
  52. {
  53. $this->BaseServiceImpl();
  54. $this->_dllPublisher = new OA_Dll_Publisher();
  55. }
  56. /**
  57. * This method checks if an action is valid and either returns a result
  58. * or an error, as appropriate.
  59. *
  60. * @access private
  61. *
  62. * @param boolean $result
  63. *
  64. * @return boolean
  65. */
  66. function _validateResult($result)
  67. {
  68. if ($result) {
  69. return true;
  70. } else {
  71. $this->raiseError($this->_dllPublisher->getLastError());
  72. return false;
  73. }
  74. }
  75. /**
  76. * The addPublisher method creates a publisher and updates the
  77. * publisher object with the publisher ID.
  78. *
  79. * @access public
  80. *
  81. * @param string $sessionId
  82. * @param OA_Dll_PublisherInfo &$oPublisher <br />
  83. * <b>Optional properties:</b> agencyId, publisherName, contactName, emailAddress, username, password<br />
  84. *
  85. * @return boolean
  86. */
  87. function addPublisher($sessionId, &$oPublisher)
  88. {
  89. if ($this->verifySession($sessionId)) {
  90. return $this->_validateResult($this->_dllPublisher->modify($oPublisher));
  91. } else {
  92. return false;
  93. }
  94. }
  95. /**
  96. * The modifyPublisher method checks if a publisher ID exists and
  97. * modifies the details for the publisher if it exists or returns an error
  98. * message, as appropriate.
  99. *
  100. * @access public
  101. *
  102. * @param string $sessionId
  103. * @param OA_Dll_PublisherInfo &$oPublisher <br />
  104. * <b>Required properties:</b> publisherId<br />
  105. * <b>Optional properties:</b> agencyId, publisherName, contactName, emailAddress, username, password<br />
  106. *
  107. * @return boolean
  108. */
  109. function modifyPublisher($sessionId, &$oPublisher)
  110. {
  111. if ($this->verifySession($sessionId)) {
  112. if (isset($oPublisher->publisherId)) {
  113. return $this->_validateResult($this->_dllPublisher->modify($oPublisher));
  114. } else {
  115. $this->raiseError("Field 'publisherId' in structure does not exists");
  116. return false;
  117. }
  118. } else {
  119. return false;
  120. }
  121. }
  122. /**
  123. * The deletePublisher method checks if a publisher exists and deletes
  124. * the publisher or returns an error message, as appropriate.
  125. *
  126. * @access public
  127. *
  128. * @param string $sessionId
  129. * @param integer $publisherId
  130. *
  131. * @return boolean
  132. */
  133. function deletePublisher($sessionId, $publisherId)
  134. {
  135. if ($this->verifySession($sessionId)) {
  136. return $this->_validateResult($this->_dllPublisher->delete($publisherId));
  137. } else {
  138. return false;
  139. }
  140. }
  141. /**
  142. * The getPublisherDailyStatistics method returns daily statistics for a
  143. * publisher for a specified period.
  144. *
  145. * @access public
  146. *
  147. * @param string $sessionId
  148. * @param integer $publisherId
  149. * @param date $oStartDate
  150. * @param date $oEndDate
  151. * @param bool $localTZ
  152. * @param array &$aData return data
  153. *
  154. * @return boolean
  155. */
  156. function getPublisherDailyStatistics($sessionId, $publisherId, $oStartDate, $oEndDate, $localTZ, &$aData)
  157. {
  158. if ($this->verifySession($sessionId)) {
  159. return $this->_validateResult(
  160. $this->_dllPublisher->getPublisherDailyStatistics(
  161. $publisherId, $oStartDate, $oEndDate, $localTZ, $aData));
  162. } else {
  163. return false;
  164. }
  165. }
  166. /**
  167. * The getPublisherZoneStatistics method returns zone statistics for a
  168. * publisher for a specified period.
  169. *
  170. * @access public
  171. *
  172. * @param string $sessionId
  173. * @param integer $publisherId
  174. * @param date $oStartDate
  175. * @param date $oEndDate
  176. * @param bool $localTZ
  177. * @param recordSet &$rsStatisticsData return data
  178. *
  179. * @return boolean
  180. */
  181. function getPublisherZoneStatistics($sessionId, $publisherId, $oStartDate, $oEndDate, $localTZ, &$rsStatisticsData)
  182. {
  183. if ($this->verifySession($sessionId)) {
  184. return $this->_validateResult(
  185. $this->_dllPublisher->getPublisherZoneStatistics(
  186. $publisherId, $oStartDate, $oEndDate, $localTZ, $rsStatisticsData));
  187. } else {
  188. return false;
  189. }
  190. }
  191. /**
  192. * The getPublisherAdvertiserStatistics method returns advertiser statistics
  193. * for a publisher for a specified period.
  194. *
  195. * @access public
  196. *
  197. * @param string $sessionId
  198. * @param integer $publisherId
  199. * @param date $oStartDate
  200. * @param date $oEndDate
  201. * @param bool $localTZ
  202. * @param recordSet &$rsStatisticsData return data
  203. *
  204. * @return boolean
  205. */
  206. function getPublisherAdvertiserStatistics($sessionId, $publisherId, $oStartDate, $oEndDate, $localTZ, &$rsStatisticsData)
  207. {
  208. if ($this->verifySession($sessionId)) {
  209. return $this->_validateResult(
  210. $this->_dllPublisher->getPublisherAdvertiserStatistics(
  211. $publisherId, $oStartDate, $oEndDate, $localTZ, $rsStatisticsData));
  212. } else {
  213. return false;
  214. }
  215. }
  216. /**
  217. * The getPublisherCampaignStatistics method returns campaign statistics for
  218. * a publisher for a specified period.
  219. *
  220. * @access public
  221. *
  222. * @param string $sessionId
  223. * @param integer $publisherId
  224. * @param date $oStartDate
  225. * @param date $oEndDate
  226. * @param bool $localTZ
  227. * @param recordSet &$rsStatisticsData return data
  228. *
  229. * @return boolean
  230. */
  231. function getPublisherCampaignStatistics($sessionId, $publisherId, $oStartDate, $oEndDate, $localTZ, &$rsStatisticsData)
  232. {
  233. if ($this->verifySession($sessionId)) {
  234. return $this->_validateResult(
  235. $this->_dllPublisher->getPublisherCampaignStatistics(
  236. $publisherId, $oStartDate, $oEndDate, $localTZ, $rsStatisticsData));
  237. } else {
  238. return false;
  239. }
  240. }
  241. /**
  242. * The getPublisherBannerStatistics method returns banner statistics for a
  243. * publisher for a specified period.
  244. *
  245. * @access public
  246. *
  247. * @param string $sessionId
  248. * @param integer $publisherId
  249. * @param date $oStartDate
  250. * @param date $oEndDate
  251. * @param bool $localTZ
  252. * @param recordSet &$rsStatisticsData return data
  253. *
  254. * @return boolean
  255. */
  256. function getPublisherBannerStatistics($sessionId, $publisherId, $oStartDate, $oEndDate, $localTZ, &$rsStatisticsData)
  257. {
  258. if ($this->verifySession($sessionId)) {
  259. return $this->_validateResult(
  260. $this->_dllPublisher->getPublisherBannerStatistics(
  261. $publisherId, $oStartDate, $oEndDate, $localTZ, $rsStatisticsData));
  262. } else {
  263. return false;
  264. }
  265. }
  266. /**
  267. * The getPublisher method returns the details of a specified publisher.
  268. *
  269. * @access public
  270. *
  271. * @param string $sessionId
  272. * @param integer $publisherId
  273. * @param OA_Dll_PublisherInfo &$oPublisher
  274. *
  275. * @return boolean
  276. */
  277. function getPublisher($sessionId, $publisherId, &$oPublisher)
  278. {
  279. if ($this->verifySession($sessionId)) {
  280. return $this->_validateResult(
  281. $this->_dllPublisher->getPublisher($publisherId, $oPublisher));
  282. } else {
  283. return false;
  284. }
  285. }
  286. /**
  287. * The getPublisherListByAgencyId method returns a list of publishers for
  288. * a specified agency.
  289. *
  290. * @access public
  291. *
  292. * @param string $sessionId
  293. * @param integer $agencyId
  294. * @param array &$aPublisherList Array of OA_Dll_PublisherInfo classes
  295. *
  296. * @return boolean
  297. */
  298. function getPublisherListByAgencyId($sessionId, $agencyId, &$aPublisherList)
  299. {
  300. if ($this->verifySession($sessionId)) {
  301. return $this->_validateResult(
  302. $this->_dllPublisher->getPublisherListByAgencyId($agencyId,
  303. $aPublisherList));
  304. } else {
  305. return false;
  306. }
  307. }
  308. }
  309. ?>