<?php
-// vim:set expandtab tabstop=4 shiftwidth=4 softtabstop=4 foldmethod=marker syntax=php:
+// vim:set expandtab tabstop=4 shiftwidth=4 softtabstop=4 foldmethod=marker syntax=php:
/**
* EditMemberInfo
* @category MembersDB
* @package Toolkit_Members
* @author Jamie Kahgee <steve@gaslightmedia.com.com>
- * @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';
* @package Toolkit_Members
* @author Jamie Kahgee <steve@gaslightmedia.com>
* @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 <tr> 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 <tr> 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 = '
<div id="form-success-top">
The information below has been successfully submitted.
</div>';
- /**
- * 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'
* @param string $target (optional)Form's target defaults to '_self'
* @param mixed $attributes (optional)Extra attributes for <form> 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',
$attributes = null,
$trackSubmit = false
) {
- parent::__construct(
+ parent::__construct(
$formName,
$method,
$action,
$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__ . ']<br>';
- echo '
- <p>
- Please define the
- <strong>MEMBER_RECORD_UPDATES_ADVISOR</strong> constant
- in the setup file first.<br><br> This Constant should hold
- the email address of the person you would like notified
- when a member submits an update.<br>Set to false if you do
- not want an email to be sent.
- </p>';
- 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 <jamie.kahgee+secondaryAdvisorTest1@gmail.com>
- // 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__ . ']<br>';
+ echo '
+ <p>
+ Please define the
+ <strong>MEMBER_RECORD_UPDATES_ADVISOR</strong> constant
+ in the setup file first.<br><br> This Constant should hold
+ the email address of the person you would like notified
+ when a member submits an update.<br>Set to false if you do
+ not want an email to be sent.
+ </p>';
+ 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 <jamie.kahgee+secondaryAdvisorTest1@gmail.com>
+ // 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()
}
}
- // {{{ 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
* @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
* @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
* @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] = "<span>{$tree->category}</span>";
- } 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] = "<span>{$tree->category}</span>";
+ } 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 = '<img src="'.MEMBER_PHOTOS.$v.'"
- alt="'.$v.'">';
+ $k = 'image_rmv';
+ $v = '<img src="'.MEMBER_PHOTOS.$v.'"
+ alt="'.$v.'">';
break;
case 'lat':
$latDMS = Toolkit_Common::f2LatLon(
$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',
);
// {{{ 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',
'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,
'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',
'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')
'element' => 'url',
'filter' => array('Toolkit_Common', 'filterURI')
);
- $this->setupFilters($f);
- }
+ $this->setupFilters($f);
+ }
- // }}}
+ // }}}
// {{{ configureForm()
/**
}
// }}}
- // {{{ 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!',
// '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!',
// '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',
'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 = '<a target="_blank" href="'.BASE_URL.'pending-member/'.$_GET['id'].'/">link</a>';
-
- $template->compile($this->emailTemplate);
- // Merge the compiled template with the $page object.
- $htmlMsg = $template->bufferedOutputObject($page);
-
- $msg = "
- <h3>$memberName</h3>
- <p>
- 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}
- </p>";
- $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 = '<a target="_blank" href="'.BASE_URL.'pending-member/'.$_GET['id'].'/">link</a>';
+
+ $template->compile($this->emailTemplate);
+ // Merge the compiled template with the $page object.
+ $htmlMsg = $template->bufferedOutputObject($page);
+
+ $msg = "
+ <h3>$memberName</h3>
+ <p>
+ 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}
+ </p>";
+ $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()
*
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
- *
- * <example>
- * ... 'name' => 'remove_rmv', ...
- * </example>
- *
- * 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
+ *
+ * <example>
+ * ... 'name' => 'remove_rmv', ...
+ * </example>
+ *
+ * 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
);
$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()
/**
* @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 = '<img alt="'. $imgName . '" src="'.MEMBER_PHOTOS . $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 = '<img alt="'. $imgName . '" src="'.MEMBER_PHOTOS . $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()
}
// }}}
- // {{{ setLatLngCoords()
+ // {{{ setLatLngCoords()
/**
* Turning off the lookup of lat lon for this site
* @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'];
$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
* @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
* @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 <i> tags for the member categories
* @return string set of <i> 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 .= '<i>';
- $out .= '<input id="catid'.$category['category_id'].'" ';
- $out .= 'type="hidden" name="member_cats[]" ';
- $out .= 'value="'.$category['category_id'].'">';
- $out .= '<label class="remove" for="'.$category['category_id'].'">';
- $out .= '<input type="checkbox" name="removeCat[]" ';
- $out .= 'id="'.$category['category_id'].'" ';
- $out .= 'value="'.$category['category_id'].'">';
- $out .= 'Remove';
- $out .= '</label>';
- $out .= $category['name'];
- $out .= '</i>';
- }
- } 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 .= '<i>';
+ $out .= '<input id="catid'.$category['category_id'].'" ';
+ $out .= 'type="hidden" name="member_cats[]" ';
+ $out .= 'value="'.$category['category_id'].'">';
+ $out .= '<label class="remove" for="'.$category['category_id'].'">';
+ $out .= '<input type="checkbox" name="removeCat[]" ';
+ $out .= 'id="'.$category['category_id'].'" ';
+ $out .= 'value="'.$category['category_id'].'">';
+ $out .= 'Remove';
+ $out .= '</label>';
+ $out .= $category['name'];
+ $out .= '</i>';
+ }
+ } 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
* @return object True on success
* @access public
*/
- public function updateData($values)
- {
+ public function updateData($values)
+ {
$addressUpdated = false;
$currentAddress = $this->getCurrentAddress();
$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.
/**
* @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;
+ }
+ }
+
+ // }}}
}
?>
<?php
-// vim:set expandtab tabstop=4 shiftwidth=4 softtabstop=4 foldmethod=marker syntax=php:
+// vim:set expandtab tabstop=4 shiftwidth=4 softtabstop=4 foldmethod=marker syntax=php:
/**
* File Doc Comment
* @category MembersDB
* @package Toolkit_Members
* @author Jamie Kahgee <jamie.kahgee@gmail.com>
- * @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
*/
/**
* @package Toolkit_Members
* @author Jamie Kahgee <jamie.kahgee@gmail.com>
* @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'
* @param string $target (optional)Form's target defaults to '_self'
* @param mixed $attributes (optional)Extra attributes for <form> 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',
$attributes = null,
$trackSubmit = false
) {
- parent::__construct(
+ parent::__construct(
$pdo,
$formName,
$method,
$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'] = '<img alt="'.$row['update'].'"
- src="'.MEMBER_PHOTOS.$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'] = '<img alt="'.$row['update'].'"
+ src="'.MEMBER_PHOTOS.$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',
'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
// }}}
- $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'
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()
/**
* @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()
/**
* @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 .= '
- <i>
- <input id="catid'.$category['category_id'].'"
- type="hidden" name="member_cats[]"
- value="'.$category['category_id'].'" >';
- if ( defined('MEMBERS_ONLY_AREA_ON')
- && MEMBERS_ONLY_AREA_ON == true
- ) {
- // do nothing
- } else {
- $out .= '
- <input type="image" name="removeCat" height="16" width="16"
- class="remove" src="'.BASE_URL.'assets/cancel.png"
- value="'.$category['category_id'].'" >';
- }
- $out .= "{$category['name']}</i>";
- }
- } 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 .= '
+ <i>
+ <input id="catid'.$category['category_id'].'"
+ type="hidden" name="member_cats[]"
+ value="'.$category['category_id'].'" >';
+ if ( defined('MEMBERS_ONLY_AREA_ON')
+ && MEMBERS_ONLY_AREA_ON == true
+ ) {
+ // do nothing
+ } else {
+ $out .= '
+ <input type="image" name="removeCat" height="16" width="16"
+ class="remove" src="'.BASE_URL.'assets/cancel.png"
+ value="'.$category['category_id'].'" >';
+ }
+ $out .= "{$category['name']}</i>";
+ }
+ } 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)) {
$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]");
}
}
}
- } 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();
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;
+ }
+
+ // }}}
}
?>