public function setFeature(SiteModel $site, \BaseSiteFeature $siteFeature, $value, UserAccountModel $userAccountModel = null) { try { $this->app['db']->beginTransaction(); $changeMade = false; $stat = $this->app['db']->prepare("SELECT is_on FROM site_feature_information WHERE site_id=:site_id AND extension_id =:extension_id AND feature_id =:feature_id"); $stat->execute(array('site_id' => $site->getId(), 'extension_id' => $siteFeature->getExtensionId(), 'feature_id' => $siteFeature->getFeatureId())); if ($stat->rowCount() == 1) { $data = $stat->fetch(); if ($data['is_on'] != $value) { $stat = $this->app['db']->prepare("UPDATE site_feature_information SET is_on=:is_on " . " WHERE site_id=:site_id AND extension_id =:extension_id AND feature_id =:feature_id "); $stat->execute(array('site_id' => $site->getId(), 'extension_id' => $siteFeature->getExtensionId(), 'feature_id' => $siteFeature->getFeatureId(), 'is_on' => $value ? 1 : 0)); $changeMade = true; } } else { $stat = $this->app['db']->prepare("INSERT INTO site_feature_information (site_id, extension_id, feature_id, is_on) " . " VALUES(:site_id, :extension_id, :feature_id, :is_on) "); $stat->execute(array('site_id' => $site->getId(), 'extension_id' => $siteFeature->getExtensionId(), 'feature_id' => $siteFeature->getFeatureId(), 'is_on' => $value ? 1 : 0)); $changeMade = true; } if ($changeMade) { $stat = $this->app['db']->prepare("INSERT INTO site_feature_history (site_id, extension_id, feature_id, is_on, user_account_id, created_at) " . " VALUES (:site_id, :extension_id, :feature_id, :is_on, :user_account_id, :created_at)"); $stat->execute(array('site_id' => $site->getId(), 'extension_id' => $siteFeature->getExtensionId(), 'feature_id' => $siteFeature->getFeatureId(), 'is_on' => $value ? 1 : 0, 'user_account_id' => $userAccountModel ? $userAccountModel->getId() : null, 'created_at' => \TimeSource::getFormattedForDataBase())); } $this->app['db']->commit(); } catch (Exception $e) { $this->app['db']->rollBack(); } }
protected function build() { $this->select[] = 'area_information.*'; if ($this->site) { $this->where[] = " area_information.site_id = :site_id "; $this->params['site_id'] = $this->site->getId(); } if ($this->country) { $this->where[] = " area_information.country_id = :country_id "; $this->params['country_id'] = $this->country->getId(); } if (!$this->include_deleted) { $this->where[] = " area_information.is_deleted = '0' "; } if ($this->noParentArea) { $this->where[] = ' area_information.parent_area_id IS null '; } else { if ($this->parentArea) { $this->where[] = " area_information.parent_area_id = :parent_id "; $this->params['parent_id'] = $this->parentArea->getId(); } } if ($this->cacheNeedsBuildingOnly) { $this->where[] = " area_information.cache_area_has_parent_generated = '0'"; } if ($this->freeTextSearch) { $this->where[] = ' area_information.title ILIKE :free_text_search '; $this->params['free_text_search'] = "%" . strtolower($this->freeTextSearch) . "%"; } if ($this->include_parent_levels > 0) { $this->joins[] = " LEFT JOIN area_information AS area_information_parent_1 ON area_information.parent_area_id = area_information_parent_1.id "; $this->select[] = " area_information_parent_1.title AS parent_1_title"; } }
protected function build() { if ($this->site) { $this->where[] = " incoming_link.site_id = :site_id "; $this->params['site_id'] = $this->site->getId(); } }
protected function build() { if ($this->site) { $this->where[] = " human_information.site_id = :site_id "; $this->params['site_id'] = $this->site->getId(); } if ($this->humansForEvent) { $this->joins[] = " JOIN event_has_human ON event_has_human.human_id = human_information.id AND event_has_human.event_id = :event_id AND event_has_human.removed_at IS NULL"; $this->params['event_id'] = $this->humansForEvent->getId(); } else { if ($this->humansNotForEvent) { $this->joins[] = " LEFT JOIN event_has_human ON event_has_human.human_id = human_information.id AND event_has_human.event_id = :event_id AND event_has_human.removed_at IS NULL"; $this->params['event_id'] = $this->humansNotForEvent->getId(); $this->where[] = ' event_has_human.event_id IS NULL '; } } if ($this->area) { // TODO direct areas only, should do child areas to. But not now. $this->joins[] = " JOIN human_in_area ON human_in_area.human_id = human_information.id AND human_in_area.area_id = :area_id AND human_in_area.removed_at IS NULL"; $this->params['area_id'] = $this->area->getId(); } if (!$this->include_deleted) { $this->where[] = " human_information.is_deleted = '0' "; } if ($this->freeTextSearch) { $this->where[] = '(CASE WHEN human_information.title IS NULL THEN \'\' ELSE human_information.title END ) || \' \' || ' . '(CASE WHEN human_information.description IS NULL THEN \'\' ELSE human_information.description END )' . ' ILIKE :free_text_search '; $this->params['free_text_search'] = "%" . strtolower($this->freeTextSearch) . "%"; } }
protected function build() { $this->select = array('group_information.*'); if ($this->site) { $this->where[] = " group_information.site_id = :site_id "; $this->params['site_id'] = $this->site->getId(); } if ($this->event) { $this->joins[] = " JOIN event_in_group AS event_in_group ON event_in_group.group_id = group_information.id " . "AND event_in_group.removed_at IS NULL AND event_in_group.event_id = :event_id "; $this->params['event_id'] = $this->event->getId(); } else { if ($this->notEvent) { $this->joins[] = " LEFT JOIN event_in_group AS event_in_group ON event_in_group.group_id = group_information.id " . "AND event_in_group.removed_at IS NULL AND event_in_group.event_id = :event_id "; $this->params['event_id'] = $this->notEvent->getId(); $this->where[] = ' event_in_group.event_id IS NULL '; } } if ($this->freeTextSearch) { $this->where[] = '(CASE WHEN group_information.title IS NULL THEN \'\' ELSE group_information.title END ) || \' \' || ' . '(CASE WHEN group_information.description IS NULL THEN \'\' ELSE group_information.description END )' . ' ILIKE :free_text_search '; $this->params['free_text_search'] = "%" . strtolower($this->freeTextSearch) . "%"; } if (!$this->include_deleted) { $this->where[] = " group_information.is_deleted = '0' "; } if ($this->includeMediasSlugs) { $this->select[] = " (SELECT array_to_string(array_agg(media_information.slug), ',') FROM media_information " . " JOIN media_in_group ON media_information.id = media_in_group.media_id " . " WHERE media_information.deleted_at IS NULL AND media_information.is_file_lost='0' " . " AND media_in_group.removal_approved_at IS NULL AND media_in_group.group_id = group_information.id " . " GROUP BY group_information.id ) AS media_group_slugs "; } if ($this->editedByUser) { $this->where[] = " group_information.id IN (SELECT group_id FROM group_history WHERE user_account_id = :editedByUser) "; $this->params['editedByUser'] = $this->editedByUser->getId(); } }
protected function build() { $this->select[] = 'event_custom_field_definition_information.*'; if ($this->site) { $this->where[] = " event_custom_field_definition_information.site_id = :site_id "; $this->params['site_id'] = $this->site->getId(); } }
protected function build() { $this->select = array('new_event_draft_information.*'); if ($this->site) { $this->where[] = " new_event_draft_information.site_id = :site_id "; $this->params['site_id'] = $this->site->getId(); } }
protected function build() { if ($this->onlyCurrent) { $this->where[] = "user_watches_site_information.is_watching = '1'"; } if ($this->site) { $this->where[] = " user_watches_site_information.site_id = :site_id"; $this->params['site_id'] = $this->site->getId(); } }
protected function build() { if ($this->site) { $this->where[] = " send_email_information.site_id = :site_id "; $this->params['site_id'] = $this->site->getId(); } if ($this->userCreatedBy) { $this->where[] = " send_email_information.created_by = :created_by "; $this->params['created_by'] = $this->userCreatedBy->getId(); } }
protected function build() { if ($this->site) { $this->where[] = " import_url_information.site_id = :site_id "; $this->params['site_id'] = $this->site->getId(); } if ($this->group) { $this->where[] = " import_url_information.group_id = :group_id "; $this->params['group_id'] = $this->group->getId(); } }
protected function build() { global $DB; if ($this->site) { $this->joins[] = " JOIN user_group_in_site ON user_group_in_site.user_group_id = user_group_information.id " . " AND user_group_in_site.site_id = :site_id AND user_group_in_site.removed_at IS NULL"; $this->params['site_id'] = $this->site->getId(); } if (!$this->include_deleted) { $this->where[] = " user_group_information.is_deleted = '0' "; } if ($this->index_only) { $this->where[] = " user_group_information.is_in_index = '1' "; } }
protected function build() { $this->joins[] = " LEFT JOIN site_information ON site_information.id = user_notification.site_id "; if ($this->site) { $this->where[] = " user_notification.site_id = :site_id "; $this->params['site_id'] = $this->site->getId(); } if ($this->user) { $this->where[] = " user_notification.user_id = :user_id "; $this->params['user_id'] = $this->user->getId(); } if ($this->isOpenBySysAdminsOnly) { $this->where[] = " ( site_information.is_closed_by_sys_admin = '0' OR site_information.is_closed_by_sys_admin is null ) "; } }
public function isCountryInSite(CountryModel $country, SiteModel $site) { global $DB; $stat = $DB->prepare("SELECT * FROM country_in_site_information WHERE site_id =:site_id AND country_id =:country_id AND is_in= '1'"); $stat->execute(array('country_id' => $country->getId(), 'site_id' => $site->getId())); return $stat->rowCount() == 1; }
protected function build() { $this->select[] = 'country.*'; if ($this->site && $this->siteInformation) { $this->joins[] = " LEFT JOIN country_in_site_information ON country_in_site_information.country_id = country.id AND country_in_site_information.site_id = :site_id "; $this->params['site_id'] = $this->site->getId(); $this->select[] = " country_in_site_information.is_in AS site_is_in "; } else { if ($this->site && $this->siteIn) { $this->joins[] = " JOIN country_in_site_information ON country_in_site_information.country_id = country.id "; $this->where[] = " country_in_site_information.site_id = :site_id"; $this->where[] = " country_in_site_information.is_in = '1'"; $this->params['site_id'] = $this->site->getId(); } } }
public function isUserInSite(UserAccountModel $userAccountModel, SiteModel $siteModel) { global $DB; $stat = $DB->prepare("SELECT * FROM user_has_no_editor_permissions_in_site WHERE site_id=:site_id AND user_account_id=:user_account_id AND removed_at IS NULL"); $stat->execute(array("site_id" => $siteModel->getId(), "user_account_id" => $userAccountModel->getId())); return $stat->rowCount() > 0; }
protected function build() { $this->select[] = ' curated_list_information.* '; if ($this->userAccount) { $this->joins[] = " JOIN user_in_curated_list_information ON user_in_curated_list_information.curated_list_id = curated_list_information.id " . "AND user_in_curated_list_information.user_account_id = :user_account_id "; $this->params['user_account_id'] = $this->userAccount->getId(); $this->where[] = " (user_in_curated_list_information.is_owner = '1' OR user_in_curated_list_information.is_editor = '1' ) "; } if ($this->site) { $this->where[] = " curated_list_information.site_id = :site_id "; $this->params['site_id'] = $this->site->getId(); } if ($this->containsEvent) { $this->params['event_id'] = $this->containsEvent->getId(); // event directly in list? $this->joins[] = " LEFT JOIN event_in_curated_list ON event_in_curated_list.curated_list_id = curated_list_information.id AND " . " event_in_curated_list.event_id = :event_id AND event_in_curated_list.removed_at IS NULL "; // event in list via group? $this->joins[] = " LEFT JOIN ( SELECT group_in_curated_list.curated_list_id, MAX(group_in_curated_list.group_id) AS group_id FROM group_in_curated_list " . " JOIN event_in_group ON event_in_group.group_id = group_in_curated_list.group_id " . " WHERE event_in_group.event_id = :event_id AND group_in_curated_list.removed_at IS NULL AND event_in_group.removed_at IS NULL " . " GROUP BY group_in_curated_list.curated_list_id ) AS event_in_curated_list_via_group_table ON event_in_curated_list_via_group_table.curated_list_id = curated_list_information.id "; $this->where[] = " (event_in_curated_list.added_at IS NOT NULL OR event_in_curated_list_via_group_table.group_id IS NOT NULL) "; } else { if ($this->eventInfo) { $this->params['event_id'] = $this->eventInfo->getId(); // event directly in list? $this->joins[] = " LEFT JOIN event_in_curated_list ON event_in_curated_list.curated_list_id = curated_list_information.id AND " . " event_in_curated_list.event_id = :event_id AND event_in_curated_list.removed_at IS NULL "; $this->select[] = " event_in_curated_list.added_at AS is_event_in_list "; // event in list via group? $this->joins[] = " LEFT JOIN ( SELECT group_in_curated_list.curated_list_id, MAX(group_in_curated_list.group_id) AS group_id FROM group_in_curated_list " . " JOIN event_in_group ON event_in_group.group_id = group_in_curated_list.group_id " . " WHERE event_in_group.event_id = :event_id AND group_in_curated_list.removed_at IS NULL AND event_in_group.removed_at IS NULL " . " GROUP BY group_in_curated_list.curated_list_id ) AS event_in_curated_list_via_group_table ON event_in_curated_list_via_group_table.curated_list_id = curated_list_information.id "; $this->select[] = " event_in_curated_list_via_group_table.group_id AS event_in_list_via_group_id "; } } if ($this->containsGroup) { $this->joins[] = " LEFT JOIN group_in_curated_list ON group_in_curated_list.curated_list_id = curated_list_information.id AND " . " group_in_curated_list.group_id = :group_id AND group_in_curated_list.removed_at IS NULL "; $this->params['group_id'] = $this->containsGroup->getId(); $this->where[] = " group_in_curated_list.added_at IS NOT NULL "; } else { if ($this->groupInfo) { $this->joins[] = " LEFT JOIN group_in_curated_list ON group_in_curated_list.curated_list_id = curated_list_information.id AND " . " group_in_curated_list.group_id = :group_id AND group_in_curated_list.removed_at IS NULL "; $this->params['group_id'] = $this->groupInfo->getId(); $this->select[] = " group_in_curated_list.added_at AS is_group_in_list "; } } if (!$this->include_deleted) { $this->where[] = " curated_list_information.is_deleted = '0' "; } }
protected function build() { global $DB; $this->select[] = 'imported_event.*'; if ($this->site) { $this->joins[] = " JOIN import_url_information ON imported_event.import_url_id = import_url_information.id "; $this->where[] = " import_url_information.site_id = :site_id "; $this->params['site_id'] = $this->site->getId(); } if ($this->importURL) { $this->where[] = " imported_event.import_url_id = :import_url_id "; $this->params['import_url_id'] = $this->importURL->getId(); } if ($this->after) { $this->where[] = ' imported_event.end_at > :after'; $this->params['after'] = $this->after->format("Y-m-d H:i:s"); } }
/** * This will always return something. If one doesn't exist, one will be created. * @return UserWatchesSiteStopModel */ public function getForUserAndSite(UserAccountModel $user, SiteModel $site) { global $DB; $stat = $DB->prepare("SELECT * FROM user_watches_site_stop WHERE user_account_id=:uid AND site_id=:sid"); $stat->execute(array('uid' => $user->getId(), 'sid' => $site->getId())); if ($stat->rowCount() > 0) { $uwss = new UserWatchesSiteStopModel(); $uwss->setFromDataBaseRow($stat->fetch()); return $uwss; } $uwss = new UserWatchesSiteStopModel(); $uwss->setUserAccountId($user->getId()); $uwss->setSiteId($site->getId()); $uwss->setAccessKey(createKey(2, 150)); // TODO check not already used $stat = $DB->prepare("INSERT INTO user_watches_site_stop (user_account_id, site_id, access_key, created_at) " . "VALUES (:user_account_id, :site_id, :access_key, :created_at)"); $stat->execute(array('user_account_id' => $uwss->getUserAccountId(), 'site_id' => $uwss->getSiteId(), 'access_key' => $uwss->getAccessKey(), 'created_at' => \TimeSource::getFormattedForDataBase())); return $uwss; }
public function loadBySlug(SiteModel $site, $slug) { global $DB; $stat = $DB->prepare("SELECT human_information.* FROM human_information WHERE slug =:slug AND site_id =:sid"); $stat->execute(array('sid' => $site->getId(), 'slug' => $slug)); if ($stat->rowCount() > 0) { $human = new HumanModel(); $human->setFromDataBaseRow($stat->fetch()); return $human; } }
protected function build() { if ($this->site) { $this->where[] = " tag_information.site_id = :site_id "; $this->params['site_id'] = $this->site->getId(); } if ($this->tagsForEvent) { $this->joins[] = " JOIN event_has_tag ON event_has_tag.tag_id = tag_information.id AND event_has_tag.event_id = :event_id AND event_has_tag.removed_at IS NULL"; $this->params['event_id'] = $this->tagsForEvent->getId(); } else { if ($this->tagsNotForEvent) { $this->joins[] = " LEFT JOIN event_has_tag ON event_has_tag.tag_id = tag_information.id AND event_has_tag.event_id = :event_id AND event_has_tag.removed_at IS NULL"; $this->params['event_id'] = $this->tagsNotForEvent->getId(); $this->where[] = ' event_has_tag.event_id IS NULL '; } } if (!$this->include_deleted) { $this->where[] = " tag_information.is_deleted = '0' "; } }
public function loadBySlug(SiteModel $site, $slug) { global $DB; $stat = $DB->prepare("SELECT send_email_information.* FROM send_email_information WHERE slug =:slug AND site_id =:sid"); $stat->execute(array('sid' => $site->getId(), 'slug' => $slug)); if ($stat->rowCount() > 0) { $sem = new SendEmailModel(); $sem->setFromDataBaseRow($stat->fetch()); return $sem; } }
public function loadBySlug(SiteModel $site, $slug) { global $DB; $stat = $DB->prepare("SELECT import_url_information.* FROM import_url_information WHERE slug =:slug AND site_id =:sid"); $stat->execute(array('sid' => $site->getId(), 'slug' => $slug)); if ($stat->rowCount() > 0) { $iurl = new ImportURLModel(); $iurl->setFromDataBaseRow($stat->fetch()); return $iurl; } }
public function loadBySlug(SiteModel $site, $slug) { global $DB; $stat = $DB->prepare("SELECT curated_list_information.* FROM curated_list_information WHERE slug =:slug AND site_id =:sid"); $stat->execute(array('sid' => $site->getId(), 'slug' => $slug)); if ($stat->rowCount() > 0) { $clist = new CuratedListModel(); $clist->setFromDataBaseRow($stat->fetch()); return $clist; } }
/** * This will return one country only. It is intended for sites with one country only. **/ public function loadBySite(SiteModel $site) { global $DB; $stat = $DB->prepare("SELECT country.* FROM country " . " JOIN country_in_site_information ON country_in_site_information.country_id = country.id AND country_in_site_information.is_in = '1' " . " WHERE country_in_site_information.site_id=:id "); $stat->execute(array('id' => $site->getId())); if ($stat->rowCount() > 0) { $country = new CountryModel(); $country->setFromDataBaseRow($stat->fetch()); return $country; } }
public function loadBySlugForSite($slug, SiteModel $siteModel) { global $DB; $stat = $DB->prepare("SELECT new_event_draft_information.* FROM new_event_draft_information " . " WHERE new_event_draft_information.slug =:slug AND new_event_draft_information.site_id = :site_id "); $stat->execute(array('slug' => $slug, 'site_id' => $siteModel->getId())); if ($stat->rowCount() > 0) { $event = new NewEventDraftModel(); $event->setFromDataBaseRow($stat->fetch()); return $event; } }
protected function build() { if ($this->site) { $this->where[] = " media_information.site_id = :site_id "; $this->params['site_id'] = $this->site->getId(); } if ($this->group) { $this->joins[] = " JOIN media_in_group AS media_in_group ON media_in_group.media_id = media_information.id " . "AND media_in_group.removed_at IS NULL AND media_in_group.group_id = :group_id "; $this->params['group_id'] = $this->group->getId(); } else { if ($this->groupNotIn) { $this->joins[] = " LEFT JOIN media_in_group AS media_in_group ON media_in_group.media_id = media_information.id " . "AND media_in_group.removed_at IS NULL AND media_in_group.group_id = :group_id "; $this->where[] = " media_in_group.added_at IS NULL "; $this->params['group_id'] = $this->groupNotIn->getId(); } } if ($this->venue) { $this->joins[] = " JOIN media_in_venue AS media_in_venue ON media_in_venue.media_id = media_information.id " . "AND media_in_venue.removed_at IS NULL AND media_in_venue.venue_id = :venue_id "; $this->params['venue_id'] = $this->venue->getId(); } else { if ($this->venueNotIn) { $this->joins[] = " LEFT JOIN media_in_venue AS media_in_venue ON media_in_venue.media_id = media_information.id " . "AND media_in_venue.removed_at IS NULL AND media_in_venue.venue_id = :venue_id "; $this->where[] = " media_in_venue.added_at IS NULL "; $this->params['venue_id'] = $this->venueNotIn->getId(); } } if ($this->event) { $this->joins[] = " JOIN media_in_event AS media_in_event ON media_in_event.media_id = media_information.id " . "AND media_in_event.removed_at IS NULL AND media_in_event.event_id = :event_id "; $this->params['event_id'] = $this->event->getId(); } else { if ($this->eventNotIn) { $this->joins[] = " LEFT JOIN media_in_event AS media_in_event ON media_in_event.media_id = media_information.id " . "AND media_in_event.removed_at IS NULL AND media_in_event.event_id = :event_id "; $this->where[] = " media_in_event.added_at IS NULL "; $this->params['event_id'] = $this->eventNotIn->getId(); } } if (!$this->include_deleted) { $this->where[] = " media_information.deleted_at IS NULL "; } }
protected function build() { global $DB; $this->select[] = " venue_information.* "; if ($this->site) { $this->where[] = " venue_information.site_id = :site_id "; $this->params['site_id'] = $this->site->getId(); } if ($this->country) { $this->where[] = " venue_information.country_id = :country_id "; $this->params['country_id'] = $this->country->getId(); } if ($this->area) { $areaids = array($this->area->getId()); $this->statAreas = $DB->prepare("SELECT area_id FROM cached_area_has_parent WHERE has_parent_area_id=:id"); $this->statAreas->execute(array('id' => $this->area->getId())); while ($d = $this->statAreas->fetch()) { $areaids[] = $d['area_id']; } $this->where[] = " venue_information.area_id IN (" . implode(",", $areaids) . ")"; } if ($this->freeTextSearch) { $this->where[] = '(CASE WHEN venue_information.title IS NULL THEN \'\' ELSE venue_information.title END ) || \' \' || ' . '(CASE WHEN venue_information.description IS NULL THEN \'\' ELSE venue_information.description END ) || \' \' || ' . '(CASE WHEN venue_information.address IS NULL THEN \'\' ELSE venue_information.address END ) || \' \' || ' . '(CASE WHEN venue_information.address_code IS NULL THEN \'\' ELSE venue_information.address_code END ) ' . ' ILIKE :free_text_search '; $this->params['free_text_search'] = "%" . strtolower($this->freeTextSearch) . "%"; } if ($this->freeTextSearchAddressCode) { $this->where[] = ' venue_information.address_code ILIKE :free_text_search_address_code '; $this->params['free_text_search_address_code'] = "%" . strtolower($this->freeTextSearchAddressCode) . "%"; } if ($this->freeTextSearchAddress) { $this->where[] = 'venue_information.address ILIKE :free_text_search_address '; $this->params['free_text_search_address'] = "%" . strtolower($this->freeTextSearchAddress) . "%"; } if ($this->freeTextSearchTitle) { $this->where[] = 'venue_information.title ILIKE :free_text_search_title '; $this->params['free_text_search_title'] = "%" . strtolower($this->freeTextSearchTitle) . "%"; } if (!$this->include_deleted) { $this->where[] = " venue_information.is_deleted = '0' "; } if ($this->includeMediasSlugs) { $this->select[] = " (SELECT array_to_string(array_agg(media_information.slug), ',') FROM media_information " . " JOIN media_in_venue ON media_information.id = media_in_venue.media_id " . " WHERE media_information.deleted_at IS NULL AND media_information.is_file_lost='0' " . " AND media_in_venue.removal_approved_at IS NULL AND media_in_venue.venue_id = venue_information.id " . " GROUP BY venue_information.id ) AS media_venue_slugs "; } if ($this->must_have_lat_lng) { $this->where[] = " venue_information.lat IS NOT NULL "; $this->where[] = " venue_information.lng IS NOT NULL "; } if ($this->editedByUser) { $this->where[] = " venue_information.id IN (SELECT venue_id FROM venue_history WHERE user_account_id = :editedByUser) "; $this->params['editedByUser'] = $this->editedByUser->getId(); } }
public function createOrEdit(SiteModel $site, UserAccountModel $user) { global $DB; $createdat = \TimeSource::getFormattedForDataBase(); try { $DB->beginTransaction(); $stat = $DB->prepare("SELECT * FROM site_profile_media_information WHERE site_id=:site_id"); $stat->execute(array('site_id' => $site->getId())); if ($stat->rowCount() == 1) { $stat = $DB->prepare("UPDATE site_profile_media_information SET logo_media_id=:logo_media_id " . " WHERE site_id=:site_id"); } else { $stat = $DB->prepare("INSERT INTO site_profile_media_information (site_id, logo_media_id) " . " VALUES (:site_id, :logo_media_id)"); } $stat->execute(array('logo_media_id' => $site->getLogoMediaId(), 'site_id' => $site->getId())); $stat = $DB->prepare("INSERT INTO site_profile_media_history (site_id, logo_media_id, user_account_id, created_at) " . " VALUES (:site_id, :logo_media_id, :user_account_id, :created_at)"); $stat->execute(array('site_id' => $site->getId(), 'logo_media_id' => $site->getLogoMediaId(), 'created_at' => $createdat, 'user_account_id' => $user->getId())); $data = $stat->fetch(); $DB->commit(); } catch (Exception $e) { $DB->rollBack(); } }
public function create(\BaseIncomingLink $incomingLink, SiteModel $site = null) { global $DB; try { $DB->beginTransaction(); $stat = $DB->prepare("INSERT INTO incoming_link (site_id, extension_id, type, source_url, target_url, reporter_useragent, reporter_ip, created_at) " . "VALUES (:site_id, :extension_id, :type, :source_url, :target_url, :reporter_useragent, :reporter_ip, :created_at) RETURNING id"); $stat->execute(array('site_id' => $site ? $site->getId() : null, 'extension_id' => $incomingLink->getTypeExtensionID(), 'type' => $incomingLink->getType(), 'source_url' => $incomingLink->getSourceURL(), 'target_url' => $incomingLink->getTargetURL(), 'reporter_useragent' => $incomingLink->getReporterUseragent(), 'reporter_ip' => $incomingLink->getReporterIp(), 'created_at' => \TimeSource::getFormattedForDataBase())); $data = $stat->fetch(); $incomingLink->setId($data['id']); $DB->commit(); } catch (Exception $e) { $DB->rollBack(); } }
public function loadBySlug(SiteModel $site, $slug) { if (strpos($slug, "-")) { $slug = array_shift(explode("-", $slug, 2)); } global $DB; $stat = $DB->prepare("SELECT venue_information.* FROM venue_information WHERE slug =:slug AND site_id =:sid"); $stat->execute(array('sid' => $site->getId(), 'slug' => $slug)); if ($stat->rowCount() > 0) { $venue = new VenueModel(); $venue->setFromDataBaseRow($stat->fetch()); return $venue; } }