Update to get the member_golf section tab into the member only side.
$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) {
$this->commitUpdates($k, array_keys($v), $updates);
}
$this->updatePackages($packageUpdates);
+ $this->updateGolf($golfUpdates);
$this->updateCCards($ccardUpdates);
$this->updateAmenities($amenityUpdates);
$this->updatePhotos($photoUpdates);
}
// }}}
+ /**
+ * 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()
/**
WHERE id = {$this->courseId}";
$defaults = $this->dbh->query($sql)->fetch(PDO::FETCH_ASSOC);
+ //var_dump($this->courseId);
+ if ($this->courseId === 10) {
+ //echo '<pre>'.print_r($defaults, true).'</pre>';exit;
+ }
$defaults['curr_image_rmv'] = $defaults['image'];
$img = '<img src="%s">';
$defaults['curr_image'] = sprintf($img, MEMBER_PHOTOS . $defaults['image']);
'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,
'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,
// 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
*
/**
* 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
* @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
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
*/
// {{{ 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()
{
// {{{ 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();
}
// {{{ 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
*
{
$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',
'',
'',
$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',
'',
'',
}
/**
- * 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
* @var string
* @access public
*/
- public $tableName = 'member_packages';
+ public $tableName = 'member_golf';
/**
* The template used to render the form
*/
protected $successMsg
= '<div id="form-success-top">
- You successfully uploaded your package.
+ You successfully uploaded your course.
</div>';
/**
'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,
'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')
);
$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!',
// {{{ 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)
try {
$sql = "
SELECT *
- FROM member_packages
+ FROM member_golf
WHERE member_id = :member_id
ORDER BY id DESC LIMIT 1";
);
}*/
$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);
$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'],
$this->emailOwner();
$listPage = MEDIA_BASE_URL .
- "members-only-area/?rt=EditProfile&tab=packages";
+ "members-only-area/?rt=EditProfile&tab=courses";
header("Location: $listPage");
}
}
/**
- * 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
* @var string
* @access public
*/
- public $tableName = 'member_packages';
+ public $tableName = 'member_golf';
/**
* The template used to render the form
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
*/
protected $successMsg
= '<div id="form-success-top">
- You successfully updated your package.
+ You successfully updated your course.
</div>';
/**
$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;
}
$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'];
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'];
'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,
'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,
$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!',
);
}*/
$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);
$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'],
}
$listPage = MEDIA_BASE_URL .
- "members-only-area/?rt=EditProfile&tab=packages";
+ "members-only-area/?rt=EditProfile&tab=courses";
header("Location: $listPage");
}
{
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
// {{{ updateData()
/**
- * Update the package caption
+ * Update the course caption
*
* @param array $values Submitted form values
*
{
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,
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,
*/
class Toolkit_Members_MembersOnly_Controller
{
- // {{{ properties
+ // {{{ properties
/**
* Member ID
* @var int
* @access private
*/
- private $_mid;
+ private $_mid;
- // }}}
+ // }}}
- // {{{ __construct()
+ // {{{ __construct()
/**
* Class constructor
* @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()
/**
* @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
* @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()
}// }}}
- // {{{ _editMember()
+ // {{{ _editMember()
/**
* Description for _editMember()
* @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
* @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 .= "<h1>Exposure Reports</h1>\n";
- $out .= "<p>\n";
- $out .= "Exposure Reports - Check the statistics being compiled that include:\n";
- $out .= "<ul>\n";
- $out .= "\t<li>Listed - Number of times your member record was viewed in search result page.</li>\n";
- $out .= "\t<li>Details - Number of times your member profile page was visited.</li>\n";
- $out .= "\t<li>Clicks - Number of times your web site address was clicks on.</li>\n";
- $out .= "</ul\n";
- $out .= "</p>\n";
- $out .= "<br clear=\"all\"></hr>\n";
- }
-
- return $out;
- }
-
- // }}}
-
- // {{{ _pageToolbox()
+ 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 .= "<h1>Exposure Reports</h1>\n";
+ $out .= "<p>\n";
+ $out .= "Exposure Reports - Check the statistics being compiled that include:\n";
+ $out .= "<ul>\n";
+ $out .= "\t<li>Listed - Number of times your member record was viewed in search result page.</li>\n";
+ $out .= "\t<li>Details - Number of times your member profile page was visited.</li>\n";
+ $out .= "\t<li>Clicks - Number of times your web site address was clicks on.</li>\n";
+ $out .= "</ul\n";
+ $out .= "</p>\n";
+ $out .= "<br clear=\"all\"></hr>\n";
+ }
+
+ return $out;
+ }
+
+ // }}}
+
+ // {{{ _pageToolbox()
/**
* Description of _pageToolbox
* @throws RuntimeException
* @access private
*/
- private function _pageToolbox()
- {
- if (!ctype_digit($_GET['page_id'])) {
- throw new RuntimeException(
- '$_GET[\'page_id\'] must be an integer'
- );
- }
-
- $toolbox = new GLM_TEMPLATE($_GET['page_id']);
- $out = $toolbox->get_category();
- $out .= $toolbox->get_listings();
-
- return $out;
- }
-
- // }}}
+ private function _pageToolbox()
+ {
+ if (!ctype_digit($_GET['page_id'])) {
+ throw new RuntimeException(
+ '$_GET[\'page_id\'] must be an integer'
+ );
+ }
+
+ $toolbox = new GLM_TEMPLATE($_GET['page_id']);
+ $out = $toolbox->get_category();
+ $out .= $toolbox->get_listings();
+
+ return $out;
+ }
+
+ // }}}
}
?>
<?php
/**
* IndexController.php
- *
+ *
* PHP Version 5.2
- *
+ *
* @category Toolkit
* @package Members_MembersOnly
* @author Jamie Kahgee <steve@gaslightmedia.com>
/**
* Toolkit_Members_MembersOnly_IndexController
- *
+ *
* Description of Toolkit_Members_MembersOnly_IndexController
- *
+ *
* @category Toolkit
* @package Members_MembersOnly
* @author Jamie Kahgee <steve@gaslightmedia.com>
* @link <>
*/
class Toolkit_Members_MembersOnly_IndexController
- extends Toolkit_BaseControllerAbstract implements Toolkit_IController
+ extends Toolkit_BaseControllerAbstract implements Toolkit_IController
{
- // {{{ indexAction()
+ // {{{ indexAction()
/**
* Description of indexAction()
- *
+ *
* @return void
- * @access public
+ * @access public
*/
- public function indexAction()
- {
- $breadCrumbsFactory = new Toolkit_BreadCrumbsFactory(
- new Toolkit_Toolbox_PageGatewayPublishFactory(
- $this->registry->dbh
- )
- );
- $keywordReplacement = new Toolkit_Template_KeywordReplacement(
- new Toolkit_Toolbox_PageGatewayPublish(
- $this->registry->dbh
- )
- );
- $tEngine = new HTML_Template_Flexy($this->registry->flexyOptions);
- $glmPage = new Toolkit_Page(
- new Toolkit_Template_Page(),
- $breadCrumbsFactory,
- new Toolkit_Toolbox_PageGatewayPublishFactory($this->registry->dbh),
- new Toolkit_Toolbox_ParagraphGatewayPublishFactory($this->registry->dbh),
- new Toolkit_Members_MembersOnly_Navigation_Factory(),
- $keywordReplacement,
- $this->registry->pageid
- );
+ public function indexAction()
+ {
+ $breadCrumbsFactory = new Toolkit_BreadCrumbsFactory(
+ new Toolkit_Toolbox_PageGatewayPublishFactory(
+ $this->registry->dbh
+ )
+ );
+ $keywordReplacement = new Toolkit_Template_KeywordReplacement(
+ new Toolkit_Toolbox_PageGatewayPublish(
+ $this->registry->dbh
+ )
+ );
+ $tEngine = new HTML_Template_Flexy($this->registry->flexyOptions);
+ $glmPage = new Toolkit_Page(
+ new Toolkit_Template_Page(),
+ $breadCrumbsFactory,
+ new Toolkit_Toolbox_PageGatewayPublishFactory($this->registry->dbh),
+ new Toolkit_Toolbox_ParagraphGatewayPublishFactory($this->registry->dbh),
+ new Toolkit_Members_MembersOnly_Navigation_Factory(),
+ $keywordReplacement,
+ $this->registry->pageid
+ );
- //$glmPage->title = $toolbox->title();
+ //$glmPage->title = $toolbox->title();
- $glmPage->fetchPage();
+ $glmPage->fetchPage();
- $glmPage->topScripts = Toolkit_Common::getScripts($GLOBALS['topScripts']);
- $glmPage->bottomScripts = Toolkit_Common::getScripts($GLOBALS['bottomScripts']);
- $glmPage->styles = Toolkit_Common::getStyleSheets();
+ $glmPage->topScripts = Toolkit_Common::getScripts($GLOBALS['topScripts']);
+ $glmPage->bottomScripts = Toolkit_Common::getScripts($GLOBALS['bottomScripts']);
+ $glmPage->styles = Toolkit_Common::getStyleSheets();
- $tEngine->compile('template.html');
- $tEngine->outputObject($glmPage);
- }
+ $tEngine->compile('template.html');
+ $tEngine->outputObject($glmPage);
+ }
- // }}}
+ // }}}
}
<?php
/**
* index.php
- *
+ *
* PHP Version 5.2
- *
+ *
* @category Toolkit
* @package Members_MembersOnly
* @author Steve Sutton <steve@gaslightmedia.com>
$root =& $conf->parseConfig(BASE . 'Toolkit/Members/config.ini', 'IniFile');
$authContainer = new Toolkit_Members_AuthContainer(
- Toolkit_Database::getInstance(),
- array(
- 'table' => 'member',
- 'usernamecol' => 'member_login',
- 'passwordcol' => 'member_passwd',
- 'db_fields' => array('member_id', 'member_name'),
- 'cryptType' => 'none',
- 'db_where' => 'new_member <> true AND active = true',
- )
+ Toolkit_Database::getInstance(),
+ array(
+ 'table' => 'member',
+ 'usernamecol' => 'member_login',
+ 'passwordcol' => 'member_passwd',
+ 'db_fields' => array('member_id', 'member_name'),
+ 'cryptType' => 'none',
+ 'db_where' => 'new_member <> true AND active = true',
+ )
);
$memberAuth = new Toolkit_Members_Auth(
- $root,
- $authContainer,
- '',
- false
+ $root,
+ $authContainer,
+ '',
+ false
);
$memberAuth->setIdle();
$memberAuth->start();
if (isset($_GET['logout'])) {
- $memberAuth->logout();
+ $memberAuth->logout();
}
if (!$memberAuth->checkAuth()) {
- // Manually adjust the authentication status for empty credentials
- if (empty($_POST['username']) || empty($_POST['password'])) {
- $status = -3;
- }
- $status = $memberAuth->getStatus();
- header('Location: ' . MEDIA_BASE_URL . 'index.php?catid=' . MEMBERS_CATEGORY . '&status=' . $status);
+ // Manually adjust the authentication status for empty credentials
+ if (empty($_POST['username']) || empty($_POST['password'])) {
+ $status = -3;
+ }
+ $status = $memberAuth->getStatus();
+ header('Location: ' . MEDIA_BASE_URL . 'index.php?catid=' . MEMBERS_CATEGORY . '&status=' . $status);
} else {
if (!Toolkit_Membersonly::checkMemberExists(
Toolkit_Database::getInstance(),
$status = $memberAuth->getStatus();
header('Location: ' . MEDIA_BASE_URL . 'index.php?catid=' . MEMBERS_CATEGORY . '&status=' . $status);
}
- // Carry over from old code
- // @todo: work to remove
- $pageId = filter_var($_REQUEST['page_id']);
+ // Carry over from old code
+ // @todo: work to remove
+ $pageId = filter_var($_REQUEST['page_id']);
if ($pageId) {
$_GET['catid'] = $pageId;
$_GET['page_id'] = $pageId;
}
- $_GET['catid'] = ctype_digit($_REQUEST['page_id'])
- ? $_REQUEST['page_id']
- : MEMBERS_ONLY_HOME_PAGE;
+ $_GET['catid'] = ctype_digit($_REQUEST['page_id'])
+ ? $_REQUEST['page_id']
+ : MEMBERS_ONLY_HOME_PAGE;
- // Create a new registry so we don't pollute the global namespace
- $registry = new Toolkit_Registry;
+ // Create a new registry so we don't pollute the global namespace
+ $registry = new Toolkit_Registry;
- $registry->cacheOptions = $GLOBALS['cacheOptions'];
- $registry->flexyOptions = $GLOBALS['flexyOptions'];
- $registry->memberId = $memberAuth->getAuthData('member_id');
- $registry->memberName = $memberAuth->getAuthData('member_name');
- $registry->logger = Toolkit_Logger::getLogger();
- $registry->pageid = $_GET['catid'];
- $registry->dbh = Toolkit_Database::getInstance();
+ $registry->cacheOptions = $GLOBALS['cacheOptions'];
+ $registry->flexyOptions = $GLOBALS['flexyOptions'];
+ $registry->memberId = $memberAuth->getAuthData('member_id');
+ $registry->memberName = $memberAuth->getAuthData('member_name');
+ $registry->logger = Toolkit_Logger::getLogger();
+ $registry->pageid = $_GET['catid'];
+ $registry->dbh = Toolkit_Database::getInstance();
- // Create a router so we can get where we need to be.
- $registry->router = new Toolkit_Router($registry);
- $registry->router->setPath(BASE . 'Toolkit/Members/MembersOnly');
- $registry->router->setApplication('Members/MembersOnly');
+ // Create a router so we can get where we need to be.
+ $registry->router = new Toolkit_Router($registry);
+ $registry->router->setPath(BASE . 'Toolkit/Members/MembersOnly');
+ $registry->router->setApplication('Members/MembersOnly');
- $registry->router->loader();
+ $registry->router->loader();
}
'url' => "/?$params",
'desc' => "View and edit $singularType categories",
),
+ 'courses' => array(
+ 'title' => 'Course Profile',
+ 'url' => "/?$params",
+ 'desc' => "View and edit $singularType Course Profile",
+ ),
'amenities' => array(
'title' => 'Amenities',
'url' => "/?$params",
$out = $mp->getPage($nav);
break;
+ case 'courses' :
+ $GLOBALS['bottomScripts'][]
+ = CKEDITOR_JS . '';
+ $GLOBALS['bottomScripts'][]
+ = MEDIA_BASE_URL . 'Toolkit/Members/libjs/edit-member-course.js';
+
+ $mp = new Toolkit_Members_EditCourses($dbh, $tEngine);
+ $mp->setupPage($root);
+ $out = $mp->getPage($nav);
+ break;
+
case 'photos' :
$GLOBALS['bottomScripts'][]
= MEDIA_APP_BASE_URL . 'libjs/jqueryui/1.8.13/js/jquery-ui-1.8.13.custom.min.js';
</ul>
<div id="column">
<div id="subnav"><!-- only if there are subpages -->
- <h2>Services</h2>
- <ul>
- <li><a href="#">Navigation Name</a></li>
- <li><a href="#">Halloisann hu</a></li>
- <li><a href="#">Lorem Ipsum</a></li>
- <li><a href="#">Navigator Tools</a></li>
- <li><a href="#">Nav</a></li>
- <li><a href="#">Navigation Name</a></li>
- <li><a href="#">Halloisann hu</a></li>
- <li><a href="#">Lorem Ipsum</a></li>
- <li><a href="#">Navigator Tools</a></li>
- <li></li>
- </ul>
+ {sideNav:h}
</div><!-- /#subnav -->
</div><!-- /#column -->
<div id="main">
<li id="aAAD">AAD</li>
<li id="aABD">ABD</li>
<li id="aACMS">ACMS</li>
- <li id="aASDS">ASDS</li>
+ <li id="aASDS">ASDS</li>
</ul>
<div id="copyright">
Copyright©<?php echo date('Y');?> {siteName:h} - Produced by <a href="http://www.gaslightmedia.com">Gaslight Media</a>, All Rights Reserved.