function create_from_supporter($dia_supporter_key) { $dia = new DemocracyInAction_API(DIA_API_NODE, DIA_API_USERNAME, DIA_API_PASSWORD); $dia->authenticate(); $supporter = $dia->get('supporter', $dia_supporter_key); if (empty($supporter)) { WinMember::dia_supporter_not_found(); } $member = WinMember::find_by_email($supporter['Email']); if (!$member) { $member = new WinMember($supporter['uid']); } $member->dia =& $dia; if (empty($supporter['uid'])) { trigger_error('no supporter UID'); $member->data->mergeData(array(WIN_USERNAME => $supporter['Email'], WIN_DIA_SUPPORTER_KEY => $supporter['supporter_KEY'], 'Email' => $supporter['Email'], 'First_Name' => $supporter['First_Name'], 'Last_Name' => $supporter['Last_Name'], 'Street' => $supporter['Street'], 'City' => $supporter['City'], 'State' => $supporter['State'], 'Zip' => $supporter['Zip'], 'modin' => 20)); $member->data->save(); trigger_error(var_export($member->data->id, true)); trigger_error(var_export($member->data->getData('Email'), true)); $member->dia->save('supporter', array('Email' => $member->data->getData('Email'), 'email_trigger_KEYS' => '0,' . WIN_SET_PASSWORD_EMAIL_KEY, 'USERNAME' => $member->data->getData('Email'))); $message = 'You must set your password before you can log in. <a href="http://www.winonline.org/forgot_password.php?login_type=content">Click here to set your password now </a>'; AMP_flashMessage($message, $error = 'true'); } return $member; }
function readData($file_name) { $file_path = $this->_base_path . DIRECTORY_SEPARATOR . $file_name; if (!file_exists($file_path)) { AMP_flashMessage(sprintf(AMP_TEXT_ERROR_FILE_EXISTS_NOT, $file_path), true); return false; } $this->setFile($file_path); return true; }
function validate_unique_email($udm) { if (!AMP_params('btnUdmSubmit')) { return; } if (AMP_params('Email') && !AMP_params('uid')) { $finder = new AMP_System_User_Profile(AMP_dbcon()); $existing_accounts = $finder->find(array('Email' => AMP_params('Email'), 'modin' => 20)); if (!empty($existing_accounts)) { AMP_flashMessage('The email address you entered is already associated with an account and must be unique to create a new one. Are you already a member? If so <a href="forgot_password.php?login_type=content">you can recover your password here</a>.', $error = true); AMP_redirect('/form.php?id=' . $udm->instance); exit; } } }
function move($folder_name, $create_folder_name = null) { if ($create_folder_name) { if (!AMP_add_image_subfolder($create_folder_name)) { return false; } $folder_name = $create_folder_name; } if (!$folder_name) { return false; } if (file_exists(AMP_image_path($this->getNameForFolder($folder_name)))) { AMP_flashMessage(sprintf(AMP_TEXT_ERROR_FILE_EXISTS, $this->getNameForFolder($folder_name))); return false; } foreach (AMP_lookup('image_classes') as $image_class => $image_class_name) { if (!file_exists(AMP_image_path($this->getName(), $image_class))) { continue; } rename(AMP_image_path($this->getName(), $image_class), AMP_image_path($this->getNameForFolder($folder_name), $image_class)); } //save new location to database $this->update_database_folder($folder_name); return true; }
$udm = new UserDataInput(AMP_dbcon(), 20); $udm->getUser($AMP_Authen_Handler->getUserId()); // Hide fields that should be present on the signup form, but not on the edit form // Custom1 = username // Custom2 = password // remember users email field so we can use it later when we save $email = $udm->fields['Email']; // Remove non-editable fields so that they don't display on the form $non_editable_fields = array('custom1', 'custom2', 'Email'); foreach ($non_editable_fields as $field_name) { unset($udm->fields[$field_name]); } // if there is POST data, save and redirect back to self. if (isset($_POST['btnUdmSubmit'])) { // add email field back in so DIA syncing works if (empty($udm->fields['Email'])) { $udm->fields['Email'] = $email; //add the email back in the post so that the udm save function doesn't throw a validation error. $_POST['Email'] = $email['value']; } $udm->saveUser(); AMP_flashMessage('Profile Updated'); AMP_redirect('profile.php'); } //BaseModuleIntro uses this local variable to decide what intro text to display for this page. //$intro_id = $udm->modTemplateID; $intro_id = AMP_CONTENT_EDIT_PROFILE_INTROTEXT_ID; AMP_directDisplay('<div id="' . sprintf(AMP_UDM_FORM_CONTAINER, 20) . '">' . $udm->output() . '</div>'); require_once 'AMP/BaseTemplate.php'; require_once 'AMP/BaseModuleIntro.php'; require_once 'AMP/BaseFooter.php';
function bail($message, $redirect_url = '/search.php') { AMP_flashMessage($message, true); AMP_redirect($redirect_url); die; }
<?php require_once 'AMP/Base/Config.php'; require_once 'AMP/Auth/Password/Reset.php'; require_once 'AMP/Auth/Password/Reset/Request/Form.php'; $login_type = AMP_params('login_type'); if (!($login_type && $login_type == 'content')) { trigger_error('attempted to request password reset for non-content login'); AMP_redirect(AMP_CONTENT_URL_FRONTPAGE); } $pw_reset = new AMP_Auth_Password_Reset($login_type); if ($pw_reset->success()) { AMP_flashMessage('You should receive an email message allowing you to reset your password shortly.'); AMP_redirect(AMP_CONTENT_URL_FRONTPAGE); } else { if ($pw_reset->submitted()) { AMP_flashMessage('I can\'t find that account, please try again.'); } $form = new AMP_Auth_Password_Reset_Request_Form(); $form->Build(); AMP_directDisplay($form->execute()); $intro_id = AMP_CONTENT_PUBLICPAGE_ID_PASSWORD_RESET; require_once 'AMP/BaseTemplate.php'; require_once 'AMP/BaseModuleIntro.php'; require_once 'AMP/BaseFooter.php'; }
<?php require_once 'AMP/Base/Config.php'; require_once 'AMP/Auth/Password/Reset/Form.php'; require_once 'AMP/System/User/Profile/Profile.php'; require_once 'AMP/Auth/Handler.inc.php'; #require_once( 'AMP/BaseTemplate.php' ); #require_once( 'AMP/BaseModuleIntro.php' ); // define('AMP_AUTHENTICATION_DEBUG',true); $AMP_Authen_Handler = new AMP_Authentication_Handler(AMP_Registry::getDbcon(), 'content'); if (!$AMP_Authen_Handler->is_authenticated()) { AMP_flashMessage('You need to submit another password reset request, as yours has expired'); $AMP_Authen_Handler->do_login(); } $password_reset_form = new AMP_Auth_Password_Reset_Form(); $password_reset_form->Build(); if ($_POST['new_password']) { $passwords = $password_reset_form->getValues(); $user = new AMP_System_User_Profile(AMP_dbcon(), $AMP_Authen_Handler->userid); if ($user->reset_password($passwords, 'custom2')) { global $dbcon; $dbcon->Execute('DELETE FROM users_sessions where hash=' . $dbcon->qstr($hash)); AMP_flashMessage('Password reset successful'); AMP_redirect('profile.php'); } else { AMP_flashMessage('Passwords do not match'); } } echo $password_reset_form->execute(); require_once 'AMP/BaseFooter.php';