public function partyFromId($partyId, $presenterId = null, $activeOnly = false) { App::uses("CustomizeProvider", "Lib"); $conditions = array("Party.id" => $partyId, "Party.error_message" => array('', 'An error occurred while processing this request. Please try again later.'), "Party.deleted_time is null"); if (!empty($presenterId)) { $conditions["Party.presenter_id"] = $presenterId; } if ($activeOnly) { $conditions[] = "end_time >= now()"; $conditions[] = "start_time <= now()"; } $party = $this->find('first', array('conditions' => $conditions, 'contain' => array('Presenter' => array("fields" => array("id", "presenter_sequence_id"), "User" => array("fields" => array("first_name", "last_name", "facebook_id", "largeimage"), "Email" => array("email")), "PresenterSite" => array("fields" => array("site_url"))), 'Hostess' => array("fields" => array("id", "first_name", "last_name", "facebook_id", "largeimage"), "UserOauth2" => array("fields" => array("provider", "imageUrl"), 'order' => 'UserOauth2.primary DESC', 'limit' => 1), "Email" => array("email")), 'ContactBook'))); if (!empty($party)) { $hostess_profile_imgs = CustomizeProvider::getProviderImages($party['Hostess']['UserOauth2'][0]['provider'], $party['Hostess']['UserOauth2'][0]['imageUrl'], $party['Hostess']['facebook_id']); $party['Hostess'] = array_merge($party['Hostess'], $hostess_profile_imgs); } return $party; }
public function setPrimaryAccount($id = null) { App::uses("CustomizeProvider", "Lib"); if (!empty($this->data['profileId'])) { $id = $this->data['profileId']; } if ($id) { //set primary = 0 where user_id and not id $this->UserOauth2->updateAll(array('primary' => 0), array('UserOauth2.user_id' => $this->Session->read('user_id'))); //set primary = 1 where id $this->UserOauth2->updateAll(array('primary' => 1), array('UserOauth2.id' => $id)); $presenterId = $this->Presenter->presenterIdFromUserId($this->Session->read('user_id')); $siteurl = $this->Session->read('siteurl'); $user = $this->User->find('first', array("contain" => array("UserOauth2" => array('order' => 'UserOauth2.primary DESC', 'limit' => 1)), 'conditions' => array("User.id" => $this->Session->read('user_id')))); if (isset($user['UserOauth2'][0])) { $user['UserOauth2'] = $user['UserOauth2'][0]; } $profile_imgs = CustomizeProvider::getProviderImages($user['UserOauth2']['provider'], $user['UserOauth2']['imageUrl'], $user['UserOauth2']['uid']); $this->Session->write("user.img", $profile_imgs['img_150']); if ($presenterId == $siteurl->id) { $siteurl->img_75 = $profile_imgs['img_75']; $siteurl->img_150 = $profile_imgs['img_150']; $siteurl->img_200 = $profile_imgs['img_200']; $this->Session->write("siteurl", $siteurl); } } // $this->profiles($this->Session->read('user_id')); $this->sendSuccess($this->Session->read('user_id')); }
public function websiteLinkDetails($presenterId, $usePresenterNumber = false) { if ($usePresenterNumber) { $conditions = array("Presenter.presenter_sequence_id" => $presenterId); } else { $conditions = array("Presenter.id" => $presenterId); } $presenter = $this->find('first', array("contain" => array("PresenterSite", "User" => array("Email", "Phone", "UserFacebookSocial", "UserOauth2" => array('order' => 'UserOauth2.primary DESC', 'limit' => 1)), 'Sponsor' => array("User")), 'conditions' => $conditions)); App::uses("CustomizeProvider", "Lib"); $img_array = CustomizeProvider::getProviderImages($presenter['User']['UserOauth2'][0]['provider'], $presenter['User']['UserOauth2'][0]['imageUrl'], $presenter['User']['facebook_id']); // check if current sponsor is active and compress if not $sponsor_id = $this->findActiveSponsor($presenter['Presenter']['id']); if ($presenter['Sponsor']['id'] != $sponsor_id) { $spon = new Presenter(); $sponsor = $spon->find('first', array("conditions" => array('Presenter.id' => $sponsor_id), "fields" => array("id", "user_id", "presenter_sequence_id"), "contain" => array("User" => array("fields" => array("first_name", "last_name", "id"), "Email" => array("fields" => array("email", "id"))), "PresenterSite" => array("fields" => array("site_url", "id"))))); $presenter['Sponsor'] = $sponsor['Presenter']; $presenter['Sponsor']['User'] = $sponsor['User']; $presenter['Sponsor']['PresenterSite'] = $sponsor['PresenterSite']; } if (!empty($presenter['User']['UserFacebookSocial'])) { $facebookUrl = $presenter['User']['UserFacebookSocial']['social_id']; } if (empty($facebookUrl)) { $facebookUrl = $presenter['User']['facebook_id']; } $facebookUrl = "https://www.facebook.com/" . $facebookUrl; $details = array("id" => $presenter['Presenter']['id'], "presenterNumber" => $presenter['Presenter']['presenter_sequence_id'], "name" => $presenter['User']['first_name'] . " " . $presenter['User']['last_name'], "siteurl" => $presenter['PresenterSite']['site_url'], "analytics_code" => $presenter['PresenterSite']['analytics_code'], "email" => $presenter['User']['Email']['email'], "phone" => $presenter['User']['Phone']['phone'], "sponsor" => $presenter['Sponsor']['User']['first_name'] . " " . $presenter['Sponsor']['User']['last_name'], "facebookurl" => $facebookUrl, "userid" => $presenter['Presenter']['user_id']); $details = array_merge($details, $img_array); return $details; }