public function theme($templateName) { if (YOUNIQUE_TESTSERVER == true) { $kudos_date = strtotime($this->SystemSetting->getSystemSetting("kudos_date", time())); } else { $kudos_date = time(); } $kudosMonth = strtolower(date("M", $kudos_date)); $language = $this->request->query['language']; $page_data = NULL; $usable_userLocale = $language; DruniqueAPIUtil::getData(['api_url' => 'page_blocks.json', 'params' => ['tag' => 'theme-page'], 'tag' => "theme-page_" . $usable_userLocale, 'locale' => $usable_userLocale, 'duration' => 'long'], $page_data); $templateObject = new stdClass(); $templateObject->kudos = array("id" => "3", "name" => DruniqueAPIUtil::bullet_r('Party Theme Names', $page_data, 0), "title" => DruniqueAPIUtil::bullet_r('Kudos Party Event Description', $page_data, 0), "event_desc" => html_entity_decode(DruniqueAPIUtil::content("Kudos Party Event Description", $page_data), ENT_QUOTES), "asset_id" => $kudosMonth . "/kudos-01.jpg", "plaintext" => "kudos", "youtube_channel_id" => "", "media_items" => array(array("asset_tag" => "Younique Kudos 1", "asset_id" => $kudosMonth . "/kudos-01.jpg"), array("asset_tag" => "Younique Kudos 2", "asset_id" => $kudosMonth . "/kudos-02.jpg")), "share_desc" => html_entity_decode(DruniqueAPIUtil::content("Kudos Party Share Description", $page_data), ENT_QUOTES), "share_img" => "/party/party_media/" . $kudosMonth . "/kudos-01.jpg"); $templateObject->lashes = array("id" => "1", "name" => DruniqueAPIUtil::bullet_r('Party Theme Names', $page_data, 1), "title" => DruniqueAPIUtil::bullet_r('Lash Party Event Description', $page_data, 0), "event_desc" => html_entity_decode(DruniqueAPIUtil::content('Lash Party Event Description', $page_data), ENT_QUOTES), "asset_id" => "theme_lashes.jpg", "plaintext" => "lashes", "youtube_channel_id" => "", "media_items" => array(array("asset_tag" => "Moodstruck Lashes Kit 1", "asset_id" => "theme_lashes.jpg"), array("asset_tag" => "Moodstruck Lashes Kit 2", "asset_id" => "lash1.jpg")), "share_desc" => html_entity_decode(DruniqueAPIUtil::content('Lash Party Share Description', $page_data), ENT_QUOTES), "share_img" => "/party/party_media/theme_lashes.jpg"); $templateObject->lips = array("id" => "2", "name" => DruniqueAPIUtil::bullet_r('Party Theme Names', $page_data, 2), "title" => DruniqueAPIUtil::bullet_r('Luscious Lips Party Event Description', $page_data, 0), "event_desc" => html_entity_decode(DruniqueAPIUtil::content('Luscious Lips Party Event Description', $page_data), ENT_QUOTES), "asset_id" => "theme_lips.jpg", "plaintext" => "lips", "youtube_channel_id" => "", "media_items" => array(array("asset_tag" => "Lip BonBon Party 1", "asset_id" => "theme_lips.jpg"), array("asset_tag" => "Lucrative Lip Gloss 1", "asset_id" => "lip1.jpg"), array("asset_tag" => "Lucrative Lip Gloss 2", "asset_id" => "lip2.jpg"), array("asset_tag" => "Stiff Upper Lip Lip Stain 1", "asset_id" => "lip3.jpg"), array("asset_tag" => "Opulence Lipstick Party 1", "asset_id" => "theme_opulencelipstick.jpg"), array("asset_tag" => "Opulence Lipstick Party 2", "asset_id" => "opulencelipstick1.jpg"), array("asset_tag" => "Opulence Lipstick Party 3", "asset_id" => "opulencelipstick2.jpg")), "share_desc" => html_entity_decode(DruniqueAPIUtil::content('Luscious Lips Party Share Description', $page_data), ENT_QUOTES), "share_img" => "/party/party_media/theme_lips.jpg"); $templateObject->opulencelipstick = array("id" => "7", "name" => DruniqueAPIUtil::bullet_r('Party Theme Names', $page_data, 6), "title" => DruniqueAPIUtil::bullet_r('Younique Virtual Party', $page_data, 0), "event_desc" => html_entity_decode(DruniqueAPIUtil::content("Younique Virtual Party", $page_data), ENT_QUOTES), "asset_id" => "theme_opulencelipstick.jpg", "plaintext" => "opulencelipstick", "youtube_channel_id" => "PLBIUEB1d9Q3nif7HalOCYwloaeCT0GHDO", "media_items" => array(array("asset_tag" => "Opulence Lipstick Party 1", "asset_id" => "theme_opulencelipstick.jpg"), array("asset_tag" => "Opulence Lipstick Party 2", "asset_id" => "opulencelipstick1.jpg"), array("asset_tag" => "Opulence Lipstick Party 3", "asset_id" => "opulencelipstick2.jpg")), "share_desc" => DruniqueAPIUtil::bullet_r('Younique Virtual Party', $page_data, 1), "share_img" => "/party/party_media/theme_opulencelipstick.jpg"); $templateObject->eyeProducts = array("id" => "9", "name" => DruniqueAPIUtil::bullet_r('Party Theme Names', $page_data, 12), "title" => DruniqueAPIUtil::bullet_r('Younique Virtual Party', $page_data, 0), "event_desc" => html_entity_decode(DruniqueAPIUtil::content("Younique Virtual Party", $page_data), ENT_QUOTES), "asset_id" => "theme_shadowpalette.jpg", "plaintext" => "eyeProducts", "youtube_channel_id" => "", "media_items" => array(array("asset_tag" => "Moodstruck Addiction Shadow Palette Party 1", "asset_id" => "theme_shadowpalette.jpg"), array("asset_tag" => "Shadow Palette Party 2", "asset_id" => "shadowpalette1.jpg"), array("asset_tag" => "Shadow Palette Party 3", "asset_id" => "shadowpalette2.jpg"), array("asset_tag" => "Moodstruck Precision Brow Products Party 1", "asset_id" => "theme_browproducts.jpg"), array("asset_tag" => "Brow Products Party 2", "asset_id" => "browproducts1.jpg"), array("asset_tag" => "Moodstruck Lashes Kit 2", "asset_id" => "lash1.jpg")), "share_desc" => DruniqueAPIUtil::bullet_r('Younique Virtual Party', $page_data, 1), "share_img" => "/party/party_media/theme_shadowpalette.jpg"); $templateObject->faceProducts = array("id" => "8", "name" => DruniqueAPIUtil::bullet_r('Party Theme Names', $page_data, 11), "title" => DruniqueAPIUtil::bullet_r('Younique Virtual Party', $page_data, 0), "event_desc" => html_entity_decode(DruniqueAPIUtil::content("Younique Virtual Party", $page_data), ENT_QUOTES), "asset_id" => "theme_concealer.jpg", "plaintext" => "faceProducts", "youtube_channel_id" => "", "media_items" => array(array("asset_tag" => "TOUCH Minerals Skin Perfecting Concealer Party 1", "asset_id" => "theme_concealer.jpg"), array("asset_tag" => "Concealer Party 2", "asset_id" => "concealer1.jpg"), array("asset_tag" => "Concealer Party 3", "asset_id" => "concealer2.jpg"), array("asset_tag" => "TOUCH Minerals Liquid Foundation Party 1", "asset_id" => "theme_liquidfoundation.jpg"), array("asset_tag" => "Foundation Party 2", "asset_id" => "liquidfoundation1.jpg"), array("asset_tag" => "Foundation Party 3", "asset_id" => "liquidfoundation2.jpg")), "share_desc" => DruniqueAPIUtil::bullet_r('Younique Virtual Party', $page_data, 1), "share_img" => "/party/party_media/theme_concealer.jpg"); $templateObject->beachfront = array("id" => "10", "name" => DruniqueAPIUtil::bullet_r('Party Theme Names', $page_data, 9), "title" => DruniqueAPIUtil::bullet_r('Younique Virtual Party', $page_data, 0), "event_desc" => html_entity_decode(DruniqueAPIUtil::content("Younique Virtual Party", $page_data), ENT_QUOTES), "asset_id" => "theme_beachfront.jpg", "plaintext" => "beachfront", "youtube_channel_id" => "", "media_items" => array(array("asset_tag" => "Beachfront Party", "asset_id" => "theme_beachfront.jpg"), array("asset_tag" => "Beachfront Party 2", "asset_id" => "beachfront1.jpg"), array("asset_tag" => "Beachfront Party 3", "asset_id" => "beachfront2.jpg"), array("asset_tag" => "Beachfront Party 4", "asset_id" => "beachfront3.jpg"), array("asset_tag" => "Beachfront Party 5", "asset_id" => "beachfront4.jpg")), "share_desc" => DruniqueAPIUtil::bullet_r('Younique Virtual Party', $page_data, 1), "share_img" => "/party/party_media/theme_beachfront.jpg"); $templateObject->liquidEyeliner = array("id" => "11", "name" => DruniqueAPIUtil::bullet_r('Party Theme Names', $page_data, 10), "title" => DruniqueAPIUtil::bullet_r('Younique Virtual Party', $page_data, 0), "event_desc" => html_entity_decode(DruniqueAPIUtil::content("Younique Virtual Party", $page_data), ENT_QUOTES), "asset_id" => "theme_liquidEyeliner.jpg", "plaintext" => "liquidEyeliner", "youtube_channel_id" => "", "media_items" => array(array("asset_tag" => "Eyeliner Party", "asset_id" => "theme_liquidEyeliner.jpg"), array("asset_tag" => "Eyeliner Party 2", "asset_id" => "liquidEyeliner1.jpg")), "share_desc" => DruniqueAPIUtil::bullet_r('Younique Virtual Party', $page_data, 1), "share_img" => "/party/party_media/theme_liquidEyeliner.jpg"); $templateObject->standard = array("id" => "4", "name" => DruniqueAPIUtil::bullet_r('Party Theme Names', $page_data, 3), "title" => DruniqueAPIUtil::bullet_r('Younique Virtual Party', $page_data, 0), "event_desc" => html_entity_decode(DruniqueAPIUtil::content("Younique Virtual Party", $page_data), ENT_QUOTES), "asset_id" => "theme_default.jpg", "plaintext" => "standard", "youtube_channel_id" => "PLBIUEB1d9Q3nMvzkrL_75cI_tkt-30Xjj", "media_items" => array(array("asset_tag" => "Default Party 1", "asset_id" => "theme_default.jpg"), array("asset_tag" => "Default Party 2", "asset_id" => "default1.jpg")), "share_desc" => DruniqueAPIUtil::bullet_r('Younique Virtual Party', $page_data, 1), "share_img" => "/party/party_media/theme_default.jpg"); if ($templateName) { $this->sendSuccess($templateObject->{$templateName}); } else { $this->sendSuccess($templateObject); } }
/** * Get Item drupal content for admin * @param $sku * @return null */ protected function getItemDrupal($sku) { if (empty($sku)) { return null; } $drupal = null; DruniqueAPIUtil::getData(['api_url' => 'product.json', 'params' => ['sku' => $sku], 'tag' => 'product_' . $sku, 'locale' => 'en_US', 'duration' => 'long'], $drupal); return $drupal; }
/** * Wrapper of CakeEmail object creation and submission. * @param $emailData * @param string $templateName * @param string $to * @param string $subjectBlockName * @param string $tag * @param string $locale * @param bool $debug * @param array $emailOptions * @return string * @throws Exception */ public static function sendEmail($emailData, $templateName = '', $to = '', $subjectBlockName = '', $tag = '', $locale = 'en-US', $debug = false, $emailOptions = array()) { if (empty($templateName) || empty($to) || empty($subjectBlockName)) { CakeLog::error('CRITICAL EXEPTION: In email library.'); CakeLog::error('Empty argument passed to email sender.'); throw new BadMethodCallException('Empty argument passed to email sender.', 1); return false; } // Since getting the data from Drupal happens in-line we need to check // for errors by seeing if we only get log_info back and nothing else. if (!empty($tag)) { $drupalData = array(); DruniqueAPIUtil::getData(['api_url' => 'email_text.json', 'params' => ['tag' => $tag], 'locale' => $locale], $drupalData); if (sizeof($drupalData) <= 1) { CakeLog::error('CRITICAL EXEPTION: In email library.'); CakeLog::error('Unable to get view variables from CMS.'); throw new Exception('Unable to get view variables from CMS.', 1); return false; } $emailData['email_text'] = $drupalData; } $email = new CakeEmail('default'); $subject = DruniqueAPIUtil::content($subjectBlockName, $emailData['email_text']); $subject = preg_replace('/[\\pZ\\pC]/u', ' ', $subject); if ($debug) { $email->transport('Debug'); } // Make sure format is set correctly based on existence of templates. $format = 'both'; $htmlTemplateExists = is_readable(APP . "View/Emails/html/{$templateName}.ctp"); $textTemplateExists = is_readable(APP . "View/Emails/text/{$templateName}.ctp"); if (!$htmlTemplateExists && !$textTemplateExists) { CakeLog::error('CRITICAL ERROR: In email library.'); CakeLog::error("Unable to find email template named {$templateName}.ctp"); return false; } elseif (!$htmlTemplateExists && $textTemplateExists) { $format = 'text'; } elseif ($htmlTemplateExists && !$textTemplateExists) { $format = 'html'; } $email->template($templateName, 'default')->emailFormat($format)->to($to)->subject(html_entity_decode($subject, ENT_QUOTES))->viewVars($emailData); if (isset($emailOptions['bcc'])) { $email->bcc($emailOptions['bcc']); } if (isset($emailOptions['cc'])) { $email->cc($emailOptions['cc']); } try { $response = $email->send(); if ($debug) { return $response; } if ($response) { $result = 'Email was sent successfully'; } else { $result = 'Email failed to send without exceptions'; CakeLog::error('CRITICAL ERROR: Email library failed to send an email without exception.'); Cakelog::error(print_r($email, true)); } } catch (Exception $e) { $result = 'Email failed with exception: ' . print_r($e->getMessage(), true); CakeLog::error('CRITICAL ERROR: In email library.'); CakeLog::error($e->getMessage()); } return $result; }
public function createECBAccomplishment($userToReceive, $eligibleStatus, $yearmonth) { $page_data = NULL; $usable_userLocale = empty($userToReceive['User']['user_default_locale']) ? 'en_US' : $userToReceive['User']['user_default_locale']; DruniqueAPIUtil::getData(['api_url' => 'page_blocks.json', 'params' => ['tag' => 'createECBAccomplishment-page'], 'tag' => "createECBAccomplishment-page_" . $usable_userLocale, 'locale' => $usable_userLocale, 'duration' => 'long'], $page_data); $userName = $userToReceive['User']['first_name'] . " " . $userToReceive['User']['last_name']; switch ($eligibleStatus) { case 5: $accomplishmentType = "ecbgreen"; $accomplishmentMessage = DruniqueAPIUtil::content('eliteconsistencyaccomplishment_0', $page_data, $userName); $fullaccomplishmentType = "fullecbgreen"; $fullaccomplishmentMessage = DruniqueAPIUtil::content('eliteconsistencyaccomplishment_1', $page_data, $userName); break; case 6: $accomplishmentType = "ecborange"; $accomplishmentMessage = DruniqueAPIUtil::content('eliteconsistencyaccomplishment_2', $page_data, $userName); $fullaccomplishmentType = "fullecborange"; $fullaccomplishmentMessage = DruniqueAPIUtil::content('eliteconsistencyaccomplishment_3', $page_data, $userName); break; } //Give the presenter an accomplishment for their efforts $this->saveCreate(array('type' => $accomplishmentType, 'bragger' => 1, 'user_id' => $userToReceive['User']['id'], 'message' => $accomplishmentMessage, 'datetime' => date('Y-m-d h:i:s'), 'reference_id' => $yearmonth, 'facebook_id' => '-1')); //Has the presenter earned all four months? Give them another accomplishment $countECB = $this->find('count', array('conditions' => array('user_id' => $userToReceive['User']['id'], 'type' => $accomplishmentType))); if ($countECB == 4) { $this->saveCreate(array('type' => $fullaccomplishmentType, 'bragger' => 1, 'user_id' => $userToReceive['User']['id'], 'message' => $fullaccomplishmentMessage, 'datetime' => date('Y-m-d h:i:s'), 'facebook_id' => '-1')); } }