1<?php 2 3/** 4 * OrangeHRM is a comprehensive Human Resource Management (HRM) System that captures 5 * all the essential functionalities required for any enterprise. 6 * Copyright (C) 2006 OrangeHRM Inc., http://www.orangehrm.com 7 * 8 * OrangeHRM is free software; you can redistribute it and/or modify it under the terms of 9 * the GNU General Public License as published by the Free Software Foundation; either 10 * version 2 of the License, or (at your option) any later version. 11 * 12 * OrangeHRM is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 13 * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 14 * See the GNU General Public License for more details. 15 * 16 * You should have received a copy of the GNU General Public License along with this program; 17 * if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 18 * Boston, MA 02110-1301, USA 19 */ 20 21/** 22 * Description of BuzzServiceWrapper 23 * 24 * @author nirmal 25 */ 26class BuzzServiceWrapper implements WebServiceWrapper { 27 28 protected $buzzWebServiceHelper; 29 30 const DEFAULT_SHARE_LIMIT = 10; 31 32 public function getServiceInstance() { 33 if (!$this->buzzWebServiceHelper instanceof BuzzWebServiceHelper) { 34 $this->buzzWebServiceHelper = new BuzzWebServiceHelper(); 35 } 36 return $this->buzzWebServiceHelper; 37 } 38 39 /** 40 * Get Current Logged in Employee Number 41 * @param type $options 42 */ 43 public function getLoggedInEmployeeNumber() { 44 return sfContext::getInstance()->getUser()->getAttribute("auth.empNumber"); 45 } 46 47 /** 48 * 49 * @api {get} /getLoggedInEmployee Get LoggedIn Employee 50 * @apiDescription Get LoggedIn Employee 51 * @apiVersion 0.1.0 52 * @apiName getLoggedInEmployee 53 * @apiGroup BUZZ 54 * @apiSuccess {Array} Employee Logged in employee 55 */ 56 public function getLoggedInEmployee() { 57 return $this->getServiceInstance()->getLoggedInEmployee(); 58 } 59 60 /** 61 * 62 * @api {get} /getLatestBuzzShares/recentShareId/:recentShareId Get Latest Buzz Shares 63 * @apiDescription Get Latest Buzz Shares 64 * @apiVersion 0.1.0 65 * @apiName getLatestBuzzShares 66 * @apiGroup BUZZ 67 * @apiSuccess {Array} Shares Get latest shares 68 */ 69 public function getLatestBuzzShares($recentShareId) { 70 return $this->getServiceInstance()->getLatestBuzzShares($recentShareId); 71 } 72 73 /** 74 * 75 * @api {get} /getBuzzShares/limit/:limit Get shares 76 * @apiDescription Get shares 77 * @apiVersion 0.1.0 78 * @apiName getBuzzShares 79 * @apiGroup BUZZ 80 * @apiSuccess {Array} Shares Get recent [at first load] shares default number of shares are 10 81 */ 82 public function getBuzzShares($limit) { 83 return $this->getServiceInstance()->getBuzzShares($limit); 84 } 85 86 87 /** 88 * 89 * @api {get} /getMoreBuzzShares/lastShareId/:lastShareId/limit/:limit Get More shares 90 * @apiDescription Get More shares 91 * @apiVersion 0.1.0 92 * @apiName getMoreBuzzShares 93 * @apiGroup BUZZ 94 * @apiSuccess {Array} Shares Get shares older than a given share Id 95 */ 96 public function getMoreBuzzShares($lastShareId, $limit) { 97 return $this->getServiceInstance()->getMoreBuzzShares($lastShareId, $limit); 98 } 99 100 101 /** 102 * 103 * @api {get} /getShareAndPostDetailsByShareId/shareId/:shareId Get share by share id 104 * @apiDescription Get share by share id 105 * @apiVersion 0.1.0 106 * @apiName getShareAndPostDetailsByShareId 107 * @apiGroup BUZZ 108 * @apiError shareIdIsNotValid Valid parameters are not provided 109 * @apiSuccess {Array} Shares Get share and post details by share id, this will retun post details, comment and like details, etc 110 */ 111 public function getShareAndPostDetailsByShareId($shareId) { 112 if (is_null($shareId)) { 113 throw new Exception("Valid parameters are not provided"); 114 } else { 115 return $this->getServiceInstance()->getShareAndPostDetailsByShareId($shareId); 116 } 117 } 118 119 /** 120 * 121 * @api {get} /postContentOnFeed/contentText/:contentText/image_data/:image_data Post content on news feed 122 * @apiDescription Post content on news feed 123 * @apiVersion 0.1.0 124 * @apiName postContentOnFeed 125 * @apiGroup BUZZ 126 * @apiError contentTextAndimage_dataIsNull Valid parameters are not provided 127 * @apiSuccess {Array} Share Share 128 */ 129 public function postContentOnFeed($contentText, $image_data) { 130 if (is_null($contentText)) { 131 throw new Exception("Valid parameters are not provided"); 132 } else { 133 $empNumber = $this->getLoggedInEmployeeNumber(); 134 return $this->getServiceInstance()->postContentOnFeed($empNumber, $contentText, date("Y-m-d H:i:s"), $image_data); 135 } 136 } 137 138 139 /** 140 * 141 * @api {get} /getBuzzImage/imageId/:imageId 142 * @apiDescription Gets the image from the id 143 * @apiVersion 0.1.0 144 * @apiName getBuzzImage 145 * @apiGroup BUZZ 146 * @apiSuccess Photo 147 */ 148 public function getBuzzImage($imageId) { 149 $this->getServiceInstance()->getBuzzImage($imageId); 150 } 151 152 /** 153 * 154 * @api {get} /getEmployeeImage/empNumber/:empNumber 155 * @apiDescription Gets the image of employee from the empNumber 156 * @apiVersion 0.1.0 157 * @apiName getEmployeeImage 158 * @apiGroup BUZZ 159 * @apiSuccess Photo 160 */ 161 public function getEmployeeImage($empNumber) { 162 $this->getServiceInstance()->getEmployeeImage($empNumber); 163 } 164 165 /** 166 * 167 * @api {get} /commentOnShare/shareId/:shareId/contentText/:contentText Comment On Share 168 * @apiDescription Comment On Share 169 * @apiVersion 0.1.0 170 * @apiName commentOnShare 171 * @apiGroup BUZZ 172 * @apiError shareIdAndcontentTextIsNull Valid parameters are not provided 173 * @apiSuccess {Array} Comment Comment added to the share 174 */ 175 public function commentOnShare($shareId, $contentText) { 176 if (is_null($shareId && $contentText)) { 177 throw new Exception("Valid parameters are not provided"); 178 } else { 179 $empNumber = $this->getLoggedInEmployeeNumber(); 180 return $this->getServiceInstance()->commentOnShare($shareId, $empNumber, $contentText, date("Y-m-d H:i:s")); 181 } 182 } 183 184 /** 185 * 186 * @api {get} /likeOnShare/shareId/:shareId Like On Share 187 * @apiDescription Like on a share / post 188 * @apiVersion 0.1.0 189 * @apiName likeOnShare 190 * @apiGroup BUZZ 191 * @apiError shareIdIsNull Valid parameters are not provided 192 * @apiSuccess {Array} Share Share that is liked 193 */ 194 public function likeOnShare($shareId) { 195 if (is_null($shareId)) { 196 throw new Exception("Valid parameters are not provided"); 197 } else { 198 $empNumber = $this->getLoggedInEmployeeNumber(); 199 return $this->getServiceInstance()->likeOnShare($shareId, $empNumber, date("Y-m-d H:i:s")); 200 } 201 } 202 203 /** 204 * 205 * @api {get} /disLikeOnShare/shareId/:shareId Dislike On Share 206 * @apiDescription Dislike on a share / post 207 * @apiVersion 0.1.0 208 * @apiName disLikeOnShare 209 * @apiGroup BUZZ 210 * @apiError shareIdIsNull Valid parameters are not provided 211 * @apiSuccess {Array} Share Share that is disliked 212 */ 213 public function disLikeOnShare($shareId) { 214 if (is_null($shareId)) { 215 throw new Exception("Valid parameters are not provided"); 216 } else { 217 $empNumber = $this->getLoggedInEmployeeNumber(); 218 return $this->getServiceInstance()->dislikeOnShare($shareId, $empNumber, date("Y-m-d H:i:s")); 219 } 220 } 221 222 /** 223 * 224 * @api {get} /likeOnComment/commentId/:commentId Like on a comment 225 * @apiDescription Like on a comment 226 * @apiVersion 0.1.0 227 * @apiName likeOnComment 228 * @apiGroup BUZZ 229 * @apiError commentIdIsNull Valid parameters are not provided 230 * @apiSuccess {Array} Comment Comment that is liked 231 */ 232 public function likeOnComment($commentId) { 233 if (is_null($commentId)) { 234 throw new Exception("Valid parameters are not provided"); 235 } else { 236 $empNumber = $this->getLoggedInEmployeeNumber(); 237 return $this->getServiceInstance()->likeOnComment($commentId, $empNumber, date("Y-m-d H:i:s")); 238 } 239 } 240 241 /** 242 * 243 * @api {get} /dislikeOnComment/commentId/:commentId Dislike on a comment 244 * @apiDescription Dislike on a comment 245 * @apiVersion 0.1.0 246 * @apiName dislikeOnComment 247 * @apiGroup BUZZ 248 * @apiError commentIdIsNull Valid parameters are not provided 249 * @apiSuccess {Array} Comment Comment that is disliked 250 */ 251 public function dislikeOnComment($commentId) { 252 if (is_null($commentId)) { 253 throw new Exception("Valid parameters are not provided"); 254 } else { 255 $empNumber = $this->getLoggedInEmployeeNumber(); 256 return $this->getServiceInstance()->dislikeOnComment($commentId, $empNumber, date("Y-m-d H:i:s")); 257 } 258 } 259 260 /** 261 * 262 * @api {get} /sharePost/shareId/:shareId Share Post 263 * @apiDescription Sharing a share / post 264 * @apiVersion 0.1.0 265 * @apiName sharePost 266 * @apiGroup BUZZ 267 * @apiError shareIdIsNull Valid parameters are not provided 268 * @apiSuccess {Array} Share Shared Post 269 */ 270 public function sharePost($postId, $newText){ 271 if (!is_null($postId) || !is_null($newText)) { 272 $empNumber = $this->getLoggedInEmployeeNumber(); 273 return $this->getServiceInstance()->sharePost($postId, $empNumber, $newText); 274 } else { 275 throw new Exception("Valid parameters are not provided"); 276 } 277 } 278 279 /** 280 * 281 * @api {get} /getBuzzForEmployee/:empNum Get buzz by employee 282 * @apiDescription Get buzz by employee number 283 * @apiVersion 0.1.0 284 * @apiName getBuzzForEmployee 285 * @apiGroup BUZZ 286 * @apiError empNum Is Null Valid parameters are not provided 287 * @apiSuccess {Array} Shares Get shares made by the Employee 288 */ 289 public function getBuzzForEmployee($empNum) { 290 if (!is_null($empNum)) { 291 $loggedInEmpNumber = $this->getLoggedInEmployeeNumber(); 292 return $this->getServiceInstance()->getBuzzForEmployee($empNum,$loggedInEmpNumber); 293 } else { 294 throw new Exception("Valid parameters are not provided"); 295 } 296 } 297 298 /** 299 * 300 * @api {post} /deleteShare/:shareId Delete Post 301 * @apiDescription Delete a share 302 * @apiVersion 0.1.0 303 * @apiName deleteShare 304 * @apiGroup BUZZ 305 * @apiError shareId Is Null Valid parameters are not provided 306 * @apiSuccess {Array} Share delete success state 307 */ 308 public function deleteShare($shareId) { 309 if (!is_null($shareId)) { 310 $loggedInEmployeeNumber = $this->getLoggedInEmployeeNumber(); 311 return $this->getServiceInstance()->deleteShare($shareId, $loggedInEmployeeNumber); 312 } else { 313 throw new Exception("Valid parameters are not provided"); 314 } 315 } 316 317 /** 318 * 319 * @api {post} /deleteComment/:commentId Delete Comment 320 * @apiDescription Delete a comment 321 * @apiVersion 0.1.0 322 * @apiName deleteComment 323 * @apiGroup BUZZ 324 * @apiError commentId Is Null Valid parameters are not provided 325 * @apiSuccess {Array} Share comment delete success state 326 */ 327 public function deleteComment($commentId) { 328 if (!is_null($commentId)) { 329 $loggedInEmployeeNumber = $this->getLoggedInEmployeeNumber(); 330 return $this->getServiceInstance()->deleteCommentForShare($commentId, $loggedInEmployeeNumber); 331 } else { 332 throw new Exception("Valid parameters are not provided"); 333 } 334 } 335 336} 337