本文整理汇总了PHP中Gdn_Validation::results方法的典型用法代码示例。如果您正苦于以下问题:PHP Gdn_Validation::results方法的具体用法?PHP Gdn_Validation::results怎么用?PHP Gdn_Validation::results使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Gdn_Validation
的用法示例。
在下文中一共展示了Gdn_Validation::results方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: delete
/**
* Remove a role.
*
* @since 2.0.0
* @access public
*/
public function delete($RoleID = false)
{
if (!$this->_permission($RoleID)) {
return;
}
$this->title(t('Delete Role'));
$this->addSideMenu('dashboard/role');
$Role = $this->RoleModel->getByRoleID($RoleID);
if ($Role->Deletable == '0') {
$this->Form->addError('You cannot delete this role.');
}
// Make sure the form knows which item we are deleting.
$this->Form->addHidden('RoleID', $RoleID);
// Figure out how many users will be affected by this deletion
$this->AffectedUsers = $this->RoleModel->getUserCount($RoleID);
// Figure out how many users will be orphaned by this deletion
$this->OrphanedUsers = $this->RoleModel->getUserCount($RoleID, true);
// Get a list of roles other than this one that can act as a replacement
$this->ReplacementRoles = $this->RoleModel->getByNotRoleID($RoleID);
if ($this->Form->authenticatedPostBack()) {
// Make sure that a replacement role has been selected if there were going to be orphaned users
if ($this->OrphanedUsers > 0) {
$Validation = new Gdn_Validation();
$Validation->applyRule('ReplacementRoleID', 'Required', 'You must choose a replacement role for orphaned users.');
$Validation->validate($this->Form->formValues());
$this->Form->setValidationResults($Validation->results());
}
if ($this->Form->errorCount() == 0) {
// Go ahead and delete the Role
$this->RoleModel->deleteAndReplace($RoleID, $this->Form->getValue('ReplacementRoleID'));
$this->RedirectUrl = url('dashboard/role');
$this->informMessage(t('Deleting role...'));
}
}
$this->render();
}
示例2: index
/**
* Main import page.
*
* @since 2.0.0
* @access public
*/
public function index()
{
$this->permission('Garden.Import');
// This permission doesn't exist, so only users with Admin == '1' will succeed.
$Timer = new Gdn_Timer();
// Determine the current step.
$this->Form = new Gdn_Form();
$Imp = new ImportModel();
$Imp->loadState();
// Search for the list of acceptable imports.
$ImportPaths = array();
$ExistingPaths = SafeGlob(PATH_UPLOADS . '/export*', array('gz', 'txt'));
$ExistingPaths2 = SafeGlob(PATH_UPLOADS . '/porter/export*', array('gz'));
$ExistingPaths = array_merge($ExistingPaths, $ExistingPaths2);
foreach ($ExistingPaths as $Path) {
$ImportPaths[$Path] = basename($Path);
}
// Add the database as a path.
$ImportPaths = array_merge(array('db:' => t('This Database')), $ImportPaths);
if ($Imp->CurrentStep < 1) {
// Check to see if there is a file.
$ImportPath = c('Garden.Import.ImportPath');
$Validation = new Gdn_Validation();
if (strcasecmp(Gdn::request()->requestMethod(), 'post') == 0) {
$Upload = new Gdn_Upload();
$Validation = new Gdn_Validation();
if (count($ImportPaths) > 0) {
$Validation->applyRule('PathSelect', 'Required', t('You must select a file to import.'));
}
if (count($ImportPaths) == 0 || $this->Form->getFormValue('PathSelect') == 'NEW') {
$TmpFile = $Upload->ValidateUpload('ImportFile', false);
} else {
$TmpFile = '';
}
if ($TmpFile) {
$Filename = $_FILES['ImportFile']['name'];
$Extension = pathinfo($Filename, PATHINFO_EXTENSION);
$TargetFolder = PATH_ROOT . DS . 'uploads' . DS . 'import';
if (!file_exists($TargetFolder)) {
mkdir($TargetFolder, 0777, true);
}
$ImportPath = $Upload->GenerateTargetName(PATH_ROOT . DS . 'uploads' . DS . 'import', $Extension);
$Upload->SaveAs($TmpFile, $ImportPath);
$Imp->ImportPath = $ImportPath;
$this->Form->setFormValue('PathSelect', $ImportPath);
$UploadedFiles = val('UploadedFiles', $Imp->Data);
$UploadedFiles[$ImportPath] = basename($Filename);
$Imp->Data['UploadedFiles'] = $UploadedFiles;
} elseif ($PathSelect = $this->Form->getFormValue('PathSelect')) {
if ($PathSelect == 'NEW') {
$Validation->addValidationResult('ImportFile', 'ValidateRequired');
} else {
$Imp->ImportPath = $PathSelect;
}
} elseif (!$Imp->ImportPath && count($ImportPaths) == 0) {
// There was no file uploaded this request or before.
$Validation->addValidationResult('ImportFile', $Upload->Exception);
}
// Validate the overwrite.
if (true || strcasecmp($this->Form->getFormValue('Overwrite'), 'Overwrite') == 0) {
if (!stringBeginsWith($this->Form->getFormValue('PathSelect'), 'Db:', true)) {
$Validation->applyRule('Email', 'Required');
}
}
if ($Validation->validate($this->Form->formValues())) {
$this->Form->setFormValue('Overwrite', 'overwrite');
$Imp->fromPost($this->Form->formValues());
$this->View = 'Info';
} else {
$this->Form->setValidationResults($Validation->results());
}
} else {
$this->Form->setFormValue('PathSelect', $Imp->ImportPath);
}
$Imp->saveState();
} else {
$this->setData('Steps', $Imp->steps());
$this->View = 'Info';
}
if (!stringBeginsWith($Imp->ImportPath, 'db:') && !file_exists($Imp->ImportPath)) {
$Imp->deleteState();
}
try {
$UploadedFiles = val('UploadedFiles', $Imp->Data, array());
$ImportPaths = array_merge($ImportPaths, $UploadedFiles);
$this->setData('ImportPaths', $ImportPaths);
$this->setData('Header', $Imp->getImportHeader());
$this->setData('Stats', val('Stats', $Imp->Data, array()));
$this->setData('GenerateSQL', val('GenerateSQL', $Imp->Data));
$this->setData('ImportPath', $Imp->ImportPath);
$this->setData('OriginalFilename', val('OriginalFilename', $Imp->Data));
$this->setData('CurrentStep', $Imp->CurrentStep);
$this->setData('LoadSpeedWarning', $Imp->loadTableType(false) == 'LoadTableWithInsert');
} catch (Gdn_UserException $Ex) {
//.........这里部分代码省略.........
示例3: merge
/**
*
*
* @throws Exception
* @throws Gdn_UserException
*/
public function merge()
{
$this->permission('Garden.Settings.Manage');
// This must be a postback.
if (!$this->Request->isAuthenticatedPostBack()) {
throw forbiddenException('GET');
}
$Validation = new Gdn_Validation();
$Validation->applyRule('OldUserID', 'ValidateRequired');
$Validation->applyRule('NewUserID', 'ValidateRequired');
if ($Validation->validate($this->Request->Post())) {
$Result = Gdn::userModel()->merge($this->Request->post('OldUserID'), $this->Request->post('NewUserID'));
$this->setData($Result);
} else {
$this->Form->setValidationResults($Validation->results());
}
$this->render('Blank', 'Utility');
}