From: Steve Sutton Date: Tue, 24 Jun 2014 13:27:41 +0000 (+0000) Subject: Adding new field to the trails X-Git-Tag: v1.0~1 X-Git-Url: http://cvs2.gaslightmedia.com/gitweb/index.cgi?a=commitdiff_plain;h=137bddfb535811cca24b8f7943b9ffb4f467d73a;p=web%2FMichiganTrailMaps.git Adding new field to the trails Add field called nearest_city which will be output as: Nearest City or Town --- diff --git a/Toolkit/Members/Database/addNearestCity.sql b/Toolkit/Members/Database/addNearestCity.sql new file mode 100644 index 0000000..c2ca5c3 --- /dev/null +++ b/Toolkit/Members/Database/addNearestCity.sql @@ -0,0 +1 @@ +ALTER TABLE members.member ADD nearest_city TEXT; diff --git a/Toolkit/Members/EditMemberInfo.php b/Toolkit/Members/EditMemberInfo.php index 6ed25c0..f940e07 100644 --- a/Toolkit/Members/EditMemberInfo.php +++ b/Toolkit/Members/EditMemberInfo.php @@ -1,5 +1,5 @@ - * @license http://www.gaslightmedia.com Gaslightmedia + * @license http://www.gaslightmedia.com Gaslightmedia * @version CVS: $Id: EditMemberInfo.php,v 1.52 2010/08/09 17:58:03 jamie Exp $ - * @link http://demo.gaslightmedia.com + * @link http://demo.gaslightmedia.com */ require_once BASE . 'Toolkit/Image/Server.php'; @@ -35,279 +35,279 @@ require_once BASE . 'Toolkit/Image/Server.php'; * @package Toolkit_Members * @author Jamie Kahgee * @copyright 2008 Gaslight Media - * @license http://www.gaslightmedia.com Gaslightmedia + * @license http://www.gaslightmedia.com Gaslightmedia * @link http://demo.gaslightmedia.com/admin/members.php?rt=Members&ac=editMember&tab=info * @see Toolkit_Members, member_admin */ class Toolkit_Members_EditMemberInfo extends Toolkit_FormBuilder implements Toolkit_Form { - // {{{ properties - - /** - * The Table name used to store the data of the member record in the database. - * - * @var string - * @access public - */ - public $tableName = 'member'; - - /** - * Array of data that holds the meta data info on the table - * - * Contains information on the type of fields in the database. - * That way when we run our automated SQL queries with our PDO - * we can properly bind data to our SQL queries. This will - * allow for one more layer of protection against any sql - * injection attempts. - * - * @var string - * @access public - * @see Toolkit_Common::processData() - */ - public $tableMetaData; - - /** - * Determines if member updates have to be approved if changed - * - * If set to true, all module info must be approved by admin before it - * will be displayed on the front end to visitors. This also includes - * ccard information. - * - * Since all member forms will be spawned from this class, if we put - * this value here we can set once / change once and affect the entire - * app if we need to alter this. We can also set this up in any child - * class and override on individual classes if need be. - * - * @var string - * @access protected - */ - protected $strictPending = true; - - /** - * Some special forms dont utlize this stylesheet - * Allow classes to override this setting so it doesn't - * get included - * - * @var boolean - * @access protected - */ - protected $includeContactStyleSheet = false; - - /** - * The table used to store the data of the member record in the database. - * - * @var string - * @access public - */ - public $pendingTable = 'member_updates'; - - /** - * Determines if a member is in the pending state or not - * - * When the member has rows of data in the member_updates table in the DB - * they are considered "pending updates" until those changes are accepted - * or rejected by an admin user. - * - * @var string - * @access public - */ - public $pending = false; - - /** - * holds all the fields that are currently pending - * - * used in conjunction with the template, all fields that are in this - * list, will have a pending class for the row, so they can easily - * be identified. - * - * @var string - * @access public - */ - public $pendingFields = array(); - - // What are the modules associated with this form. - // New members won't have access to these right away. - // This boolean settings will be overridden inside the class. - - /** - * The status of accommodation related categories associated w/ the member - * - * If the member has any categories that are assigned to the accommodations - * module, then this setting will become true and the form will show - * the accommodation module. - * - * @var bool - * @access protected - */ - protected $accommodations = false; - - /** - * The status of restaurant related categories associated w/ the member - * - * If the member has any categories that are assigned to the restaurant - * module, then this setting will become true and the form will show - * the restaurant module. - * - * @var bool - * @access protected - */ - protected $restaurant = false; - - /** - * The status of golf related categories associated w/ the member - * - * If the member has any categories that are assigned to the golf - * module, then this setting will become true and the form will show - * the golf module. - * - * @var bool - * @access protected - */ - protected $golf = false; - - /** - * Cities array for select list - * - * @var array - * @access protected - */ - protected $cities; - - /** - * States array for select list - * - * @var array - * @access protected - */ - protected $states; - - /** - * Category record objects - * - * Used when creating the category select list. - * - * @var array - * @access protected - */ - protected $records = array(); - - /** - * The categories the member has associated with it - * - * @var array - * @access protected - */ - protected $memberCategories = null; - - /** - * Primary email address to send notification a record has been updated - * - * Set this value to false and it will turn off the email - * update notifications. - * - * @var string - * @access protected - */ - protected $primaryAdvisee; - - /** - * Email address of people that might also want to be advised of updates - * - * A list of all email address that might also want to be advised - * updates have been made on a business record. You can add as many - * as you would like and they will be CC in the email. - * - * N.B. You cannot make this array bigger than 5 people or you will need to - * rewrite the function to handle the server spam issue. - * @var array - * @access private - */ - protected $secondaryAdvisees = array(); - - /** - * Flexy options used in the renderer - * - * @var array - * @access protected - */ - protected $flexyOptions; - - /** - * The name of the template used to render the business info form - * - * @var string - * @access protected - */ - protected $formTemplate = 'editMember.tpl'; - - /** - * The name of the template used to email the owner for any updates - * - * When a member makes an update to thier record, this is the template - * we will use to send out the email notification to the site owner. - * - * @var string - * @access protected - */ - protected $emailTemplate = 'emailOwner.tpl'; - - /** - * Message to return if the form successfully submits - * - * @var string - * @access protected - */ + // {{{ properties + + /** + * The Table name used to store the data of the member record in the database. + * + * @var string + * @access public + */ + public $tableName = 'member'; + + /** + * Array of data that holds the meta data info on the table + * + * Contains information on the type of fields in the database. + * That way when we run our automated SQL queries with our PDO + * we can properly bind data to our SQL queries. This will + * allow for one more layer of protection against any sql + * injection attempts. + * + * @var string + * @access public + * @see Toolkit_Common::processData() + */ + public $tableMetaData; + + /** + * Determines if member updates have to be approved if changed + * + * If set to true, all module info must be approved by admin before it + * will be displayed on the front end to visitors. This also includes + * ccard information. + * + * Since all member forms will be spawned from this class, if we put + * this value here we can set once / change once and affect the entire + * app if we need to alter this. We can also set this up in any child + * class and override on individual classes if need be. + * + * @var string + * @access protected + */ + protected $strictPending = true; + + /** + * Some special forms dont utlize this stylesheet + * Allow classes to override this setting so it doesn't + * get included + * + * @var boolean + * @access protected + */ + protected $includeContactStyleSheet = false; + + /** + * The table used to store the data of the member record in the database. + * + * @var string + * @access public + */ + public $pendingTable = 'member_updates'; + + /** + * Determines if a member is in the pending state or not + * + * When the member has rows of data in the member_updates table in the DB + * they are considered "pending updates" until those changes are accepted + * or rejected by an admin user. + * + * @var string + * @access public + */ + public $pending = false; + + /** + * holds all the fields that are currently pending + * + * used in conjunction with the template, all fields that are in this + * list, will have a pending class for the row, so they can easily + * be identified. + * + * @var string + * @access public + */ + public $pendingFields = array(); + + // What are the modules associated with this form. + // New members won't have access to these right away. + // This boolean settings will be overridden inside the class. + + /** + * The status of accommodation related categories associated w/ the member + * + * If the member has any categories that are assigned to the accommodations + * module, then this setting will become true and the form will show + * the accommodation module. + * + * @var bool + * @access protected + */ + protected $accommodations = false; + + /** + * The status of restaurant related categories associated w/ the member + * + * If the member has any categories that are assigned to the restaurant + * module, then this setting will become true and the form will show + * the restaurant module. + * + * @var bool + * @access protected + */ + protected $restaurant = false; + + /** + * The status of golf related categories associated w/ the member + * + * If the member has any categories that are assigned to the golf + * module, then this setting will become true and the form will show + * the golf module. + * + * @var bool + * @access protected + */ + protected $golf = false; + + /** + * Cities array for select list + * + * @var array + * @access protected + */ + protected $cities; + + /** + * States array for select list + * + * @var array + * @access protected + */ + protected $states; + + /** + * Category record objects + * + * Used when creating the category select list. + * + * @var array + * @access protected + */ + protected $records = array(); + + /** + * The categories the member has associated with it + * + * @var array + * @access protected + */ + protected $memberCategories = null; + + /** + * Primary email address to send notification a record has been updated + * + * Set this value to false and it will turn off the email + * update notifications. + * + * @var string + * @access protected + */ + protected $primaryAdvisee; + + /** + * Email address of people that might also want to be advised of updates + * + * A list of all email address that might also want to be advised + * updates have been made on a business record. You can add as many + * as you would like and they will be CC in the email. + * + * N.B. You cannot make this array bigger than 5 people or you will need to + * rewrite the function to handle the server spam issue. + * @var array + * @access private + */ + protected $secondaryAdvisees = array(); + + /** + * Flexy options used in the renderer + * + * @var array + * @access protected + */ + protected $flexyOptions; + + /** + * The name of the template used to render the business info form + * + * @var string + * @access protected + */ + protected $formTemplate = 'editMember.tpl'; + + /** + * The name of the template used to email the owner for any updates + * + * When a member makes an update to thier record, this is the template + * we will use to send out the email notification to the site owner. + * + * @var string + * @access protected + */ + protected $emailTemplate = 'emailOwner.tpl'; + + /** + * Message to return if the form successfully submits + * + * @var string + * @access protected + */ protected $successMsg = '
The information below has been successfully submitted.
'; - /** - * The flexy template object which holds the rendered object - * - * @var object - * @access protected - */ - protected $template; - - /** - * Form access from inside the template - * - * @var object - * @access protected - */ - protected $view; - - /** - * Extra rules we need to register so we can fully validate form elements - * - * @var array - * @access protected - */ - protected $registeredRules = array( - 'zip', - 'phone', - array( - 'checkEmail', - 'callback', - 'email', - 'Validate' - ), - array( - 'checkURI', - 'callback', - 'uri', - 'Validate' - ) - ); - - // }}} - // {{{ __construct() - - /** - * Class constructor - * + /** + * The flexy template object which holds the rendered object + * + * @var object + * @access protected + */ + protected $template; + + /** + * Form access from inside the template + * + * @var object + * @access protected + */ + protected $view; + + /** + * Extra rules we need to register so we can fully validate form elements + * + * @var array + * @access protected + */ + protected $registeredRules = array( + 'zip', + 'phone', + array( + 'checkEmail', + 'callback', + 'email', + 'Validate' + ), + array( + 'checkURI', + 'callback', + 'uri', + 'Validate' + ) + ); + + // }}} + // {{{ __construct() + + /** + * Class constructor + * * @param PDO $pdo PHP Data Object to use for DB calls * @param string $formName Form's name. * @param string $method (optional)Form's method defaults to 'POST' @@ -315,12 +315,12 @@ class Toolkit_Members_EditMemberInfo * @param string $target (optional)Form's target defaults to '_self' * @param mixed $attributes (optional)Extra attributes for
tag * @param bool $trackSubmit (optional)Whether to track if the form was - * submitted by adding a special hidden field + * submitted by adding a special hidden field * - * @access public - * @see Toolkit_FormBuilder, HTML_QuickForm - */ - public function __construct( + * @access public + * @see Toolkit_FormBuilder, HTML_QuickForm + */ + public function __construct( PDO $pdo, $formName, $method = 'post', @@ -329,7 +329,7 @@ class Toolkit_Members_EditMemberInfo $attributes = null, $trackSubmit = false ) { - parent::__construct( + parent::__construct( $formName, $method, $action, @@ -337,69 +337,69 @@ class Toolkit_Members_EditMemberInfo $attributes, $trackSubmit ); - // if this value is set to false, then no emails will be sent out - // upon update of a record. - if ($this->primaryAdvisee !== false) { - if (!defined('MEMBER_RECORD_UPDATES_ADVISOR')) { - // Please see property definition above for explanation. - echo 'in file: [' . __FILE__ . ' ] on line: [' . __LINE__ . ']
'; - echo ' -

- Please define the - MEMBER_RECORD_UPDATES_ADVISOR constant - in the setup file first.

This Constant should hold - the email address of the person you would like notified - when a member submits an update.
Set to false if you do - not want an email to be sent. -

'; - die; - } - $this->primaryAdvisee = MEMBER_RECORD_UPDATES_ADVISOR; - } - // If you want to add secondary advisors that will also receive - // an email when a record is updated, update the property here. - // If you use associative key values then they will be appended - // to the email string. i.e. - // Jamie Kahgee - // Other wise the address will just be added. - $this->secondaryAdvisees = array( - //'Jamie Kahgee' => 'jamie.kahgee+secondaryAdvisorTest1@gmail.com', - //'Jodie Bissonette' => 'jodie@gaslightmedia.com', - ); - - $this->dbh = $pdo; - - $this->flexyOptions = Toolkit_Members::getFlexyOptions(); - } - - // }}} - - // {{{ addInfoElement() - - /** - * Determines if the element is supposed to display additional info - * + // if this value is set to false, then no emails will be sent out + // upon update of a record. + if ($this->primaryAdvisee !== false) { + if (!defined('MEMBER_RECORD_UPDATES_ADVISOR')) { + // Please see property definition above for explanation. + echo 'in file: [' . __FILE__ . ' ] on line: [' . __LINE__ . ']
'; + echo ' +

+ Please define the + MEMBER_RECORD_UPDATES_ADVISOR constant + in the setup file first.

This Constant should hold + the email address of the person you would like notified + when a member submits an update.
Set to false if you do + not want an email to be sent. +

'; + die; + } + $this->primaryAdvisee = MEMBER_RECORD_UPDATES_ADVISOR; + } + // If you want to add secondary advisors that will also receive + // an email when a record is updated, update the property here. + // If you use associative key values then they will be appended + // to the email string. i.e. + // Jamie Kahgee + // Other wise the address will just be added. + $this->secondaryAdvisees = array( + //'Jamie Kahgee' => 'jamie.kahgee+secondaryAdvisorTest1@gmail.com', + //'Jodie Bissonette' => 'jodie@gaslightmedia.com', + ); + + $this->dbh = $pdo; + + $this->flexyOptions = Toolkit_Members::getFlexyOptions(); + } + + // }}} + + // {{{ addInfoElement() + + /** + * Determines if the element is supposed to display additional info + * * @param string $element name of element * - * @return boolean True if supposed to display additional info. - * false otherwise - * @access public - */ - function addInfoElement($element) - { - switch ($element) { - case 'street' : - case 'member_contact_email' : - return true; - break; - - default : - return false; - break; - } - } + * @return boolean True if supposed to display additional info. + * false otherwise + * @access public + */ + function addInfoElement($element) + { + switch ($element) { + case 'street' : + case 'member_contact_email' : + return true; + break; + + default : + return false; + break; + } + } - // }}} + // }}} /** * Description of addMemberToStreamSend() @@ -419,89 +419,89 @@ class Toolkit_Members_EditMemberInfo } } - // {{{ checkMemberName() - - /** - * Checks if the member name already exists in the database - * - * @param array $data The name of the member to check for. - * - * @return bool False on SQL Query error, otherwise true. - * @access protected - */ - public function checkMemberName($data) - { - try { - // If we're editing a member, they - // can save that member as its - // own name. so don't include that - // member in the check. - if (is_numeric($_GET['id'])) { - $and = "AND member_id <> :id"; - } - $sql = " - SELECT count(*) AS total - FROM member - WHERE member_name = :name - $and"; - $stmt = $this->dbh->prepare($sql); - $stmt->bindParam(':name', $data, PDO::PARAM_STR); - if (is_numeric($_GET['id'])) { - $stmt->bindParam(':id', $_GET['id'], PDO::PARAM_STR); - } - $stmt->execute(); + // {{{ checkMemberName() + + /** + * Checks if the member name already exists in the database + * + * @param array $data The name of the member to check for. + * + * @return bool False on SQL Query error, otherwise true. + * @access protected + */ + public function checkMemberName($data) + { + try { + // If we're editing a member, they + // can save that member as its + // own name. so don't include that + // member in the check. + if (is_numeric($_GET['id'])) { + $and = "AND member_id <> :id"; + } + $sql = " + SELECT count(*) AS total + FROM member + WHERE member_name = :name + $and"; + $stmt = $this->dbh->prepare($sql); + $stmt->bindParam(':name', $data, PDO::PARAM_STR); + if (is_numeric($_GET['id'])) { + $stmt->bindParam(':id', $_GET['id'], PDO::PARAM_STR); + } + $stmt->execute(); $stmt->bindColumn('total', $valid); - $stmt->fetch(); - - return !(bool) $valid; - } catch (PDOException $e) { - return Toolkit_Common::handleError($e); - } - } - - // }}} - // {{{ checkUName() - - /** - * Checks if the login name already exists in the database - * - * @param array $data The name of the member to check for. - * - * @return boolean False on SQL Query error, otherwise true. - * @access protected - */ - public function checkUName($data) - { - try { - // If we're editing a member, they - // can save that member as its - // own name. so don't include that - // member in the check. - if (is_numeric($_GET['id'])) { - $and = "AND member_id <> :id"; - } - $sql = " - SELECT count(*) AS total - FROM {$this->tableName} - WHERE member_login = :name - $and"; - $stmt = $this->dbh->prepare($sql); - $stmt->bindParam(':name', $data, PDO::PARAM_STR); - if (is_numeric($_GET['id'])) { - $stmt->bindParam(':id', $_GET['id'], PDO::PARAM_STR); - } - $stmt->execute(); + $stmt->fetch(); + + return !(bool) $valid; + } catch (PDOException $e) { + return Toolkit_Common::handleError($e); + } + } + + // }}} + // {{{ checkUName() + + /** + * Checks if the login name already exists in the database + * + * @param array $data The name of the member to check for. + * + * @return boolean False on SQL Query error, otherwise true. + * @access protected + */ + public function checkUName($data) + { + try { + // If we're editing a member, they + // can save that member as its + // own name. so don't include that + // member in the check. + if (is_numeric($_GET['id'])) { + $and = "AND member_id <> :id"; + } + $sql = " + SELECT count(*) AS total + FROM {$this->tableName} + WHERE member_login = :name + $and"; + $stmt = $this->dbh->prepare($sql); + $stmt->bindParam(':name', $data, PDO::PARAM_STR); + if (is_numeric($_GET['id'])) { + $stmt->bindParam(':id', $_GET['id'], PDO::PARAM_STR); + } + $stmt->execute(); $stmt->bindColumn('total', $valid); - $stmt->fetch(); + $stmt->fetch(); - return !(bool) $valid; - } catch (PDOException $e) { - return Toolkit_Common::handleError($e); - } - } + return !(bool) $valid; + } catch (PDOException $e) { + return Toolkit_Common::handleError($e); + } + } - // }}} - // {{{ checkDate() + // }}} + // {{{ checkDate() /** * Validate date input @@ -513,28 +513,28 @@ class Toolkit_Members_EditMemberInfo * @return boolean true if valid, false if not * @access public */ - public function checkDate($date) - { - $validate = false; - foreach ($date as $i) { - if (is_numeric($i)) { - $validate = true; - break; - } - } - - if ($validate) { - // at least one date list had a number in it. - $d = implode('-', $date); - return Validate::date($d, array('format' => '%n-%j-%Y')); - } else { - // no date numbers were selected - return true; - } - } - - // }}} - // {{{ checkLatitude() + public function checkDate($date) + { + $validate = false; + foreach ($date as $i) { + if (is_numeric($i)) { + $validate = true; + break; + } + } + + if ($validate) { + // at least one date list had a number in it. + $d = implode('-', $date); + return Validate::date($d, array('format' => '%n-%j-%Y')); + } else { + // no date numbers were selected + return true; + } + } + + // }}} + // {{{ checkLatitude() /** * Validate latitude input @@ -544,14 +544,14 @@ class Toolkit_Members_EditMemberInfo * @return boolean true if valid, false if not * @access public */ - public function checkLatitude($lat) - { - $newLat = (float) $lat; - return ($newLat >= -90.0 && $newLat <= 90.0); - } + public function checkLatitude($lat) + { + $newLat = (float) $lat; + return ($newLat >= -90.0 && $newLat <= 90.0); + } - // }}} - // {{{ checkLongitude() + // }}} + // {{{ checkLongitude() /** * Validate longitude input @@ -561,136 +561,136 @@ class Toolkit_Members_EditMemberInfo * @return boolean true if valid, false if not * @access public */ - public function checkLongitude($lng) - { - $newLng = (float) $lng; - return ($newLng >= -180.0 && $newLng <= 180.0); - } - - // }}} - // {{{ clearModule() - - /** - * Removes a module from a member - * - * When updating a member this function is called for every module. - * Then if the member still has that module category assigned to them - * the data will be re-inserted back into the db. Otherwise it will - * removed and not associated with that member anymore. - * - * @param string $tableName The name of the table / module to clear - * - * @return Boolean False on SQL Query error, otherwise true. - * @access protected - */ - protected function clearModule($tableName) - { - try { - $sql = " + public function checkLongitude($lng) + { + $newLng = (float) $lng; + return ($newLng >= -180.0 && $newLng <= 180.0); + } + + // }}} + // {{{ clearModule() + + /** + * Removes a module from a member + * + * When updating a member this function is called for every module. + * Then if the member still has that module category assigned to them + * the data will be re-inserted back into the db. Otherwise it will + * removed and not associated with that member anymore. + * + * @param string $tableName The name of the table / module to clear + * + * @return Boolean False on SQL Query error, otherwise true. + * @access protected + */ + protected function clearModule($tableName) + { + try { + $sql = " DELETE FROM $tableName WHERE member_id = :member_id"; - $stmt = $this->dbh->prepare($sql); - $stmt->bindParam(':member_id', $_GET['id'], PDO::PARAM_INT); - return $stmt->execute(); - } catch (PDOException $e) { - return Toolkit_Common::handleError($e); - } - } - - // }}} - // {{{ createCategories() - - /** - * Creates an array from the array of category tree objects - * + $stmt = $this->dbh->prepare($sql); + $stmt->bindParam(':member_id', $_GET['id'], PDO::PARAM_INT); + return $stmt->execute(); + } catch (PDOException $e) { + return Toolkit_Common::handleError($e); + } + } + + // }}} + // {{{ createCategories() + + /** + * Creates an array from the array of category tree objects + * * @param array $tree linear tree array of member categories * @param integer $depth what level we are on * - * @return array The array list of categories that - * that can be loaded into a select element - * @access protected - */ - protected function createCategories($tree, $depth = 0) - { - $this->records[] = $tree->category; - if ($depth == 0) { - $this->categories[$tree->catid] = "{$tree->category}"; - } else { - $this->categories[$tree->catid] = $tree->category; - } - if (empty($tree->children)) { - return; - } else { - ++$depth; - foreach ($tree->children as $miniTrees) { - $this->createCategories($miniTrees, $depth); - } - } - } - - // }}} - // {{{ configureConstants() - - /** - * Sets the constants for the form - * - * The member category select list must always default - * to the -- Select Category -- option - * + * @return array The array list of categories that + * that can be loaded into a select element + * @access protected + */ + protected function createCategories($tree, $depth = 0) + { + $this->records[] = $tree->category; + if ($depth == 0) { + $this->categories[$tree->catid] = "{$tree->category}"; + } else { + $this->categories[$tree->catid] = $tree->category; + } + if (empty($tree->children)) { + return; + } else { + ++$depth; + foreach ($tree->children as $miniTrees) { + $this->createCategories($miniTrees, $depth); + } + } + } + + // }}} + // {{{ configureConstants() + + /** + * Sets the constants for the form + * + * The member category select list must always default + * to the -- Select Category -- option + * * @return void - * @access public - */ - public function configureConstants() - { - $c = array(); - - // set the remove_logo_rmv element to 0 so - // if a logo is uploaded and then the remove - // checkbox is checked and the form is submitted - // it won't retain its checked status. - $c = array( - 'member_cats[]' => '', - 'remove_logo_rmv' => 0, - ); - - $this->setupConstants($c); - } - - // }}} - // {{{ configureDefaults() - - /** - * Sets the defaults for the an existing member - * - * Populates data for the main member form. Also grabs - * data to populate the modules on the form if needed. - * - * @return array $defaults Returns the array of defaults - * so children who call this function - * can obtain a copy of these values. - * @access public - */ - public function configureDefaults() - { - if (ctype_digit($_GET['id'])) { - try { - $member_id = $_GET['id']; - // Get the data for the main form items - $sql = " - SELECT * - FROM {$this->tableName} - WHERE member_id = :member_id"; - $stmt = $this->dbh->prepare($sql); - $stmt->bindParam(':member_id', $member_id, PDO::PARAM_INT); - $stmt->execute(); - while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) { - foreach ($row as $k => $v) { + * @access public + */ + public function configureConstants() + { + $c = array(); + + // set the remove_logo_rmv element to 0 so + // if a logo is uploaded and then the remove + // checkbox is checked and the form is submitted + // it won't retain its checked status. + $c = array( + 'member_cats[]' => '', + 'remove_logo_rmv' => 0, + ); + + $this->setupConstants($c); + } + + // }}} + // {{{ configureDefaults() + + /** + * Sets the defaults for the an existing member + * + * Populates data for the main member form. Also grabs + * data to populate the modules on the form if needed. + * + * @return array $defaults Returns the array of defaults + * so children who call this function + * can obtain a copy of these values. + * @access public + */ + public function configureDefaults() + { + if (ctype_digit($_GET['id'])) { + try { + $member_id = $_GET['id']; + // Get the data for the main form items + $sql = " + SELECT * + FROM {$this->tableName} + WHERE member_id = :member_id"; + $stmt = $this->dbh->prepare($sql); + $stmt->bindParam(':member_id', $member_id, PDO::PARAM_INT); + $stmt->execute(); + while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) { + foreach ($row as $k => $v) { switch ($k) { case 'logo': $defaults['old_logo_rmv'] = $v; - $k = 'image_rmv'; - $v = ''.$v.''; + $k = 'image_rmv'; + $v = ''.$v.''; break; case 'lat': $latDMS = Toolkit_Common::f2LatLon( @@ -726,350 +726,358 @@ class Toolkit_Members_EditMemberInfo $defaults[$k] = $v; break; } - } - } + } + } - // Set the defaults for the credit cards. - $sql = " + // Set the defaults for the credit cards. + $sql = " SELECT cct.*, mcct.* FROM ccard_type cct, member_ccard_type mcct WHERE cct.ccard_type_id = mcct.ccard_type_id AND mcct.member_id = :member_id"; - $stmt = $this->dbh->prepare($sql); - $stmt->bindParam(':member_id', $member_id, PDO::PARAM_INT); - $stmt->execute(); - while ($member = $stmt->fetch(PDO::FETCH_ASSOC)) { - $defaults["creditCards[{$member['ccard_type_name']}]"] = true; - } - - $moduleTables = array( - 'member_accommodations', - 'member_golf', - 'member_restaurants', - ); - foreach ($moduleTables as $table) { - $sql = " + $stmt = $this->dbh->prepare($sql); + $stmt->bindParam(':member_id', $member_id, PDO::PARAM_INT); + $stmt->execute(); + while ($member = $stmt->fetch(PDO::FETCH_ASSOC)) { + $defaults["creditCards[{$member['ccard_type_name']}]"] = true; + } + + $moduleTables = array( + 'member_accommodations', + 'member_golf', + 'member_restaurants', + ); + foreach ($moduleTables as $table) { + $sql = " SELECT * FROM $table WHERE member_id = :member_id"; - $stmt = $this->dbh->prepare($sql); - $stmt->bindParam(':member_id', $member_id, PDO::PARAM_INT); - $stmt->execute(); - while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) { - foreach ($row as $k => $v) { - $defaults[$k] = $v; - } - } - } - } catch (PDOException $e) { - Toolkit_Common::handleError($e); - } - } else { - // get member type - $defaultState = $this->config - ->getItem('section', 'conf') - ->getItem('directive', 'defaultState') - ->getContent(); - $defaults = array( - 'member_cats[]' => '', - 'state_id' => $defaultState, - 'country' => '', - ); - } - - $this->setupDefaults($defaults); - return $defaults; - } - - // }}} - // {{{ configureElements() - - /** - * Setup the elements to use on the form. - * - * Categories are populated into the protected class property $categories. - * These categories are used to populate the select list of categories. - * Modules are configured before any elements are setup, that way we will - * know if we need to include them in the rendering of the form. - * + $stmt = $this->dbh->prepare($sql); + $stmt->bindParam(':member_id', $member_id, PDO::PARAM_INT); + $stmt->execute(); + while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) { + foreach ($row as $k => $v) { + $defaults[$k] = $v; + } + } + } + } catch (PDOException $e) { + Toolkit_Common::handleError($e); + } + } else { + // get member type + $defaultState = $this->config + ->getItem('section', 'conf') + ->getItem('directive', 'defaultState') + ->getContent(); + $defaults = array( + 'member_cats[]' => '', + 'state_id' => $defaultState, + 'country' => '', + ); + } + + $this->setupDefaults($defaults); + return $defaults; + } + + // }}} + // {{{ configureElements() + + /** + * Setup the elements to use on the form. + * + * Categories are populated into the protected class property $categories. + * These categories are used to populate the select list of categories. + * Modules are configured before any elements are setup, that way we will + * know if we need to include them in the rendering of the form. + * * @return void - * @access public - */ - public function configureElements() - { - $e = array(); + * @access public + */ + public function configureElements() + { + $e = array(); // get member type - $singularType = $this->config - ->getItem('section', 'listing type') - ->getItem('directive', 'singular') - ->getContent(); - $pluralType = $this->config - ->getItem('section', 'listing type') - ->getItem('directive', 'plural') - ->getContent(); - $useCtrlCities = $this->config - ->getItem('section', 'conf') - ->getItem('directive', 'controlledCities') - ->getContent(); - $allowRegions = $this->config - ->getItem('section', 'conf') - ->getItem('directive', 'regions') - ->getContent(); - $dateStartYear = $this->config - ->getItem('section', 'conf') - ->getItem('directive', 'dateStartYear') - ->getContent(); - $usesGlmReservations = $this->config - ->getItem('section', 'conf') - ->getItem('directive', 'glmReservations') - ->getContent(); - - $this->setupFormCategories(); - $this->configureModules(); - - $this->getCategories(); - - // All Grouped Elements are created here. - // All Elements are created here. This includes group element definitions. + $singularType = $this->config + ->getItem('section', 'listing type') + ->getItem('directive', 'singular') + ->getContent(); + $pluralType = $this->config + ->getItem('section', 'listing type') + ->getItem('directive', 'plural') + ->getContent(); + $useCtrlCities = $this->config + ->getItem('section', 'conf') + ->getItem('directive', 'controlledCities') + ->getContent(); + $allowRegions = $this->config + ->getItem('section', 'conf') + ->getItem('directive', 'regions') + ->getContent(); + $dateStartYear = $this->config + ->getItem('section', 'conf') + ->getItem('directive', 'dateStartYear') + ->getContent(); + $usesGlmReservations = $this->config + ->getItem('section', 'conf') + ->getItem('directive', 'glmReservations') + ->getContent(); + + $this->setupFormCategories(); + $this->configureModules(); + + $this->getCategories(); + + // All Grouped Elements are created here. + // All Elements are created here. This includes group element definitions. // {{{ Member Information - $e[] = array( - 'type' => 'header', - 'req' => false, - 'name' => 'memberInfoHdr', - 'display' => "$singularType Information", - 'col1' => true - ); - $e[] = array( - 'type' => 'advcheckbox', - 'req' => true, - 'name' => 'active', - 'display' => 'Status', + $e[] = array( + 'type' => 'header', + 'req' => false, + 'name' => 'memberInfoHdr', + 'display' => "$singularType Information", + 'col1' => true + ); + $e[] = array( + 'type' => 'advcheckbox', + 'req' => true, + 'name' => 'active', + 'display' => 'Status', 'opts' => 'Active', - 'val' => array(0, 1), - ); + 'val' => array(0, 1), + ); $e[] = array( - 'type' => 'advcheckbox', - 'req' => true, - 'name' => 'reviewed', - 'display' => 'Reviewed?', + 'type' => 'advcheckbox', + 'req' => true, + 'name' => 'reviewed', + 'display' => 'Reviewed?', 'opts' => 'Yes', - 'val' => array(0, 1), - ); - $e[] = array( - 'type' => 'text', - 'req' => true, - 'name' => 'member_name', - 'display' => "$singularType Name", - 'opts' => array('class' => 'text') - ); - - $e[] = array( - 'type' => 'text', - 'req' => false, - 'name' => 'phone', - 'display' => 'Primary Phone', - 'opts' => array('class' => 'text') - ); - - $e[] = array( - 'type' => 'text', - 'req' => false, - 'name' => 'url', - 'display' => 'Website Address', + 'val' => array(0, 1), + ); + $e[] = array( + 'type' => 'text', + 'req' => true, + 'name' => 'member_name', + 'display' => "$singularType Name", + 'opts' => array('class' => 'text') + ); + + $e[] = array( + 'type' => 'text', + 'req' => false, + 'name' => 'phone', + 'display' => 'Primary Phone', + 'opts' => array('class' => 'text') + ); + + $e[] = array( + 'type' => 'text', + 'req' => false, + 'name' => 'url', + 'display' => 'Website Address', 'opts' => array('class' => 'text'), 'noCharLimit' => true - ); + ); $e[] = array( - 'type' => 'text', - 'req' => false, - 'name' => 'paypal', - 'display' => 'Pay Pal URL', + 'type' => 'text', + 'req' => false, + 'name' => 'paypal', + 'display' => 'Pay Pal URL', 'opts' => array('class' => 'text'), 'noCharLimit' => true - ); + ); $e[] = array( - 'type' => 'text', - 'req' => false, - 'name' => 'distance', - 'display' => 'Distance', + 'type' => 'text', + 'req' => false, + 'name' => 'distance', + 'display' => 'Distance', 'opts' => array('class' => 'text'), 'noCharLimit' => true - ); + ); $e[] = array( - 'type' => 'text', - 'req' => false, - 'name' => 'trailtype', - 'display' => 'Type', + 'type' => 'text', + 'req' => false, + 'name' => 'trailtype', + 'display' => 'Type', 'opts' => array('class' => 'text'), 'noCharLimit' => true - ); + ); $e[] = array( - 'type' => 'text', - 'req' => false, - 'name' => 'terrain', - 'display' => 'Terrain', + 'type' => 'text', + 'req' => false, + 'name' => 'terrain', + 'display' => 'Terrain', 'opts' => array('class' => 'text'), 'noCharLimit' => true - ); + ); // $e[] = array( -// 'type' => 'text', -// 'req' => false, -// 'name' => 'dogs', -// 'display' => 'Dogs', -// 'opts' => array('class' => 'text') -// ); +// 'type' => 'text', +// 'req' => false, +// 'name' => 'dogs', +// 'display' => 'Dogs', +// 'opts' => array('class' => 'text') +// ); + $e[] = array( + 'type' => 'text', + 'req' => false, + 'name' => 'difficulty', + 'display' => 'Difficulty', + 'opts' => array('class' => 'text'), + 'noCharLimit' => true + ); $e[] = array( - 'type' => 'text', - 'req' => false, - 'name' => 'difficulty', - 'display' => 'Difficulty', + 'type' => 'text', + 'req' => false, + 'name' => 'nearest_city', + 'display' => 'Nearest City or Town', 'opts' => array('class' => 'text'), 'noCharLimit' => true - ); + ); // }}} - // {{{ Member Categories - - $e[] = array( - 'type' => 'header', - 'req' => false, - 'name' => 'memberCategoriesHdr', - 'display' => "$singularType Categories", - 'col1' => true - ); - $e[] = array( - 'type' => 'select3', - 'req' => false, - 'name' => 'member_cats[]', - 'opts' => $this->categories, - 'att' => array('id' => 'categories') - ); - - // }}} - // {{{ Member Description - - $e[] = array( - 'type' => 'header', - 'req' => false, - 'name' => 'memberDescHdr', - 'display' => "$singularType Description", - 'col1' => true - ); - $e[] = array( - 'type' => 'textarea', - 'req' => false, - 'name' => 'description', - 'display' => null, - 'opts' => array( + // {{{ Member Categories + + $e[] = array( + 'type' => 'header', + 'req' => false, + 'name' => 'memberCategoriesHdr', + 'display' => "$singularType Categories", + 'col1' => true + ); + $e[] = array( + 'type' => 'select3', + 'req' => false, + 'name' => 'member_cats[]', + 'opts' => $this->categories, + 'att' => array('id' => 'categories') + ); + + // }}} + // {{{ Member Description + + $e[] = array( + 'type' => 'header', + 'req' => false, + 'name' => 'memberDescHdr', + 'display' => "$singularType Description", + 'col1' => true + ); + $e[] = array( + 'type' => 'textarea', + 'req' => false, + 'name' => 'description', + 'display' => null, + 'opts' => array( 'id' => 'description', 'rows' => 8, 'cols' => 43 - ), + ), 'noCharLimit' => true - ); + ); // }}} $e[] = array( - 'type' => 'header', - 'req' => false, - 'name' => 'memberGuideHdr', - 'display' => "$singularType Guide", - 'col1' => true - ); - $e[] = array( - 'type' => 'textarea', - 'req' => false, - 'name' => 'guide', - 'display' => null, - 'opts' => array( + 'type' => 'header', + 'req' => false, + 'name' => 'memberGuideHdr', + 'display' => "$singularType Guide", + 'col1' => true + ); + $e[] = array( + 'type' => 'textarea', + 'req' => false, + 'name' => 'guide', + 'display' => null, + 'opts' => array( 'id' => 'guide', 'rows' => 8, 'cols' => 43 - ), + ), 'noCharLimit' => true - ); + ); + $e[] = array( + 'type' => 'header', + 'req' => false, + 'name' => 'memberFacilityHdr', + 'display' => "Facilities", + 'col1' => true + ); $e[] = array( - 'type' => 'header', - 'req' => false, - 'name' => 'memberFacilityHdr', - 'display' => "Facilities", - 'col1' => true - ); - $e[] = array( - 'type' => 'textarea', - 'req' => false, - 'name' => 'facilities', - 'display' => null, - 'opts' => array( + 'type' => 'textarea', + 'req' => false, + 'name' => 'facilities', + 'display' => null, + 'opts' => array( 'id' => 'facilities', 'rows' => 8, 'cols' => 43 - ), + ), 'noCharLimit' => true - ); + ); $e[] = array( - 'type' => 'header', - 'req' => false, - 'name' => 'memberHoursHdr', - 'display' => "Hours & Fees", - 'col1' => true - ); - $e[] = array( - 'type' => 'textarea', - 'req' => false, - 'name' => 'hours', - 'display' => null, - 'opts' => array( + 'type' => 'header', + 'req' => false, + 'name' => 'memberHoursHdr', + 'display' => "Hours & Fees", + 'col1' => true + ); + $e[] = array( + 'type' => 'textarea', + 'req' => false, + 'name' => 'hours', + 'display' => null, + 'opts' => array( 'id' => 'hours', 'rows' => 8, 'cols' => 43 - ), + ), 'noCharLimit' => true - ); + ); + $e[] = array( + 'type' => 'header', + 'req' => false, + 'name' => 'memberDirectionsHdr', + 'display' => "Directions", + 'col1' => true + ); $e[] = array( - 'type' => 'header', - 'req' => false, - 'name' => 'memberDirectionsHdr', - 'display' => "Directions", - 'col1' => true - ); - $e[] = array( - 'type' => 'textarea', - 'req' => false, - 'name' => 'directions', - 'display' => null, - 'opts' => array( + 'type' => 'textarea', + 'req' => false, + 'name' => 'directions', + 'display' => null, + 'opts' => array( 'id' => 'directions', 'rows' => 8, 'cols' => 43 - ), + ), 'noCharLimit' => true - ); + ); $e[] = array( - 'type' => 'header', - 'req' => false, - 'name' => 'memberInfomationHdr', - 'display' => "Information", - 'col1' => true - ); - $e[] = array( - 'type' => 'textarea', - 'req' => false, - 'name' => 'information', - 'display' => null, - 'opts' => array( + 'type' => 'header', + 'req' => false, + 'name' => 'memberInfomationHdr', + 'display' => "Information", + 'col1' => true + ); + $e[] = array( + 'type' => 'textarea', + 'req' => false, + 'name' => 'information', + 'display' => null, + 'opts' => array( 'id' => 'information', 'rows' => 8, 'cols' => 43 - ), + ), 'noCharLimit' => true - ); - // {{{ Account Info + ); + // {{{ Account Info $e[] = array( 'type' => 'header', @@ -1080,13 +1088,13 @@ class Toolkit_Members_EditMemberInfo ); // {{{ Physical Address - $e[] = array( - 'type' => 'text', - 'req' => false, - 'name' => 'street', - 'display' => 'Street Address', - 'opts' => array('class' => 'text') - ); + $e[] = array( + 'type' => 'text', + 'req' => false, + 'name' => 'street', + 'display' => 'Street Address', + 'opts' => array('class' => 'text') + ); if ($useCtrlCities) { $e[] = array( 'type' => 'select', @@ -1104,13 +1112,13 @@ class Toolkit_Members_EditMemberInfo 'opts' => array('class' => 'text') ); } - $e[] = array( - 'type' => 'select', - 'req' => false, - 'name' => 'state_id', - 'display' => 'State / Province', - 'opts' => array('' => '-- Select --') + $this->states - ); + $e[] = array( + 'type' => 'select', + 'req' => false, + 'name' => 'state_id', + 'display' => 'State / Province', + 'opts' => array('' => '-- Select --') + $this->states + ); $e[] = array( 'type' => 'select', 'req' => true, @@ -1118,22 +1126,22 @@ class Toolkit_Members_EditMemberInfo 'display' => 'County', 'opts' => $this->getCounties() ); - if ($allowRegions) { - $e[] = array( - 'type' => 'select', - 'req' => true, - 'name' => 'region', - 'display' => 'Region', - 'opts' => $this->getRegions() - ); - } - $e[] = array( - 'type' => 'text', - 'req' => false, - 'name' => 'zip', - 'display' => 'Zip / Postal Code', - 'opts' => array('class' => 'text') - ); + if ($allowRegions) { + $e[] = array( + 'type' => 'select', + 'req' => true, + 'name' => 'region', + 'display' => 'Region', + 'opts' => $this->getRegions() + ); + } + $e[] = array( + 'type' => 'text', + 'req' => false, + 'name' => 'zip', + 'display' => 'Zip / Postal Code', + 'opts' => array('class' => 'text') + ); $e[] = array( 'type' => 'header', 'name' => 'eventLocationInfoHeader_rmv', @@ -1244,65 +1252,65 @@ class Toolkit_Members_EditMemberInfo 'noCharLimit' => true ); - // {{{ Main Image - - $e[] = array( - 'type' => 'header', - 'req' => false, - 'name' => 'logoHdr', - 'display' => 'Main Image', - 'col2' => true - ); - if ($this->hasLogo()) { - $e[] = array( - 'type' => 'checkbox', - 'req' => false, - 'name' => 'remove_logo_rmv', - 'display' => 'Remove Image' - ); - $e[] = array( - 'type' => 'static', - 'req' => false, - 'name' => 'image_rmv', - 'display' => 'Current Image' - ); + // {{{ Main Image + + $e[] = array( + 'type' => 'header', + 'req' => false, + 'name' => 'logoHdr', + 'display' => 'Main Image', + 'col2' => true + ); + if ($this->hasLogo()) { + $e[] = array( + 'type' => 'checkbox', + 'req' => false, + 'name' => 'remove_logo_rmv', + 'display' => 'Remove Image' + ); + $e[] = array( + 'type' => 'static', + 'req' => false, + 'name' => 'image_rmv', + 'display' => 'Current Image' + ); $e[] = array( - 'type' => 'hidden', - 'req' => false, - 'name' => 'old_logo_rmv' - ); - } - - $e[] = array( - 'type' => 'file', - 'req' => false, - 'name' => 'new_logo_rmv', - 'display' => 'New Image', - 'opts' => array('class' => 'file') - ); + 'type' => 'hidden', + 'req' => false, + 'name' => 'old_logo_rmv' + ); + } + + $e[] = array( + 'type' => 'file', + 'req' => false, + 'name' => 'new_logo_rmv', + 'display' => 'New Image', + 'opts' => array('class' => 'file') + ); // }}} - $this->setupElements($e); - } + $this->setupElements($e); + } - // }}} - // {{{ configureFilters() + // }}} + // {{{ configureFilters() - /** - * Setup the filters to apply to the elements before we are - * handed the values submitted - * + /** + * Setup the filters to apply to the elements before we are + * handed the values submitted + * * @return void - * @access public - */ - public function configureFilters() - { - $f = array(); - $f[] = array( - 'element' => '__ALL__', + * @access public + */ + public function configureFilters() + { + $f = array(); + $f[] = array( + 'element' => '__ALL__', 'filter' => 'trim' - ); + ); $f[] = array( 'element' => 'paypal', 'filter' => array('Toolkit_Common', 'filterURI') @@ -1311,10 +1319,10 @@ class Toolkit_Members_EditMemberInfo 'element' => 'url', 'filter' => array('Toolkit_Common', 'filterURI') ); - $this->setupFilters($f); - } + $this->setupFilters($f); + } - // }}} + // }}} // {{{ configureForm() /** @@ -1333,115 +1341,115 @@ class Toolkit_Members_EditMemberInfo } // }}} - // {{{ configureModules() + // {{{ configureModules() - /** - * Turns on a modules if the member has the appropriate category - * + /** + * Turns on a modules if the member has the appropriate category + * * @return void - * @access protected - */ - protected function configureModules() - { - if (is_array($this->memberCategories)) { - try { - $sql = " - SELECT * - FROM category - WHERE category_id = :cid"; - $stmt = $this->dbh->prepare($sql); - foreach ($this->memberCategories as $cid => $v) { - $stmt->bindParam(':cid', $cid, PDO::PARAM_INT); - $stmt->execute(); - $row = $stmt->fetch(PDO::FETCH_ASSOC); - if ($row['accommodations'] == 't') { - $this->accommodations = true; - } - if ($row['restaurant'] == 't') { - $this->restaurant = true; - } - if ($row['golf'] == 't') { - $this->golf = true; - } - } - } catch (PDOException $e) { - return Toolkit_Common::handleError($e); - } - } - } - - // }}} - // {{{ configureRules() - - /** - * Sets up all the rules to be used when the form is validated. - * + * @access protected + */ + protected function configureModules() + { + if (is_array($this->memberCategories)) { + try { + $sql = " + SELECT * + FROM category + WHERE category_id = :cid"; + $stmt = $this->dbh->prepare($sql); + foreach ($this->memberCategories as $cid => $v) { + $stmt->bindParam(':cid', $cid, PDO::PARAM_INT); + $stmt->execute(); + $row = $stmt->fetch(PDO::FETCH_ASSOC); + if ($row['accommodations'] == 't') { + $this->accommodations = true; + } + if ($row['restaurant'] == 't') { + $this->restaurant = true; + } + if ($row['golf'] == 't') { + $this->golf = true; + } + } + } catch (PDOException $e) { + return Toolkit_Common::handleError($e); + } + } + } + + // }}} + // {{{ configureRules() + + /** + * Sets up all the rules to be used when the form is validated. + * * @return void - * @access public - */ - public function configureRules() - { - $mimeTypes = array( - 'image/jpe', - 'image/jpeg', - 'image/jpg', - 'image/jfif', - 'image/pjpeg', - 'image/pjp', - 'image/gif', - 'image/png', - ); - - $r = array(); - - $r[] = array( - 'element' => 'reservation_id', - 'message' => 'ERROR: Must be an integer!', - 'type' => 'numeric', - 'format' => null, - 'validation' => $this->validationType, - 'reset' => false, - 'force' => false - ); - $r[] = array( - 'element' => 'process_email', - 'message' => 'ERROR: Invalid email format!', - 'type' => 'checkEmail', - 'format' => array('use_rfc822' => true), - 'validation' => $this->validationType, - 'reset' => false, - 'force' => false - ); - $r[] = array( - 'element' => 'member_contact_email', - 'message' => 'ERROR: Invalid email format!', - 'type' => 'checkEmail', - 'format' => array('use_rfc822' => true), - 'validation' => $this->validationType, - 'reset' => false, - 'force' => false - ); - $r[] = array( - 'element' => 'join_date', - 'message' => 'ERROR: Invalid date!', - 'type' => 'callback', - 'format' => array(&$this, 'checkDate'), - 'validation' => $this->validationType, - 'reset' => false, - 'force' => false - ); - $r[] = array( - 'element' => 'paypal', - 'message' => 'ERROR: Invalid URL format', - 'type' => 'checkURI', - 'format' => array( - 'allowed_schemes' => array('http', 'https'), - 'strict' => false - ), - 'validation' => $this->validationType, - 'reset' => false, - 'force' => false - ); + * @access public + */ + public function configureRules() + { + $mimeTypes = array( + 'image/jpe', + 'image/jpeg', + 'image/jpg', + 'image/jfif', + 'image/pjpeg', + 'image/pjp', + 'image/gif', + 'image/png', + ); + + $r = array(); + + $r[] = array( + 'element' => 'reservation_id', + 'message' => 'ERROR: Must be an integer!', + 'type' => 'numeric', + 'format' => null, + 'validation' => $this->validationType, + 'reset' => false, + 'force' => false + ); + $r[] = array( + 'element' => 'process_email', + 'message' => 'ERROR: Invalid email format!', + 'type' => 'checkEmail', + 'format' => array('use_rfc822' => true), + 'validation' => $this->validationType, + 'reset' => false, + 'force' => false + ); + $r[] = array( + 'element' => 'member_contact_email', + 'message' => 'ERROR: Invalid email format!', + 'type' => 'checkEmail', + 'format' => array('use_rfc822' => true), + 'validation' => $this->validationType, + 'reset' => false, + 'force' => false + ); + $r[] = array( + 'element' => 'join_date', + 'message' => 'ERROR: Invalid date!', + 'type' => 'callback', + 'format' => array(&$this, 'checkDate'), + 'validation' => $this->validationType, + 'reset' => false, + 'force' => false + ); + $r[] = array( + 'element' => 'paypal', + 'message' => 'ERROR: Invalid URL format', + 'type' => 'checkURI', + 'format' => array( + 'allowed_schemes' => array('http', 'https'), + 'strict' => false + ), + 'validation' => $this->validationType, + 'reset' => false, + 'force' => false + ); // $r[] = array( // 'element' => 'lat', // 'message' => 'ERROR: Must be a numeric!', @@ -1451,15 +1459,15 @@ class Toolkit_Members_EditMemberInfo // 'reset' => false, // 'force' => false // ); -// $r[] = array( -// 'element' => 'lat', -// 'message' => 'ERROR: Latitude out of range!', -// 'type' => 'callback', -// 'format' => array(&$this, 'checkLatitude'), -// 'validation' => $this->validationType, -// 'reset' => false, -// 'force' => false -// ); +// $r[] = array( +// 'element' => 'lat', +// 'message' => 'ERROR: Latitude out of range!', +// 'type' => 'callback', +// 'format' => array(&$this, 'checkLatitude'), +// 'validation' => $this->validationType, +// 'reset' => false, +// 'force' => false +// ); // $r[] = array( // 'element' => 'lon', // 'message' => 'ERROR: Must be a numeric!', @@ -1469,20 +1477,20 @@ class Toolkit_Members_EditMemberInfo // 'reset' => false, // 'force' => false // ); -// $r[] = array( -// 'element' => 'lon', -// 'message' => 'ERROR: Longitude out of range!', -// 'type' => 'callback', -// 'format' => array(&$this, 'checkLongitude'), -// 'validation' => $this->validationType, -// 'reset' => false, -// 'force' => false -// ); - $allowDuplicateMemberNames - = $this->config - ->getItem('section', 'conf') - ->getItem('directive', 'duplicateMembers') - ->getContent(); +// $r[] = array( +// 'element' => 'lon', +// 'message' => 'ERROR: Longitude out of range!', +// 'type' => 'callback', +// 'format' => array(&$this, 'checkLongitude'), +// 'validation' => $this->validationType, +// 'reset' => false, +// 'force' => false +// ); + $allowDuplicateMemberNames + = $this->config + ->getItem('section', 'conf') + ->getItem('directive', 'duplicateMembers') + ->getContent(); if (!$allowDuplicateMemberNames) { $r[] = array( 'element' => 'member_name', @@ -1494,227 +1502,227 @@ class Toolkit_Members_EditMemberInfo 'force' => false ); } - $r[] = array( - 'element' => 'state_id', - 'message' => 'ERROR: Invalid State!', - 'type' => 'numeric', - 'format' => null, - 'validation' => $this->validationType, - 'reset' => false, - 'force' => false - ); - $r[] = array( - 'element' => 'mailing_state_id', - 'message' => 'ERROR: Invalid State!', - 'type' => 'numeric', - 'format' => null, - 'validation' => $this->validationType, - 'reset' => false, - 'force' => false - ); - $r[] = array( - 'element' => 'region', - 'message' => 'ERROR: Invalid Region!', - 'type' => 'numeric', - 'format' => null, - 'validation' => $this->validationType, - 'reset' => false, - 'force' => false - ); - $r[] = array( - 'element' => 'zip', - 'message' => 'ERROR: Invalid Zip Code!', - 'type' => 'zip', - 'format' => array('requireDBCheck' => false), - 'validation' => $this->validationType, - 'reset' => false, - 'force' => false - ); - $r[] = array( - 'element' => 'mailing_zip', - 'message' => 'ERROR: Invalid Zip Code!', - 'type' => 'zip', - 'format' => array('requireDBCheck' => false), - 'validation' => $this->validationType, - 'reset' => false, - 'force' => false - ); - $r[] = array( - 'element' => 'new_logo_rmv', - 'message' => 'ERROR: Incorrect File Type (.gif, .png, .jpg) only!', - 'type' => 'mimetype', - 'format' => $mimeTypes, - 'validation' => $this->validationType, - 'reset' => false, - 'force' => false - ); - - $this->setupRules($r); - } - - // }}} - - // {{{ emailOwner() - - /** - * Emails the owner and anyone else who wants to be advised of updates - * - * A false value in the primaryAdvisee will cause no email to be sent. - * all secondary advisees listed in the constructor are carbon copied - * in the email. - * - * Emails are sent out in both HTML and TXT forms. - * + $r[] = array( + 'element' => 'state_id', + 'message' => 'ERROR: Invalid State!', + 'type' => 'numeric', + 'format' => null, + 'validation' => $this->validationType, + 'reset' => false, + 'force' => false + ); + $r[] = array( + 'element' => 'mailing_state_id', + 'message' => 'ERROR: Invalid State!', + 'type' => 'numeric', + 'format' => null, + 'validation' => $this->validationType, + 'reset' => false, + 'force' => false + ); + $r[] = array( + 'element' => 'region', + 'message' => 'ERROR: Invalid Region!', + 'type' => 'numeric', + 'format' => null, + 'validation' => $this->validationType, + 'reset' => false, + 'force' => false + ); + $r[] = array( + 'element' => 'zip', + 'message' => 'ERROR: Invalid Zip Code!', + 'type' => 'zip', + 'format' => array('requireDBCheck' => false), + 'validation' => $this->validationType, + 'reset' => false, + 'force' => false + ); + $r[] = array( + 'element' => 'mailing_zip', + 'message' => 'ERROR: Invalid Zip Code!', + 'type' => 'zip', + 'format' => array('requireDBCheck' => false), + 'validation' => $this->validationType, + 'reset' => false, + 'force' => false + ); + $r[] = array( + 'element' => 'new_logo_rmv', + 'message' => 'ERROR: Incorrect File Type (.gif, .png, .jpg) only!', + 'type' => 'mimetype', + 'format' => $mimeTypes, + 'validation' => $this->validationType, + 'reset' => false, + 'force' => false + ); + + $this->setupRules($r); + } + + // }}} + + // {{{ emailOwner() + + /** + * Emails the owner and anyone else who wants to be advised of updates + * + * A false value in the primaryAdvisee will cause no email to be sent. + * all secondary advisees listed in the constructor are carbon copied + * in the email. + * + * Emails are sent out in both HTML and TXT forms. + * * @return boolean result of email - * @access protected - */ - protected function emailOwner() - { - if ($this->primaryAdvisee === false) { - return; - } else { - try { - $sql = " + * @access protected + */ + protected function emailOwner() + { + if ($this->primaryAdvisee === false) { + return; + } else { + try { + $sql = " SELECT member_name FROM member WHERE member_id = :member_id"; - $stmt = $this->dbh->prepare($sql); - $stmt->bindParam(':member_id', $_GET['id'], PDO::PARAM_INT); - $stmt->execute(); - $row = $stmt->fetch(PDO::FETCH_ASSOC); - $memberName = $row['member_name']; - } catch (PDOException $e) { - return Toolkit_Common::handleError($e); - } - $template = new HTML_Template_Flexy($this->flexyOptions); - $page = new stdClass(); - $page->member = $memberName; - $page->url = ($_SERVER['HTTPS'] == 'on') ? BASE_SECURE_URL : BASE_URL; - $page->email = DO_NOT_REPLY_EMAIL; - $page->siteName = SITENAME; - $page->link = 'link'; - - $template->compile($this->emailTemplate); - // Merge the compiled template with the $page object. - $htmlMsg = $template->bufferedOutputObject($page); - - $msg = " -

$memberName

-

- Has updated thier business record and is now in a pending - state. To approve / reject thier changes you can either log - into your {$page->siteName} admin area or follow this - {$page->link} -

"; - $crlf = "\n"; - $mimeMail = new Mail_mime($crlf); + $stmt = $this->dbh->prepare($sql); + $stmt->bindParam(':member_id', $_GET['id'], PDO::PARAM_INT); + $stmt->execute(); + $row = $stmt->fetch(PDO::FETCH_ASSOC); + $memberName = $row['member_name']; + } catch (PDOException $e) { + return Toolkit_Common::handleError($e); + } + $template = new HTML_Template_Flexy($this->flexyOptions); + $page = new stdClass(); + $page->member = $memberName; + $page->url = ($_SERVER['HTTPS'] == 'on') ? BASE_SECURE_URL : BASE_URL; + $page->email = DO_NOT_REPLY_EMAIL; + $page->siteName = SITENAME; + $page->link = 'link'; + + $template->compile($this->emailTemplate); + // Merge the compiled template with the $page object. + $htmlMsg = $template->bufferedOutputObject($page); + + $msg = " +

$memberName

+

+ Has updated thier business record and is now in a pending + state. To approve / reject thier changes you can either log + into your {$page->siteName} admin area or follow this + {$page->link} +

"; + $crlf = "\n"; + $mimeMail = new Mail_mime($crlf); $from = preg_replace("/[^A-Za-z ]/", "", SITENAME) . ' <' . DO_NOT_REPLY_EMAIL . '>'; - $mimeMail->setFrom($from); - $mimeMail->setSubject('Member Record Update'); - if (!empty($this->secondaryAdvisees)) { - foreach ($this->secondaryAdvisees as $k => $v) { - if (is_string($k) && !is_numeric($k)) { - $email = "$k <$v>"; - } else { - $email = $v; - } - $mimeMail->addCC($email); - } - } - $mimeMail->setHTMLBody($htmlMsg); - $mimeMail->setTXTBody($msg); - - $mail =& Mail::factory('mail'); - $body = $mimeMail->get(); - $headers = $mimeMail->headers($hdrs); - - $res = $mail->send($this->primaryAdvisee, $headers, $body); - if (PEAR::isError($res)) { - return Toolkit_Common::handleError($res); - } else { - return $res; - } - } - } - - // }}} - - // {{{ fieldPending() - - /** - * Determines if template fields are pending or not - * - * Each field in the template calls this function to determine if it - * is in a pending state or not. Fields that return true get a - * different colored background and border so they are easily recognizable. - * - * fields are considered pending if they are in the pendingFields array. - * + $mimeMail->setFrom($from); + $mimeMail->setSubject('Member Record Update'); + if (!empty($this->secondaryAdvisees)) { + foreach ($this->secondaryAdvisees as $k => $v) { + if (is_string($k) && !is_numeric($k)) { + $email = "$k <$v>"; + } else { + $email = $v; + } + $mimeMail->addCC($email); + } + } + $mimeMail->setHTMLBody($htmlMsg); + $mimeMail->setTXTBody($msg); + + $mail =& Mail::factory('mail'); + $body = $mimeMail->get(); + $headers = $mimeMail->headers($hdrs); + + $res = $mail->send($this->primaryAdvisee, $headers, $body); + if (PEAR::isError($res)) { + return Toolkit_Common::handleError($res); + } else { + return $res; + } + } + } + + // }}} + + // {{{ fieldPending() + + /** + * Determines if template fields are pending or not + * + * Each field in the template calls this function to determine if it + * is in a pending state or not. Fields that return true get a + * different colored background and border so they are easily recognizable. + * + * fields are considered pending if they are in the pendingFields array. + * * @param string $elem element to check for pending * - * @return boolean If the field is pending - * @access protected - */ - public function fieldPending($elem) + * @return boolean If the field is pending + * @access protected + */ + public function fieldPending($elem) + { + if (!is_array($this->pendingFields)) { + return false; + } else { + return in_array($elem->name, $this->pendingFields); + } + } + + // }}} + + // {{{ getCategories() + + /** + * Creates array structure of the category tree for use in a select element. + * + * This method will also instantiate a class property called tree for your + * class. This object will hold the tree structure of the categories list + * from the Database. + * + * @return array The array list of categories that can be loaded + * into a select element + * + * @access protected + * @see Toolkit_Members_CategoryTree + */ + protected function getCategories() { - if (!is_array($this->pendingFields)) { - return false; - } else { - return in_array($elem->name, $this->pendingFields); - } - } - - // }}} - - // {{{ getCategories() - - /** - * Creates array structure of the category tree for use in a select element. - * - * This method will also instantiate a class property called tree for your - * class. This object will hold the tree structure of the categories list - * from the Database. - * - * @return array The array list of categories that can be loaded - * into a select element - * - * @access protected - * @see Toolkit_Members_CategoryTree - */ - protected function getCategories() - { - try { - $sql = " - SELECT * - FROM category - WHERE parent_id = 0 - ORDER BY name"; - foreach ($this->dbh->query($sql, PDO::FETCH_ASSOC) as $row) { - $this->tree[] = new Toolkit_Members_CategoryTree( - $row['category_id'], + try { + $sql = " + SELECT * + FROM category + WHERE parent_id = 0 + ORDER BY name"; + foreach ($this->dbh->query($sql, PDO::FETCH_ASSOC) as $row) { + $this->tree[] = new Toolkit_Members_CategoryTree( + $row['category_id'], $row['name'], $this->dbh - ); - } - if (!empty($this->tree)) { - foreach ($this->tree as $t) { - $this->createCategories($t); - } - } - - if (empty($this->categories)) { - $this->categories - = array('' => '-- No Categories Created Yet --'); - } else { - $this->categories + ); + } + if (!empty($this->tree)) { + foreach ($this->tree as $t) { + $this->createCategories($t); + } + } + + if (empty($this->categories)) { + $this->categories + = array('' => '-- No Categories Created Yet --'); + } else { + $this->categories = array('' => '-- Select Category --') + $this->categories; - } - } catch (PDOException $e) { - return Toolkit_Common::handleError($e); - } - } + } + } catch (PDOException $e) { + return Toolkit_Common::handleError($e); + } + } - // }}} + // }}} /** * Description of getCurrentAddress() * @@ -1736,435 +1744,435 @@ class Toolkit_Members_EditMemberInfo var_dump($e); exit; } - } - // {{{ getCounties() + } + // {{{ getCounties() + + /** + * Configure the regions for member stored in the database into an array + * + * @return array the counties + * @access protected + */ + protected function getCounties() + { + try { + $sql = " + SELECT * + FROM county + ORDER BY county_name"; + foreach ($this->dbh->query($sql) as $row) { + $counties[$row['county_id']] = $row['county_name']; + } + if (!empty($counties)) { + $counties = array('' => '-- Select County --') + $counties; + } else { + $counties = array('' => '-- No Counties Created Yet -- '); + } + return $counties; + } catch (PDOException $e) { + return Toolkit_Common::handleError($e); + } + } + + // }}} + // {{{ getRegions() + + /** + * Configure the regions for member stored in the database into an array + * + * @return array the regions + * @access protected + */ + protected function getRegions() + { + try { + $sql = " + SELECT * + FROM region + ORDER BY region_name"; + foreach ($this->dbh->query($sql) as $row) { + $regions[$row['region_id']] = $row['region_name']; + } + if (!empty($regions)) { + $regions = array('' => '-- Select Region --') + $regions; + } else { + $regions = array('' => '-- No Regions Created Yet -- '); + } + return $regions; + } catch (PDOException $e) { + return Toolkit_Common::handleError($e); + } + } + + // }}} + + // {{{ hasLogo() + + /** + * Determine if the member record has a logo + * + * @return boolean if the record has a logo or not + * @access protected + */ + protected function hasLogo() + { + try { + $member_id = $_GET['id']; + + $sql = " + SELECT logo + FROM {$this->tableName} + WHERE member_id = :member_id"; + + $stmt = $this->dbh->prepare($sql); + $stmt->bindParam(':member_id', $member_id, PDO::PARAM_INT); + $stmt->execute(); + $row = $stmt->fetch(PDO::FETCH_ASSOC); + + if (get_class($this) === 'Toolkit_Members_EditMemberOnlyInfo') { + $sql = " + SELECT count(*) AS total + FROM {$this->pendingTable} + WHERE member_id = :member_id + AND field = 'logo'"; + + $stmt = $this->dbh->prepare($sql); + $stmt->bindParam(':member_id', $member_id, PDO::PARAM_INT); + $stmt->execute(); + $pendingLogos = $stmt->fetch(PDO::FETCH_ASSOC); + } + + $hasPending = !empty($pendingLogos['total']); + $hasLogo = !is_null($row['logo']); + + return ($hasLogo || $hasPending); + } catch (PDOException $e) { + return Toolkit_Common::handleError($e); + } + } + + // }}} + + // {{{ inColumn2() + + /** + * Lets the form know when to add a new column + * + * When rendering the form, we need to know what element + * to start rendering the new columns on, this function + * checks to see if we should start on the current + * element or not. + * + * This function is called from within the template. + * + * @param string $section element to check + * + * @return boolean if the section is in the 2nd column or not + * @access protected + */ + public function inColumn2($section) + { + return ($this->formHeaders[$section]['col2']); + } + + // }}} + // {{{ insertData() + + /** + * Create a new record in the database from the data on the form + * + * When a member is first created, we don't have to worry about + * and module data ie.(golf, restaurant, accommodations), since + * they initially don't have any categories associated with them. + * + * Lat / Lon coordinates are not generated here, but they are + * injected into the form values if they are not filled in. This + * enables us to use google driving directions on all our members. + * + * Two groups of data are pulled from the values array of data. + * (categories & credit cards), these values are then unset in + * the values array, b/c we don't insert this data into the primary + * table. They each have their own table they get inserted into and + * are then associated to the newly inserted member. + * + * Empty field values are inserted as NULLS vs empty strings to allow + * for unique member_login names. + * + * A transaction is used to avoid orphaned data if any of the sql queries + * fail to properly insert the data. + * + * @param array $values Form values + * + * @return boolean False on error, True otherwise. + * @access public + */ + public function insertData($values) + { + // {{{ Golfing + + // Remove Golf Fields for Special Insert. + $fields = array( + 'par', + 'yardage', + 'course_rating', + 'slope_rating', + 'walking_course', + 'holes18', + 'holes9', + ); + + foreach ($fields as $v) { + $golfFields[$v] = $values[$v]; + unset($values[$v]); + } + + // }}} + // {{{ Accommodations + + // Remove Accommodation Fields for Special Insert. + $fields = array( + 'reservation_url', + 'reservation_id', + 'num_rooms', + 'year_round', + ); + foreach ($fields as $v) { + $accommodationFields[$v] = $values[$v]; + unset($values[$v]); + } + + // }}} + // {{{ Restaurant + + // Remove Restaurant Fields for Special Insert. + $fields = array( + 'breakfast', + 'breakfast_from', + 'breakfast_to', + 'brunch', + 'brunch_from', + 'brunch_to', + 'lunch', + 'lunch_from', + 'lunch_to', + 'dinner', + 'dinner_from', + 'dinner_to', + 'alcohol', + 'non_smoking', + ); + foreach ($fields as $v) { + $restaurantFields[$v] = $values[$v]; + unset($values[$v]); + } - /** - * Configure the regions for member stored in the database into an array - * - * @return array the counties - * @access protected - */ - protected function getCounties() - { - try { - $sql = " - SELECT * - FROM county - ORDER BY county_name"; - foreach ($this->dbh->query($sql) as $row) { - $counties[$row['county_id']] = $row['county_name']; - } - if (!empty($counties)) { - $counties = array('' => '-- Select County --') + $counties; - } else { - $counties = array('' => '-- No Counties Created Yet -- '); - } - return $counties; - } catch (PDOException $e) { - return Toolkit_Common::handleError($e); - } - } - - // }}} - // {{{ getRegions() - - /** - * Configure the regions for member stored in the database into an array - * - * @return array the regions - * @access protected - */ - protected function getRegions() - { - try { - $sql = " - SELECT * - FROM region - ORDER BY region_name"; - foreach ($this->dbh->query($sql) as $row) { - $regions[$row['region_id']] = $row['region_name']; - } - if (!empty($regions)) { - $regions = array('' => '-- Select Region --') + $regions; - } else { - $regions = array('' => '-- No Regions Created Yet -- '); - } - return $regions; - } catch (PDOException $e) { - return Toolkit_Common::handleError($e); - } - } - - // }}} - - // {{{ hasLogo() + // }}} - /** - * Determine if the member record has a logo - * - * @return boolean if the record has a logo or not - * @access protected - */ - protected function hasLogo() - { - try { - $member_id = $_GET['id']; + if (empty($values['lat']) || empty($values['lon'])) { + try { + $this->setLatLngCoords($values); + } catch (Exception $e) { + return Toolkit_Common::handleError($e); + } + } - $sql = " - SELECT logo - FROM {$this->tableName} - WHERE member_id = :member_id"; + $ccards = $values['creditCards']; + // If they dynamically add any categories, but then realize they + // want to remove them, they will show up in this array. + if (isset($values['removeCat'])) { + // So remove them before we get the categories to insert for the member. + $this->removeCategories($values['removeCat'], $values['member_cats']); + } + // Now get the cats so we can insert them into a seperate table later. + $categories = $values['member_cats']; - $stmt = $this->dbh->prepare($sql); - $stmt->bindParam(':member_id', $member_id, PDO::PARAM_INT); - $stmt->execute(); - $row = $stmt->fetch(PDO::FETCH_ASSOC); + // Unneeded data that will not be stored in the member table + unset($values['member_cats'], + $values['removeCat'], + $values['creditCards'] + ); - if (get_class($this) === 'Toolkit_Members_EditMemberOnlyInfo') { + try { + $params = implode(', ', array_keys($values)); + $bindParams = ':' . implode(', :', array_keys($values)); + $sql = " + INSERT INTO {$this->tableName} ($params) + VALUES ($bindParams) + RETURNING member_id"; + $this->dbh->beginTransaction(); + $stmt = $this->dbh->prepare($sql); + foreach ($values as $k => &$v) { + $metaData = $this->tableMetaData[$k]; + if ($metaData == 'integer') { + $dataType = PDO::PARAM_INT; + } elseif ($metaData == 'boolean') { + $dataType = PDO::PARAM_BOOL; + } else { + $dataType = PDO::PARAM_STR; + } + // for empty values that are not actually a zero (0), we + // want to insert null's. + // This will help hold the unique values for member_logins, + // as empty values '', are not considered unique + if (empty($v) && $v !== 0) { + $v = null; + $dataType = PDO::PARAM_NULL; + } + $stmt->bindParam(":$k", $v, $dataType); + } + $stmt->execute(); + $stmt->bindColumn('member_id', $mid); + $stmt->fetch(); + + // Insert the categories into the DB and associate + // them w/ the newly inserted member. + if (!empty($categories)) { $sql = " - SELECT count(*) AS total - FROM {$this->pendingTable} - WHERE member_id = :member_id - AND field = 'logo'"; + INSERT INTO member_category(member_id, category_id) + VALUES(:member_id, :cid)"; + $stmt = $this->dbh->prepare($sql); + $stmt->bindParam(':member_id', $mid, PDO::PARAM_INT); + foreach ($categories as $cid) { + // If the user didn't select a category, + // Then don't run an insert query. + if (!empty($cid)) { + $stmt->bindParam(':cid', $cid, PDO::PARAM_INT); + $stmt->execute(); + } + } + } + + // Insert the members credit cards into the DB and associate + // the w/ our new member. We get the ccard ID # by querying for + // it in the ccard_type table by the ccard name. + if (!empty($ccards)) { + $sql = " + INSERT INTO member_ccard_type(member_id, ccard_type_id) + SELECT :member_id, ccard_type_id + FROM ccard_type + WHERE ccard_type_name = :cctn"; $stmt = $this->dbh->prepare($sql); - $stmt->bindParam(':member_id', $member_id, PDO::PARAM_INT); - $stmt->execute(); - $pendingLogos = $stmt->fetch(PDO::FETCH_ASSOC); + $stmt->bindParam(':member_id', $mid, PDO::PARAM_INT); + foreach ($ccards as $k => $v) { + $stmt->bindParam(':cctn', $k, PDO::PARAM_STR); + $stmt->execute(); + } } - $hasPending = !empty($pendingLogos['total']); - $hasLogo = !is_null($row['logo']); - - return ($hasLogo || $hasPending); - } catch (PDOException $e) { - return Toolkit_Common::handleError($e); - } - } - - // }}} - - // {{{ inColumn2() - - /** - * Lets the form know when to add a new column - * - * When rendering the form, we need to know what element - * to start rendering the new columns on, this function - * checks to see if we should start on the current - * element or not. - * - * This function is called from within the template. - * - * @param string $section element to check - * - * @return boolean if the section is in the 2nd column or not - * @access protected - */ - public function inColumn2($section) - { - return ($this->formHeaders[$section]['col2']); - } - - // }}} - // {{{ insertData() - - /** - * Create a new record in the database from the data on the form - * - * When a member is first created, we don't have to worry about - * and module data ie.(golf, restaurant, accommodations), since - * they initially don't have any categories associated with them. - * - * Lat / Lon coordinates are not generated here, but they are - * injected into the form values if they are not filled in. This - * enables us to use google driving directions on all our members. - * - * Two groups of data are pulled from the values array of data. - * (categories & credit cards), these values are then unset in - * the values array, b/c we don't insert this data into the primary - * table. They each have their own table they get inserted into and - * are then associated to the newly inserted member. - * - * Empty field values are inserted as NULLS vs empty strings to allow - * for unique member_login names. - * - * A transaction is used to avoid orphaned data if any of the sql queries - * fail to properly insert the data. - * - * @param array $values Form values - * - * @return boolean False on error, True otherwise. - * @access public - */ - public function insertData($values) - { - // {{{ Golfing - - // Remove Golf Fields for Special Insert. - $fields = array( - 'par', - 'yardage', - 'course_rating', - 'slope_rating', - 'walking_course', - 'holes18', - 'holes9', - ); - - foreach ($fields as $v) { - $golfFields[$v] = $values[$v]; - unset($values[$v]); - } - - // }}} - // {{{ Accommodations - - // Remove Accommodation Fields for Special Insert. - $fields = array( - 'reservation_url', - 'reservation_id', - 'num_rooms', - 'year_round', - ); - foreach ($fields as $v) { - $accommodationFields[$v] = $values[$v]; - unset($values[$v]); - } - - // }}} - // {{{ Restaurant - - // Remove Restaurant Fields for Special Insert. - $fields = array( - 'breakfast', - 'breakfast_from', - 'breakfast_to', - 'brunch', - 'brunch_from', - 'brunch_to', - 'lunch', - 'lunch_from', - 'lunch_to', - 'dinner', - 'dinner_from', - 'dinner_to', - 'alcohol', - 'non_smoking', - ); - foreach ($fields as $v) { - $restaurantFields[$v] = $values[$v]; - unset($values[$v]); - } - - // }}} - - if (empty($values['lat']) || empty($values['lon'])) { - try { - $this->setLatLngCoords($values); - } catch (Exception $e) { - return Toolkit_Common::handleError($e); - } - } - - $ccards = $values['creditCards']; - // If they dynamically add any categories, but then realize they - // want to remove them, they will show up in this array. - if (isset($values['removeCat'])) { - // So remove them before we get the categories to insert for the member. - $this->removeCategories($values['removeCat'], $values['member_cats']); - } - // Now get the cats so we can insert them into a seperate table later. - $categories = $values['member_cats']; - - // Unneeded data that will not be stored in the member table - unset($values['member_cats'], - $values['removeCat'], - $values['creditCards'] - ); - - try { - $params = implode(', ', array_keys($values)); - $bindParams = ':' . implode(', :', array_keys($values)); - $sql = " - INSERT INTO {$this->tableName} ($params) - VALUES ($bindParams) - RETURNING member_id"; - $this->dbh->beginTransaction(); - $stmt = $this->dbh->prepare($sql); - foreach ($values as $k => &$v) { - $metaData = $this->tableMetaData[$k]; - if ($metaData == 'integer') { - $dataType = PDO::PARAM_INT; - } elseif ($metaData == 'boolean') { - $dataType = PDO::PARAM_BOOL; - } else { - $dataType = PDO::PARAM_STR; - } - // for empty values that are not actually a zero (0), we - // want to insert null's. - // This will help hold the unique values for member_logins, - // as empty values '', are not considered unique - if (empty($v) && $v !== 0) { - $v = null; - $dataType = PDO::PARAM_NULL; - } - $stmt->bindParam(":$k", $v, $dataType); - } - $stmt->execute(); - $stmt->bindColumn('member_id', $mid); - $stmt->fetch(); - - // Insert the categories into the DB and associate - // them w/ the newly inserted member. - if (!empty($categories)) { - $sql = " - INSERT INTO member_category(member_id, category_id) - VALUES(:member_id, :cid)"; - $stmt = $this->dbh->prepare($sql); - $stmt->bindParam(':member_id', $mid, PDO::PARAM_INT); - foreach ($categories as $cid) { - // If the user didn't select a category, - // Then don't run an insert query. - if (!empty($cid)) { - $stmt->bindParam(':cid', $cid, PDO::PARAM_INT); - $stmt->execute(); - } - } - } - - // Insert the members credit cards into the DB and associate - // the w/ our new member. We get the ccard ID # by querying for - // it in the ccard_type table by the ccard name. - if (!empty($ccards)) { - $sql = " - INSERT INTO member_ccard_type(member_id, ccard_type_id) - SELECT :member_id, ccard_type_id - FROM ccard_type - WHERE ccard_type_name = :cctn"; - - $stmt = $this->dbh->prepare($sql); - $stmt->bindParam(':member_id', $mid, PDO::PARAM_INT); - foreach ($ccards as $k => $v) { - $stmt->bindParam(':cctn', $k, PDO::PARAM_STR); - $stmt->execute(); - } - } - - $golf = $restaurant = $accommodations = false; - if (!empty($categories)) { - $sql = " - SELECT * - FROM category - WHERE category_id = :cid"; - $stmt = $this->dbh->prepare($sql); - foreach ($categories as &$cid) { - if (!empty($cid)) { - $stmt->bindParam(':cid', $cid, PDO::PARAM_INT); - $stmt->execute(); - $row = $stmt->fetch(PDO::FETCH_ASSOC); - // If any of the module statuses are true, set them. - // otherwise leave them as they were, (we don't want - // to set a true back to a false). - $golf = ($row['golf'] == 't') ? true : $golf; - $accommodations = ($row['accommodations'] == 't') ? - true : $accommodations; - $restaurant = ($row['restaurant'] == 't') ? - true : $restaurant; - } - } - } - $this->clearModule('member_golf'); - if ($golf) { - $this->updateModuleFields($golfFields, 'member_golf', $mid); - } - $this->clearModule('member_accommodations'); - if ($accommodations) { - $this->updateModuleFields($accommodationFields, 'member_accommodations', $mid); - } - $this->clearModule('member_restaurants'); - if ($restaurant) { - $this->updateModuleFields($restaurantFields, 'member_restaurants', $mid); - } - $this->dbh->commit(); - } catch (PDOException $e) { - return Toolkit_Common::handleError($e); - } + $golf = $restaurant = $accommodations = false; + if (!empty($categories)) { + $sql = " + SELECT * + FROM category + WHERE category_id = :cid"; + $stmt = $this->dbh->prepare($sql); + foreach ($categories as &$cid) { + if (!empty($cid)) { + $stmt->bindParam(':cid', $cid, PDO::PARAM_INT); + $stmt->execute(); + $row = $stmt->fetch(PDO::FETCH_ASSOC); + // If any of the module statuses are true, set them. + // otherwise leave them as they were, (we don't want + // to set a true back to a false). + $golf = ($row['golf'] == 't') ? true : $golf; + $accommodations = ($row['accommodations'] == 't') ? + true : $accommodations; + $restaurant = ($row['restaurant'] == 't') ? + true : $restaurant; + } + } + } + $this->clearModule('member_golf'); + if ($golf) { + $this->updateModuleFields($golfFields, 'member_golf', $mid); + } + $this->clearModule('member_accommodations'); + if ($accommodations) { + $this->updateModuleFields($accommodationFields, 'member_accommodations', $mid); + } + $this->clearModule('member_restaurants'); + if ($restaurant) { + $this->updateModuleFields($restaurantFields, 'member_restaurants', $mid); + } + $this->dbh->commit(); + } catch (PDOException $e) { + return Toolkit_Common::handleError($e); + } $this->addMemberToStreamSend($mid); header('Location: ' . BASE_URL . "admin/members.php?rt=Members&ac=editMember&tab=info&id=$mid"); - return true; - } + return true; + } - // }}} + // }}} - // {{{ newColumn() + // {{{ newColumn() - /** - * Determines if we've reached the field that should start a new column - * - * This is used from the Flexy template. Each field name is passed into - * this function, when we reach the appropriate field, we will know that - * we need to start a new column. - * - * @param string $string The name of the field we're checking. + /** + * Determines if we've reached the field that should start a new column * - * @return boolean True on the right field, otherwise false. - * @access protected - */ - public function newColumn($string) - { - return ($string == 'Street Address'); - } + * This is used from the Flexy template. Each field name is passed into + * this function, when we reach the appropriate field, we will know that + * we need to start a new column. + * + * @param string $string The name of the field we're checking. + * + * @return boolean True on the right field, otherwise false. + * @access protected + */ + public function newColumn($string) + { + return ($string == 'Street Address'); + } - // }}} + // }}} public function isMyCheckBox($string) { return (in_array($string, array('active', 'dogsallowed', 'reviewed'))); } - // {{{ processData() - - /** - * Handles processing the submitted forms data. - * - * Sets up the table meta data so we can insert into the member table. - * removes any unwanted fields from the values array. these fields - * will be denoted by the '_rmv' at the end of thier name in the - * configureElements function - * - * - * ... 'name' => 'remove_rmv', ... - * - * - * This function also verifies that the lat/lon values were properly filled - * out, if they were left blank then the values will either be looked up - * via google maps or through our own zip DB. These values will then be - * inserted into the values array AND also injected into the form field - * values so they will display when the form comes back around. - * - * The form then decides if it is handeling a new member or not and calls - * the appropriate function to insert or update data. - * - * @param array $values The array of all submitted form values. - * - * @return boolean Whether the insert/update succeeded. - * @access public - */ - public function processData($values) - { - // Clean up some form elements before we try any processing - if (is_array($values['join_date'])) { - if (is_numeric($values['join_date']['m'])) { - $values['join_date'] = implode('-', $values['join_date']); - } else { - $values['join_date'] = null; - } - } - $this->processLogo($values); - $this->tableMetaData = Toolkit_Common::getTableMetaData( + // {{{ processData() + + /** + * Handles processing the submitted forms data. + * + * Sets up the table meta data so we can insert into the member table. + * removes any unwanted fields from the values array. these fields + * will be denoted by the '_rmv' at the end of thier name in the + * configureElements function + * + * + * ... 'name' => 'remove_rmv', ... + * + * + * This function also verifies that the lat/lon values were properly filled + * out, if they were left blank then the values will either be looked up + * via google maps or through our own zip DB. These values will then be + * inserted into the values array AND also injected into the form field + * values so they will display when the form comes back around. + * + * The form then decides if it is handeling a new member or not and calls + * the appropriate function to insert or update data. + * + * @param array $values The array of all submitted form values. + * + * @return boolean Whether the insert/update succeeded. + * @access public + */ + public function processData($values) + { + // Clean up some form elements before we try any processing + if (is_array($values['join_date'])) { + if (is_numeric($values['join_date']['m'])) { + $values['join_date'] = implode('-', $values['join_date']); + } else { + $values['join_date'] = null; + } + } + $this->processLogo($values); + $this->tableMetaData = Toolkit_Common::getTableMetaData( $this->dbh, $this->tableName ); @@ -2183,30 +2191,30 @@ class Toolkit_Members_EditMemberInfo $values['lon'] = $lonInput['dir'] * ($lonInput['deg'] + ($lonInput['min'] + ($lonInput['sec'] / 60)) / 60); // var_dump($values); // exit; - foreach ($values as $k => $v) { - switch ($k) { - case 'MAX_FILE_SIZE' : - unset($values[$k]); - break; - - default : - if (preg_match('/^.+_rmv$/', $k)) { - unset($values[$k]); - } - break; - } - } + foreach ($values as $k => $v) { + switch ($k) { + case 'MAX_FILE_SIZE' : + unset($values[$k]); + break; + + default : + if (preg_match('/^.+_rmv$/', $k)) { + unset($values[$k]); + } + break; + } + } - if (ctype_digit($_GET['id'])) { - return $this->updateData($values); - } else { - return $this->insertData($values); - } - } + if (ctype_digit($_GET['id'])) { + return $this->updateData($values); + } else { + return $this->insertData($values); + } + } - // }}} + // }}} - // {{{ processLogo() + // {{{ processLogo() /** @@ -2219,142 +2227,142 @@ class Toolkit_Members_EditMemberInfo * @return object Return description (if any) ... * @access protected */ - protected function processLogo(&$values) - { - // Keep a tidy house. - // There are 2 scenarios to deal w/ logos: - // 1. Removing logo: - // Delete the image from the image server - // and set the values['logo'] to null. - // 2. New logo: - // Check to see if old_logo_rmv holds a value, - // if it does then remove that logo - // Upload the image and put new filename - // into values['logo'] variable. - $imgServer = new Toolkit_Image_Server(); - - if ($values['remove_logo_rmv'] == 1) { - $imgServer->imageDelete($values['old_logo_rmv']); - $values['logo'] = null; - - if (get_class($this) == 'Toolkit_Members_EditMemberOnlyInfo') { - try { - // Make sure any logos that were pending are removed as well. - $sql = " - DELETE FROM {$this->pendingTable} - WHERE field = 'logo' - AND member_id = :member_id"; - $stmt = $this->dbh->prepare($sql); - $stmt->bindParam(':member_id', $_GET['id'], PDO::PARAM_INT); - $stmt->execute(); - - $sql = " - UPDATE {$this->tableName} - SET logo = :logo - WHERE member_id = :member_id"; - $stmt = $this->dbh->prepare($sql); - $stmt->bindParam(':logo', $values['logo'], PDO::PARAM_NULL); - $stmt->bindParam(':member_id', $_GET['id'], PDO::PARAM_INT); - $stmt->execute(); - } catch (PDOException $e) { - return Toolkit_Common::handleError($e); - } - } - } - - // If a new logo is uploaded, have the image server - // process that logo and give us back the file name on - // the server. - if ($values['new_logo_rmv']['size'] > 0) { - $imgName = $imgServer->imageUpload('new_logo_rmv'); - $values['logo'] = $imgName; - $img = ''. $imgName . ''; - - // If the old_logo_rmv key is set and not empty - // then we are replacing an existing logo and did not - // check the remove logo checkbox. - // remove this old logo just for good house keeping. - if (isset($values['old_logo_rmv']) && !empty($values['old_logo_rmv'])) { - $imgServer->imageDelete($values['old_logo_rmv']); - // update the elements on the form if we are replacing an existing logo. - if ($this->elementExists('old_logo_rmv')) { - $e =& $this->getElement('old_logo_rmv'); - $e->setValue($imgName); - } - if ($this->elementExists('image_rmv')) { - $e =& $this->getElement('image_rmv'); - $e->setValue($img); - } - } else { - $source =& $this->createElement( + protected function processLogo(&$values) + { + // Keep a tidy house. + // There are 2 scenarios to deal w/ logos: + // 1. Removing logo: + // Delete the image from the image server + // and set the values['logo'] to null. + // 2. New logo: + // Check to see if old_logo_rmv holds a value, + // if it does then remove that logo + // Upload the image and put new filename + // into values['logo'] variable. + $imgServer = new Toolkit_Image_Server(); + + if ($values['remove_logo_rmv'] == 1) { + $imgServer->imageDelete($values['old_logo_rmv']); + $values['logo'] = null; + + if (get_class($this) == 'Toolkit_Members_EditMemberOnlyInfo') { + try { + // Make sure any logos that were pending are removed as well. + $sql = " + DELETE FROM {$this->pendingTable} + WHERE field = 'logo' + AND member_id = :member_id"; + $stmt = $this->dbh->prepare($sql); + $stmt->bindParam(':member_id', $_GET['id'], PDO::PARAM_INT); + $stmt->execute(); + + $sql = " + UPDATE {$this->tableName} + SET logo = :logo + WHERE member_id = :member_id"; + $stmt = $this->dbh->prepare($sql); + $stmt->bindParam(':logo', $values['logo'], PDO::PARAM_NULL); + $stmt->bindParam(':member_id', $_GET['id'], PDO::PARAM_INT); + $stmt->execute(); + } catch (PDOException $e) { + return Toolkit_Common::handleError($e); + } + } + } + + // If a new logo is uploaded, have the image server + // process that logo and give us back the file name on + // the server. + if ($values['new_logo_rmv']['size'] > 0) { + $imgName = $imgServer->imageUpload('new_logo_rmv'); + $values['logo'] = $imgName; + $img = ''. $imgName . ''; + + // If the old_logo_rmv key is set and not empty + // then we are replacing an existing logo and did not + // check the remove logo checkbox. + // remove this old logo just for good house keeping. + if (isset($values['old_logo_rmv']) && !empty($values['old_logo_rmv'])) { + $imgServer->imageDelete($values['old_logo_rmv']); + // update the elements on the form if we are replacing an existing logo. + if ($this->elementExists('old_logo_rmv')) { + $e =& $this->getElement('old_logo_rmv'); + $e->setValue($imgName); + } + if ($this->elementExists('image_rmv')) { + $e =& $this->getElement('image_rmv'); + $e->setValue($img); + } + } else { + $source =& $this->createElement( 'checkbox', 'remove_logo_rmv', 'Remove Logo' ); - $this->insertElementBefore($source, 'new_logo_rmv'); + $this->insertElementBefore($source, 'new_logo_rmv'); - $source =& $this->addElement('hidden', 'old_logo_rmv'); - $source->setValue($imgName); + $source =& $this->addElement('hidden', 'old_logo_rmv'); + $source->setValue($imgName); - $source =& $this->createElement( + $source =& $this->createElement( 'static', 'image_rmv', 'Current Image' ); - $source->setValue($img); - $element = $this->insertElementBefore($source, 'new_logo_rmv'); - - if (PEAR::isError($element)) { - die ('there was an error uploading your file!'); - } else { - // I don't know why, but the insertElementBefore - // function was erasing the value we set earlier. - // so just reset it to make double sure its there. - $element->setValue($img); - } - } - } - - // We clicked to remove the logo and did not upload a new one. - if ($values['remove_logo_rmv'] == 1 && $values['new_logo_rmv']['size'] == 0) { - if ($this->elementExists('remove_logo_rmv')) { - $this->removeElement('remove_logo_rmv', false); - } - if ($this->elementExists('image_rmv')) { - $this->removeElement('image_rmv', false); - } - if ($this->elementExists('old_logo_rmv')) { - $this->removeElement('old_logo_rmv', false); - } - } - } - - // }}} - - // {{{ removeCategories() - - /** - * Remove categories from the values['member_cats'] array - * - * Any values in the removeCats array are removed from the - * values['member_cats'] array which is passed in by reference - * so we don't have to return any values. - * - * @param array $targets All the category id's we want to remove - * @param array &$values All the categories submitte. - * + $source->setValue($img); + $element = $this->insertElementBefore($source, 'new_logo_rmv'); + + if (PEAR::isError($element)) { + die ('there was an error uploading your file!'); + } else { + // I don't know why, but the insertElementBefore + // function was erasing the value we set earlier. + // so just reset it to make double sure its there. + $element->setValue($img); + } + } + } + + // We clicked to remove the logo and did not upload a new one. + if ($values['remove_logo_rmv'] == 1 && $values['new_logo_rmv']['size'] == 0) { + if ($this->elementExists('remove_logo_rmv')) { + $this->removeElement('remove_logo_rmv', false); + } + if ($this->elementExists('image_rmv')) { + $this->removeElement('image_rmv', false); + } + if ($this->elementExists('old_logo_rmv')) { + $this->removeElement('old_logo_rmv', false); + } + } + } + + // }}} + + // {{{ removeCategories() + + /** + * Remove categories from the values['member_cats'] array + * + * Any values in the removeCats array are removed from the + * values['member_cats'] array which is passed in by reference + * so we don't have to return any values. + * + * @param array $targets All the category id's we want to remove + * @param array &$values All the categories submitte. + * * @return void - * @access protected - */ - protected function removeCategories($targets, &$values) - { - foreach ($targets as $cid) { - $key = array_search($cid, $values); - unset($values[$key]); - } - } - - // }}} + * @access protected + */ + protected function removeCategories($targets, &$values) + { + foreach ($targets as $cid) { + $key = array_search($cid, $values); + unset($values[$key]); + } + } + + // }}} // {{{ setConfig() @@ -2404,7 +2412,7 @@ class Toolkit_Members_EditMemberInfo } // }}} - // {{{ setLatLngCoords() + // {{{ setLatLngCoords() /** * Turning off the lookup of lat lon for this site @@ -2414,44 +2422,44 @@ class Toolkit_Members_EditMemberInfo * @return void|mixed Only on pdo error * @access protected */ - protected function setLatLngCoords(&$values) - { + protected function setLatLngCoords(&$values) + { return $values; - $geocoder = new GeocodeYahoo(); - - $sql = " - SELECT c.city_name, s.state_abb - FROM city c, state s - WHERE c.city_id = :cityId - AND s.state_id = :stateId"; - - try { - $stmt = $this->dbh->prepare($sql); - $stmt->bindParam(':cityId', $values['city_id'], PDO::PARAM_INT); - $stmt->bindParam(':stateId', $values['state_id'], PDO::PARAM_INT); - $stmt->execute(); - $stmt->bindColumn('city_name', $cityName); - $stmt->bindColumn('state_abb', $stateName); - $stmt->fetch(PDO::FETCH_ASSOC); - } catch (PDOException $e) { - return Toolkit_Common::handleError($e); - } - - $address = array( - 'city' => $cityName, - 'state' => $stateName, - 'zip' => $values['zip'], - ); - if (!empty($values['street'])) { - $address['street'] = $values['street']; - } - - if ( $this->elementExists('lat') - && $this->elementExists('lon') - ) { - try { - $response = $geocoder->geocodeAddress($address); - $responseArray = unserialize($response); + $geocoder = new GeocodeYahoo(); + + $sql = " + SELECT c.city_name, s.state_abb + FROM city c, state s + WHERE c.city_id = :cityId + AND s.state_id = :stateId"; + + try { + $stmt = $this->dbh->prepare($sql); + $stmt->bindParam(':cityId', $values['city_id'], PDO::PARAM_INT); + $stmt->bindParam(':stateId', $values['state_id'], PDO::PARAM_INT); + $stmt->execute(); + $stmt->bindColumn('city_name', $cityName); + $stmt->bindColumn('state_abb', $stateName); + $stmt->fetch(PDO::FETCH_ASSOC); + } catch (PDOException $e) { + return Toolkit_Common::handleError($e); + } + + $address = array( + 'city' => $cityName, + 'state' => $stateName, + 'zip' => $values['zip'], + ); + if (!empty($values['street'])) { + $address['street'] = $values['street']; + } + + if ( $this->elementExists('lat') + && $this->elementExists('lon') + ) { + try { + $response = $geocoder->geocodeAddress($address); + $responseArray = unserialize($response); if ($responseArray['ResultSet']['Result'][0]['Latitude']) { $values['lat'] = $responseArray['ResultSet']['Result'][0]['Latitude']; $values['lon'] = $responseArray['ResultSet']['Result'][0]['Longitude']; @@ -2460,20 +2468,20 @@ class Toolkit_Members_EditMemberInfo $values['lon'] = $responseArray['ResultSet']['Result']['Longitude']; } - $lat =& $this->getElement('lat'); - $lat->setValue($values['lat']); - $lng =& $this->getElement('lon'); - $lng->setValue($values['lon']); - } catch (BadMethodCallException $e) { - Toolkit_Logger::logException('Invalid Arg', $e); - } catch (Exception $e) { - Toolkit_Logger::logException('Yahoo GeoCode', $e); - } - } - } + $lat =& $this->getElement('lat'); + $lat->setValue($values['lat']); + $lng =& $this->getElement('lon'); + $lng->setValue($values['lon']); + } catch (BadMethodCallException $e) { + Toolkit_Logger::logException('Invalid Arg', $e); + } catch (Exception $e) { + Toolkit_Logger::logException('Yahoo GeoCode', $e); + } + } + } - // }}} - // {{{ setupFormCategories() + // }}} + // {{{ setupFormCategories() /** * Short description for function @@ -2483,70 +2491,70 @@ class Toolkit_Members_EditMemberInfo * @return void * @access protected */ - protected function setupFormCategories() - { - try { - // Determine if this is a new member record or we're editing - // an existing member record. - $member_id = $_GET['id']; - // Get all the categories already associated w/ this member. - // This part is primarily for editing existing members. - // That way they categories initially show up. - // They are ordered by the mem_cat_id which should keep - // them in the same order as they were added. - $sql = " + protected function setupFormCategories() + { + try { + // Determine if this is a new member record or we're editing + // an existing member record. + $member_id = $_GET['id']; + // Get all the categories already associated w/ this member. + // This part is primarily for editing existing members. + // That way they categories initially show up. + // They are ordered by the mem_cat_id which should keep + // them in the same order as they were added. + $sql = " SELECT * FROM member_category WHERE member_id = :id - ORDER BY member_category_id"; - $stmt = $this->dbh->prepare($sql); - $stmt->bindParam(':id', $member_id, PDO::PARAM_INT); - $stmt->execute(); - - while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) { - $memCats[$row['category_id']] = true; - } - - // If we submitted the form: - // 1. Get all the member_cat values on the form that were submitted. - // If we flip the key/value pairs when we add the submitted values - // we won't have to worry about checking for duplicate cats submitted. - // 2. If we clicked on a remove button determine the x/y coords - // (hint: the coords will be empty if we didn't click on one). - // if the coords are not empty, then remove the category we clicked - // on, it will be the removeCat form element. - if ($this->isSubmitted()) { - if (!is_array($memCats)) { - $memCats = array(); - } - $submittedMemberCats = $this->getSubmitValue('member_cats'); - if (is_array($submittedMemberCats) && !empty($submittedMemberCats)) { - $memCats += array_flip($this->getSubmitValue('member_cats')); - } - // Holds a possible array of category id's we want to remove. - $removeTargets = $this->getSubmitValue('removeCat'); - // If the array is not empty, then scoot through it and remove - // any of the categories form the memCats array so they won't - // show up again. - if (!empty($removeTargets)) { - foreach ($removeTargets as $k => $v) { - unset($memCats[$v]); - } - } - } - - // Unset the blank key so the sql query doesn't puke when trying to - // add it into the DB. The blank key will occur if no cat is selected. - // its the default option for the select list. - unset($memCats['']); - $this->memberCategories = $memCats; - } catch (PDOException $e) { - Toolkit_Common::handleError($e); - } - } - - // }}} - // {{{ setupRenderers() + ORDER BY member_category_id"; + $stmt = $this->dbh->prepare($sql); + $stmt->bindParam(':id', $member_id, PDO::PARAM_INT); + $stmt->execute(); + + while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) { + $memCats[$row['category_id']] = true; + } + + // If we submitted the form: + // 1. Get all the member_cat values on the form that were submitted. + // If we flip the key/value pairs when we add the submitted values + // we won't have to worry about checking for duplicate cats submitted. + // 2. If we clicked on a remove button determine the x/y coords + // (hint: the coords will be empty if we didn't click on one). + // if the coords are not empty, then remove the category we clicked + // on, it will be the removeCat form element. + if ($this->isSubmitted()) { + if (!is_array($memCats)) { + $memCats = array(); + } + $submittedMemberCats = $this->getSubmitValue('member_cats'); + if (is_array($submittedMemberCats) && !empty($submittedMemberCats)) { + $memCats += array_flip($this->getSubmitValue('member_cats')); + } + // Holds a possible array of category id's we want to remove. + $removeTargets = $this->getSubmitValue('removeCat'); + // If the array is not empty, then scoot through it and remove + // any of the categories form the memCats array so they won't + // show up again. + if (!empty($removeTargets)) { + foreach ($removeTargets as $k => $v) { + unset($memCats[$v]); + } + } + } + + // Unset the blank key so the sql query doesn't puke when trying to + // add it into the DB. The blank key will occur if no cat is selected. + // its the default option for the select list. + unset($memCats['']); + $this->memberCategories = $memCats; + } catch (PDOException $e) { + Toolkit_Common::handleError($e); + } + } + + // }}} + // {{{ setupRenderers() /** * Short description for function @@ -2556,28 +2564,28 @@ class Toolkit_Members_EditMemberInfo * @return void * @access protected */ - protected function setupRenderers() - { - $renderer = new HTML_QuickForm_Renderer_Object(true); + protected function setupRenderers() + { + $renderer = new HTML_QuickForm_Renderer_Object(true); - $this->accept($renderer); + $this->accept($renderer); - $this->template = new HTML_Template_Flexy($this->flexyOptions); + $this->template = new HTML_Template_Flexy($this->flexyOptions); $m = new Toolkit_Members_RecordNavigation($this->config); $m->setupAdminNavStructure(); - // Make the view a copy of the $this object - // That way we have access to call functions in - // this class from within the template. - $this->view = $this; + // Make the view a copy of the $this object + // That way we have access to call functions in + // this class from within the template. + $this->view = $this; $this->view->baseUrl = BASE_URL; - $this->view->form = $renderer->toObject(); + $this->view->form = $renderer->toObject(); $this->view->nav = $m->getPageNav(); - $this->template->compile($this->formTemplate); - } + $this->template->compile($this->formTemplate); + } - // }}} - // {{{ showCategories() + // }}} + // {{{ showCategories() /** * Creates the tags for the member categories @@ -2585,79 +2593,79 @@ class Toolkit_Members_EditMemberInfo * @return string set of tags for categories assigned to a member * @access public */ - public function showCategories() - { - if (!empty($this->memberCategories)) { - try { - $sql = " - SELECT * - FROM category - WHERE category_id = :cid"; - $stmt = $this->dbh->prepare($sql); - $out = ''; - foreach ($this->memberCategories as $cid => $v) { - $stmt->bindParam(':cid', $cid, PDO::PARAM_INT); - $stmt->execute(); - $category = $stmt->fetch(PDO::FETCH_ASSOC); - - $out .= ''; - $out .= ''; - $out .= ''; - $out .= $category['name']; - $out .= ''; - } - } catch (PDOException $e) { - return Toolkit_Common::handleError($e); - } - } - - return $out; - } - - // }}} - - // {{{ toHTML() - - /** - * Renders the form - * - * sets the page the form should be redirected to instead of coming back - * around to itself. - * - * @return string The rendered form - * @access public - */ - public function toHTML() - { - // We need to validate (and freeze if needed) - // before we render the form. That way the - // template knows about any errors on the form. - $this->validated = $this->validate(); + public function showCategories() + { + if (!empty($this->memberCategories)) { + try { + $sql = " + SELECT * + FROM category + WHERE category_id = :cid"; + $stmt = $this->dbh->prepare($sql); + $out = ''; + foreach ($this->memberCategories as $cid => $v) { + $stmt->bindParam(':cid', $cid, PDO::PARAM_INT); + $stmt->execute(); + $category = $stmt->fetch(PDO::FETCH_ASSOC); + + $out .= ''; + $out .= ''; + $out .= ''; + $out .= $category['name']; + $out .= ''; + } + } catch (PDOException $e) { + return Toolkit_Common::handleError($e); + } + } + + return $out; + } + + // }}} + + // {{{ toHTML() + + /** + * Renders the form + * + * sets the page the form should be redirected to instead of coming back + * around to itself. + * + * @return string The rendered form + * @access public + */ + public function toHTML() + { + // We need to validate (and freeze if needed) + // before we render the form. That way the + // template knows about any errors on the form. + $this->validated = $this->validate(); // var_dump($this); // exit; - if ($this->validated) { + if ($this->validated) { // die('here'); - $processed = $this->process(array(&$this, 'processData'), $this->mergeFiles); - } + $processed = $this->process(array(&$this, 'processData'), $this->mergeFiles); + } - // ProcessData handles settingup the lat/lon coordinates if they were not entered - // into the form. these values ar calculated and then inserted into the forms - // element values. So we need to process the data first and then render the form. - $this->setupRenderers(); + // ProcessData handles settingup the lat/lon coordinates if they were not entered + // into the form. these values ar calculated and then inserted into the forms + // element values. So we need to process the data first and then render the form. + $this->setupRenderers(); // - return $this->template->bufferedOutputObject($this->view); - } + return $this->template->bufferedOutputObject($this->view); + } - // }}} + // }}} - // {{{ updateData() + // {{{ updateData() /** * Update the record data @@ -2667,8 +2675,8 @@ class Toolkit_Members_EditMemberInfo * @return object True on success * @access public */ - public function updateData($values) - { + public function updateData($values) + { $addressUpdated = false; $currentAddress = $this->getCurrentAddress(); @@ -2684,228 +2692,228 @@ class Toolkit_Members_EditMemberInfo $values['lon'] = ''; } - $member_id = $_GET['id']; - // {{{ Golfing - - // Remove Golf Fields for Special Insert. - $fields = array( - 'par', - 'yardage', - 'course_rating', - 'slope_rating', - 'walking_course', - 'holes18', - 'holes9', - ); - - foreach ($fields as $v) { - $golfFields[$v] = $values[$v]; - unset($values[$v]); - } - - // }}} - // {{{ Accommodations - - // Remove Accommodation Fields for Special Insert. - $fields = array( - 'reservation_url', - 'reservation_id', - 'num_rooms', - 'year_round', - ); - foreach ($fields as $v) { - $accommodationFields[$v] = $values[$v]; - unset($values[$v]); - } - - // }}} - // {{{ Restaurant - - // Remove Restaurant Fields for Special Insert. - $fields = array( - 'breakfast', - 'breakfast_from', - 'breakfast_to', - 'brunch', - 'brunch_from', - 'brunch_to', - 'lunch', - 'lunch_from', - 'lunch_to', - 'dinner', - 'dinner_from', - 'dinner_to', - 'alcohol', - 'non_smoking', - ); - foreach ($fields as $v) { - $restaurantFields[$v] = $values[$v]; - unset($values[$v]); - } - - // }}} - - if (empty($values['lat']) || empty($values['lon'])) { - try { - $this->setLatLngCoords($values); - } catch (Exception $e) { - return Toolkit_Common::handleError($e); - } - } - - // Remove values not wanted before we get all the member categories. - if (isset($values['removeCat'])) { - // So remove them before we get the categories to insert for the member. - $this->removeCategories($values['removeCat'], $values['member_cats']); - } - // Now get the cats so we can insert them into a seperate table later. - $categories = $values['member_cats']; - - $ccards = $values['creditCards']; - unset($values['member_cats'], - $values['removeCat'], - $values['creditCards'] - ); - - try { - $params = array_keys($values); - $length = count($params); - for ($i = 0; $i < $length; ++$i) { - $bindParams .= "{$params[$i]} = :{$params[$i]}"; + $member_id = $_GET['id']; + // {{{ Golfing + + // Remove Golf Fields for Special Insert. + $fields = array( + 'par', + 'yardage', + 'course_rating', + 'slope_rating', + 'walking_course', + 'holes18', + 'holes9', + ); + + foreach ($fields as $v) { + $golfFields[$v] = $values[$v]; + unset($values[$v]); + } + + // }}} + // {{{ Accommodations + + // Remove Accommodation Fields for Special Insert. + $fields = array( + 'reservation_url', + 'reservation_id', + 'num_rooms', + 'year_round', + ); + foreach ($fields as $v) { + $accommodationFields[$v] = $values[$v]; + unset($values[$v]); + } + + // }}} + // {{{ Restaurant + + // Remove Restaurant Fields for Special Insert. + $fields = array( + 'breakfast', + 'breakfast_from', + 'breakfast_to', + 'brunch', + 'brunch_from', + 'brunch_to', + 'lunch', + 'lunch_from', + 'lunch_to', + 'dinner', + 'dinner_from', + 'dinner_to', + 'alcohol', + 'non_smoking', + ); + foreach ($fields as $v) { + $restaurantFields[$v] = $values[$v]; + unset($values[$v]); + } + + // }}} + + if (empty($values['lat']) || empty($values['lon'])) { + try { + $this->setLatLngCoords($values); + } catch (Exception $e) { + return Toolkit_Common::handleError($e); + } + } + + // Remove values not wanted before we get all the member categories. + if (isset($values['removeCat'])) { + // So remove them before we get the categories to insert for the member. + $this->removeCategories($values['removeCat'], $values['member_cats']); + } + // Now get the cats so we can insert them into a seperate table later. + $categories = $values['member_cats']; + + $ccards = $values['creditCards']; + unset($values['member_cats'], + $values['removeCat'], + $values['creditCards'] + ); + + try { + $params = array_keys($values); + $length = count($params); + for ($i = 0; $i < $length; ++$i) { + $bindParams .= "{$params[$i]} = :{$params[$i]}"; if ($i < ($length - 1)) { $bindParams .= ', '; } - } - $this->dbh->beginTransaction(); - $sql = " - UPDATE {$this->tableName} - SET $bindParams - WHERE member_id = :member_id"; - $stmt = $this->dbh->prepare($sql); - $stmt->bindParam(':member_id', $member_id, PDO::PARAM_INT); - foreach ($values as $k => &$v) { - $metaData = $this->tableMetaData[$k]; - if ($metaData == 'integer') { - $dataType = PDO::PARAM_INT; - } else if ($metaData == 'boolean') { - $dataType = PDO::PARAM_BOOL; - } else { - $dataType = PDO::PARAM_STR; - } - // for empty values that are not actually a zero (0), we - // want to insert null's. - // This will help hold the unique values for member_logins, - // as empty values '', are not considered unique - if (empty($v) && $v !== 0) { - $v = null; - $dataType = PDO::PARAM_NULL; - } - $stmt->bindParam(":$k", $v, $dataType); - } - $stmt->execute(); - - // Handle updating the credit cards - $sql = " + } + $this->dbh->beginTransaction(); + $sql = " + UPDATE {$this->tableName} + SET $bindParams + WHERE member_id = :member_id"; + $stmt = $this->dbh->prepare($sql); + $stmt->bindParam(':member_id', $member_id, PDO::PARAM_INT); + foreach ($values as $k => &$v) { + $metaData = $this->tableMetaData[$k]; + if ($metaData == 'integer') { + $dataType = PDO::PARAM_INT; + } else if ($metaData == 'boolean') { + $dataType = PDO::PARAM_BOOL; + } else { + $dataType = PDO::PARAM_STR; + } + // for empty values that are not actually a zero (0), we + // want to insert null's. + // This will help hold the unique values for member_logins, + // as empty values '', are not considered unique + if (empty($v) && $v !== 0) { + $v = null; + $dataType = PDO::PARAM_NULL; + } + $stmt->bindParam(":$k", $v, $dataType); + } + $stmt->execute(); + + // Handle updating the credit cards + $sql = " DELETE FROM member_ccard_type WHERE member_id = :id"; - $stmt = $this->dbh->prepare($sql); - $stmt->bindParam(':id', $member_id, PDO::PARAM_INT); - $stmt->execute(); - - if (is_array($ccards)) { - $sql = " - INSERT INTO member_ccard_type (member_id, ccard_type_id) - SELECT :id, ccard_type_id - FROM ccard_type - WHERE ccard_type_name = :cctn"; - $stmt = $this->dbh->prepare($sql); - $stmt->bindParam(':id', $member_id, PDO::PARAM_INT); - foreach ($ccards as $k => &$v) { - if ($v) { - $stmt->bindParam(':cctn', $k, PDO::PARAM_STR); - $stmt->execute(); - } - } - } - - // Handle updating the categories - $sql = " + $stmt = $this->dbh->prepare($sql); + $stmt->bindParam(':id', $member_id, PDO::PARAM_INT); + $stmt->execute(); + + if (is_array($ccards)) { + $sql = " + INSERT INTO member_ccard_type (member_id, ccard_type_id) + SELECT :id, ccard_type_id + FROM ccard_type + WHERE ccard_type_name = :cctn"; + $stmt = $this->dbh->prepare($sql); + $stmt->bindParam(':id', $member_id, PDO::PARAM_INT); + foreach ($ccards as $k => &$v) { + if ($v) { + $stmt->bindParam(':cctn', $k, PDO::PARAM_STR); + $stmt->execute(); + } + } + } + + // Handle updating the categories + $sql = " DELETE FROM member_category WHERE member_id = :id"; - $stmt = $this->dbh->prepare($sql); - $stmt->bindParam(':id', $member_id, PDO::PARAM_INT); - $stmt->execute(); + $stmt = $this->dbh->prepare($sql); + $stmt->bindParam(':id', $member_id, PDO::PARAM_INT); + $stmt->execute(); - if (is_array($categories)) { - $sql = " + if (is_array($categories)) { + $sql = " INSERT INTO member_category (member_id, category_id) VALUES (:member_id, :cid)"; - $stmt = $this->dbh->prepare($sql); - $stmt->bindParam(':member_id', $member_id, PDO::PARAM_INT); - foreach ($categories as &$cid) { - if (!empty($cid)) { - $stmt->bindParam(':cid', $cid, PDO::PARAM_INT); - $stmt->execute(); - } - } - } - - $golf = $restaurant = $accommodations = false; - if (!empty($categories)) { - $sql = " - SELECT * - FROM category - WHERE category_id = :cid"; - $stmt = $this->dbh->prepare($sql); - foreach ($categories as &$cid) { - if (!empty($cid)) { - $stmt->bindParam(':cid', $cid, PDO::PARAM_INT); - $stmt->execute(); - $row = $stmt->fetch(PDO::FETCH_ASSOC); - // If any of the module statuses are true, set them. - // otherwise leave them as they were, (we don't want - // to set a true back to a false). - $golf = ($row['golf'] == 't') ? true : $golf; - $accommodations = ($row['accommodations'] == 't') ? - true : $accommodations; - $restaurant = ($row['restaurant'] == 't') ? - true : $restaurant; - } - } - } - $this->clearModule('member_golf'); - if ($golf) { - $this->updateModuleFields($golfFields, 'member_golf'); - } - $this->clearModule('member_accommodations'); - if ($accommodations) { - $this->updateModuleFields($accommodationFields, 'member_accommodations'); - } - $this->clearModule('member_restaurants'); - if ($restaurant) { - $this->updateModuleFields($restaurantFields, 'member_restaurants'); - } + $stmt = $this->dbh->prepare($sql); + $stmt->bindParam(':member_id', $member_id, PDO::PARAM_INT); + foreach ($categories as &$cid) { + if (!empty($cid)) { + $stmt->bindParam(':cid', $cid, PDO::PARAM_INT); + $stmt->execute(); + } + } + } + + $golf = $restaurant = $accommodations = false; + if (!empty($categories)) { + $sql = " + SELECT * + FROM category + WHERE category_id = :cid"; + $stmt = $this->dbh->prepare($sql); + foreach ($categories as &$cid) { + if (!empty($cid)) { + $stmt->bindParam(':cid', $cid, PDO::PARAM_INT); + $stmt->execute(); + $row = $stmt->fetch(PDO::FETCH_ASSOC); + // If any of the module statuses are true, set them. + // otherwise leave them as they were, (we don't want + // to set a true back to a false). + $golf = ($row['golf'] == 't') ? true : $golf; + $accommodations = ($row['accommodations'] == 't') ? + true : $accommodations; + $restaurant = ($row['restaurant'] == 't') ? + true : $restaurant; + } + } + } + $this->clearModule('member_golf'); + if ($golf) { + $this->updateModuleFields($golfFields, 'member_golf'); + } + $this->clearModule('member_accommodations'); + if ($accommodations) { + $this->updateModuleFields($accommodationFields, 'member_accommodations'); + } + $this->clearModule('member_restaurants'); + if ($restaurant) { + $this->updateModuleFields($restaurantFields, 'member_restaurants'); + } $cache = new Cache_Lite(Toolkit_Members::getCacheOptions()); - $cache->remove("Member-{$_GET['id']}", 'Profile'); + $cache->remove("Member-{$_GET['id']}", 'Profile'); - $ret = $this->dbh->commit(); + $ret = $this->dbh->commit(); $this->addMemberToStreamSend($_GET['id']); return $ret; - } catch (PDOException $e) { - $this->dbh->rollBack(); - return Toolkit_Common::handleError($e); - } - } + } catch (PDOException $e) { + $this->dbh->rollBack(); + return Toolkit_Common::handleError($e); + } + } - // }}} - // {{{ updateModuleFields() + // }}} + // {{{ updateModuleFields() - // member_id in the params is for inserting the data if the form fails validation - // first and comes back around and module categories will be included on the form - // and you need to be able to insert the data and associate to the member. + // member_id in the params is for inserting the data if the form fails validation + // first and comes back around and module categories will be included on the form + // and you need to be able to insert the data and associate to the member. /** @@ -2920,75 +2928,75 @@ class Toolkit_Members_EditMemberInfo * @return object Return description (if any) ... * @access protected */ - protected function updateModuleFields( + protected function updateModuleFields( $values, $tableName, $member_id = null ) { - $this->tableMetaData = Toolkit_Common::getTableMetaData( + $this->tableMetaData = Toolkit_Common::getTableMetaData( $this->dbh, $tableName ); - $values['member_id'] = !is_null($member_id) + $values['member_id'] = !is_null($member_id) ? $member_id : $_GET['id']; - try { - $params = implode(', ', array_keys($values)); - $bindParams = ':' . implode(', :', array_keys($values)); - $sql = " + try { + $params = implode(', ', array_keys($values)); + $bindParams = ':' . implode(', :', array_keys($values)); + $sql = " INSERT INTO $tableName ($params) VALUES ($bindParams)"; - $stmt = $this->dbh->prepare($sql); - foreach ($values as $k => &$v) { - $metaData = $this->tableMetaData[$k]; - if ($metaData == 'integer') { - $dataType = PDO::PARAM_INT; - } else if ($metaData == 'boolean') { - $dataType = PDO::PARAM_BOOL; - } else { - $dataType = PDO::PARAM_STR; - } - // for empty values that are not actually a zero (0), we - // want to insert null's. - // This will help hold the unique values for member_logins, - // as empty values '', are not considered unique - if (empty($v) && $v !== 0) { - $v = null; - $dataType = PDO::PARAM_NULL; - } - $stmt->bindParam(":$k", $v, $dataType); - } - return $stmt->execute(); - } catch (PDOException $e) { - return Toolkit_Common::handleError($e); - } - } - - // }}} - - // {{{ validated() - - /** - * Checks if the form is validated - * - * If the form is validated display the success msg. - * If the form is submitted but not validated, display - * the error msg. Other wise display nothing. - * - * This function is called from within the template. - * - * @return string The success or error msg for the user. - * @access protected - */ - public function validated() - { - if ($this->validated) { - return $this->successMsg; - } elseif ($this->isSubmitted()) { - return $this->errorMsg; - } - } - - // }}} + $stmt = $this->dbh->prepare($sql); + foreach ($values as $k => &$v) { + $metaData = $this->tableMetaData[$k]; + if ($metaData == 'integer') { + $dataType = PDO::PARAM_INT; + } else if ($metaData == 'boolean') { + $dataType = PDO::PARAM_BOOL; + } else { + $dataType = PDO::PARAM_STR; + } + // for empty values that are not actually a zero (0), we + // want to insert null's. + // This will help hold the unique values for member_logins, + // as empty values '', are not considered unique + if (empty($v) && $v !== 0) { + $v = null; + $dataType = PDO::PARAM_NULL; + } + $stmt->bindParam(":$k", $v, $dataType); + } + return $stmt->execute(); + } catch (PDOException $e) { + return Toolkit_Common::handleError($e); + } + } + + // }}} + + // {{{ validated() + + /** + * Checks if the form is validated + * + * If the form is validated display the success msg. + * If the form is submitted but not validated, display + * the error msg. Other wise display nothing. + * + * This function is called from within the template. + * + * @return string The success or error msg for the user. + * @access protected + */ + public function validated() + { + if ($this->validated) { + return $this->successMsg; + } elseif ($this->isSubmitted()) { + return $this->errorMsg; + } + } + + // }}} } ?> diff --git a/Toolkit/Members/EditMemberOnlyInfo.php b/Toolkit/Members/EditMemberOnlyInfo.php index 68ea7a5..865e6b4 100644 --- a/Toolkit/Members/EditMemberOnlyInfo.php +++ b/Toolkit/Members/EditMemberOnlyInfo.php @@ -1,5 +1,5 @@ - * @license http://www.gaslightmedia.com Gaslightmedia + * @license http://www.gaslightmedia.com Gaslightmedia * @version CVS: $Id: EditMemberOnlyInfo.php,v 1.27 2010/03/12 18:22:53 jamie Exp $ - * @link http://demo.gaslightmedia.com + * @link http://demo.gaslightmedia.com */ /** @@ -33,47 +33,47 @@ * @package Toolkit_Members * @author Jamie Kahgee * @copyright 2008 Gaslight Media - * @license http://www.gaslightmedia.com Gaslightmedia + * @license http://www.gaslightmedia.com Gaslightmedia * @link http://demo.gaslightmedia.com * @see Toolkit_Members, member_admin */ class Toolkit_Members_EditMemberOnlyInfo extends Toolkit_Members_EditMemberInfo implements Toolkit_Form { - // {{{ properties - - /** - * Set all the tables in the DB that hold the module info - * - * @var string - * @access protected - */ - protected $moduleTables = array( - 'member_golf' => array(), - 'member_restaurants' => array(), - 'member_accommodations' => array(), - ); - - /** - * All the default data - * - * When we load the default data (member record from the database), we will - * store all that data in this variable. That way when we process the form - * we will have all the information to compare against, so we can find the - * updates. - * - * @var string - * @access protected - */ - protected $oldData; - - // }}} - - // {{{ __construct() - - /** - * Class constructor - * + // {{{ properties + + /** + * Set all the tables in the DB that hold the module info + * + * @var string + * @access protected + */ + protected $moduleTables = array( + 'member_golf' => array(), + 'member_restaurants' => array(), + 'member_accommodations' => array(), + ); + + /** + * All the default data + * + * When we load the default data (member record from the database), we will + * store all that data in this variable. That way when we process the form + * we will have all the information to compare against, so we can find the + * updates. + * + * @var string + * @access protected + */ + protected $oldData; + + // }}} + + // {{{ __construct() + + /** + * Class constructor + * * @param PDO $pdo PHP Data Object to use for DB calls * @param string $formName Form's name. * @param string $method (optional)Form's method defaults to 'POST' @@ -81,12 +81,12 @@ class Toolkit_Members_EditMemberOnlyInfo * @param string $target (optional)Form's target defaults to '_self' * @param mixed $attributes (optional)Extra attributes for tag * @param bool $trackSubmit (optional)Whether to track if the form was - * submitted by adding a special hidden field + * submitted by adding a special hidden field * - * @access public - * @see Toolkit_Members_EditMemberInfo - */ - public function __construct( + * @access public + * @see Toolkit_Members_EditMemberInfo + */ + public function __construct( PDO $pdo, $formName, $method = 'post', @@ -95,7 +95,7 @@ class Toolkit_Members_EditMemberOnlyInfo $attributes = null, $trackSubmit = false ) { - parent::__construct( + parent::__construct( $pdo, $formName, $method, @@ -104,223 +104,223 @@ class Toolkit_Members_EditMemberOnlyInfo $attributes, $trackSubmit ); - $this->setPending(); - // Unset this so it won't get displayed. - $this->successMsg = null; - } - - // }}} - - // {{{ configureDefaults() - - /** - * Loads default values for the form - * - * Setup the members default values to load into the form. - * Copy all these values, which is the old data we will use to compare - * against when the form is submitted to determine the updates, into - * the oldData variable. - * - * @return array default values - * @access protected - */ - public function configureDefaults() - { - $this->oldData = parent::configureDefaults(); - - try { - $sql = " + $this->setPending(); + // Unset this so it won't get displayed. + $this->successMsg = null; + } + + // }}} + + // {{{ configureDefaults() + + /** + * Loads default values for the form + * + * Setup the members default values to load into the form. + * Copy all these values, which is the old data we will use to compare + * against when the form is submitted to determine the updates, into + * the oldData variable. + * + * @return array default values + * @access protected + */ + public function configureDefaults() + { + $this->oldData = parent::configureDefaults(); + + try { + $sql = " SELECT field, 'update' FROM {$this->pendingTable} WHERE id in ( - SELECT max(id) - FROM {$this->pendingTable} - WHERE member_id = :member_id - AND (db_table = 'member' OR - db_table = 'member_ccard_type' OR - db_table = 'member_accommodations' OR - db_table = 'member_restaurants' OR - db_table = 'member_golf') - GROUP BY field)"; - $stmt = $this->dbh->prepare($sql); - $stmt->bindParam(':member_id', $_GET['id'], PDO::PARAM_INT); - $stmt->execute(); - while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) { - if ($row['field'] == 'logo') { - $this->oldData['old_logo_rmv'] = $row['update']; - $row['update'] = ''.$row['update'].''; - $row['field'] = 'image_rmv'; - } - $this->oldData[$row['field']] = $row['update']; - } - return $this->setupDefaults($this->oldData); - } catch (PDOException $e) { - return Toolkit_Common::handleError($e); - } - } - - // }}} - // {{{ configureElements() - - /** - * Setup the elements to use on the form. - * - * Categories are populated into the protected class property $categories. - * These categories are used to populate the select list of categories. - * Modules are configured before any elements are setup, that way we will - * know if we need to include them in the rendering of the form. - * - * @return void - * @access public - */ - public function configureElements() - { - $e = array(); - - $singularType = $this->config - ->getItem('section', 'listing type') - ->getItem('directive', 'singular') - ->getContent(); - $pluralType = $this->config - ->getItem('section', 'listing type') - ->getItem('directive', 'plural') - ->getContent(); - $useCtrlCities = $this->config - ->getItem('section', 'conf') - ->getItem('directive', 'controlledCities') - ->getContent(); - $allowRegions = $this->config - ->getItem('section', 'conf') - ->getItem('directive', 'regions') - ->getContent(); - $usesGlmReservations= $this->config - ->getItem('section', 'conf') - ->getItem('directive', 'glmReservations') - ->getContent(); - - $this->setupFormCategories(); - $this->configureModules(); - - $this->getCategories(); - - // All Grouped Elements are created here. - // All Elements are created here. This includes group element definitions. - - // {{{ Member Information - - $e[] = array( - 'type' => 'header', - 'req' => false, - 'name' => 'memberInfoHdr', - 'display' => "$singularType Information", - 'col1' => true - ); - $e[] = array( - 'type' => 'text', - 'req' => false, - 'name' => 'primary_contact_fname', - 'display' => 'Primary Contact First Name', - 'opts' => array('class' => 'text') - ); - $e[] = array( - 'type' => 'text', - 'req' => false, - 'name' => 'primary_contact_lname', - 'display' => 'Primary Contact Last Name', - 'opts' => array('class' => 'text') - ); - $e[] = array( - 'type' => 'text', - 'req' => false, - 'name' => 'process_email', - 'display' => 'Primary Contact Email', - 'opts' => array('class' => 'text') - ); - $e[] = array( - 'type' => 'text', - 'req' => false, - 'name' => 'phone', - 'display' => 'Primary Phone', - 'opts' => array('class' => 'text') - ); - $e[] = array( - 'type' => 'text', - 'req' => false, - 'name' => 'toll_free', - 'display' => 'Phone 2', - 'opts' => array('class' => 'text') - ); - $e[] = array( - 'type' => 'text', - 'req' => false, - 'name' => 'fax', - 'display' => 'Fax Number', - 'opts' => array('class' => 'text') - ); - $e[] = array( - 'type' => 'text', - 'req' => false, - 'name' => 'member_contact_email', - 'display' => 'Email on Website', - 'opts' => array('class' => 'text') - ); - /* - $e[] = array( - 'type' => 'select', - 'req' => false, - 'name' => 'country', - 'display' => 'Country', - 'opts' => array( - '' => '-- Select Country --', - 'USA' => 'USA', - 'Canada' => 'Canada' - ) - ); - */ - $e[] = array( - 'type' => 'text', - 'req' => false, - 'name' => 'url', - 'display' => 'Website Address', - 'opts' => array('class' => 'text'), + SELECT max(id) + FROM {$this->pendingTable} + WHERE member_id = :member_id + AND (db_table = 'member' OR + db_table = 'member_ccard_type' OR + db_table = 'member_accommodations' OR + db_table = 'member_restaurants' OR + db_table = 'member_golf') + GROUP BY field)"; + $stmt = $this->dbh->prepare($sql); + $stmt->bindParam(':member_id', $_GET['id'], PDO::PARAM_INT); + $stmt->execute(); + while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) { + if ($row['field'] == 'logo') { + $this->oldData['old_logo_rmv'] = $row['update']; + $row['update'] = ''.$row['update'].''; + $row['field'] = 'image_rmv'; + } + $this->oldData[$row['field']] = $row['update']; + } + return $this->setupDefaults($this->oldData); + } catch (PDOException $e) { + return Toolkit_Common::handleError($e); + } + } + + // }}} + // {{{ configureElements() + + /** + * Setup the elements to use on the form. + * + * Categories are populated into the protected class property $categories. + * These categories are used to populate the select list of categories. + * Modules are configured before any elements are setup, that way we will + * know if we need to include them in the rendering of the form. + * + * @return void + * @access public + */ + public function configureElements() + { + $e = array(); + + $singularType = $this->config + ->getItem('section', 'listing type') + ->getItem('directive', 'singular') + ->getContent(); + $pluralType = $this->config + ->getItem('section', 'listing type') + ->getItem('directive', 'plural') + ->getContent(); + $useCtrlCities = $this->config + ->getItem('section', 'conf') + ->getItem('directive', 'controlledCities') + ->getContent(); + $allowRegions = $this->config + ->getItem('section', 'conf') + ->getItem('directive', 'regions') + ->getContent(); + $usesGlmReservations= $this->config + ->getItem('section', 'conf') + ->getItem('directive', 'glmReservations') + ->getContent(); + + $this->setupFormCategories(); + $this->configureModules(); + + $this->getCategories(); + + // All Grouped Elements are created here. + // All Elements are created here. This includes group element definitions. + + // {{{ Member Information + + $e[] = array( + 'type' => 'header', + 'req' => false, + 'name' => 'memberInfoHdr', + 'display' => "$singularType Information", + 'col1' => true + ); + $e[] = array( + 'type' => 'text', + 'req' => false, + 'name' => 'primary_contact_fname', + 'display' => 'Primary Contact First Name', + 'opts' => array('class' => 'text') + ); + $e[] = array( + 'type' => 'text', + 'req' => false, + 'name' => 'primary_contact_lname', + 'display' => 'Primary Contact Last Name', + 'opts' => array('class' => 'text') + ); + $e[] = array( + 'type' => 'text', + 'req' => false, + 'name' => 'process_email', + 'display' => 'Primary Contact Email', + 'opts' => array('class' => 'text') + ); + $e[] = array( + 'type' => 'text', + 'req' => false, + 'name' => 'phone', + 'display' => 'Primary Phone', + 'opts' => array('class' => 'text') + ); + $e[] = array( + 'type' => 'text', + 'req' => false, + 'name' => 'toll_free', + 'display' => 'Phone 2', + 'opts' => array('class' => 'text') + ); + $e[] = array( + 'type' => 'text', + 'req' => false, + 'name' => 'fax', + 'display' => 'Fax Number', + 'opts' => array('class' => 'text') + ); + $e[] = array( + 'type' => 'text', + 'req' => false, + 'name' => 'member_contact_email', + 'display' => 'Email on Website', + 'opts' => array('class' => 'text') + ); + /* + $e[] = array( + 'type' => 'select', + 'req' => false, + 'name' => 'country', + 'display' => 'Country', + 'opts' => array( + '' => '-- Select Country --', + 'USA' => 'USA', + 'Canada' => 'Canada' + ) + ); + */ + $e[] = array( + 'type' => 'text', + 'req' => false, + 'name' => 'url', + 'display' => 'Website Address', + 'opts' => array('class' => 'text'), 'noCharLimit' => true - ); + ); + + // }}} + // {{{ Member Categories + + $e[] = array( + 'type' => 'header', + 'req' => false, + 'name' => 'memberCategoryHdr', + 'display' => "$singularType Categories", + 'col1' => true + ); + $e[] = array( + 'type' => 'static', + 'req' => false, + 'name' => 'member_cats[]', + 'opts' => $this->categories, + 'att' => array('id' => 'categories') + ); // }}} - // {{{ Member Categories - - $e[] = array( - 'type' => 'header', - 'req' => false, - 'name' => 'memberCategoryHdr', - 'display' => "$singularType Categories", - 'col1' => true - ); - $e[] = array( - 'type' => 'static', - 'req' => false, - 'name' => 'member_cats[]', - 'opts' => $this->categories, - 'att' => array('id' => 'categories') - ); - - // }}} - // {{{ Physical Address - - $e[] = array( - 'type' => 'header', - 'req' => false, - 'name' => 'physicalAddressHdr', - 'display' => 'Street Address', - ); - $e[] = array( - 'type' => 'text', - 'req' => false, - 'name' => 'street', - 'display' => 'Street Address', - 'opts' => array('class' => 'text') - ); + // {{{ Physical Address + + $e[] = array( + 'type' => 'header', + 'req' => false, + 'name' => 'physicalAddressHdr', + 'display' => 'Street Address', + ); + $e[] = array( + 'type' => 'text', + 'req' => false, + 'name' => 'street', + 'display' => 'Street Address', + 'opts' => array('class' => 'text') + ); if ($useCtrlCities) { $e[] = array( 'type' => 'select', @@ -338,409 +338,409 @@ class Toolkit_Members_EditMemberOnlyInfo 'opts' => array('class' => 'text') ); } - $e[] = array( - 'type' => 'select', - 'req' => true, - 'name' => 'state_id', - 'display' => 'State / Province', - 'opts' => array('' => '-- Select --') + $this->states - ); - $e[] = array( - 'type' => 'text', - 'req' => true, - 'name' => 'zip', - 'display' => 'Zip / Postal Code', - 'opts' => array('class' => 'text') - ); + $e[] = array( + 'type' => 'select', + 'req' => true, + 'name' => 'state_id', + 'display' => 'State / Province', + 'opts' => array('' => '-- Select --') + $this->states + ); + $e[] = array( + 'type' => 'text', + 'req' => true, + 'name' => 'zip', + 'display' => 'Zip / Postal Code', + 'opts' => array('class' => 'text') + ); // }}} - // {{{ Mailing Address - - $e[] = array( - 'type' => 'header', - 'req' => false, - 'name' => 'MailingAddressHdrRmv', - 'display' => 'Mailing Address (if different than physical address)', - ); - $e[] = array( - 'type' => 'text', - 'req' => false, - 'name' => 'mailing_address', - 'display' => 'Mailing Address', - 'opts' => array('class' => 'text') - ); - $e[] = array( - 'type' => 'text', - 'req' => false, - 'name' => 'mailing_city', - 'display' => 'City', - 'opts' => array('class' => 'text') - ); - $e[] = array( - 'type' => 'select', - 'req' => false, - 'name' => 'mailing_state_id', - 'display' => 'State / Province', - 'opts' => array('' => '-- Select --') + $this->states - ); - $e[] = array( - 'type' => 'text', - 'req' => false, - 'name' => 'mailing_zip', - 'display' => 'Zip / Postal Code', - 'opts' => array('class' => 'text') - ); + // {{{ Mailing Address + + $e[] = array( + 'type' => 'header', + 'req' => false, + 'name' => 'MailingAddressHdrRmv', + 'display' => 'Mailing Address (if different than physical address)', + ); + $e[] = array( + 'type' => 'text', + 'req' => false, + 'name' => 'mailing_address', + 'display' => 'Mailing Address', + 'opts' => array('class' => 'text') + ); + $e[] = array( + 'type' => 'text', + 'req' => false, + 'name' => 'mailing_city', + 'display' => 'City', + 'opts' => array('class' => 'text') + ); + $e[] = array( + 'type' => 'select', + 'req' => false, + 'name' => 'mailing_state_id', + 'display' => 'State / Province', + 'opts' => array('' => '-- Select --') + $this->states + ); + $e[] = array( + 'type' => 'text', + 'req' => false, + 'name' => 'mailing_zip', + 'display' => 'Zip / Postal Code', + 'opts' => array('class' => 'text') + ); // }}} - // {{{ Member Description - - $e[] = array( - 'type' => 'header', - 'req' => false, - 'name' => 'memberDescHdr', - 'display' => "$singularType Description", - 'col1' => true - ); - $e[] = array( - 'type' => 'textarea', - 'req' => false, - 'name' => 'description', - 'display' => 'Description', - 'opts' => array( - 'id' => 'description', - 'rows' => 8, - 'cols' => 43 - ), + // {{{ Member Description + + $e[] = array( + 'type' => 'header', + 'req' => false, + 'name' => 'memberDescHdr', + 'display' => "$singularType Description", + 'col1' => true + ); + $e[] = array( + 'type' => 'textarea', + 'req' => false, + 'name' => 'description', + 'display' => 'Description', + 'opts' => array( + 'id' => 'description', + 'rows' => 8, + 'cols' => 43 + ), 'noCharLimit' => true - ); + ); // }}} - // {{{ Account Info - - $e[] = array( - 'type' => 'header', - 'req' => false, - 'name' => 'accountInfoHdr', - 'display' => 'Account Info', - 'col2' => true - ); - $e[] = array( - 'type' => 'text', - 'req' => false, - 'name' => 'member_login', - 'display' => 'Username', - 'opts' => array('class' => 'text') - ); - $e[] = array( - 'type' => 'text', - 'req' => false, - 'name' => 'member_passwd', - 'display' => 'Password', - 'opts' => array('class' => 'text') - ); + // {{{ Account Info + + $e[] = array( + 'type' => 'header', + 'req' => false, + 'name' => 'accountInfoHdr', + 'display' => 'Account Info', + 'col2' => true + ); + $e[] = array( + 'type' => 'text', + 'req' => false, + 'name' => 'member_login', + 'display' => 'Username', + 'opts' => array('class' => 'text') + ); + $e[] = array( + 'type' => 'text', + 'req' => false, + 'name' => 'member_passwd', + 'display' => 'Password', + 'opts' => array('class' => 'text') + ); // }}} - // {{{ Main Image - - $e[] = array( - 'type' => 'header', - 'req' => false, - 'name' => 'logoHdr', - 'display' => 'Main Image', - 'col2' => true - ); - if ($this->hasLogo()) { - $e[] = array( - 'type' => 'checkbox', - 'req' => false, - 'name' => 'remove_logo_rmv', - 'display' => 'Remove Image' - ); - $e[] = array( - 'type' => 'static', - 'req' => false, - 'name' => 'image_rmv', - 'display' => 'Current Image' - ); + // {{{ Main Image + + $e[] = array( + 'type' => 'header', + 'req' => false, + 'name' => 'logoHdr', + 'display' => 'Main Image', + 'col2' => true + ); + if ($this->hasLogo()) { + $e[] = array( + 'type' => 'checkbox', + 'req' => false, + 'name' => 'remove_logo_rmv', + 'display' => 'Remove Image' + ); + $e[] = array( + 'type' => 'static', + 'req' => false, + 'name' => 'image_rmv', + 'display' => 'Current Image' + ); $e[] = array( - 'type' => 'hidden', - 'req' => false, - 'name' => 'old_logo_rmv' - ); - } - - $e[] = array( - 'type' => 'file', - 'req' => false, - 'name' => 'new_logo_rmv', - 'display' => 'New Image', - 'opts' => array('class' => 'file') - ); + 'type' => 'hidden', + 'req' => false, + 'name' => 'old_logo_rmv' + ); + } + + $e[] = array( + 'type' => 'file', + 'req' => false, + 'name' => 'new_logo_rmv', + 'display' => 'New Image', + 'opts' => array('class' => 'file') + ); // }}} - // {{{ Payment Type Accepted - - $e[] = array( - 'type' => 'header', - 'req' => false, - 'name' => 'CreditCardsHdr', - 'display' => 'Payment Type Accepted', - 'col2' => true - ); - $e[] = array( - 'type' => 'advcheckbox', - 'req' => false, - 'name' => 'creditCards[American Express]', - 'display' => 'American Express', - 'val' => array(0, 1) - ); - $e[] = array( - 'type' => 'advcheckbox', - 'req' => false, - 'name' => 'creditCards[Discover]', - 'display' => 'Discover', - 'val' => array(0, 1) - ); - $e[] = array( - 'type' => 'advcheckbox', - 'req' => false, - 'name' => 'creditCards[Master Card]', - 'display' => 'Master Card', - 'val' => array(0, 1) - ); - $e[] = array( - 'type' => 'advcheckbox', - 'req' => false, - 'name' => 'creditCards[Visa]', - 'display' => 'Visa', - 'val' => array(0, 1) - ); + // {{{ Payment Type Accepted + + $e[] = array( + 'type' => 'header', + 'req' => false, + 'name' => 'CreditCardsHdr', + 'display' => 'Payment Type Accepted', + 'col2' => true + ); + $e[] = array( + 'type' => 'advcheckbox', + 'req' => false, + 'name' => 'creditCards[American Express]', + 'display' => 'American Express', + 'val' => array(0, 1) + ); + $e[] = array( + 'type' => 'advcheckbox', + 'req' => false, + 'name' => 'creditCards[Discover]', + 'display' => 'Discover', + 'val' => array(0, 1) + ); + $e[] = array( + 'type' => 'advcheckbox', + 'req' => false, + 'name' => 'creditCards[Master Card]', + 'display' => 'Master Card', + 'val' => array(0, 1) + ); + $e[] = array( + 'type' => 'advcheckbox', + 'req' => false, + 'name' => 'creditCards[Visa]', + 'display' => 'Visa', + 'val' => array(0, 1) + ); $e[] = array( - 'type' => 'advcheckbox', - 'req' => false, - 'name' => 'creditCards[Diners]', - 'display' => 'Diners' - ); + 'type' => 'advcheckbox', + 'req' => false, + 'name' => 'creditCards[Diners]', + 'display' => 'Diners' + ); // }}} - // {{{ Accommodations Information - - if ($this->accommodations) { - $e[] = array( - 'type' => 'header', - 'req' => false, - 'name' => 'AccommodationsHdr', - 'display' => 'Accommodations Information', - 'col2' => true - ); - $e[] = array( - 'type' => 'text', - 'req' => false, - 'name' => 'reservation_url', - 'display' => 'Reservation Url', - 'opts' => array('class' => 'text') - ); - if ($usesGlmReservations) { - $e[] = array( - 'type' => 'text', - 'req' => false, - 'name' => 'reservation_id', - 'display' => 'Reservation Id', - 'opts' => array('class' => 'text') - ); - } - $e[] = array( - 'type' => 'text', - 'req' => false, - 'name' => 'num_rooms', - 'display' => 'Number of Rooms', - 'opts' => array('class' => 'text') - ); - $e[] = array( - 'type' => 'advcheckbox', - 'req' => false, - 'name' => 'year_round', - 'display' => 'Open all Year', - 'val' => array(0, 1) - ); - } + // {{{ Accommodations Information + + if ($this->accommodations) { + $e[] = array( + 'type' => 'header', + 'req' => false, + 'name' => 'AccommodationsHdr', + 'display' => 'Accommodations Information', + 'col2' => true + ); + $e[] = array( + 'type' => 'text', + 'req' => false, + 'name' => 'reservation_url', + 'display' => 'Reservation Url', + 'opts' => array('class' => 'text') + ); + if ($usesGlmReservations) { + $e[] = array( + 'type' => 'text', + 'req' => false, + 'name' => 'reservation_id', + 'display' => 'Reservation Id', + 'opts' => array('class' => 'text') + ); + } + $e[] = array( + 'type' => 'text', + 'req' => false, + 'name' => 'num_rooms', + 'display' => 'Number of Rooms', + 'opts' => array('class' => 'text') + ); + $e[] = array( + 'type' => 'advcheckbox', + 'req' => false, + 'name' => 'year_round', + 'display' => 'Open all Year', + 'val' => array(0, 1) + ); + } // }}} - // {{{ Restaurant Information - - if ($this->restaurant) { - $e[] = array( - 'type' => 'header', - 'req' => false, - 'name' => 'RestaurantHdr', - 'display' => 'Restaurant Information', - 'col2' => true - ); - $e[] = array( - 'type' => 'advcheckbox', - 'req' => false, - 'name' => 'breakfast', - 'display' => 'Breakfast', - 'att' => array('id' => 'breakfast'), - 'val' => array(0, 1) - ); -// $e[] = array( -// 'type' => 'text', -// 'req' => false, -// 'name' => 'breakfast_from', -// 'display' => 'From', -// 'opts' => array('class' => 'priceFrom') -// ); -// $e[] = array( -// 'type' => 'text', -// 'req' => false, -// 'name' => 'breakfast_to', -// 'display' => 'To', -// 'opts' => array('class' => 'priceTo') -// ); - $e[] = array( - 'type' => 'advcheckbox', - 'req' => false, - 'name' => 'brunch', - 'display' => 'Brunch', - 'att' => array('id' => 'brunch'), - 'val' => array(0, 1) - ); -// $e[] = array( -// 'type' => 'text', -// 'req' => false, -// 'name' => 'brunch_from', -// 'display' => 'From', -// 'opts' => array('class' => 'priceFrom') -// ); -// $e[] = array( -// 'type' => 'text', -// 'req' => false, -// 'name' => 'brunch_to', -// 'display' => 'To', -// 'opts' => array('class' => 'priceTo') -// ); - $e[] = array( - 'type' => 'advcheckbox', - 'req' => false, - 'name' => 'lunch', - 'display' => 'Lunch', - 'att' => array('id' => 'lunch'), - 'val' => array(0, 1) - ); -// $e[] = array( -// 'type' => 'text', -// 'req' => false, -// 'name' => 'lunch_from', -// 'display' => 'From', -// 'opts' => array('class' => 'priceFrom') -// ); -// $e[] = array( -// 'type' => 'text', -// 'req' => false, -// 'name' => 'lunch_to', -// 'display' => 'To', -// 'opts' => array('class' => 'priceTo') -// ); - $e[] = array( - 'type' => 'advcheckbox', - 'req' => false, - 'name' => 'dinner', - 'display' => 'Dinner', - 'att' => array('id' => 'dinner'), - 'val' => array(0, 1) - ); -// $e[] = array( -// 'type' => 'text', -// 'req' => false, -// 'name' => 'dinner_from', -// 'display' => 'From', -// 'opts' => array('class' => 'priceFrom') -// ); -// $e[] = array( -// 'type' => 'text', -// 'req' => false, -// 'name' => 'dinner_to', -// 'display' => 'To', -// 'opts' => array('class' => 'priceTo') -// ); - $e[] = array( - 'type' => 'advcheckbox', - 'req' => false, - 'name' => 'alcohol', - 'display' => 'Alcohol', - 'val' => array(0, 1) - ); -// $e[] = array( -// 'type' => 'advcheckbox', -// 'req' => false, -// 'name' => 'non_smoking', -// 'display' => 'Non-Smoking', -// 'val' => array(0, 1) -// ); - } + // {{{ Restaurant Information + + if ($this->restaurant) { + $e[] = array( + 'type' => 'header', + 'req' => false, + 'name' => 'RestaurantHdr', + 'display' => 'Restaurant Information', + 'col2' => true + ); + $e[] = array( + 'type' => 'advcheckbox', + 'req' => false, + 'name' => 'breakfast', + 'display' => 'Breakfast', + 'att' => array('id' => 'breakfast'), + 'val' => array(0, 1) + ); +// $e[] = array( +// 'type' => 'text', +// 'req' => false, +// 'name' => 'breakfast_from', +// 'display' => 'From', +// 'opts' => array('class' => 'priceFrom') +// ); +// $e[] = array( +// 'type' => 'text', +// 'req' => false, +// 'name' => 'breakfast_to', +// 'display' => 'To', +// 'opts' => array('class' => 'priceTo') +// ); + $e[] = array( + 'type' => 'advcheckbox', + 'req' => false, + 'name' => 'brunch', + 'display' => 'Brunch', + 'att' => array('id' => 'brunch'), + 'val' => array(0, 1) + ); +// $e[] = array( +// 'type' => 'text', +// 'req' => false, +// 'name' => 'brunch_from', +// 'display' => 'From', +// 'opts' => array('class' => 'priceFrom') +// ); +// $e[] = array( +// 'type' => 'text', +// 'req' => false, +// 'name' => 'brunch_to', +// 'display' => 'To', +// 'opts' => array('class' => 'priceTo') +// ); + $e[] = array( + 'type' => 'advcheckbox', + 'req' => false, + 'name' => 'lunch', + 'display' => 'Lunch', + 'att' => array('id' => 'lunch'), + 'val' => array(0, 1) + ); +// $e[] = array( +// 'type' => 'text', +// 'req' => false, +// 'name' => 'lunch_from', +// 'display' => 'From', +// 'opts' => array('class' => 'priceFrom') +// ); +// $e[] = array( +// 'type' => 'text', +// 'req' => false, +// 'name' => 'lunch_to', +// 'display' => 'To', +// 'opts' => array('class' => 'priceTo') +// ); + $e[] = array( + 'type' => 'advcheckbox', + 'req' => false, + 'name' => 'dinner', + 'display' => 'Dinner', + 'att' => array('id' => 'dinner'), + 'val' => array(0, 1) + ); +// $e[] = array( +// 'type' => 'text', +// 'req' => false, +// 'name' => 'dinner_from', +// 'display' => 'From', +// 'opts' => array('class' => 'priceFrom') +// ); +// $e[] = array( +// 'type' => 'text', +// 'req' => false, +// 'name' => 'dinner_to', +// 'display' => 'To', +// 'opts' => array('class' => 'priceTo') +// ); + $e[] = array( + 'type' => 'advcheckbox', + 'req' => false, + 'name' => 'alcohol', + 'display' => 'Alcohol', + 'val' => array(0, 1) + ); +// $e[] = array( +// 'type' => 'advcheckbox', +// 'req' => false, +// 'name' => 'non_smoking', +// 'display' => 'Non-Smoking', +// 'val' => array(0, 1) +// ); + } // }}} - // {{{ Golf Information - - if ($this->golf) { - $e[] = array( - 'type' => 'header', - 'req' => false, - 'name' => 'GolfingHdr', - 'display' => 'Golf Course Information', - 'col2' => true - ); - $e[] = array( - 'type' => 'text', - 'req' => false, - 'name' => 'par', - 'display' => 'Par', - 'opts' => array('class' => 'text') - ); - $e[] = array( - 'type' => 'text', - 'req' => false, - 'name' => 'yardage', - 'display' => 'Yardage', - 'opts' => array('class' => 'text') - ); - $e[] = array( - 'type' => 'text', - 'req' => false, - 'name' => 'course_rating', - 'display' => 'Course Rating', - 'opts' => array('class' => 'text') - ); - $e[] = array( - 'type' => 'text', - 'req' => false, - 'name' => 'slope_rating', - 'display' => 'Slope Rating', - 'opts' => array('class' => 'text') - ); - $e[] = array( - 'type' => 'advcheckbox', - 'req' => false, - 'name' => 'walking_course', - 'display' => 'Walking Course', - 'val' => array(0, 1) - ); - $e[] = array( - 'type' => 'text', - 'req' => false, - 'name' => 'holes18', - 'display' => '18 Holes', - 'opts' => array('class' => 'text') - ); - $e[] = array( - 'type' => 'text', - 'req' => false, - 'name' => 'holes9', - 'display' => '9 Holes', - 'opts' => array('class' => 'text') - ); - } + // {{{ Golf Information + + if ($this->golf) { + $e[] = array( + 'type' => 'header', + 'req' => false, + 'name' => 'GolfingHdr', + 'display' => 'Golf Course Information', + 'col2' => true + ); + $e[] = array( + 'type' => 'text', + 'req' => false, + 'name' => 'par', + 'display' => 'Par', + 'opts' => array('class' => 'text') + ); + $e[] = array( + 'type' => 'text', + 'req' => false, + 'name' => 'yardage', + 'display' => 'Yardage', + 'opts' => array('class' => 'text') + ); + $e[] = array( + 'type' => 'text', + 'req' => false, + 'name' => 'course_rating', + 'display' => 'Course Rating', + 'opts' => array('class' => 'text') + ); + $e[] = array( + 'type' => 'text', + 'req' => false, + 'name' => 'slope_rating', + 'display' => 'Slope Rating', + 'opts' => array('class' => 'text') + ); + $e[] = array( + 'type' => 'advcheckbox', + 'req' => false, + 'name' => 'walking_course', + 'display' => 'Walking Course', + 'val' => array(0, 1) + ); + $e[] = array( + 'type' => 'text', + 'req' => false, + 'name' => 'holes18', + 'display' => '18 Holes', + 'opts' => array('class' => 'text') + ); + $e[] = array( + 'type' => 'text', + 'req' => false, + 'name' => 'holes9', + 'display' => '9 Holes', + 'opts' => array('class' => 'text') + ); + } // }}} // {{{ Social Media Links @@ -811,53 +811,53 @@ class Toolkit_Members_EditMemberOnlyInfo // }}} - $this->setupElements($e); - } - - // }}} - - // {{{ processData() - - /** - * Handles processing the submitted forms data - * - * See parent function for better description. - * - * @param array $values The array of all submitted form values. - * - * @return boolean Whether the insert/update succeeded. - * @access public - * @see Toolkit_Members_EditMemberInfo::processData() - */ - public function processData($values) - { - $id = $GLOBALS['memberAuth']->getAuthData('member_id'); + $this->setupElements($e); + } + + // }}} + + // {{{ processData() + + /** + * Handles processing the submitted forms data + * + * See parent function for better description. + * + * @param array $values The array of all submitted form values. + * + * @return boolean Whether the insert/update succeeded. + * @access public + * @see Toolkit_Members_EditMemberInfo::processData() + */ + public function processData($values) + { + $id = $GLOBALS['memberAuth']->getAuthData('member_id'); $cache = new Cache_Lite(Toolkit_Members::getCacheOptions()); $cache->remove("Member-$id", 'Profile'); - $return = parent::processData($values); - $this->setPending(); - return $return; - } + $return = parent::processData($values); + $this->setPending(); + return $return; + } - // }}} + // }}} - // {{{ setPending() + // {{{ setPending() - /** - * Determines if the member has made any update requests - * - * Any update requests that are in the member_updates table - * will let us know if this member is pending or not. - * + /** + * Determines if the member has made any update requests + * + * Any update requests that are in the member_updates table + * will let us know if this member is pending or not. + * * @return void - * @access public - */ - public function setPending() - { - unset ($this->pendingFields); - try { - $sql = " + * @access public + */ + public function setPending() + { + unset ($this->pendingFields); + try { + $sql = " SELECT DISTINCT CASE field WHEN 'lat' THEN 'latitude' @@ -867,25 +867,25 @@ class Toolkit_Members_EditMemberOnlyInfo END AS field FROM {$this->pendingTable} WHERE member_id = :member_id - AND (db_table = '{$this->tableName}' - OR db_table = 'member_ccard_type' - OR db_table = 'member_restaurants' - OR db_table = 'member_accommodations' - OR db_table = 'member_golf')"; - $stmt = $this->dbh->prepare($sql); - $stmt->bindParam(':member_id', $_GET['id'], PDO::PARAM_INT); - $stmt->execute(); - while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) { - $this->pendingFields[] = $row['field']; - } - $this->pending = (count($this->pendingFields)); - } catch (PDOException $e) { - Toolkit_Common::handleError($e); - } - } - - // }}} - // {{{ setupRenderers() + AND (db_table = '{$this->tableName}' + OR db_table = 'member_ccard_type' + OR db_table = 'member_restaurants' + OR db_table = 'member_accommodations' + OR db_table = 'member_golf')"; + $stmt = $this->dbh->prepare($sql); + $stmt->bindParam(':member_id', $_GET['id'], PDO::PARAM_INT); + $stmt->execute(); + while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) { + $this->pendingFields[] = $row['field']; + } + $this->pending = (count($this->pendingFields)); + } catch (PDOException $e) { + Toolkit_Common::handleError($e); + } + } + + // }}} + // {{{ setupRenderers() /** @@ -896,27 +896,27 @@ class Toolkit_Members_EditMemberOnlyInfo * @return void * @access protected */ - protected function setupRenderers() - { - $renderer = new HTML_QuickForm_Renderer_Object(true); + protected function setupRenderers() + { + $renderer = new HTML_QuickForm_Renderer_Object(true); - $this->accept($renderer); + $this->accept($renderer); - $this->template = new HTML_Template_Flexy($this->flexyOptions); + $this->template = new HTML_Template_Flexy($this->flexyOptions); $m = new Toolkit_Members_RecordNavigation($this->config); $m->setupUserNavStructure(); - // Make the view a copy of the $this object - // That way we have access to call functions in - // this class from within the template. - $this->view = $this; - $this->view->form = $renderer->toObject(); + // Make the view a copy of the $this object + // That way we have access to call functions in + // this class from within the template. + $this->view = $this; + $this->view->form = $renderer->toObject(); $this->view->nav = $m->getPageNav(); - $this->template->compile($this->formTemplate); - } + $this->template->compile($this->formTemplate); + } - // }}} - // {{{ showCategories() + // }}} + // {{{ showCategories() /** @@ -927,127 +927,127 @@ class Toolkit_Members_EditMemberOnlyInfo * @return string Return description (if any) ... * @access public */ - public function showCategories() - { - if (!empty($this->memberCategories)) { - try { - $sql = " - SELECT * - FROM category - WHERE category_id = :cid"; - $stmt = $this->dbh->prepare($sql); - foreach ($this->memberCategories as $cid => $v) { - $stmt->bindParam(':cid', $cid, PDO::PARAM_INT); - $stmt->execute(); - $category = $stmt->fetch(PDO::FETCH_ASSOC); - - $out .= ' - - '; - if ( defined('MEMBERS_ONLY_AREA_ON') - && MEMBERS_ONLY_AREA_ON == true - ) { - // do nothing - } else { - $out .= ' - '; - } - $out .= "{$category['name']}"; - } - } catch (PDOException $e) { - return Toolkit_Common::handleError($e); - } - } - - return $out; - } - - // }}} - - // {{{ updateData() - - /** - * Insert the values that were updated from the member only form - * - * 1. Get all the field types in the DB for the module tables - * 2. Check the module fields against the old Data (the original values - * we obtained when we got the defaults for the form). If the - * value is not the same, then add the value to the column field of - * the table in the moduleUpdates array. - * 3. Get the updates for the member record. - * 4. Insert all the updates into the member_updates table. + public function showCategories() + { + if (!empty($this->memberCategories)) { + try { + $sql = " + SELECT * + FROM category + WHERE category_id = :cid"; + $stmt = $this->dbh->prepare($sql); + foreach ($this->memberCategories as $cid => $v) { + $stmt->bindParam(':cid', $cid, PDO::PARAM_INT); + $stmt->execute(); + $category = $stmt->fetch(PDO::FETCH_ASSOC); + + $out .= ' + + '; + if ( defined('MEMBERS_ONLY_AREA_ON') + && MEMBERS_ONLY_AREA_ON == true + ) { + // do nothing + } else { + $out .= ' + '; + } + $out .= "{$category['name']}"; + } + } catch (PDOException $e) { + return Toolkit_Common::handleError($e); + } + } + + return $out; + } + + // }}} + + // {{{ updateData() + + /** + * Insert the values that were updated from the member only form + * + * 1. Get all the field types in the DB for the module tables + * 2. Check the module fields against the old Data (the original values + * we obtained when we got the defaults for the form). If the + * value is not the same, then add the value to the column field of + * the table in the moduleUpdates array. + * 3. Get the updates for the member record. + * 4. Insert all the updates into the member_updates table. * * @param array $values submitted form values - * + * * @return mixed - * @access public - */ - public function updateData($values) - { - if ($this->strictPending) { - foreach ($this->moduleTables as $tname => &$arr) { - $this->tableMetaData = Toolkit_Common::getTableMetaData( + * @access public + */ + public function updateData($values) + { + if ($this->strictPending) { + foreach ($this->moduleTables as $tname => &$arr) { + $this->tableMetaData = Toolkit_Common::getTableMetaData( $this->dbh, $tname ); - if (is_array($this->tableMetaData)) { - foreach ($this->tableMetaData as $k => $v) { - switch ($k) { - case 'id' : - case 'member_id' : - break; - - default : - $arr[$k]['data_type'] = $v; - $arr[$k]['value'] = $values[$k]; - unset($values[$k]); - break; - } - } - } - } - // Check for updates in the module tables. - foreach ($this->moduleTables as $tname => &$arr) { - foreach ($arr as $k => $v) { - if (array_key_exists($k, $this->oldData)) { - if ($v['data_type'] != 'boolean') { - if ($v['value'] != $this->oldData[$k]) { - $moduleUpdates[$tname][$k] = $v; - } - } else { - // Due to how PDO's cast a boolean value False - // to '' when you query the DB. - // we need to adjust any empty fields - // that are of data_type boolean to a 0, True - // values are queried as 1. - // See: http://bugs.php.net/bug.php?id=33876 - // for more info. - $oldData = (empty($this->oldData[$k])) ? 0 : 1; - if ($v['value'] != $oldData) { - $moduleUpdates[$tname][$k] = $v; - } - } - // If the field was set in the module Updates array - // then also try and set what type of field we are - // dealing w/ on the form. - if (isset($moduleUpdates[$tname][$k])) { - if ($this->elementExists($k)) { - $e =& $this->getElement($k); - if (PEAR::isError($e)) { - return Toolkit_Common::handleError($e); - } - $moduleUpdates[$tname][$k]['field_type'] = $e->getType(); - } - } - } - } - } - - // Need a special case for the credit cards. + if (is_array($this->tableMetaData)) { + foreach ($this->tableMetaData as $k => $v) { + switch ($k) { + case 'id' : + case 'member_id' : + break; + + default : + $arr[$k]['data_type'] = $v; + $arr[$k]['value'] = $values[$k]; + unset($values[$k]); + break; + } + } + } + } + // Check for updates in the module tables. + foreach ($this->moduleTables as $tname => &$arr) { + foreach ($arr as $k => $v) { + if (array_key_exists($k, $this->oldData)) { + if ($v['data_type'] != 'boolean') { + if ($v['value'] != $this->oldData[$k]) { + $moduleUpdates[$tname][$k] = $v; + } + } else { + // Due to how PDO's cast a boolean value False + // to '' when you query the DB. + // we need to adjust any empty fields + // that are of data_type boolean to a 0, True + // values are queried as 1. + // See: http://bugs.php.net/bug.php?id=33876 + // for more info. + $oldData = (empty($this->oldData[$k])) ? 0 : 1; + if ($v['value'] != $oldData) { + $moduleUpdates[$tname][$k] = $v; + } + } + // If the field was set in the module Updates array + // then also try and set what type of field we are + // dealing w/ on the form. + if (isset($moduleUpdates[$tname][$k])) { + if ($this->elementExists($k)) { + $e =& $this->getElement($k); + if (PEAR::isError($e)) { + return Toolkit_Common::handleError($e); + } + $moduleUpdates[$tname][$k]['field_type'] = $e->getType(); + } + } + } + } + } + + // Need a special case for the credit cards. if (is_array($values['creditCards'])) { foreach ($values['creditCards'] as $k => $v) { if (array_key_exists("creditCards[$k]", $this->oldData)) { @@ -1059,9 +1059,9 @@ class Toolkit_Members_EditMemberOnlyInfo $ccUpdates["creditCards[$k]"]['data_type'] = 'integer'; $ccUpdates["creditCards[$k]"]['value'] = $v; } - // If the credit card was set in the credit card updates array - // then also try and set what type of field we are dealing w/ - // on the form. + // If the credit card was set in the credit card updates array + // then also try and set what type of field we are dealing w/ + // on the form. if (isset($ccUpdates["creditCards[$k]"])) { if ($this->elementExists("creditCards[$k]")) { $e =& $this->getElement("creditCards[$k]"); @@ -1073,106 +1073,106 @@ class Toolkit_Members_EditMemberOnlyInfo } } } - } else { - return parent::updateData($values); - } - - $ccards = $values['creditCards']; - $pattern = '/^-?(.+)$/i'; - $replacement = '$1'; - // Adjust the lat/lon coordinates to negative #'s if needed - $coords = array('lat' => 'South', 'lon' => 'East'); - foreach ($coords as $k => $v) { - if ($values["{$k}Direction"] == $v && !empty($values[$k])) { - $string = $values[$k]; - $values[$k] = preg_replace($pattern, $replacement, $string); - $values[$k] = "-{$values[$k]}"; - } - } - unset($values['lonDirection'], - $values['latDirection'], - $values['member_cats'], - $values['creditCards'] - ); + } else { + return parent::updateData($values); + } + + $ccards = $values['creditCards']; + $pattern = '/^-?(.+)$/i'; + $replacement = '$1'; + // Adjust the lat/lon coordinates to negative #'s if needed + $coords = array('lat' => 'South', 'lon' => 'East'); + foreach ($coords as $k => $v) { + if ($values["{$k}Direction"] == $v && !empty($values[$k])) { + $string = $values[$k]; + $values[$k] = preg_replace($pattern, $replacement, $string); + $values[$k] = "-{$values[$k]}"; + } + } + unset($values['lonDirection'], + $values['latDirection'], + $values['member_cats'], + $values['creditCards'] + ); $this->tableMetaData = Toolkit_Common::getTableMetaData( $this->dbh, $this->tableName ); - // Check for updates in the member record. - // If we find any, add that field to the list of record updates - // along with what type of field it is in the member table. - // We will use the data_type field when the admin is dealing - // w/ the updates to determine values on boolean records and empty - // text field records. - foreach ($values as $k => $v) { - if (array_key_exists($k, $this->oldData)) { - if ($v != $this->oldData[$k]) { - if ($this->elementExists($k)) { - $e =& $this->getElement($k); - if (PEAR::isError($e)) { - return Toolkit_Common::handleError($e); - } - $recordUpdates[$k]['field_type'] = $e->getType(); - } - $recordUpdates[$k]['data_type'] = $this->tableMetaData[$k]; - $recordUpdates[$k]['value'] = $v; - } - } - // We need a special case for the member image. cause Its a pain - // in the ass. - if ($k == 'logo') { - if (!empty($v)) { - if (array_key_exists('old_logo_rmv', $this->oldData)) { - if ($v != $this->oldData['old_logo_rmv']) { - $recordUpdates[$k]['data_type'] = 'boolean'; - $recordUpdates[$k]['field_type'] = 'file'; - $recordUpdates[$k]['value'] = $v; - } - } - } - } - } - - // Combine the update arrays for the modules and the member record - // into one single array. The array will hold this pattern. - // An array of tables that holds an array of fields that were updated - // [DB Table] => array - // ( - // [Column Name] => array - // ( - // [data_type] => boolean / text / integer - // [field_type] => text / select / checkbox - // [value] => updated value from the form. - // ) - // ) - // Make sure to only add these array's if there is update information - // in them. - $updates = array(); - if (is_array($moduleUpdates)) { - $updates += $moduleUpdates; - } - if (is_array($recordUpdates)) { - $updates += array('member' => $recordUpdates); - } - if (is_array($ccUpdates)) { - $updates += array('member_ccard_type' => $ccUpdates); - } - - try { - // If we have an array of updates, we need to insert all the - // updates into the member_updates table. This will signal that - // the member has pending updates that the admin needs to - // authorize. - if (!empty($updates)) { - // Loop through all the elements that were updated and get - // the label we use on the form so when the admin is looking - // at the updates they will know what field its for. - // We can be sure we are getting the right label because - // there can only be unique element names in the form. - foreach ($updates as &$sec) { - foreach ($sec as $field => $v) { - switch ($field) { + // Check for updates in the member record. + // If we find any, add that field to the list of record updates + // along with what type of field it is in the member table. + // We will use the data_type field when the admin is dealing + // w/ the updates to determine values on boolean records and empty + // text field records. + foreach ($values as $k => $v) { + if (array_key_exists($k, $this->oldData)) { + if ($v != $this->oldData[$k]) { + if ($this->elementExists($k)) { + $e =& $this->getElement($k); + if (PEAR::isError($e)) { + return Toolkit_Common::handleError($e); + } + $recordUpdates[$k]['field_type'] = $e->getType(); + } + $recordUpdates[$k]['data_type'] = $this->tableMetaData[$k]; + $recordUpdates[$k]['value'] = $v; + } + } + // We need a special case for the member image. cause Its a pain + // in the ass. + if ($k == 'logo') { + if (!empty($v)) { + if (array_key_exists('old_logo_rmv', $this->oldData)) { + if ($v != $this->oldData['old_logo_rmv']) { + $recordUpdates[$k]['data_type'] = 'boolean'; + $recordUpdates[$k]['field_type'] = 'file'; + $recordUpdates[$k]['value'] = $v; + } + } + } + } + } + + // Combine the update arrays for the modules and the member record + // into one single array. The array will hold this pattern. + // An array of tables that holds an array of fields that were updated + // [DB Table] => array + // ( + // [Column Name] => array + // ( + // [data_type] => boolean / text / integer + // [field_type] => text / select / checkbox + // [value] => updated value from the form. + // ) + // ) + // Make sure to only add these array's if there is update information + // in them. + $updates = array(); + if (is_array($moduleUpdates)) { + $updates += $moduleUpdates; + } + if (is_array($recordUpdates)) { + $updates += array('member' => $recordUpdates); + } + if (is_array($ccUpdates)) { + $updates += array('member_ccard_type' => $ccUpdates); + } + + try { + // If we have an array of updates, we need to insert all the + // updates into the member_updates table. This will signal that + // the member has pending updates that the admin needs to + // authorize. + if (!empty($updates)) { + // Loop through all the elements that were updated and get + // the label we use on the form so when the admin is looking + // at the updates they will know what field its for. + // We can be sure we are getting the right label because + // there can only be unique element names in the form. + foreach ($updates as &$sec) { + foreach ($sec as $field => $v) { + switch ($field) { case 'lat' : $g =& $this->getElement('latitude'); $e =& $g->getElements(); @@ -1191,58 +1191,58 @@ class Toolkit_Members_EditMemberOnlyInfo default : $e =& $this->getElement($field); - // Check to make sure an actual element was - // returned. If a "module" is unassigned from a - // category, those elements will not be created. - // so we won't be able to get the labels for those - // elements. In this case, just use the field - // name. + // Check to make sure an actual element was + // returned. If a "module" is unassigned from a + // category, those elements will not be created. + // so we won't be able to get the labels for those + // elements. In this case, just use the field + // name. if (PEAR::isError($e)) { $sec [$field]['label'] = $field; } else { $sec[$field]['label'] = $e->getLabel(); } break; - } - } - } - $this->dbh->beginTransaction(); - - $sql = " - INSERT INTO {$this->pendingTable} (member_id, field, update, db_table, data_type, field_type, label) - VALUES (:member_id, :field, :update, :table, :data_type, :field_type, :label)"; - - $stmt = $this->dbh->prepare($sql); - $stmt->bindParam(':member_id', $GLOBALS['memberAuth']->getAuthData('member_id'), PDO::PARAM_INT); - foreach ($updates as $table => &$sec) { - $stmt->bindParam(':table', $table, PDO::PARAM_STR); - foreach ($sec as $k => &$v) { - $dataType = PDO::PARAM_STR; - // Fields that are empty which have a data_type of text - // can be inserted as NULL values. - if (empty($v['value']) && $v['data_type'] == 'text') { - $v['value'] = null; - $dataType = PDO::PARAM_NULL; - } - $stmt->bindParam(":field", $k, PDO::PARAM_STR); - $stmt->bindParam(":update", $v['value'], $dataType); - $stmt->bindParam(":data_type", $v['data_type'], PDO::PARAM_STR); - $stmt->bindParam(":field_type", $v['field_type'], PDO::PARAM_STR); - $stmt->bindParam(":label", $v['label'], PDO::PARAM_STR); - $stmt->execute(); - } - } - $this->setPending(); - $this->emailOwner(); - return $this->dbh->commit(); - } - } catch (PDOException $e) { - return Toolkit_Common::handleError($e); - } - - return; - } - - // }}} + } + } + } + $this->dbh->beginTransaction(); + + $sql = " + INSERT INTO {$this->pendingTable} (member_id, field, update, db_table, data_type, field_type, label) + VALUES (:member_id, :field, :update, :table, :data_type, :field_type, :label)"; + + $stmt = $this->dbh->prepare($sql); + $stmt->bindParam(':member_id', $GLOBALS['memberAuth']->getAuthData('member_id'), PDO::PARAM_INT); + foreach ($updates as $table => &$sec) { + $stmt->bindParam(':table', $table, PDO::PARAM_STR); + foreach ($sec as $k => &$v) { + $dataType = PDO::PARAM_STR; + // Fields that are empty which have a data_type of text + // can be inserted as NULL values. + if (empty($v['value']) && $v['data_type'] == 'text') { + $v['value'] = null; + $dataType = PDO::PARAM_NULL; + } + $stmt->bindParam(":field", $k, PDO::PARAM_STR); + $stmt->bindParam(":update", $v['value'], $dataType); + $stmt->bindParam(":data_type", $v['data_type'], PDO::PARAM_STR); + $stmt->bindParam(":field_type", $v['field_type'], PDO::PARAM_STR); + $stmt->bindParam(":label", $v['label'], PDO::PARAM_STR); + $stmt->execute(); + } + } + $this->setPending(); + $this->emailOwner(); + return $this->dbh->commit(); + } + } catch (PDOException $e) { + return Toolkit_Common::handleError($e); + } + + return; + } + + // }}} } ?> diff --git a/Toolkit/Members/ProfilePage.php b/Toolkit/Members/ProfilePage.php index 03fdc2f..6181130 100644 --- a/Toolkit/Members/ProfilePage.php +++ b/Toolkit/Members/ProfilePage.php @@ -1,5 +1,5 @@ dbh = $pdo; $this->_pageGateway = $pageGateway; $this->setMemberId($mid); @@ -83,65 +83,65 @@ class Toolkit_Members_ProfilePage // }}} - // {{{ _isNewMember() - - /** - * Determines if we are dealing w/ a new member from the addyourbusiness form - * - * @return boolean - * @access private - */ - private function _isNewMember() - { - try { - $sql = " + // {{{ _isNewMember() + + /** + * Determines if we are dealing w/ a new member from the addyourbusiness form + * + * @return boolean + * @access private + */ + private function _isNewMember() + { + try { + $sql = " SELECT new_member FROM member WHERE member_id = :mid"; - $stmt = $this->dbh->prepare($sql); - $stmt->bindParam(':mid', $this->_mid, PDO::PARAM_INT); - $stmt->execute(); - $stmt->bindColumn('new_member', $isNew); - $stmt->fetch(); + $stmt = $this->dbh->prepare($sql); + $stmt->bindParam(':mid', $this->_mid, PDO::PARAM_INT); + $stmt->execute(); + $stmt->bindColumn('new_member', $isNew); + $stmt->fetch(); - return (bool) $isNew; - } catch (PDOException $e) { - return Toolkit_Common::handleError($e); - } - } + return (bool) $isNew; + } catch (PDOException $e) { + return Toolkit_Common::handleError($e); + } + } - // }}} + // }}} - // {{{ getMemberId() + // {{{ getMemberId() /** * Description for getMemberId() * * @return integer */ - public function getMemberId() - { - return $this->_mid; - } - - // }}} - // {{{ memberActive() - - /** - * Check to make sure the member is active in the DB. - * - * @return boolean true or false if the member is active - * @access private - */ - private function _memberActive() + public function getMemberId() + { + return $this->_mid; + } + + // }}} + // {{{ memberActive() + + /** + * Check to make sure the member is active in the DB. + * + * @return boolean true or false if the member is active + * @access private + */ + private function _memberActive() { - if (!filter_var($this->_mid, FILTER_VALIDATE_INT)) { + if (!filter_var($this->_mid, FILTER_VALIDATE_INT)) { return false; } - try { - $sql = " + try { + $sql = " SELECT CASE WHEN active THEN 1 ELSE 0 @@ -149,52 +149,52 @@ class Toolkit_Members_ProfilePage FROM member WHERE member_id = :member_id"; - $stmt = $this->dbh->prepare($sql); - $stmt->bindParam(':member_id', $this->_mid, PDO::PARAM_INT); - $stmt->execute(); - $stmt->bindColumn('active', $active); - $stmt->fetch(); - - return (bool) $active; - } catch (PDOException $e) { - return Toolkit_Common::handleError($e); - } - } - - // }}} - // {{{ memberExists() - - /** - * Check to make sure the member exists in the database - * - * @return boolean true or false if the member exists - * @access private - */ - private function _memberExists() + $stmt = $this->dbh->prepare($sql); + $stmt->bindParam(':member_id', $this->_mid, PDO::PARAM_INT); + $stmt->execute(); + $stmt->bindColumn('active', $active); + $stmt->fetch(); + + return (bool) $active; + } catch (PDOException $e) { + return Toolkit_Common::handleError($e); + } + } + + // }}} + // {{{ memberExists() + + /** + * Check to make sure the member exists in the database + * + * @return boolean true or false if the member exists + * @access private + */ + private function _memberExists() { - if (!filter_var($this->_mid, FILTER_VALIDATE_INT)) { + if (!filter_var($this->_mid, FILTER_VALIDATE_INT)) { return false; } - try { - $sql = " - SELECT count(*) AS total - FROM member - WHERE member_id = :member_id"; + try { + $sql = " + SELECT count(*) AS total + FROM member + WHERE member_id = :member_id"; - $stmt = $this->dbh->prepare($sql); - $stmt->bindParam(':member_id', $this->_mid, PDO::PARAM_INT); - $stmt->execute(); - $stmt->bindColumn('total', $total); - $stmt->fetch(); + $stmt = $this->dbh->prepare($sql); + $stmt->bindParam(':member_id', $this->_mid, PDO::PARAM_INT); + $stmt->execute(); + $stmt->bindColumn('total', $total); + $stmt->fetch(); - return (bool) $total; - } catch (PDOException $e) { - return Toolkit_Common::handleError($e); - } - } + return (bool) $total; + } catch (PDOException $e) { + return Toolkit_Common::handleError($e); + } + } - // }}} + // }}} // {{{ setCatId() @@ -209,7 +209,7 @@ class Toolkit_Members_ProfilePage */ public function setCatId($catid) { - if (filter_var($catid, FILTER_VALIDATE_INT)) { + if (filter_var($catid, FILTER_VALIDATE_INT)) { $this->_catid = $catid; } else { $this->_catid = null; @@ -250,31 +250,31 @@ class Toolkit_Members_ProfilePage } // }}} - // {{{ setMemberAccommodations() + // {{{ setMemberAccommodations() /** * Get all the member accommodation info * * @param object &$page The object you want to use with the flexy template - * + * * @return void * @access protected */ - protected function setMemberAccommodations(&$page) - { - try { - // Check to see if there are any rows in the + protected function setMemberAccommodations(&$page) + { + try { + // Check to see if there are any rows in the // member_accommodations table that are linked to this // member. If there are, then we know this member - // needs the hotel section - $sql = " + // needs the hotel section + $sql = " SELECT reservation_url, reservation_id, num_rooms, year_round FROM member_accommodations WHERE member_id = :mid"; - $stmt = $this->dbh->prepare($sql); - $stmt->bindParam(':mid', $this->_mid, PDO::PARAM_INT); - $stmt->execute(); + $stmt = $this->dbh->prepare($sql); + $stmt->bindParam(':mid', $this->_mid, PDO::PARAM_INT); + $stmt->execute(); if ($row = $stmt->fetch(PDO::FETCH_ASSOC)) { $accommodations = array_filter($row); @@ -282,157 +282,157 @@ class Toolkit_Members_ProfilePage $page->has_accommodations = !empty($accommodations); $page->does_online_reservations - = ( !is_null($accommodations['reservation_id']) - || !is_null($accommodations['reservation_url']) - ); + = ( !is_null($accommodations['reservation_id']) + || !is_null($accommodations['reservation_url']) + ); $page->reservation_id = $accommodations['reservation_id']; $page->reservation_url = $accommodations['reservation_url']; $page->lists_number_of_rooms = !is_null($accommodations['num_rooms']); $page->num_rooms = $accommodations['num_rooms']; $page->year_round = $accommodations['year_round']; - } catch (PDOException $e) { - return Toolkit_Common::handleError($e); - } - } + } catch (PDOException $e) { + return Toolkit_Common::handleError($e); + } + } - // }}} - // {{{ setMemberAmenities() + // }}} + // {{{ setMemberAmenities() /** * Get all the member amenity info * * @param object &$page The object you want to use with the flexy template - * + * * @return void * @access protected */ - protected function setMemberAmenities(&$page) - { - try { - $sql = " - SELECT * - FROM amenity - WHERE amenity_id in ( - SELECT amenity_id - FROM member_amenity - WHERE member_id = :mid)"; - - $stmt = $this->dbh->prepare($sql); - $stmt->bindParam(':mid', $this->_mid, PDO::PARAM_INT); - $stmt->execute(); - - while ($row = $stmt->fetch()) { - $page->amenities[] = $row['amenity_name']; - } - } catch (PDOException $e) { - return Toolkit_Common::handleError($e); - } - } - - // }}} - // {{{ setMemberCCards() + protected function setMemberAmenities(&$page) + { + try { + $sql = " + SELECT * + FROM amenity + WHERE amenity_id in ( + SELECT amenity_id + FROM member_amenity + WHERE member_id = :mid)"; + + $stmt = $this->dbh->prepare($sql); + $stmt->bindParam(':mid', $this->_mid, PDO::PARAM_INT); + $stmt->execute(); + + while ($row = $stmt->fetch()) { + $page->amenities[] = $row['amenity_name']; + } + } catch (PDOException $e) { + return Toolkit_Common::handleError($e); + } + } + + // }}} + // {{{ setMemberCCards() /** * Get all the member Credit Card info * * @param object &$page The object you want to use with the flexy template - * + * * @return void * @access protected */ - protected function setMemberCCards(&$page) - { - try { - $sql = " + protected function setMemberCCards(&$page) + { + try { + $sql = " SELECT * FROM ccard_type WHERE ccard_type_id in ( - SELECT ccard_type_id - FROM member_ccard_type - WHERE member_id = :mid)"; + SELECT ccard_type_id + FROM member_ccard_type + WHERE member_id = :mid)"; - $stmt = $this->dbh->prepare($sql); - $stmt->bindParam(':mid', $this->_mid, PDO::PARAM_INT); - $stmt->execute(); + $stmt = $this->dbh->prepare($sql); + $stmt->bindParam(':mid', $this->_mid, PDO::PARAM_INT); + $stmt->execute(); - while ($row = $stmt->fetch()) { - $page->ccards[] = $row['ccard_type_name']; - } - } catch (PDOException $e) { - return Toolkit_Common::handleError($e); - } - } + while ($row = $stmt->fetch()) { + $page->ccards[] = $row['ccard_type_name']; + } + } catch (PDOException $e) { + return Toolkit_Common::handleError($e); + } + } - // }}} - // {{{ setMemberDetail() + // }}} + // {{{ setMemberDetail() /** * Get the member profile page * * @param stdClass $page controller object used with the template - * + * * @return string html string of member profile page * @access public */ - public function setMemberDetail(stdClass $page) - { + public function setMemberDetail(stdClass $page) + { if (!$this->_validMember()) { return false; } - $this->profile =& $page; + $this->profile =& $page; - $page->image_path = $this->imagePath; + $page->image_path = $this->imagePath; $page->full_image = ORIGINAL; - $page->base_url = BASE_URL; + $page->base_url = BASE_URL; $page->glm_base_url = GLM_APP_BASE_URL; - $this->setMemberInfo($page); - $this->setMemberPhotos($page); - $this->setMemberAmenities($page); - $this->setMemberFiles($page); - } + $this->setMemberInfo($page); + $this->setMemberPhotos($page); + $this->setMemberAmenities($page); + $this->setMemberFiles($page); + } - // }}} - // {{{ setMemberFiles() + // }}} + // {{{ setMemberFiles() /** * Get all the file data for the the member profile being looked at * * @param object &$page The object you want to use with the flexy template - * + * * @return void * @access protected */ - protected function setMemberFiles(&$page) - { - try { - $sql = " - SELECT * - FROM member_files - WHERE member_id = :mid - AND NOT pending"; - - $stmt = $this->dbh->prepare($sql); - $stmt->bindParam(':mid', $this->_mid, PDO::PARAM_INT); - $stmt->execute(); - - $count = 0; - while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) { - $page->files[$count]['href'] - = BASE_URL . "member-file/{$this->_mid}/{$row['id']}/"; - $page->files[$count]['name'] - = empty($row['file_name']) ? - $row['original_name'] : - $row['file_name']; - ++$count; - } - } catch (PDOException $e) { - return Toolkit_Common::handleError($e); - } - } - - // }}} + protected function setMemberFiles(&$page) + { + try { + $sql = " + SELECT * + FROM member_files + WHERE member_id = :mid + AND NOT pending"; + + $stmt = $this->dbh->prepare($sql); + $stmt->bindParam(':mid', $this->_mid, PDO::PARAM_INT); + $stmt->execute(); + + $count = 0; + while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) { + $page->files[$count]['href'] + = BASE_URL . "member-file/{$this->_mid}/{$row['id']}/"; + $page->files[$count]['name'] + = empty($row['file_name']) ? + $row['original_name'] : + $row['file_name']; + ++$count; + } + } catch (PDOException $e) { + return Toolkit_Common::handleError($e); + } + } + + // }}} // {{{ setMemberId() /** @@ -446,7 +446,7 @@ class Toolkit_Members_ProfilePage */ public function setMemberId($mid) { - if ($mid = filter_var($mid, FILTER_VALIDATE_INT)) { + if ($mid = filter_var($mid, FILTER_VALIDATE_INT)) { $this->_mid = $mid; } else { $this->_mid = null; @@ -455,20 +455,20 @@ class Toolkit_Members_ProfilePage } // }}} - // {{{ setMemberInfo() + // {{{ setMemberInfo() /** * Set the record data stored in the database for the template * * @param object &$page The object you want to use with the flexy template - * + * * @return void * @access protected */ - protected function setMemberInfo(&$page) - { - try { - $sql = " + protected function setMemberInfo(&$page) + { + try { + $sql = " SELECT m.*, c.city_name, s.state_name, ct.county_name, s.state_abb AS state_abbr @@ -478,10 +478,10 @@ class Toolkit_Members_ProfilePage LEFT OUTER JOIN county ct ON (m.county = ct.county_id) WHERE m.member_id = :mid"; - $stmt = $this->dbh->prepare($sql); - $stmt->bindParam(':mid', $this->_mid, PDO::PARAM_INT); - $stmt->execute(); - $row = $stmt->fetch(PDO::FETCH_ASSOC); + $stmt = $this->dbh->prepare($sql); + $stmt->bindParam(':mid', $this->_mid, PDO::PARAM_INT); + $stmt->execute(); + $row = $stmt->fetch(PDO::FETCH_ASSOC); if (!empty($row['logo'])) { $page->logo = $row['logo']; @@ -505,63 +505,64 @@ class Toolkit_Members_ProfilePage $longitude = Toolkit_Common::f2LatLon($row['lon'], 'Lon', 'DMS', 2); $page->lon = $longitude['text']; } - $page->county_name = $row['county_name']; - $page->state_name = $row['state_name']; - $page->state_abbr = $row['state_abbr']; - $page->zip = $row['zip']; - $page->phone = $row['phone']; - $page->toll_free = $row['toll_free']; - $page->fax = $row['fax']; - $page->email = $row['member_contact_email']; - $page->paypal = $row['paypal']; - $page->reviewed = $row['reviewed']; - $page->distance = $row['distance']; - $page->trailtype = $row['trailtype']; - $page->terrain = $row['terrain']; - $page->difficulty = $row['difficulty']; - $page->dogs = $row['dogs']; - $page->guide = $row['guide']; - $page->facilities = $row['facilities']; - $page->hours = $row['hours']; - $page->directions = $row['directions']; - $page->information = $row['information']; + $page->county_name = $row['county_name']; + $page->state_name = $row['state_name']; + $page->state_abbr = $row['state_abbr']; + $page->zip = $row['zip']; + $page->phone = $row['phone']; + $page->toll_free = $row['toll_free']; + $page->fax = $row['fax']; + $page->email = $row['member_contact_email']; + $page->paypal = $row['paypal']; + $page->reviewed = $row['reviewed']; + $page->distance = $row['distance']; + $page->trailtype = $row['trailtype']; + $page->terrain = $row['terrain']; + $page->difficulty = $row['difficulty']; + $page->nearest_city = $row['nearest_city']; + $page->dogs = $row['dogs']; + $page->guide = $row['guide']; + $page->facilities = $row['facilities']; + $page->hours = $row['hours']; + $page->directions = $row['directions']; + $page->information = $row['information']; if ($row['url'] && strpos($row['url'], 'http://') === false) { $row['url'] = 'http://' . $row['url']; } $page->url = $row['url']; - // handle if we should be showing mailing addresses - // on the member profile or not. - $mailingAddyD - =& $config->getItem('directive', 'showMailingAddress'); - if ($mailingAddyD->getContent()) { - $sql = " - SELECT c.city_name AS mailing_city_name, s.state_name AS - mailing_state_name, s.state_abb AS mailing_state_abbr + // handle if we should be showing mailing addresses + // on the member profile or not. + $mailingAddyD + =& $config->getItem('directive', 'showMailingAddress'); + if ($mailingAddyD->getContent()) { + $sql = " + SELECT c.city_name AS mailing_city_name, s.state_name AS + mailing_state_name, s.state_abb AS mailing_state_abbr FROM member m, city c, state s WHERE m.member_id = :mid AND m.mailing_state_id = s.state_id AND m.mailing_city_id = c.city_id"; - $stmt = $this->dbh->prepare($sql); - $stmt->bindParam(':mid', $this->_mid, PDO::PARAM_INT); - $stmt->execute(); - $mailingAddyRow = $stmt->fetch(PDO::FETCH_ASSOC); - - if ($mailingAddyRow) { - $page->hasMailingAddy = true; - $page->mailing_address - = $row['mailing_address']; - $page->mailing_city - = $mailingAddyRow['mailing_city_name']; - $page->mailing_state - = $mailingAddyRow['mailing_state_name']; - $page->mailing_state_abbr - = $mailingAddyRow['mailing_state_abbr']; - $page->mailing_zip = $row['mailing_zip']; - } - } + $stmt = $this->dbh->prepare($sql); + $stmt->bindParam(':mid', $this->_mid, PDO::PARAM_INT); + $stmt->execute(); + $mailingAddyRow = $stmt->fetch(PDO::FETCH_ASSOC); + + if ($mailingAddyRow) { + $page->hasMailingAddy = true; + $page->mailing_address + = $row['mailing_address']; + $page->mailing_city + = $mailingAddyRow['mailing_city_name']; + $page->mailing_state + = $mailingAddyRow['mailing_state_name']; + $page->mailing_state_abbr + = $mailingAddyRow['mailing_state_abbr']; + $page->mailing_zip = $row['mailing_zip']; + } + } if (!empty($row['lat']) && !empty($row['lon'])) { $fromAddress = trim(urlencode(str_replace("\n", "", strip_tags($row['member_name'])))); @@ -582,9 +583,9 @@ class Toolkit_Members_ProfilePage if ($_SESSION['wish_list'][$this->_mid]) { $page->addToLink = false; $page->plink = Toolkit_Template_Page::getSeoUrl( - $this->_pageGateway, - MEMBER_SESSION_PAGE - ); + $this->_pageGateway, + MEMBER_SESSION_PAGE + ); } else { $page->addToLink = true; $page->plink = BASE_URL . "Toolkit/Members/TripPlanner/" @@ -594,13 +595,13 @@ class Toolkit_Members_ProfilePage } else { $page->plink = null; } - } catch (PDOException $e) { - return Toolkit_Common::handleError($e); - } - } + } catch (PDOException $e) { + return Toolkit_Common::handleError($e); + } + } - // }}} - // {{{ setMemberPhotos() + // }}} + // {{{ setMemberPhotos() /** * set all the non-pending photos that a member has @@ -610,28 +611,28 @@ class Toolkit_Members_ProfilePage * @return void * @access protected */ - protected function setMemberPhotos(&$page) - { - try { - $sql = " - SELECT * - FROM member_photos - WHERE member_id = :mid - AND (NOT pending OR pending IS NULL) - ORDER BY pos"; - - $stmt = $this->dbh->prepare($sql); - $stmt->bindParam(':mid', $this->_mid, PDO::PARAM_INT); - $stmt->execute(); - - $count = 0; - while ($row = $stmt->fetch()) { - $images[$count]['alt'] = $row['caption']; - $images[$count]['id'] = PHOTO_LARGE_URL . $row['image']; - $images[$count]['src'] = PHOTO_SMALL_URL . $row['image']; - $images[$count]['img'] = $row['image']; - ++$count; - } + protected function setMemberPhotos(&$page) + { + try { + $sql = " + SELECT * + FROM member_photos + WHERE member_id = :mid + AND (NOT pending OR pending IS NULL) + ORDER BY pos"; + + $stmt = $this->dbh->prepare($sql); + $stmt->bindParam(':mid', $this->_mid, PDO::PARAM_INT); + $stmt->execute(); + + $count = 0; + while ($row = $stmt->fetch()) { + $images[$count]['alt'] = $row['caption']; + $images[$count]['id'] = PHOTO_LARGE_URL . $row['image']; + $images[$count]['src'] = PHOTO_SMALL_URL . $row['image']; + $images[$count]['img'] = $row['image']; + ++$count; + } $page->photos = !empty($images) ? $images : false; if ($page->photos) { @@ -639,12 +640,12 @@ class Toolkit_Members_ProfilePage ? BASE_SECURE_URL : BASE_URL; } - } catch (PDOException $e) { - return Toolkit_Common::handleError($e); - } - } + } catch (PDOException $e) { + return Toolkit_Common::handleError($e); + } + } - // }}} + // }}} // {{{ _validMember() diff --git a/Toolkit/Members/SearchList.php b/Toolkit/Members/SearchList.php index f7fabe2..c23c6b8 100644 --- a/Toolkit/Members/SearchList.php +++ b/Toolkit/Members/SearchList.php @@ -1,5 +1,5 @@ - * @license http://www.gaslightmedia.com Gaslightmedia + * @license http://www.gaslightmedia.com Gaslightmedia * @release CVS: $Id: SearchList.php,v 1.47 2010/07/14 23:31:14 jamie Exp $ - * @link http://demo.gaslightmedia.com + * @link http://demo.gaslightmedia.com */ /** @@ -26,62 +26,62 @@ */ class Toolkit_Members_SearchList extends Toolkit_FlexyDataGridBuilder { - // {{{ properties + // {{{ properties /** * Description for protected * @var string * @access protected */ - protected $tableName = 'member'; + protected $tableName = 'member'; /** * Description for protected * @var array * @access protected */ - protected $queryParams = array(); + protected $queryParams = array(); /** * Description for protected * @var unknown * @access protected */ - protected $showSearchBox; + protected $showSearchBox; /** * Description for protected * @var string * @access protected */ - protected $template = 'membersList.tpl'; - - /** - * Whether subcats should be included in the search results - * - * If this is turned on, the subcategories beneath all categories assigned - * to the page will be included in the search results. - * - * Example Category Tree: - * - * Parent - * |_ Child - * | |_ GrandChild - * | - * |_ Sibling - * - * If set to true and only "Parent" is assigned to a page from the toolbox, - * then members with all categories (parent, child, grandchild, sibling) will - * be included in the search results. - * - * If set to false and only Child is assigned to a page, then only members - * that have the category "Child" assigned to them will be included in the - * search Results. - * - * @var boolean - * @access protected - */ - protected $includeSubCats = true; + protected $template = 'membersList.tpl'; + + /** + * Whether subcats should be included in the search results + * + * If this is turned on, the subcategories beneath all categories assigned + * to the page will be included in the search results. + * + * Example Category Tree: + * + * Parent + * |_ Child + * | |_ GrandChild + * | + * |_ Sibling + * + * If set to true and only "Parent" is assigned to a page from the toolbox, + * then members with all categories (parent, child, grandchild, sibling) will + * be included in the search results. + * + * If set to false and only Child is assigned to a page, then only members + * that have the category "Child" assigned to them will be included in the + * search Results. + * + * @var boolean + * @access protected + */ + protected $includeSubCats = true; /** * map icon numbers only get displayed if the map is there @@ -91,22 +91,22 @@ class Toolkit_Members_SearchList extends Toolkit_FlexyDataGridBuilder */ protected $memberMap = false; - // }}} - // {{{ __construct() - - /** - * Class constructor - * - * define where templates for the data grid are at, then call the parent constructor which will handle - * finishing the settings for the datagrid. - * - * After all settings are finished you can call the toHTML() function on this object and the datagrid - * will be rendered and returned as a string. Optionally you could call show() and the datagrid would - * be rendered and output immediatley to the screen. - * + // }}} + // {{{ __construct() + + /** + * Class constructor + * + * define where templates for the data grid are at, then call the parent constructor which will handle + * finishing the settings for the datagrid. + * + * After all settings are finished you can call the toHTML() function on this object and the datagrid + * will be rendered and returned as a string. Optionally you could call show() and the datagrid would + * be rendered and output immediatley to the screen. + * * @param PDO $pdo PHP Data Object to use for DB calls * @param string $limit The number of records to display per page. - * @param int $page The current page viewed. + * @param int $page The current page viewed. * In most cases, this is useless. * Note: if you specify this, the "page" GET * variable will be ignored. @@ -116,11 +116,11 @@ class Toolkit_Members_SearchList extends Toolkit_FlexyDataGridBuilder * {@link getOutput} * @param boolean $showSearchBox If we should allow searching for members * @param array $sections specific members we should show - * + * * @return void - * @access public - */ - public function __construct( + * @access public + */ + public function __construct( PDO $pdo, $limit = null, $page = null, @@ -128,175 +128,181 @@ class Toolkit_Members_SearchList extends Toolkit_FlexyDataGridBuilder $showSearchBox = true, array $sections = null ) { - $GLOBALS['styleSheets'][] = BASE_URL . 'Toolkit/Members/css/member.css'; - $GLOBALS['bottomScripts'][] - = BASE_URL . 'Toolkit/Members/libjs/business-search.js'; + $GLOBALS['styleSheets'][] = BASE_URL . 'Toolkit/Members/css/member.css'; + $GLOBALS['bottomScripts'][] + = BASE_URL . 'Toolkit/Members/libjs/business-search.js'; if (defined("MEMBER_SESSION_LIST") && MEMBER_SESSION_LIST) { $GLOBALS['bottomScripts'][] = BASE_URL . 'Toolkit/Members/libjs/travel-list.js'; } - $this->showSearchBox = $showSearchBox; - $this->pagerOptions['containerClass'] = 'pages'; - parent::__construct($pdo, $limit, $page, $rendererType); - } + $this->showSearchBox = $showSearchBox; + $this->pagerOptions['containerClass'] = 'pages'; + parent::__construct($pdo, $limit, $page, $rendererType); + } - // }}} + // }}} - // {{{ city() + // {{{ city() - /** - * Returns the city for a member. - * + /** + * Returns the city for a member. + * * If this memberdb is using controlled cities then we need to extract * the city name via the city_id - * + * * @param array $data tuple record from db - * - * @return string City name for the record - * @access public - */ - public function city($data) - { + * + * @return string City name for the record + * @access public + */ + public function city($data) + { // get reference to [conf] section of config file $ctrlCtyD =& $this->config - ->getItem('section', 'conf') - ->getItem('directive', 'controlledCities'); + ->getItem('section', 'conf') + ->getItem('directive', 'controlledCities'); if ($ctrlCtyD->getContent()) { return $data['record']['city_name']; } else { return $data['record']['city']; } - } - - // }}} - // {{{ configureColumns() - - /** - * Configures the columns that will be used in our datagrid renderer. - * - * @return void - * @access protected - */ - protected function configureColumns() - { - $this->addColumn(new Structures_DataGrid_Column( - 'Logo', - 'logo', - 'logo', - null, - null, - array(&$this, 'logo') - )); + } + + // }}} + // {{{ configureColumns() + + /** + * Configures the columns that will be used in our datagrid renderer. + * + * @return void + * @access protected + */ + protected function configureColumns() + { + $this->addColumn(new Structures_DataGrid_Column( + 'Logo', + 'logo', + 'logo', + null, + null, + array(&$this, 'logo') + )); $this->addColumn(new Structures_DataGrid_Column( - 'Reviewed', + 'Reviewed', 'reviewed', 'reviewed' - )); + )); $this->addColumn(new Structures_DataGrid_Column( - 'Distance', + 'Distance', 'distance', 'distance' - )); + )); $this->addColumn(new Structures_DataGrid_Column( - 'Type', + 'Type', 'trailtype', 'trailtype' - )); + )); $this->addColumn(new Structures_DataGrid_Column( - 'Terrain', + 'Terrain', 'terrain', 'terrain' - )); + )); $this->addColumn(new Structures_DataGrid_Column( - 'Difficulty', + 'Difficulty', 'difficulty', 'difficulty' - )); + )); + + $this->addColumn(new Structures_DataGrid_Column( + 'Nearest City', + 'nearest_city', + 'nearest_city' + )); $this->addColumn(new Structures_DataGrid_Column( - 'Dogs', + 'Dogs', 'dogs', 'dogs' - )); + )); - $this->addColumn(new Structures_DataGrid_Column( - 'Member Name', + $this->addColumn(new Structures_DataGrid_Column( + 'Member Name', 'member_name', 'member_name' - )); + )); - $this->addColumn(new Structures_DataGrid_Column( - 'Email', + $this->addColumn(new Structures_DataGrid_Column( + 'Email', 'member_contact_email', 'member_contact_email' - )); + )); - $this->addColumn(new Structures_DataGrid_Column( - 'Address', + $this->addColumn(new Structures_DataGrid_Column( + 'Address', 'address', 'address', null, null, array(&$this, 'drivingDirections') - )); + )); - $this->addColumn(new Structures_DataGrid_Column( - 'Street', + $this->addColumn(new Structures_DataGrid_Column( + 'Street', 'street', 'street' - )); + )); - $this->addColumn( new Structures_DataGrid_Column( - 'City', + $this->addColumn( new Structures_DataGrid_Column( + 'City', 'city', 'city', null, null, array(&$this, 'city') - )); + )); - $this->addColumn(new Structures_DataGrid_Column( - 'State', + $this->addColumn(new Structures_DataGrid_Column( + 'State', 'state', 'state' - )); + )); - $this->addColumn(new Structures_DataGrid_Column( - 'State Abbr', + $this->addColumn(new Structures_DataGrid_Column( + 'State Abbr', 'state_abbr', 'state_abbr' - )); + )); - $this->addColumn(new Structures_DataGrid_Column( - 'Zip', + $this->addColumn(new Structures_DataGrid_Column( + 'Zip', 'zip', 'zip' - )); + )); - $this->addColumn(new Structures_DataGrid_Column( - 'Phone', + $this->addColumn(new Structures_DataGrid_Column( + 'Phone', 'phone', 'phone', null, null, array(&$this, 'phone') - )); + )); - $this->addColumn(new Structures_DataGrid_Column( - 'URL', + $this->addColumn(new Structures_DataGrid_Column( + 'URL', 'url', 'url', null, null, array(&$this, 'url') - )); + )); if (defined("MEMBER_SESSION_LIST") && MEMBER_SESSION_LIST) { $this->addColumn( @@ -323,28 +329,28 @@ class Toolkit_Members_SearchList extends Toolkit_FlexyDataGridBuilder ); $this->addColumn(new Structures_DataGrid_Column( - 'member_id', + 'member_id', 'member_id', 'member_id' - )); + )); $this->addColumn(new Structures_DataGrid_Column( - 'Website', - 'website', - 'website', - null, - null, - array(&$this, 'website') - )); + 'Website', + 'website', + 'website', + null, + null, + array(&$this, 'website') + )); $this->addColumn(new Structures_DataGrid_Column( - 'map_icon', - 'map_icon', - 'map_icon', - null, - null, - array(&$this, 'mapIcon') - )); + 'map_icon', + 'map_icon', + 'map_icon', + null, + null, + array(&$this, 'mapIcon') + )); $this->addColumn(new Structures_DataGrid_Column( 'Latitude', @@ -368,29 +374,29 @@ class Toolkit_Members_SearchList extends Toolkit_FlexyDataGridBuilder // }}} - // {{{ drivingDirections() - - /** - * Get the html link for driving directions to google - * - * @param array $data tuple record from db - * - * @return string html string for link to google maps for driving directions - * @access public - */ - public function drivingDirections($data) - { - extract($data['record']); - $format = 'http://maps.google.com/maps?daddr=%s@%s,%s'; - return sprintf( - $format, - urlencode($member_name), - $lat, - $lon - ); - } - - // }}} + // {{{ drivingDirections() + + /** + * Get the html link for driving directions to google + * + * @param array $data tuple record from db + * + * @return string html string for link to google maps for driving directions + * @access public + */ + public function drivingDirections($data) + { + extract($data['record']); + $format = 'http://maps.google.com/maps?daddr=%s@%s,%s'; + return sprintf( + $format, + urlencode($member_name), + $lat, + $lon + ); + } + + // }}} // {{{ getAlphaList() @@ -403,71 +409,71 @@ class Toolkit_Members_SearchList extends Toolkit_FlexyDataGridBuilder * * @access protected */ - protected function getAlphaList() - { - $pattern = "/ (\s*?AND\s*?)?upper\(substr\(m.member_name, 1, 1\)\) = upper\('.'\)/i"; - $replacement = ''; - $sql = preg_replace($pattern, $replacement, $this->sql); - try { - $letters = array(); - $stmt = $this->dbh->prepare($sql); - $stmt->execute(); - - $stmt->bindColumn('member_name', $name); - - while ($row = $stmt->fetch()) { - $letters[] = strtoupper($name{0}); - } - - $letters = array_unique($letters); - sort($letters); - - $addNumeric = false; - while ($i = current($letters)) { - if (is_numeric($i)) { - $addNumeric = true; - unset($letters[key($letters)]); - } else { - break; - } - } - - if ($addNumeric) { - array_unshift($letters, '0-9'); - } - - // We only need to show the links of alphabet if we have more than - // one letter to display. - if (count($letters) > 1) { - foreach ($_GET as $k => $v) { - if ($k != 'alpha') { - if (is_array($v)) { - foreach ($v as $i => $j) { - $queryString .= $k . '[' . $i . ']=' . $j . '&'; - } - } else { - $queryString .= "$k=$v&"; - } - } - } - $links['All']['url'] = BASE_URL . "index.php?{$queryString}"; - $links['All']['class'] = empty($_GET['alpha']) ? 'curr' : null; - foreach ($letters as $v) { - $links[$v]['url'] = BASE_URL . "index.php?{$queryString}alpha=$v"; - if ($_GET['alpha'] == $v) { - $links[$v]['class'] = 'curr'; - } - } - return $links; - } - } catch (PDOException $e) { - return Toolkit_Common::handleError($e); - } - } - - // }}} - - // {{{ hasHotelInfo() + protected function getAlphaList() + { + $pattern = "/ (\s*?AND\s*?)?upper\(substr\(m.member_name, 1, 1\)\) = upper\('.'\)/i"; + $replacement = ''; + $sql = preg_replace($pattern, $replacement, $this->sql); + try { + $letters = array(); + $stmt = $this->dbh->prepare($sql); + $stmt->execute(); + + $stmt->bindColumn('member_name', $name); + + while ($row = $stmt->fetch()) { + $letters[] = strtoupper($name{0}); + } + + $letters = array_unique($letters); + sort($letters); + + $addNumeric = false; + while ($i = current($letters)) { + if (is_numeric($i)) { + $addNumeric = true; + unset($letters[key($letters)]); + } else { + break; + } + } + + if ($addNumeric) { + array_unshift($letters, '0-9'); + } + + // We only need to show the links of alphabet if we have more than + // one letter to display. + if (count($letters) > 1) { + foreach ($_GET as $k => $v) { + if ($k != 'alpha') { + if (is_array($v)) { + foreach ($v as $i => $j) { + $queryString .= $k . '[' . $i . ']=' . $j . '&'; + } + } else { + $queryString .= "$k=$v&"; + } + } + } + $links['All']['url'] = BASE_URL . "index.php?{$queryString}"; + $links['All']['class'] = empty($_GET['alpha']) ? 'curr' : null; + foreach ($letters as $v) { + $links[$v]['url'] = BASE_URL . "index.php?{$queryString}alpha=$v"; + if ($_GET['alpha'] == $v) { + $links[$v]['class'] = 'curr'; + } + } + return $links; + } + } catch (PDOException $e) { + return Toolkit_Common::handleError($e); + } + } + + // }}} + + // {{{ hasHotelInfo() /** * Determines if the record has any available hotel info to display @@ -477,28 +483,28 @@ class Toolkit_Members_SearchList extends Toolkit_FlexyDataGridBuilder * @return boolean true if any data to display, otherwise false * @access public */ - public function hasHotelInfo($data) - { + public function hasHotelInfo($data) + { extract($data['record']); return !(empty($reservation_id) && empty($num_rooms) && empty($year_round)); - } + } - // }}} + // }}} // {{{ inList() - /** + /** * Returns the bool for a member in session (list) - * - * Used when configuring the columns for the data grid. This + * + * Used when configuring the columns for the data grid. This * function returns true or false if the member is in not session * then true * * @param array $data tuple record from db - * + * * @return boolean true if member is not in $_SESSION['wish_list'] - * @access public - */ + * @access public + */ public function inList($data) { return !($_SESSION['wish_list'][$data['record']['member_id']]); @@ -506,25 +512,25 @@ class Toolkit_Members_SearchList extends Toolkit_FlexyDataGridBuilder // }}} - // {{{ listUrl() + // {{{ listUrl() - /** - * Returns the url for a member. - * - * Used when configuring the columns for the data grid. This - * function generates the url to get to the member detail page - * + /** + * Returns the url for a member. + * + * Used when configuring the columns for the data grid. This + * function generates the url to get to the member detail page + * * @param array $data tuple record from db - * - * @access Public - * @version Release: @package_version@ - * @return url for the add to or remove from $_SESSION['wish_list'] - */ - public function listUrl($data) - { + * + * @access Public + * @version Release: @package_version@ + * @return url for the add to or remove from $_SESSION['wish_list'] + */ + public function listUrl($data) + { if (defined("MEMBER_SESSION_LIST") && MEMBER_SESSION_LIST) { if ($_SESSION['wish_list'][$data['record']['member_id']]) { - $url = Toolkit_Template_Page::getSeoUrl($this->_pageGateway, MEMBER_SESSION_PAGE); + $url = Toolkit_Template_Page::getSeoUrl($this->_pageGateway, MEMBER_SESSION_PAGE); } else { $url = BASE_URL . "Toolkit/Members/TripPlanner/" . "wish-list.php?catid={$_REQUEST['catid']}" @@ -534,26 +540,26 @@ class Toolkit_Members_SearchList extends Toolkit_FlexyDataGridBuilder $url = false; } return $url; - } + } - // }}} - // {{{ logo() + // }}} + // {{{ logo() - /** - * Returns the logo for a member. - * + /** + * Returns the logo for a member. + * * @param array $data tuple record from db * - * @return false when empty, otherwise logo path for member - * @access - */ - public function logo($data) - { + * @return false when empty, otherwise logo path for member + * @access + */ + public function logo($data) + { extract($data['record']); - return empty($logo) ? false : MEMBER_PHOTOS . $logo; - } + return empty($logo) ? false : MEMBER_PHOTOS . $logo; + } - // }}} + // }}} public function lat($data) { @@ -577,26 +583,26 @@ class Toolkit_Members_SearchList extends Toolkit_FlexyDataGridBuilder } } - // {{{ phone() + // {{{ phone() - /** - * Returns the phone # for a member. - * - * Used when configuring the columns for the data grid. This - * function generates the phone for the member - * + /** + * Returns the phone # for a member. + * + * Used when configuring the columns for the data grid. This + * function generates the phone for the member + * * @param array $data tuple record from db * - * @return mixed false when empty, member phone number if not empty - * @access public - */ - public function phone($data) - { + * @return mixed false when empty, member phone number if not empty + * @access public + */ + public function phone($data) + { extract($data['record']); - return empty($phone) ? false : $phone; - } + return empty($phone) ? false : $phone; + } - // }}} + // }}} // {{{ setConfig() @@ -641,13 +647,13 @@ class Toolkit_Members_SearchList extends Toolkit_FlexyDataGridBuilder * @access public */ public function setPageGateway( - Toolkit_Toolbox_PageGatewayAbstract $pageGateway - ) { + Toolkit_Toolbox_PageGatewayAbstract $pageGateway + ) { $this->_pageGateway= $pageGateway; } // }}} - // {{{ setControlObject() + // {{{ setControlObject() /** * These are the objects that will be inserted into the template. @@ -655,20 +661,20 @@ class Toolkit_Members_SearchList extends Toolkit_FlexyDataGridBuilder * @return void * @access protected */ - protected function setControlObject() - { + protected function setControlObject() + { $searchMapIconActive =& $this->config ->getItem('section', 'conf') ->getItem('directive', 'searchMapIconActive') ->getContent(); - $this->ctrlObj['base_url'] = BASE_URL; - $this->ctrlObj['catid'] = $_REQUEST['catid']; - $this->ctrlObj['trip_planner_id'] = MEMBER_SESSION_PAGE; - $this->ctrlObj['letters'] = $this->getAlphaList(); + $this->ctrlObj['base_url'] = BASE_URL; + $this->ctrlObj['catid'] = $_REQUEST['catid']; + $this->ctrlObj['trip_planner_id'] = MEMBER_SESSION_PAGE; + $this->ctrlObj['letters'] = $this->getAlphaList(); $this->ctrlObj['searchMapIconActive'] = $searchMapIconActive; - if (isset($_GET['search']) && $this->showSearchBox) { - $action = BASE_URL . "index.php?{$_SERVER['QUERY_STRING']}"; + if (isset($_GET['search']) && $this->showSearchBox) { + $action = BASE_URL . "index.php?{$_SERVER['QUERY_STRING']}"; $form = new Toolkit_Members_UserSearchForm( 'SearchForm', 'get', @@ -676,7 +682,7 @@ class Toolkit_Members_SearchList extends Toolkit_FlexyDataGridBuilder null, null, true - ); + ); $res = $form->setCatId($_GET['catid']); if (PEAR::isError($res)) { @@ -686,51 +692,51 @@ class Toolkit_Members_SearchList extends Toolkit_FlexyDataGridBuilder $form->setPageMemberRegions($this->_pageGateway); $form->configureForm($this->dbh, $this->config); $this->ctrlObj['member_search_form'] = $form->toHtml( - Toolkit_Members::getFlexyOptions(), - $this->_pageGateway - ); + Toolkit_Members::getFlexyOptions(), + $this->_pageGateway + ); } - } - } + } + } - // }}} + // }}} - // {{{ url() + // {{{ url() - /** - * Returns the url for a member. - * - * Used when configuring the columns for the data grid. This - * function generates the url to get to the member detail page - * + /** + * Returns the url for a member. + * + * Used when configuring the columns for the data grid. This + * function generates the url to get to the member detail page + * * @param array $data tuple record from db - * - * @return string uri for exposure record - * @access public - */ - public function url($data) - { - extract($data['record']); + * + * @return string uri for exposure record + * @access public + */ + public function url($data) + { + extract($data['record']); $exposure = new Toolkit_Members_Exposure($member_id, 'list'); - $exposure->runUpdate(); - return BASE_URL . "member-profile/{$_GET['catid']}/$member_id/"; - } - - // }}} - - // {{{ website() - - /** - * Returns html link to members website w/ clickthru tracking - * - * @param array $data tuple record from db - * - * @return string html string for member website w/ clickthru tracking - * @access public - */ - public function website($data) - { - extract($data['record']); + $exposure->runUpdate(); + return BASE_URL . "member-profile/{$_GET['catid']}/$member_id/"; + } + + // }}} + + // {{{ website() + + /** + * Returns html link to members website w/ clickthru tracking + * + * @param array $data tuple record from db + * + * @return string html string for member website w/ clickthru tracking + * @access public + */ + public function website($data) + { + extract($data['record']); if (!$url) { return false; } @@ -739,28 +745,28 @@ class Toolkit_Members_SearchList extends Toolkit_FlexyDataGridBuilder $url = 'http://' . $url; } return $url; - } - - // }}} - - // {{{ mapIcon() - - /** - * Returns html link to members website w/ clickthru tracking - * - * @param array $data tuple record from db - * - * @return string html string for member website w/ clickthru tracking - * @access public - */ - public function mapIcon($data) - { + } + + // }}} + + // {{{ mapIcon() + + /** + * Returns html link to members website w/ clickthru tracking + * + * @param array $data tuple record from db + * + * @return string html string for member website w/ clickthru tracking + * @access public + */ + public function mapIcon($data) + { static $currentRecordNumber = 1; $searchResultNumbered =& $this->config ->getItem('section', 'conf') ->getItem('directive', 'searchResultNumbered') ->getContent(); - extract($data['record']); + extract($data['record']); if (!$lat || !$lon) { return false; } @@ -769,39 +775,39 @@ class Toolkit_Members_SearchList extends Toolkit_FlexyDataGridBuilder $format = BASE_URL . 'map/5680FC/%s.png'; } - if (empty($format)) { - return false; - } - $html = array( + if (empty($format)) { + return false; + } + $html = array( 'id' => $currentRecordNumber - 1, 'icon' => sprintf( $format, $currentRecordNumber ) - ); + ); ++$currentRecordNumber; return $html; - } + } - // }}} + // }}} - // {{{ yearRound() + // {{{ yearRound() - /** - * Returns the year round for a member w/ accommodations. - * - * Used when configuring the columns for the data grid. This - * function generates the year round for the member detail page + /** + * Returns the year round for a member w/ accommodations. + * + * Used when configuring the columns for the data grid. This + * function generates the year round for the member detail page * * @param array $data tuple record from db - * + * * @return string if the accommodations is offered year round - * @access public - */ - public function yearRound($data) - { - return ($data['record']['year_round'] == 't') ? 'Yes' : 'No'; - } - - // }}} + * @access public + */ + public function yearRound($data) + { + return ($data['record']['year_round'] == 't') ? 'Yes' : 'No'; + } + + // }}} } diff --git a/Toolkit/Members/templates/memberDetail.tpl b/Toolkit/Members/templates/memberDetail.tpl index 87ced13..bf8e2f5 100644 --- a/Toolkit/Members/templates/memberDetail.tpl +++ b/Toolkit/Members/templates/memberDetail.tpl @@ -1,106 +1,107 @@ + flexy:prefix="glm_" + base_url="base_url" + trip_planner_id="trip_planner_id" + catid="catid" + >
-
-
- {if:addToLink} - - Add to Trip Planner - - {else:} - - View Trip Planner - - {end:} - -
- - Member Logo Image - -
-
-

Amenities

-
-
    -
  • {v:h}
  • -
-
-
-
-

File Downloads

- -
-
-
-

{member_name:h}

-
-
Street Address
-
{street:h}
-
- {city:h}, - - {state_abbr:h} - - {zip:h} -
-
-
- Phone: - {phone:h} -
-
- Toll Free: - {toll_free:h} -
- - Website -
-
- -

Get Driving Directions:

-
- - - -
- -
-
-
- Fax: - {fax:h} -
-
- {county_name:h} County -
-
-
Lat: {lat:h}
-
Lon: {lon:h}
-
-
-
Distance: {distance:h}
-
Trail Type: {trailtype:h}
-
Terrain: {terrain:h}
-
Difficulty: {difficulty:h}
-
-
+
+
+ {if:addToLink} + + Add to Trip Planner + + {else:} + + View Trip Planner + + {end:} + +
+ + Member Logo Image + +
+
+

Amenities

+
+
    +
  • {v:h}
  • +
+
+
+
+

File Downloads

+ +
+
+
+

{member_name:h}

+
+
Street Address
+
{street:h}
+
+ {city:h}, + + {state_abbr:h} + + {zip:h} +
+
+
+ Phone: + {phone:h} +
+
+ Toll Free: + {toll_free:h} +
+ + Website +
+
+
+

Get Driving Directions:

+
+ + + +
+
+
+
+
+ Fax: + {fax:h} +
+
+ {county_name:h} County +
+
+
Lat: {lat:h}
+
Lon: {lon:h}
+
+
+
Distance: {distance:h}
+
Trail Type: {trailtype:h}
+
Terrain: {terrain:h}
+
Difficulty: {difficulty:h}
+
Nearest City: {nearest_city:h}
+
+
{description:h}
-
+
-
Trail Guide
-
Facilities
-
Directions
-
Hours & fees
-
Information
+
Trail Guide
+
Facilities
+
Directions
+
Hours & fees
+
Information
-
- {guide:h} -
-
- {facilities:h} -
-
- {hours:h} -
-
- {directions:h} -
-
- {information:h} -
+
+ {guide:h} +
+
+ {facilities:h} +
+
+ {hours:h} +
+
+ {directions:h} +
+
+ {information:h} +
\ No newline at end of file + diff --git a/Toolkit/Members/templates/membersList.tpl b/Toolkit/Members/templates/membersList.tpl index a8f8aba..83dd738 100644 --- a/Toolkit/Members/templates/membersList.tpl +++ b/Toolkit/Members/templates/membersList.tpl @@ -1,11 +1,11 @@
{member_search_form:h}
- + {if:numberedSet}
{getResults(#Found %s Trails in %s page(s)#):h}
@@ -14,60 +14,61 @@ {getPaging():h}
-
Narrow result by letter:
- {k} +
Narrow result by letter:
+ {k}
-
- {if:row[logo]} - {row[logo]} - {end:} - {if:row[addToLink]} - - Add To Trip Planner - - {else:} - - View Trip Planner - - {end:} -
-

{row[member_name]:h}

-
- {if:row[map_icon]} - - {end:} -
-
Distance: {row[distance]}
-
Trail Type: {row[trailtype]}
-
Terrain: {row[terrain]}
-
Difficulty: {row[difficulty]}
- -
-
- Email -
-
- Website -
- -
-
-
+
+ {if:row[logo]} + {row[logo]} + {end:} + {if:row[addToLink]} + + Add To Trip Planner + + {else:} + + View Trip Planner + + {end:} +
+

{row[member_name]:h}

+
+ {if:row[map_icon]} + + {end:} +
+
Distance: {row[distance]}
+
Trail Type: {row[trailtype]}
+
Terrain: {row[terrain]}
+
Difficulty: {row[difficulty]}
+
Nearest City or Town: {row[nearest_city]}
+ +
+
+ Email +
+
+ Website +
+ +
+
+
{getPaging():h}
{else:}