function find_by_email($email) { $finder = new AMP_System_User_Profile(AMP_dbcon()); $records = $finder->find(array('Email' => $email)); $user = array_pop($records); return new WinMember($user->id); }
function execute() { $this->udm =& new UserDataInput(AMP_dbcon(), $this->modin, true); $this->uid = isset($_REQUEST['uid']) && $_REQUEST['uid'] ? intval($_REQUEST['uid']) : false; $this->udm->getUser($this->uid); return $this->getTitle() . $this->udm->output(); }
function is_article_commentable() { $comment_data = $this->getValues(); if (!(isset($comment_data['articleid']) && $comment_data['articleid'])) { return true; } require_once 'AMP/Content/Article.inc.php'; $article = new Article(AMP_dbcon(), $comment_data['articleid']); return $article->acceptingNewComments(); }
function init_controller_by_route($route) { $resource_class = ucfirst($route['target_type']); $controller_class = "AMP_Controller_" . AMP_pluralize($resource_class); $controller_path = str_replace('_', '/', $controller_class) . ".php"; require_once $controller_path; $controller = new $controller_class(AMP_dbcon(), $route['target_id']); $controller->set_action('show'); $controller->set_params(array('id' => $route['target_id'])); return $controller; }
function show() { $this->_before('show'); $section = $this->current_object =& new Section(AMP_dbcon(), $this->params['id']); if (!($section && $section->hasData() && ($section->isDisplayable() || AMP_Authenticate('admin')))) { return AMP_make_404(); } $display =& $section->getDisplay(); $this->_render_section_header($display); $this->render($display); }
function show() { $this->_before('show'); $article = $this->current_object = new Article(AMP_dbcon(), $this->params['id']); //section headers redirect to sections if ($article && $article->hasData() && $article->getData('class') == AMP_CONTENT_CLASS_SECTIONHEADER) { return ampredirect(AMP_route_for('section', $article->getParent())); } if (!($article && AmpUtility::display_okay($article))) { return AMP_make_404(); } $this->render($article->getDisplay()); }
function show() { $this->_before('show'); $section = $this->current_object = new Section(AMP_dbcon(), $this->params['id']); if (!($section && AmpUtility::display_okay($section))) { return AMP_make_404(); } if ($target = $section->getHeaderRedirect()) { ampredirect($target); } $display =& $section->getDisplay(); $this->_render_section_header($display); $this->render($display); }
function replace_image_references($existing_name, $new_name) { $image_fields = AMP_lookup('userdata_image_fields'); if (!$image_fields) { return false; } $user_data = new AMP_User_Data(AMP_dbcon()); foreach ($image_fields as $image_field_desc) { $action = $image_field_desc['fieldname'] . "=" . $user_data->dbcon->qstr($new_name); $crit = $user_data->makeCriteria(array('modin' => $image_field_desc['modin'])); array_push($crit, $user_data->_makeCriteriaEquals($image_field_desc['fieldname'], $existing_name)); $scope = join(' AND ', $crit); $user_data->update_all($action, $scope); } }
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 execute() { $output = '<hr><p class="subtitle"><a name="comments"></a>Comments</p>'; $article = new Article(AMP_dbcon(), $this->comment_set->getArticleId()); if ($article && $article->acceptingNewComments()) { $output .= $this->_HTML_addCommentLink($this->comment_set->getArticleId()); } else { $output .= "<p>" . AMP_TEXT_COMMENTS_CLOSED . "</p>"; } if (AMP_CONTENT_TRACKBACKS_ENABLED) { $output .= ' | ' . $this->_HTML_trackback($this->comment_set->getArticleId()); } if (!$this->comment_set->makeReady()) { return $output; } $output .= '<ol>'; while ($data = $this->comment_set->getData()) { $output .= $this->_HTML_comment($this->_HTML_p_commaJoin(array($this->_HTML_author($data['author'], $data['author_url']), $this->_HTML_date($data['date']))) . $this->_HTML_commentBody($data['comment'])); } $output .= '</ol>'; return $output; }
function getOwner() { $owner_class = ucfirst($this->getData('owner_type')); require_once 'AMP/Content/' . $owner_class . '.inc.php'; return new $owner_class(AMP_dbcon(), $this->getData('owner_id')); }
function __construct($route_slug) { $AMP_dbcon = AMP_dbcon(); $this->criteria = "name = " . $AMP_dbcon->qstr($route_slug); parent::__construct(); }
function update_database_folder($new_folder_name) { $this->_init_attributes(); if ($this->db_metadata) { $this->db_metadata->mergeData(array('folder' => $new_folder_name, 'name' => $this->getNameForFolder($new_folder_name))); $this->db_metadata->save(); } require_once 'Modules/Gallery/Image.inc.php'; require_once 'AMP/Content/Article.inc.php'; require_once 'AMP/Content/Section.inc.php'; require_once 'Modules/Gallery/Gallery.php'; require_once 'AMP/Content/Tag/Tag.php'; require_once 'AMP/Content/Template.inc.php'; require_once 'AMP/Content/Link/Link.php'; require_once 'AMP/User/Data/Data.php'; $this->update_associated_items('Section', 'image2', $new_folder_name); $this->update_associated_items('Section', 'flash', $new_folder_name); $this->update_associated_items('Article', 'image', $new_folder_name); $this->update_associated_items('Gallery', 'img', $new_folder_name); $this->update_associated_items('GalleryImage', 'img', $new_folder_name); $this->update_associated_items('AMP_Content_Tag', 'image', $new_folder_name); $this->update_associated_items('AMP_Content_Link', 'image', $new_folder_name); //article body search $finder = new Article(AMP_dbcon()); $update_action = "test=REPLACE( test, " . $finder->dbcon->qstr($this->getName()) . ", " . $finder->dbcon->qstr($this->getNameForFolder($new_folder_name)) . ")"; $finder->update_all($update_action, array('image_in_body' => $this->getName())); //template body $finder = new AMP_Content_Template(AMP_dbcon()); $update_action = "header2=REPLACE( header2, " . $finder->dbcon->qstr($this->getName()) . ", " . $finder->dbcon->qstr($this->getNameForFolder($new_folder_name)) . ")"; $finder->update_all($update_action, array('image_in_body' => $this->getName())); //udm data AMP_User_Data::replace_image_references($this->getName(), $this->getNameForFolder($new_folder_name)); return true; }
<?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';
<?php require_once 'AMP/Base/Config.php'; require_once 'AMP/Content/RouteSlug/RouteSlug.php'; if (!($raw_slug_name = AMP_params('slug_name'))) { exit; } $finder = new AMP_Content_RouteSlug(AMP_dbcon()); $slug_name = $finder->clean($raw_slug_name); $raw_matches = $finder->find(array('name' => $slug_name)); $exceptions = AMP_params('ignore'); $matches = array(); if (!empty($raw_matches) && $exceptions) { foreach ($exceptions as $ignore) { foreach ($raw_matches as $match_key => $match) { if (!($match->getData('owner_type') == $ignore['owner_type'] and $match->getData('owner_id') == $ignore['owner_id'])) { $matches[] = $match; } } } } else { $matches = $raw_matches; } if (empty($matches)) { print AMP_to_json(array('clean_url' => $slug_name, 'conflicts' => array())); exit; } $match_results = array(); foreach ($matches as $route) { $owner = $route->getOwner(); $match_results[] = array_merge($route->getData(), array('owner_edit_url' => $owner->get_url_edit()));
function create($attributes = array(), $class_name = null) { if (!$class_name) { $context = debug_backtrace(); trigger_error('class name not included for call to ' . __FUNCTION__ . ' on ' . $debug_backtrace[0]['class']); return false; } $item = new $class_name(AMP_dbcon()); $item->setDefaults(); $item->mergeData($attributes); return $item; }
function _save_route_slug() { if (!AMP_CONTENT_HUMANIZE_URLS) { return true; } $finder = new AMP_Content_RouteSlug(AMP_dbcon()); $slugs = $finder->find(array('owner_type' => 'section', 'owner_id' => $this->id)); $assigned_slug = $this->getData('route_slug'); if (empty($slugs) && !$assigned_slug) { return true; } $slug_exists = false; foreach ($slugs as $slug) { if ($slug->getName() == $assigned_slug) { $slug_exists = true; continue; } $slug->delete(); } if ($slug_exists) { return true; } $slug = $finder; $slug->mergeData(array('owner_type' => 'section', 'owner_id' => $this->id, 'name' => $assigned_slug)); $slug->force_valid_slug(); return $slug->save(); }
function donation_is_unique($donation) { $finder = new AMP_System_User_Profile(AMP_dbcon()); $finder->_exact_value_fields[] = WIN_RECENT_DONATION_KEY; return !$finder->find(array(WIN_RECENT_DONATION_KEY => $donation['key']), 'AMP_System_User_Profile'); }
<?php require 'AMP/Base/Config.php'; require_once 'AMP/System/User/Profile/Profile.php'; require_once 'AMP/UserData/Input.inc.php'; require_once 'AMP/Auth/Handler.inc.php'; $AMP_Authen_Handler = new AMP_Authentication_Handler(AMP_Registry::getDbcon(), 'content'); if (!$AMP_Authen_Handler->is_authenticated()) { $AMP_Authen_Handler->do_login(); } $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();
function getRequestedData() { if ($_REQUEST['action'] == 'edit') { return array(); } $finder = new HotlineCaller(AMP_dbcon()); $finder->_exact_value_fields = array("modin", "custom2"); return $finder->find($this->getSearchCriteria()); }
function password_reset_message($account) { $message = new AMPSystem_IntroText(AMP_dbcon(), AMP_CONTENT_PUBLICPAGE_ID_PASSWORD_RESET_EMAIL); return $message->mergeBodyFields(array('reset_link' => $this->password_reset_link($account))); }