public static function process($options = array()) { $default = array('entries' => array(), 'section' => null, 'field_name' => null, 'iptc' => true, 'exif' => true); $options = array_merge($default, $options); self::checkRequirements($options['exif']); if (!$options['field_name'] || !$options['entries'] || !$options['section']) { self::throwEx('Missing required option'); } $root = new XMLElement(self::getRootElement()); $field = FieldManager::fetchFieldIDFromElementName($options['field_name'], $options['section']->get('id')); foreach ($options['entries'] as $entry) { $data = $entry->getData($field); $rel = $data['file']; $img = WORKSPACE . $rel; $xml = new XMLElement('image', null, array('path' => $rel, 'entry_id' => $entry->get('id'))); if ($options['iptc']) { $result = self::processIptc($img); $xml->appendChild($result); } if ($options['exif']) { $result = self::processExif($img); $xml->appendChild($result); } $root->appendChild($xml); } return $root; }
public function grab(array &$param_pool = NULL) { // remove placeholder elements unset($this->dsParamINCLUDEDELEMENTS); // fill with all included elements if none are set if (is_null(REST_Entries::getDatasourceParam('included_elements'))) { // get all fields in this section $fields = FieldManager::fetchFieldsSchema(REST_Entries::getSectionId()); // add them to the data source foreach ($fields as $field) { $this->dsParamINCLUDEDELEMENTS[] = $field['element_name']; } // also add pagination $this->dsParamINCLUDEDELEMENTS[] = 'system:pagination'; } else { $this->dsParamINCLUDEDELEMENTS = explode(',', REST_Entries::getDatasourceParam('included_elements')); } // fill the other parameters if (!is_null(REST_Entries::getDatasourceParam('limit'))) { $this->dsParamLIMIT = REST_Entries::getDatasourceParam('limit'); } if (!is_null(REST_Entries::getDatasourceParam('page'))) { $this->dsParamSTARTPAGE = REST_Entries::getDatasourceParam('page'); } if (!is_null(REST_Entries::getDatasourceParam('sort'))) { $this->dsParamSORT = REST_Entries::getDatasourceParam('sort'); } if (!is_null(REST_Entries::getDatasourceParam('order'))) { $this->dsParamORDER = REST_Entries::getDatasourceParam('order'); } // Do grouping if (!is_null(REST_Entries::getDatasourceParam('groupby'))) { $field_id = FieldManager::fetchFieldIDFromElementName(REST_Entries::getDatasourceParam('groupby'), REST_Entries::getSectionId()); if ($field_id) { $this->dsParamGROUP = $field_id; } } // if API is calling a known entry, filter on System ID only if (!is_null(REST_Entries::getEntryId())) { $this->dsParamFILTERS['id'] = REST_Entries::getEntryId(); } elseif (REST_Entries::getDatasourceParam('filters')) { foreach (REST_Entries::getDatasourceParam('filters') as $field_handle => $filter_value) { $filter_value = rawurldecode($filter_value); $field_id = FieldManager::fetchFieldIDFromElementName($field_handle, REST_Entries::getSectionId()); if (is_numeric($field_id)) { $this->dsParamFILTERS[$field_id] = $filter_value; } } } return $this->execute($param_pool); }
public function removeDSFilters($context) { //Check if there is a preview link field attached. $has_preview_link = false; if (!isset(self::$fieldManager)) { self::$fieldManager = new fieldManager(Symphony::Engine()); } if (is_array($context['elements'])) { foreach ($context['elements'] as $element) { $field_id = self::$fieldManager->fetchFieldIDFromElementName($element); $field_type = self::$fieldManager->fetchFieldTypeFromID($field_id); if ($field_type == 'preview_url') { $has_preview_link = true; } } } $contents = $context['contents']; $first_line = '$result = new XMLElement($this->dsParamROOTELEMENT);'; //CREATE THE HORRIBLE FILTER STRING $this->dsFilter = ' //PREVIEW LINK EXTENSION: Remove Filters' . PHP_EOL; $this->dsFilter .= ' if (!strpos($_SERVER[‘HTTP_USER_AGENT’],"Googlebot")) {' . PHP_EOL; $this->dsFilter .= ' if(sha1($_GET["entryid"]) == $_GET["key"]) {' . PHP_EOL; $this->dsFilter .= ' $filters = $this->dsParamFILTERS;' . PHP_EOL; $this->dsFilter .= ' foreach($filters as $key=>$filter) {' . PHP_EOL; $this->dsFilter .= ' unset($this->dsParamFILTERS[$key]);' . PHP_EOL; $this->dsFilter .= ' }' . PHP_EOL; $this->dsFilter .= ' $this->dsParamFILTERS["id"] = $_GET["entryid"];' . PHP_EOL; $this->dsFilter .= ' }' . PHP_EOL; $this->dsFilter .= ' }'; if ($has_preview_link) { $contents = str_replace($first_line, $first_line . PHP_EOL . PHP_EOL . $this->dsFilter, $contents); } else { $contents = str_replace($this->dsFilter, '', $contents); } $this->dsContents = $contents; }
public function view() { $handle = General::sanitize($_GET['handle']); $section = General::sanitize($_GET['section']); $options = array(); $filters = array(); if (!empty($handle) && !empty($section)) { $section_id = SectionManager::fetchIDFromHandle($section); $field_id = FieldManager::fetchFieldIDFromElementName($handle, $section_id); $field = FieldManager::fetch($field_id); if (!empty($field) && $field->canPublishFilter() === true) { if (method_exists($field, 'getToggleStates')) { $options = $field->getToggleStates(); } elseif (method_exists($field, 'findAllTags')) { $options = $field->findAllTags(); } } } foreach ($options as $value => $data) { $filters[] = array('value' => $value ? $value : $data, 'text' => $data ? $data : $value); } $this->_Result['filters'] = $filters; }
/** * get filters using filterable field ids and the section denoting where the filters are */ public function getFilters($filterableFields, $section_id) { //if no need to filter return empty filters if (empty($filterableFields)) { return array(); } if (isset(Symphony::Engine()->Page)) { $context = method_exists(Symphony::Engine()->Page, 'getContext') ? Symphony::Engine()->Page->getContext() : array(); $filters = $context['filters']; if (!isset($filters)) { $filters = array(); } // check if the filters are used for entry ordering and switch from name to id foreach ($filters as $field_name => $value) { $filtered_field_id = FieldManager::fetchFieldIDFromElementName($field_name, $section_id); if (in_array($filtered_field_id, $filterableFields)) { //ensuring that capitalization will never be an issue $filters[$filtered_field_id] = strtolower(General::sanitize($value)); } unset($filters[$field_name]); } } else { $filters = $this->dsFilters; if (empty($filters)) { return array(); } // check if the filters are used for entry ordering otherwise remove from list foreach ($filters as $filtered_field_id => $value) { if (!in_array($filtered_field_id, $filterableFields)) { unset($filters[$filtered_field_id]); } else { $filters[$filtered_field_id] = strtolower(General::sanitize($value)); } } } return $filters; }
public function __viewIndex() { if (!($section_id = SectionManager::fetchIDFromHandle($this->_context['section_handle']))) { Administration::instance()->throwCustomError(__('The Section, %s, could not be found.', array('<code>' . $this->_context['section_handle'] . '</code>')), __('Unknown Section'), Page::HTTP_STATUS_NOT_FOUND); } else { if (!is_writable(CONFIG)) { $this->pageAlert(__('The Symphony configuration file, %s, is not writable. The sort order cannot be modified.', array('<code>/manifest/config.php</code>')), Alert::NOTICE); } } $section = SectionManager::fetch($section_id); $this->setPageType('table'); $this->setTitle(__('%1$s – %2$s', array($section->get('name'), __('Symphony')))); $filters = array(); $filter_querystring = $prepopulate_querystring = $where = $joins = null; $current_page = isset($_REQUEST['pg']) && is_numeric($_REQUEST['pg']) ? max(1, intval($_REQUEST['pg'])) : 1; if (isset($_REQUEST['filter'])) { // legacy implementation, convert single filter to an array // split string in the form ?filter=handle:value if (!is_array($_REQUEST['filter'])) { list($field_handle, $filter_value) = explode(':', $_REQUEST['filter'], 2); $filters[$field_handle] = rawurldecode($filter_value); } else { $filters = $_REQUEST['filter']; } foreach ($filters as $handle => $value) { // Handle multiple values through filtering. RE: #2290 if (is_array($value) && empty($value) || trim($value) == '') { continue; } if (!is_array($value)) { $filter_type = Datasource::determineFilterType($value); $value = preg_split('/' . ($filter_type == Datasource::FILTER_AND ? '\\+' : '(?<!\\\\),') . '\\s*/', $value, -1, PREG_SPLIT_NO_EMPTY); $value = array_map('trim', $value); $value = array_map(array('Datasource', 'removeEscapedCommas'), $value); } // Handle date meta data #2003 $handle = Symphony::Database()->cleanValue($handle); if (in_array($handle, array('system:creation-date', 'system:modification-date'))) { $date_joins = ''; $date_where = ''; $date = new FieldDate(); $date->buildDSRetrievalSQL($value, $date_joins, $date_where, $filter_type == Datasource::FILTER_AND ? true : false); // Replace the date field where with the `creation_date` or `modification_date`. $date_where = preg_replace('/`t\\d+`.date/', $field_id !== 'system:modification-date' ? '`e`.creation_date_gmt' : '`e`.modification_date_gmt', $date_where); $where .= $date_where; } else { // Handle normal fields $field_id = FieldManager::fetchFieldIDFromElementName($handle, $section->get('id')); $field = FieldManager::fetch($field_id); if ($field instanceof Field) { $field->buildDSRetrievalSQL($value, $joins, $where, $filter_type == Datasource::FILTER_AND ? true : false); $value = implode(',', $value); $encoded_value = rawurlencode($value); $filter_querystring .= sprintf("filter[%s]=%s&", $handle, $encoded_value); // Some fields require that prepopulation be done via ID. RE: #2331 if (!is_numeric($value) && method_exists($field, 'fetchIDfromValue')) { $encoded_value = $field->fetchIDfromValue($value); } $prepopulate_querystring .= sprintf("prepopulate[%d]=%s&", $field_id, $encoded_value); } else { unset($filters[$handle]); } } } $filter_querystring = preg_replace("/&\$/", '', $filter_querystring); $prepopulate_querystring = preg_replace("/&\$/", '', $prepopulate_querystring); } Sortable::initialize($this, $entries, $sort, $order, array('current-section' => $section, 'filters' => $filter_querystring ? "&" . $filter_querystring : '', 'unsort' => isset($_REQUEST['unsort']))); $this->Form->setAttribute('action', Administration::instance()->getCurrentPageURL() . '?pg=' . $current_page . ($filter_querystring ? "&" . $filter_querystring : '')); // Build filtering interface $this->createFilteringInterface(); $subheading_buttons = array(Widget::Anchor(__('Create New'), Administration::instance()->getCurrentPageURL() . 'new/' . ($prepopulate_querystring ? '?' . $prepopulate_querystring : ''), __('Create a new entry'), 'create button', null, array('accesskey' => 'c'))); // Only show the Edit Section button if the Author is a developer. #938 ^BA if (Symphony::Author()->isDeveloper()) { array_unshift($subheading_buttons, Widget::Anchor(__('Edit Section'), SYMPHONY_URL . '/blueprints/sections/edit/' . $section_id . '/', __('Edit Section Configuration'), 'button')); } $this->appendSubheading($section->get('name'), $subheading_buttons); /** * Allows adjustments to be made to the SQL where and joins statements * before they are used to fetch the entries for the page * * @delegate AdjustPublishFiltering * @since Symphony 2.3.3 * @param string $context * '/publish/' * @param integer $section_id * An array of the current columns, passed by reference * @param string $where * The current where statement, or null if not set * @param string $joins */ Symphony::ExtensionManager()->notifyMembers('AdjustPublishFiltering', '/publish/', array('section-id' => $section_id, 'where' => &$where, 'joins' => &$joins)); // Check that the filtered query fails that the filter is dropped and an // error is logged. #841 ^BA try { $entries = EntryManager::fetchByPage($current_page, $section_id, Symphony::Configuration()->get('pagination_maximum_rows', 'symphony'), $where, $joins, true); } catch (DatabaseException $ex) { $this->pageAlert(__('An error occurred while retrieving filtered entries. Showing all entries instead.'), Alert::ERROR); $filter_querystring = null; Symphony::Log()->pushToLog(sprintf('%s - %s%s%s', $section->get('name') . ' Publish Index', $ex->getMessage(), $ex->getFile() ? " in file " . $ex->getFile() : null, $ex->getLine() ? " on line " . $ex->getLine() : null), E_NOTICE, true); $entries = EntryManager::fetchByPage($current_page, $section_id, Symphony::Configuration()->get('pagination_maximum_rows', 'symphony')); } // Flag filtering if (isset($_REQUEST['filter'])) { $filter_stats = new XMLElement('p', '<span>– ' . __('%d of %d entries (filtered)', array($entries['total-entries'], EntryManager::fetchCount($section_id))) . '</span>', array('class' => 'inactive')); } else { $filter_stats = new XMLElement('p', '<span>– ' . __('%d entries', array($entries['total-entries'])) . '</span>', array('class' => 'inactive')); } $this->Breadcrumbs->appendChild($filter_stats); // Build table $visible_columns = $section->fetchVisibleColumns(); $columns = array(); if (is_array($visible_columns) && !empty($visible_columns)) { foreach ($visible_columns as $column) { $columns[] = array('label' => $column->get('label'), 'sortable' => $column->isSortable(), 'handle' => $column->get('id'), 'attrs' => array('id' => 'field-' . $column->get('id'), 'class' => 'field-' . $column->get('type'))); } } else { $columns[] = array('label' => __('ID'), 'sortable' => true, 'handle' => 'id'); } $aTableHead = Sortable::buildTableHeaders($columns, $sort, $order, $filter_querystring ? "&" . $filter_querystring : ''); $child_sections = array(); $associated_sections = $section->fetchChildAssociations(true); if (is_array($associated_sections) && !empty($associated_sections)) { foreach ($associated_sections as $key => $as) { $child_sections[$key] = SectionManager::fetch($as['child_section_id']); $aTableHead[] = array($child_sections[$key]->get('name'), 'col'); } } /** * Allows the creation of custom table columns for each entry. Called * after all the Section Visible columns have been added as well * as the Section Associations * * @delegate AddCustomPublishColumn * @since Symphony 2.2 * @param string $context * '/publish/' * @param array $tableHead * An array of the current columns, passed by reference * @param integer $section_id * The current Section ID */ Symphony::ExtensionManager()->notifyMembers('AddCustomPublishColumn', '/publish/', array('tableHead' => &$aTableHead, 'section_id' => $section->get('id'))); // Table Body $aTableBody = array(); if (!is_array($entries['records']) || empty($entries['records'])) { $aTableBody = array(Widget::TableRow(array(Widget::TableData(__('None found.'), 'inactive', null, count($aTableHead))), 'odd')); } else { $field_pool = array(); if (is_array($visible_columns) && !empty($visible_columns)) { foreach ($visible_columns as $column) { $field_pool[$column->get('id')] = $column; } } $link_column = array_reverse($visible_columns); $link_column = end($link_column); reset($visible_columns); foreach ($entries['records'] as $entry) { $tableData = array(); // Setup each cell if (!is_array($visible_columns) || empty($visible_columns)) { $tableData[] = Widget::TableData(Widget::Anchor($entry->get('id'), Administration::instance()->getCurrentPageURL() . 'edit/' . $entry->get('id') . '/')); } else { $link = Widget::Anchor('', Administration::instance()->getCurrentPageURL() . 'edit/' . $entry->get('id') . '/' . ($filter_querystring ? '?' . $prepopulate_querystring : ''), $entry->get('id'), 'content'); foreach ($visible_columns as $position => $column) { $data = $entry->getData($column->get('id')); $field = $field_pool[$column->get('id')]; $value = $field->prepareTableValue($data, $column == $link_column ? $link : null, $entry->get('id')); if (!is_object($value) && (strlen(trim($value)) == 0 || $value == __('None'))) { $value = $position == 0 ? $link->generate() : __('None'); } if ($value == __('None')) { $tableData[] = Widget::TableData($value, 'inactive field-' . $column->get('type') . ' field-' . $column->get('id')); } else { $tableData[] = Widget::TableData($value, 'field-' . $column->get('type') . ' field-' . $column->get('id')); } unset($field); } } if (is_array($child_sections) && !empty($child_sections)) { foreach ($child_sections as $key => $as) { $field = FieldManager::fetch((int) $associated_sections[$key]['child_section_field_id']); $parent_section_field_id = (int) $associated_sections[$key]['parent_section_field_id']; if (!is_null($parent_section_field_id)) { $search_value = $field->fetchAssociatedEntrySearchValue($entry->getData($parent_section_field_id), $parent_section_field_id, $entry->get('id')); } else { $search_value = $entry->get('id'); } if (!is_array($search_value)) { $associated_entry_count = $field->fetchAssociatedEntryCount($search_value); $tableData[] = Widget::TableData(Widget::Anchor(sprintf('%d →', max(0, intval($associated_entry_count))), sprintf('%s/publish/%s/?filter[%s]=%s', SYMPHONY_URL, $as->get('handle'), $field->get('element_name'), rawurlencode($search_value)), $entry->get('id'), 'content')); } } } /** * Allows Extensions to inject custom table data for each Entry * into the Publish Index * * @delegate AddCustomPublishColumnData * @since Symphony 2.2 * @param string $context * '/publish/' * @param array $tableData * An array of `Widget::TableData`, passed by reference * @param integer $section_id * The current Section ID * @param Entry $entry_id * The entry object, please note that this is by error and this will * be removed in Symphony 2.4. The entry object is available in * the 'entry' key as of Symphony 2.3.1. * @param Entry $entry * The entry object for this row */ Symphony::ExtensionManager()->notifyMembers('AddCustomPublishColumnData', '/publish/', array('tableData' => &$tableData, 'section_id' => $section->get('id'), 'entry_id' => $entry, 'entry' => $entry)); $tableData[count($tableData) - 1]->appendChild(Widget::Label(__('Select Entry %d', array($entry->get('id'))), null, 'accessible', null, array('for' => 'entry-' . $entry->get('id')))); $tableData[count($tableData) - 1]->appendChild(Widget::Input('items[' . $entry->get('id') . ']', null, 'checkbox', array('id' => 'entry-' . $entry->get('id')))); // Add a row to the body array, assigning each cell to the row $aTableBody[] = Widget::TableRow($tableData, null, 'id-' . $entry->get('id')); } } $table = Widget::Table(Widget::TableHead($aTableHead), null, Widget::TableBody($aTableBody), 'selectable', null, array('role' => 'directory', 'aria-labelledby' => 'symphony-subheading', 'data-interactive' => 'data-interactive')); $this->Form->appendChild($table); $tableActions = new XMLElement('div'); $tableActions->setAttribute('class', 'actions'); $options = array(array(null, false, __('With Selected...')), array('delete', false, __('Delete'), 'confirm', null, array('data-message' => __('Are you sure you want to delete the selected entries?')))); $toggable_fields = $section->fetchToggleableFields(); if (is_array($toggable_fields) && !empty($toggable_fields)) { $index = 2; foreach ($toggable_fields as $field) { $toggle_states = $field->getToggleStates(); if (is_array($toggle_states)) { $options[$index] = array('label' => __('Set %s', array($field->get('label'))), 'options' => array()); foreach ($toggle_states as $value => $state) { $options[$index]['options'][] = array('toggle-' . $field->get('id') . '-' . $value, false, $state); } } $index++; } } /** * Allows an extension to modify the existing options for this page's * With Selected menu. If the `$options` parameter is an empty array, * the 'With Selected' menu will not be rendered. * * @delegate AddCustomActions * @since Symphony 2.3.2 * @param string $context * '/publish/' * @param array $options * An array of arrays, where each child array represents an option * in the With Selected menu. Options should follow the same format * expected by `Widget::__SelectBuildOption`. Passed by reference. */ Symphony::ExtensionManager()->notifyMembers('AddCustomActions', '/publish/', array('options' => &$options)); if (!empty($options)) { $tableActions->appendChild(Widget::Apply($options)); $this->Form->appendChild($tableActions); } if ($entries['total-pages'] > 1) { $ul = new XMLElement('ul'); $ul->setAttribute('class', 'page'); // First $li = new XMLElement('li'); if ($current_page > 1) { $li->appendChild(Widget::Anchor(__('First'), Administration::instance()->getCurrentPageURL() . '?pg=1' . ($filter_querystring ? "&" . $filter_querystring : ''))); } else { $li->setValue(__('First')); } $ul->appendChild($li); // Previous $li = new XMLElement('li'); if ($current_page > 1) { $li->appendChild(Widget::Anchor(__('← Previous'), Administration::instance()->getCurrentPageURL() . '?pg=' . ($current_page - 1) . ($filter_querystring ? "&" . $filter_querystring : ''))); } else { $li->setValue(__('← Previous')); } $ul->appendChild($li); // Summary $li = new XMLElement('li'); $li->setAttribute('title', __('Viewing %1$s - %2$s of %3$s entries', array($entries['start'], $current_page != $entries['total-pages'] ? $current_page * Symphony::Configuration()->get('pagination_maximum_rows', 'symphony') : $entries['total-entries'], $entries['total-entries']))); $pgform = Widget::Form(Administration::instance()->getCurrentPageURL(), 'get', 'paginationform'); $pgmax = max($current_page, $entries['total-pages']); $pgform->appendChild(Widget::Input('pg', null, 'text', array('data-active' => __('Go to page …'), 'data-inactive' => __('Page %1$s of %2$s', array((string) $current_page, $pgmax)), 'data-max' => $pgmax))); $li->appendChild($pgform); $ul->appendChild($li); // Next $li = new XMLElement('li'); if ($current_page < $entries['total-pages']) { $li->appendChild(Widget::Anchor(__('Next →'), Administration::instance()->getCurrentPageURL() . '?pg=' . ($current_page + 1) . ($filter_querystring ? "&" . $filter_querystring : ''))); } else { $li->setValue(__('Next →')); } $ul->appendChild($li); // Last $li = new XMLElement('li'); if ($current_page < $entries['total-pages']) { $li->appendChild(Widget::Anchor(__('Last'), Administration::instance()->getCurrentPageURL() . '?pg=' . $entries['total-pages'] . ($filter_querystring ? "&" . $filter_querystring : ''))); } else { $li->setValue(__('Last')); } $ul->appendChild($li); $this->Contents->appendChild($ul); } }
public function view() { $field_id = General::sanitize($_POST['field']); $items = $_POST['items']; $filters = $_POST['filters']; if (!is_array($items) || empty($items)) { $this->_Result['error'] = __('No items provided'); $this->generate(); } $where = ''; $field = FieldManager::fetch($field_id); $filterableFields = explode(',', $field->get('filtered_fields')); $section_id = $field->get('parent_section'); if (!is_array($filters) && empty($filters)) { $filters = array(); } //set change the field name with the field id for each filter if (!empty($filterableFields)) { // check if the filters are related to the entry order being saved foreach ($filters as $field_name => $value) { $filtered_field_id = FieldManager::fetchFieldIDFromElementName($field_name, $section_id); if (in_array($filtered_field_id, $filterableFields)) { $filters[$filtered_field_id] = strtolower(General::sanitize($value)); } unset($filters[$field_name]); } $where = $field->buildFilteringSQL($filters); } /** * Just prior to reordering entries * * @delegate EntryPreOrder * @param string $context * '/publish/' * @param number $field_id * @param array $items */ Symphony::ExtensionManager()->notifyMembers('EntriesPreOrder', '/publish/', array('field_id' => $field_id, 'items' => &$items)); foreach ($items as $entry_id => $position) { $id = Symphony::Database()->fetchVar('id', 0, "\n\t\t\t\t\tSELECT id\n\t\t\t\t\tFROM tbl_entries_data_{$field_id}\n\t\t\t\t\tWHERE `entry_id` = '{$entry_id}' {$where}\n\t\t\t\t\tORDER BY id ASC LIMIT 1\n\t\t\t\t"); if (is_null($id)) { $fields = ''; $values = ''; //add the filtered params if available (default set to null) foreach ($filterableFields as $key => $filterable_field) { if (isset($filters[$filterable_field])) { $fields .= " ,field_{$filterable_field}"; $values .= " ,'{$filters[$filterable_field]}'"; } } Symphony::Database()->query("\n\t\t\t\t\t\tINSERT INTO tbl_entries_data_{$field_id} (entry_id, value{$fields})\n\t\t\t\t\t\tVALUES ('{$entry_id}', '{$position}'{$values})\n\t\t\t\t\t"); } else { Symphony::Database()->query("\n\t\t\t\t\t\tUPDATE tbl_entries_data_{$field_id}\n\t\t\t\t\t\tSET `value`='{$position}'\n\t\t\t\t\t\tWHERE `entry_id` = '{$entry_id}' {$where}\n\t\t\t\t\t"); Symphony::Database()->query("\n\t\t\t\t\t\tDELETE FROM tbl_entries_data_{$field_id}\n\t\t\t\t\t\tWHERE `entry_id` = '{$entry_id}' {$where}\n\t\t\t\t\t\tAND `id` > '{$id}'\n\t\t\t\t\t"); } } /** * After reordering entries * * @delegate EntryPostOrder * @param string $context * '/publish/' * @param array $entry_id */ Symphony::ExtensionManager()->notifyMembers('EntriesPostOrder', '/publish/', array('entry_id' => array_keys($items))); $this->_Result['success'] = __('Sorting complete'); }
public function dataSourcePreExecute($context) { // clear preexisting output $context['xml'] = null; // check if language preconditions are met if (self::$languages && self::$language !== self::$languages[0]) { $filters = $context['datasource']->dsParamFILTERS; $section = $context['datasource']->getSource(); // check if datasource has filters if (is_array($filters)) { // swap filters to current language fields foreach ($filters as $field_id => $filter) { $field_handle = FieldManager::fetchHandleFromID($field_id); // check if field handle is multilingual if (preg_match('/-' . self::$languages[0] . '$/', $field_handle)) { // get current language field handle $field2_handle = preg_replace('/-' . self::$languages[0] . '$/', '-' . self::$language, $field_handle); // check if current language field exists if ($field2_id = FieldManager::fetchFieldIDFromElementName($field2_handle, $section)) { // remove default field from filters unset($filters[$field_id]); // add current language field to filters $filters[$field2_id] = $filter; } } } // backup default filters $context['datasource']->dsDefaultFILTERS = $context['datasource']->dsParamFILTERS; // save current language filters $context['datasource']->dsParamFILTERS = $filters; } } }
public function sendEvent($context) { //Store some information on the Symphony Entry. $entry = $context['entry']; $entry_settings = $entry->get(); $entry_id = $entry_settings['id']; $e_data = array(); foreach($context['fields'] as $key => $value) { if($this->string_begins_with($key, 'e-')) { $e_data[str_replace('e-', 'e_', $key)] = $value; } else if ($this->string_begins_with($key, 'g-')) { $e_data[str_replace('g-', 'g_', $key)] = $value; } } //Change the e_status property to a value the API understands if($e_data['e_status'] == 'yes') { $e_data['e_status'] = 'active'; } else { $e_data['e_status'] = 'pending'; } //Set the format of the Date/Times $e_data['e_start'] = date('Y-m-d G:i:s', strtotime($e_data['e_start'])); $e_data['e_stop'] = date('Y-m-d G:i:s', strtotime($e_data['e_stop'])); $e_data['e_deadline'] = date('Y-m-d G:i:s', strtotime($e_data['e_deadline'])); //Another Required field is the User ID $e_data['u_id'] = $this->u_id; //Create a unique Push URL (e_pushurl) from the entry ID. $e_data['e_pushurl'] = URL .'/eventarc-updater/?hash='.sha1($entry_id).'&id='.$entry_id; //Address Data $a_data = array(); foreach($context['fields'] as $key => $value) { if($this->string_begins_with($key, 'a-')) { $a_data[str_replace('a-', 'a_', $key)] = $value; } } //If the ID & URL are not set - Create a new event. if($e_data['e_id'] == '' && $e_data['e_url'] == '') { unset($e_data['e_id']); unset($e_data['e_url']); if(!empty($a_data)) { //Set the type as venue. $a_data['a_type'] = 'venue'; // Send the event to eventarc with the address details $result = $this->eventarc ->add_event($e_data) ->add_address($a_data) ->event_create(); } else { // Send the event to eventarc $result = $this->eventarc ->add_event($e_data) ->event_create(); } if($result) { if(!isset(self::$fieldManager)) { self::$fieldManager = new fieldManager(Symphony::Engine()); } $field_id = self::$fieldManager->fetchFieldIDFromElementName('e-id'); $entry->setData($field_id, array( 'handle' => $result['e_id'], 'value' => $result['e_id'], 'value_formatted' => $result['e_id'], 'word_count' => 0 )); //Save the returned Eventarc URL (e_url). $field_id = self::$fieldManager->fetchFieldIDFromElementName('e-url'); $entry->setData($field_id, array( 'handle' => $result['url'], 'value' => $result['url'], 'value_formatted' => $result['url'], 'word_count' => 0 )); //Save the returned Eventarc Address ID (a_id). $field_id = self::$fieldManager->fetchFieldIDFromElementName('a-id'); $entry->setData($field_id, array( 'handle' => $result['a_id'], 'value' => $result['a_id'], 'value_formatted' => $result['a_id'], 'word_count' => 0 )); $entry->commit(); } } //Event already exists - update the event. else { //Check that the URL is not empty. if($e_data['e_url'] == '') { $result = $this->eventarc->event_get($e_data['e_id']); if(!isset(self::$fieldManager)) { self::$fieldManager = new fieldManager(Symphony::Engine()); } //Save the returned Eventarc URL (e_url). $field_id = self::$fieldManager->fetchFieldIDFromElementName('e-url'); $entry->setData($field_id, array( 'handle' => $result['url'], 'value' => $result['url'], 'value_formatted' => $result['url'], 'word_count' => 0 )); $entry->commit(); } //Check that the Address ID is not empty. if($a_data['a_id'] == '') { $result = $this->eventarc->event_get_address($e_data['e_id']); if(!isset(self::$fieldManager)) { self::$fieldManager = new fieldManager(Symphony::Engine()); } //Save the returned Eventarc Address ID (a_id). $field_id = self::$fieldManager->fetchFieldIDFromElementName('a-id'); $entry->setData($field_id, array( 'handle' => $result['a_id'], 'value' => $result['a_id'], 'value_formatted' => $result['a_id'], 'word_count' => 0 )); //Store the retrieved address ID. $a_data['a_id'] = $result['a_id']; $entry->commit(); } //Don't want to manually change the URL generated by Eventarc. unset($e_data['e_url']); //Edit the Event. if(!empty($a_data)) { //Set the type as venue. $a_data['a_type'] = 'venue'; // Send the event to eventarc with the address details $result = $this->eventarc ->add_event($e_data) ->event_update(); $result = $this->eventarc ->add_address($a_data) ->address_update(); } else { // Send the event to eventarc $result = $this->eventarc ->add_event($e_data) ->event_update(); } } }
public function actionLogin($parent, $values, $redirect) { $em = new EntryManager($this->parent); $fm = new FieldManager($this->parent); $fields = array(); $section = $this->section; $where = $joins = $group = null; $name_where = $name_joins = $name_group = null; $result = new XMLElement('section'); $result->setAttribute('handle', $this->handle); $parent->appendChild($result); // Get given fields: foreach ($values as $key => $value) { $field_id = $fm->fetchFieldIDFromElementName($key, $this->section->get('id')); if (!is_null($field_id)) { $field = $fm->fetch($field_id, $this->section->get('id')); if ($field instanceof FieldMemberName or $field instanceof FieldMemberPassword) { $fields[] = $field; $field->buildDSRetrivalSQL($value, $joins, $where); if (!$group) { $group = $field->requiresSQLGrouping(); } //Build SQL for determining of the username or the password was incorrrect. Only executed if login fails if ($field instanceof FieldMemberName) { $field->buildDSRetrivalSQL($value, $name_joins, $name_where); if (!$name_group) { $name_group = $field->requiresSQLGrouping(); } } } } } // Find matching entries: $entries = $em->fetch(null, $this->section->get('id'), 1, null, $where, $joins, $group, true); // Invalid credentials, woot! if (!($entry = @current($entries))) { $result->setAttribute('status', 'failed'); //determine reason for login failure. This should not normally be shown to the user as it can lead to account cracking attempts. $name_entries = $em->fetch(null, $this->section->get('id'), 1, null, $name_where, $name_joins, $name_group, true); if ($name_entry = @current($name_entries)) { $result->setAttribute('reason', 'incorrect-password'); } else { $result->setAttribute('reason', 'incorrect-username'); } return false; } $this->setMember($entry); $field = $this->getMemberField(FMM::FIELD_MEMBERSTATUS); $data = $entry->getData($field->get('id')); $status = @current($data['value']); // The member is banned: if ($status == FMM::STATUS_BANNED) { $result->setAttribute('status', 'banned'); return false; } // The member is inactive: if ($status == FMM::STATUS_PENDING) { $result->setAttribute('status', 'pending'); return false; } $result->setAttribute('status', 'success'); $this->updateTrackingData(FMM::TRACKING_LOGIN); if ($redirect != null) { redirect($redirect); } return true; }
public function __viewIndex() { if (!($section_id = SectionManager::fetchIDFromHandle($this->_context['section_handle']))) { Administration::instance()->customError(__('Unknown Section'), __('The Section you are looking for, %s, could not be found.', array('<code>' . $this->_context['section_handle'] . '</code>'))); } $section = SectionManager::fetch($section_id); $this->setPageType('table'); $this->setTitle(__('%1$s – %2$s', array($section->get('name'), __('Symphony')))); $this->Form->setAttribute("class", $this->_context['section_handle']); $filters = array(); $filter_querystring = $prepopulate_querystring = $where = $joins = NULL; $current_page = isset($_REQUEST['pg']) && is_numeric($_REQUEST['pg']) ? max(1, intval($_REQUEST['pg'])) : 1; if (isset($_REQUEST['filter'])) { // legacy implementation, convert single filter to an array // split string in the form ?filter=handle:value if (!is_array($_REQUEST['filter'])) { list($field_handle, $filter_value) = explode(':', $_REQUEST['filter'], 2); $filters[$field_handle] = rawurldecode($filter_value); } else { $filters = $_REQUEST['filter']; } foreach ($filters as $handle => $value) { $field_id = FieldManager::fetchFieldIDFromElementName(Symphony::Database()->cleanValue($handle), $section->get('id')); $field = FieldManager::fetch($field_id); if ($field instanceof Field) { // For deprecated reasons, call the old, typo'd function name until the switch to the // properly named buildDSRetrievalSQL function. $field->buildDSRetrivalSQL(array($value), $joins, $where, false); $filter_querystring .= sprintf("filter[%s]=%s&", $handle, rawurlencode($value)); $prepopulate_querystring .= sprintf("prepopulate[%d]=%s&", $field_id, rawurlencode($value)); } else { unset($filters[$handle]); } } $filter_querystring = preg_replace("/&\$/", '', $filter_querystring); $prepopulate_querystring = preg_replace("/&\$/", '', $prepopulate_querystring); } Sortable::initialize($this, $entries, $sort, $order, array('current-section' => $section, 'filters' => $filter_querystring ? "&" . $filter_querystring : '', 'unsort' => isset($_REQUEST['unsort']))); $this->Form->setAttribute('action', Administration::instance()->getCurrentPageURL() . '?pg=' . $current_page . ($filter_querystring ? "&" . $filter_querystring : '')); $subheading_buttons = array(Widget::Anchor(__('Create New'), Administration::instance()->getCurrentPageURL() . 'new/' . ($filter_querystring ? '?' . $prepopulate_querystring : ''), __('Create a new entry'), 'create button', NULL, array('accesskey' => 'c'))); // Only show the Edit Section button if the Author is a developer. #938 ^BA if (Administration::instance()->Author->isDeveloper()) { array_unshift($subheading_buttons, Widget::Anchor(__('Edit Section'), SYMPHONY_URL . '/blueprints/sections/edit/' . $section_id, __('Edit Section Configuration'), 'button')); } $this->appendSubheading($section->get('name'), $subheading_buttons); // Check that the filtered query fails that the filter is dropped and an // error is logged. #841 ^BA try { $entries = EntryManager::fetchByPage($current_page, $section_id, Symphony::Configuration()->get('pagination_maximum_rows', 'symphony'), $where, $joins); } catch (DatabaseException $ex) { $this->pageAlert(__('An error occurred while retrieving filtered entries. Showing all entries instead.'), Alert::ERROR); $filter_querystring = null; Symphony::Log()->pushToLog(sprintf('%s - %s%s%s', $section->get('name') . ' Publish Index', $ex->getMessage(), $ex->getFile() ? " in file " . $ex->getFile() : null, $ex->getLine() ? " on line " . $ex->getLine() : null), E_NOTICE, true); $entries = EntryManager::fetchByPage($current_page, $section_id, Symphony::Configuration()->get('pagination_maximum_rows', 'symphony')); } $visible_columns = $section->fetchVisibleColumns(); $columns = array(); if (is_array($visible_columns) && !empty($visible_columns)) { foreach ($visible_columns as $column) { $columns[] = array('label' => $column->get('label'), 'sortable' => $column->isSortable(), 'handle' => $column->get('id'), 'attrs' => array('id' => 'field-' . $column->get('id'), 'class' => 'field-' . $column->get('type'))); } } else { $columns[] = array('label' => __('ID'), 'sortable' => true, 'handle' => 'id'); } $aTableHead = Sortable::buildTableHeaders($columns, $sort, $order, $filter_querystring ? "&" . $filter_querystring : ''); $child_sections = array(); $associated_sections = $section->fetchAssociatedSections(true); if (is_array($associated_sections) && !empty($associated_sections)) { foreach ($associated_sections as $key => $as) { $child_sections[$key] = SectionManager::fetch($as['child_section_id']); $aTableHead[] = array($child_sections[$key]->get('name'), 'col'); } } /** * Allows the creation of custom entries tablecolumns. Called * after all the Section Visible columns have been added as well * as the Section Associations * * @delegate AddCustomPublishColumn * @since Symphony 2.2 * @param string $context * '/publish/' * @param array $tableHead * An array of the current columns, passed by reference * @param integer $section_id * The current Section ID */ Symphony::ExtensionManager()->notifyMembers('AddCustomPublishColumn', '/publish/', array('tableHead' => &$aTableHead, 'section_id' => $section->get('id'))); // Table Body $aTableBody = array(); if (!is_array($entries['records']) || empty($entries['records'])) { $aTableBody = array(Widget::TableRow(array(Widget::TableData(__('None found.'), 'inactive', NULL, count($aTableHead))), 'odd')); } else { $field_pool = array(); if (is_array($visible_columns) && !empty($visible_columns)) { foreach ($visible_columns as $column) { $field_pool[$column->get('id')] = $column; } } $link_column = end(array_reverse($visible_columns)); reset($visible_columns); foreach ($entries['records'] as $entry) { $tableData = array(); // Setup each cell if (!is_array($visible_columns) || empty($visible_columns)) { $tableData[] = Widget::TableData(Widget::Anchor($entry->get('id'), Administration::instance()->getCurrentPageURL() . 'edit/' . $entry->get('id') . '/')); } else { $link = Widget::Anchor(__('None'), Administration::instance()->getCurrentPageURL() . 'edit/' . $entry->get('id') . '/', $entry->get('id'), 'content'); foreach ($visible_columns as $position => $column) { $data = $entry->getData($column->get('id')); $field = $field_pool[$column->get('id')]; $value = $field->prepareTableValue($data, $column == $link_column ? $link : null, $entry->get('id')); if (!is_object($value) && (strlen(trim($value)) == 0 || $value == __('None'))) { $value = $position == 0 ? $link->generate() : __('None'); } if ($value == __('None')) { $tableData[] = Widget::TableData($value, 'inactive field-' . $column->get('type') . ' field-' . $column->get('id')); } else { $tableData[] = Widget::TableData($value, 'field-' . $column->get('type') . ' field-' . $column->get('id')); } unset($field); } } if (is_array($child_sections) && !empty($child_sections)) { foreach ($child_sections as $key => $as) { $field = FieldManager::fetch((int) $associated_sections[$key]['child_section_field_id']); $parent_section_field_id = (int) $associated_sections[$key]['parent_section_field_id']; if (!is_null($parent_section_field_id)) { $search_value = $field->fetchAssociatedEntrySearchValue($entry->getData($parent_section_field_id), $parent_section_field_id, $entry->get('id')); } else { $search_value = $entry->get('id'); } if (!is_array($search_value)) { $associated_entry_count = $field->fetchAssociatedEntryCount($search_value); $tableData[] = Widget::TableData(Widget::Anchor(sprintf('%d →', max(0, intval($associated_entry_count))), sprintf('%s/publish/%s/?filter=%s:%s', SYMPHONY_URL, $as->get('handle'), $field->get('element_name'), rawurlencode($search_value)), $entry->get('id'), 'content')); } } } /** * Allows Extensions to inject custom table data for each Entry * into the Publish Index * * @delegate AddCustomPublishColumnData * @since Symphony 2.2 * @param string $context * '/publish/' * @param array $tableData * An array of `Widget::TableData`, passed by reference * @param integer $section_id * The current Section ID * @param integer $entry_id * The Entry ID for this row */ Symphony::ExtensionManager()->notifyMembers('AddCustomPublishColumnData', '/publish/', array('tableData' => &$tableData, 'section_id' => $section->get('id'), 'entry_id' => $entry)); $tableData[count($tableData) - 1]->appendChild(Widget::Input('items[' . $entry->get('id') . ']', NULL, 'checkbox')); // Add a row to the body array, assigning each cell to the row $aTableBody[] = Widget::TableRow($tableData, NULL, 'id-' . $entry->get('id')); } } $table = Widget::Table(Widget::TableHead($aTableHead), NULL, Widget::TableBody($aTableBody), 'selectable'); $this->Form->appendChild($table); $tableActions = new XMLElement('div'); $tableActions->setAttribute('class', 'actions'); $options = array(array(NULL, false, __('With Selected...')), array('delete', false, __('Delete'), 'confirm', null, array('data-message' => __('Are you sure you want to delete the selected entries?')))); $toggable_fields = $section->fetchToggleableFields(); if (is_array($toggable_fields) && !empty($toggable_fields)) { $index = 2; foreach ($toggable_fields as $field) { $options[$index] = array('label' => __('Set %s', array($field->get('label'))), 'options' => array()); foreach ($field->getToggleStates() as $value => $state) { $options[$index]['options'][] = array('toggle-' . $field->get('id') . '-' . $value, false, $state); } $index++; } } $tableActions->appendChild(Widget::Apply($options)); $this->Form->appendChild($tableActions); if ($entries['total-pages'] > 1) { $ul = new XMLElement('ul'); $ul->setAttribute('class', 'page'); // First $li = new XMLElement('li'); if ($current_page > 1) { $li->appendChild(Widget::Anchor(__('First'), Administration::instance()->getCurrentPageURL() . '?pg=1' . ($filter_querystring ? "&" . $filter_querystring : ''))); } else { $li->setValue(__('First')); } $ul->appendChild($li); // Previous $li = new XMLElement('li'); if ($current_page > 1) { $li->appendChild(Widget::Anchor(__('← Previous'), Administration::instance()->getCurrentPageURL() . '?pg=' . ($current_page - 1) . ($filter_querystring ? "&" . $filter_querystring : ''))); } else { $li->setValue(__('← Previous')); } $ul->appendChild($li); // Summary $li = new XMLElement('li'); $li->setAttribute('title', __('Viewing %1$s - %2$s of %3$s entries', array($entries['start'], $current_page != $entries['total-pages'] ? $current_page * Symphony::Configuration()->get('pagination_maximum_rows', 'symphony') : $entries['total-entries'], $entries['total-entries']))); $pgform = Widget::Form(Administration::instance()->getCurrentPageURL(), 'get', 'paginationform'); $pgmax = max($current_page, $entries['total-pages']); $pgform->appendChild(Widget::Input('pg', NULL, 'text', array('data-active' => __('Go to page …'), 'data-inactive' => __('Page %1$s of %2$s', array((string) $current_page, $pgmax)), 'data-max' => $pgmax))); $li->appendChild($pgform); $ul->appendChild($li); // Next $li = new XMLElement('li'); if ($current_page < $entries['total-pages']) { $li->appendChild(Widget::Anchor(__('Next →'), Administration::instance()->getCurrentPageURL() . '?pg=' . ($current_page + 1) . ($filter_querystring ? "&" . $filter_querystring : ''))); } else { $li->setValue(__('Next →')); } $ul->appendChild($li); // Last $li = new XMLElement('li'); if ($current_page < $entries['total-pages']) { $li->appendChild(Widget::Anchor(__('Last'), Administration::instance()->getCurrentPageURL() . '?pg=' . $entries['total-pages'] . ($filter_querystring ? "&" . $filter_querystring : ''))); } else { $li->setValue(__('Last')); } $ul->appendChild($li); $this->Contents->appendChild($ul); } }
/** * Fetch the ruleset stored in the specified record in the section and field as set in the preferences. * * @param string $entryId * @return array */ protected function fetchRuleset($entryId) { // Initialize a SectionManager and fetch the section ID. $sectionManager = new SectionManager($this->_Parent); $sectionId = $sectionManager->fetchIDFromHandle($this->getSection()); // Initialize an EntryManager and fetch the entry. $entryManager = new EntryManager($this->_Parent); $entries = $entryManager->fetch($entryId, $sectionId); // Check the result. if (!is_array($entries) || empty($entries)) { return false; } // Initialize a FieldManager and fetch the ruleset. $fieldManager = new FieldManager($this->_Parent); $fieldId = $fieldManager->fetchFieldIDFromElementName($this->getField()); $fieldData = $entries[0]->getData($fieldId); $field = $fieldData['value']; // Split the ruleset by newlines into an array. $field = preg_replace('/\\r\\n/', '\\n', $field); $field = preg_replace('/\\r/', '\\n', $field); return explode('\\n', $field); }
public function actionLogin($result, $values, $redirect, $simulate = false) { $em = new EntryManager($this->parent); $fm = new FieldManager($this->parent); $section = $this->section; $where = $joins = $group = null; $name_where = $name_joins = $name_group = null; $has_email = false; $has_password = false; // Get given fields: foreach ($values as $key => $value) { $field_id = $fm->fetchFieldIDFromElementName($key, $this->section->get('id')); if (!is_null($field_id)) { $field = $fm->fetch($field_id, $this->section->get('id')); if ($field instanceof FieldMemberEmail) { $has_email = true; } if ($field instanceof FieldMemberPassword) { $has_password = true; } if ($field instanceof FieldMemberEmail or $field instanceof FieldMemberPassword) { $field->buildDSRetrivalSQL($value, $joins, $where); if (!$group) { $group = $field->requiresSQLGrouping(); } // Build SQL for determining of the username or the password was // incorrrect. Only executed if login fails if ($field instanceof FieldMemberEmail) { $field->buildDSRetrivalSQL($value, $name_joins, $name_where); if (!$name_group) { $name_group = $field->requiresSQLGrouping(); } } } } } if ($has_email == false || $has_password == false) { $result->setAttribute('status', 'failed'); if ($has_email == false) { $result->setAttribute('reason', 'missing-email-field'); } if ($has_password == false) { $result->setAttribute('reason', 'missing-password-field'); } return FMM::RESULT_ERROR; } // Find matching entries: $entries = $em->fetch(null, $this->section->get('id'), 1, null, $where, $joins, $group, true); // Invalid credentials, woot! if (!($entry = @current($entries))) { $result->setAttribute('status', 'failed'); // Determine reason for login failure. $name_entries = $em->fetch(null, $this->section->get('id'), 1, null, $name_where, $name_joins, $name_group, true); if ($name_entry = @current($name_entries)) { $result->setAttribute('reason', 'incorrect-password'); return FMM::RESULT_INCORRECT_PASSWORD; } else { $result->setAttribute('reason', 'incorrect-email'); return FMM::RESULT_INCORRECT_EMAIL; } } $this->setMember($entry); $field = $this->getMemberField(FMM::FIELD_MEMBERSTATUS); $data = $entry->getData($field->get('id')); $status = is_array($data['value']) ? current($data['value']) : $data['value']; // The member is banned: if ($status == FMM::STATUS_BANNED) { $result->setAttribute('status', 'failed'); $result->setAttribute('reason', 'banned'); return FMM::RESULT_ACCOUNT_BANNED; } // The member is inactive: if ($status == FMM::STATUS_PENDING) { $result->setAttribute('status', 'failed'); $result->setAttribute('reason', 'pending'); return FMM::RESULT_ACCOUNT_PENDING; } $result->setAttribute('status', 'success'); if (!$simulate) { $this->updateTrackingData(FMM::TRACKING_LOGIN); if (!is_null($redirect)) { redirect($redirect); } } return FMM::RESULT_SUCCESS; }
/** * Get where and join information to build a query. * * The information returned by this function can be used in the * fetch() methods of the EntryManager class. If you only need * to fetch data the getSlice function is recommended. * * @return array */ public function getWhereJoinsAndGroup($count_only = false) { $where = NULL; $joins = NULL; if (is_array($this->dsParamFILTERS) && !empty($this->dsParamFILTERS)) { foreach ($this->dsParamFILTERS as $field_id => $filter) { if (is_array($filter) && empty($filter) || trim($filter) == '') { continue; } if (!is_array($filter)) { $filter_type = $this->__determineFilterType($filter); $value = preg_split('/' . ($filter_type == DS_FILTER_AND ? '\\+' : '(?<!\\\\),') . '\\s*/', $filter, -1, PREG_SPLIT_NO_EMPTY); $value = array_map('trim', $value); $value = array_map(array('Datasource', 'removeEscapedCommas'), $value); } else { $value = $filter; } if (!isset($fieldPool[$field_id]) || !is_object($fieldPool[$field_id])) { $fieldPool[$field_id] =& FieldManager::fetch($field_id); } if ($field_id != 'id' && $field_id != 'system:date' && !$fieldPool[$field_id] instanceof Field) { throw new Exception(__('Error creating field object with id %1$d, for filtering in data source "%2$s". Check this field exists.', array($field_id, $this->dsParamROOTELEMENT))); } if ($field_id == 'id') { $where = " AND `e`.id IN ('" . implode("', '", $value) . "') "; } elseif ($field_id == 'system:date') { $date = new fieldDate(Frontend::instance()); // Create an empty string, we don't care about the Joins, we just want the WHERE clause. $empty = ""; $date->buildDSRetrievalSQL($value, $empty, $where, $filter_type == DS_FILTER_AND ? true : false); $where = preg_replace('/`t\\d+`.value/', '`e`.creation_date', $where); } else { if (!$fieldPool[$field_id]->buildDSRetrievalSQL($value, $joins, $where, $filter_type == DS_FILTER_AND ? true : false)) { $this->_force_empty_result = true; return; } if (!$group) { $group = $fieldPool[$field_id]->requiresSQLGrouping(); } } } } $where .= ' AND `d`.`value` IS NOT NULL'; $joins .= ' LEFT JOIN tbl_entries_data_' . FieldManager::fetchFieldIDFromElementName($this->emailField, $this->getSource()) . ' AS `d` ON `e`.`id` = `d`.`entry_id`'; if ($this->newsletter_id !== NULL) { $joins .= ' LEFT OUTER JOIN tbl_tmp_email_newsletters_sent_' . $this->newsletter_id . ' AS `n` ON `d`.`value` = `n`.`email`'; $where .= ' AND `n`.`email` IS NULL GROUP BY `d`.`value`'; } elseif ($count_only != true) { $where .= ' GROUP BY `d`.`value`'; } return array('where' => $where, 'joins' => $joins); }
protected function __trigger(){ //Check the hash and the ID match if($_GET["hash"] == sha1($_GET["id"])) { //Get the entry object from the ID. if(!isset(self::$entryManager)) { self::$entryManager = new entryManager(Symphony::Engine()); } $entry_id = $_GET["id"]; $section_id = self::$entryManager->fetchEntrySectionID($entry_id); $entry = self::$entryManager->fetch($entry_id, $section_id); $entry = $entry[0]; //Retreive the Pushed JSON from the Eventarc API. $data = json_decode( utf8_encode(file_get_contents("php://input")), TRUE ); //Eventarc entry id. $e_id = $data['e_id']; //Login to eventarc & return the API key. $eventarc = new Eventarc; $login_data = $eventarc->user_login($this->get('eventarc-username'),$this->get('eventarc-password')); $u_apikey = $login_data['u_apikey']; //Now retrieve the Event $eventarc = new Eventarc($u_apikey, $this->get('eventarc-username')); $event = $eventarc->event_get($e_id); //First save the standard event entry fields $fields = array(); foreach($event as $key => $value) { if($this->string_begins_with($key, 'e_')) { $fields[str_replace('e_', 'e-', $key)] = strip_tags($value); } else if ($this->string_begins_with($key, 'g_')) { $fields[str_replace('g_', 'g-', $key)] = strip_tags($value); } } //Update the e_status to be 'Yes/No' for Symphony; if($fields['e-status'] == 'active') { $fields['e-status'] = 'yes'; } else { $fields['e-status'] = 'no'; } //Now look for address details $address = $eventarc->event_get_address($e_id); foreach($address as $key => $value) { if($this->string_begins_with($key, 'a_')) { $fields[str_replace('a_', 'a-', $key)] = strip_tags($value); } } if(!isset(self::$fieldManager)) { self::$fieldManager = new fieldManager(Symphony::Engine()); } foreach($fields as $key => $value) { $field_id = self::$fieldManager->fetchFieldIDFromElementName($key); if(isset($field_id)) { $entry->setData($field_id, array( 'value' => $value, )); } } $entry->commit(); return true; } }
/** * Check the field's settings to ensure they are valid on the section * editor * * @param array $errors * the array to populate with the errors found. * @param boolean $checkForDuplicates (optional) * if set to true, duplicate Field name's in the same section will be flagged * as errors. Defaults to true. * @return integer * returns the status of the checking. if errors has been populated with * any errors `self::__ERROR__`, `self::__OK__` otherwise. */ public function checkFields(array &$errors, $checkForDuplicates = true) { $parent_section = $this->get('parent_section'); $label = $this->get('label'); $element_name = $this->get('element_name'); if (Lang::isUnicodeCompiled()) { $valid_name = preg_match('/^[\\p{L}]([0-9\\p{L}\\.\\-\\_]+)?$/u', $element_name); } else { $valid_name = preg_match('/^[A-z]([\\w\\d-_\\.]+)?$/i', $element_name); } if ($label === '') { $errors['label'] = __('This is a required field.'); } elseif (strtolower($label) === 'id') { $errors['label'] = __('%s is a reserved name used by the system and is not allowed for a field handle. Try using %s instead.', array('<code>ID</code>', '<code>UID</code>')); } if ($element_name === '') { $errors['element_name'] = __('This is a required field.'); } elseif ($element_name === 'id') { $errors['element_name'] = __('%s is a reserved name used by the system and is not allowed for a field handle. Try using %s instead.', array('<code>id</code>', '<code>uid</code>')); } elseif (!$valid_name) { $errors['element_name'] = __('Invalid element name. Must be valid %s.', array('<code>QName</code>')); } elseif ($checkForDuplicates) { if (FieldManager::fetchFieldIDFromElementName($element_name, $parent_section) !== $this->get('id')) { $errors['element_name'] = __('A field with that element name already exists. Please choose another.'); } } // Check that if the validator is provided that it's a valid regular expression if (!is_null($this->get('validator')) && $this->get('validator') !== '') { if (@preg_match($this->get('validator'), 'teststring') === false) { $errors['validator'] = __('Validation rule is not a valid regular expression'); } } return !empty($errors) ? self::__ERROR__ : self::__OK__; }
/** * Check the field's settings to ensure they are valid on the section * editor * * @param array $errors * the array to populate with the errors found. * @param boolean $checkForDuplicates (optional) * if set to true, duplicate Field name's in the same section will be flagged * as errors. Defaults to true. * @return integer * returns the status of the checking. if errors has been populated with * any errors `self::__ERROR__`, `self::__OK__` otherwise. */ public function checkFields(array &$errors, $checkForDuplicates = true) { $parent_section = $this->get('parent_section'); $element_name = $this->get('element_name'); if (Lang::isUnicodeCompiled()) { $valid_name = preg_match('/^[\\p{L}]([0-9\\p{L}\\.\\-\\_]+)?$/u', $this->get('element_name')); } else { $valid_name = preg_match('/^[A-z]([\\w\\d-_\\.]+)?$/i', $this->get('element_name')); } if ($this->get('label') == '') { $errors['label'] = __('This is a required field.'); } if ($this->get('element_name') == '') { $errors['element_name'] = __('This is a required field.'); } elseif (!$valid_name) { $errors['element_name'] = __('Invalid element name. Must be valid %s.', array('<code>QName</code>')); } elseif ($checkForDuplicates) { if (FieldManager::fetchFieldIDFromElementName($element_name, $parent_section) != $this->get('id')) { $errors['element_name'] = __('A field with that element name already exists. Please choose another.'); } } return !empty($errors) ? self::__ERROR__ : self::__OK__; }
/** * Given an array of Entry data from `tbl_entries` and a section ID, return an * array of Entry objects. For performance reasons, it's possible to pass an array * of field handles via `$element_names`, so that only a subset of the section schema * will be queried. This function currently only supports Entry from one section at a * time. * * @param array $rows * An array of Entry data from `tbl_entries` including the Entry ID, Entry section, * the ID of the Author who created the Entry, and a Unix timestamp of creation * @param integer $section_id * The section ID of the entries in the `$rows` * @param array $element_names * Choose whether to get data from a subset of fields or all fields in a section, * by providing an array of field names. Defaults to null, which will load data * from all fields in a section. * @throws DatabaseException * @return array * An array of Entry objects */ public static function __buildEntries(array $rows, $section_id, $element_names = null) { $entries = array(); if (empty($rows)) { return $entries; } $schema = FieldManager::fetchFieldIDFromElementName($element_names, $section_id); if (is_int($schema)) { $schema = array($schema); } $raw = array(); $rows_string = ''; // Append meta data: foreach ($rows as $entry) { $raw[$entry['id']]['meta'] = $entry; $rows_string .= $entry['id'] . ','; } $rows_string = trim($rows_string, ','); // Append field data: if (is_array($schema)) { foreach ($schema as $field_id) { try { $row = Symphony::Database()->fetch("SELECT * FROM `tbl_entries_data_{$field_id}` WHERE `entry_id` IN ({$rows_string}) ORDER BY `id` ASC"); } catch (Exception $e) { // No data due to error continue; } if (!is_array($row) || empty($row)) { continue; } foreach ($row as $r) { $entry_id = $r['entry_id']; unset($r['id']); unset($r['entry_id']); if (!isset($raw[$entry_id]['fields'][$field_id])) { $raw[$entry_id]['fields'][$field_id] = $r; } else { foreach (array_keys($r) as $key) { // If this field already has been set, we need to take the existing // value and make it array, adding the current value to it as well // There is a special check incase the the field's value has been // purposely set to null in the database. if ((isset($raw[$entry_id]['fields'][$field_id][$key]) || is_null($raw[$entry_id]['fields'][$field_id][$key])) && !is_array($raw[$entry_id]['fields'][$field_id][$key])) { $raw[$entry_id]['fields'][$field_id][$key] = array($raw[$entry_id]['fields'][$field_id][$key], $r[$key]); // This key/value hasn't been set previously, so set it } elseif (!isset($raw[$entry_id]['fields'][$field_id][$key])) { $raw[$entry_id]['fields'][$field_id] = array($r[$key]); // This key has been set and it's an array, so just append // this value onto the array } else { $raw[$entry_id]['fields'][$field_id][$key][] = $r[$key]; } } } } } } // Loop over the array of entry data and convert it to an array of Entry objects foreach ($raw as $entry) { $obj = self::create(); $obj->set('id', $entry['meta']['id']); $obj->set('author_id', $entry['meta']['author_id']); $obj->set('section_id', $entry['meta']['section_id']); $obj->set('creation_date', DateTimeObj::get('c', $entry['meta']['creation_date'])); if (isset($entry['meta']['modification_date'])) { $obj->set('modification_date', DateTimeObj::get('c', $entry['meta']['modification_date'])); } else { $obj->set('modification_date', $obj->get('creation_date')); } $obj->creationDate = $obj->get('creation_date'); if (isset($entry['fields']) && is_array($entry['fields'])) { foreach ($entry['fields'] as $field_id => $data) { $obj->setData($field_id, $data); } } $entries[] = $obj; } return $entries; }
/** * Replaces variables in field data * * @param $input * * @return array */ private function sectionsReplace($input) { $output = $input; foreach ($output as $handle => &$section) { foreach ($section['entries'] as &$entry) { // skip done entries if ($entry['done'] === true) { continue; } foreach ($entry['fields'] as $f_handle => $value) { $new_value = $this->sectionsReplaceGetNewValue($value); if ($new_value === $value) { continue; } /** @var $field Field */ $f_id = FieldManager::fetchFieldIDFromElementName($f_handle, $section['id']); $field = FieldManager::fetch($f_id); // skip non-fields if (!$field instanceof Field) { continue; } // skip upload fields b/c on new uploads it gives false replacements if ($field instanceof FieldUpload) { continue; } // set data for post_back_values $entry['fields'][$f_handle] = $new_value; // set data for DB if Entry exists if ($entry['entry'] instanceof Entry) { $f_data = $field->processRawFieldData($new_value, $status, $message, false, $entry['entry']->get('id')); $entry['entry']->setData($f_id, $f_data); } } } } return $output; }
public function execute(array &$param_pool) { $result = new XMLElement($this->dsParamROOTELEMENT); $this->_param_pool = $param_pool; $where = NULL; $joins = NULL; $group = false; include_once TOOLKIT . '/class.entrymanager.php'; if (!($section = SectionManager::fetch((int) $this->getSource()))) { $about = $this->about(); trigger_error(__('The section associated with the data source %s could not be found.', array('<code>' . $about['name'] . '</code>')), E_USER_ERROR); } $sectioninfo = new XMLElement('section', General::sanitize($section->get('name')), array('id' => $section->get('id'), 'handle' => $section->get('handle'))); if ($this->_force_empty_result == true) { $this->_force_empty_result = false; //this is so the section info element doesn't disappear. $result = $this->emptyXMLSet(); $result->prependChild($sectioninfo); return; } if (is_array($this->dsParamINCLUDEDELEMENTS)) { $include_pagination_element = in_array('system:pagination', $this->dsParamINCLUDEDELEMENTS); } else { $this->dsParamINCLUDEDELEMENTS = array(); } if (isset($this->dsParamPARAMOUTPUT) && !is_array($this->dsParamPARAMOUTPUT)) { $this->dsParamPARAMOUTPUT = array($this->dsParamPARAMOUTPUT); } $this->_can_process_system_parameters = $this->canProcessSystemParameters(); if (!isset($this->dsParamPAGINATERESULTS)) { $this->dsParamPAGINATERESULTS = 'yes'; } // Process Filters $this->processFilters($where, $joins, $group); // Process Sorting if ($this->dsParamSORT == 'system:id') { EntryManager::setFetchSorting('id', $this->dsParamORDER); } else { if ($this->dsParamSORT == 'system:date') { EntryManager::setFetchSorting('date', $this->dsParamORDER); } else { EntryManager::setFetchSorting(FieldManager::fetchFieldIDFromElementName($this->dsParamSORT, $this->getSource()), $this->dsParamORDER); } } // combine `INCLUDEDELEMENTS`, `PARAMOUTPUT` and `GROUP` into an // array of field handles to optimise the `EntryManager` queries $datasource_schema = $this->dsParamINCLUDEDELEMENTS; if (is_array($this->dsParamPARAMOUTPUT)) { $datasource_schema = array_merge($datasource_schema, $this->dsParamPARAMOUTPUT); } if ($this->dsParamGROUP) { $datasource_schema[] = FieldManager::fetchHandleFromID($this->dsParamGROUP); } $entries = EntryManager::fetchByPage($this->dsParamPAGINATERESULTS == 'yes' && $this->dsParamSTARTPAGE > 0 ? $this->dsParamSTARTPAGE : 1, $this->getSource(), $this->dsParamPAGINATERESULTS == 'yes' && $this->dsParamLIMIT >= 0 ? $this->dsParamLIMIT : NULL, $where, $joins, $group, !$include_pagination_element ? true : false, true, array_unique($datasource_schema)); /** * Immediately after building entries allow modification of the Data Source entry list * * @delegate DataSourceEntriesBuilt * @param string $context * '/frontend/' * @param Datasource $datasource * @param array $entries * @param array $filters */ Symphony::ExtensionManager()->notifyMembers('DataSourceEntriesBuilt', '/frontend/', array('datasource' => &$this, 'entries' => &$entries, 'filters' => $this->dsParamFILTERS)); if (($entries['total-entries'] <= 0 || $include_pagination_element === true) && (!is_array($entries['records']) || empty($entries['records'])) || $this->dsParamSTARTPAGE == '0') { if ($this->dsParamREDIRECTONEMPTY == 'yes') { throw new FrontendPageNotFoundException(); } $this->_force_empty_result = false; $result = $this->emptyXMLSet(); $result->prependChild($sectioninfo); if ($include_pagination_element) { $pagination_element = General::buildPaginationElement(); if ($pagination_element instanceof XMLElement && $result instanceof XMLElement) { $result->prependChild($pagination_element); } } } else { if (!$this->_param_output_only) { $result->appendChild($sectioninfo); if ($include_pagination_element) { $t = $this->dsParamPAGINATERESULTS == 'yes' && isset($this->dsParamLIMIT) && $this->dsParamLIMIT >= 0 ? $this->dsParamLIMIT : $entries['total-entries']; $pagination_element = General::buildPaginationElement($entries['total-entries'], $entries['total-pages'], $t, $this->dsParamPAGINATERESULTS == 'yes' && $this->dsParamSTARTPAGE > 0 ? $this->dsParamSTARTPAGE : 1); if ($pagination_element instanceof XMLElement && $result instanceof XMLElement) { $result->prependChild($pagination_element); } } } // If this datasource has a Limit greater than 0 or the Limit is not set if (!isset($this->dsParamLIMIT) || $this->dsParamLIMIT > 0) { if (!isset($this->dsParamASSOCIATEDENTRYCOUNTS) || $this->dsParamASSOCIATEDENTRYCOUNTS == 'yes') { $this->_associated_sections = $section->fetchAssociatedSections(); } // If the datasource require's GROUPING if (isset($this->dsParamGROUP)) { self::$_fieldPool[$this->dsParamGROUP] =& FieldManager::fetch($this->dsParamGROUP); $groups = self::$_fieldPool[$this->dsParamGROUP]->groupRecords($entries['records']); foreach ($groups as $element => $group) { foreach ($group as $g) { $result->appendChild($this->processRecordGroup($element, $g)); } } } else { if (isset($entries['records'][0])) { $data = $entries['records'][0]->getData(); $pool = FieldManager::fetch(array_keys($data)); self::$_fieldPool += $pool; } foreach ($entries['records'] as $entry) { $xEntry = $this->processEntry($entry); if ($xEntry instanceof XMLElement) { $result->appendChild($xEntry); } } } } } $param_pool = $this->_param_pool; return $result; }
/** * Parse the indexable content for an entry * * @param int $entry * @param int $section */ public function indexEntry($entry, $section, $check_filters = TRUE) { self::assert(); if (is_object($entry)) { $entry = $entry->get('id'); } if (is_object($section)) { $section = $section->get('id'); } // get a list of sections that have indexing enabled $indexed_sections = self::getIndexes(); // go no further if this section isn't being indexed if (!isset($indexed_sections[$section])) { return; } // delete existing index for this entry self::deleteIndexByEntry($entry); // get the current section index config $section_index = $indexed_sections[$section]; // only pass entries through filters if we need to. If entry is being sent // from the Re-Index AJAX it has already gone through filtering, so no need here if ($check_filters === TRUE) { if (self::$_where == NULL || self::$_joins == NULL) { // modified from class.datasource.php // create filters and build SQL required for each if (is_array($section_index['filters']) && !empty($section_index['filters'])) { foreach ($section_index['filters'] as $field_id => $filter) { if (is_array($filter) && empty($filter) || trim($filter) == '') { continue; } if (!is_array($filter)) { $filter_type = DataSource::__determineFilterType($filter); $value = preg_split('/' . ($filter_type == DS_FILTER_AND ? '\\+' : ',') . '\\s*/', $filter, -1, PREG_SPLIT_NO_EMPTY); $value = array_map('trim', $value); } else { $value = $filter; } $field = self::$_entry_manager->fieldManager->fetch($field_id); $field->buildDSRetrivalSQL($value, $joins, $where, $filter_type == DS_FILTER_AND ? TRUE : FALSE); } } self::$_where = $where; self::$_joins = $joins; } // run entry though filters $entry_prefilter = self::$_entry_manager->fetch($entry, $section, 1, 0, self::$_where, self::$_joins, FALSE, FALSE); // if no entry found, it didn't pass the pre-filtering if (empty($entry_prefilter)) { return; } // if entry passes filtering, pass entry_id as a DS filter to the EntryXMLDataSource DS $entry = reset($entry_prefilter); $entry = $entry['id']; } if (!is_array($entry)) { $entry = array($entry); } // create a DS and filter on System ID of the current entry to build the entry's XML #$ds = new EntryXMLDataSource(Administration::instance(), NULL, FALSE); self::$_entry_xml_datasource->dsParamINCLUDEDELEMENTS = $indexed_sections[$section]['fields']; self::$_entry_xml_datasource->dsParamFILTERS['id'] = implode(',', $entry); self::$_entry_xml_datasource->dsSource = (string) $section; $param_pool = array(); $entry_xml = self::$_entry_xml_datasource->grab($param_pool); require_once TOOLKIT . '/class.xsltprocess.php'; $xml = simplexml_load_string($entry_xml->generate()); /* MULTILANGUAGE SUPPORT: */ require_once TOOLKIT . '/class.extensionmanager.php'; require_once TOOLKIT . '/class.fieldmanager.php'; $fieldManager = new FieldManager($this); $extensionManager = new ExtensionManager($this); $status = $extensionManager->fetchStatus('multilanguage'); $multilingualFields = array(); $languages = array(); if ($status == EXTENSION_ENABLED) { // Check if this section has multilingual fields: $results = Symphony::Database()->fetch('SELECT `element_name` FROM `tbl_fields` WHERE `parent_section` = ' . $section . ' AND `multilanguage` = 1;'); foreach ($results as $result) { $multilingualFields[] = $result['element_name']; } $languages = explode(',', file_get_contents(MANIFEST . '/multilanguage-languages')); } foreach ($xml->xpath("//entry") as $entry_xml) { // get text value of the entry (default behaviour) $proc = new XsltProcess(); $data = $proc->process($entry_xml->asXML(), file_get_contents(EXTENSIONS . '/search_index/lib/parse-entry.xsl')); $dataLanguages = array(); foreach ($languages as $language) { foreach ($entry_xml->children() as $child) { $name = $child->getName(); if (in_array($name, $multilingualFields)) { // Bingo! // Get the correct value for this item: $field_id = $fieldManager->fetchFieldIDFromElementName($name); $entry_id = $entry_xml->attributes()->id; $values = Symphony::Database()->fetch('SELECT * FROM `tbl_multilanguage_values` WHERE `id_entry` = ' . $entry_id . ' AND `id_field` = ' . $field_id . ' AND `language` = \'' . $language . '\';'); if (count($values) >= 1) { // Value found: foreach ($values as $value) { switch ($value['field_name']) { case 'value': $entry_xml->{$name} = $value['value']; break; } } } } } // Store it: $proc = new XsltProcess(); $dataLanguages[$language] = $proc->process($entry_xml->asXML(), file_get_contents(EXTENSIONS . '/search_index/lib/parse-entry.xsl')); } self::saveEntryIndex((int) $entry_xml->attributes()->id, $section, $data, $dataLanguages); /* END MULTILANGUAGE SUPPORT */ } }
private function __fetchFields($section, $context, $subsection, $field, $mode = '') { // Section context if ($section !== 0) { $section = " AND t2.`parent_section` = '" . intval($section) . "' "; } else { $section = ''; } $subsection = Symphony::Database()->cleanValue($subsection); // Get id $id = Symphony::Database()->fetch("(SELECT t1.`subsection_id`, t1.field_id\n\t\t\t\t\tFROM `tbl_fields_subsectionmanager` AS t1\n\t\t\t\t\tINNER JOIN `tbl_fields` AS t2\n\t\t\t\t\tWHERE t2.`element_name` = '{$subsection}'\n\t\t\t\t\t{$section}\n\t\t\t\t\tAND t1.`field_id` = t2.`id`\n\t\t\t\t\tLIMIT 1)"); // Get subfield id $subfield_id = FieldManager::fetchFieldIDFromElementName($field, $id[0]['subsection_id']); // Store field data $field_id = $id[0]['field_id']; if (!is_array(self::$storage['fields'][$context][$field_id][$subfield_id])) { self::storeSubsectionFields($context, $field_id, $subfield_id, $mode); } return $id[0]['subsection_id']; }
$invoiceID = $transaction->getInvoiceNumber(); $invoice = current(EntryManager::fetch($invoiceID)); $sectionID = $invoice->get('section_id'); $fieldID = FieldManager::fetchFieldIDFromElementName('status', $sectionID); $invoice->setData($fieldID, array('value' => $state, 'handle' => General::createHandle($state))); $invoice->commit(); $itemFieldID = FieldManager::fetchFieldIDFromElementName('item', $sectionID); if (in_array("JCI Malta Membership", $invoice->getData($itemFieldID)['description'])) { //user paid for a membership kindly convert user to a member $memberFieldID = FieldManager::fetchFieldIDFromElementName('member', $sectionID); $memberID = $invoice->getData($memberFieldID)['relation_id']; $member = current(EntryManager::fetch($memberID)); $roleFieldID = FieldManager::fetchFieldIDFromElementName('role', $member->get('section_id')); $member->setData($roleFieldID, array('role_id' => 2)); $member->commit(); $emailID = FieldManager::fetchFieldIDFromElementName('email', $member->get('section_id')); $email = $member->getData($emailID)['value']; $member = ExtensionManager::getInstance('members')->getMemberDriver()->login(array('email' => $email)); } header('Location: ' . URL . '/register/?thankyou=1', true, 302); exit; var_dump($invoice->getData($itemFieldID)['description']); // if item contains membership change the role of the user to a member. echo $state; } catch (Exception $ex) { //getting payment var_dump($ex); die; } } catch (Exception $ex) { //executing payment