/** * Checks if this field is complete. * * @author Jason Rey <*****@*****.**> * @since 1.2 * @access public * @param SocialUser $user The user being checked. */ public function onFieldCheck($user) { $timezone = $user->getParam('timezone'); if ($this->isRequired() && empty($timezone)) { $this->setError(JText::_('PLG_FIELDS_JOOMLA_TIMEZONE_VALIDATION_SELECT_TIMEZONE')); return false; } return true; }
/** * Notify users and administrator when they create an account on the site. * * @since 1.0 * @access public * @param SocialUser The user object. * @param SocialTableProfile The profile type. * @return bool True if success, false otherwise. * @author Mark Lee <*****@*****.**> */ public function notify($data, SocialUser $user, SocialTableProfile $profile, $oauth = false) { // Get the application data. $jConfig = FD::jConfig(); $config = FD::config(); if ($config->get('registrations.emailasusername')) { $data['username'] = $user->email; } // Push arguments to template variables so users can use these arguments $params = array('site' => $jConfig->getValue('sitename'), 'username' => $data['username'], 'password' => $user->password_clear, 'firstName' => !empty($data['first_name']) ? $data['first_name'] : '', 'middleName' => !empty($data['middle_name']) ? $data['middle_name'] : '', 'lastName' => !empty($data['last_name']) ? $data['last_name'] : '', 'name' => $user->getName(), 'id' => $user->id, 'avatar' => $user->getAvatar(SOCIAL_AVATAR_LARGE), 'profileLink' => $user->getPermalink(true, true), 'email' => $user->email, 'activation' => FRoute::registration(array('external' => true, 'task' => 'activate', 'controller' => 'registration', 'token' => $user->activation)), 'token' => $user->activation, 'manageAlerts' => false, 'profileType' => $profile->get('title')); // Get the user preferred language $language = $user->getParam('language', ''); // Get the email title. $title = $profile->getEmailTitle('', $language); // Get the email format. $format = $profile->getEmailFormat(); // Immediately send out emails $mailer = FD::mailer(); // Get the email template. $mailTemplate = $mailer->getTemplate(); // Set recipient $mailTemplate->setRecipient($user->name, $user->email); // Set title $mailTemplate->setTitle($title); // Set the contents $mailTemplate->setTemplate($profile->getEmailTemplate('', $oauth), $params, $format); // Set the priority. We need it to be sent out immediately since this is user registrations. $mailTemplate->setPriority(SOCIAL_MAILER_PRIORITY_IMMEDIATE); // Set the language. We need the email to be sent out with the correct language. $mailTemplate->setLanguage($language); // Try to send out email now. $state = $mailer->create($mailTemplate); return $state; }