From: Steve Sutton Date: Wed, 25 Feb 2015 16:37:17 +0000 (-0500) Subject: Update for member only section and member_golf X-Git-Tag: v1.0.0^2~71 X-Git-Url: http://cvs2.gaslightmedia.com/gitweb/?a=commitdiff_plain;h=5e9b14c98cc6782a51a51648b6076490855930f4;p=web%2FGaylordGolfMecca.git Update for member only section and member_golf Update to get the member_golf section tab into the member only side. --- diff --git a/Toolkit/Members/Admin/AuthorizeUpdates.php b/Toolkit/Members/Admin/AuthorizeUpdates.php index ca81e0d..e7418d6 100755 --- a/Toolkit/Members/Admin/AuthorizeUpdates.php +++ b/Toolkit/Members/Admin/AuthorizeUpdates.php @@ -1272,11 +1272,13 @@ class Toolkit_Members_Admin_AuthorizeUpdates extends Toolkit_FormBuilder $photoUpdates = $values['member_photos']; $fileUpdates = $values['member_files']; $packageUpdates = $values['member_packages']; + $golfUpdates = $values['member_golf']; unset ($values['member_ccard_type'], $values['member_amenity'], $values['member_files'], $values['member_photos'], - $values['member_packages'] + $values['member_packages'], + $values['member_golf'] ); foreach ($values as $k => $v) { @@ -1372,6 +1374,7 @@ class Toolkit_Members_Admin_AuthorizeUpdates extends Toolkit_FormBuilder $this->commitUpdates($k, array_keys($v), $updates); } $this->updatePackages($packageUpdates); + $this->updateGolf($golfUpdates); $this->updateCCards($ccardUpdates); $this->updateAmenities($amenityUpdates); $this->updatePhotos($photoUpdates); @@ -1630,6 +1633,124 @@ class Toolkit_Members_Admin_AuthorizeUpdates extends Toolkit_FormBuilder } // }}} + /** + * Handle updating any approvals or rejections on the member courses + * + * @param array $courses an array of courses updates and their update status + * + * @return bool True on success, false on error. + * @access protected + */ + protected function updateGolf($courses) + { + if (empty($courses)) { + return true; + } + try { + $this->dbh->beginTransaction(); + // Stmt to find the newest request in the updates table for + // a specific field. + $sql = " + SELECT * + FROM {$this->tableName} + WHERE id = :id"; + + $fetchStmt = $this->dbh->prepare($sql); + // Stmt to update the package + $updateSql = " + UPDATE member_golf + SET %s = :update + WHERE id = :id"; + // Stmt to remove any updates for a package that + // are still in the updates table. + // Remove from updates table. + $sql = " + DELETE FROM {$this->tableName} + WHERE foreign_key = :id + AND field = :field + AND db_table = 'member_golf'"; + + $remStmt = $this->dbh->prepare($sql); + // Loop through all the package field and see if the update was + // accepted or not. If it was accepted, get the update + // row from the updates table and find out if the update + // was to add [update = 1] the card or remove [update = 0]. + // Perform the update, and then remove the requests from the + // updates table. + $values = $this->getSubmitValues(); + $checkToResetPending = array(); + foreach ($courses as $field => $accepted) { + list($id, $field) = explode('_', $field, 2); + $fetchStmt->bindParam(':id', $id, PDO::PARAM_INT); + $fetchStmt->execute(); + $row = $fetchStmt->fetch(PDO::FETCH_ASSOC); + + if ($accepted == 'yes') { + $sql = " + SELECT foreign_key + FROM member_updates + WHERE id = :id"; + $stmt = $this->dbh->prepare($sql); + $stmt->bindParam(':id', $id, PDO::PARAM_INT); + $stmt->execute(); + $row = $stmt->fetch(PDO::FETCH_ASSOC); + $checkToResetPending[] = $row['foreign_key']; + $updtStmt = $this->dbh->prepare(sprintf($updateSql, $field)); + $update = $this->getSubmitValue("{$id}_{$field}_update"); + if (empty($update)) { + $update = $row['update']; + } + $updtStmt->bindParam(':update', $update, PDO::PARAM_STR); + $updtStmt->bindParam(':id', $row['foreign_key'], PDO::PARAM_INT); + $updtStmt->execute(); + + // Remove field from the member_updates table. + $remStmt->bindParam(':field', $field, PDO::PARAM_STR); + $remStmt->bindParam(':id', $row['foreign_key'], PDO::PARAM_INT); + $remStmt->execute(); + } else { + // Remove field from the member_updates table. + $remStmt->bindParam(':field', $field, PDO::PARAM_STR); + $remStmt->bindParam(':id', $row['foreign_key'], PDO::PARAM_INT); + $remStmt->execute(); + } + } + + $checkToResetPending = array_unique($checkToResetPending); + $sql = " + SELECT count(*) as total + FROM member_updates + WHERE db_table = 'member_golf' + AND member_id = :mid + AND foreign_key = :fk"; + $selectStmt = $this->dbh->prepare($sql); + $selectStmt->bindParam(':mid', $_GET['id'], PDO::PARAM_INT); + if (is_array($checkToResetPending) && !empty($checkToResetPending)) { + foreach ($checkToResetPending as $i) { + $selectStmt->bindParam(':fk', $i, PDO::PARAM_INT); + $selectStmt->execute(); + + $row = $selectStmt->fetch(PDO::FETCH_ASSOC); + if ($row['total'] == 0) { + $sql = " + UPDATE member_golf + SET pending = false + WHERE member_id = :mid + AND id = :id"; + + $updateStmt = $this->dbh->prepare($sql); + $updateStmt->bindParam(':mid', $_GET['id'], PDO::PARAM_INT); + $updateStmt->bindParam(':id', $i, PDO::PARAM_INT); + $updateStmt->execute(); + } + } + } + return $this->dbh->commit(); + } catch (PDOException $e) { + $this->dbh->rollBack(); + return Toolkit_Common::handleError($e); + } + } // {{{ updatePhotos() /** diff --git a/Toolkit/Members/Admin/EditCourses.php b/Toolkit/Members/Admin/EditCourses.php index c5e1eff..fc2ba32 100644 --- a/Toolkit/Members/Admin/EditCourses.php +++ b/Toolkit/Members/Admin/EditCourses.php @@ -1059,6 +1059,10 @@ class EditAdminCourse extends Toolkit_FormBuilder WHERE id = {$this->courseId}"; $defaults = $this->dbh->query($sql)->fetch(PDO::FETCH_ASSOC); + //var_dump($this->courseId); + if ($this->courseId === 10) { + //echo '
'.print_r($defaults, true).'
';exit; + } $defaults['curr_image_rmv'] = $defaults['image']; $img = ''; $defaults['curr_image'] = sprintf($img, MEMBER_PHOTOS . $defaults['image']); @@ -1119,13 +1123,6 @@ class EditAdminCourse extends Toolkit_FormBuilder 'name' => 'image', 'display' => 'Upload a Course Photo / Image', ); - $e[] = array( - 'type' => 'submit', - 'req' => false, - 'name' => 'add_rmv', - 'display' => 'Update Course', - 'opts' => array('class' => 'submit') - ); $e[] = array( 'type' => 'text', 'req' => false, @@ -1183,6 +1180,13 @@ class EditAdminCourse extends Toolkit_FormBuilder 'display' => '9 Holes', 'opts' => array('class' => 'text') ); + $e[] = array( + 'type' => 'submit', + 'req' => false, + 'name' => 'add_rmv', + 'display' => 'Update Course', + 'opts' => array('class' => 'submit') + ); $e[] = array( 'type' => 'submit', 'req' => false, diff --git a/Toolkit/Members/EditCourses.php b/Toolkit/Members/EditCourses.php index 83e9d21..4894730 100644 --- a/Toolkit/Members/EditCourses.php +++ b/Toolkit/Members/EditCourses.php @@ -2,10 +2,10 @@ // vim:set expandtab tabstop=4 shiftwidth=4 softtabstop=4 foldmethod=marker syntax=php: /** - * Handles the packages tab in the member record + * Handles the courses tab in the member record * - * Controls setting up the add package form if applicable, and rendering - * each uploaded package edit form to edit/delete the package. + * Controls setting up the add course form if applicable, and rendering + * each uploaded course edit form to edit/delete the course. * * PHP version 5 * @@ -28,9 +28,9 @@ require_once BASE . 'Toolkit/Image/Server.php'; /** * Constructor class to setup the page layout * - * this class determines if the user can upload any more packages to their - * account and if so renders the add package form. It also controls - * rending the individual forms for each previously uploaded package. + * this class determines if the user can upload any more courses to their + * account and if so renders the add course form. It also controls + * rending the individual forms for each previously uploaded course. * * @category MembersDB * @package Toolkit_Members @@ -49,17 +49,17 @@ class Toolkit_Members_EditCourses * @var string * @access public */ - public $tableName = 'member_packages'; + public $tableName = 'member_golf'; /** - * Template used to layout form when editing a package + * Template used to layout form when editing a course * @var string * @access protected */ protected $pageTemplate = 'editCourses.tpl'; /** - * What is the maximum caption length for packages + * What is the maximum caption length for courses * * @var array * @access public @@ -68,7 +68,7 @@ class Toolkit_Members_EditCourses static public $maxTitleLength = 60; /** - * Objects that will go into the page (add form, edit package forms) + * Objects that will go into the page (add form, edit course forms) * @var object * @access protected */ @@ -85,14 +85,14 @@ class Toolkit_Members_EditCourses // {{{ canAddCourses() /** - * Determine if this member can have more packages added to their profile + * Determine if this member can have more courses added to their profile * - * Load the entire package gallery into member via a linked list. + * Load the entire course gallery into member via a linked list. * Then return if the # of linked list nodes is smaller than - * the maximum limit of packages. + * the maximum limit of courses. * * @access protected - * @return boolean If the linked list is smaller than max packages allowed + * @return boolean If the linked list is smaller than max courses allowed */ protected function canAddCourses() { @@ -136,24 +136,24 @@ class Toolkit_Members_EditCourses // {{{ getUploadedCourses() /** - * Get an array of package ids from the DB that have been uploaded for this member + * Get an array of course ids from the DB that have been uploaded for this member * - * - Create a linked list of all the members packages + * - Create a linked list of all the members courses * - Walk through the linked list extracting the id from each node into an array * * @access protected - * @return array Ids of all uploaded packages for this member + * @return array Ids of all uploaded courses for this member */ protected function getUploadedCourses() { $id = $GLOBALS['memberAuth']->getAuthData('member_id'); - $packages = new Toolkit_Members_Courses(null, $id); - $packages->setDbh($this->dbh); - $packages->createMemberList(); - $packages->rewind(); + $courses = new Toolkit_Members_Courses(null, $id); + $courses->setDbh($this->dbh); + $courses->createMemberList(); + $courses->rewind(); $ids = array(); - foreach ($packages as $i) { + foreach ($courses as $i) { $ids[] = $i->getId(); } @@ -165,14 +165,14 @@ class Toolkit_Members_EditCourses // {{{ setUpPage() /** - * Sets up the page to manipulate packages for a member + * Sets up the page to manipulate courses for a member * - * Checks if all the packages uploaded for a member (pending & non-pending) - * exceed or match the maximum # of packages allowed for each member to + * Checks if all the courses uploaded for a member (pending & non-pending) + * exceed or match the maximum # of courses allowed for each member to * upload to their account. * - * For every package that is already uploaded, create an edit-package form that - * will allow the user to update the caption or delete the package. + * For every course that is already uploaded, create an edit-course form that + * will allow the user to update the caption or delete the course. * * @param Config_Container $c Application configuration * @@ -183,12 +183,12 @@ class Toolkit_Members_EditCourses { $this->page = new StdClass; - // Find out if we can still add packages to the record. + // Find out if we can still add courses to the record. // If we can, then add the upload form to the page for the member to see. if ($this->canAddCourses()) { $addForm = new AddCourse( $this->dbh, - 'new_member_package', + 'new_member_course', 'post', '', '', @@ -200,15 +200,15 @@ class Toolkit_Members_EditCourses $this->page->uploadForm = $addForm->toHtml($this->tEngine); } - // Find out if we have any packages already uploaded. - // If we do, then add the edit package form to the page for each package - // so the member can edit/delete their packages. - if ($packages = $this->getUploadedCourses()) { + // Find out if we have any courses already uploaded. + // If we do, then add the edit course form to the page for each course + // so the member can edit/delete their courses. + if ($courses = $this->getUploadedCourses()) { $this->page->editForm = array(); - while (list($i, $j) = each($packages)) { + while (list($i, $j) = each($courses)) { $editForm = new EditCourse( $this->dbh, - "edit_member_package_$j", + "edit_member_course_$j", 'post', '', '', @@ -226,11 +226,11 @@ class Toolkit_Members_EditCourses } /** - * Form to handle creating a new package in the members only area + * Form to handle creating a new course in the members only area * - * Handles inserting new package into db as a pending package and creating a + * Handles inserting new course into db as a pending course and creating a * tuple in the member_updates table which will allow the admin to - * approve/deny the new package request. + * approve/deny the new course request. * * @category MembersDB * @package Toolkit_Members @@ -249,7 +249,7 @@ class AddCourse extends Toolkit_FormBuilder * @var string * @access public */ - public $tableName = 'member_packages'; + public $tableName = 'member_golf'; /** * The template used to render the form @@ -284,7 +284,7 @@ class AddCourse extends Toolkit_FormBuilder */ protected $successMsg = '
- You successfully uploaded your package. + You successfully uploaded your course.
'; /** @@ -397,42 +397,6 @@ class AddCourse extends Toolkit_FormBuilder 'opts' => array('id' => 'descrAdd', 'class' => 'ckeditor'), 'noCharLimit' => true ); - $e[] = array( - 'type' => 'date', - 'req' => true, - 'name' => 'sdate', - 'display' => 'Start Date', - 'opts' => array( - 'format' => 'm / d / Y', - 'minYear' => date('Y'), - 'maxYear' => date('Y') + 10, - 'addEmptyOption' => true, - 'emptyOptionValue' => '', - 'emptyOptionText' => array( - 'm' => 'mm', - 'd' => 'dd', - 'Y' => 'yyyy', - ), - ) - ); - $e[] = array( - 'type' => 'date', - 'req' => true, - 'name' => 'edate', - 'display' => 'End Date', - 'opts' => array( - 'format' => 'm / d / Y', - 'minYear' => date('Y'), - 'maxYear' => date('Y') + 10, - 'addEmptyOption' => true, - 'emptyOptionValue' => '', - 'emptyOptionText' => array( - 'm' => 'mm', - 'd' => 'dd', - 'Y' => 'yyyy', - ), - ) - ); $e[] = array( 'type' => 'checkbox', 'req' => false, @@ -456,11 +420,68 @@ class AddCourse extends Toolkit_FormBuilder 'name' => 'image', 'display' => 'Upload a Course Photo / Image', ); + $e[] = array( + 'type' => 'text', + 'req' => false, + 'name' => 'res_url', + 'display' => 'TeeTime URL', + 'opts' => array('class' => 'text'), + 'noCharLimit' => 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') + ); $e[] = array( 'type' => 'submit', 'req' => false, 'name' => 'add_rmv', - 'display' => 'Upload new package', + 'display' => 'Upload new course', 'opts' => array('class' => 'submit') ); @@ -481,24 +502,6 @@ class AddCourse extends Toolkit_FormBuilder $r = array(); $checkDate = create_function('$d', '$d = implode("-", $d); return Validate::date($d, array("format" => "%n-%j-%Y"));'); - $r[] = array( - 'element' => 'sdate', - 'message' => 'ERROR: Invalid Date!', - 'type' => 'callback', - 'format' => $checkDate, - 'validation' => $this->validationType, - 'reset' => false, - 'force' => false - ); - $r[] = array( - 'element' => 'edate', - 'message' => 'ERROR: Invalid Date!', - 'type' => 'callback', - 'format' => $checkDate, - 'validation' => $this->validationType, - 'reset' => false, - 'force' => false - ); $r[] = array( 'element' => 'image', 'message' => 'ERROR: Incorrect File Type (.gif, .png, .jpg) only!', @@ -659,11 +662,11 @@ class AddCourse extends Toolkit_FormBuilder // {{{ insertData() /** - * Create a new package in the db + * Create a new course in the db * * @param array &$values Form submitted values * - * @return object db result of adding package + * @return object db result of adding course * @access protected */ protected function insertData(&$values) @@ -711,7 +714,7 @@ class AddCourse extends Toolkit_FormBuilder try { $sql = " SELECT * - FROM member_packages + FROM member_golf WHERE member_id = :member_id ORDER BY id DESC LIMIT 1"; @@ -751,7 +754,7 @@ class AddCourse extends Toolkit_FormBuilder ); }*/ $stmt = $this->dbh->prepare($sql); - $stmt->bindValue(':db_table', 'member_packages', PDO::PARAM_STR); + $stmt->bindValue(':db_table', 'member_golf', PDO::PARAM_STR); $stmt->bindValue(':data_type', 'text', PDO::PARAM_STR); $stmt->bindValue(':field_type', 'text', PDO::PARAM_STR); $stmt->bindParam(':foreign_key', $row['id'], PDO::PARAM_INT); @@ -788,14 +791,12 @@ class AddCourse extends Toolkit_FormBuilder $e =& $this->getElement('curr_image_rmv'); - $packages = new Toolkit_Members_Courses(null, $id); - $packages->setDbh($this->dbh); - $packages->createMemberList(); - $values['pos'] = $packages->getListSize() + 1; + $courses = new Toolkit_Members_Courses(null, $id); + $courses->setDbh($this->dbh); + $courses->createMemberList(); + $values['pos'] = $courses->getListSize() + 1; $values['image'] = $e->getValue('curr_image_rmv'); $values['member_id'] = $GLOBALS['memberAuth']->getAuthData('member_id'); - $values['sdate'] = implode('-', $values['sdate']); - $values['edate'] = implode('-', $values['edate']); unset($values['MAX_FILE_SIZE'], $values['curr_image_rmv'], $values['remove_img_rmv'], @@ -809,7 +810,7 @@ class AddCourse extends Toolkit_FormBuilder $this->emailOwner(); $listPage = MEDIA_BASE_URL . - "members-only-area/?rt=EditProfile&tab=packages"; + "members-only-area/?rt=EditProfile&tab=courses"; header("Location: $listPage"); } @@ -1023,10 +1024,10 @@ class AddCourse extends Toolkit_FormBuilder } /** - * Form to handle editing/deleting existing packages in members only area + * Form to handle editing/deleting existing courses in members only area * * Handles updating caption requests for a member or to remove a - * package from thier profile + * course from thier profile * * @category MembersDB * @package Toolkit_Members @@ -1046,7 +1047,7 @@ class EditCourse extends Toolkit_FormBuilder * @var string * @access public */ - public $tableName = 'member_packages'; + public $tableName = 'member_golf'; /** * The template used to render the form @@ -1068,11 +1069,11 @@ class EditCourse extends Toolkit_FormBuilder protected $emailTemplate = 'emailOwner.tpl'; /** - * Id of package in db + * Id of course in db * @var integer * @access protected */ - protected $packageId; + protected $courseId; /** * Description for protected @@ -1081,7 +1082,7 @@ class EditCourse extends Toolkit_FormBuilder */ protected $successMsg = '
- You successfully updated your package. + You successfully updated your course.
'; /** @@ -1144,11 +1145,11 @@ class EditCourse extends Toolkit_FormBuilder $trackSubmit ); - $this->packageId = $attributes['id']; + $this->courseId = $attributes['id']; $id = $GLOBALS['memberAuth']->getAuthData('member_id'); - $this->packages = new Toolkit_Members_Courses(null, $id); - $this->packages->setDbh($pdo); - $this->packages->createMemberList(); + $this->courses = new Toolkit_Members_Courses(null, $id); + $this->courses->setDbh($pdo); + $this->courses->createMemberList(); $this->dbh = $pdo; } @@ -1188,7 +1189,7 @@ class EditCourse extends Toolkit_FormBuilder $sql = " SELECT * FROM {$this->tableName} - WHERE id = {$this->packageId}"; + WHERE id = {$this->courseId}"; $defaults = $this->dbh->query($sql)->fetch(PDO::FETCH_ASSOC); $defaults['curr_image_rmv'] = $defaults['image']; @@ -1204,11 +1205,11 @@ class EditCourse extends Toolkit_FormBuilder SELECT max(id) FROM member_updates WHERE foreign_key = :foreign_key - AND db_table = 'member_packages' + AND db_table = 'member_golf' GROUP BY field)"; $stmt = $this->dbh->prepare($sql); - $stmt->execute(array($this->packageId)); + $stmt->execute(array($this->courseId)); while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) { if ($row['field'] == 'title') { $defaults['title'] = $row['update']; @@ -1248,45 +1249,9 @@ class EditCourse extends Toolkit_FormBuilder 'req' => false, 'name' => 'description', 'display' => 'Course Description', - 'opts' => array('id' => 'descr' . $this->packageId, 'class' => 'ckeditor'), + 'opts' => array('id' => 'descr' . $this->courseId, 'class' => 'ckeditor'), 'noCharLimit' => true ); - $e[] = array( - 'type' => 'date', - 'req' => true, - 'name' => 'sdate', - 'display' => 'Start Date', - 'opts' => array( - 'format' => 'm / d / Y', - 'minYear' => date('Y'), - 'maxYear' => date('Y') + 10, - 'addEmptyOption' => true, - 'emptyOptionValue' => '', - 'emptyOptionText' => array( - 'm' => 'mm', - 'd' => 'dd', - 'Y' => 'yyyy', - ), - ) - ); - $e[] = array( - 'type' => 'date', - 'req' => true, - 'name' => 'edate', - 'display' => 'End Date', - 'opts' => array( - 'format' => 'm / d / Y', - 'minYear' => date('Y'), - 'maxYear' => date('Y') + 10, - 'addEmptyOption' => true, - 'emptyOptionValue' => '', - 'emptyOptionText' => array( - 'm' => 'mm', - 'd' => 'dd', - 'Y' => 'yyyy', - ), - ) - ); $e[] = array( 'type' => 'checkbox', 'req' => false, @@ -1304,6 +1269,63 @@ class EditCourse extends Toolkit_FormBuilder 'req' => false, 'name' => 'curr_image_rmv', ); + $e[] = array( + 'type' => 'text', + 'req' => false, + 'name' => 'res_url', + 'display' => 'TeeTime URL', + 'opts' => array('class' => 'text'), + 'noCharLimit' => 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') + ); $e[] = array( 'type' => 'file', 'req' => false, @@ -1342,24 +1364,6 @@ class EditCourse extends Toolkit_FormBuilder $r = array(); $checkDate = create_function('$d', '$d = implode("-", $d); return Validate::date($d, array("format" => "%n-%j-%Y"));'); - $r[] = array( - 'element' => 'sdate', - 'message' => 'ERROR: Invalid Date!', - 'type' => 'callback', - 'format' => $checkDate, - 'validation' => $this->validationType, - 'reset' => false, - 'force' => false - ); - $r[] = array( - 'element' => 'edate', - 'message' => 'ERROR: Invalid Date!', - 'type' => 'callback', - 'format' => $checkDate, - 'validation' => $this->validationType, - 'reset' => false, - 'force' => false - ); $r[] = array( 'element' => 'image', 'message' => 'ERROR: Incorrect File Type (.gif, .png, .jpg) only!', @@ -1479,7 +1483,7 @@ class EditCourse extends Toolkit_FormBuilder ); }*/ $stmt = $this->dbh->prepare($sql); - $stmt->bindValue(':db_table', 'member_packages', PDO::PARAM_STR); + $stmt->bindValue(':db_table', 'member_golf', PDO::PARAM_STR); $stmt->bindValue(':data_type', 'text', PDO::PARAM_STR); $stmt->bindValue(':field_type', 'text', PDO::PARAM_STR); $stmt->bindParam(':foreign_key', $values['id'], PDO::PARAM_INT); @@ -1596,8 +1600,6 @@ class EditCourse extends Toolkit_FormBuilder $e =& $this->getElement('curr_image_rmv'); $values['image'] = $e->getValue('curr_image_rmv'); - $values['sdate'] = implode('-', $values['sdate']); - $values['edate'] = implode('-', $values['edate']); unset($values['MAX_FILE_SIZE'], $values['curr_image_rmv'], $values['remove_img_rmv'], @@ -1615,7 +1617,7 @@ class EditCourse extends Toolkit_FormBuilder } $listPage = MEDIA_BASE_URL . - "members-only-area/?rt=EditProfile&tab=packages"; + "members-only-area/?rt=EditProfile&tab=courses"; header("Location: $listPage"); } @@ -1789,7 +1791,7 @@ class EditCourse extends Toolkit_FormBuilder { try { $this->dbh->beginTransaction(); - // need to delete the image associated w/ this package here. + // need to delete the image associated w/ this course here. $sql = " DELETE FROM {$this->tableName} WHERE id = :id @@ -1831,7 +1833,7 @@ class EditCourse extends Toolkit_FormBuilder // {{{ updateData() /** - * Update the package caption + * Update the course caption * * @param array $values Submitted form values * @@ -1842,13 +1844,12 @@ class EditCourse extends Toolkit_FormBuilder { try { if (array_key_exists('remove_rmv', $values)) { - return $this->removeCourse($this->packageId); + return $this->removeCourse($this->courseId); } $this->dbh->beginTransaction(); $pending = $values; $pending['member_id'] = $GLOBALS['memberAuth']->getAuthData('member_id'); - unset($pending['sdate'], $pending['edate']); unset($values['title'], $values['description']); $sql = Toolkit_Common::createSQLUpdate( $this->tableName, @@ -1856,8 +1857,8 @@ class EditCourse extends Toolkit_FormBuilder array('id = :id') ); - //$values['id'] = $this->packageId; - $pending['id'] = $values['id'] = $this->packageId; + //$values['id'] = $this->courseId; + $pending['id'] = $values['id'] = $this->courseId; $res = Toolkit_Common::processQuery( $this->dbh, $this->tableName, diff --git a/Toolkit/Members/MembersOnly/Controller.php b/Toolkit/Members/MembersOnly/Controller.php index 3f06b0e..7c4b834 100644 --- a/Toolkit/Members/MembersOnly/Controller.php +++ b/Toolkit/Members/MembersOnly/Controller.php @@ -28,18 +28,18 @@ */ class Toolkit_Members_MembersOnly_Controller { - // {{{ properties + // {{{ properties /** * Member ID * @var int * @access private */ - private $_mid; + private $_mid; - // }}} + // }}} - // {{{ __construct() + // {{{ __construct() /** * Class constructor @@ -49,23 +49,23 @@ class Toolkit_Members_MembersOnly_Controller * @throws InvalidArgumentException * @access public */ - public function __construct($mid) - { - if (!ctype_digit((string)$mid)) { - throw new InvalidArgumentException( - '$mid must be an integer' - ); - } + public function __construct($mid) + { + if (!ctype_digit((string)$mid)) { + throw new InvalidArgumentException( + '$mid must be an integer' + ); + } - $this->_mid = $mid; - $_GET['catid'] = $page_id = ($_REQUEST['page_id']) - ? $_REQUEST['page_id'] - : MEMBERS_ONLY_CATEGORY; - } + $this->_mid = $mid; + $_GET['catid'] = $page_id = ($_REQUEST['page_id']) + ? $_REQUEST['page_id'] + : MEMBERS_ONLY_CATEGORY; + } - // }}} + // }}} - // {{{ getPage() + // {{{ getPage() /** @@ -79,67 +79,67 @@ class Toolkit_Members_MembersOnly_Controller * @return string|mixed Mixed only from error * @access public */ - public function getPage( - PDO $dbh, - Config_Container $config, - Toolkit_Members_MembersOnly_Navigation $nav, - $template - ) { - $toolbox = new GLM_TEMPLATE($_GET['catid']); - $tEngine = new HTML_Template_Flexy($GLOBALS['flexyOptions']); - $page = new Toolkit_Page($toolbox); - - $navArray = $nav->getNavStructure($dbh, $config); - $page->sideNav = $nav->renderPageNav($navArray, 'tree'); - $page->title = $toolbox->title(); - - $page->toolboxContent = ''; - - if (isset($_GET['Option']) && isset($_GET['Action'])) { - if ( $_GET['Option'] == 'Member' - && $_GET['Action'] == 'Edit' - ) { - $toolbox->set_catid(MEMBERS_PROFILE_FORM_PAGE); - $page->toolboxContent = $toolbox->get_page(); - } elseif ( $_GET['Option'] == 'Coupons' - && $_GET['Action'] == 'List' - ) { - $toolbox->set_catid(MEMBERS_COUPONS_PAGE); - $page->toolboxContent = $toolbox->get_page(); - } elseif ( $_GET['Option'] == 'Events' - && $_GET['Action'] == 'List' - ) { - $toolbox->set_catid(MEMBERS_EVENTS_PAGE); - $page->toolboxContent = $toolbox->get_page(); - } elseif ( $_GET['Option'] == 'Reports' - && $_GET['Action'] == 'List' - ) { - $toolbox->set_catid(MEMBERS_REPORTS_PAGE); - $page->toolboxContent = $toolbox->get_page(); - } - } - - try { - $method = $this->_getMethod(); - } catch (BadMethodCallException $e) { - return Toolkit_Common::handleError($e); - } - - if ($method = $this->_getMethod()) { - $page->toolboxContent .= $this->$method(); - } else { - $page->toolboxContent .= $toolbox->get_page(); - } - - $page->bottomScripts = Toolkit_Common::getScripts($GLOBALS['bottomScripts']); - $page->styles = Toolkit_Common::getStyleSheets(); - - $tEngine->compile($template); - return $tEngine->bufferedOutputObject($page); - } - - // }}} - // {{{ _getMethod() + public function getPage( + PDO $dbh, + Config_Container $config, + Toolkit_Members_MembersOnly_Navigation $nav, + $template + ) { + $toolbox = new GLM_TEMPLATE($_GET['catid']); + $tEngine = new HTML_Template_Flexy($GLOBALS['flexyOptions']); + $page = new Toolkit_Page($toolbox); + + $navArray = $nav->getNavStructure($dbh, $config); + $page->sideNav = $nav->renderPageNav($navArray, 'tree'); + $page->title = $toolbox->title(); + + $page->toolboxContent = ''; + + if (isset($_GET['Option']) && isset($_GET['Action'])) { + if ( $_GET['Option'] == 'Member' + && $_GET['Action'] == 'Edit' + ) { + $toolbox->set_catid(MEMBERS_PROFILE_FORM_PAGE); + $page->toolboxContent = $toolbox->get_page(); + } elseif ( $_GET['Option'] == 'Coupons' + && $_GET['Action'] == 'List' + ) { + $toolbox->set_catid(MEMBERS_COUPONS_PAGE); + $page->toolboxContent = $toolbox->get_page(); + } elseif ( $_GET['Option'] == 'Events' + && $_GET['Action'] == 'List' + ) { + $toolbox->set_catid(MEMBERS_EVENTS_PAGE); + $page->toolboxContent = $toolbox->get_page(); + } elseif ( $_GET['Option'] == 'Reports' + && $_GET['Action'] == 'List' + ) { + $toolbox->set_catid(MEMBERS_REPORTS_PAGE); + $page->toolboxContent = $toolbox->get_page(); + } + } + + try { + $method = $this->_getMethod(); + } catch (BadMethodCallException $e) { + return Toolkit_Common::handleError($e); + } + + if ($method = $this->_getMethod()) { + $page->toolboxContent .= $this->$method(); + } else { + $page->toolboxContent .= $toolbox->get_page(); + } + + $page->bottomScripts = Toolkit_Common::getScripts($GLOBALS['bottomScripts']); + $page->styles = Toolkit_Common::getStyleSheets(); + + $tEngine->compile($template); + return $tEngine->bufferedOutputObject($page); + } + + // }}} + // {{{ _getMethod() /** * Description of _getMethod @@ -148,28 +148,28 @@ class Toolkit_Members_MembersOnly_Controller * @access private * @throws BadMethodCallException */ - private function _getMethod() - { - $act = strtolower($_GET['Action']); - $opt = ucfirst($_GET['Option']); - - if (!empty($opt) && !empty($act)) { - $methodName = "_{$act}{$opt}"; - - if (!method_exists($this, $methodName)) { - throw new BadMethodCallException( - "Invalid method $methodName" - ); - } - - return $methodName; - } else { - // no method to call - return false; - } - } - - // }}} + private function _getMethod() + { + $act = strtolower($_GET['Action']); + $opt = ucfirst($_GET['Option']); + + if (!empty($opt) && !empty($act)) { + $methodName = "_{$act}{$opt}"; + + if (!method_exists($this, $methodName)) { + throw new BadMethodCallException( + "Invalid method $methodName" + ); + } + + return $methodName; + } else { + // no method to call + return false; + } + } + + // }}} // {{{ _deleteEvents() /** * description for _deleteEvents() @@ -191,7 +191,7 @@ class Toolkit_Members_MembersOnly_Controller }// }}} - // {{{ _editMember() + // {{{ _editMember() /** * Description for _editMember() @@ -199,19 +199,19 @@ class Toolkit_Members_MembersOnly_Controller * @return string * @access private */ - private function _editMember() - { - // need to work at removing this - $_REQUEST['id'] = $_GET['id'] = $this->_mid; + private function _editMember() + { + // need to work at removing this + $_REQUEST['id'] = $_GET['id'] = $this->_mid; - $dbh = Toolkit_Database::getInstance(); - $member = new Toolkit_Membersonly(); - return $member->toHtml($dbh, $this->_mid); - } + $dbh = Toolkit_Database::getInstance(); + $member = new Toolkit_Membersonly(); + return $member->toHtml($dbh, $this->_mid); + } - // }}} + // }}} - // {{{ _listReports() + // {{{ _listReports() /** * Description for _listReports @@ -219,49 +219,49 @@ class Toolkit_Members_MembersOnly_Controller * @return string * @access private */ - private function _listReports() - { - $dReport = new Toolkit_Members_ExposureDetailReports( - Toolkit_Database::getInstance() - ); - $dReport->setQuery($this->_mid); - $dReport->setDefaultSort(array('month' => 'desc')); - - $rEngine = new Structures_DataGrid_Renderer_Flexy(); - $tplOpts = Toolkit_Members::getFlexyOptions(); - $tEngine = new HTML_Template_Flexy($tplOpts); - $rEngine->setContainer($tEngine); - - $out = $dReport->toHtml($rEngine); - - if ( defined('EXPOSURE_REPORTS_LIST') - && EXPOSURE_REPORTS_LIST - ) { - $eReports = new Toolkit_Members_ExposureReports( - Toolkit_Database::getInstance() - ); - $eReports->setQuery($_REQUEST['reportMonth']); - - $out .= $eReports->toHtml($rEngine); - } else { - $out .= "

Exposure Reports

\n"; - $out .= "

\n"; - $out .= "Exposure Reports - Check the statistics being compiled that include:\n"; - $out .= "