当前位置: 首页>>代码示例>>PHP>>正文


PHP Gdn_Validation::Results方法代码示例

本文整理汇总了PHP中Gdn_Validation::Results方法的典型用法代码示例。如果您正苦于以下问题:PHP Gdn_Validation::Results方法的具体用法?PHP Gdn_Validation::Results怎么用?PHP Gdn_Validation::Results使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Gdn_Validation的用法示例。


在下文中一共展示了Gdn_Validation::Results方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: Delete

 public function Delete($RoleID = FALSE)
 {
     $this->Title(Translate('Delete Role'));
     $this->Permission('Garden.Roles.Manage');
     $this->AddSideMenu('garden/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->Delete($RoleID, $this->Form->GetValue('ReplacementRoleID'));
             $this->RedirectUrl = Url('garden/role');
             $this->StatusMessage = Gdn::Translate('Deleting role...');
         }
     }
     $this->Render();
 }
开发者ID:Aetasiric,项目名称:Garden,代码行数:34,代码来源:role.php

示例2: Validate

 public function Validate($Criteria, $Form)
 {
     $Validation = new Gdn_Validation();
     $Validation->ApplyRules(array(array('Name' => 'Target', 'Validation' => array('Required', 'Integer')), array('Name' => 'Duration', 'Validation' => array('Required', 'Integer')), array('Name' => 'Period', 'Validation' => 'Required')));
     $Validation->Validate($Criteria);
     $Form->SetValidationResults($Validation->Results());
 }
开发者ID:hxii,项目名称:Application-Yaga,代码行数:7,代码来源:class.commentmarathon.php

示例3: Validate

 public function Validate($Criteria, $Form)
 {
     $Validation = new Gdn_Validation();
     $Validation->ApplyRules(array(array('Name' => 'SocialNetwork', 'Validation' => array('Required'))));
     $Validation->Validate($Criteria);
     $Form->SetValidationResults($Validation->Results());
 }
开发者ID:hxii,项目名称:Application-Yaga,代码行数:7,代码来源:class.socialconnection.php

示例4: Validate

 public function Validate($Criteria, $Form)
 {
     $Validation = new Gdn_Validation();
     foreach ($Criteria as $ActionID => $Target) {
         $Validation->ApplyRule($ActionID, 'Integer');
     }
     $Validation->Validate($Criteria);
     $Form->SetValidationResults($Validation->Results());
 }
开发者ID:hxii,项目名称:Application-Yaga,代码行数:9,代码来源:class.postreactions.php

示例5: Create

 protected function Create($Sender)
 {
     $Sender->Permission('Garden.Email.Manage');
     $Sender->CanGiveJobToCron = C('EnabledPlugins.PluginUtils') !== False;
     $Validation = new Gdn_Validation();
     $Validation->ApplyRule('RecipientEmailList', array('Required', 'ValidateEmail'));
     $Validation->ApplyRule('Subject', 'Required');
     $Validation->ApplyRule('Body', 'Required');
     $Sender->DrawConfirmSend = False;
     if ($Sender->Form->AuthenticatedPostBack() != False) {
         $FormValues = $Sender->Form->FormValues();
         $ValidationResult = $Validation->Validate($FormValues);
         $Sender->Form->SetValidationResults($Validation->Results());
         if ($ValidationResult) {
             $Emails = $this->GetUserEmails($FormValues);
             $Sender->CountEmails = count($Emails);
             if ($Sender->CountEmails == 0) {
                 $Sender->Form->AddError('No one to send');
             }
         }
         if ($Sender->Form->ErrorCount() == 0) {
             $Sender->DrawConfirmSend = True;
             if (ArrayValue('ConfirmSend', $FormValues)) {
                 $Sent = $this->Send($Emails, $FormValues);
                 if ($Sent != False) {
                     $Sender->StatusMessage = T('Your message was successfully sent.');
                 }
             }
         }
     } else {
         $SupportAddress = C('Garden.Email.SupportAddress');
         if (!$SupportAddress) {
             $SupportAddress = 'noreply@' . Gdn::Request()->Host();
         }
         $Sender->Form->SetValue('RecipientEmailList', $SupportAddress);
     }
     $Sender->View = $this->GetView('create.php');
     $RoleModel = Gdn::Factory('RoleModel');
     $Sender->RoleData = $RoleModel->Get();
     $Sender->Render();
 }
开发者ID:unlight,项目名称:MassDelivery,代码行数:41,代码来源:massdelivery.plugin.php

示例6: ValidationResults

 /**
  * Returns the $this->Validation->ValidationResults() array.
  *
  * @return unknown
  * @todo add return type
  */
 public function ValidationResults()
 {
     return $this->Validation->Results();
 }
开发者ID:seedbank,项目名称:old-repo,代码行数:10,代码来源:class.model.php

示例7: 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_ROOT . '/uploads/export*', array('gz', 'txt'));
     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 = GetValue('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 (!$this->Form->GetFormValue('UseCurrentPassword')) {
                         $Validation->ApplyRule('Password', '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 = GetValue('UploadedFiles', $Imp->Data, array());
         $ImportPaths = array_merge($ImportPaths, $UploadedFiles);
         $this->SetData('ImportPaths', $ImportPaths);
         $this->SetData('Header', $Imp->GetImportHeader());
         $this->SetData('Stats', GetValue('Stats', $Imp->Data, array()));
         $this->SetData('GenerateSQL', GetValue('GenerateSQL', $Imp->Data));
         $this->SetData('ImportPath', $Imp->ImportPath);
         $this->SetData('OriginalFilename', GetValue('OriginalFilename', $Imp->Data));
         $this->SetData('CurrentStep', $Imp->CurrentStep);
         $this->SetData('LoadSpeedWarning', $Imp->LoadTableType(FALSE) == 'LoadTableWithInsert');
//.........这里部分代码省略.........
开发者ID:seedbank,项目名称:old-repo,代码行数:101,代码来源:class.importcontroller.php

示例8: Index

 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();
     if ($Imp->CurrentStep < 1) {
         // Check to see if there is a file.
         $ImportPath = Gdn::Config('Garden.Import.ImportPath');
         $Validation = new Gdn_Validation();
         if (strcasecmp(Gdn::Request()->RequestMethod(), 'post') == 0) {
             $Upload = new Gdn_Upload();
             $Validation = new Gdn_Validation();
             $TmpFile = $Upload->ValidateUpload('ImportFile', FALSE);
             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;
                 $Imp->Data['OriginalFilename'] = basename($Filename);
             } elseif (!$Imp->ImportPath) {
                 // There was no file uploaded this request or before.
                 $Validation->AddValidationResult('ImportFile', $Upload->Exception);
             }
             // Validate the overwrite.
             if (strcasecmp($this->Form->GetFormValue('Overwrite'), 'Overwrite') == 0) {
                 $Validation->ApplyRule('Email', 'Required');
                 $Validation->ApplyRule('Password', 'Required');
             }
             if ($Validation->Validate($this->Form->FormValues())) {
                 $Imp->Overwrite($this->Form->GetFormValue('Overwrite', 'Overwrite'), $this->Form->GetFormValue('Email'), $this->Form->GetFormValue('Password'));
                 $this->View = 'Info';
             } else {
                 $this->Form->SetValidationResults($Validation->Results());
             }
         } else {
             // Search for an existing file that was uploaded by the web admin.
             $ImportPaths = SafeGlob(PATH_ROOT . DS . 'uploads' . DS . 'import' . DS . 'import.*');
             if ($ImportPaths) {
                 $ImportPath = $ImportPaths[0];
                 if (in_array(pathinfo($ImportPath, PATHINFO_EXTENSION), array('gz', 'txt'))) {
                     $Imp->ImportPath = $ImportPath;
                     $Imp->Data['OriginalFilename'] = basename($ImportPath);
                 }
             }
         }
         $Imp->SaveState();
     } else {
         $this->View = 'Info';
     }
     $this->SetData('Header', $Imp->GetImportHeader());
     $this->SetData('ImportPath', $Imp->ImportPath);
     $this->SetData('OriginalFilename', GetValue('OriginalFilename', $Imp->Data));
     $this->Render();
 }
开发者ID:sheldon,项目名称:Garden,代码行数:63,代码来源:class.importcontroller.php

示例9: Award

 /**
  * You can manually award badges to users for special cases
  *
  * @param int $UserID
  * @throws Gdn_UserException
  */
 public function Award($UserID)
 {
     // Check permission
     $this->Permission('Yaga.Badges.Add');
     $this->AddSideMenu('badge/settings');
     // Only allow awarding if some badges exist
     if (!$this->BadgeModel->GetCount()) {
         throw new Gdn_UserException(T('Yaga.Error.NoBadges'));
     }
     $UserModel = Gdn::UserModel();
     $User = $UserModel->GetID($UserID);
     $this->SetData('Username', $User->Name);
     $Badges = $this->BadgeModel->Get();
     $Badgelist = array();
     foreach ($Badges as $Badge) {
         $Badgelist[$Badge->BadgeID] = $Badge->Name;
     }
     $this->SetData('Badges', $Badgelist);
     if ($this->Form->IsPostBack() == FALSE) {
         // Add the user id field
         $this->Form->AddHidden('UserID', $User->UserID);
     } else {
         $Validation = new Gdn_Validation();
         $Validation->ApplyRule('UserID', 'ValidateRequired');
         $Validation->ApplyRule('BadgeID', 'ValidateRequired');
         if ($Validation->Validate($this->Request->Post())) {
             $FormValues = $this->Form->FormValues();
             if ($this->BadgeAwardModel->Exists($FormValues['UserID'], $FormValues['BadgeID'])) {
                 $this->Form->AddError(sprintf(T('Yaga.Badge.AlreadyAwarded'), $User->Name), 'BadgeID');
                 // Need to respecify the user id
                 $this->Form->AddHidden('UserID', $User->UserID);
             }
             if ($this->Form->ErrorCount() == 0) {
                 $this->BadgeAwardModel->Award($FormValues['BadgeID'], $FormValues['UserID'], Gdn::Session()->UserID, $FormValues['Reason']);
                 if ($this->Request->Get('Target')) {
                     $this->RedirectUrl = $this->Request->Get('Target');
                 } elseif ($this->DeliveryType() == DELIVERY_TYPE_ALL) {
                     $this->RedirectUrl = Url(UserUrl($User));
                 } else {
                     $this->JsonTarget('', '', 'Refresh');
                 }
             }
         } else {
             $this->Form->SetValidationResults($Validation->Results());
         }
     }
     $this->Render();
 }
开发者ID:hxii,项目名称:Application-Yaga,代码行数:54,代码来源:class.badgecontroller.php

示例10: Merge

 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');
 }
开发者ID:3marproof,项目名称:vanilla,代码行数:18,代码来源:class.usercontroller.php

示例11: ProfileController_MyProfileEdit_Create

 public function ProfileController_MyProfileEdit_Create($Sender, $Args)
 {
     $sfYaml = Gdn::Factory('sfYaml');
     $Sender->UserID = ArrayValue(0, $Args, '');
     $Sender->UserName = ArrayValue(1, $Args, '');
     $Sender->GetUserInfo($Sender->UserID, $Sender->UserName);
     $SessionUserID = Gdn::Session()->UserID;
     if ($Sender->User->UserID != $SessionUserID) {
         $Sender->Permission('Garden.Users.Edit');
         $MyMetaUserID = $Sender->User->UserID;
     } else {
         $MyMetaUserID = $SessionUserID = Gdn::Session()->UserID;
     }
     if (file_exists(dirname(__FILE__) . DS . 'mymeta.yml')) {
         $Meta = $sfYaml->load(dirname(__FILE__) . DS . 'mymeta.yml');
         $Sender->SetData('Example', false);
     } else {
         if (file_exists(dirname(__FILE__) . DS . 'mymeta.yml.example')) {
             $Meta = $sfYaml->load(dirname(__FILE__) . DS . 'mymeta.yml.example');
             $Sender->SetData('Example', true);
         }
     }
     $Sender->Form = new Gdn_Form();
     $ValidationFailed = false;
     if ($Sender->Form->AuthenticatedPostBack() === FALSE) {
         $Sender->Form->SetData($Sender->MyProfile);
     } else {
         $Data = $Sender->Form->FormValues();
         $Validation = new Gdn_Validation();
         foreach ($Data as $DataI => $DataV) {
             $Field = $Meta['MyMeta'][$DataI];
             if (GetValue('required', $Field)) {
                 $Validation->ApplyRule($DataI, 'Required', sprintf(T('%s is required'), $Field['name']));
             }
             foreach (GetValue('requiredwith', $Field) as $RequiredWith) {
                 if (!GetValue($RequiredWith, $Datarequired)) {
                     $Validation->ApplyRule($RequiredWith, 'Required', sprintf(T('%s is required with %s'), $Meta['MyMeta'][$RequiredWith]['name'], $Field['name']));
                 }
             }
             if (empty($DataV)) {
                 continue;
             }
             if ($V = GetValue('validate', $Field)) {
                 if (strpos($V, 'Validate') === 0) {
                     //Begins with
                     $V = substr($V, 8);
                     if (function_exists($V)) {
                         $Validation->AddRule($V, 'function:' . $V);
                     } else {
                         if (function_exists($V)) {
                             $Validation->AddRule($V, 'function:Validate' . $V);
                         }
                     }
                 }
                 $Validation->ApplyRule($DataI, $V, sprintf(T('%s not valid'), $Field['name']));
             }
             if ($R = GetValue('validateregex', $Field)) {
                 $Validation->AddRule($DataI, 'regex:`^' . $R . '$`i');
                 $Validation->ApplyRule($DataI, $DataI, sprintf(T('%s not valid'), $Field['name']));
             }
             if ($M = GetValue('maxchar', $Field)) {
                 $Validation->AddRule('MaxLen' . $DataI, 'regex:`^.{0,' . $M . '}$`is');
                 $Validation->ApplyRule($DataI, 'MaxLen' . $DataI, sprintf(T('%s not cannot be longer than %s chars'), $Field['name'], $M));
             }
         }
         $Validation->Validate($Data);
         if (count($Validation->Results()) == 0) {
             $MyMeta = array_intersect_key($Data, $Meta['MyMeta']);
             UserModel::SetMeta($MyMetaUserID, $MyMeta, 'MyMeta.');
         } else {
             $ValidationFailed = true;
         }
         $Sender->Form->SetValidationResults($Validation->Results());
     }
     if (!$ValidationFailed) {
         $Data = UserModel::GetMeta($MyMetaUserID, 'MyMeta.%', 'MyMeta.');
     }
     $MyMeta = array_intersect_key($Data, $Meta['MyMeta']);
     $Sender->SetData('Fields', $Meta['MyMeta']);
     $Sender->SetData('MyMeta', $MyMeta);
     $Sender->View = dirname(__FILE__) . DS . 'views' . DS . 'edit.php';
     $Sender->Render();
 }
开发者ID:seedbank,项目名称:old-repo,代码行数:83,代码来源:default.php

示例12: Promote

 /**
  * You can manually award ranks to users for special cases
  *
  * @param int $UserID
  * @throws Gdn_UserException
  */
 public function Promote($UserID)
 {
     // Check permission
     $this->Permission('Yaga.Ranks.Add');
     $this->AddSideMenu('rank/settings');
     // Only allow awarding if some ranks exist
     if (!$this->RankModel->GetCount()) {
         throw new Gdn_UserException(T('Yaga.Error.NoRanks'));
     }
     $UserModel = Gdn::UserModel();
     $User = $UserModel->GetID($UserID);
     $this->SetData('Username', $User->Name);
     $Ranks = $this->RankModel->Get();
     $Ranklist = array();
     foreach ($Ranks as $Rank) {
         $Ranklist[$Rank->RankID] = $Rank->Name;
     }
     $this->SetData('Ranks', $Ranklist);
     if ($this->Form->IsPostBack() == FALSE) {
         // Add the user id field
         $this->Form->AddHidden('UserID', $User->UserID);
     } else {
         $Validation = new Gdn_Validation();
         $Validation->ApplyRule('UserID', 'ValidateRequired');
         $Validation->ApplyRule('RankID', 'ValidateRequired');
         if ($Validation->Validate($this->Request->Post())) {
             $FormValues = $this->Form->FormValues();
             if ($this->Form->ErrorCount() == 0) {
                 $this->RankModel->Set($FormValues['RankID'], $FormValues['UserID'], $FormValues['RecordActivity']);
                 $UserModel->SetField($UserID, 'RankProgression', $FormValues['RankProgression']);
                 if ($this->Request->Get('Target')) {
                     $this->RedirectUrl = $this->Request->Get('Target');
                 } elseif ($this->DeliveryType() == DELIVERY_TYPE_ALL) {
                     $this->RedirectUrl = Url(UserUrl($User));
                 } else {
                     $this->JsonTarget('', '', 'Refresh');
                 }
             }
         } else {
             $this->Form->SetValidationResults($Validation->Results());
         }
     }
     $this->Render();
 }
开发者ID:hxii,项目名称:Application-Yaga,代码行数:50,代码来源:class.rankcontroller.php


注:本文中的Gdn_Validation::Results方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。