本文整理汇总了PHP中Security::PermissionFailure方法的典型用法代码示例。如果您正苦于以下问题:PHP Security::PermissionFailure方法的具体用法?PHP Security::PermissionFailure怎么用?PHP Security::PermissionFailure使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Security
的用法示例。
在下文中一共展示了Security::PermissionFailure方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: SaveProfile
function SaveProfile($data, $form)
{
//Check for a logged in member
if ($CurrentMember = Member::currentUser()) {
//Get InfusionSoft Api
$app = $this->getInfusionSoftApi();
$returnFields = array('Id');
$conInfo = $app->findByEmail($data['Email'], $returnFields);
//Check for another member with the same email address
if ($member = DataObject::get_one("Member", "Email = '" . Convert::raw2sql($data['Email']) . "' AND ID != " . $CurrentMember->ID)) {
$form->addErrorMessage("Email", 'Sorry, that Email address already exists.', "bad");
Session::set("FormInfo.Form_EditProfileForm.data", $data);
return $this->redirectBack();
} elseif ($CurrentMember->Email != $data['Email'] && !empty($conInfo)) {
$form->addErrorMessage("Email", 'Sorry, that Email address already exists.', "bad");
Session::set("FormInfo.Form_EditProfileForm.data", $data);
return $this->redirectBack();
} else {
//Update the InfusionSoft contact details
$isConID = $CurrentMember->ISContactID;
$conDat = array('FirstName' => $data['FirstName'], 'LastName' => $data['Surname'], 'Email' => $data['Email']);
$app->updateCon($isConID, $conDat);
//Update the member on site
$form->saveInto($CurrentMember);
$CurrentMember->write();
$this->setMessage('Success', 'Your profile has been saved!');
return $this->redirectBack();
}
} else {
return Security::PermissionFailure($this->controller, 'You must <a href="register">registered</a> and logged in to edit your profile:');
}
}
示例2: Form
/**
* @return EditProfilePage|SS_HTTPResponse
*/
public function Form()
{
if (!Member::currentUser()) {
return Security::PermissionFailure($this->controller, null);
} else {
$form = EditProfileForm::create($this, 'Form');
$this->extend('updateEditProfileForm', $form);
return $form;
}
}
示例3: SaveProfile
/**
* @param $data
* @param $form
* @return SS_HTTPResponse
*/
function SaveProfile($data, $form)
{
// Check for a logged in member
if ($CurrentMember = Member::currentUser()) {
// Check for another member with the same email address
if ($member = DataObject::get_one("Member", "Email = '" . Convert::raw2sql($data['Email']) . "' AND ID != " . $CurrentMember->ID)) {
$form->addErrorMessage("Name", 'Sorry, that name already exists.', "bad");
Session::set("FormInfo.Form_EditProfileForm.data", $data);
return Director::redirectBack();
} else {
$form->saveInto($CurrentMember);
$CurrentMember->write();
return $this->redirect($this->Link('?saved=1'));
}
} else {
return Security::PermissionFailure($this->controller, 'you must be logged in to edit your profile');
}
}
示例4: SaveProfile
function SaveProfile($data, $form)
{
//Check for a logged in member
if ($CurrentMember = Member::currentUser()) {
//Check for another member with the same email address
if ($member = DataObject::get_one("Member", "Email = '" . Convert::raw2sql($data['Email']) . "' AND ID != " . $CurrentMember->ID)) {
//Set error message
$form->sessionMessage($data['Email'] . ". Sorry, that email address already exists. Please choose another.", 'bad');
//Return back to form
return $this->redirectBack();
//return Director::redirectBack();
} else {
$form->saveInto($CurrentMember);
$CurrentMember->write();
return $this->redirect($this->Link('?saved=1'));
}
} else {
return Security::PermissionFailure($this->controller, 'You must <a href="register">registered</a> and logged in to edit your profile:');
}
}
示例5: SaveProfile
/**
* @param $data
* @param $form
* @return bool|SS_HTTPResponse
*/
public function SaveProfile($data, $form)
{
if ($CurrentMember = Member::currentUser()) {
if ($member = DataObject::get_one('Member', "Email = '" . Convert::raw2sql($data['Email']) . "' AND ID != " . $CurrentMember->ID)) {
$form->addErrorMessage('Email', _t('EditProfilePage.EmailErrorText', 'Sorry, that Email already exists.'), 'validation');
return $this->redirectBack();
} else {
// If no password don't save the field
if (!isset($data['password'])) {
unset($data['password']);
}
$this->setFlash(_t('EditProfilePage.EmailSuccessText', 'Your profile has been updated'), 'success');
$form->saveInto($CurrentMember);
$CurrentMember->write();
return $this->redirect($this->Link());
}
} else {
return Security::PermissionFailure($this->controller, 'You must <a href="register">registered</a> and logged in to edit your profile:');
}
}
示例6: Save
/**
* @param $data
* @param $form
* @return bool|SS_HTTPResponse|void
* @throws ValidationException
* @throws null
*/
public function Save($data, $form)
{
/** @var Form $form */
$data = $form->getData();
if ($CurrentMember = Member::currentUser()) {
if ($member = DataObject::get_one('Member', "Email = '" . Convert::raw2sql($data['Email']) . "' AND ID != " . $CurrentMember->ID)) {
$form->addErrorMessage('Email', 'Sorry, that Email already exists.', 'validation');
return $this->controller->redirectBack();
} else {
/** If no password don't save the field */
if (!isset($data['password'])) {
unset($data['password']);
}
$this->controller->setFlash('Your profile has been updated', 'success');
$form->saveInto($CurrentMember);
$CurrentMember->write();
return $this->controller->redirect($this->controller->Link());
}
} else {
/** Get registration page otherwise display warning.
*
* @var RegistrationPage $registerPage
*/
if ($registerPage = DataObject::get_one('RegistrationPage')) {
return Security::PermissionFailure($this->controller, 'You must <a href="' . $registerPage->Link() . '">registered</a> and logged in to edit your profile.');
} else {
$this->controller->setFlash('You must registered and logged in to edit your profile.', 'warning');
return $this->controller->redirect(Director::absoluteBaseURL());
}
}
}
示例7: SaveProfile
function SaveProfile($data, $form)
{
//Check for a logged in member
if ($CurrentMember = Member::currentUser()) {
//Check for another member with the same email address
if (Member::get()->filter(array('Email' => Convert::raw2sql($data['Email']), 'ID:not' => $CurrentMember->ID))->count() > 0) {
$form->addErrorMessage("Email", 'Sorry, that email address already exists.', "bad");
Session::set("FormInfo.Form_EditProfileForm.data", $data);
return $this->redirect($this->Link('?error=1'));
} else {
// Clean up bio
if ($data["Bio"]) {
$config = HTMLPurifier_Config::createDefault();
// Remove any CSS or inline styles
$config->set('CSS.AllowedProperties', array());
$purifier = new HTMLPurifier($config);
$cleanedBio = $purifier->purify($data["Bio"]);
}
$form->saveInto($CurrentMember);
if (isset($cleanedBio)) {
$CurrentMember->Bio = $cleanedBio;
}
if ($data['Gender'] == 'Specify') {
$CurrentMember->Gender = $data['GenderSpecify'];
}
if ($CurrentMember->isChanged('Email')) {
$sender = new MemberRegistrationSenderService();
$sender->send($CurrentMember->resetConfirmation());
}
$CurrentMember->write();
$speaker = PresentationSpeaker::get()->filter('MemberID', $CurrentMember->ID)->first();
if ($speaker) {
if ($data['ReplaceName'] == 1) {
$speaker->FirstName = $data['FirstName'];
}
if ($data['ReplaceSurname'] == 1) {
$speaker->Surname = $data['Surname'];
}
if ($data['ReplaceBio'] == 1) {
$speaker->Bio = $data['Bio'];
}
$speaker->write();
}
// If they do not have a photo uploaded, but they have provided a twitter URL, attempt to grab a photo from twitter
if ($CurrentMember->TwitterName && !$CurrentMember->Photo()->Exists()) {
$this->ProfilePhotoFromTwitter($CurrentMember);
}
return $this->redirect($this->Link('?saved=1'));
}
} else {
return Security::PermissionFailure($this->controller, 'You must be <a href="/join">registered</a> and logged in to edit your profile:');
}
}
示例8: addAction
function addAction($data, $form)
{
//Check for a logged in member
if ($CurrentMember = Member::currentUser()) {
// Find a site member (in any group) based on the MemberID field
$id = Convert::raw2sql($data['MemberID']);
$member = DataObject::get_by_id("Member", $id);
if ($data['SpeakerID'] && is_numeric($data['SpeakerID'])) {
$speaker = PresentationSpeaker::get()->byID(intval($data['SpeakerID']));
} elseif ($member) {
$speaker = PresentationSpeaker::get()->filter('MemberID', $member->ID)->first();
}
if (!$speaker) {
$speaker = new PresentationSpeaker();
}
//Find or create the 'speaker' group
if (!($userGroup = DataObject::get_one('Group', "Code = 'speakers'"))) {
$userGroup = new Group();
$userGroup->Code = "speakers";
$userGroup->Title = "Speakers";
$userGroup->Write();
$member->Groups()->add($userGroup);
}
//Add member to the group
$member->Groups()->add($userGroup);
if ($data['Country'] != '' && $data['Country'] != $member->Country) {
$member->Country = convert::raw2sql($data['Country']);
}
if ($data['ReplaceName'] == 1) {
$member->FirstName = $data['FirstName'];
}
if ($data['ReplaceSurname'] == 1) {
$member->Surname = $data['LastName'];
}
if ($data['ReplaceBio'] == 1) {
$member->Bio = $data['Bio'];
}
$member->write();
$form->saveInto($speaker);
$speaker->MemberID = $member->ID;
$speaker->AdminID = Member::currentUser()->ID;
// Attach Photo
if ($member->PhotoID && $speaker->PhotoID == 0) {
$speaker->PhotoID = $member->PhotoID;
}
$speaker->AskedAboutBureau = TRUE;
// Languages
foreach ($speaker->Languages() as $currentlang) {
$currentlang->delete();
}
foreach ($data['Language'] as $lang) {
if (trim($lang) != '') {
$spoken_lang = SpeakerLanguage::create(array('Language' => $lang));
$speaker->Languages()->add($spoken_lang);
}
}
// Expertise
$speaker->AreasOfExpertise()->removeAll();
foreach ($data['Expertise'] as $exp) {
if (trim($exp) != '') {
$expertise = SpeakerExpertise::create(array('Expertise' => $exp));
$speaker->AreasOfExpertise()->add($expertise);
}
}
// Presentation Link
$speaker->OtherPresentationLinks()->removeAll();
foreach ($data['PresentationLink'] as $key => $link) {
if (trim($link) != '') {
$presentation_title = trim($data['PresentationTitle'][$key]);
$presentation_link = SpeakerPresentationLink::create(array('LinkUrl' => $link, 'Title' => $presentation_title));
$speaker->OtherPresentationLinks()->add($presentation_link);
}
}
// Travel Preferences
$speaker->TravelPreferences()->removeAll();
foreach ($data['CountriesToTravel'] as $travel_country) {
$travel_pref = SpeakerTravelPreference::create(array('Country' => $travel_country));
$speaker->TravelPreferences()->add($travel_pref);
}
$speaker->write();
$form->sessionMessage('Your profile has been updated', 'good');
Session::clear("FormInfo.{$form->FormName()}.data", $data);
return $this->controller()->redirectBack();
} else {
return Security::PermissionFailure($this->controller, 'You must be <a href="/join">registered</a> and logged in to edit your profile:');
}
}
示例9: addAction
function addAction($data, $form)
{
//Check for a logged in member
if ($CurrentMember = Member::currentUser()) {
// Find a site member (in any group) based on the MemberID field
$id = Convert::raw2sql($data['MemberID']);
$member = DataObject::get_by_id("Member", $id);
if ($data['SpeakerID'] && is_numeric($data['SpeakerID'])) {
$speaker = PresentationSpeaker::get()->byID(intval($data['SpeakerID']));
} elseif ($member) {
$speaker = PresentationSpeaker::get()->filter('MemberID', $member->ID)->first();
}
if (!$speaker) {
$speaker = new PresentationSpeaker();
}
//Find or create the 'speaker' group
if (!($userGroup = DataObject::get_one('Group', "Code = 'speakers'"))) {
$userGroup = new Group();
$userGroup->Code = "speakers";
$userGroup->Title = "Speakers";
$userGroup->Write();
$member->Groups()->add($userGroup);
}
//Add member to the group
$member->Groups()->add($userGroup);
if ($data['Country'] != '' && $data['Country'] != $member->Country) {
$member->Country = convert::raw2sql($data['Country']);
}
if ($data['ReplaceName'] == 1) {
$member->FirstName = $data['FirstName'];
}
if ($data['ReplaceSurname'] == 1) {
$member->Surname = $data['LastName'];
}
if ($data['ReplaceBio'] == 1) {
$member->Bio = $data['Bio'];
}
$member->write();
$form->saveInto($speaker);
$speaker->MemberID = $member->ID;
$speaker->AdminID = Member::currentUser()->ID;
// Attach Photo
if ($member->PhotoID && $speaker->PhotoID == 0) {
$speaker->PhotoID = $member->PhotoID;
}
$speaker->AskedAboutBureau = TRUE;
$speaker->write();
$this->controller->redirect($this->controller()->Link() . 'speaker?saved=1');
} else {
return Security::PermissionFailure($this->controller, 'You must be <a href="/join">registered</a> and logged in to edit your profile:');
}
}