/** * This method should handle any login logic and report back to the subject * For Joomla 1.6, onLoginUser is now onUserLogin * * @access public * @param array holds the user data * @param array extra options * @return boolean True on success * @since 1.6 */ public function onUserLogin($user, $options) { $app = JFactory::getApplication(); $cUser = CFactory::getUser(CUserHelper::getUserId($user['username'])); if ($cUser->block) { $app->setUserState('users.login.form.return', 'index.php?option=com_users&view=profile'); } return $this->onLoginUser($user, $options); }
public function _buildQuery() { $db = JFactory::getDBO(); $mainframe = JFactory::getApplication(); $jinput = $mainframe->input; $actor = $jinput->get('actor', '', 'NONE'); //JRequest::getVar( 'actor' , '' ); $archived = JRequest::getInt('archived', 0); $app = $jinput->get('app', 'none', 'NONE'); //JRequest::getVar( 'app' , 'none' ); $where = array(); $userId = 0; if (!empty($actor)) { $userId = CUserHelper::getUserId($actor); } if ($userId != 0) { $where[] = 'actor=' . $db->Quote($userId) . ' '; } if ($archived != 0) { $archived = $archived - 1; $where[] = 'archived=' . $db->Quote($archived) . ' '; } if ($app != 'none') { $where[] = 'app=' . $db->Quote($app); } $query = 'SELECT * FROM ' . $db->quoteName('#__community_activities'); if (!empty($where)) { for ($i = 0; $i < count($where); $i++) { if ($i == 0) { $query .= ' WHERE '; } else { $query .= ' AND '; } $query .= $where[$i]; } } $query .= ' ORDER BY created DESC'; return $query; }
/** * Deprecated since 1.8 * Use CUserHelper::getUserId instead. */ function cGetUserId($username) { return CUserHelper::getUserId($username); }
/** * Automatically link username in the provided message when message contains @username * * @param $message A string of message that may or may not contain @username * * return $message A modified copy of the message with the proper hyperlinks. **/ public static function replaceAliasURL($message) { $pattern = '/@(("(.*)")|([A-Z0-9][A-Z0-9_-]+)([A-Z0-9][A-Z0-9_-]+))/i'; preg_match_all($pattern, $message, $matches); if (isset($matches[0]) && !empty($matches[0])) { CFactory::load('helpers', 'user'); CFactory::load('helpers', 'linkgenerator'); $usernames = $matches[0]; for ($i = 0; $i < count($usernames); $i++) { $username = $usernames[$i]; $username = CString::str_ireplace('"', '', $username); $username = explode('@', $username); $username = $username[1]; $id = CUserHelper::getUserId($username); if ($id != 0) { $message = CString::str_ireplace($username, CLinkGeneratorHelper::getUserURL($id, $username), $message); } } } return $message; }