本文整理汇总了PHP中Flash::noErrors方法的典型用法代码示例。如果您正苦于以下问题:PHP Flash::noErrors方法的具体用法?PHP Flash::noErrors怎么用?PHP Flash::noErrors使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Flash
的用法示例。
在下文中一共展示了Flash::noErrors方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: saveData
public function saveData($aLinkData)
{
if ($this->iLinkId === null) {
$oLink = new Link();
} else {
$oLink = LinkQuery::create()->findPk($this->iLinkId);
}
$oLink->setUrl(LinkUtil::getUrlWithProtocolIfNotSet($aLinkData['url']));
$oLink->setName($aLinkData['name']);
$oLink->setLinkCategoryId($aLinkData['link_category_id'] == null ? null : $aLinkData['link_category_id']);
$oLink->setDescription($aLinkData['description']);
if (isset($aLinkData['language_id'])) {
$oLink->setLanguageId($aLinkData['language_id'] != null ? $aLinkData['language_id'] : null);
}
$this->validate($aLinkData);
if (!Flash::noErrors()) {
throw new ValidationException();
}
if ($oLink->getLinkCategoryId() != null) {
if ($oLink->isNew() || $oLink->isColumnModified(LinkPeer::LINK_CATEGORY_ID)) {
$oLink->setSort(LinkQuery::create()->filterByLinkCategoryId($oLink->getLinkCategoryId())->count() + 1);
}
}
$oLink->save();
return $oLink->getId();
}
示例2: saveData
public function saveData($aDocumentationData)
{
if ($this->iDocumentationId === null) {
$oDocumentation = new Documentation();
} else {
$oDocumentation = DocumentationQuery::create()->findPk($this->iDocumentationId);
}
$oRichtextUtil = new RichtextUtil();
$oRichtextUtil->setTrackReferences($oDocumentation);
$oDocumentation->setDescription($oRichtextUtil->parseInputFromEditor($aDocumentationData['description']));
$oDocumentation->setName($aDocumentationData['name']);
$oDocumentation->setTitle($aDocumentationData['title']);
$oDocumentation->setKey($aDocumentationData['key']);
if (isset($aDocumentationData['name_space'])) {
$oDocumentation->setNameSpace($aDocumentationData['name_space']);
}
$oDocumentation->setVersion($aDocumentationData['version']);
$oDocumentation->setTitle($aDocumentationData['title']);
$oDocumentation->setIsPublished($aDocumentationData['is_published']);
$oDocumentation->setYoutubeUrl($aDocumentationData['youtube_url']);
if ($oDocumentation->getYoutubeUrl() == null) {
$oDocumentation->setYoutubeUrl(null);
}
$this->validate($aDocumentationData, $oDocumentation);
if (!Flash::noErrors()) {
throw new ValidationException();
}
return $oDocumentation->save();
}
示例3: saveData
public function saveData($aTagData)
{
$aTagData['name'] = StringUtil::normalize($aTagData['name']);
if ($this->iTagId === null) {
$oTag = new Tag();
} else {
$oTag = TagQuery::create()->findPk($this->iTagId);
}
$this->validate($aTagData);
if (!Flash::noErrors()) {
throw new ValidationException();
}
$sStringName = "tag.{$aTagData['name']}";
if ($oTag->getName() !== $aTagData['name']) {
//Rename Strings for the tag
$sOldStringName = "tag.{$oTag->getName()}";
foreach (TranslationQuery::create()->filterByStringKey($sOldStringName)->find() as $oString) {
$sLanguageId = $oString->getLanguageId();
//You can’t technically rename strings because string_key is the PKEY so we delete it and re-generate
$oString->delete();
$oString = new Translation();
$oString->setStringKey($sStringName);
$oString->setLanguageId($sLanguageId);
$oString->save();
}
$oTag->setName($aTagData['name']);
}
foreach ($aTagData['edited_languages'] as $iIndex => $sLanguageId) {
TranslationPeer::addOrUpdateString($sStringName, $aTagData['text'][$iIndex], $sLanguageId);
}
$oTag->save();
}
示例4: saveData
public function saveData($aSubscriberData)
{
$oSubscriber = SubscriberQuery::create()->findPk($this->iSubscriberId);
if ($oSubscriber === null) {
$oSubscriber = new Subscriber();
$oSubscriber->setCreatedBy(Session::getSession()->getUserId());
$oSubscriber->setCreatedAt(date('c'));
}
$oSubscriber->setPreferredLanguageId($aSubscriberData['preferred_language_id']);
$oSubscriber->setName($aSubscriberData['name']);
$oSubscriber->setEmail($aSubscriberData['email']);
$this->validate($aSubscriberData, $oSubscriber);
if (!Flash::noErrors()) {
throw new ValidationException();
}
// Subscriptions
foreach ($oSubscriber->getSubscriberGroupMemberships() as $oSubscriberGroupMembership) {
$oSubscriberGroupMembership->delete();
}
$aSubscriptions = isset($aSubscriberData['subscriber_group_ids']) ? $aSubscriberData['subscriber_group_ids'] : array();
foreach ($aSubscriptions as $iSubscriberGroupId) {
$oSubscriberGroupMembership = new SubscriberGroupMembership();
$oSubscriberGroupMembership->setSubscriberGroupId($iSubscriberGroupId);
$oSubscriber->addSubscriberGroupMembership($oSubscriberGroupMembership);
}
return $oSubscriber->save();
}
示例5: saveData
public function saveData($aSubscriberGroupData)
{
if ($this->iSubscriberGroupId) {
$oSubscriberGroup = SubscriberGroupQuery::create()->findPk($this->iSubscriberGroupId);
} else {
$oSubscriberGroup = new SubscriberGroup();
$oSubscriberGroup->setCreatedBy(Session::getSession()->getUserId());
$oSubscriberGroup->setCreatedAt(date('c'));
}
$oSubscriberGroup->setName($aSubscriberGroupData['name']);
$oSubscriberGroup->setDisplayName($aSubscriberGroupData['display_name'] == null ? null : $aSubscriberGroupData['display_name']);
$this->validate($aSubscriberGroupData);
if (!Flash::noErrors()) {
throw new ValidationException();
}
$oSubscriberGroup->save();
$oResult = new stdClass();
$oResult->id = $oSubscriberGroup->getId();
if ($this->iSubscriberGroupId === null) {
$oResult->inserted = true;
} else {
$oResult->updated = true;
}
$this->iSubscriberGroupId = $oResult->id;
return $oResult;
}
示例6: saveData
public function saveData($aRoleData)
{
$oRole = null;
if ($this->sRoleId === null) {
$oRole = new Role();
} else {
$oRole = RoleQuery::create()->findPk($this->sRoleId);
// If the role_key has changed and the new key does not exist yet, delete the current role and create a new one
if ($oRole->getRoleKey() !== $aRoleData['role_key']) {
if (RoleQuery::create()->filterByRoleKey($aRoleData['role_key'])->count() === 0) {
$oRole->delete();
$oRole = new Role();
}
}
}
$this->validate($aRoleData, $oRole);
if (!Flash::noErrors()) {
throw new ValidationException();
}
$oRole->setRoleKey($aRoleData['role_key']);
$oRole->setDescription($aRoleData['description']);
if (isset($aRoleData['page_id'])) {
if (!$oRole->isNew()) {
RightQuery::create()->filterByRole($oRole)->delete();
}
$aRights = array();
foreach ($aRoleData['page_id'] as $iCounter => $sPageId) {
$sRightKey = $sPageId . ($aRoleData['is_inherited'][$iCounter] ? "_inherited" : "_uninherited");
if (isset($aRights[$sRightKey])) {
$oRight = $aRights[$sRightKey];
$oRight->setMayEditPageContents($oRight->getMayEditPageContents() || $aRoleData['may_edit_page_contents'][$iCounter]);
$oRight->setMayEditPageDetails($oRight->getMayEditPageDetails() || $aRoleData['may_edit_page_details'][$iCounter]);
$oRight->setMayDelete($oRight->getMayDelete() || $aRoleData['may_delete'][$iCounter]);
$oRight->setMayCreateChildren($oRight->getMayCreateChildren() || $aRoleData['may_create_children'][$iCounter]);
$oRight->setMayViewPage($oRight->getMayViewPage() || $aRoleData['may_view_page'][$iCounter]);
} else {
$oRight = new Right();
$oRight->setPageId($sPageId);
$oRight->setRole($oRole);
$oRight->setIsInherited($aRoleData['is_inherited'][$iCounter]);
$oRight->setMayEditPageContents($aRoleData['may_edit_page_contents'][$iCounter]);
$oRight->setMayEditPageDetails($aRoleData['may_edit_page_details'][$iCounter]);
$oRight->setMayDelete($aRoleData['may_delete'][$iCounter]);
$oRight->setMayCreateChildren($aRoleData['may_create_children'][$iCounter]);
$oRight->setMayViewPage($aRoleData['may_view_page'][$iCounter]);
$aRights[$sRightKey] = $oRight;
}
}
foreach ($aRights as $oRight) {
$oRight->save();
}
}
$oRole->save();
return array('id' => $oRole->getRoleKey());
}
示例7: uploadFile
public function uploadFile($sFileKey = 'file', $aOptions = null, $bCreateType = false)
{
$oFlash = Flash::getFlash();
$oFlash->checkForFileUpload($sFileKey);
$oFlash->finishReporting();
if (!Flash::noErrors()) {
throw new ValidationException();
}
$aFileInfo = $_FILES[$sFileKey];
if ($aOptions['document_id']) {
$oDocument = DocumentQuery::create()->findPk($aOptions['document_id']);
} else {
$oDocument = new Document();
}
if ($oDocument === null) {
throw new LocalizedException("wns.file_upload.document_not_found");
}
$sFileName = $aOptions['name'];
$aName = explode('.', $sFileName);
if (count($aName) > 1) {
array_pop($aName);
}
$sFileName = implode('.', $aName);
$iDocumentTypeId = null;
try {
$iDocumentTypeId = $this->accepts($aOptions['name'], $aOptions['type']);
} catch (Exception $e) {
if ($bCreateType) {
$aName = explode('.', $aOptions['name']);
$sExtension = null;
if (count($aName) > 1) {
$sExtension = array_pop($aName);
}
$aMimeType = explode('/', $aOptions['type']);
if ($sExtension === null) {
$sExtension = $aMimeType[1];
}
if ($sExtension === null) {
throw new LocalizedException("wns.file_upload.unknown_document_type");
}
$oDocumentType = new DocumentType();
$oDocumentType->setExtension($sExtension);
$oDocumentType->setMimetype(implode('/', $aMimeType));
$oDocumentType->save();
$iDocumentTypeId = $oDocumentType->getId();
} else {
throw $e;
}
}
$oDocument->setData(fopen($aFileInfo['tmp_name'], "r"));
$this->updateDocument($oDocument, $aOptions, $sFileName, $iDocumentTypeId);
$oDocument->save();
return $oDocument->getId();
}
示例8: saveData
public function saveData($aDocumentTypeData)
{
if ($this->iTypeId === null) {
$oType = new DocumentType();
} else {
$oType = DocumentTypeQuery::create()->findPk($this->iTypeId);
}
$this->validate($aDocumentTypeData, $oType);
if (!Flash::noErrors()) {
throw new ValidationException();
}
$oType->setExtension($aDocumentTypeData['extension']);
$oType->setMimetype($aDocumentTypeData['mimetype']);
return $oType->save();
}
示例9: saveData
public function saveData($aLanguageData)
{
// string key is changed if a existing Language string_key is changed
if ($aLanguageData['language_id'] !== $this->sLanguageId) {
$this->sLanguageId = $aLanguageData['language_id'];
}
$oLanguage = LanguageQuery::create()->findPk($this->sLanguageId);
if ($oLanguage === null) {
$oLanguage = new Language();
$oLanguage->setId($aLanguageData['language_id']);
}
$this->validate($aLanguageData, $oLanguage);
if (!Flash::noErrors()) {
throw new ValidationException();
}
$oLanguage->setIsActive($aLanguageData['is_active']);
$oLanguage->setPathPrefix($aLanguageData['path_prefix']);
return $oLanguage->save();
}
示例10: saveData
public function saveData($aJournalData)
{
if ($this->iJournalId === null) {
$oJournal = new Journal();
} else {
$oJournal = JournalQuery::create()->findPk($this->iJournalId);
}
$this->validate($aJournalData);
$oJournal->setName($aJournalData['name']);
$oJournal->setDescription($aJournalData['description']);
$oJournal->setUseCaptcha($aJournalData['use_captcha']);
$sCommentMode = $aJournalData['comment_mode'];
$oJournal->setEnableComments($sCommentMode === 'on' || $sCommentMode === 'notified');
$oJournal->setNotifyComments($sCommentMode === 'moderated' || $sCommentMode === 'notified');
if (!Flash::noErrors()) {
throw new ValidationException();
}
$oJournal->save();
return $oJournal->getId();
}
示例11: saveData
public function saveData($aDocumentationPartData)
{
if ($this->iDocumentationPartId === null) {
$oDocumentationPart = new DocumentationPart();
} else {
$oDocumentationPart = DocumentationPartQuery::create()->findPk($this->iDocumentationPartId);
}
$this->validate($aDocumentationPartData);
$oDocumentationPart->setName($aDocumentationPartData['name']);
$oDocumentationPart->setKey($aDocumentationPartData['key']);
$oDocumentationPart->setIsOverview($aDocumentationPartData['is_overview']);
$oDocumentationPart->setIsPublished($aDocumentationPartData['is_published']);
$oDocumentationPart->setDocumentationId($aDocumentationPartData['documentation_id']);
$oDocumentationPart->setLanguageId($oDocumentationPart->getDocumentation()->getLanguageId());
$oDocumentationPart->setImageId($aDocumentationPartData['image_id'] != null ? $aDocumentationPartData['image_id'] : null);
if ($oDocumentationPart->getTitle() == null) {
$oDocumentationPart->setTitle(null);
}
$oRichtextUtil = new RichtextUtil();
$oRichtextUtil->setTrackReferences($oDocumentationPart);
$oDocumentationPart->setBody($oRichtextUtil->parseInputFromEditor($aDocumentationPartData['body']));
if ($oDocumentationPart->isNew() && is_numeric($oDocumentationPart->getDocumentationId())) {
$oDocumentationPart->setSort(DocumentationPartQuery::create()->filterByDocumentationId($oDocumentationPart->getDocumentationId())->count() + 1);
}
if ($aDocumentationPartData['image_id'] == null && $oDocumentationPart->getDocument()) {
$oDocumentationPart->getDocument()->delete();
}
if (!Flash::noErrors()) {
// Don't validate on file upload but set is_published to false if there are errors
if ($aDocumentationPartData['documentation_id'] != null && $aDocumentationPartData['is_file_upload']) {
$oDocumentationPart->setIsPublished(false);
} else {
throw new ValidationException();
}
}
$oDocumentationPart->save();
return $oDocumentationPart->getId();
}
示例12: saveData
public function saveData($aLinkCategoryData)
{
if ($this->iLinkCategoryId === null) {
$oLinkCategory = new LinkCategory();
} else {
$oLinkCategory = LinkCategoryQuery::create()->findPk($this->iLinkCategoryId);
}
$this->validate($aLinkCategoryData);
if (!Flash::noErrors()) {
throw new ValidationException();
}
$oLinkCategory->setName($aLinkCategoryData['name']);
$oLinkCategory->setIsExternallyManaged($aLinkCategoryData['is_externally_managed']);
$oLinkCategory->save();
$oResult = new stdClass();
if ($this->iLinkCategoryId === null) {
$oResult->inserted = true;
} else {
$oResult->updated = true;
}
$oResult->id = $this->iLinkCategoryId = $oLinkCategory->getId();
return $oResult;
}
示例13: renderFile
public function renderFile()
{
$aCurrentValues = $this->oFormStorage->saveCurrentValuesToSession();
$oFlash = Flash::getFlash();
$oFlash->setArrayToCheck($aCurrentValues);
$bHasCaptcha = false;
foreach ($this->oFormStorage->getFormObjects() as $oFormObject) {
if ($oFormObject instanceof CaptchaObject) {
$bHasCaptcha = true;
}
if ($oFormObject->shouldExcludeFromReport()) {
continue;
}
if ($oFormObject->isRequired()) {
$oFlash->checkForValue($oFormObject->getName());
}
$oEmailItemTemplateInstance = clone $this->oEmailItemTemplate;
$oEmailItemTemplateInstance->replaceIdentifier('name', $oFormObject->getName());
$oEmailItemTemplateInstance->replaceIdentifier('label', $oFormObject->getLabel());
$oEmailItemTemplateInstance->replaceIdentifier('value', $oFormObject->getCurrentValue());
$this->oEmailTemplate->replaceIdentifierMultiple('form_content', $oEmailItemTemplateInstance);
}
if ($bHasCaptcha && !FormFrontendModule::validateRecaptchaInput()) {
$oFlash->addMessage('captcha_code_required');
}
$oFlash->finishReporting();
if (Flash::noErrors()) {
$oEmail = new EMail(TranslationPeer::getString('wns.form_module.email_subject', null, null, array('page' => $this->sPageName)), $this->oEmailTemplate);
$oEmail->addRecipient($this->sEmailAddress);
$oEmail->send();
$this->oFormStorage->deleteCurrentValuesFromSession();
LinkUtil::redirect($_REQUEST['origin'] . '?form_success=true');
} else {
$oFlash->stick();
LinkUtil::redirect($_REQUEST['origin']);
}
}
示例14: loginNewPassword
public static function loginNewPassword($sReferrer = '')
{
$oFlash = Flash::getFlash();
$oUser = UserQuery::create()->filterByUsername(trim($_REQUEST['recover_username']))->isActive()->findOne();
if ($oUser === null || md5($oUser->getPasswordRecoverHint()) !== $_REQUEST['recover_hint']) {
$oFlash->addMessage('login.recovery.invalid');
return 'login';
}
if ($_POST['new_password'] === '') {
$oFlash->addMessage('login.empty_fields');
}
PasswordHash::checkPasswordValidity($_POST['new_password'], $oFlash);
if ($_POST['new_password'] !== $_POST['new_password_retype']) {
$oFlash->addMessage('password_confirm');
}
$oFlash->finishReporting();
if (!Flash::noErrors()) {
return 'password_reset';
}
//No errors – set new password, login and redirect
UserPeer::ignoreRights(true);
$oUser->setPassword($_POST['new_password']);
$oUser->setPasswordRecoverHint(null);
$oUser->save();
self::login($_POST['recover_username'], $_POST['new_password'], $sReferrer);
return 'login';
}
示例15: saveData
public function saveData($aUserData)
{
if ($this->iUserId === null) {
$oUser = new User();
} else {
$oUser = UserQuery::create()->findPk($this->iUserId);
}
$this->validate($aUserData, $oUser);
if (!Flash::noErrors()) {
throw new ValidationException();
}
$oUser->setUsername($aUserData['username']);
$oUser->setFirstName($aUserData['first_name']);
$oUser->setLastName($aUserData['last_name']);
$oUser->setEmail($aUserData['email']);
$oUser->setLanguageId($aUserData['language_id']);
$oUser->setTimezone($aUserData['timezone']);
//Password
if ($aUserData['force_password_reset']) {
$oUser->forcePasswordReset();
} else {
if ($aUserData['password'] !== '') {
$oUser->setPassword($aUserData['password']);
$oUser->setPasswordRecoverHint(null);
}
}
//This also means the user’s an admin (or has the role “users”) because non-admins can only edit themselves
if (!$oUser->isSessionUser()) {
//Only admins may give or take admin rights, having the role “users” does not suffice
if (Session::user()->getIsAdmin()) {
$oUser->setIsAdmin($aUserData['is_admin']);
}
//Admin & inactive flags
$oUser->setIsBackendLoginEnabled($oUser->getIsAdmin() || $aUserData['is_admin_login_enabled'] || $aUserData['is_backend_login_enabled']);
$oUser->setIsAdminLoginEnabled($oUser->getIsAdmin() || $aUserData['is_admin_login_enabled']);
$oUser->setIsInactive($aUserData['is_inactive']);
//Groups
foreach ($oUser->getUserGroupsRelatedByUserId() as $oUserGroup) {
$oUserGroup->delete();
}
$aRequestedGroups = isset($aUserData['group_ids']) ? $aUserData['group_ids'] : array();
foreach ($aRequestedGroups as $iGroupId) {
if ($iGroupId === false) {
continue;
}
$oUserGroup = new UserGroup();
$oUserGroup->setGroupId($iGroupId);
$oUser->addUserGroupRelatedByUserId($oUserGroup);
}
//Roles
foreach ($oUser->getUserRolesRelatedByUserId() as $oUserRole) {
$oUserRole->delete();
}
$aRequestedRoles = isset($aUserData['role_keys']) ? !is_array($aUserData['role_keys']) ? array($aUserData['role_keys']) : $aUserData['role_keys'] : array();
foreach ($aRequestedRoles as $sRoleKey) {
if ($sRoleKey === false) {
continue;
}
$oUserRole = new UserRole();
$oUserRole->setRoleKey($sRoleKey);
$oUser->addUserRoleRelatedByUserId($oUserRole);
}
} else {
//Set the new session language for the currently logged-in user
Session::getSession()->setLanguage($oUser->getLanguageId());
}
return $oUser->save();
}