PageRenderTime 48ms CodeModel.GetById 20ms RepoModel.GetById 1ms app.codeStats 0ms

/www/api/v1/xmlrpc/AdvertiserServiceImpl.php

https://bitbucket.org/valmy/openx
PHP | 353 lines | 120 code | 47 blank | 186 comment | 24 complexity | 5d617caccf54553c177dadc74f69e1ac 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$
  25. */
  26. /**
  27. * @package OpenX
  28. * @author Ivan Klishch <iklishch@lohika.com>
  29. *
  30. */
  31. // Require the base class, BaseLogonService
  32. require_once MAX_PATH . '/www/api/v1/common/BaseServiceImpl.php';
  33. // Require the advertiser Dll class.
  34. require_once MAX_PATH . '/lib/OA/Dll/Advertiser.php';
  35. /**
  36. * The AdvertiserServiceImpl class extends the BaseServiceImpl class to enable
  37. * you to add, modify, delete and search the advertiser object.
  38. *
  39. */
  40. class AdvertiserServiceImpl extends BaseServiceImpl
  41. {
  42. /**
  43. *
  44. * @var OA_Dll_Advertiser $_dllAdvertiser
  45. */
  46. var $_dllAdvertiser;
  47. /**
  48. *
  49. * The AdvertiserServiceImpl method is the constructor for the
  50. * AdvertiserServiceImpl class.
  51. */
  52. function AdvertiserServiceImpl()
  53. {
  54. $this->BaseServiceImpl();
  55. $this->_dllAdvertiser = new OA_Dll_Advertiser();
  56. }
  57. /**
  58. * This method checks if an action is valid and either returns a result
  59. * or an error, as appropriate.
  60. *
  61. * @access private
  62. *
  63. * @param boolean $result
  64. *
  65. * @return boolean
  66. */
  67. function _validateResult($result)
  68. {
  69. if ($result) {
  70. return true;
  71. } else {
  72. $this->raiseError($this->_dllAdvertiser->getLastError());
  73. return false;
  74. }
  75. }
  76. /**
  77. * The addAdvertiser method creates an advertiser and updates the
  78. * advertiser object with the advertiser ID.
  79. *
  80. * @access public
  81. *
  82. * @param string $sessionId
  83. * @param OA_Dll_AdvertiserInfo &$oAdvertiser <br />
  84. * <b>Required properties:</b> advertiserName<br />
  85. * <b>Optional properties:</b> agencyId, contactName, emailAddress, username, password<br />
  86. *
  87. * @return boolean
  88. */
  89. function addAdvertiser($sessionId, &$oAdvertiser)
  90. {
  91. if ($this->verifySession($sessionId)) {
  92. return $this->_validateResult($this->_dllAdvertiser->modify($oAdvertiser));
  93. } else {
  94. return false;
  95. }
  96. }
  97. /**
  98. * The modifyAdvertiser method checks if an advertiser ID exists and
  99. * modifies the details for the advertiser if it exists or returns an error
  100. * message, as appropriate.
  101. *
  102. * @access public
  103. *
  104. * @param string $sessionId
  105. * @param OA_Dll_AdvertiserInfo &$oAdvertiser <br />
  106. * <b>Required properties:</b> advertiserId<br />
  107. * <b>Optional properties:</b> agencyId, advertiserName, contactName, emailAddress, username, password<br />
  108. *
  109. * @return boolean
  110. */
  111. function modifyAdvertiser($sessionId, &$oAdvertiser)
  112. {
  113. if ($this->verifySession($sessionId)) {
  114. if (isset($oAdvertiser->advertiserId)) {
  115. return $this->_validateResult($this->_dllAdvertiser->modify($oAdvertiser));
  116. } else {
  117. $this->raiseError("Field 'advertiserId' in structure does not exists");
  118. return false;
  119. }
  120. } else {
  121. return false;
  122. }
  123. }
  124. /**
  125. * The deleteAdvertiser method checks if an advertiser exists and deletes
  126. * the advertiser or returns an error message, as appropriate.
  127. *
  128. * @access public
  129. *
  130. * @param string $sessionId
  131. * @param integer $advertiserId
  132. *
  133. * @return boolean
  134. */
  135. function deleteAdvertiser($sessionId, $advertiserId)
  136. {
  137. if ($this->verifySession($sessionId)) {
  138. return $this->_validateResult($this->_dllAdvertiser->delete($advertiserId));
  139. } else {
  140. return false;
  141. }
  142. }
  143. /**
  144. * The getAdvertiserDailyStatistics method returns daily statistics for an
  145. * advertiser for a specified period.
  146. *
  147. * @access public
  148. *
  149. * @param string $sessionId
  150. * @param integer $advertiserId
  151. * @param date $oStartDate
  152. * @param date $oEndDate
  153. * @param recordSet &$rsStatisticsData return data
  154. *
  155. * @return boolean
  156. */
  157. function getAdvertiserDailyStatistics($sessionId, $advertiserId, $oStartDate, $oEndDate, &$rsStatisticsData)
  158. {
  159. if ($this->verifySession($sessionId)) {
  160. return $this->_validateResult(
  161. $this->_dllAdvertiser->getAdvertiserDailyStatistics(
  162. $advertiserId, $oStartDate, $oEndDate, false, $rsStatisticsData));
  163. } else {
  164. return false;
  165. }
  166. }
  167. /**
  168. * The getAdvertiserCampaignStatistics method returns campaign statistics
  169. * for an advertiser for a specified period.
  170. *
  171. * @access public
  172. *
  173. * @param string $sessionId
  174. * @param integer $advertiserId
  175. * @param date $oStartDate
  176. * @param date $oEndDate
  177. * @param recordSet &$rsStatisticsData return data
  178. *
  179. * @return boolean
  180. */
  181. function getAdvertiserCampaignStatistics($sessionId, $advertiserId, $oStartDate, $oEndDate, &$rsStatisticsData)
  182. {
  183. if ($this->verifySession($sessionId)) {
  184. return $this->_validateResult(
  185. $this->_dllAdvertiser->getAdvertiserCampaignStatistics(
  186. $advertiserId, $oStartDate, $oEndDate, false, $rsStatisticsData));
  187. } else {
  188. return false;
  189. }
  190. }
  191. /**
  192. * The getAdvertiserBannerStatistics method returns banner statistics for
  193. * an advertiser for a specified period.
  194. *
  195. * @access public
  196. *
  197. * @param string $sessionId
  198. * @param integer $advertiserId
  199. * @param date $oStartDate
  200. * @param date $oEndDate
  201. * @param recordSet &$rsStatisticsData return data
  202. *
  203. * @return boolean
  204. */
  205. function getAdvertiserBannerStatistics($sessionId, $advertiserId, $oStartDate, $oEndDate, &$rsStatisticsData)
  206. {
  207. if ($this->verifySession($sessionId)) {
  208. return $this->_validateResult(
  209. $this->_dllAdvertiser->getAdvertiserBannerStatistics(
  210. $advertiserId, $oStartDate, $oEndDate, false, $rsStatisticsData));
  211. } else {
  212. return false;
  213. }
  214. }
  215. /**
  216. * The getAdvertiserPublisherStatistics method returns publisher
  217. * statistics for an advertiser for a specified period.
  218. *
  219. * @access public
  220. *
  221. * @param string $sessionId
  222. * @param integer $advertiserId
  223. * @param date $oStartDate
  224. * @param date $oEndDate
  225. * @param recordSet &$rsStatisticsData return data
  226. *
  227. * @return boolean
  228. */
  229. function getAdvertiserPublisherStatistics($sessionId, $advertiserId, $oStartDate, $oEndDate, &$rsStatisticsData)
  230. {
  231. if ($this->verifySession($sessionId)) {
  232. return $this->_validateResult(
  233. $this->_dllAdvertiser->getAdvertiserPublisherStatistics(
  234. $advertiserId, $oStartDate, $oEndDate, false, $rsStatisticsData));
  235. } else {
  236. return false;
  237. }
  238. }
  239. /**
  240. * The getAdvertiserZoneStatistics method returns zone statistics for an
  241. * advertiser for a specified period.
  242. *
  243. * @access public
  244. *
  245. * @param string $sessionId
  246. * @param integer $advertiserId
  247. * @param date $oStartDate
  248. * @param date $oEndDate
  249. * @param recordSet &$rsStatisticsData return data
  250. *
  251. * @return boolean
  252. */
  253. function getAdvertiserZoneStatistics($sessionId, $advertiserId, $oStartDate, $oEndDate, &$rsStatisticsData)
  254. {
  255. if ($this->verifySession($sessionId)) {
  256. return $this->_validateResult(
  257. $this->_dllAdvertiser->getAdvertiserZoneStatistics(
  258. $advertiserId, $oStartDate, $oEndDate, false, $rsStatisticsData));
  259. } else {
  260. return false;
  261. }
  262. }
  263. /**
  264. * The getAdvertiser method returns the advertiser details for a specified advertiser.
  265. *
  266. * @access public
  267. *
  268. * @param string $sessionId
  269. * @param integer $advertiserId
  270. * @param OA_Dll_AdvertiserInfo &$oAdvertiser
  271. *
  272. * @return boolean
  273. */
  274. function getAdvertiser($sessionId, $advertiserId, &$oAdvertiser)
  275. {
  276. if ($this->verifySession($sessionId)) {
  277. return $this->_validateResult(
  278. $this->_dllAdvertiser->getAdvertiser($advertiserId, $oAdvertiser));
  279. } else {
  280. return false;
  281. }
  282. }
  283. /**
  284. * The getAdvertiserListByAgencyId method returns a list of advertisers
  285. * for a specified agency.
  286. *
  287. * @access public
  288. *
  289. * @param string $sessionId
  290. * @param integer $agencyId
  291. * @param array &$aAdvertiserList Array of OA_Dll_AdvertiserInfo classes
  292. *
  293. * @return boolean
  294. */
  295. function getAdvertiserListByAgencyId($sessionId, $agencyId, &$aAdvertiserList)
  296. {
  297. if ($this->verifySession($sessionId)) {
  298. return $this->_validateResult(
  299. $this->_dllAdvertiser->getAdvertiserListByAgencyId($agencyId,
  300. $aAdvertiserList));
  301. } else {
  302. return false;
  303. }
  304. }
  305. }
  306. ?>