Getting reworked for 2.1 so I'm cheating and skipping params for now. -mlr
public add ( integer $ActivityUserID, string $ActivityType, string $Story = null, integer | null $RegardingUserID = null, integer $CommentActivityID = null, string $Route = null, string | boolean $SendEmail = '' ) : integer | ||
$ActivityUserID | integer | |
$ActivityType | string | |
$Story | string | |
$RegardingUserID | integer | null | |
$CommentActivityID | integer | |
$Route | string | |
$SendEmail | string | boolean | |
Результат | integer | ActivityID of item created. |
/** * * * @return bool * @throws Gdn_UserException */ public function addActivity() { // Build the story for the activity. $Header = $this->getImportHeader(); $PorterVersion = val('Vanilla Export', $Header, t('unknown')); $SourceData = val('Source', $Header, t('unknown')); $Story = sprintf(t('Vanilla Export: %s, Source: %s'), $PorterVersion, $SourceData); $ActivityModel = new ActivityModel(); $ActivityModel->add(Gdn::session()->UserID, 'Import', $Story); return true; }
/** * Registration that requires approval. * * Events: RegistrationPending * * @access private * @since 2.0.0 */ private function registerApproval() { Gdn::userModel()->addPasswordStrength($this); // If the form has been posted back... if ($this->Form->isPostBack()) { // Add validation rules that are not enforced by the model $this->UserModel->defineSchema(); $this->UserModel->Validation->applyRule('Name', 'Username', $this->UsernameError); $this->UserModel->Validation->applyRule('TermsOfService', 'Required', t('You must agree to the terms of service.')); $this->UserModel->Validation->applyRule('Password', 'Required'); $this->UserModel->Validation->applyRule('Password', 'Strength'); $this->UserModel->Validation->applyRule('Password', 'Match'); $this->UserModel->Validation->applyRule('DiscoveryText', 'Required', 'Tell us why you want to join!'); // $this->UserModel->Validation->applyRule('DateOfBirth', 'MinimumAge'); $this->fireEvent('RegisterValidation'); try { $Values = $this->Form->formValues(); $Values = $this->UserModel->filterForm($Values, true); unset($Values['Roles']); $AuthUserID = $this->UserModel->register($Values); $this->setData('UserID', $AuthUserID); if (!$AuthUserID) { $this->Form->setValidationResults($this->UserModel->validationResults()); } else { // The user has been created successfully, so sign in now. Gdn::session()->start($AuthUserID); if ($this->Form->getFormValue('RememberMe')) { Gdn::authenticator()->SetIdentity($AuthUserID, true); } // Notification text $Label = t('NewApplicantEmail', 'New applicant:'); $Story = anchor(Gdn_Format::text($Label . ' ' . $Values['Name']), ExternalUrl('dashboard/user/applicants')); $this->EventArguments['AuthUserID'] = $AuthUserID; $this->EventArguments['Story'] =& $Story; $this->fireEvent('RegistrationPending'); $this->View = "RegisterThanks"; // Tell the user their application will be reviewed by an administrator. // Grab all of the users that need to be notified. $Data = Gdn::database()->sql()->getWhere('UserMeta', array('Name' => 'Preferences.Email.Applicant'))->resultArray(); $ActivityModel = new ActivityModel(); foreach ($Data as $Row) { $ActivityModel->add($AuthUserID, 'Applicant', $Story, $Row['UserID'], '', '/dashboard/user/applicants', 'Only'); } } } catch (Exception $Ex) { $this->Form->addError($Ex); } $this->render(); } else { $this->render(); } }