language/de.xml 0100644 0000000 0000000 00000040524 13753742715 012525 0 ustar 00 0000000 0000000
„{$username}“ hat {if LANGUAGE_USE_INFORMAL_VARIANT}dir{else}Ihnen{/if} über die Website {PAGE_TITLE|language} folgende Nachricht gesandt: {@$message|newlineToBreak} „{$username}“ sent you a message on {PAGE_TITLE|language}: {@$message|newlineToBreak}{lang}wcf.acp.invite.list{/lang}
{lang}wcf.global.objectID{/lang} | {lang}wcf.acp.invite.code{/lang} | {lang}wcf.acp.invite.time{/lang} | {lang}wcf.acp.invite.inviterName{/lang} | {lang}wcf.acp.invite.successCount{/lang} | {lang}wcf.acp.invite.emails{/lang} | {event name='columnHeads'}||
---|---|---|---|---|---|---|---|
{event name='rowButtons'} | {@$invite->inviteID} | {$invite->code} | {@$invite->time|time} | {$invite->inviterName} | {#$invite->successCount} | {$invite->emails} | {$invite->message} | {event name='columns'}
{lang}wcf.global.noItems{/lang}
{/if} {include file='footer'} files.tar 0100644 0000000 0000000 00000240000 13753743765 011437 0 ustar 00 0000000 0000000 lib/ 0040755 0000000 0000000 00000000000 13743343432 010364 5 ustar 00 0000000 0000000 lib/acp/ 0040755 0000000 0000000 00000000000 13743343432 011127 5 ustar 00 0000000 0000000 lib/acp/page/ 0040755 0000000 0000000 00000000000 13743343433 012044 5 ustar 00 0000000 0000000 lib/data/ 0040755 0000000 0000000 00000000000 13743343432 011275 5 ustar 00 0000000 0000000 lib/data/user/ 0040755 0000000 0000000 00000000000 13743343433 012254 5 ustar 00 0000000 0000000 lib/data/user/invite/ 0040755 0000000 0000000 00000000000 13743343433 013552 5 ustar 00 0000000 0000000 lib/data/user/invite/success/ 0040755 0000000 0000000 00000000000 13743343433 015222 5 ustar 00 0000000 0000000 lib/form/ 0040755 0000000 0000000 00000000000 13743343432 011327 5 ustar 00 0000000 0000000 lib/page/ 0040755 0000000 0000000 00000000000 13743343433 011301 5 ustar 00 0000000 0000000 lib/system/ 0040755 0000000 0000000 00000000000 13743343433 011711 5 ustar 00 0000000 0000000 lib/system/box/ 0040755 0000000 0000000 00000000000 13743343433 012501 5 ustar 00 0000000 0000000 lib/system/bulk/ 0040755 0000000 0000000 00000000000 13743343433 012646 5 ustar 00 0000000 0000000 lib/system/bulk/processing/ 0040755 0000000 0000000 00000000000 13743343433 015022 5 ustar 00 0000000 0000000 lib/system/bulk/processing/user/ 0040755 0000000 0000000 00000000000 13743343433 016000 5 ustar 00 0000000 0000000 lib/system/cache/ 0040755 0000000 0000000 00000000000 13743343433 012754 5 ustar 00 0000000 0000000 lib/system/cache/builder/ 0040755 0000000 0000000 00000000000 13743343433 014402 5 ustar 00 0000000 0000000 lib/system/event/ 0040755 0000000 0000000 00000000000 13743343433 013032 5 ustar 00 0000000 0000000 lib/system/event/listener/ 0040755 0000000 0000000 00000000000 13743343433 014657 5 ustar 00 0000000 0000000 lib/system/menu/ 0040755 0000000 0000000 00000000000 13743343433 012655 5 ustar 00 0000000 0000000 lib/system/menu/user/ 0040755 0000000 0000000 00000000000 13743343433 013633 5 ustar 00 0000000 0000000 lib/system/stat/ 0040755 0000000 0000000 00000000000 13743343433 012664 5 ustar 00 0000000 0000000 lib/system/user/ 0040755 0000000 0000000 00000000000 13743343433 012667 5 ustar 00 0000000 0000000 lib/system/user/activity/ 0040755 0000000 0000000 00000000000 13743343433 014523 5 ustar 00 0000000 0000000 lib/system/user/activity/event/ 0040755 0000000 0000000 00000000000 13743343433 015644 5 ustar 00 0000000 0000000 lib/system/user/invite/ 0040755 0000000 0000000 00000000000 13743343433 014165 5 ustar 00 0000000 0000000 lib/system/user/notification/ 0040755 0000000 0000000 00000000000 13743343433 015355 5 ustar 00 0000000 0000000 lib/system/user/notification/event/ 0040755 0000000 0000000 00000000000 13743343433 016476 5 ustar 00 0000000 0000000 lib/system/user/notification/object/ 0040755 0000000 0000000 00000000000 13743343433 016623 5 ustar 00 0000000 0000000 lib/system/user/notification/object/type/ 0040755 0000000 0000000 00000000000 13743343433 017604 5 ustar 00 0000000 0000000 lib/system/worker/ 0040755 0000000 0000000 00000000000 13743343433 013222 5 ustar 00 0000000 0000000 lib/acp/page/InviteListPage.class.php 0100644 0000000 0000000 00000001446 13663532704 016554 0 ustar 00 0000000 0000000 * @package com.uz.wcf.invitation */ class InviteListPage extends SortablePage { /** * @inheritDoc */ public $activeMenuItem = 'wcf.acp.menu.link.user.inviteList'; /** * @inheritDoc */ public $neededPermissions = ['admin.user.canEditGroup', 'admin.user.canDeleteGroup']; /** * @inheritDoc */ public $defaultSortField = 'time'; /** * @inheritDoc */ public $validSortFields = ['inviteID', 'code', 'emails', 'inviterName', 'successCount']; /** * @inheritDoc */ public $objectListClassName = InviteList::class; } lib/data/user/invite/Invite.class.php 0100644 0000000 0000000 00000007733 13663532704 016636 0 ustar 00 0000000 0000000 * @package com.uz.wcf.invitation */ class Invite extends DatabaseObject { /** * @inheritDoc */ protected static $databaseTableName = 'user_invite'; /** * @inheritDoc */ protected static $databaseTableIndexName = 'inviteID'; /** * Returns true, if the user can use invitations (and see it in activities) */ public function canSee() { return WCF::getSession()->getPermission('user.profile.canInvite'); } /** * Returns 0 if the code does not exist or has expired */ public static function checkCodeExist($code) { // get code and check expiration $sql = "SELECT * FROM wcf".WCF_N."_user_invite WHERE code = ?"; $statement = WCF::getDB()->prepareStatement($sql, 1); $statement->execute([$code]); $row = $statement->fetchArray(); if (!$row) return 0; if (INVITE_CODE_EXPIRE && $row['time'] + INVITE_CODE_EXPIRE * 86400 < TIME_NOW) return 0; // code exists, check usage $sql = "SELECT used FROM wcf".WCF_N."_user_invite_code WHERE code = ?"; $statement = WCF::getDB()->prepareStatement($sql, 1); $statement->execute([$code]); $used = $statement->fetchColumn(); if (!$used || !INVITE_CODE_LIMIT) return 1; if (INVITE_CODE_LIMIT && $used < INVITE_CODE_LIMIT) return 1; return 0; } /** * Returns invite by code */ public static function getInviteByCode($code) { $sql = "SELECT * FROM wcf".WCF_N."_user_invite WHERE code = ?"; $statement = WCF::getDB()->prepareStatement($sql); $statement->execute([$code]); $row = $statement->fetchArray(); if (!$row) $row = []; return new Invite(null, $row); } /** * Returns invite by email (latest inviter) */ public static function getInviteByEmail($email) { $sql = "SELECT inviteID FROM wcf".WCF_N."_user_invite_email WHERE email = ? ORDER BY time DESC"; $statement = WCF::getDB()->prepareStatement($sql, 1); $statement->execute([$email]); $row = $statement->fetchArray(); if (!$row) return new Invite(null, []); $sql = "SELECT * FROM wcf".WCF_N."_user_invite WHERE inviteID = ?"; $statement = WCF::getDB()->prepareStatement($sql); $statement->execute([$row['inviteID']]); $row = $statement->fetchArray(); if (!$row) $row = []; return new Invite(null, $row); } /** * Return 0 if email is not used within time otherwise return days */ public static function checkEmailBlocked($email) { $sql = "SELECT time FROM wcf".WCF_N."_user_invite_email WHERE email = ? ORDER BY time DESC"; $statement = WCF::getDB()->prepareStatement($sql, 1); $statement->execute([$email]); if ($row = $statement->fetchArray()) { if ($row['time'] + INVITE_EMAIL_TIME * 86400 < TIME_NOW) return 0; return ceil(($row['time'] + INVITE_EMAIL_TIME * 86400 - TIME_NOW) / 86400); } return 0; } /** * returns names of users who registered after invitation */ public function getUsernames() { $nameList = new InviteSuccessList(); $nameList->getConditionBuilder()->add('inviteID = ?', [$this->inviteID]); $nameList->sqlOrderBy = 'time DESC'; $nameList->readObjects(); $names = []; foreach($nameList->getObjects() as $name) { if ($name->userID) { $user = UserRuntimeCache::getInstance()->getObject($name->userID); $names[] = '' . $name->username . ''; } else { $names[] = $name->username; } } return implode(', ', $names); } /** * returns formatted message */ public function getExcerpt($maxLength = 255) { return StringUtil::truncateHTML($this->message, $maxLength); } } lib/data/user/invite/InviteAction.class.php 0100644 0000000 0000000 00000006430 13663532704 017765 0 ustar 00 0000000 0000000 * @package com.uz.wcf.invitation */ class InviteAction extends AbstractDatabaseObjectAction implements IDeleteAction { /** * @inheritDoc */ protected $className = InviteEditor::class; /** * @inheritDoc */ protected $permissionsCreate = ['user.profile.canInvite']; /** * @inheritDoc */ protected $permissionsDelete = ['user.profile.canInvite', 'admin.user.canManageInvite']; /** * @inheritDoc */ protected $permissionsUpdate = ['user.profile.canInvite']; /** * @inheritDoc */ protected $requireACP = []; /** * @inheritDoc */ protected $allowGuestAccess = ['getGroupedUserList']; /** * @inheritDoc */ public function validateDelete() { } /** * @inheritDoc */ public function delete() { $itemsToUserSubmit = $itemsToUserSuccess = []; foreach ($this->objectIDs as $id) { $invite = new Invite($id); if (!$invite->inviteID) continue; $user = new User($invite->inviterID); if (!$user->userID) continue; // delete success first with action for other purposes $successList = new InviteSuccessList(); $successList->getConditionBuilder()->add("user_invite_success.inviteID = ?", [$invite->inviteID]); $successList->readObjectIDs(); $action = new InviteSuccessAction($successList->getObjectIDs(), 'delete'); $action->executeAction(); // update user counts $editor = new UserEditor($user); $editor->updateCounters([ 'invites' => -1, 'inviteSuccess' => -1 * $invite->success ]); // store points if (!isset($itemsToUserSubmit[$invite->inviterID])) { $itemsToUserSubmit[$invite->inviterID] = 0; } $itemsToUserSubmit[$invite->inviterID]++; if (!isset($itemsToUserSuccess[$invite->inviterID])) { $itemsToUserSuccess[$invite->inviterID] = 0; } $itemsToUserSuccess[$invite->inviterID] += $invite->successCount; } // remove activity event UserActivityEventHandler::getInstance()->removeEvents('com.uz.wcf.invitation.recentActivityEvent.submit', [$invite->inviteID]); // remove points if (count($itemsToUserSubmit)) { UserActivityPointHandler::getInstance()->removeEvents('com.uz.wcf.invitation.activityPointEvent.submit', $itemsToUserSubmit); } if (count($itemsToUserSuccess)) { UserActivityPointHandler::getInstance()->removeEvents('com.uz.wcf.invitation.activityPointEvent.success', $itemsToUserSuccess); } // update cache InviteTopMembersBoxCacheBuilder::getInstance()->reset(); InviteTopSuccessMembersBoxCacheBuilder::getInstance()->reset(); parent::delete(); } /** * @inheritDoc */ public function validateUpdate() { } } lib/data/user/invite/InviteEditor.class.php 0100644 0000000 0000000 00000000636 13663532704 020000 0 ustar 00 0000000 0000000 * @package com.uz.wcf.invitation */ class InviteEditor extends DatabaseObjectEditor { /** * @inheritDoc */ public static $baseClass = Invite::class; } lib/data/user/invite/InviteList.class.php 0100644 0000000 0000000 00000000637 13663532704 017466 0 ustar 00 0000000 0000000 * @package com.uz.wcf.invitation */ class InviteList extends DatabaseObjectList { /** * @inheritDoc */ public $className = Invite::class; } lib/data/user/invite/success/InviteSuccess.class.php 0100644 0000000 0000000 00000002565 13663532704 021635 0 ustar 00 0000000 0000000 * @package com.uz.wcf.invitation */ class InviteSuccess extends DatabaseObject { /** * @inheritDoc */ protected static $databaseTableName = 'user_invite_success'; /** * @inheritDoc */ protected static $databaseTableIndexName = 'successID'; /** * returns for a specific user the names of users who registered per username registration */ public static function getUsernamesOfNameRegistration($userID) { $nameList = new InviteSuccessList(); $nameList->getConditionBuilder()->add('inviterID = ?', [$userID]); $nameList->getConditionBuilder()->add('inviteID IS NULL'); $nameList->sqlOrderBy = 'username ASC'; $nameList->readObjects(); $names = []; foreach($nameList->getObjects() as $name) { if ($name->userID) { $user = UserRuntimeCache::getInstance()->getObject($name->userID); $names[] = '' . $name->username . ''; } else { $names[] = $name->username; } } return implode(', ', $names); } } lib/data/user/invite/success/InviteSuccessAction.class.php 0100644 0000000 0000000 00000000736 13663532704 022771 0 ustar 00 0000000 0000000 * @package com.uz.wcf.invitation */ class InviteSuccessAction extends AbstractDatabaseObjectAction { /** * @inheritDoc */ protected $className = InviteSuccessEditor::class; } lib/data/user/invite/success/InviteSuccessEditor.class.php 0100644 0000000 0000000 00000000675 13663532704 023004 0 ustar 00 0000000 0000000 * @package com.uz.wcf.invitation */ class InviteSuccessEditor extends DatabaseObjectEditor { /** * @inheritDoc */ public static $baseClass = InviteSuccess::class; } lib/data/user/invite/success/InviteSuccessList.class.php 0100644 0000000 0000000 00000000676 13663532704 022472 0 ustar 00 0000000 0000000 * @package com.uz.wcf.invitation */ class InviteSuccessList extends DatabaseObjectList { /** * @inheritDoc */ public $className = InviteSuccess::class; } lib/form/InviteAddForm.class.php 0100644 0000000 0000000 00000017417 13753742712 015653 0 ustar 00 0000000 0000000 * @package com.uz.wcf.invitation */ class InviteAddForm extends AbstractForm { /** * @inheritDoc */ public $loginRequired = true; /** * @inheritDoc */ public $neededPermissions = ['user.profile.canInvite']; /** * invite data */ public $emailField = ''; public $emails = []; public $code = ''; public $description = ''; public $method = 'email'; public $codeOption = ''; public $subject = ''; public $message = ''; /** * affected user */ public $user = null; /** * @inheritDoc */ public function readParameters() { parent::readParameters(); // set user $this->user = WCF::getUser(); // presets $this->code = base_convert(uniqid(), 16, 36); $this->method = 'copy'; switch (INVITE_CODE_OPTION) { case 'may': $this->description = WCF::getLanguage()->getDynamicVariable('wcf.user.invite.description.may'); break; case 'maynot': $this->code = ''; $this->description = WCF::getLanguage()->getDynamicVariable('wcf.user.invite.description.maynot'); $this->method = 'email'; break; case 'must': $this->description = WCF::getLanguage()->getDynamicVariable('wcf.user.invite.description.must'); break; } $this->subject = WCF::getLanguage()->getDynamicVariable('wcf.user.invite.subject.default'); $this->message = WCF::getLanguage()->getDynamicVariable('wcf.user.invite.message.default', ['code' => $this->code]); } /** * @inheritDoc */ public function readData() { parent::readData(); } /** * @inheritDoc */ public function readFormParameters() { parent::readFormParameters(); if (isset($_POST['code'])) $this->code = $_POST['code']; if (isset($_POST['emailField'])) $this->emailField = StringUtil::trim($_POST['emailField']); if (isset($_POST['message'])) $this->message = StringUtil::trim($_POST['message']); if (isset($_POST['subject'])) $this->subject = StringUtil::trim($_POST['subject']); if (INVITE_CODE_OPTION != 'maynot') if (isset($_POST['method'])) $this->method = $_POST['method']; } /** * @inheritDoc */ public function validate() { parent::validate(); // check email if ($this->method == 'email') { // emailField not empty if (empty($this->emailField)) { throw new UserInputException('emailField'); } // emails must be correct and are limited $emails = array_unique(ArrayUtil::trim(explode("\n", $this->emailField))); if (count($emails) > INVITE_EMAIL_LIMIT) throw new UserInputException('emailField', 'tooMany'); foreach ($emails as $email) { if (!UserUtil::isValidEmail($email)) { WCF::getTPL()->assign([ 'invalidEmail' => $email ]); throw new UserInputException('emailField', 'notValid'); } // check email (spam) $days = Invite::checkEmailBlocked($email); if ($days) { WCF::getTPL()->assign([ 'blockedEmail' => $email, 'days' => $days ]); throw new UserInputException('emailField', 'blockedEmail'); } } $this->emailField = implode(', ', $emails); // subject not empty and < 256 chars if (empty($this->subject)) throw new UserInputException('subject'); if (mb_strlen($this->subject) > 255) throw new UserInputException('subject', 'tooLong'); // message not empty if (empty($this->message)) throw new UserInputException('message'); // either subject or message must contain the code, if required if (INVITE_CODE_OPTION == 'must') { if (mb_stripos($this->subject, $this->code) === false && mb_stripos($this->message, $this->code) === false) { throw new UserInputException('message', 'noCode'); } } } } /** * @inheritDoc */ public function assignVariables() { parent::assignVariables(); WCF::getTPL()->assign([ 'code' => $this->code, 'description' => $this->description, 'emailField' => $this->emailField, 'message' => $this->message, 'method' => $this->method, 'subject' => $this->subject, 'user' => $this->user ]); } /** * @inheritDoc */ public function show() { // set active tab UserMenu::getInstance()->setActiveMenuItem('wcf.user.menu.invite.add'); parent::show(); } /** * @inheritDoc */ public function save() { parent::save(); $data = [ 'code' => $this->code, 'codeExpires' => INVITE_CODE_EXPIRE ? TIME_NOW + 86400 * INVITE_CODE_EXPIRE : 0, 'emails' => ($this->method == 'email' ? $this->emailField : ''), 'inviterID' => $this->user->userID, 'inviterName' => $this->user->username, 'message' => ($this->method == 'email' ? $this->message : ''), 'subject' => ($this->method == 'email' ? $this->subject : ''), 'time' => TIME_NOW ]; $action = new InviteAction([], 'create', ['data' => $data]); $returnValues = $action->executeAction(); $inviteID = $returnValues['returnValues']->inviteID; // update user count $editor = new UserEditor($this->user); $editor->updateCounters([ 'invites' => 1 ]); // send emails and store them if ($this->method == 'email') { $language = WCF::getLanguage(); $receivers = explode(', ', $this->emailField); $sender = WCF::getUser(); $replyTo = new UserMailBox($sender); $messageData = [ 'message' => $this->message, 'username' => $sender->username ]; foreach ($receivers as $receiver) { $email = new Email(); $email->addRecipient(new Mailbox($receiver, null, $language)); $email->setSubject($sender->getLanguage()->getDynamicVariable('wcf.user.invite.email.subject', [ 'username' => $sender->username, 'subject' => $this->subject ])); $email->setBody(new MimePartFacade([ new RecipientAwareTextMimePart('text/html', 'invite_email', 'wcf', $messageData), new RecipientAwareTextMimePart('text/plain', 'invite_email', 'wcf', $messageData) ])); $email->setReplyTo(new UserMailbox($sender)); $email->send(); } // block emails WCF::getDB()->beginTransaction(); $sql = "INSERT INTO wcf".WCF_N."_user_invite_email (email, time, inviteID) VALUES (?, ?, ?)"; $statement = WCF::getDB()->prepareStatement($sql); foreach ($receivers as $receiver) { if (mb_strlen($receiver) < 256) { $statement->execute([$receiver, TIME_NOW - 1, $inviteID]); } } WCF::getDB()->commitTransaction(); } // recent activity and points (always) if (MODULE_INVITE_ACTIVITY) { UserActivityEventHandler::getInstance()->fireEvent('com.uz.wcf.invitation.recentActivityEvent.submit', $inviteID); } UserActivityPointHandler::getInstance()->fireEvent('com.uz.wcf.invitation.activityPointEvent.submit', $inviteID, $this->user->userID); // reset box cache InviteTopMembersBoxCacheBuilder::getInstance()->reset(); $this->saved(); // show success message WCF::getTPL()->assign('success', true); // forward to list page HeaderUtil::delayedRedirect(LinkHandler::getInstance()->getLink('InviteListUser'), WCF::getLanguage()->get('wcf.user.invite.add.success'), 2); exit; } } lib/page/InviteListUserPage.class.php 0100644 0000000 0000000 00000002756 13663532704 016655 0 ustar 00 0000000 0000000 * @package com.uz.wcf.invitation */ class InviteListUserPage extends SortablePage { /** * @inheritDoc */ public $loginRequired = true; /** * @inheritDoc */ public $neededPermissions = ['user.profile.canInvite']; /** * @inheritDoc */ public $objectListClassName = InviteList::class; /** * @inheritDoc */ public $sqlOrderBy = 'user_invite.time DESC'; /** * @inheritDoc */ public $itemsPerPage = 10; /** * usernames of users who registered entering inviter username */ public $usernames = ''; /** * @inheritDoc */ protected function initObjectList() { parent::initObjectList(); $this->objectList->getConditionBuilder()->add("user_invite.inviterID = ?", [WCF::getUser()->userID]); $this->usernames = InviteSuccess::getUsernamesOfNameRegistration(WCF::getUser()->userID); } /** * @inheritDoc */ public function assignVariables() { parent::assignVariables(); WCF::getTPL()->assign([ 'usernames' => $this->usernames ]); } /** * @inheritDoc */ public function show() { // set active tab UserMenu::getInstance()->setActiveMenuItem('wcf.user.menu.invite.list'); parent::show(); } } lib/system/box/InviteTopMembersBoxController.class.php 0100644 0000000 0000000 00000002514 13663532704 022270 0 ustar 00 0000000 0000000 * @package com.uz.wcf.invitation */ class InviteTopMembersBoxController extends AbstractBoxController { /** * @inheritDoc */ protected static $supportedPositions = ['sidebarLeft', 'sidebarRight']; /** * @inheritDoc */ public function hasLink() { return MODULE_MEMBERS_LIST == 1; } /** * @inheritDoc */ public function getLink() { if (MODULE_MEMBERS_LIST) { $parameters = 'sortField=invites&sortOrder=DESC'; return LinkHandler::getInstance()->getLink('MembersList', [], $parameters); } return ''; } /** * @inheritDoc */ protected function loadContent() { if (MODULE_INVITE) { $userIDs = InviteTopMembersBoxCacheBuilder::getInstance()->getData(); if (!empty($userIDs)) { $userProfiles = UserProfileRuntimeCache::getInstance()->getObjects($userIDs); WCF::getTPL()->assign([ 'userProfiles' => $userProfiles ]); $this->content = WCF::getTPL()->fetch('boxInviteTopMembers'); } } } } lib/system/box/InviteTopSuccessMembersBoxController.class.php 0100644 0000000 0000000 00000002633 13663532704 023623 0 ustar 00 0000000 0000000 * @package com.uz.wcf.invitation */ class InviteTopSuccessMembersBoxController extends AbstractBoxController { /** * @inheritDoc */ protected static $supportedPositions = ['sidebarLeft', 'sidebarRight']; /** * @see wcf\system\box\IBoxController::hasLink() */ public function hasLink() { return MODULE_MEMBERS_LIST == 1; } /** * @inheritDoc */ public function getLink() { if (MODULE_MEMBERS_LIST) { $parameters = 'sortField=inviteSuccess&sortOrder=DESC'; return LinkHandler::getInstance()->getLink('MembersList', [], $parameters); } return ''; } /** * @inheritDoc */ protected function loadContent() { if (MODULE_INVITE) { $userIDs = InviteTopSuccessMembersBoxCacheBuilder::getInstance()->getData(); if (!empty($userIDs)) { $userProfiles = UserProfileRuntimeCache::getInstance()->getObjects($userIDs); WCF::getTPL()->assign([ 'userProfiles' => $userProfiles ]); $this->content = WCF::getTPL()->fetch('boxInviteTopSuccessMembers'); } } } } lib/system/bulk/processing/user/InviteDeleteBulkProcessingAction.class.php 0100644 0000000 0000000 00000005570 13663532704 026215 0 ustar 00 0000000 0000000 * @package com.uz.wcf.invitation */ class InviteDeleteBulkProcessingAction extends AbstractUserBulkProcessingAction { /** * @inheritDoc */ public function executeAction(DatabaseObjectList $objectList) { if (!($objectList instanceof UserList)) return; $users = $objectList->getObjects(); if (!empty($users)) { $userIDs = $inviteToUser = $successToUser = []; foreach ($users as $user) { $userIDs[] = $user->userID; if (!isset($inviteToUser[$user->userID])) { $inviteToUser[$user->userID] = 0; } $inviteToUser[$user->userID] += $user->invites; if (!isset($successToUser[$user->userID])) { $successToUser[$user->userID] = 0; } $successToUser[$user->userID] += $user->inviteSuccess; } // remove points UserActivityPointHandler::getInstance()->removeEvents('com.uz.wcf.invitation.activityPointEvent.submit', $inviteToUser); UserActivityPointHandler::getInstance()->removeEvents('com.uz.wcf.invitation.activityPointEvent.success', $successToUser); // remove user counts $conditions = new PreparedStatementConditionBuilder(); $conditions->add("userID IN (?)", [$userIDs]); $sql = "UPDATE wcf".WCF_N."_user SET invites = 0, inviteSuccess = 0 ".$conditions; $statement = WCF::getDB()->prepareStatement($sql); $statement->execute($conditions->getParameters()); // reset invitation box cache InviteTopMembersBoxCacheBuilder::getInstance()->reset(); // remove invites and success $conditions = new PreparedStatementConditionBuilder(); $conditions->add("inviterID IN (?)", [$userIDs]); $sql = "DELETE FROM wcf".WCF_N."_user_invite ".$conditions; $statement = WCF::getDB()->prepareStatement($sql); $statement->execute($conditions->getParameters()); $conditions = new PreparedStatementConditionBuilder(); $conditions->add("inviterID IN (?)", [$userIDs]); $conditions->add("inviteID IS NULL"); $sql = "DELETE FROM wcf".WCF_N."_user_invite_success ".$conditions; $statement = WCF::getDB()->prepareStatement($sql); $statement->execute($conditions->getParameters()); } } /** * @inheritDoc */ public function getObjectList() { $userList = parent::getObjectList(); // only users with invites $userList->getConditionBuilder()->add("(user_table.invites > ? OR user_table.inviteSuccess > ?)", [0, 0]); return $userList; } } lib/system/cache/builder/InviteTopMembersBoxCacheBuilder.class.php 0100644 0000000 0000000 00000001172 13663532704 024357 0 ustar 00 0000000 0000000 * @package com.uz.wcf.invitation */ class InviteTopMembersBoxCacheBuilder extends AbstractSortedUserCacheBuilder { /** * @inheritDoc */ protected $maxLifetime = 300; /** * @inheritDoc */ protected $defaultLimit = INVITE_DISPLAY_BOX_ENTRIES + 1; /** * @inheritDoc */ protected $positiveValuesOnly = true; /** * @inheritDoc */ protected $sortField = 'invites'; } lib/system/cache/builder/InviteTopSuccessMembersBoxCacheBuilder.class.php 0100644 0000000 0000000 00000001222 13663532704 025704 0 ustar 00 0000000 0000000 * @package com.uz.wcf.invitation */ class InviteTopSuccessMembersBoxCacheBuilder extends AbstractSortedUserCacheBuilder { /** * @inheritDoc */ protected $maxLifetime = 300; /** * @inheritDoc */ protected $defaultLimit = INVITE_DISPLAY_BOX_ENTRIES + 1; /** * @inheritDoc */ protected $positiveValuesOnly = true; /** * @inheritDoc */ protected $sortField = 'inviteSuccess'; } lib/system/event/listener/InviteMembersListPageListener.class.php 0100644 0000000 0000000 00000001141 13663532704 024400 0 ustar 00 0000000 0000000 * @package com.uz.wcf.invitation */ class InviteMembersListPageListener implements IParameterizedEventListener { /** * @inheritDoc */ public function execute($eventObj, $className, $eventName, array &$parameters) { $eventObj->validSortFields[] = 'invites'; $eventObj->validSortFields[] = 'inviteSuccess'; } } lib/system/event/listener/InviteRegisterFormListener.class.php 0100644 0000000 0000000 00000013716 13663532704 024000 0 ustar 00 0000000 0000000 * @package com.uz.wcf.invitation */ class InviteRegisterFormListener implements IParameterizedEventListener { /** * @inheritDoc */ protected $eventObj = null; /** * invite, code and option */ public $invite = null; public $inviter = null; public $inviteByName = false; public $inviteCode = ''; public $inviteCodeOption = ''; /** * @inheritDoc */ public function execute($eventObj, $className, $eventName, array &$parameters) { if (!MODULE_INVITE) return; $this->eventObj = $eventObj; $this->$eventName(); } /** * Handles the readFormParameters event. */ protected function readFormParameters() { if (isset($_POST['inviteCode'])) $this->inviteCode = StringUtil::trim($_POST['inviteCode']); } /** * Handles the readParameters event. */ protected function readParameters() { $this->inviteCodeOption = INVITE_CODE_OPTION; } /** * Handles the assignVariables event. */ protected function assignVariables() { WCF::getTPL()->assign([ 'inviteCode' => $this->inviteCode, 'inviteCodeOption' => $this->inviteCodeOption ]); } /** * Handles the validate event. */ protected function validate() { // code is required if ($this->inviteCodeOption == 'must') { try { // empty if (empty($this->inviteCode)) { throw new UserInputException('inviteCode', 'empty'); } // must be correct if (!Invite::checkCodeExist($this->inviteCode)) { throw new UserInputException('inviteCode', 'invalid'); } } catch (UserInputException $e) { $this->eventObj->errorType[$e->getField()] = $e->getType(); } } // must be correct if entered if ($this->inviteCodeOption == 'may') { if (!empty($this->inviteCode)) { try { // either valid code or username if (INVITE_CODE_USERNAME) { if (!Invite::checkCodeExist($this->inviteCode)) { $this->inviter = User::getUserByUsername($this->inviteCode); if (!$this->inviter->userID) { throw new UserInputException('inviteCode', 'invalidUsername'); } } } else { if (!Invite::checkCodeExist($this->inviteCode)) { throw new UserInputException('inviteCode', 'invalid'); } } } catch (UserInputException $e) { $this->eventObj->errorType[$e->getField()] = $e->getType(); } } } } /** * Handles the save event. */ protected function save() { // get invite to honour inviter if (!empty($this->inviteCode)) { $invite = Invite::getInviteByCode($this->inviteCode); } else { // get it from emails $invite = Invite::getInviteByEmail($this->eventObj->email); } if (!$invite->inviteID) { // last chance username if ($this->inviteCodeOption == 'may' && INVITE_CODE_USERNAME) { if (!$this->inviter) return; $this->inviteByName = true; } else return; } if ($this->inviteByName === true) { // update user invite count $editor = new UserEditor($this->inviter); $editor->updateCounters([ 'inviteSuccess' => 1 ]); } else { // check inviting user $user = new User($invite->inviterID); if (!$user->userID) return; // successful invitation $this->invite = $invite; // update invite data $usernames = []; if (!empty($this->invite->usernames)) $usernames = explode(', ', $this->invite->usernames); $usernames[] = $this->eventObj->username; $editor = new InviteEditor($this->invite); $editor->updateCounters([ 'successCount' => 1 ]); // update user invite count $editor = new UserEditor($user); $editor->updateCounters([ 'inviteSuccess' => 1 ]); // update code count if (!empty($this->inviteCode)) { $sql = "INSERT INTO wcf".WCF_N."_user_invite_code (code, used) VALUES (?, ?) ON DUPLICATE KEY UPDATE used = used + 1"; $statement = WCF::getDB()->prepareStatement($sql); $statement->execute([$this->inviteCode, 1]); } } } /** * Handles the saved event. */ protected function saved() { if ($this->invite || $this->inviteByName) { // invite success $data = [ 'inviteID' => $this->inviteByName ? null : $this->invite->inviteID, 'inviterID' => $this->inviteByName ? $this->inviter->userID : $this->invite->inviterID, 'inviterName' => $this->inviteByName ? $this->inviter->username : $this->invite->inviterName, 'userID' => WCF::getUser()->userID, 'username' => WCF::getUser()->username, 'time' => TIME_NOW ]; $action = new InviteSuccessAction([], 'create', ['data' => $data]); $returnValues = $action->executeAction(); $successID = $returnValues['returnValues']->successID; // notification $inviterID = $this->inviteByName ? $this->inviter->userID : $this->invite->inviterID; UserNotificationHandler::getInstance()->fireEvent( 'success', 'com.uz.wcf.invitation', new InviteSuccessUserNotificationObject(new InviteSuccess($successID)), [$inviterID]); // points for successful invitation UserActivityPointHandler::getInstance()->fireEvent('com.uz.wcf.invitation.activityPointEvent.success', $successID, $inviterID); // update cache InviteTopSuccessMembersBoxCacheBuilder::getInstance()->reset(); } } } lib/system/menu/user/InviteMenuItemProvider.class.php 0100644 0000000 0000000 00000000761 13663532704 022070 0 ustar 00 0000000 0000000 * @package com.uz.wcf.invitation */ class InviteMenuItemProvider extends DefaultUserMenuItemProvider { /** * @inheritDoc */ public function isVisible() { if (WCF::getSession()->getPermission('user.profile.canInvite')) return true; return false; } } lib/system/stat/InviteSubmitStatDailyHandler.class.php 0100644 0000000 0000000 00000001073 13663532704 022240 0 ustar 00 0000000 0000000 * @package com.uz.wcf.invitation */ class InviteSubmitStatDailyHandler extends AbstractStatDailyHandler { /** * @inheritDoc */ public function getData($date) { return [ 'counter' => $this->getCounter($date, 'wcf'.WCF_N.'_user_invite', 'time'), 'total' => $this->getTotal($date, 'wcf'.WCF_N.'_user_invite', 'time') ]; } } lib/system/stat/InviteSuccessStatDailyHandler.class.php 0100644 0000000 0000000 00000001111 13663532704 022376 0 ustar 00 0000000 0000000 * @package com.uz.wcf.invitation */ class InviteSuccessStatDailyHandler extends AbstractStatDailyHandler { /** * @inheritDoc */ public function getData($date) { return [ 'counter' => $this->getCounter($date, 'wcf'.WCF_N.'_user_invite_success', 'time'), 'total' => $this->getTotal($date, 'wcf'.WCF_N.'_user_invite_success', 'time') ]; } } lib/system/user/activity/event/InviteUserActivityEvent.class.php 0100644 0000000 0000000 00000002606 13663532704 024300 0 ustar 00 0000000 0000000 * @package com.uz.wcf.invitation */ class InviteUserActivityEvent extends SingletonFactory implements IUserActivityEvent { /** * @inheritDoc */ public function prepare(array $events) { $objectIDs = []; foreach ($events as $event) { $objectIDs[] = $event->objectID; } // fetch invitations $inviteList = new InviteList(); $inviteList->getConditionBuilder()->add("user_invite.inviteID IN (?)", [$objectIDs]); $inviteList->readObjects(); $invites = $inviteList->getObjects(); // set message foreach ($events as $event) { if (isset($invites[$event->objectID])) { $invite = $invites[$event->objectID]; // check permissions if (!$invite->canSee()) { continue; } $event->setIsAccessible(); // title and description $text = WCF::getLanguage()->getDynamicVariable('wcf.user.invite.recentActivity.submit', ['user' => WCF::getUser()]); $event->setTitle($text); $event->setDescription(''); } else { $event->setIsOrphaned(); } } } } lib/system/user/invite/InviteHandler.class.php 0100644 0000000 0000000 00000001372 13663532704 020540 0 ustar 00 0000000 0000000 * @package com.uz.wcf.invitation */ class InviteHandler extends SingletonFactory { /** * Returns a user's invite count. */ public function getCount($user = null) { if ($user === null) $user = WCF::getUser(); if (!$user->userID) return 0; $sql = "SELECT COUNT(*) AS count FROM wcf".WCF_N."_user_invite WHERE inviterID = ?"; $statement = WCF::getDB()->prepareStatement($sql); $statement->execute([$user->userID]); return $statement->fetchColumn(); } } lib/system/user/notification/event/InviteSuccessUserNotificationEvent.class.php 0100644 0000000 0000000 00000004303 13663532705 027312 0 ustar 00 0000000 0000000 * @package com.uz.wcf.invitation */ class InviteSuccessUserNotificationEvent extends AbstractUserNotificationEvent { /** * @inheritDoc */ protected $stackable = true; /** * @inheritDoc */ protected function prepare() { UserProfileRuntimeCache::getInstance()->cacheObjectID($this->getUserNotificationObject()->objectID); } /** * @inheritDoc */ public function getTitle() { $count = count($this->getAuthors()); if ($count > 1) { return $this->getLanguage()->getDynamicVariable('wcf.user.notification.invite.title.stacked', [ 'count' => $count, 'timesTriggered' => $this->notification->timesTriggered ]); } return $this->getLanguage()->get('wcf.user.notification.invite.title'); } /** * @inheritDoc */ public function getMessage() { $authors = $this->getAuthors(); if (count($authors) > 1) { if (isset($authors[0])) { unset($authors[0]); } $count = count($authors); return $this->getLanguage()->getDynamicVariable('wcf.user.notification.invite.message.stacked', [ 'author' => $this->author, 'authors' => array_values($authors), 'count' => $count, 'others' => $count - 1, 'guestTimesTriggered' => $this->notification->guestTimesTriggered ]); } return $this->getLanguage()->getDynamicVariable('wcf.user.notification.invite.message', [ 'author' => $this->author ]); } /** * @inheritDoc */ public function getEmailMessage($notificationType = 'instant') { throw new \LogicException('Unreachable'); } /** * @inheritDoc */ public function getLink() { return LinkHandler::getInstance()->getLink('InviteListUser'); } /** * @inheritDoc */ public function getEventHash() { return sha1($this->eventID . '-' . $this->notification->userID); } /** * @inheritDoc */ public function supportsEmailNotification() { return false; } } lib/system/user/notification/object/InviteSuccessUserNotificationObject.class.php 0100644 0000000 0000000 00000001763 13663532705 027573 0 ustar 00 0000000 0000000 * @package com.uz.wcf.invitation */ class InviteSuccessUserNotificationObject extends DatabaseObjectDecorator implements IStackableUserNotificationObject { /** * @inheritDoc */ protected static $baseClass = InviteSuccess::class; /** * returns the title */ public function getTitle() { return ''; } /** * returns the URL */ public function getURL() { return ''; } /** * returns the userID */ public function getAuthorID() { //return $this->userID; return WCF::getUser()->userID; } /** * @inheritDoc */ public function getRelatedObjectID() { // return $this->inviterID; // return WCF::getUser()->userID; } } lib/system/user/notification/object/type/InviteSuccessUserNotificationObjectType.class.php 0100644 0000000 0000000 00000001550 13663532705 031410 0 ustar 00 0000000 0000000 * @package com.uz.wcf.invitation */ class InviteSuccessUserNotificationObjectType extends AbstractUserNotificationObjectType { /** * @inheritDoc */ protected static $decoratorClassName = InviteSuccessUserNotificationObject::class; /** * @inheritDoc */ protected static $objectClassName = InviteSuccess::class; /** * @inheritDoc */ protected static $objectListClassName = InviteSuccessList::class; } lib/system/worker/InviteRebuildDataWorker.class.php 0100644 0000000 0000000 00000005141 13663532705 021571 0 ustar 00 0000000 0000000 * @package com.uz.wcf.invitation */ class InviteRebuildDataWorker extends AbstractRebuildDataWorker { /** * @inheritDoc */ protected $objectListClassName = UserList::class; /** * @inheritDoc */ protected $limit = 100; /** * @inheritDoc */ protected function initObjectList() { parent::initObjectList(); $this->objectList->sqlOrderBy = 'user_table.userID'; } /** * @inheritDoc */ public function execute() { parent::execute(); if (!$this->loopCount) { // reset activity points UserActivityPointHandler::getInstance()->reset('com.uz.wcf.invitation.activityPointEvent.submit'); UserActivityPointHandler::getInstance()->reset('com.uz.wcf.invitation.activityPointEvent.success'); // reset invite counts in user $sql = "UPDATE wcf".WCF_N."_user SET invites = ?, inviteSuccess = ?"; $statement = WCF::getDB()->prepareStatement($sql); $statement->execute([0, 0]); } if (!count($this->objectList)) { return; } $inviteToUser = $successToUser = []; foreach ($this->objectList as $user) { $invite = $success = 0; $sql = "SELECT COUNT(*) AS counter FROM wcf".WCF_N."_user_invite WHERE inviterID = ?"; $statement = WCF::getDB()->prepareStatement($sql, 1); $statement->execute([$user->userID]); $invite = $statement->fetchColumn(); $sql = "SELECT COUNT(*) AS counter FROM wcf".WCF_N."_user_invite_success WHERE inviterID = ?"; $statement = WCF::getDB()->prepareStatement($sql, 1); $statement->execute([$user->userID]); $success = $statement->fetchColumn(); if ($invite || $success) { // update user $editor = new UserEditor($user); $editor->updateCounters([ 'invites' => $invite, 'inviteSuccess' => $success ]); // update point arrays if ($invite) $inviteToUser[$user->userID] = $invite; if ($success) $successToUser[$user->userID] = $success; } } // update activity points if (count($inviteToUser)) UserActivityPointHandler::getInstance()->fireEvents('com.uz.wcf.invitation.activityPointEvent.submit', $inviteToUser, true); if (count($successToUser)) UserActivityPointHandler::getInstance()->fireEvents('com.uz.wcf.invitation.activityPointEvent.success', $successToUser, true); } } templates.tar 0100644 0000000 0000000 00000050000 13753743765 012332 0 ustar 00 0000000 0000000 __inviteMessageSidebar.tpl 0100644 0000000 0000000 00000000424 13020502575 014720 0 ustar 00 0000000 0000000 {if MODULE_INVITE && INVITE_DISPLAY_MESSAGE_SIDEBAR && $userProfile->invites}{lang}wcf.global.success.edit{/lang}
{/if} {include file='footer' __disableAds=true} inviteListUser.tpl 0100644 0000000 0000000 00000004734 13051613151 013323 0 ustar 00 0000000 0000000 {capture assign='pageTitle'}{lang}wcf.user.invite.invite{/lang}: {lang}wcf.user.invite.list{/lang}{/capture} {capture assign='contentHeader'} {assign var="count" value=$__wcf->getUser()->inviteSuccess}{lang}wcf.user.invite.myInviteSuccess{/lang}
{/if}{lang}wcf.user.invite.noInvites{/lang}
{/if} {include file='footer'} inviteTopList.tpl 0100644 0000000 0000000 00000002363 13543434464 013161 0 ustar 00 0000000 0000000 {if $users|count}{lang}wcf.global.noItems{/lang}
{/if} invite_email.tpl 0100644 0000000 0000000 00000000415 13025066441 012774 0 ustar 00 0000000 0000000 {if $mimeType === 'text/plain'} {capture assign='content'}{lang}wcf.user.invite.mail.plaintext{/lang}{/capture} {include file='email_plaintext'} {else} {capture assign='content'} {lang}wcf.user.invite.mail.html{/lang} {/capture} {include file='email_html'} {/if} optionals/com.uz.jcoins.invitation.tar 0100644 0000000 0000000 00000074000 13743343577 017230 0 ustar 00 0000000 0000000 language/de.xml 0100644 0000000 0000000 00000002306 13543425223 012506 0 ustar 00 0000000 0000000