/** * Gets a list of users online. */ public function getUsersOnline() { $sql = "SELECT \t\t" . $this->sqlSelects . "\n\t\t\t\t\tuser_option.userOption" . User::getUserOptionID('invisible') . ", session.userID, session.username as guestname, session.ipAddress,\n\t\t\t\t\tsession.userAgent, session.lastActivityTime, session.requestURI, session.sessionID,\n\t\t\t\t\tsession.requestMethod, session.spiderID, groups.userOnlineMarking, user.username \n\t\t\tFROM \t\twcf" . WCF_N . "_session session\n\t\t\tLEFT JOIN \twcf" . WCF_N . "_user user\n\t\t\tON\t\t(user.userID = session.userID)\n\t\t\tLEFT JOIN \twcf" . WCF_N . "_user_option_value user_option\n\t\t\tON\t\t(user_option.userID = session.userID)\n\t\t\tLEFT JOIN \twcf" . WCF_N . "_group groups\n\t\t\tON\t\t(groups.groupID = user.userOnlineGroupID)\n\t\t\t" . $this->sqlJoins . "\n\t\t\tWHERE \t\tsession.packageID = " . PACKAGE_ID . "\n\t\t\t\t\tAND session.lastActivityTime > " . (TIME_NOW - USER_ONLINE_TIMEOUT) . "\n\t\t\t\t\t" . ($this->getSpiders ? '' : 'AND session.spiderID = 0') . "\n\t\t\t\t\t" . (!$this->enableOwnView ? "AND session.sessionID <> '" . WCF::getSession()->sessionID . "'" . (WCF::getUser()->userID ? " AND session.userID <> " . WCF::getUser()->userID : '') : '') . "\n\t\t\t\t\t" . $this->sqlConditions . " \n\t\t\tORDER BY \t" . $this->sqlOrderBy; $result = WCF::getDB()->sendQuery($sql); while ($row = WCF::getDB()->fetchArray($result)) { $this->handleRow($row, new User(null, $row)); } }
public function getOptionID($optionName) { $optID = User::getUserOptionID($optionName); if (empty($optID)) { list($optID) = WCF::getDB()->getFirstRow("SELECT optionID FROM wcf" . WCF_N . "_user_option WHERE optionName = '" . $optionName . "'", MYSQL_NUM); } return $optID; }
/** * @see EventListener::execute() */ public function execute($eventObj, $className, $eventName) { if (!USERGUESTBOOK_SHOWINSIDEBAR) { return; } if (!WCF::getUser()->getPermission('user.guestbook.canRead')) { return; } if (empty($eventObj->postList->posts)) { return; } $seen = $ret = array(); $ret = WCF::getTPL()->get('additionalSidebarUserContacts'); $link = '<a href="index.php?page=UserGuestbook&userID=%1$d' . SID_ARG_2ND . '"><img src="' . RELATIVE_WCF_DIR . 'icon/guestbookS.png" alt="" title="%2$s" /></a>'; $curUserID = WCF::getUser()->userID; $curUserCanUse = WCF::getUser()->getPermission('user.guestbook.canUseOwn'); $gbEnableOption = 'userOption' . User::getUserOptionID('userGuestbook_enable'); require_once WCF_DIR . 'lib/data/user/UserProfile.class.php'; foreach ($eventObj->postList->posts as $post) { if ($post->userID) { if ($curUserID == $post->userID && !$curUserCanUse) { continue; } else { if (!$post->{$gbEnableOption}) { continue; } else { if (array_key_exists($post->userID, $seen)) { if (!empty($seen[$post->userID])) { if (isset($ret[$post->postID])) { $ret[$post->postID] .= ' ' . $seen[$post->userID]; } else { $ret[$post->postID] = $seen[$post->userID]; } } } else { $add = ''; $user = new UserProfile($post->userID, null, null, null); if ($user->getPermission('user.guestbook.canUseOwn')) { $username = StringUtil::encodeHTML($user->username); $title = WCF::getLanguage()->get('wcf.user.guestbook.title', array('$user->username' => $username)); $add = sprintf($link, $post->userID, $title); if (isset($ret[$post->postID])) { $ret[$post->postID] .= ' ' . $add; } else { $ret[$post->postID] = $add; } } $seen[$post->userID] = $add; } } } } } if (count($ret)) { WCF::getTPL()->assign('additionalSidebarUserContacts', $ret); } }
/** * Gets user ids for active page. * * @return string */ protected function getUserIDs() { $userIDs = ''; $sql = "SELECT\t\tuser.userID,\n\t\t\t\t\t" . (!WCF::getUser()->getPermission('admin.general.canViewInvisible') ? "IF(userOption" . User::getUserOptionID('invisible') . " = 1, 0, lastActivityTime) AS lastActivityTimeSortField" : 'lastActivityTime AS lastActivityTimeSortField') . "\n\t\t\tFROM\t\twcf" . WCF_N . "_user_whitelist whitelist\n\t\t\tLEFT JOIN\t" . $this->userTable . " user\n\t\t\tON\t\t(user.userID = whitelist.whiteUserID)\n\t\t\t" . $this->sqlJoins . "\n\t\t\tWHERE\t\twhitelist.userID = " . $this->userID . "\n\t\t\t\t\tAND whitelist.confirmed = 1\n\t\t\t\t\tAND user.userID IS NOT NULL\n\t\t\tORDER BY\t" . ($this->sortField != 'lastActivity' ? 'user.' : '') . $this->realSortField . " " . $this->sortOrder . ($this->realSortField != 'username' ? ', user.userID' : ''); $result = WCF::getDB()->sendQuery($sql, $this->itemsPerPage, ($this->pageNo - 1) * $this->itemsPerPage); while ($row = WCF::getDB()->fetchArray($result)) { if (!empty($userIDs)) { $userIDs .= ','; } $userIDs .= $row['userID']; } return $userIDs; }
/** * @see Action::execute() */ public function execute() { AbstractAction::execute(); // check permission WCF::getUser()->checkPermission('admin.user.canBanUser'); // active user can't ban himself $activeUserID = WCF::getUser()->userID; $this->userIDs = array_diff($this->userIDs, array($activeUserID)); if (count($this->userIDs) > 0) { // check permission $sql = "SELECT\tDISTINCT groupID\n\t\t\t\tFROM\twcf" . WCF_N . "_user_to_groups\n\t\t\t\tWHERE\tuserID IN (" . implode(',', $this->userIDs) . ")"; $result = WCF::getDB()->sendQuery($sql); while ($row = WCF::getDB()->fetchArray($result)) { if (!Group::isAccessibleGroup($row['groupID'])) { throw new PermissionDeniedException(); } } // get adminCanMail user option id $adminCanMailID = User::getUserOptionID('adminCanMail'); // update user $sql = "UPDATE\twcf" . WCF_N . "_user\n\t\t\t\tSET\tbanned = 1\n\t\t\t\tWHERE\tuserID IN (" . implode(',', $this->userIDs) . ")"; WCF::getDB()->sendQuery($sql); // update user options if ($adminCanMailID !== null) { $sql = "UPDATE\twcf" . WCF_N . "_user_option_value\n\t\t\t\t\tSET\tuserOption" . $adminCanMailID . " = 0\n\t\t\t\t\tWHERE\tuserID IN (" . implode(',', $this->userIDs) . ")"; WCF::getDB()->sendQuery($sql); } // unmark users UserEditor::unmarkAll(); // reset sessions Session::resetSessions($this->userIDs); } $this->executed(); if (!empty($this->url)) { HeaderUtil::redirect($this->url); } else { // set active menu item WCFACP::getMenu()->setActiveMenuItem('wcf.acp.menu.link.user.management'); // show succes message WCF::getTPL()->assign('message', 'wcf.acp.user.ban.success'); WCF::getTPL()->display('success'); } exit; }
/** * @see MembersListPage::getMembers() */ protected function readMembers() { $sql = "SELECT\t\t" . $this->sqlSelects . "\n\t\t\t\t\t" . (in_array('language', $this->activeFields) ? "language.languageCode," : '') . "\n\t\t\t\t\tavatar.*, user.*, rank.*,\n\t\t\t\t\tusergroup.groupID, usergroup.groupName,\n\t\t\t\t\t" . (!WCF::getUser()->getPermission('admin.general.canViewInvisible') ? "IF(userOption" . User::getUserOptionID('invisible') . " = 1, 0, lastActivityTime) AS lastActivityTimeSortField" : 'lastActivityTime AS lastActivityTimeSortField') . ",\n\t\t\t\t\t" . (TEAM_SHOW_GROUP_LEADERS ? "group_leader.leaderUserID" : 0) . " AS isGroupLeader\n \t\t\tFROM \t\twcf" . WCF_N . "_group usergroup\n \t\t\tLEFT JOIN \twcf" . WCF_N . "_user_to_groups user_to_groups \n\t\t\tON\t\t(user_to_groups.groupID = usergroup.groupID)\n\t\t\tLEFT JOIN \t" . $this->userTable . " user \n\t\t\tON\t\t(user.userID = user_to_groups.userID)\n\t\t\t" . $this->sqlJoins . "\n \t\t\tLEFT JOIN\twcf" . WCF_N . "_avatar avatar\n\t\t\tON\t\t(avatar.avatarID = " . $this->userTableAlias . ".avatarID)\n\t\t\tLEFT JOIN \twcf" . WCF_N . "_user_rank rank\n\t\t\tON\t\t(rank.rankID = " . $this->userTableAlias . ".rankID)\n\t\t\t" . (in_array('language', $this->activeFields) ? "\n\t\t\tLEFT JOIN\twcf" . WCF_N . "_language language\n\t\t\tON\t\t(language.languageID = " . $this->userTableAlias . ".languageID)\n\t\t\t" : '') . "\n\t\t\t" . (TEAM_SHOW_GROUP_LEADERS ? "\n\t\t\tLEFT JOIN \twcf" . WCF_N . "_group_leader group_leader\n\t\t\tON\t\t(group_leader.leaderUserID = " . $this->userTableAlias . ".userID AND group_leader.groupID = usergroup.groupID)\n\t\t\t" : '') . "\n\t\t\tWHERE \t\tusergroup.showOnTeamPage = 1\n\t\t\tORDER BY \tusergroup.teamPagePosition,\n\t\t\t\t\t" . ($this->sortField != 'lastActivity' ? 'user.' : '') . $this->realSortField . " " . $this->sortOrder; $result = WCF::getDB()->sendQuery($sql); while ($row = WCF::getDB()->fetchArray($result)) { if (!$row['userID']) { continue; } $member = $this->getMember($row); $userID = $member['user']->userID; if (TEAM_SHOW_MULTIPLE_MEMBERSHIPS || !isset($this->members[$userID])) { if (!isset($this->groupedMembers[$row['groupID']])) { $this->groupedMembers[$row['groupID']] = array('members' => array(), 'leaders' => array(), 'groupName' => $row['groupName']); } if (!isset($this->members[$userID])) { $this->members[$userID] = $member; } $this->groupedMembers[$row['groupID']][$row['isGroupLeader'] ? 'leaders' : 'members'][] =& $this->members[$userID]; } } }
public function __construct($data, $boxname = "") { $this->LastOnlineBoxData['templatename'] = "lastonlinebox"; $this->getBoxStatus($data); $this->LastOnlineBoxData['boxID'] = $data['boxID']; $cntTodayOnline = 0; $showAllOU = 0; $curPage = ''; if (!defined('LASTONLINEBOX_NUMOFUSER_ACP')) { define('LASTONLINEBOX_NUMOFUSER_ACP', 5); } if (!defined('LASTONLINEBOX_SBCOLOR_ACP')) { define('LASTONLINEBOX_SBCOLOR_ACP', 2); } if (!defined('LASTONLINEBOX_MAXHEIGHT_ACP')) { define('LASTONLINEBOX_MAXHEIGHT_ACP', 300); } if (!defined('LASTONLINEBOX_SHOWTIME_ACP')) { define('LASTONLINEBOX_SHOWTIME_ACP', true); } if (!defined('LASTONLINEBOX_SHOWUSERMARKING_ACP')) { define('LASTONLINEBOX_SHOWUSERMARKING_ACP', true); } if (WCF::getUser()->getPermission('user.board.canSeeLastOnlineBox') > 0) { $itstamp = time(); $todayStartTime = mktime(0, 0, 0, (int) date("m", $itstamp), (int) date("d", $itstamp), (int) date("Y", $itstamp)); $i = 0; if (!empty($_GET['showAllOU'])) { $showAllOU = 1; } if (!empty($_GET['page'])) { $curPage = $_GET['page']; } if (WCF::getUser()->userID > 0 && WCF::getUser()->getPermission('admin.general.canViewInvisible')) { $sql = "SELECT COUNT(*) AS cntTodayOnline" . "\n FROM wcf" . WCF_N . "_user wcu" . "\n WHERE wcu.lastActivityTime >= " . $todayStartTime; $result = WBBCore::getDB()->getFirstRow($sql); $cntTodayOnline = $result['cntTodayOnline']; } else { $sql = "SELECT COUNT(*) AS cntTodayOnline" . "\n FROM wcf" . WCF_N . "_user wcu" . "\n LEFT JOIN wcf" . WCF_N . "_user_option_value wcuo ON (wcuo.userID = wcu.userID)" . "\n WHERE wcu.lastActivityTime >= " . $todayStartTime . "\n AND wcuo.userOption" . User::getUserOptionID('invisible') . " = 0"; $result = WBBCore::getDB()->getFirstRow($sql); $cntTodayOnline = $result['cntTodayOnline']; } if (LASTONLINEBOX_SHOWUSERMARKING_ACP) { $sql = "SELECT wcu.userID, wcu.username, wcu.lastActivityTime, wcuo.userOption" . User::getUserOptionID('invisible') . " isInvisible, wcg.userOnlineMarking" . "\n FROM wcf" . WCF_N . "_user wcu" . "\n LEFT JOIN wcf" . WCF_N . "_group wcg ON (wcg.groupID = wcu.userOnlineGroupID)"; } else { $sql = "SELECT wcu.userID, wcu.username, wcu.lastActivityTime, wcuo.userOption" . User::getUserOptionID('invisible') . " isInvisible" . "\n FROM wcf" . WCF_N . "_user wcu"; } $sql .= "\n LEFT JOIN wcf" . WCF_N . "_user_option_value wcuo ON (wcuo.userID = wcu.userID)" . "\n WHERE wcu.lastActivityTime >= " . $todayStartTime . "\n ORDER BY wcu.lastActivityTime DESC"; if (LASTONLINEBOX_NUMOFUSER_ACP > 0 && empty($showAllOU)) { $sql .= "\n LIMIT 0, " . LASTONLINEBOX_NUMOFUSER_ACP; } $result = WBBCore::getDB()->sendQuery($sql); while ($row = WBBCore::getDB()->fetchArray($result)) { if ($row['isInvisible'] && !WCF::getUser()->getPermission('admin.general.canViewInvisible')) { continue; } if (LASTONLINEBOX_SHOWUSERMARKING_ACP && $row['userOnlineMarking'] != '%s') { $row['username'] = sprintf($row['userOnlineMarking'], StringUtil::encodeHTML($row['username'])); if ($row['isInvisible']) { $row['username'] .= WCF::getLanguage()->get('wcf.usersOnline.invisible'); } } else { $row['username'] = StringUtil::encodeHTML($row['username']); } $this->lastOnline[$i]['userID'] = $row['userID']; $this->lastOnline[$i]['username'] = $row['username']; $this->lastOnline[$i]['plainname'] = $row['username']; $this->lastOnline[$i]['lastActivityTime'] = $row['lastActivityTime']; $i++; } $this->getSortedByNames(); } WCF::getTPL()->assign('LASTONLINEBOX_SBCOLOR_ACP', intval(LASTONLINEBOX_SBCOLOR_ACP)); WCF::getTPL()->assign('LASTONLINEBOX_MAXHEIGHT_ACP', intval(LASTONLINEBOX_MAXHEIGHT_ACP)); WCF::getTPL()->assign('LASTONLINEBOX_SHOWTIME_ACP', LASTONLINEBOX_SHOWTIME_ACP); WCF::getTPL()->assign('lastOnline', $this->lastOnline); WCF::getTPL()->assign('lastOnlineByName', $this->lastOnlineByName); WCF::getTPL()->assign('canSeeLastOnlineBox', WCF::getUser()->getPermission('user.board.canSeeLastOnlineBox')); WCF::getTPL()->assign('cntTodayOnline', $cntTodayOnline); WCF::getTPL()->assign('showAllOU', $showAllOU); WCF::getTPL()->assign('curPage', $curPage); }
/** * @see Form::save() */ public function save() { parent::save(); // active user can't ban himself $this->userIDArray = array_diff($this->userIDArray, array(WCF::getUser()->userID)); if (count($this->userIDArray) > 0) { // check permission $sql = "SELECT\tDISTINCT groupID\n\t\t\t\tFROM\twcf" . WCF_N . "_user_to_groups\n\t\t\t\tWHERE\tuserID IN (" . implode(',', $this->userIDArray) . ")"; $result = WCF::getDB()->sendQuery($sql); while ($row = WCF::getDB()->fetchArray($result)) { if (!Group::isAccessibleGroup($row['groupID'])) { throw new PermissionDeniedException(); } } // get adminCanMail user option id $adminCanMailID = User::getUserOptionID('adminCanMail'); // update user $sql = "UPDATE\twcf" . WCF_N . "_user\n\t\t\t\tSET\tbanned = 1,\n\t\t\t\t\tbanReason = '" . escapeString($this->reason) . "'\n\t\t\t\tWHERE\tuserID IN (" . implode(',', $this->userIDArray) . ")"; WCF::getDB()->sendQuery($sql); // update user options if ($adminCanMailID !== null) { $sql = "UPDATE\twcf" . WCF_N . "_user_option_value\n\t\t\t\t\tSET\tuserOption" . $adminCanMailID . " = 0\n\t\t\t\t\tWHERE\tuserID IN (" . implode(',', $this->userIDArray) . ")"; WCF::getDB()->sendQuery($sql); } // unmark users UserEditor::unmarkAll(); // reset sessions Session::resetSessions($this->userIDArray); } $this->saved(); // forward if (empty($this->url)) { $this->url = 'index.php?form=UserSearch&packageID=' . PACKAGE_ID . SID_ARG_2ND_NOT_ENCODED; } HeaderUtil::redirect($this->url); exit; }
/** * Gets the list of members for the current page number. */ protected function readMembers() { if ($this->items) { // get user ids for active page $userIDs = $this->getUserIDs(); // get users if (!empty($userIDs)) { $sql = "SELECT\t\t" . $this->sqlSelects . "\n\t\t\t\t\t\t\t" . (in_array('avatar', $this->activeFields) ? "avatar.*," : '') . "\n\t\t\t\t\t\t\t" . (in_array('language', $this->activeFields) ? "language.languageCode," : '') . "\n\t\t\t\t\t\t\tuser.*,\n\t\t\t\t\t\t\trank.*,\n\t\t\t\t\t\t\t" . (!WCF::getUser()->getPermission('admin.general.canViewInvisible') ? "IF(userOption" . User::getUserOptionID('invisible') . " = 1, 0, lastActivityTime) AS lastActivityTimeSortField" : 'lastActivityTime AS lastActivityTimeSortField') . "\n\t\t\t\t\tFROM\t\t" . $this->userTable . " user\n\t\t\t\t\t" . $this->sqlJoins . "\n\t\t\t\t\t" . (in_array('avatar', $this->activeFields) ? "\n\t\t\t\t\tLEFT JOIN\twcf" . WCF_N . "_avatar avatar\n\t\t\t\t\tON\t\t(avatar.avatarID = " . $this->userTableAlias . ".avatarID)\n\t\t\t\t\t" : '') . "\n\t\t\t\t\t" . (in_array('language', $this->activeFields) ? "\n\t\t\t\t\tLEFT JOIN\twcf" . WCF_N . "_language language\n\t\t\t\t\tON\t\t(language.languageID = " . $this->userTableAlias . ".languageID)\n\t\t\t\t\t" : '') . "\n\t\t\t\t\tLEFT JOIN \twcf" . WCF_N . "_user_rank rank\n\t\t\t\t\tON\t\t(rank.rankID = " . $this->userTableAlias . ".rankID)\n\t\t\t\t\tWHERE\t\tuser.userID IN (" . $userIDs . ")\n\t\t\t\t\tORDER BY\t" . ($this->sortField != 'lastActivity' ? "user." : '') . $this->realSortField . " " . $this->sortOrder . ($this->realSortField != 'username' ? ', user.userID' : ''); $result = WCF::getDB()->sendQuery($sql); while ($row = WCF::getDB()->fetchArray($result)) { if (empty($row['username'])) { continue; } $this->members[] = $this->getMember($row); } } } }
public function __construct($data, $boxname = "") { $this->TeamOnlineBoxData['templatename'] = "teamonlinebox"; $this->getBoxStatus($data); $this->TeamOnlineBoxData['boxID'] = $data['boxID']; if (!defined('TEAMONLINEBOX_SHOWCOUNT_ACP')) { define('TEAMONLINEBOX_SHOWCOUNT_ACP', true); } if (!defined('TEAMONLINEBOX_SHOWBYLINE_ACP')) { define('TEAMONLINEBOX_SHOWBYLINE_ACP', true); } if (!defined('TEAMONLINEBOX_SHOWTIME_ACP')) { define('TEAMONLINEBOX_SHOWTIME_ACP', true); } if (!defined('TEAMONLINEBOX_ORDERBY_ACP')) { define('TEAMONLINEBOX_ORDERBY_ACP', 'lastActivityTime'); } if (!defined('TEAMONLINEBOX_SORTDESC_ACP')) { define('TEAMONLINEBOX_SORTDESC_ACP', true); } if (!defined('TEAMONLINEBOX_SBCOLOR_ACP')) { define('TEAMONLINEBOX_SBCOLOR_ACP', 2); } $teamOnline = array(); if (WCF::getUser()->userID > 0 && WCF::getUser()->getPermission('user.board.canSeeTeamOnlineBox') > 0) { require_once WCF_DIR . 'lib/data/user/usersOnline/UsersOnlineList.class.php'; $teamOnlineList = null; $teamOnlineList = new UsersOnlineList('', true); $teamOnlineList->renderOnlineList(); $uOnlineIDs = '0'; if (isset($teamOnlineList->usersOnline)) { foreach ($teamOnlineList->usersOnline as $k => $v) { if (isset($v['userID'])) { $uOnlineIDs .= ',' . $v['userID']; } } } if ($uOnlineIDs != '0') { if (TEAMONLINEBOX_SORTDESC_ACP) { $sort = 'DESC'; } else { $sort = 'ASC'; } $sql = "SELECT DISTINCT wcu.userID, wcu.username, wcu.lastActivityTime, wcuo.userOption" . User::getUserOptionID('invisible') . " isInvisible, teamOnlineMarking" . "\n FROM wcf" . WCF_N . "_user wcu" . "\n JOIN wcf" . WCF_N . "_group wcg ON (wcg.groupID = wcu.userOnlineGroupID)" . "\n JOIN wcf" . WCF_N . "_user_option_value wcuo ON (wcuo.userID = wcu.userID)" . "\n WHERE wcg.showOnTeamOnlineBox = 1" . "\n AND wcu.userID IN (" . $uOnlineIDs . ")" . "\n ORDER BY wcu." . TEAMONLINEBOX_ORDERBY_ACP . " " . $sort; $result = WBBCore::getDB()->sendQuery($sql); $i = 0; while ($row = WBBCore::getDB()->fetchArray($result)) { if ($row['isInvisible'] && !WCF::getUser()->getPermission('admin.general.canViewInvisible')) { continue; } if ($row['teamOnlineMarking'] != '%s') { if ($row['isInvisible']) { $row['username'] .= WCF::getLanguage()->get('wcf.usersOnline.invisible'); } $row['username'] = sprintf($row['teamOnlineMarking'], StringUtil::encodeHTML($row['username'])); } else { $row['username'] = StringUtil::encodeHTML($row['username']); } $teamOnline[$i]['userID'] = $row['userID']; $teamOnline[$i]['username'] = $row['username']; $teamOnline[$i]['lastActivityTime'] = $row['lastActivityTime']; $i++; } } } WCF::getTPL()->assign('teamOnline', $teamOnline); WCF::getTPL()->assign('TEAMONLINEBOX_SHOWCOUNT_ACP', TEAMONLINEBOX_SHOWCOUNT_ACP); WCF::getTPL()->assign('TEAMONLINEBOX_SHOWBYLINE_ACP', TEAMONLINEBOX_SHOWBYLINE_ACP); WCF::getTPL()->assign('TEAMONLINEBOX_SHOWTIME_ACP', TEAMONLINEBOX_SHOWTIME_ACP); WCF::getTPL()->assign('TEAMONLINEBOX_SBCOLOR_ACP', intval(TEAMONLINEBOX_SBCOLOR_ACP)); }
/** * Gets a list of all members in this white list. */ protected function readMembers() { // get members require_once WCF_DIR . 'lib/data/user/UserProfile.class.php'; $sql = "SELECT\t\tuser_option.userOption" . User::getUserOptionID('invisible') . ", user.userID, user.username, user.lastActivityTime\n\t\t\tFROM\t\twcf" . WCF_N . "_user_" . $this->listType . "list " . $this->listType . "list\n\t\t\tLEFT JOIN\twcf" . WCF_N . "_user user\n\t\t\tON\t\t(user.userID = " . $this->listType . "list." . $this->listType . "UserID)\n\t\t\tLEFT JOIN\twcf" . WCF_N . "_user_option_value user_option\n\t\t\tON \t\t(user_option.userID = user.userID) \n\t\t\tWHERE \t\t" . $this->listType . "list.userID = " . WCF::getUser()->userID . "\n\t\t\t\t\tAND user.userID IS NOT NULL\n\t\t\tORDER BY \tuser.username"; $result = WCF::getDB()->sendQuery($sql); while ($row = WCF::getDB()->fetchArray($result)) { $this->members[] = new UserProfile(null, $row); } }
/** * Sends e-mail notifications to all group leaders. */ public function sendLeaderNotification() { // send notifications $languages = array(); $languages[WCF::getLanguage()->getLanguageID()] = WCF::getLanguage(); $languages[0] = WCF::getLanguage(); require_once WCF_DIR . 'lib/data/mail/Mail.class.php'; // get group leaders $sql = "SELECT\t\tuser_option.*, user_table.*\n\t\t\tFROM\t\twcf" . WCF_N . "_user user_table\n\t\t\tLEFT JOIN\twcf" . WCF_N . "_user_option_value user_option\n\t\t\tON\t\t(user_option.userID = user_table.userID)\n\t\t\tWHERE \t\t(user_table.userID IN (\n\t\t\t\t\t\tSELECT\tleaderUserID\n\t\t\t\t\t\tFROM\twcf" . WCF_N . "_group_leader\n\t\t\t\t\t\tWHERE\tgroupID = " . $this->groupID . "\n\t\t\t\t\t\t\tAND leaderUserID <> 0\n\t\t\t\t\t) \n\t\t\t\t\tOR user_table.userID IN (\n\t\t\t\t\t\tSELECT\t\tuser_to_groups.userID\n\t\t\t\t\t\tFROM\t\twcf" . WCF_N . "_group_leader group_leader\n\t\t\t\t\t\tLEFT JOIN\twcf" . WCF_N . "_user_to_groups user_to_groups\n\t\t\t\t\t\tON\t\t(user_to_groups.groupID = group_leader.leaderGroupID)\n\t\t\t\t\t\tWHERE\t\tuser_to_groups.groupID = " . $this->groupID . "\n\t\t\t\t\t\t\t\tAND leaderGroupID <> 0\n\t\t\t\t\t))\n\t\t\t\t\tAND user_option.userOption" . User::getUserOptionID('enableGroupApplicationEmailNotification') . " = 1"; $result = WCF::getDB()->sendQuery($sql, 100); while ($row = WCF::getDB()->fetchArray($result)) { $recipient = new User(null, $row); // get language if (!isset($languages[$recipient->languageID])) { $languages[$recipient->languageID] = new Language($recipient->languageID); } // enable language $languages[$recipient->languageID]->setLocale(); // send mail $data = array('PAGE_TITLE' => $languages[$recipient->languageID]->get(PAGE_TITLE), 'PAGE_URL' => PAGE_URL, '$applicationID' => $this->applicationID, '$recipient' => $recipient->username, '$applicant' => $this->username, '$reason' => $this->reason, '$groupName' => $languages[$recipient->languageID]->get($this->groupName)); $mail = new Mail(array($recipient->username => $recipient->email), $languages[$recipient->languageID]->get('wcf.user.userGroups.application.leader.notification.subject', array('PAGE_TITLE' => $languages[$recipient->languageID]->get(PAGE_TITLE))), $languages[$recipient->languageID]->get('wcf.user.userGroups.application.leader.notification.mail', $data)); $mail->send(); } // enable user language WCF::getLanguage()->setLocale(); }
public function getBirthdays($y, $m, $d = 0) { $month = intval($m); $day = intval($d); if ($day != 0 && $day < 10) { $day = '0' . $day; } $ret = array(); if ($month < 10) { $month = '0' . $month; } $optionID = intval(User::getUserOptionID('birthday')); if (!empty($optionID)) { $sql = "SELECT u.userID, u.username, uov.userOption" . $optionID . " AS BD" . "\n FROM wcf" . WCF_N . "_user_option_value uov" . "\n LEFT JOIN wcf" . WCF_N . "_user u ON (u.userID = uov.userID)" . "\n WHERE 1 = 1"; if ($day == 0) { $sql .= "\n AND uov.userOption" . $optionID . " LIKE '____-" . $month . "-__'"; } else { $sql .= "\n AND uov.userOption" . $optionID . " LIKE '____-" . $month . "-" . $day . "'"; } $result = WBBCore::getDB()->sendQuery($sql); while ($row = WBBCore::getDB()->fetchArray($result)) { list($by, $bm, $bd) = preg_split('/\\-/', $row['BD'], 3); $by = intval($by); $bm = intval($bm); $bd = intval($bd); if ($y >= $by) { if (!$by > 0) { $age = null; } else { $age = $y - $by; } if (isset($ret[$bd])) { $ret[$bd] .= ", "; } else { $ret[$bd] = ''; } $ret[$bd] .= StringUtil::encodeHTML($row['username']) . ($age ? ' (' . $age . ')' : ''); } } } return $ret; }
/** * Gets a list of all members in this white list. */ protected function readInvitingMembers() { // get members $sql = "SELECT\t\tuser_option.userOption" . User::getUserOptionID('invisible') . ", user.userID, user.username, user.lastActivityTime\n\t\t\tFROM\t\twcf" . WCF_N . "_user_whitelist whitelist\n\t\t\tLEFT JOIN\twcf" . WCF_N . "_user user\n\t\t\tON\t\t(user.userID = whitelist.userID)\n\t\t\tLEFT JOIN\twcf" . WCF_N . "_user_option_value user_option\n\t\t\tON \t\t(user_option.userID = user.userID) \n\t\t\tWHERE \t\twhitelist.whiteUserID = " . WCF::getUser()->userID . "\n\t\t\t\t\tAND whitelist.confirmed = 0\n\t\t\t\t\tAND user.userID IS NOT NULL\n\t\t\tORDER BY \tuser.username"; $result = WCF::getDB()->sendQuery($sql); while ($row = WCF::getDB()->fetchArray($result)) { $this->invitingMembers[] = new UserProfile(null, $row); } }
/** * @see UserSearchForm::buildStaticConditions() */ protected function buildStaticConditions() { parent::buildStaticConditions(); if (isset($this->staticParameters['email']) && !empty($this->staticParameters['email'])) { $this->conditions->add("option_value.userOption" . User::getUserOptionID('hideEmailAddress') . " = 0"); } }