public function createObj($paginator, $flag) { $tag_arr = array(); $all_tags_arr = array(); $sub_cat_data = ""; $all_tags_str = ""; $obj_user->success = "true"; $user_id = 0; if ($flag == "deal") { $obj_user->Deals = new stdClass(); } if ($flag == "business") { $obj_user->Businesses = new stdClass(); } $arr = array(); foreach ($paginator as $item) { $obj_deal = new App_Model_Deal(); $obj_name = 'object'; $obj_name = new stdClass(); if (isset($item['user_id'])) { $user_id = $item['user_id']; } if (isset($item['id']) && $flag == "deal") { $obj_name->deal_id = $item['id']; } if (isset($item['type'])) { $obj_name->deal_type = $item['type']; } if (isset($item['business_id']) && $flag == "business") { $obj_name->business_id = $item['business_id']; } if (isset($item['id'])) { $mark_as_fav_status_deal = $obj_deal->checkFavouriteDealBusinesssModule($user_id, $item['id'], 'deal'); } $obj_name->favourite_flag_deal = $mark_as_fav_status_deal; if (isset($item['business_id'])) { $mark_as_fav_status_business = $obj_deal->checkFavouriteDealBusinesssModule($user_id, $item['business_id'], 'business'); $obj_name->favourite_flag_business = $mark_as_fav_status_business; } $obj_name->title = $item['tiny_description']; $obj_name->latitude = $item['latitude']; $obj_name->longitude = $item['longitude']; $obj_name->address = $item['address']; $obj_name->description = $item['description']; if (isset($item['user_id'])) { $obj_name->user_id = $item['user_id']; } if (isset($item['buss_cat_id'])) { $obj_name->category_id = $item['buss_cat_id']; $obj_subcategoryapifunction = new App_Model_SubCategoryAPIFunction(); $sub_cat_data = $obj_subcategoryapifunction->getSubCategory($item['buss_cat_id'], $item['id']); } if (isset($item['buss_id'])) { $obj_name->business_id = $item['buss_id']; } if (isset($item['buss_name'])) { $obj_name->business_name = $item['buss_name']; } if (isset($sub_cat_data)) { if (sizeof($sub_cat_data) > 1) { $obj_name->tags = $sub_cat_data[1]; } } if (sizeof($sub_cat_data) > 1) { $all_tags_str .= $sub_cat_data[2]; } array_push($arr, $obj_name); } //end of for if ($flag == "deal") { $obj_user->Deals->record = $arr; } if ($flag == "business") { $obj_user->Businesses->record = $arr; } $total_records_count = $paginator->getTotalItemCount(); $obj_user->totalrecord = $total_records_count; if (isset($sub_cat_data)) { $all_tags_arr = explode("|", $all_tags_str); array_pop($all_tags_arr); $all_tags_arr_unique = array_unique($all_tags_arr); $obj_user->AllTagArr = $all_tags_arr_unique; } return $obj_user; }
/** @var obj_user * $obj_user = array() */ public function makAsFavourite($data) { $obj_user = array(); $obj_create = new App_Model_Objcreation(); $obj_chkapi = new App_Model_Chkapi(); $validation_result = $obj_chkapi->chkAPI($data); if ($validation_result == 1) { try { $obj = new App_Model_Deal(); $result = $obj->markAsFavouriteDealModule($data); if ($result == "set" || $result == "unset") { $obj_user = $obj_create->createObjFavourite($data, $result); } elseif ($result == "2") { $obj_user = $obj_create->createObjfalse(4); } else { $obj_user = $obj_create->createObjfalse(0); } } catch (exception $e) { $obj_user = $obj_create->createObjfalse(3); } } else { $obj_user = $obj_create->createObjfalse(2); } return $obj_user; }