PageRenderTime 44ms CodeModel.GetById 17ms RepoModel.GetById 0ms app.codeStats 0ms

/www/api/v1/xmlrpc/BannerServiceImpl.php

https://bitbucket.org/blackriver/openx
PHP | 344 lines | 118 code | 46 blank | 180 comment | 24 complexity | 3beeb48019e7457540e379d885c42cc8 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: BannerServiceImpl.php 81772 2012-09-11 00:07:29Z chris.nutting $
  25. */
  26. /**
  27. * @package OpenX
  28. * @author Ivan Klishch <iklishch@lohika.com>
  29. *
  30. */
  31. // Base class BaseLogonService
  32. require_once MAX_PATH . '/www/api/v1/common/BaseServiceImpl.php';
  33. // Banner Dll class
  34. require_once MAX_PATH . '/lib/OA/Dll/Banner.php';
  35. /**
  36. * The BannerServiceImpl class extends the BaseServiceImpl class to enable
  37. * you to add, modify, delete and search the banner object.
  38. *
  39. */
  40. class BannerServiceImpl extends BaseServiceImpl
  41. {
  42. /**
  43. *
  44. * @var OA_Dll_Banner $_dllBanner
  45. */
  46. var $_dllBanner;
  47. /**
  48. *
  49. * The BannerServiceImpl method is the constructor for the BannerServiceImpl class.
  50. */
  51. function BannerServiceImpl()
  52. {
  53. $this->BaseServiceImpl();
  54. $this->_dllBanner = new OA_Dll_Banner();
  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->_dllBanner->getLastError());
  72. return false;
  73. }
  74. }
  75. /**
  76. * The addBanner method creates a banner and updates the
  77. * banner object with the banner ID.
  78. *
  79. * @access public
  80. *
  81. * @param string $sessionId
  82. * @param OA_Dll_BannerInfo &$oBanner <br />
  83. * <b>Required properties:</b> campaignId<br />
  84. * <b>Optional properties:</b> bannerName, storageType, fileName, imageURL, htmlTemplate, width, height, weight, url<br />
  85. *
  86. * @return boolean
  87. */
  88. function addBanner($sessionId, &$oBanner)
  89. {
  90. if ($this->verifySession($sessionId)) {
  91. return $this->_validateResult($this->_dllBanner->modify($oBanner));
  92. } else {
  93. return false;
  94. }
  95. }
  96. /**
  97. * The modifyBanner method checks if a banner ID exists and
  98. * modifies the details for the banner if it exists or returns an error
  99. * message, as appropriate.
  100. *
  101. * @access public
  102. *
  103. * @param string $sessionId
  104. * @param OA_Dll_BannerInfo &$oBanner <br />
  105. * <b>Required properties:</b> bannerId<br />
  106. * <b>Optional properties:</b> campaignId, bannerName, storageType, fileName, imageURL, htmlTemplate, width, height, weight, url<br />
  107. *
  108. * @return boolean
  109. */
  110. function modifyBanner($sessionId, &$oBanner)
  111. {
  112. if ($this->verifySession($sessionId)) {
  113. if (isset($oBanner->bannerId)) {
  114. return $this->_validateResult($this->_dllBanner->modify($oBanner));
  115. } else {
  116. $this->raiseError("Field 'bannerId' in structure does not exists");
  117. return false;
  118. }
  119. } else {
  120. return false;
  121. }
  122. }
  123. /**
  124. * The deleteBanner method checks if a banner exists and deletes
  125. * the banner or returns an error message, as appropriate.
  126. *
  127. * @access public
  128. *
  129. * @param string $sessionId
  130. * @param integer $bannerId
  131. *
  132. * @return boolean
  133. */
  134. function deleteBanner($sessionId, $bannerId)
  135. {
  136. if ($this->verifySession($sessionId)) {
  137. return $this->_validateResult($this->_dllBanner->delete($bannerId));
  138. } else {
  139. return false;
  140. }
  141. }
  142. /**
  143. * This method return targeting limitations for banner
  144. * or returns an error message,.
  145. *
  146. * @access public
  147. *
  148. * @param string $sessionId
  149. * @param integer $bannerId
  150. * @param array &$aTargeting
  151. *
  152. * @return boolean
  153. */
  154. function getBannerTargeting($sessionId, $bannerId, &$aTargeting)
  155. {
  156. if ($this->verifySession($sessionId)) {
  157. return $this->_validateResult($this->_dllBanner->getBannerTargeting(
  158. $bannerId, $aTargeting));
  159. } else {
  160. return false;
  161. }
  162. }
  163. /**
  164. * This method set targeting limitations for banner
  165. * or returns an error message.
  166. *
  167. * @access public
  168. *
  169. * @param string $sessionId
  170. * @param integer $bannerId
  171. * @param array &$aTargeting
  172. *
  173. * @return boolean
  174. */
  175. function setBannerTargeting($sessionId, $bannerId, &$aTargeting)
  176. {
  177. if ($this->verifySession($sessionId)) {
  178. return $this->_validateResult($this->_dllBanner->setBannerTargeting(
  179. $bannerId, $aTargeting));
  180. } else {
  181. return false;
  182. }
  183. }
  184. /**
  185. * The getBannerDailyStatistics method returns daily statistics for a
  186. * banner for a specified period.
  187. *
  188. * @access public
  189. *
  190. * @param string $sessionId
  191. * @param integer $bannerId
  192. * @param date $oStartDate
  193. * @param date $oEndDate
  194. * @param recordSet &$rsStatisticsData return data
  195. *
  196. * @return boolean
  197. */
  198. function getBannerDailyStatistics($sessionId, $bannerId, $oStartDate, $oEndDate, &$rsStatisticsData)
  199. {
  200. if ($this->verifySession($sessionId)) {
  201. return $this->_validateResult(
  202. $this->_dllBanner->getBannerDailyStatistics(
  203. $bannerId, $oStartDate, $oEndDate, false, $rsStatisticsData));
  204. } else {
  205. return false;
  206. }
  207. }
  208. /**
  209. * The getBannerPublisherStatistics method returns publisher statistics for
  210. * a banner for a specified period.
  211. *
  212. * @access public
  213. *
  214. * @param string $sessionId
  215. * @param integer $bannerId
  216. * @param date $oStartDate
  217. * @param date $oEndDate
  218. * @param recordSet &$rsStatisticsData return data
  219. *
  220. * @return boolean
  221. */
  222. function getBannerPublisherStatistics($sessionId, $bannerId, $oStartDate, $oEndDate, &$rsStatisticsData)
  223. {
  224. if ($this->verifySession($sessionId)) {
  225. return $this->_validateResult(
  226. $this->_dllBanner->getBannerPublisherStatistics(
  227. $bannerId, $oStartDate, $oEndDate, false, $rsStatisticsData));
  228. } else {
  229. return false;
  230. }
  231. }
  232. /**
  233. * The getBannerZoneStatistics method returns zone statistics for a zone for
  234. * a specified period.
  235. *
  236. * @access public
  237. *
  238. * @param string $sessionId
  239. * @param integer $bannerId
  240. * @param date $oStartDate
  241. * @param date $oEndDate
  242. * @param recordSet &$rsStatisticsData return data
  243. *
  244. * @return boolean
  245. */
  246. function getBannerZoneStatistics($sessionId, $bannerId, $oStartDate, $oEndDate, &$rsStatisticsData)
  247. {
  248. if ($this->verifySession($sessionId)) {
  249. return $this->_validateResult(
  250. $this->_dllBanner->getBannerZoneStatistics(
  251. $bannerId, $oStartDate, $oEndDate, false, $rsStatisticsData));
  252. } else {
  253. return false;
  254. }
  255. }
  256. /**
  257. * The getBanner method returns the banner details for a specified banner.
  258. *
  259. * @access public
  260. *
  261. * @param string $sessionId
  262. * @param integer $bannerId
  263. * @param OA_Dll_BannerInfo &$oBanner
  264. *
  265. * @return boolean
  266. */
  267. function getBanner($sessionId, $bannerId, &$oBanner)
  268. {
  269. if ($this->verifySession($sessionId)) {
  270. return $this->_validateResult(
  271. $this->_dllBanner->getBanner($bannerId, $oBanner));
  272. } else {
  273. return false;
  274. }
  275. }
  276. /**
  277. * The getBannerListByCampaignId method returns a list of banners for a campaign.
  278. *
  279. * @access public
  280. *
  281. * @param string $sessionId
  282. * @param integer $campaignId
  283. * @param array &$aBannerList Array of OA_Dll_BannerInfo classes
  284. *
  285. * @return boolean
  286. */
  287. function getBannerListByCampaignId($sessionId, $campaignId, &$aBannerList)
  288. {
  289. if ($this->verifySession($sessionId)) {
  290. return $this->_validateResult(
  291. $this->_dllBanner->getBannerListByCampaignId($campaignId,
  292. $aBannerList));
  293. } else {
  294. return false;
  295. }
  296. }
  297. }
  298. ?>