本文整理汇总了PHP中Captcha::enabled方法的典型用法代码示例。如果您正苦于以下问题:PHP Captcha::enabled方法的具体用法?PHP Captcha::enabled怎么用?PHP Captcha::enabled使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Captcha
的用法示例。
在下文中一共展示了Captcha::enabled方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: render
/**
* Wrapper for captcha rendering.
*
* Allows conditional ignoring of captcha rendering if skipped in the config.
*
* @param Gdn_Controller $controller
* @return null;
*/
public static function render($controller)
{
if (!Captcha::enabled()) {
return null;
}
// Hook to allow rendering of captcha form
$controller->fireAs('captcha')->fireEvent('render');
return null;
}
示例2: insertForBasic
/**
* To be used for basic registration, and captcha registration.
*
* @param array $FormPostValues
* @param bool $CheckCaptcha
* @param array $Options
* @return bool|int|string
* @throws Exception
*/
public function insertForBasic($FormPostValues, $CheckCaptcha = true, $Options = [])
{
$RoleIDs = RoleModel::getDefaultRoles(RoleModel::TYPE_MEMBER);
if (!is_array($RoleIDs) || count($RoleIDs) == 0) {
throw new Exception(t('The default role has not been configured.'), 400);
}
if (val('SaveRoles', $Options)) {
$RoleIDs = val('RoleID', $FormPostValues);
}
$UserID = false;
// Define the primary key in this model's table.
$this->defineSchema();
// Add & apply any extra validation rules.
if (val('ValidateEmail', $Options, true)) {
$this->Validation->applyRule('Email', 'Email');
}
// TODO: DO I NEED THIS?!
// Make sure that the checkbox val for email is saved as the appropriate enum
if (array_key_exists('ShowEmail', $FormPostValues)) {
$FormPostValues['ShowEmail'] = forceBool($FormPostValues['ShowEmail'], '0', '1', '0');
}
if (array_key_exists('Banned', $FormPostValues)) {
$FormPostValues['Banned'] = forceBool($FormPostValues['Banned'], '0', '1', '0');
}
$this->addInsertFields($FormPostValues);
if ($this->validate($FormPostValues, true) === true) {
$Fields = $this->Validation->validationFields();
// All fields on the form that need to be validated (including non-schema field rules defined above)
$Username = val('Name', $Fields);
$Email = val('Email', $Fields);
$Fields = $this->Validation->schemaValidationFields();
// Only fields that are present in the schema
$Fields['Roles'] = $RoleIDs;
unset($Fields[$this->PrimaryKey]);
// If in Captcha registration mode, check the captcha value.
if ($CheckCaptcha && Captcha::enabled()) {
$captchaIsValid = Captcha::validate();
if ($captchaIsValid !== true) {
$this->Validation->addValidationResult('Garden.Registration.CaptchaPublicKey', 'The captcha was not completed correctly. Please try again.');
return false;
}
}
if (!$this->validateUniqueFields($Username, $Email)) {
return false;
}
// Check for spam.
if (val('ValidateSpam', $Options, true)) {
$ValidateSpam = $this->validateSpamRegistration($FormPostValues);
if ($ValidateSpam !== true) {
return $ValidateSpam;
}
}
// Define the other required fields:
$Fields['Email'] = $Email;
// And insert the new user
$UserID = $this->insertInternal($Fields, $Options);
if ($UserID > 0 && !val('NoActivity', $Options)) {
$ActivityModel = new ActivityModel();
$ActivityModel->save(['ActivityUserID' => $UserID, 'ActivityType' => 'Registration', 'HeadlineFormat' => t('HeadlineFormat.Registration', '{ActivityUserID,You} joined.'), 'Story' => t('Welcome Aboard!')], false, ['GroupBy' => 'ActivityTypeID']);
}
}
return $UserID;
}