/www/api/v2/xmlrpc/ZoneServiceImpl.php

https://github.com/yabba/openx · PHP · 379 lines · 153 code · 51 blank · 175 comment · 32 complexity · 6c0bada45e85367e1e07c9ea8989e927 MD5 · raw file

  1. <?php
  2. /*
  3. +---------------------------------------------------------------------------+
  4. | OpenX v${RELEASE_MAJOR_MINOR} |
  5. | =======${RELEASE_MAJOR_MINOR_DOUBLE_UNDERLINE} |
  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$
  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/v2/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 bool $localTZ
  153. * @param array &$aData return data
  154. *
  155. * @return boolean
  156. */
  157. function getZoneDailyStatistics($sessionId, $zoneId, $oStartDate, $oEndDate, $localTZ, &$aData)
  158. {
  159. if ($this->verifySession($sessionId)) {
  160. return $this->_validateResult(
  161. $this->_dllZone->getZoneDailyStatistics(
  162. $zoneId, $oStartDate, $oEndDate, $localTZ, $aData));
  163. } else {
  164. return false;
  165. }
  166. }
  167. /**
  168. * The getZoneAdvertiserStatistics method returns advertiser statistics for a
  169. * zone for a specified period.
  170. *
  171. * @access public
  172. *
  173. * @param string $sessionId
  174. * @param integer $zoneId
  175. * @param date $oStartDate
  176. * @param date $oEndDate
  177. * @param bool $localTZ
  178. * @param recordSet &$rsStatisticsData return data
  179. *
  180. * @return boolean
  181. */
  182. function getZoneAdvertiserStatistics($sessionId, $zoneId, $oStartDate, $oEndDate, $localTZ, &$rsStatisticsData)
  183. {
  184. if ($this->verifySession($sessionId)) {
  185. return $this->_validateResult(
  186. $this->_dllZone->getZoneAdvertiserStatistics(
  187. $zoneId, $oStartDate, $oEndDate, $localTZ, $rsStatisticsData));
  188. } else {
  189. return false;
  190. }
  191. }
  192. /**
  193. * The getZoneCampaignStatistics method returns campaign statistics for a zone
  194. * for a specified period.
  195. *
  196. * @access public
  197. *
  198. * @param string $sessionId
  199. * @param integer $zoneId
  200. * @param date $oStartDate
  201. * @param date $oEndDate
  202. * @param bool $localTZ
  203. * @param recordSet &$rsStatisticsData return data
  204. *
  205. * @return boolean
  206. */
  207. function getZoneCampaignStatistics($sessionId, $zoneId, $oStartDate, $oEndDate, $localTZ, &$rsStatisticsData)
  208. {
  209. if ($this->verifySession($sessionId)) {
  210. return $this->_validateResult(
  211. $this->_dllZone->getZoneCampaignStatistics(
  212. $zoneId, $oStartDate, $oEndDate, $localTZ, $rsStatisticsData));
  213. } else {
  214. return false;
  215. }
  216. }
  217. /**
  218. * The getZoneBannerStatistics method returns banner statistics for a zone
  219. * for a specified period.
  220. *
  221. * @access public
  222. *
  223. * @param string $sessionId
  224. * @param integer $zoneId
  225. * @param date $oStartDate
  226. * @param date $oEndDate
  227. * @param bool $localTZ
  228. * @param recordSet &$rsStatisticsData return data
  229. *
  230. * @return boolean
  231. */
  232. function getZoneBannerStatistics($sessionId, $zoneId, $oStartDate, $oEndDate, $localTZ, &$rsStatisticsData)
  233. {
  234. if ($this->verifySession($sessionId)) {
  235. return $this->_validateResult(
  236. $this->_dllZone->getZoneBannerStatistics(
  237. $zoneId, $oStartDate, $oEndDate, $localTZ, $rsStatisticsData));
  238. } else {
  239. return false;
  240. }
  241. }
  242. /**
  243. * The getZone method returns zone details for a specified zone.
  244. *
  245. * @access public
  246. *
  247. * @param string $sessionId
  248. * @param integer $zoneId
  249. * @param OA_Dll_ZoneInfo &$oZone
  250. *
  251. * @return boolean
  252. */
  253. function getZone($sessionId, $zoneId, &$oZone)
  254. {
  255. if ($this->verifySession($sessionId)) {
  256. return $this->_validateResult(
  257. $this->_dllZone->getZone($zoneId, $oZone));
  258. } else {
  259. return false;
  260. }
  261. }
  262. /**
  263. * The getZoneListByPublisherId method returns a list of zones for a
  264. * specified publisher.
  265. *
  266. * @access public
  267. *
  268. * @param string $sessionId
  269. * @param integer $publisherId
  270. * @param array &$oZone Array of OA_Dll_ZoneInfo classes
  271. *
  272. * @return boolean
  273. */
  274. function getZoneListByPublisherId($sessionId, $publisherId, &$aZoneList)
  275. {
  276. if ($this->verifySession($sessionId)) {
  277. return $this->_validateResult(
  278. $this->_dllZone->getZoneListByPublisherId($publisherId,
  279. $aZoneList));
  280. } else {
  281. return false;
  282. }
  283. }
  284. function linkBanner($sessionId, $zoneId, $bannerId)
  285. {
  286. if ($this->verifySession($sessionId)) {
  287. return $this->_validateResult($this->_dllZone->linkBanner($zoneId, $bannerId));
  288. } else {
  289. return false;
  290. }
  291. }
  292. function linkCampaign($sessionId, $zoneId, $campaignId)
  293. {
  294. if ($this->verifySession($sessionId)) {
  295. return $this->_validateResult($this->_dllZone->linkCampaign($zoneId, $campaignId));
  296. } else {
  297. return false;
  298. }
  299. }
  300. function unlinkBanner($sessionId, $zoneId, $bannerId)
  301. {
  302. if ($this->verifySession($sessionId)) {
  303. return $this->_validateResult($this->_dllZone->unlinkBanner($zoneId, $bannerId));
  304. } else {
  305. return false;
  306. }
  307. }
  308. function unlinkCampaign($sessionId, $zoneId, $campaignId)
  309. {
  310. if ($this->verifySession($sessionId)) {
  311. return $this->_validateResult($this->_dllZone->unlinkCampaign($zoneId, $campaignId));
  312. } else {
  313. return false;
  314. }
  315. }
  316. function generateTags($sessionId, $zoneId, $codeType, $aParams, &$generatedTag)
  317. {
  318. if ($this->verifySession($sessionId)) {
  319. $result = $this->_dllZone->generateTags($zoneId, $codeType, $aParams);
  320. if ($this->_validateResult($result)) {
  321. $generatedTag = $result;
  322. return true;
  323. }
  324. }
  325. return false;
  326. }
  327. }
  328. ?>