/** * Retrieves the email title for moderator. * * @since 1.0 * @access public * @param string * @return */ public function getModeratorEmailTitle($username) { // @TODO: Make this configurable. $title = FD::jConfig()->getValue('sitename'); $message = JText::sprintf('COM_EASYSOCIAL_EMAILS_REGISTRATION_MODERATOR_EMAIL_TITLE', $username, $title); return $message; }
/** * Retrieves a list of online users from the site * * @since 1.0 * @access public * @param string * @return */ public function getOnlineMembers($groupId) { $db = FD::db(); $sql = $db->sql(); // Get the session life time so we can know who is really online. $jConfig = FD::jConfig(); $lifespan = $jConfig->getValue('lifetime'); $online = time() - $lifespan * 60; $sql->select('#__session', 'a'); $sql->column('b.id'); $sql->join('#__users', 'b', 'INNER'); $sql->on('a.userid', 'b.id'); $sql->join('#__social_clusters_nodes', 'c', 'INNER'); $sql->on('c.uid', 'b.id'); $sql->on('c.type', SOCIAL_TYPE_USER); // exclude esad users $sql->innerjoin('#__social_profiles_maps', 'upm'); $sql->on('c.uid', 'upm.user_id'); $sql->innerjoin('#__social_profiles', 'up'); $sql->on('upm.profile_id', 'up.id'); $sql->on('up.community_access', '1'); if (FD::config()->get('users.blocking.enabled') && !JFactory::getUser()->guest) { $sql->leftjoin('#__social_block_users', 'bus'); $sql->on('b.id', 'bus.user_id'); $sql->on('bus.target_id', JFactory::getUser()->id); $sql->isnull('bus.id'); } $sql->where('a.time', $online, '>='); $sql->where('b.block', 0); $sql->where('c.cluster_id', $groupId); $sql->group('a.userid'); $db->setQuery($sql); $result = $db->loadColumn(); if (!$result) { return array(); } $users = FD::user($result); return $users; }
/** * Retrieves the user's one time password settings * * @since 1.3 * @access public * @param string * @return */ public function getOtpConfig() { static $cache = array(); if (!isset($cache[$this->id])) { $otpConfig = new stdClass(); $otpConfig->method = 'none'; $otpConfig->config = array(); $otpConfig->otep = array(); // Ensure the user has an otp set if (!$this->otpKey) { $cache[$this->id] = $otpConfig; return $cache[$this->id]; } // Get the encrypted data list($method, $encryptedConfig) = explode(':', $this->otpKey, 2); $encryptedOtep = $this->otep; // Create an encryptor class $key = FD::jConfig()->getValue('secret'); $aes = new FOFEncryptAes($key, 256); // Decrypt the data $decryptedConfig = $aes->decryptString($encryptedConfig); $decryptedOtep = $aes->decryptString($encryptedOtep); // Remove the null padding added during encryption $decryptedConfig = rtrim($decryptedConfig, ""); $decryptedOtep = rtrim($decryptedOtep, ""); // Update the configuration object $otpConfig->method = $method; $otpConfig->config = @json_decode($decryptedConfig); $otpConfig->otep = @json_decode($decryptedOtep); /* * If the decryption failed for any reason we essentially disable the * two-factor authentication. This prevents impossible to log in sites * if the site admin changes the site secret for any reason. */ if (is_null($otpConfig->config)) { $otpConfig->config = array(); } if (is_object($otpConfig->config)) { $otpConfig->config = (array) $otpConfig->config; } if (is_null($otpConfig->otep)) { $otpConfig->otep = array(); } if (is_object($otpConfig->otep)) { $otpConfig->otep = (array) $otpConfig->otep; } $cache[$this->id] = $otpConfig; } return $cache[$this->id]; }
/** * Resends activation emails to the user. * * @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 resendActivation(SocialUser $user) { // Get the application data. $jConfig = FD::jConfig(); $config = FD::config(); // Push arguments to template variables so users can use these arguments $params = array('site' => $jConfig->getValue('sitename'), 'username' => $user->username, 'password' => $user->password_clear, '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); // Get the email title. $title = JText::_('COM_EASYSOCIAL_REGISTRATION_ACTIVATION_REMINDER'); // 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('site/registration/reactivate', $params); // Set the priority. We need it to be sent out immediately since this is user registrations. $mailTemplate->setPriority(SOCIAL_MAILER_PRIORITY_IMMEDIATE); // Try to send out email now. $state = $mailer->create($mailTemplate); return $state; }
public function getOnlineGuests($eventId) { $db = FD::db(); $sql = $db->sql(); // Get the session life time so we can know who is really online. $lifespan = FD::jConfig()->getValue('lifetime'); $online = time() - $lifespan * 60; $sql->select('#__session', 'a'); $sql->column('b.id'); $sql->innerjoin('#__users', 'b'); $sql->on('a.userid', 'b.id'); $sql->innerjoin('#__social_clusters_nodes', 'c'); $sql->on('c.uid', 'b.id'); $sql->on('c.type', SOCIAL_TYPE_USER); $sql->where('a.time', $online, '>='); $sql->where('b.block', 0); $sql->where('c.cluster_id', $eventId); $sql->group('a.userid'); $db->setQuery($sql); $result = $db->loadColumn(); if (!$result) { return array(); } $users = FD::user($result); return $users; }
/** * Remind username * * @since 1.0 * @access public * @param string * @return */ public function remindUsername($email) { // Load backend language file. FD::language()->loadAdmin(); $db = FD::db(); $sql = $db->sql(); // Check if such email exists $sql->select('#__users'); $sql->where('email', $email); $db->setQuery($sql); $row = $db->loadObject(); if (!$row) { $this->setError(JText::_('COM_EASYSOCIAL_USERS_NO_SUCH_USER_WITH_EMAIL')); return false; } // Ensure that the user is not blocked if ($row->block) { $this->setError(JText::_('COM_EASYSOCIAL_USERS_USER_BLOCKED')); return false; } $user = FD::user($row->id); // Get the application data. $jConfig = FD::jConfig(); // Push arguments to template variables so users can use these arguments $params = array('site' => $jConfig->getValue('sitename'), 'username' => $row->username, 'name' => $user->getName(), 'id' => $user->id, 'avatar' => $user->getAvatar(SOCIAL_AVATAR_LARGE), 'profileLink' => $user->getPermalink(true, true), 'email' => $email); // Get the email title. $title = JText::sprintf('COM_EASYSOCIAL_EMAILS_REMIND_USERNAME_TITLE', $jConfig->getValue('sitename')); // 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('site/user/remind.username', $params); // Set the priority. We need it to be sent out immediately since this is user registrations. $mailTemplate->setPriority(SOCIAL_MAILER_PRIORITY_IMMEDIATE); // Try to send out email now. $state = $mailer->create($mailTemplate); return $state; }