public function selectMemberSubmission($memberID, $submissionKey, $dbConnection = null) { $preparedStatement = null; $processed = false; try { if ($memberID !== null && $submissionKey != null) { if ($dbConnection == null) { $dbConnection = DatabaseUtilities::getDatabaseConnection(); } $preparedStatement = $dbConnection->prepare(MemberSubmissionDao::MEMBER_SUBMISSION_SELECT); $preparedStatement->bindParam(MemberSubmissionDao::MEMBER_ID_PARAMETER, $memberID); $preparedStatement->bindParam(MemberSubmissionDao::SUBMISSION_KEY_PARAMETER, $submissionKey, PDO::PARAM_STR); $preparedStatement->execute(); while ($result = $preparedStatement->fetch()) { if ($result[MemberSubmissionDao::COUNT_FIELD] == '1') { $processed = true; } } } } catch (PDOException $ex) { echo 'Caught exception: ' . $ex->getMessage() . "\n"; $processed = false; } $preparedStatement = null; return $processed; }
public function getInstrumentStyles($instrumentID, $dbConnection = null) { $instrumentStyles = null; $preparedStatement = null; try { if ($instrumentID != null) { if ($dbConnection == null) { $dbConnection = DatabaseUtilities::getDatabaseConnection(); } $preparedStatement = $dbConnection->prepare(InstrumentUtilities::INSTRUMENT_STYLE_SELECT); $preparedStatement->bindParam(InstrumentUtilities::INSTRUMENT_TYPE_ID_PARAMETER, $instrumentID); $preparedStatement->execute(); //Should never be more then one record, but secondary condition is there just to be safe. while ($result = $preparedStatement->fetch()) { if ($result[InstrumentUtilities::STYLE_ID_FIELD] != null) { $instrumentStyle = new ReferenceObject($result[InstrumentUtilities::STYLE_ID_FIELD], $result[InstrumentUtilities::STYLE_NAME_FIELD]); $instrumentStyles[] = $instrumentStyle; } } } } catch (Exception $ex) { $instrumentStyles = null; } $preparedStatement = null; return $instrumentStyles; }
public function selectBandImage($bandID, $imageType, $dbConnection = null) { $preparedStatement = null; $bandImage = null; try { if ($bandID !== null) { if ($dbConnection == null) { $dbConnection = DatabaseUtilities::getDatabaseConnection(); } $preparedStatement = $dbConnection->prepare(BandImageDao::BAND_IMAGE_SELECT); $preparedStatement->bindParam(BandImageDao::BAND_ID_PARAMETER, $bandID); $preparedStatement->bindParam(BandImageDao::IMAGE_TYPE_ID_PARAMETER, $imageType); $preparedStatement->execute(); //Should never be more then one record, but secondary condition is there just to be safe. while ($result = $preparedStatement->fetch()) { if ($result[BandImageDao::BAND_ID_FIELD] !== null) { $bandImage = $result[BandImageDao::IMAGE_ID_FIELD]; } } $preparedStatement = null; } } catch (Exception $ex) { echo 'Caught exception: ' . $ex->getMessage() . "\n"; $bandImage = null; } return $bandImage; }
public function deleteBandAdvertisement($advertisementID, $dbConnection = null) { $success = false; try { if ($advertisementID != null) { if ($dbConnection == null) { $dbConnection = DatabaseUtilities::getDatabaseConnection(); } $preparedStatement = $dbConnection->prepare(BandAdvertisementDao::BAND_ADVERTISEMENT_DELETE); $preparedStatement->bindParam(BandAdvertisementDao::ADVERTISEMENT_ID_PARAMETER, $advertisementID); $success = $preparedStatement->execute(); } } catch (PD0Exception $ex) { echo 'insertBandAdvertisement exception: ' . $ex->getMessage(); $success = false; } $preparedStatement = null; return $success; }
public function deleteMemberGenres($memberID, $dbConnection = null) { $preparedStatement = null; $processed = false; try { if ($memberID !== null) { if ($dbConnection == null) { $dbConnection = DatabaseUtilities::getDatabaseConnection(); } //Delete existing member genres. $preparedStatement = $dbConnection->prepare(MemberGenreDao::MEMBER_GENRE_DELETE); $preparedStatement->bindParam(MemberGenreDao::MEMBER_ID_PARAMETER, $memberID); $processed = $preparedStatement->execute(); } } catch (Exception $ex) { $processed = false; echo 'Caught exception: ' . $ex->getMessage() . "\n"; } $preparedStatement = null; return $processed; }
public function selectSessionMemberID($sguid, $dbConnection = null) { $memberID = null; try { if ($dbConnection == null) { $dbConnection = DatabaseUtilities::getDatabaseConnection(); } $preparedStatement = $dbConnection->prepare(SessionDao::SESSION_SELECT); $preparedStatement->bindParam(SessionDao::SGUID_PARAMETER, $sguid); $preparedStatement->execute(); while ($result = $preparedStatement->fetch()) { if ($result[SessionDao::MEMBER_ID_FIELD] != null) { $memberID = $result[SessionDao::MEMBER_ID_FIELD]; } } } catch (Exception $ex) { $memberID = null; } $preparedStatement = null; return $memberID; }
public function login($dbConnection = null) { global $facebook; global $session; $facebookID = null; $loggedIn = false; try { $facebookID = $facebook->getUser(); if ($facebookID != null) { if ($dbConnection == null) { $dbConnection = DatabaseUtilities::getDatabaseConnection(); } $sessionKey = SessionDao::generateSGUID($facebookID, $dbConnection); //If sguid is null, attempt to create users account. if ($sessionKey == null) { //If member account is successfully created, attemp to generate a GUID. if (LoginController::createMemberAccount($facebookID, $facebook)) { //Account should have been created, get SGUID. $sessionKey = SessionDao::generateSGUID($facebookID, $dbConnection); } } //If session key has been created, add to session if ($sessionKey != null) { //Refresh any old sessions. if (SessionDao::updateSession($facebookID, $sessionKey, $dbConnection)) { $_SESSION[LoginController::SESSION_ID] = $sessionKey; $loggedIn = true; } } } else { //User has not authenticated with Facebook. } } catch (Exception $ex) { echo "Exception: " . $ex->getMessage(); $loggedIn = false; } return $loggedIn; }
public function insertMemberPurposes($memberID, $purposeList, $dbConnection = null) { $preparedStatement = null; $processed = false; try { if ($memberID !== null) { if ($dbConnection == null) { $dbConnection = DatabaseUtilities::getDatabaseConnection(); } $preparedStatement = $dbConnection->prepare(MemberPurposeDao::MEMBER_PURPOSE_INSERT); foreach ($purposeList as $purposeID) { $preparedStatement->bindParam(MemberPurposeDao::MEMBER_ID_PARAMETER, $memberID); $preparedStatement->bindParam(MemberPurposeDao::PURPOSE_ID_PARAMETER, $purposeID); $preparedStatement->execute(); } $processed = true; } } catch (Exception $ex) { echo 'Caught exception: ' . $ex->getMessage() . "\n"; } $preparedStatement = null; return $processed; }
public function deleteBandMemberInstruments($bandID, $memberID, $dbConnection = null) { $success = false; $preparedStatement = null; try { if ($memberID !== null) { if ($dbConnection == null) { $dbConnection = DatabaseUtilities::getDatabaseConnection(); } //Delete existing member genres. $preparedStatement = $dbConnection->prepare(BandMemberInstrumentDao::BAND_MEMBER_INSTRUMENT_DELETE); $preparedStatement->bindParam(BandMemberInstrumentDao::BAND_ID_PARAMETER, $bandID); $preparedStatement->bindParam(BandMemberInstrumentDao::MEMBER_ID_PARAMETER, $memberID); if ($preparedStatement->execute()) { $success = true; } } } catch (PDOException $ex) { echo 'Caught exception: ' . $ex->getMessage() . "\n"; } $preparedStatement = null; return $success; }
public function selectAdvertisementGenres($advertisementID, $dbConnection = null) { $preparedStatement = null; $advertisementGenres = null; try { if ($advertisementID !== null) { if ($dbConnection == null) { $dbConnection = DatabaseUtilities::getDatabaseConnection(); } $preparedStatement = $dbConnection->prepare(AdvertisementGenreDao::ADVERTISEMENT_GENRE_SELECT); $preparedStatement->bindParam(AdvertisementGenreDao::ADVERTISEMENT_ID_PARAMETER, $advertisementID); $preparedStatement->execute(); //Should never be more then one record, but secondary condition is there just to be safe. while ($result = $preparedStatement->fetch()) { $advertisementGenres[] = new ReferenceObject($result[AdvertisementGenreDao::GENRE_ID_FIELD], $result[AdvertisementGenreDao::GENRE_NAME_FIELD]); } } } catch (Exception $ex) { echo 'Caught exception: ' . $ex->getMessage() . "\n"; $advertisementGenres = null; } $preparedStatement = null; return $advertisementGenres; }
public static function loadFromID($id) { $record = ASDCLoader::instance()->query("SELECT * FROM `tbl_members_roles` WHERE `id` = {$id} LIMIT 1")->current(); $forbidden_pages = $event_permissions = array(); $records = ASDCLoader::instance()->query("SELECT `page_id` FROM `tbl_members_roles_forbidden_pages` WHERE `role_id` = '{$id}' "); if ($records->length() > 0) { $forbidden_pages = DatabaseUtilities::ResultColumn($records, 'page_id'); } $tmp = ASDCLoader::instance()->query("SELECT * FROM `tbl_members_roles_event_permissions` WHERE `role_id` = '{$id}'"); if ($tmp->length() > 0) { foreach ($tmp as $e) { $event_permissions[$e->event][$e->action] = $e->level; } } return new self($id, $record->name, $event_permissions, $forbidden_pages); }
public function grab(&$param_pool) { $Members = Frontend::instance()->ExtensionManager->create('members'); $Members->initialiseCookie(); if ($Members->isLoggedIn() !== true) { // Oi! you can't be here redirect(URL . '/forbidden/'); exit; } $result = new XMLElement($this->dsParamROOTELEMENT); self::__init(); $db = ASDCLoader::instance(); $sql = 'SELECT SQL_CALC_FOUND_ROWS pinned.entry_id AS `id`, pinned.value AS `pinned`, closed.value AS `closed`, creation_date.local AS `creation-date`, last_active.local AS `last-active`, created_by.member_id AS `created-by-member-id`, created_by.username AS `created-by-username`, last_post.member_id AS `last-post-member-id`, last_post.username AS `last-post-username`, topic.value AS `topic` FROM `tbl_entries_data_%d` AS `pinned` LEFT JOIN `tbl_entries_data_%d` AS `closed` ON pinned.entry_id = closed.entry_id LEFT JOIN `tbl_entries_data_%d` AS `creation_date` ON pinned.entry_id = creation_date.entry_id LEFT JOIN `tbl_entries_data_%d` AS `last_active` ON pinned.entry_id = last_active.entry_id LEFT JOIN `tbl_entries_data_%d` AS `created_by` ON pinned.entry_id = created_by.entry_id LEFT JOIN `tbl_entries_data_%d` AS `last_post` ON pinned.entry_id = last_post.entry_id LEFT JOIN `tbl_entries_data_%d` AS `topic` ON pinned.entry_id = topic.entry_id LEFT JOIN `tbl_entries_data_%d` AS `comments` ON pinned.entry_id = comments.relation_id LEFT JOIN `tbl_entries_data_%d` AS `discussion_comments_member` ON comments.entry_id = discussion_comments_member.entry_id WHERE 1 %s AND (created_by.member_id = %11$d || discussion_comments_member.member_id = %11$d) GROUP BY pinned.entry_id ORDER BY pinned.value ASC, last_active.local DESC LIMIT %12$d, %13$d'; try { $rows = $db->query(sprintf($sql, self::findFieldID('pinned', 'discussions'), self::findFieldID('closed', 'discussions'), self::findFieldID('creation-date', 'discussions'), self::findFieldID('last-active', 'discussions'), self::findFieldID('created-by', 'discussions'), self::findFieldID('last-post', 'discussions'), self::findFieldID('topic', 'discussions'), self::findFieldID('parent-id', 'comments'), self::findFieldID('created-by', 'comments'), isset($this->dsParamFILTERS['id']) && (int) $this->dsParamFILTERS['id'] > 0 ? " AND pinned.entry_id = " . (int) $this->dsParamFILTERS['id'] : NULL, (int) $Members->Member->get('id'), max(0, ($this->dsParamSTARTPAGE - 1) * $this->dsParamLIMIT), $this->dsParamLIMIT)); } catch (Exception $e) { $result->appendChild(new XMLElement('error', General::sanitize(vsprintf('%d: %s on query %s', $db->lastError())))); return $result; } if ($rows->length() == 0) { return $this->emptyXMLSet(); } $total = $db->query('SELECT FOUND_ROWS() AS `total`;')->current()->total; $result->prependChild(General::buildPaginationElement($total, ceil($total * (1 / $this->dsParamLIMIT)), $this->dsParamLIMIT, $this->dsParamSTARTPAGE)); /* stdClass Object ( [id] => 666 [pinned] => yes [closed] => no [creation-date] => 1233599808 [last-active] => 1237161637 [created-by-member-id] => 2126 [created-by-username] => Lewis [last-post-member-id] => 2126 [last-post-username] => Lewis [topic] => Symphony 2 Documentation [comments] => 18 ) <entry id="595" comments="7"> <created-by id="2150">newnomad</created-by> <closed>No</closed> <last-active time="18:30" weekday="1">2009-02-09</last-active> <last-post id="2150">newnomad</last-post> <pinned>No</pinned> <topic handle="viewing-feeds">viewing feeds</topic> <creation-date time="19:31" weekday="3">2009-01-07</creation-date> </entry> */ $param_pool['ds-' . $this->dsParamROOTELEMENT] = DatabaseUtilities::resultColumn($rows, 'id'); foreach ($rows as $r) { // Need to do a seperate query to find the comment counts. try { $comments = $db->query(sprintf("SELECT COUNT(*) AS `count` FROM `tbl_entries_data_%d` WHERE `relation_id` = %d ", self::findFieldID('parent-id', 'comments'), $r->id))->current()->count; } catch (Exception $e) { $result->appendChild(new XMLElement('error', General::sanitize(vsprintf('%d: %s on query %s', $db->lastError())))); return $result; } $entry = new XMLElement('entry', NULL, array('id' => $r->id, 'comments' => $comments)); $entry->appendChild(new XMLElement('created-by', General::sanitize($r->{'created-by-username'}), array('id' => $r->{'created-by-member-id'}))); $entry->appendChild(new XMLElement('last-post', General::sanitize($r->{'last-post-username'}), array('id' => $r->{'last-post-member-id'}))); $entry->appendChild(new XMLElement('closed', ucfirst($r->closed))); $entry->appendChild(new XMLElement('pinned', ucfirst($r->pinned))); $entry->appendChild(new XMLElement('topic', General::sanitize($r->topic))); $entry->appendChild(General::createXMLDateObject($r->{'creation-date'}, 'creation-date')); $entry->appendChild(General::createXMLDateObject($r->{'last-active'}, 'last-active')); $result->appendChild($entry); } return $result; }
private function getBandSearchPreparedStatement($bandSearchQuery, $searchParameters, $dbConnection = null) { $preparedStatement = null; try { if ($dbConnection == null) { $dbConnection = DatabaseUtilities::getDatabaseConnection(); } //Prepare query $preparedStatement = $dbConnection->prepare($bandSearchQuery); if ($searchParameters->getVariable(BandSearchConstants::MEMBER_INPUT_ID) !== null) { $preparedStatement->bindParam(BandSearchDao::MEMBER_ID_PARAMETER, $searchParameters->getVariable(BandSearchConstants::MEMBER_INPUT_ID)); } if ($searchParameters->getVariable(BandSearchConstants::BAND_NAME_INPUT_ID) != null) { $preparedStatement->bindParam(BandSearchDao::BAND_NAME_PARAMETER, strtoupper($searchParameters->getStringVariable(BandSearchConstants::BAND_NAME_INPUT_ID))); } if ($searchParameters->getVariable(BandSearchConstants::GENRE_INPUT_ID) !== null) { $preparedStatement->bindParam(BandSearchDao::GENRE_ID_PARAMETER, implode(',', $searchParameters->getVariable(BandSearchConstants::GENRE_INPUT_ID))); } $inspirations = $searchParameters->getVariable(BandSearchConstants::INSPIRATIONS_INPUT_ID); if ($inspirations != null) { $i = 0; for ($i = 0; $i < count($inspirations); $i++) { $parameterName = BandSearchDao::INSPIRATION_PARAMETER . $i; $inspiration = strip_tags(strtoupper($inspirations[$i])); $preparedStatement->bindParam($parameterName, $inspiration); } } unset($inspirations); if ($searchParameters->getVariable(LocationConstants::LOCATION_COUNTRY_INPUT_ID) !== null) { $preparedStatement->bindParam(BandSearchDao::COUNTRY_ID_PARAMETER, $searchParameters->getVariable(LocationConstants::LOCATION_COUNTRY_INPUT_ID)); } if ($searchParameters->getVariable(LocationConstants::LOCATION_STATE_INPUT_ID) !== null) { $preparedStatement->bindParam(BandSearchDao::STATE_ID_PARAMETER, $searchParameters->getVariable(LocationConstants::LOCATION_STATE_INPUT_ID)); } if ($searchParameters->getVariable(LocationConstants::LOCATION_CITY_INPUT_ID) !== null) { $preparedStatement->bindParam(BandSearchDao::CITY_ID_PARAMETER, $searchParameters->getVariable(LocationConstants::LOCATION_CITY_INPUT_ID)); } if ($searchParameters->getVariable(LocationConstants::LOCATION_REGION_INPUT_ID) !== null) { $preparedStatement->bindParam(BandSearchDao::REGION_ID_PARAMETER, $searchParameters->getVariable(LocationConstants::LOCATION_REGION_INPUT_ID)); } } catch (Exception $ex) { echo "getBandSearchPreparedStatement Error: " . $ex->getMessage(); } return $preparedStatement; }
public function updateMemberInstrument($memberID, $instrumentID, $experienceID, $dbConnection = null) { $preparedStatement = null; $success = false; try { if ($memberID != null && $instrumentID != null && $experienceID != null) { if ($dbConnection == null) { $dbConnection = DatabaseUtilities::getDatabaseConnection(); } $preparedStatement = $dbConnection->prepare(MemberInstrumentDao::MEMBER_INSTRUMENT_UPDATE); $preparedStatement->bindParam(MemberInstrumentDao::MEMBER_ID_PARAMETER, $memberID); $preparedStatement->bindParam(MemberInstrumentDao::INSTRUMENT_TYPE_ID_PARAMETER, $instrumentID); $preparedStatement->bindParam(MemberInstrumentDao::EXPERIENCE_ID_PARAMETER, $experienceID); if ($preparedStatement->execute()) { $success = true; } } } catch (Exception $ex) { $success = false; } $preparedStatement = null; return $success; }
private function getAdvertisementUpdatePreparedStatement($updateQuery, $memberID, $applicationDetails, $dbConnection = null) { if ($dbConnection == null) { $dbConnection = DatabaseUtilities::getDatabaseConnection(); } //Prepare query $preparedStatement = $dbConnection->prepare($updateQuery); $preparedStatement->bindParam(AdvertisementPositionApplicationDao::MODIFIED_BY_PARAMETER, $memberID, PDO::PARAM_INT); if ($applicationDetails->getVariable(AdvertisementPositionApplication::ACTIVE) !== null) { $preparedStatement->bindParam(AdvertisementPositionApplicationDao::ACTIVE_PARAMETER, $applicationDetails->getVariable(AdvertisementPositionApplication::ACTIVE), PDO::PARAM_INT); } $preparedStatement->bindParam(AdvertisementPositionApplicationDao::ADVERTISEMENT_POSITION_ID_PARAMETER, $applicationDetails->getVariable(AdvertisementPositionApplication::ADVERTISEMENT_POSITION_ID)); return $preparedStatement; }
public function view() { Administration::instance()->Page->addStylesheetToHead(URL . '/extensions/members/assets/styles.css', 'screen', 9125341); $formHasErrors = is_array($this->_errors) && !empty($this->_errors); if ($formHasErrors) { $this->pageAlert('An error occurred while processing this form. <a href="#error">See below for details.</a>', AdministrationPage::PAGE_ALERT_ERROR); } $this->setPageType('form'); $this->appendSubheading('Untitled'); $fields = array(); if (isset($_POST['fields'])) { $fields = $_POST['fields']; } $fieldset = new XMLElement('fieldset'); $fieldset->setAttribute('class', 'primary'); $label = Widget::Label('Subject'); $label->appendChild(Widget::Input('fields[subject]', General::sanitize($fields['subject']))); if (isset($this->_errors['subject'])) { $fieldset->appendChild(Widget::wrapFormElementWithError($label, $this->_errors['subject'])); } else { $fieldset->appendChild($label); } $label = Widget::Label('Body'); $label->appendChild(Widget::Textarea('fields[body]', 15, 75, General::sanitize($fields['body']))); if (isset($this->_errors['body'])) { $fieldset->appendChild(Widget::wrapFormElementWithError($label, $this->_errors['body'])); } else { $fieldset->appendChild($label); } $fieldset->appendChild(new XMLElement('p', 'Dynamic fields and parameters can be included in the subject or body of the email using the <code>{$param}</code> syntax. Please see the <a href="http://github.com/symphony/members/blob/master/README.markdown">readme</a> for a complete list of available parameters.', array('class' => 'help'))); $this->Form->appendChild($fieldset); $sidebar = new XMLElement('fieldset'); $sidebar->setAttribute('class', 'secondary'); $label = Widget::Label('Type'); $options = array(array(NULL, false, NULL), array('reset-password', $fields['type'] == 'reset-password', 'Reset Password'), array('new-password', $fields['type'] == 'new-password', 'New Password'), array('activate-account', $fields['type'] == 'activate-account', 'Activate Account'), array('welcome', $fields['type'] == 'welcome', 'Welcome Email')); $label->appendChild(Widget::Select('fields[type]', $options)); if (isset($this->_errors['type'])) { $sidebar->appendChild(Widget::wrapFormElementWithError($label, $this->_errors['type'])); } else { $sidebar->appendChild($label); } $label = Widget::Label('Roles'); $label->appendChild(Widget::Input('fields[roles]', $fields['roles'])); if (isset($this->_errors['roles'])) { $sidebar->appendChild(Widget::wrapFormElementWithError($label, $this->_errors['roles'])); } else { $sidebar->appendChild($label); } $roles = DatabaseUtilities::resultColumn(ASDCLoader::instance()->query("SELECT `name` FROM `tbl_members_roles` ORDER BY `name` ASC"), 'name'); if (is_array($roles) && !empty($roles)) { $taglist = new XMLElement('ul'); $taglist->setAttribute('class', 'tags'); foreach ($roles as $tag) { $taglist->appendChild(new XMLElement('li', $tag)); } $sidebar->appendChild($taglist); } $this->Form->appendChild($sidebar); $div = new XMLElement('div'); $div->setAttribute('class', 'actions'); $div->appendChild(Widget::Input('action[save]', 'Create', 'submit', array('accesskey' => 's'))); $this->Form->appendChild($div); }
public function searchAdvertisements($advertisementSearchParameters, $dbConnection = null) { $advertisementsList = null; $preparedStatement = null; try { $advertisementSearchQuery = null; $advertisementIDQuery = null; if ($dbConnection == null) { $dbConnection = DatabaseUtilities::getDatabaseConnection(); } $advertisementIDQuery = "SELECT DISTINCT AD.ADVERTISEMENT_ID FROM advertisement AD WHERE 1 = 1"; $advertisementIDQuery .= AdvertisementSearchDao::getAdvertisementSearchWhereClause($advertisementSearchParameters); $advertisementSearchQuery = AdvertisementSearchDao::ADVERTISEMENT_SEARCH_SELECT; $advertisementSearchQuery .= " AND AD.ADVERTISEMENT_ID IN (" . $advertisementIDQuery . ")\n\t\t\t\t\t\t\t\t\t\t\t\tORDER BY AD.CREATED_DATE DESC\n\t\t\t\t\t\t\t\t\t\t\t\tLIMIT :pagingAmount OFFSET :startingPoint"; $preparedStatement = AdvertisementSearchDao::getAdvertisementSearchPreparedStatement($advertisementSearchQuery, $advertisementSearchParameters, $dbConnection); //Add paging parameters. $startingPoint = 0; $currentPage = $advertisementSearchParameters->getVariable(SearchConstants::CURRENT_PAGE_ID); $pagingAmount = $advertisementSearchParameters->getVariable(SearchConstants::PAGING_AMOUNT_ID); if ($currentPage > 1) { $startingPoint = ($currentPage - 1) * $pagingAmount; } $pagingAmount = (int) $pagingAmount; $startingPoint = (int) $startingPoint; $preparedStatement->bindParam(":pagingAmount", $pagingAmount, PDO::PARAM_INT); $preparedStatement->bindParam(":startingPoint", $startingPoint, PDO::PARAM_INT); $preparedStatement->execute(); while ($result = $preparedStatement->fetch()) { $advertisement = AdvertisementSearchDao::extractAdvertisementSearchObject($result); if ($advertisement !== null) { $advertisementsList[] = $advertisement; } } $preparedStatement = null; } catch (Exception $ex) { echo $ex->getMessage(); $advertisementsList = null; } $preparedStatement = null; return $advertisementsList; }
public function view() { if (!($email_template_id = $this->_context[0])) { redirect(extension_members::baseURL()); } if (!($existing = EmailTemplate::loadFromID($email_template_id))) { throw new SymphonyErrorPage(__('The email template you requested to edit does not exist.'), __('Email Template not found'), 'error'); } if (isset($this->_context[1])) { switch ($this->_context[1]) { case 'saved': $this->pageAlert(__('Email Template updated at %1$s. <a href="%2$s">Create another?</a> <a href="%3$s">View all Email Template</a>', array(DateTimeObj::getTimeAgo(__SYM_TIME_FORMAT__), extension_members::baseURL() . 'email_templates_new/', extension_members::baseURL() . 'email_templates/')), Alert::SUCCESS); break; case 'created': $this->pageAlert(__('Email Template created at %1$s. <a href="%2$s">Create another?</a> <a href="%3$s">View all Email Template</a>', array(DateTimeObj::getTimeAgo(__SYM_TIME_FORMAT__), extension_members::baseURL() . 'email_templates_new/', extension_members::baseURL() . 'email_templates/')), Alert::SUCCESS); break; } } Administration::instance()->Page->addStylesheetToHead(URL . '/extensions/members/assets/styles.css', 'screen', 9125341); $formHasErrors = is_array($this->_errors) && !empty($this->_errors); if ($formHasErrors) { $this->pageAlert(__('An error occurred while processing this form. <a href="#error">See below for details.</a>'), AdministrationPage::PAGE_ALERT_ERROR); } $this->setPageType('form'); $this->setTitle('Symphony – Member Roles – ' . $existing->subject); $this->appendSubheading($existing->subject); $fields = array(); if (isset($_POST['fields'])) { $fields = $_POST['fields']; } else { $fields['subject'] = $existing->subject; $fields['body'] = $existing->body; $fields['type'] = $existing->type; $fields['roles'] = NULL; foreach ($existing->roles() as $role_id => $r) { $fields['roles'] .= $r->name() . ", "; } $fields['roles'] = trim($fields['roles'], ', '); } $fieldset = new XMLElement('fieldset'); $fieldset->setAttribute('class', 'primary'); $label = Widget::Label('Subject'); $label->appendChild(Widget::Input('fields[subject]', General::sanitize($fields['subject']))); if (isset($this->_errors['subject'])) { $fieldset->appendChild(Widget::wrapFormElementWithError($label, $this->_errors['subject'])); } else { $fieldset->appendChild($label); } $label = Widget::Label('Body'); $label->appendChild(Widget::Textarea('fields[body]', 15, 75, General::sanitize($fields['body']))); if (isset($this->_errors['body'])) { $fieldset->appendChild(Widget::wrapFormElementWithError($label, $this->_errors['body'])); } else { $fieldset->appendChild($label); } $fieldset->appendChild(new XMLElement('p', 'Dynamic fields and parameters can be included in the subject or body of the email using the <code>{$param}</code> syntax. Please see the <a href="http://github.com/symphony/members/blob/master/README.markdown">readme</a> for a complete list of available parameters.', array('class' => 'help'))); $this->Form->appendChild($fieldset); $sidebar = new XMLElement('fieldset'); $sidebar->setAttribute('class', 'secondary'); $label = Widget::Label('Type'); $options = array(array(NULL, false, NULL), array('reset-password', $fields['type'] == 'reset-password', 'Reset Password'), array('new-password', $fields['type'] == 'new-password', 'New Password'), array('activate-account', $fields['type'] == 'activate-account', 'Activate Account'), array('welcome', $fields['type'] == 'welcome', 'Welcome Email')); $label->appendChild(Widget::Select('fields[type]', $options)); if (isset($this->_errors['type'])) { $sidebar->appendChild(Widget::wrapFormElementWithError($label, $this->_errors['type'])); } else { $sidebar->appendChild($label); } $label = Widget::Label('Roles'); $label->appendChild(Widget::Input('fields[roles]', $fields['roles'])); if (isset($this->_errors['roles'])) { $sidebar->appendChild(Widget::wrapFormElementWithError($label, $this->_errors['roles'])); } else { $sidebar->appendChild($label); } $roles = DatabaseUtilities::resultColumn(ASDCLoader::instance()->query("SELECT `name` FROM `tbl_members_roles` ORDER BY `name` ASC"), 'name'); if (is_array($roles) && !empty($roles)) { $taglist = new XMLElement('ul'); $taglist->setAttribute('class', 'tags'); foreach ($roles as $tag) { $taglist->appendChild(new XMLElement('li', $tag)); } $sidebar->appendChild($taglist); } $this->Form->appendChild($sidebar); $div = new XMLElement('div'); $div->setAttribute('class', 'actions'); $div->appendChild(Widget::Input('action[save]', 'Save Changes', 'submit', array('accesskey' => 's'))); $button = new XMLElement('button', __('Delete')); $button->setAttributeArray(array('name' => 'action[delete]', 'class' => 'confirm delete', 'title' => __('Delete this email template'))); $div->appendChild($button); $this->Form->appendChild($div); }
private function getAdvertisementPositionPreparedStatement($updateQuery, $memberID, $positionDetails, $dbConnection = null) { if ($dbConnection == null) { $dbConnection = DatabaseUtilities::getDatabaseConnection(); } //Prepare query $preparedStatement = $dbConnection->prepare($updateQuery); $preparedStatement->bindParam(AdvertisementPositionDao::MODIFIED_BY_PARAMETER, $memberID, PDO::PARAM_INT); if ($positionDetails->getVariable(AdvertisementPosition::POSITION_NUMBER) !== null) { $preparedStatement->bindParam(AdvertisementPositionDao::POSITION_NUMBER_PARAMETER, $positionDetails->getVariable(AdvertisementPosition::POSITION_NUMBER), PDO::PARAM_INT); } if ($positionDetails->getVariable(AdvertisementPosition::INSTRUMENT_ID) !== null) { $preparedStatement->bindParam(AdvertisementPositionDao::INSTRUMENT_TYPE_PARAMETER, $positionDetails->getVariable(AdvertisementPosition::INSTRUMENT_ID), PDO::PARAM_INT); } if ($positionDetails->getVariable(AdvertisementPosition::DURATION_ID) !== null) { $preparedStatement->bindParam(AdvertisementPositionDao::DURATION_ID_PARAMETER, $positionDetails->getVariable(AdvertisementPosition::DURATION_ID), PDO::PARAM_INT); } if ($positionDetails->getVariable(AdvertisementPosition::STYLE_ID) !== null) { $preparedStatement->bindParam(AdvertisementPositionDao::STATE_ID_PARAMETER, $positionDetails->getVariable(AdvertisementPosition::STYLE_ID), PDO::PARAM_INT); } if ($positionDetails->getVariable(AdvertisementPosition::DESCRIPTION) !== null) { $preparedStatement->bindParam(AdvertisementPositionDao::DESCRIPTION_PARAMETER, $positionDetails->getStringVariable(AdvertisementPosition::DESCRIPTION)); } if ($positionDetails->getVariable(AdvertisementPosition::EXPERIENCE_ID) !== null) { $preparedStatement->bindParam(AdvertisementPositionDao::EXPERIENCE_ID_PARAMETER, $positionDetails->getVariable(AdvertisementPosition::EXPERIENCE_ID), PDO::PARAM_INT); } if ($positionDetails->getVariable(AdvertisementPosition::GENDER_ID) !== null) { $preparedStatement->bindParam(AdvertisementPositionDao::GENDER_ID_PARAMETER, $positionDetails->getVariable(AdvertisementPosition::GENDER_ID), PDO::PARAM_INT); } if ($positionDetails->getVariable(AdvertisementPosition::AGE_RANGE_ID) !== null) { $preparedStatement->bindParam(AdvertisementPositionDao::AGE_RANGE_ID_PARAMETER, $positionDetails->getVariable(AdvertisementPosition::AGE_RANGE_ID), PDO::PARAM_INT); } if ($positionDetails->getVariable(AdvertisementPosition::ACTIVE) !== null) { $preparedStatement->bindParam(AdvertisementPositionDao::ACTIVE_PARAMETER, $positionDetails->getVariable(AdvertisementPosition::ACTIVE), PDO::PARAM_INT); } $preparedStatement->bindParam(AdvertisementPositionDao::ADVERTISEMENT_POSITION_ID_PARAMETER, $positionDetails->getVariable(AdvertisementPosition::ADVERTISEMENT_POSITION_ID)); return $preparedStatement; }
private function getAdvertisementUpdatePreparedStatement($updateQuery, $memberID, $advertisementDetails, $dbConnection = null) { if ($dbConnection == null) { $dbConnection = DatabaseUtilities::getDatabaseConnection(); } //Prepare query $preparedStatement = $dbConnection->prepare($updateQuery); $preparedStatement->bindParam(AdvertisementDao::MODIFIED_BY_PARAMETER, $memberID, PDO::PARAM_INT); if ($advertisementDetails->getVariable(Advertisement::ADVERTISEMENT_TYPE_ID) !== null) { $preparedStatement->bindParam(AdvertisementDao::ADVERTISEMENT_TYPE_ID_PARAMETER, $advertisementDetails->getVariable(Advertisement::ADVERTISEMENT_TYPE_ID), PDO::PARAM_INT); } if ($advertisementDetails->getVariable(Advertisement::SUMMARY) !== null) { $preparedStatement->bindParam(AdvertisementDao::SUMMARY_PARAMETER, $advertisementDetails->getStringVariable(Advertisement::SUMMARY)); } if ($advertisementDetails->getVariable(Advertisement::INSPIRATIONS) !== null) { $preparedStatement->bindParam(AdvertisementDao::INSPIRATIONS_PARAMETER, $advertisementDetails->getStringVariable(Advertisement::INSPIRATIONS)); } if ($advertisementDetails->getVariable(Advertisement::OTHER_INFORMATION) !== null) { $preparedStatement->bindParam(AdvertisementDao::OTHER_INFORMATION_PARAMETER, $advertisementDetails->getStringVariable(Advertisement::OTHER_INFORMATION)); } if ($advertisementDetails->getVariable(Advertisement::ACTIVE) !== null) { $preparedStatement->bindParam(AdvertisementDao::ACTIVE_PARAMETER, $advertisementDetails->getVariable(Advertisement::ACTIVE)); } if ($advertisementDetails->getVariable(LocationConstants::COUNTRY_ID) !== null) { $preparedStatement->bindParam(AdvertisementDao::COUNTRY_ID_PARAMETER, $advertisementDetails->getVariable(LocationConstants::COUNTRY_ID), PDO::PARAM_INT); } if ($advertisementDetails->getVariable(LocationConstants::STATE_ID) !== null) { $preparedStatement->bindParam(AdvertisementDao::STATE_ID_PARAMETER, $advertisementDetails->getVariable(LocationConstants::STATE_ID), PDO::PARAM_INT); } if ($advertisementDetails->getVariable(LocationConstants::CITY_ID) !== null) { $preparedStatement->bindParam(AdvertisementDao::CITY_ID_PARAMETER, $advertisementDetails->getVariable(LocationConstants::CITY_ID), PDO::PARAM_INT); } if ($advertisementDetails->getVariable(LocationConstants::REGION_ID) !== null) { $preparedStatement->bindParam(AdvertisementDao::REGION_ID_PARAMETER, $advertisementDetails->getVariable(LocationConstants::REGION_ID), PDO::PARAM_INT); } $preparedStatement->bindParam(AdvertisementDao::ADVERTISEMENT_ID_PARAMETER, $advertisementDetails->getVariable(Advertisement::ADVERTISEMENT_ID)); return $preparedStatement; }
private function getBandMemberSearchPreparedStatement($bandMemberSearchQuery, $bandMemberSearchParameters, $dbConnection = null) { $preparedStatement = null; try { if ($dbConnection == null) { $dbConnection = DatabaseUtilities::getDatabaseConnection(); } //Prepare query $preparedStatement = $dbConnection->prepare($bandMemberSearchQuery); if ($bandMemberSearchParameters->getVariable(SearchBandMemberConstants::BAND_ID_INPUT) !== null) { $preparedStatement->bindParam(BandMemberSearchDao::BAND_ID_PARAMETER, $bandMemberSearchParameters->getVariable(SearchBandMemberConstants::BAND_ID_INPUT)); } if ($bandMemberSearchParameters->getVariable(SearchBandMemberConstants::FIRST_NAME_INPUT_ID) !== null) { $preparedStatement->bindParam(BandMemberSearchDao::FIRST_NAME_PARAMETER, strtoupper($bandMemberSearchParameters->getStringVariable(SearchBandMemberConstants::FIRST_NAME_INPUT_ID))); } if ($bandMemberSearchParameters->getVariable(SearchBandMemberConstants::LAST_NAME_INPUT_ID) !== null) { $preparedStatement->bindParam(BandMemberSearchDao::LAST_NAME_PARAMETER, strtoupper($bandMemberSearchParameters->getStringVariable(SearchBandMemberConstants::LAST_NAME_INPUT_ID))); } if ($bandMemberSearchParameters->getVariable(SearchBandMemberConstants::AGE_INPUT_ID) !== null) { $preparedStatement->bindParam(BandMemberSearchDao::AGE_RANGE_ID_PARAMETER, $bandMemberSearchParameters->getVariable(SearchBandMemberConstants::AGE_INPUT_ID)); } if ($bandMemberSearchParameters->getVariable(SearchBandMemberConstants::GENDER_INPUT_ID) !== null) { $preparedStatement->bindParam(BandMemberSearchDao::GENDER_PARAMETER, $bandMemberSearchParameters->getVariable(SearchBandMemberConstants::GENDER_INPUT_ID)); } if ($bandMemberSearchParameters->getVariable(LocationConstants::LOCATION_COUNTRY_INPUT_ID) !== null) { $preparedStatement->bindParam(BandMemberSearchDao::COUNTRY_ID_PARAMETER, $bandMemberSearchParameters->getVariable(LocationConstants::LOCATION_COUNTRY_INPUT_ID)); } if ($bandMemberSearchParameters->getVariable(LocationConstants::LOCATION_STATE_INPUT_ID) !== null) { $preparedStatement->bindParam(BandMemberSearchDao::STATE_ID_PARAMETER, $bandMemberSearchParameters->getVariable(LocationConstants::LOCATION_STATE_INPUT_ID)); } if ($bandMemberSearchParameters->getVariable(LocationConstants::LOCATION_CITY_INPUT_ID) !== null) { $preparedStatement->bindParam(BandMemberSearchDao::CITY_ID_PARAMETER, $bandMemberSearchParameters->getVariable(LocationConstants::LOCATION_CITY_INPUT_ID)); } if ($bandMemberSearchParameters->getVariable(LocationConstants::LOCATION_REGION_INPUT_ID) !== null) { $preparedStatement->bindParam(BandMemberSearchDao::REGION_ID_PARAMETER, $bandMemberSearchParameters->getVariable(LocationConstants::LOCATION_REGION_INPUT_ID)); } } catch (Exception $ex) { echo "getMemberSearchPreparedStatement Error: " . $ex->getMessage(); } return $preparedStatement; }
public function getMemberSearchPreparedStatement($memberSearchQuery, $memberSearchParameters, $dbConnection = null) { $preparedStatement = null; try { if ($dbConnection == null) { $dbConnection = DatabaseUtilities::getDatabaseConnection(); } //Prepare query $preparedStatement = $dbConnection->prepare($memberSearchQuery); $inspirations = $memberSearchParameters->getVariable(MemberSearchConstants::INSPIRATIONS_INPUT_ID); if ($inspirations != null) { $i = 0; for ($i = 0; $i < count($inspirations); $i++) { $parameterName = MemberSearchDao::MUSIC_PARAMETER . $i; $inspiration = strtoupper($inspirations[$i]); $preparedStatement->bindParam($parameterName, $inspiration); } } unset($inspirations); if ($memberSearchParameters->getVariable(MemberSearchConstants::BAND_INPUT_ID) != null) { $preparedStatement->bindParam(MemberSearchDao::BAND_ID_PARAMETER, $memberSearchParameters->getVariable(MemberSearchConstants::BAND_INPUT_ID)); } if ($memberSearchParameters->getVariable(MemberSearchConstants::FIRST_NAME_INPUT_ID) != null) { $preparedStatement->bindParam(MemberSearchDao::FIRST_NAME_PARAMETER, strtoupper($memberSearchParameters->getStringVariable(MemberSearchConstants::FIRST_NAME_INPUT_ID))); } if ($memberSearchParameters->getVariable(MemberSearchConstants::LAST_NAME_INPUT_ID) != null) { $preparedStatement->bindParam(MemberSearchDao::LAST_NAME_PARAMETER, strtoupper($memberSearchParameters->getStringVariable(MemberSearchConstants::LAST_NAME_INPUT_ID))); } if ($memberSearchParameters->getVariable(MemberSearchConstants::GENRE_INPUT_ID) !== null) { $preparedStatement->bindParam(MemberSearchDao::GENRE_MULTIPLE_IDS_PARAMETER, implode(',', $memberSearchParameters->getVariable(MemberSearchConstants::GENRE_INPUT_ID))); } if ($memberSearchParameters->getVariable(MemberSearchConstants::POSITION_INPUT_ID) !== null) { $preparedStatement->bindParam(MemberSearchDao::INSTRUMENT_TYPE_MULTIPLE_IDS_PARAMETER, implode(',', $memberSearchParameters->getVariable(MemberSearchConstants::POSITION_INPUT_ID))); } if ($memberSearchParameters->getVariable(MemberSearchConstants::EXPERIENCE_INPUT_ID) !== null) { $preparedStatement->bindParam(MemberSearchDao::EXPERIENCE_ID_PARAMETER, $memberSearchParameters->getVariable(MemberSearchConstants::EXPERIENCE_INPUT_ID)); } if ($memberSearchParameters->getVariable(MemberSearchConstants::FOR_INPUT_ID) !== null) { $preparedStatement->bindParam(MemberSearchDao::PURPOSE_MULTIPLE_IDS_PARAMETER, implode(',', $memberSearchParameters->getVariable(MemberSearchConstants::FOR_INPUT_ID))); } if ($memberSearchParameters->getVariable(MemberSearchConstants::AGE_INPUT_ID) !== null) { $preparedStatement->bindParam(MemberSearchDao::AGE_RANGE_ID_PARAMETER, $memberSearchParameters->getVariable(MemberSearchConstants::AGE_INPUT_ID)); } if ($memberSearchParameters->getVariable(MemberSearchConstants::GENDER_INPUT_ID) !== null) { $preparedStatement->bindParam(MemberSearchDao::GENDER_PARAMETER, $memberSearchParameters->getVariable(MemberSearchConstants::GENDER_INPUT_ID)); } if ($memberSearchParameters->getVariable(LocationConstants::LOCATION_COUNTRY_INPUT_ID) !== null) { $preparedStatement->bindParam(MemberSearchDao::COUNTRY_ID_PARAMETER, $memberSearchParameters->getVariable(LocationConstants::LOCATION_COUNTRY_INPUT_ID)); } if ($memberSearchParameters->getVariable(LocationConstants::LOCATION_STATE_INPUT_ID) !== null) { $preparedStatement->bindParam(MemberSearchDao::STATE_ID_PARAMETER, $memberSearchParameters->getVariable(LocationConstants::LOCATION_STATE_INPUT_ID)); } if ($memberSearchParameters->getVariable(LocationConstants::LOCATION_CITY_INPUT_ID) !== null) { $preparedStatement->bindParam(MemberSearchDao::CITY_ID_PARAMETER, $memberSearchParameters->getVariable(LocationConstants::LOCATION_CITY_INPUT_ID)); } if ($memberSearchParameters->getVariable(LocationConstants::LOCATION_REGION_INPUT_ID) !== null) { $preparedStatement->bindParam(MemberSearchDao::REGION_ID_PARAMETER, $memberSearchParameters->getVariable(LocationConstants::LOCATION_REGION_INPUT_ID)); } } catch (Exception $ex) { echo "getMemberSearchPreparedStatement Error: " . $ex->getMessage(); } return $preparedStatement; }
public function getBandMemberUpdatePreparedStatement($memberID, $updateQuery, $bandMemberDetails, $dbConnection = null) { if ($dbConnection == null) { $dbConnection = DatabaseUtilities::getDatabaseConnection(); } //Prepare query $preparedStatement = $dbConnection->prepare($updateQuery); if ($bandMemberDetails->getVariable(BandMember::BIO) !== null) { $preparedStatement->bindParam(BandMemberDao::BIO_PARAMETER, $bandMemberDetails->getStringVariable(BandMember::BIO)); } if ($bandMemberDetails->getVariable(BandMember::ADMIN) !== null) { $preparedStatement->bindParam(BandMemberDao::ADMIN_PARAMETER, $bandMemberDetails->getVariable(BandMember::ADMIN)); } if ($bandMemberDetails->getVariable(BandMember::START_DATE) !== null) { $preparedStatement->bindParam(BandMemberDao::START_DATE_PARAMETER, $bandMemberDetails->getVariable(BandMember::START_DATE)); } if ($bandMemberDetails->getVariable(BandMember::END_DATE) !== null) { $preparedStatement->bindParam(BandMemberDao::END_DATE_PARAMETER, $bandMemberDetails->getVariable(BandMember::END_DATE)); } if ($bandMemberDetails->getVariable(BandMember::ACTIVE) !== null) { $preparedStatement->bindParam(BandMemberDao::ACTIVE_PARAMETER, $bandMemberDetails->getVariable(BandMember::ACTIVE)); } if ($bandMemberDetails->getVariable(BandMember::CURRENT) !== null) { $preparedStatement->bindParam(BandMemberDao::CURRENT_PARAMETER, $bandMemberDetails->getVariable(BandMember::CURRENT)); } $preparedStatement->bindParam(BandMemberDao::MODIFIED_BY_PARAMETER, $memberID); $preparedStatement->bindParam(BandMemberDao::MEMBER_ID_PARAMETER, $bandMemberDetails->getVariable(BandMember::MEMBER_ID)); $preparedStatement->bindParam(BandMemberDao::BAND_ID_PARAMETER, $bandMemberDetails->getVariable(BandMember::BAND_ID)); return $preparedStatement; }
<!DOCTYPE html> <title>Database Sample</title> <?php require_once "../../DemoMaster/Master.php"; require_once "../../lib/AutoLoad.php"; require_once "../../lib/DatabaseUtilities.php"; $tableName = 'tasks'; $properties = array('ID', 'TaskName', 'Description', 'StartDate', 'EndDate', 'IndentLevel', 'ProgressPercent', 'PredecessorIndices', 'AssignedResources', 'SortOrder', 'PreferredStartTime'); $dbh = new DatabaseUtilities('sqlite:../../Tasks.db', $tableName, $properties, null, null); //$dbh = new DatabaseUtilities('mysql:host=localhost;dbname=taskdb',$tableName,$properties,'root','password'); if ($_SERVER['REQUEST_METHOD'] == 'POST') { $typle = $_GET['type']; $dbh->SaveTasks($_POST, $tableName); } $result = $dbh->fetchTask(); ?> <div id="head"> <style type="text/css"> #Div1 > button { margin: 5px; font-size: 12px; font-family: "Portable User Interface", Helvetica, Arial, Verdana, sans-serif; width: 100%; } body { margin: 0px; } .ui-datepicker { font-size: 11px; }
private function getBandUpdatePreparedStatement($updateQuery, $memberID, $bandDetails, $dbConnection = null) { if ($dbConnection == null) { $dbConnection = DatabaseUtilities::getDatabaseConnection(); } //Prepare query $preparedStatement = $dbConnection->prepare($updateQuery); $preparedStatement->bindParam(BandDao::MODIFIED_BY_PARAMETER, $memberID, PDO::PARAM_INT); if ($bandDetails->getVariable(Band::ACTIVE) !== null) { $preparedStatement->bindParam(BandDao::ACTIVE_PARAMETER, $bandDetails->getVariable(Band::ACTIVE)); } if ($bandDetails->getVariable(Band::NAME) !== null) { $preparedStatement->bindParam(BandDao::BAND_NAME_PARAMETER, $bandDetails->getStringVariable(Band::NAME)); } if ($bandDetails->getVariable(Band::WEBSITE) !== null) { $preparedStatement->bindParam(BandDao::WEBSITE_PARAMETER, $bandDetails->getStringVariable(Band::WEBSITE)); } if ($bandDetails->getVariable(Band::SUMMARY) !== null) { $preparedStatement->bindParam(BandDao::SUMMARY_PARAMETER, $bandDetails->getStringVariable(Band::SUMMARY)); } if ($bandDetails->getVariable(Band::DESCRIPTION) !== null) { $preparedStatement->bindParam(BandDao::DESCRIPTION_PARAMETER, $bandDetails->getStringVariable(Band::DESCRIPTION)); } if ($bandDetails->getVariable(Band::CONTACT_INFORMATION) !== null) { $preparedStatement->bindParam(BandDao::CONTACT_INFORMATION_PARAMETER, $bandDetails->getStringVariable(Band::CONTACT_INFORMATION)); } if ($bandDetails->getVariable(Band::INSPIRATION) !== null) { $preparedStatement->bindParam(BandDao::INSPIRATION_PARAMETER, $bandDetails->getStringVariable(Band::INSPIRATION)); } if ($bandDetails->getVariable(Band::FACEBOOK_URL) !== null) { $preparedStatement->bindParam(BandDao::FACEBOOK_PARAMETER, $bandDetails->getStringVariable(Band::FACEBOOK_URL)); } if ($bandDetails->getVariable(Band::MYSPACE_URL) !== null) { $preparedStatement->bindParam(BandDao::MYSPACE_PARAMETER, $bandDetails->getStringVariable(Band::MYSPACE_URL)); } if ($bandDetails->getVariable(Band::TWITTER_URL) !== null) { $preparedStatement->bindParam(BandDao::TWITTER_PARAMETER, $bandDetails->getStringVariable(Band::TWITTER_URL)); } if ($bandDetails->getVariable(LocationConstants::COUNTRY_ID) !== null) { $preparedStatement->bindParam(BandDao::COUNTRY_ID_PARAMETER, $bandDetails->getVariable(LocationConstants::COUNTRY_ID)); } if ($bandDetails->getVariable(LocationConstants::STATE_ID) !== null) { $preparedStatement->bindParam(BandDao::STATE_ID_PARAMETER, $bandDetails->getVariable(LocationConstants::STATE_ID)); } if ($bandDetails->getVariable(LocationConstants::CITY_ID) !== null) { $preparedStatement->bindParam(BandDao::CITY_ID_PARAMETER, $bandDetails->getVariable(LocationConstants::CITY_ID)); } if ($bandDetails->getVariable(LocationConstants::REGION_ID) !== null) { $preparedStatement->bindParam(BandDao::REGION_ID_PARAMETER, $bandDetails->getVariable(LocationConstants::REGION_ID)); } $preparedStatement->bindParam(BandDao::BAND_ID_PARAMETER, $bandDetails->getVariable(Band::BAND_ID), PDO::PARAM_INT); return $preparedStatement; }
public function getBandMemberNotificationUpdatePreparedStatement($updateQuery, $bandMemberNotificationDetails, $dbConnection = null) { if ($dbConnection == null) { $dbConnection = DatabaseUtilities::getDatabaseConnection(); } //Prepare query $preparedStatement = $dbConnection->prepare($updateQuery); if ($bandMemberNotificationDetails->getVariable(BandMemberNotification::NEW_NOTIFICATION) !== null) { $preparedStatement->bindParam(BandMemberNotificationDao::NEW_PARAMETER, $bandMemberNotificationDetails->getVariable(BandMemberNotification::NEW_NOTIFICATION)); } if ($bandMemberNotificationDetails->getVariable(BandMemberNotification::ACTIVE) !== null) { $preparedStatement->bindParam(BandMemberNotificationDao::ACTIVE_PARAMETER, $bandMemberNotificationDetails->getVariable(BandMemberNotification::ACTIVE)); } $preparedStatement->bindParam(BandMemberNotificationDao::MODIFIED_BY_PARAMETER, $bandMemberNotificationDetails->getVariable(BandMemberNotification::MEMBER_ID)); $preparedStatement->bindParam(BandMemberNotificationDao::MEMBER_ID_PARAMETER, $bandMemberNotificationDetails->getVariable(BandMemberNotification::MEMBER_ID)); $preparedStatement->bindParam(BandMemberNotificationDao::BAND_ID_PARAMETER, $bandMemberNotificationDetails->getVariable(BandMemberNotification::BAND_ID)); $preparedStatement->bindParam(BandMemberNotificationDao::NOTIFICATION_TYPE_ID_PARAMETER, $bandMemberNotificationDetails->getStringVariable(BandMemberNotification::NOTIFICATION_TYPE_ID)); return $preparedStatement; }
public function grab(&$param_pool) { $result = new XMLElement($this->dsParamROOTELEMENT); self::__init(); $db = ASDCLoader::instance(); $sql = "SELECT SQL_CALC_FOUND_ROWS \n\t\t\t\t\t\tpinned.entry_id AS `id`, \n\t\t\t\t\t\tpinned.value AS `pinned`, \n\t\t\t\t\t\tclosed.value AS `closed`, \n\t\t\t\t\t\tcreation_date.local AS `creation-date`,\n\t\t\t\t\t\tlast_active.local AS `last-active`,\t\t\t\t\t\t\t\n\t\t\t\t\t\tcreated_by.member_id AS `created-by-member-id`,\n\t\t\t\t\t\tcreated_by.username AS `created-by-username`,\n\t\t\t\t\t\tlast_post.member_id AS `last-post-member-id`,\n\t\t\t\t\t\tlast_post.username AS `last-post-username`,\t\t\t\t\t\t\t\n\t\t\t\t\t\ttopic.value AS `topic`,\n\t\t\t\t\t\tCOUNT(comments.relation_id) AS `comments`\n\t\t\t\t\t\n\t\t\t\t\tFROM `tbl_entries_data_%d` AS `pinned`\n\t\t\t\t\tLEFT JOIN `tbl_entries_data_%d` AS `closed` ON pinned.entry_id = closed.entry_id\n\t\t\t\t\tLEFT JOIN `tbl_entries_data_%d` AS `creation_date` ON pinned.entry_id = creation_date.entry_id\t\n\t\t\t\t\tLEFT JOIN `tbl_entries_data_%d` AS `last_active` ON pinned.entry_id = last_active.entry_id\t\t\t\t\t\n\t\t\t\t\tLEFT JOIN `tbl_entries_data_%d` AS `created_by` ON pinned.entry_id = created_by.entry_id\t\n\t\t\t\t\tLEFT JOIN `tbl_entries_data_%d` AS `last_post` ON pinned.entry_id = last_post.entry_id\t\n\t\t\t\t\tLEFT JOIN `tbl_entries_data_%d` AS `topic` ON pinned.entry_id = topic.entry_id\n\t\t\t\t\tLEFT JOIN `tbl_entries_data_%d` AS `comments` ON pinned.entry_id = comments.relation_id\n\t\t\t\t\tWHERE 1 %s\n\t\t\t\t\tGROUP BY pinned.entry_id\n\t\t\t\t\tORDER BY pinned.value ASC, last_active.local DESC\n\t\t\t\t\tLIMIT %d, %d"; try { $rows = $db->query(sprintf($sql, self::findFieldID('pinned', 'discussions'), self::findFieldID('closed', 'discussions'), self::findFieldID('creation-date', 'discussions'), self::findFieldID('last-active', 'discussions'), self::findFieldID('created-by', 'discussions'), self::findFieldID('last-post', 'discussions'), self::findFieldID('topic', 'discussions'), self::findFieldID('parent-id', 'comments'), isset($this->dsParamFILTERS['id']) && (int) $this->dsParamFILTERS['id'] > 0 ? " AND pinned.entry_id = " . (int) $this->dsParamFILTERS['id'] : NULL, max(0, ($this->dsParamSTARTPAGE - 1) * $this->dsParamLIMIT), $this->dsParamLIMIT)); } catch (Exception $e) { $result->appendChild(new XMLElement('error', General::sanitize(vsprintf('%d: %s on query %s', $db->lastError())))); return $result; } if ($rows->length() == 0 && strlen(trim($dsParamFILTERS['id'])) > 0) { $this->__redirectToErrorPage(); } elseif ($rows->length() == 0) { return $this->emptyXMLSet(); } $total = $db->query('SELECT FOUND_ROWS() AS `total`;')->current()->total; $result->prependChild(General::buildPaginationElement($total, ceil($total * (1 / $this->dsParamLIMIT)), $this->dsParamLIMIT, $this->dsParamSTARTPAGE)); /* stdClass Object ( [id] => 666 [pinned] => yes [closed] => no [creation-date] => 1233599808 [last-active] => 1237161637 [created-by-member-id] => 2126 [created-by-username] => Lewis [last-post-member-id] => 2126 [last-post-username] => Lewis [topic] => Symphony 2 Documentation [comments] => 18 ) <entry id="595" comments="7"> <created-by id="2150">newnomad</created-by> <closed>No</closed> <last-active time="18:30" weekday="1">2009-02-09</last-active> <last-post id="2150">newnomad</last-post> <pinned>No</pinned> <topic handle="viewing-feeds">viewing feeds</topic> <creation-date time="19:31" weekday="3">2009-01-07</creation-date> </entry> */ $param_pool['ds-' . $this->dsParamROOTELEMENT] = DatabaseUtilities::resultColumn($rows, 'id'); foreach ($rows as $r) { $entry = new XMLElement('entry', NULL, array('id' => $r->id, 'comments' => $r->comments)); $entry->appendChild(new XMLElement('created-by', General::sanitize($r->{'created-by-username'}), array('id' => $r->{'created-by-member-id'}))); $entry->appendChild(new XMLElement('last-post', General::sanitize($r->{'last-post-username'}), array('id' => $r->{'last-post-member-id'}))); $entry->appendChild(new XMLElement('closed', ucfirst($r->closed))); $entry->appendChild(new XMLElement('pinned', ucfirst($r->pinned))); $entry->appendChild(new XMLElement('topic', General::sanitize($r->topic))); $entry->appendChild(General::createXMLDateObject($r->{'creation-date'}, 'creation-date')); $entry->appendChild(General::createXMLDateObject($r->{'last-active'}, 'last-active')); $result->appendChild($entry); } return $result; }
require_once "config.php"; require_once $config->getIncludeURL(Config::INCLUDES_PATH, "common_includes.php.inc"); require_once $config->getIncludeURL(Config::INCLUDES_PATH, "daos%member_dao.php"); require_once $config->getIncludeURL(Config::INCLUDES_PATH, "daos%member_purpose_dao.php"); require_once $config->getIncludeURL(Config::INCLUDES_PATH, "daos%member_genre_dao.php"); require_once $config->getIncludeURL(Config::INCLUDES_PATH, "daos%member_instrument_dao.php"); require_once $config->getIncludeURL(Config::INCLUDES_PATH, "controllers%member_instrument_controller.php"); require_once $config->getIncludeURL(Config::INCLUDES_PATH, "objects%member_instrument.php"); $bandDetails = null; $editable = false; $memberID = null; $processed = false; $errorCode = 0; try { $dbConnection = DatabaseUtilities::getDatabaseConnection(); //Get the current user's ID and details. $memberID = LoginController::getLoggedInMemberID($dbConnection); if ($memberID == null) { header("Location: login.php"); exit; } else { if (isset($_GET['memberID'])) { $viewMemberID = $_GET['memberID']; } else { $viewMemberID = $memberID; } if ($viewMemberID != null) { $memberDetails = MemberDao::selectMemberDetails($viewMemberID); //Encrypt the ID so it can be used for submissions. $memberIDEncrypted = EncryptionUtilities::encryptString($viewMemberID);
public function updateMember($memberDetails, $dbConnection = null) { $preparedStatement = null; $processed = false; try { if ($memberDetails->getVariable(Member::MEMBER_ID) !== null) { if ($dbConnection == null) { $dbConnection = DatabaseUtilities::getDatabaseConnection(); } $memberUpdateQuery = MemberDao::getMemberUpdateQuery($memberDetails); $preparedStatement = MemberDao::getMemberUpdatePreparedStatement($memberUpdateQuery, $memberDetails, $dbConnection); if ($preparedStatement->execute()) { $processed = true; } $preparedStatement = null; } } catch (Exception $ex) { echo 'Caught exception: ' . $ex->getMessage() . "\n"; $processed = false; } return $processed; }