/** * Send reply to contact request * * @param string $replyMessage */ public function reply($replyMessage) { $this->setStatus(Fox_Contact_Model_Contact::STATUS_REPLIED); $this->save(); $modelTemplate = Fox::getModel('core/email/template'); $modelTemplate->sendTemplateMail(Fox::getPreference('contact/reply/email_template'), $this->getEmail(), array('sender_email' => Fox::getPreference('contact/reply/email'), 'sender_name' => Fox::getPreference('contact/reply/name')), array('name' => $this->getName(), 'subject' => $this->getSubject(), 'message' => $this->getMessage(), 'reply' => $replyMessage)); }
/** * Get menu html * * @param string $key Menu group key * @return string */ public function getMenu($key) { $menuHTML = ''; $cacheSettings = Uni_Core_CacheManager::loadCacheSettings(); $isCacheEnabled = isset($cacheSettings[Fox_Core_Model_Cache::CACHE_CODE_LAYOUT]) ? $cacheSettings[Fox_Core_Model_Cache::CACHE_CODE_LAYOUT] : FALSE; $package = Fox::getPreference(Uni_Controller_Action::MODE_ADMIN . '/package'); $theme = Fox::getPreference(Uni_Controller_Action::MODE_ADMIN . '/theme'); $cacheMenuBasePath = CACHE_DIR . DIRECTORY_SEPARATOR . Fox_Core_Model_Cache::CACHE_CODE_LAYOUT . DIRECTORY_SEPARATOR . Uni_Controller_Action::MODE_WEB . DIRECTORY_SEPARATOR . $package . DIRECTORY_SEPARATOR . $theme . DIRECTORY_SEPARATOR . self::CACHE_MENU_FOLDER; file_exists($cacheMenuBasePath) && is_dir($cacheMenuBasePath) || mkdir($cacheMenuBasePath, 0777, TRUE); $cacheMenuPath = $cacheMenuBasePath . DIRECTORY_SEPARATOR . $key . '.menu'; if ($isCacheEnabled && file_exists($cacheMenuPath)) { $cacheMenuDoc = new DOMDocument(); $cacheMenuDoc->loadHTMLFile($cacheMenuPath); $menuHTML = $cacheMenuDoc->saveXML(); unset($cacheMenuDoc); } else { $menuGroupModel = Fox::getModel('navigation/menugroup'); $menuGroupModel->load($key, 'key'); if ($menuGroupModel->getId() && $menuGroupModel->getStatus() == Fox_Navigation_Model_Menugroup::STATUS_ENABLED) { $menuModel = Fox::getModel('navigation/menu'); $menuList = $menuModel->getMenuItemsByGroup($key); $mnuDoc = new DOMDocument(); $mnuDoc->formatOutput = true; $mnuRoot = NULL; if (count($menuList)) { $mnuRoot = Uni_Data_XDOMDocument::createNode(self::ROOT_TAG, array('class' => 'menu_container'), $mnuDoc); $mnuDoc->appendChild($mnuRoot); foreach ($menuList as $menu) { $node = Uni_Data_XDOMDocument::createNode(self::LEAF_TAG, array('class' => 'menu_nav' . ($menu['style_class'] ? ' ' . $menu['style_class'] : '')), $mnuDoc); if (strpos($menu['link'], 'http://', 0) === 0 || strpos($menu['link'], 'https://', 0) === 0) { $link = $menu['link']; } else { $link = Fox::getUrl($menu['link']); } $link = Uni_Data_XDOMDocument::createNode('a', array('href' => $link, 'target' => $menu['open_window'], 'class' => $menu['style_class']), $mnuDoc); $link->appendChild($mnuDoc->createTextNode($menu['title'])); $node->appendChild($link); $mnuRoot->appendChild($node); } } if (isset($mnuDoc)) { $menuHTML = $mnuDoc->saveXML($mnuRoot); if ($isCacheEnabled) { $mnuDoc->saveHTMLFile($cacheMenuPath); @chmod($cacheMenuPath, 0777); } } unset($mnuDoc); } } return $menuHTML; }
/** * Check stability is reliable * * @return boolean */ private function isReliableStability() { $packageInfo = $this->getViewOptions('package'); if (isset($packageInfo['stability']) && $packageInfo['stability']) { if ($packageInfo['stability'] >= Fox::getPreference('extensionmanager/downloader/preferred_state')) { return true; } else { $this->messages[] = "This extension is under " . Fox::getModel('extensionmanager/package/state')->getOptionText($packageInfo['stability']) . " state"; } } else { $this->messages[] = "Unknown stability"; } return false; }
/** * Loads layout for current module, controller, action. * * @param string $layoutUpdate * @param string $updateKey * * @return Uni_Core_LayoutManager */ public function loadLayout($layoutUpdate = NULL, $updateKey = NULL) { if (NULL == $this->layout) { $request = $this->getRequest(); $package = 'core'; $theme = 'default'; if ($this->appMode != self::MODE_INSTALL) { $package = Fox::getPreference($this->appMode . '/design/package'); $theme = Fox::getPreference($this->appMode . '/design/theme'); } $this->layout = new Uni_Core_LayoutManager($this->getFrontController()->getBaseUrl(), $request->getModuleName(), $request->getControllerName(), $request->getActionName(), $this->appMode, $package, $theme); $this->layout->load($layoutUpdate, $updateKey); } return $this->layout; }
/** * Subscribe action */ function subscribeAction() { if ($this->getRequest()->isPost()) { $data = $this->getRequest()->getPost(); $subscriberModel = Fox::getModel('newsletter/subscriber'); try { $subscriberModel->subscribe($data); if (Fox::getPreference('newsletter/subscription/need_to_confirm')) { Fox::getHelper('core/message')->setInfo('Confirmation request has been sent to your email.'); } else { Fox::getHelper('core/message')->setInfo('Thank you for your subscription.'); } } catch (Exception $e) { Fox::getHelper('core/message')->setError('There was a problem with the subscription.'); } } $this->redirectReferer(); }
/** * Index action */ public function indexAction() { if ($this->getRequest()->isPost()) { try { $data = $this->getRequest()->getPost(); $model = Fox::getModel('contact/contact'); $data['status'] = Fox_Contact_Model_Contact::STATUS_UNREAD; $data['contact_date'] = Fox_Core_Model_Date::getCurrentDate('Y-m-d H:i:s'); $model->setData($data); $model->save(); try { Fox::getHelper('core/message')->setInfo("Your request was successfully sent."); $modelTemplate = Fox::getModel('core/email/template'); $modelTemplate->sendTemplateMail(Fox::getPreference('contact/receiver/email_template'), Fox::getPreference('contact/receiver/email'), array('sender_name' => $data['name'], 'sender_email' => $data['email']), $data); } catch (Exception $e) { } } catch (Exception $e) { Fox::getHelper('core/message')->setError($e->getMessage()); } } $this->loadLayout(); $this->renderLayout(); }
/** * Retrieve exception printing status * * @return int Returns 1 if exception printing is enabled */ function isExceptionPrintingEnabled() { return Fox::getPreference('core/debug/exception_printing'); }
/** * Retrieve member session timeout interval in seconds * * @return int */ public static function getMemberSessionInterval() { $sessionInterval = Fox::getPreference('member/login/online_minutes_interval'); return $sessionInterval > 0 ? $sessionInterval * 60 : self::$defaultMemberSessionInterval; }
/** * Send template email * * @param int $templateId Template id * @param string $to Recipient email * @param mixed $sender array|string * @param array $vars Template variables * @param array $bcc Bcc email ids * @throws Exception if template not found */ public function sendTemplateMail($templateId, $to, $sender, $vars = array(), $bcc = array()) { $this->load($templateId); if (!$this->getId()) { throw new Exception('Email template was not found.'); } if (!is_array($sender)) { $senderName = Fox::getPreference('website_email_addresses/' . $sender . '/sender_name'); $senderEmail = Fox::getPreference('website_email_addresses/' . $sender . '/sender_email'); } else { $senderName = isset($sender['sender_name']) ? $sender['sender_name'] : ''; $senderEmail = isset($sender['sender_email']) ? $sender['sender_email'] : ''; } $subject = $this->getParsedContent($this->getSubject(), $vars); $body = $this->getParsedContent($this->getContent(), $vars); $mail = new Zend_Mail(); $mail->addHeader('MIME-Version', '1.0'); $mail->addHeader('Content-Transfer-Encoding', '8bit'); $mail->addHeader('X-Mailer:', 'PHP/' . phpversion()); $mail->addHeader("From ", $senderEmail); $mail->setSubject($subject); $mail->setBodyHtml($body); $mail->setFrom($senderEmail, $senderName); $mail->addTo($to); if (!empty($bcc)) { foreach ($bcc as $email) { $mail->addBcc($email); } } $mail->send(); }
/** * Send password changed email * * @param array $vars Email template parameters */ public function sendPasswordChangedMail($password) { try { $sender = Fox::getPreference('member/password/email_sender'); $template = Fox::getPreference('member/password/change_password_email'); $modelTemplate = Fox::getModel('core/email/template'); $vars = array('name' => $this->getFirstName(), 'email' => $this->getEmailId(), 'password' => $password); $modelTemplate->sendTemplateMail($template, $this->getEmailId(), $sender, $vars); } catch (Exception $e) { } }
/** * Get website address * * @return string */ public static function getWebsiteAddress() { return Fox::getPreference('general/website/address'); }
/** * Forget password action * * Sends an email with link to user which redirects to change password interface */ public function forgetPasswordAction() { if (Fox::getModel('admin/session')->getLoginData()) { $this->sendRedirect('*/dashboard/'); } if ($this->getRequest()->isPost()) { try { $data = $this->getRequest()->getPost(); $model = Fox::getModel('admin/user'); $model->load($data['username'], 'username'); if ($model->getId()) { $code = strtolower(substr(md5(time() * mt_rand()), 0, 20)); $modelSetCode = Fox::getModel('admin/forgetPassword'); $modelSetCode->load($model->getId(), 'user_id'); $modelSetCode->setUserId($model->getId()); $modelSetCode->setCode($code); $modelSetCode->setCreatedOn(Fox_Core_Model_Date::getCurrentDate('Y-m-d H:i:s')); $modelSetCode->save(); Fox::getHelper('core/message')->setInfo('Change Password link has been sent to your email id.'); try { $modelTemplate = Fox::getModel('core/email/template'); $sender = Fox::getPreference('admin/password/forgot_email_sender'); $template = Fox::getPreference('admin/password/forgot_email_template'); $modelTemplate->sendTemplateMail($template, $model->getEmail(), $sender, array('name' => $model->getFirstname(), 'link' => Fox::getUrl('*/*/change-password', array('user_id' => $model->getId(), 'code' => $code)))); } catch (Exception $e) { } $this->sendRedirect('*/*/'); } else { throw new Exception('Invalid username was given.'); } } catch (Exception $e) { Fox::getHelper('core/message')->setError($e->getMessage()); } } $this->loadLayout(); $this->renderLayout(); }
/** * Retrieves whether the chart is enabled * * @return boolean */ public function isChartEnabled() { return Fox::getPreference('admin/analytics/enable_charts'); }
/** * Sets template for rendering of view * * @param string $template * @return void */ public function setTemplate($template) { $package = Fox::getPreference(Fox::getMode() . '/design/package'); $theme = Fox::getPreference(Fox::getMode() . '/design/theme'); $sPath = $this->viewBase . $package . DS . $theme . DS . 'template'; if (!file_exists($sPath . DS . $template . self::VIEW_SUFFIX)) { $sPath = $this->defaultScriptPath; } parent::setScriptPath($sPath); $this->template = $template; }
/** * Get favicon image path * * @return string */ public function getFavicon() { $imgName = Fox::getPreference('web/head/favicon_image'); if ($imgName && file_exists(Fox::getUploadDirectoryPath() . DIRECTORY_SEPARATOR . Fox_Core_Model_Preference::CORE_UPLOAD_FOLDER . DIRECTORY_SEPARATOR . $imgName)) { return Fox::getUploadDirectoryUrl() . '/' . Fox_Core_Model_Preference::CORE_UPLOAD_FOLDER . '/' . $imgName; } else { return $this->themeUrl('images/default_favicon.ico'); } }
/** * Send newsletter unsubscription success email * * @param string $email Email id * @param array $vars Email template parameters */ public function sendUnsubscriptionMail($email, $vars = array()) { try { $sender = Fox::getPreference('newsletter/subscription/unsubscription_email_sender'); $template = Fox::getPreference('newsletter/subscription/unsubscription_email_template'); $modelTemplate = Fox::getModel('core/email/template'); $modelTemplate->sendTemplateMail($template, $email, $sender, $vars); } catch (Exception $e) { } }
/** * Retrieve member registration blocked message set in settings data * * @return string */ public function getRegistrationBlockedMessage() { return Fox::getPreference('member/account/registration_block_message'); }
/** * Get header image alt text * * @return string */ public function getImageAlt() { return htmlspecialchars(Fox::getPreference('web/header/logo_image_alt')); }
/** * Forgot password action * * Sends an email with link to member which redirects to change password interface */ public function forgotPasswordAction() { if ($this->getRequest()->isPost()) { try { $data = $this->getRequest()->getPost(); $model = Fox::getModel('member/member'); $model->load($data['email_id'], 'email_id'); if ($model->getId()) { $code = strtolower(substr(md5(time() * mt_rand()), 0, 20)); $passwordModel = Fox::getModel('member/password'); $passwordModel->load($model->getId(), 'mem_id'); $passwordModel->setMemId($model->getId()); $passwordModel->setCode($code); $passwordModel->setCreatedOn(Fox_Core_Model_Date::getCurrentDate('Y-m-d H:i:s')); $passwordModel->save(); try { $modelTemplate = Fox::getModel('core/email/template'); $sender = Fox::getPreference('member/password/email_sender'); $template = Fox::getPreference('member/password/forgot_email'); $modelTemplate->sendTemplateMail($template, $model->getEmailId(), $sender, array('name' => $model->getFirstName(), 'link' => Fox::getUrl('*/password/change-password', array('code' => $code)))); } catch (Exception $e) { } Fox::getHelper('core/message')->setInfo('Change password link has been sent to your email.'); $this->sendRedirect('*/*/login'); } else { Fox::getHelper('core/message')->setError('Email Id was not found.'); } } catch (Exception $e) { Fox::getHelper('core/message')->setError($e->getMessage()); } } $this->loadLayout(); $this->renderLayout(); }