PageRenderTime 45ms CodeModel.GetById 18ms RepoModel.GetById 0ms app.codeStats 0ms

/www/api/v1/xmlrpc/ZoneServiceImpl.php

https://bitbucket.org/blackriver/openx
PHP | 375 lines | 153 code | 51 blank | 171 comment | 32 complexity | edae62e61ce70a2c8fcbd2a69e0e6bca 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: ZoneServiceImpl.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. // Zone Dll class
  34. require_once MAX_PATH . '/lib/OA/Dll/Zone.php';
  35. /**
  36. * The ZoneServiceImpl class extends the BaseServiceImpl class to enable
  37. * you to add, modify, delete and search the zone object.
  38. *
  39. */
  40. class ZoneServiceImpl extends BaseServiceImpl
  41. {
  42. /**
  43. *
  44. * @var OA_Dll_Zone $_dllZone
  45. */
  46. var $_dllZone;
  47. /**
  48. *
  49. * The ZoneServiceImpl method is the constructor for the ZoneServiceImpl class.
  50. */
  51. function ZoneServiceImpl()
  52. {
  53. $this->BaseServiceImpl();
  54. $this->_dllZone = new OA_Dll_Zone();
  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->_dllZone->getLastError());
  72. return false;
  73. }
  74. }
  75. /**
  76. * The addZone method creates a zone and updates the
  77. * zone object with the zone ID.
  78. *
  79. * @access public
  80. *
  81. * @param string $sessionId
  82. * @param OA_Dll_ZoneInfo &$oZone <br />
  83. * <b>Required properties:</b> publisherId<br />
  84. * <b>Optional properties:</b> zoneName, type, width, height<br />
  85. *
  86. * @return boolean
  87. */
  88. function addZone($sessionId, &$oZone)
  89. {
  90. if ($this->verifySession($sessionId)) {
  91. return $this->_validateResult($this->_dllZone->modify($oZone));
  92. } else {
  93. return false;
  94. }
  95. }
  96. /**
  97. * The modifyZone method checks if a zone ID exists and
  98. * modifies the details for the zone if it exists or returns an error
  99. * message, as appropriate.
  100. *
  101. * @access public
  102. *
  103. * @param string $sessionId
  104. * @param OA_Dll_ZoneInfo &$oZone <br />
  105. * <b>Required properties:</b> zoneId<br />
  106. * <b>Optional properties:</b> publisherId, zoneName, type, width, height<br />
  107. *
  108. * @return boolean
  109. */
  110. function modifyZone($sessionId, &$oZone)
  111. {
  112. if ($this->verifySession($sessionId)) {
  113. if (isset($oZone->zoneId)) {
  114. return $this->_validateResult($this->_dllZone->modify($oZone));
  115. } else {
  116. $this->raiseError("Field 'zoneId' in structure does not exists");
  117. return false;
  118. }
  119. } else {
  120. return false;
  121. }
  122. }
  123. /**
  124. * The deleteZone method checks if a zone exists and deletes
  125. * the zone or returns an error message, as appropriate.
  126. *
  127. * @access public
  128. *
  129. * @param string $sessionId
  130. * @param integer $zoneId
  131. *
  132. * @return boolean
  133. */
  134. function deleteZone($sessionId, $zoneId)
  135. {
  136. if ($this->verifySession($sessionId)) {
  137. return $this->_validateResult($this->_dllZone->delete($zoneId));
  138. } else {
  139. return false;
  140. }
  141. }
  142. /**
  143. * The getZoneDailyStatistics method returns daily statistics for a zone
  144. * for a specified period.
  145. *
  146. * @access public
  147. *
  148. * @param string $sessionId
  149. * @param integer $zoneId
  150. * @param date $oStartDate
  151. * @param date $oEndDate
  152. * @param recordSet &$rsStatisticsData return data
  153. *
  154. * @return boolean
  155. */
  156. function getZoneDailyStatistics($sessionId, $zoneId, $oStartDate, $oEndDate, &$rsStatisticsData)
  157. {
  158. if ($this->verifySession($sessionId)) {
  159. return $this->_validateResult(
  160. $this->_dllZone->getZoneDailyStatistics(
  161. $zoneId, $oStartDate, $oEndDate, false, $rsStatisticsData));
  162. } else {
  163. return false;
  164. }
  165. }
  166. /**
  167. * The getZoneAdvertiserStatistics method returns advertiser statistics for a
  168. * zone for a specified period.
  169. *
  170. * @access public
  171. *
  172. * @param string $sessionId
  173. * @param integer $zoneId
  174. * @param date $oStartDate
  175. * @param date $oEndDate
  176. * @param recordSet &$rsStatisticsData return data
  177. *
  178. * @return boolean
  179. */
  180. function getZoneAdvertiserStatistics($sessionId, $zoneId, $oStartDate, $oEndDate, &$rsStatisticsData)
  181. {
  182. if ($this->verifySession($sessionId)) {
  183. return $this->_validateResult(
  184. $this->_dllZone->getZoneAdvertiserStatistics(
  185. $zoneId, $oStartDate, $oEndDate, false, $rsStatisticsData));
  186. } else {
  187. return false;
  188. }
  189. }
  190. /**
  191. * The getZoneCampaignStatistics method returns campaign statistics for a zone
  192. * for a specified period.
  193. *
  194. * @access public
  195. *
  196. * @param string $sessionId
  197. * @param integer $zoneId
  198. * @param date $oStartDate
  199. * @param date $oEndDate
  200. * @param recordSet &$rsStatisticsData return data
  201. *
  202. * @return boolean
  203. */
  204. function getZoneCampaignStatistics($sessionId, $zoneId, $oStartDate, $oEndDate, &$rsStatisticsData)
  205. {
  206. if ($this->verifySession($sessionId)) {
  207. return $this->_validateResult(
  208. $this->_dllZone->getZoneCampaignStatistics(
  209. $zoneId, $oStartDate, $oEndDate, false, $rsStatisticsData));
  210. } else {
  211. return false;
  212. }
  213. }
  214. /**
  215. * The getZoneBannerStatistics method returns banner statistics for a zone
  216. * for a specified period.
  217. *
  218. * @access public
  219. *
  220. * @param string $sessionId
  221. * @param integer $zoneId
  222. * @param date $oStartDate
  223. * @param date $oEndDate
  224. * @param recordSet &$rsStatisticsData return data
  225. *
  226. * @return boolean
  227. */
  228. function getZoneBannerStatistics($sessionId, $zoneId, $oStartDate, $oEndDate, &$rsStatisticsData)
  229. {
  230. if ($this->verifySession($sessionId)) {
  231. return $this->_validateResult(
  232. $this->_dllZone->getZoneBannerStatistics(
  233. $zoneId, $oStartDate, $oEndDate, false, $rsStatisticsData));
  234. } else {
  235. return false;
  236. }
  237. }
  238. /**
  239. * The getZone method returns zone details for a specified zone.
  240. *
  241. * @access public
  242. *
  243. * @param string $sessionId
  244. * @param integer $zoneId
  245. * @param OA_Dll_ZoneInfo &$oZone
  246. *
  247. * @return boolean
  248. */
  249. function getZone($sessionId, $zoneId, &$oZone)
  250. {
  251. if ($this->verifySession($sessionId)) {
  252. return $this->_validateResult(
  253. $this->_dllZone->getZone($zoneId, $oZone));
  254. } else {
  255. return false;
  256. }
  257. }
  258. /**
  259. * The getZoneListByPublisherId method returns a list of zones for a
  260. * specified publisher.
  261. *
  262. * @access public
  263. *
  264. * @param string $sessionId
  265. * @param integer $publisherId
  266. * @param array &$oZone Array of OA_Dll_ZoneInfo classes
  267. *
  268. * @return boolean
  269. */
  270. function getZoneListByPublisherId($sessionId, $publisherId, &$aZoneList)
  271. {
  272. if ($this->verifySession($sessionId)) {
  273. return $this->_validateResult(
  274. $this->_dllZone->getZoneListByPublisherId($publisherId,
  275. $aZoneList));
  276. } else {
  277. return false;
  278. }
  279. }
  280. function linkBanner($sessionId, $zoneId, $bannerId)
  281. {
  282. if ($this->verifySession($sessionId)) {
  283. return $this->_validateResult($this->_dllZone->linkBanner($zoneId, $bannerId));
  284. } else {
  285. return false;
  286. }
  287. }
  288. function linkCampaign($sessionId, $zoneId, $campaignId)
  289. {
  290. if ($this->verifySession($sessionId)) {
  291. return $this->_validateResult($this->_dllZone->linkCampaign($zoneId, $campaignId));
  292. } else {
  293. return false;
  294. }
  295. }
  296. function unlinkBanner($sessionId, $zoneId, $bannerId)
  297. {
  298. if ($this->verifySession($sessionId)) {
  299. return $this->_validateResult($this->_dllZone->unlinkBanner($zoneId, $bannerId));
  300. } else {
  301. return false;
  302. }
  303. }
  304. function unlinkCampaign($sessionId, $zoneId, $campaignId)
  305. {
  306. if ($this->verifySession($sessionId)) {
  307. return $this->_validateResult($this->_dllZone->unlinkCampaign($zoneId, $campaignId));
  308. } else {
  309. return false;
  310. }
  311. }
  312. function generateTags($sessionId, $zoneId, $codeType, $aParams, &$generatedTag)
  313. {
  314. if ($this->verifySession($sessionId)) {
  315. $result = $this->_dllZone->generateTags($zoneId, $codeType, $aParams);
  316. if ($this->_validateResult($result)) {
  317. $generatedTag = $result;
  318. return true;
  319. }
  320. }
  321. return false;
  322. }
  323. }
  324. ?>