Converts the METADATA extension entry name into the correct
entry-attrib names for older ANNOTATEMORE version.

@param string $entry Entry name

@return array Entry-attribute list, NULL if not supported (?)
437154
protected function md2annotate($entry)
    {
        if (substr($entry, 0, 7) == '/shared') {
            return array(substr($entry, 7), 'value.shared');
        }
        else if (substr($entry, 0, 8) == '/private') {
            return array(substr($entry, 8), 'value.priv');
        }

        // @TODO: log error
    }
288528
public function clean(array $entry)
	{
		$entry['id'] = $entry['dn'];
		$entry['remember_token'] = $entry['dn'];
		$entry['username'] = $entry['samaccountname'][0];

		// Default user type (ACL: 0 = admin, 1 = user)
		$entry['type'] = 1;
		$entry['group'] = '';

		// Group based view access check
		if(count($this->config['groups']) > 0)
		{
			$entry['type'] = NULL;
		}

		foreach ($this->config['groups'] as $group) 
		{
			$cn = 'CN='.$group.','.$this->config['groupdn'];
			if (isset($entry['dn']) 
				&& $this->checkGroup($entry['dn'], $cn))
			{
				$entry['type'] = 1;
				$entry['group'] = $group;
			}
		}
		
		// Admin Group Check
		foreach ($this->config['admin_groups'] as $group) 
		{
			$cn = 'CN='.$group.','.$this->config['groupdn'];
			if (isset($entry['dn']) 
				&& $this->checkGroup($entry['dn'], $cn))
			{
				$entry['type'] = 0;
				$entry['group'] = $group;
			}
		}

		// Admin/Owner Check (individual user owner/admins)
		foreach ($this->config['owners'] as $owner) 
		{
			if (isset($entry['samaccountname']) 
				&& $entry['samaccountname'][0] == $owner)
			{
				$entry['type'] = 0;
				$entry['group'] = '';
			}
		}

		// If View Groups exist and User is not in group
		if($entry['type'] === NULL)
			return NULL;

		$this->model = new GenericUser( $entry );

		return $this->model;
	}
816551
protected function castLoadedEntry(array $entry)
    {
        $entry['valid_until'] = (int)$entry['valid_until'];
        $entry['outside'] = (int)$entry['outside'];
        $entry['plain'] = (int)$entry['plain'];

        if ((bool)$entry['outside']) {
            return $entry;
        }

        if (!(bool)$entry['plain']) {
            $entry['payload'] = $this->serializer->deserialize($entry['payload']);
            $entry['plain'] = 1;
        }

        return $entry;
    }
316621
protected function get_fields_for_entries($entry) {
        global $DB;

        $indexfields = array();
        $validfieldtypes = array('text', 'textarea', 'menu', 'radiobutton', 'checkbox', 'multimenu', 'url');

        $sql = "SELECT dc.*, df.name AS fldname,
                       df.type AS fieldtype, df.required
                  FROM {data_content} dc, {data_fields} df
                 WHERE dc.fieldid = df.id
                       AND dc.recordid = :recordid";

        $contents = $DB->get_records_sql($sql, array('recordid' => $entry->id));
        $filteredcontents = array();

        $template = $DB->get_record_sql('SELECT addtemplate FROM {data} WHERE id = ?', array($entry->dataid));
        $template = $template->addtemplate;

        // Filtering out the data_content records having invalid fieldtypes.
        foreach ($contents as $content) {
            if (in_array($content->fieldtype, $validfieldtypes)) {
                $filteredcontents[] = $content;
            }
        }

        foreach ($filteredcontents as $content) {
            $classname = $this->get_field_class_name($content->fieldtype);
            $content->priority = $classname::get_priority();
            $content->addtemplateposition = strpos($template, '[['.$content->fldname.']]');
        }

        $orderqueue = new \SPLPriorityQueue();

        // Filtering out contents which belong to fields that aren't present in the addtemplate of the database activity instance.
        foreach ($filteredcontents as $content) {

            if ($content->addtemplateposition >= 0) {
                $orderqueue->insert($content, $content->addtemplateposition);
            }
        }

        $filteredcontents = array();

        while ($orderqueue->valid()) {
            $filteredcontents[] = $orderqueue->extract();
        }

        // SPLPriorityQueue sorts according to descending order of the priority (here, addtemplateposition).
        $filteredcontents = array_reverse($filteredcontents);

        // Using a CUSTOM SPLPriorityQueure instance to sort out the filtered contents according to these rules :
        // 1. Priorities in $fieldtypepriorities
        // 2. Compulsory fieldtypes are to be given the top priority.
        $contentqueue = new sortedcontentqueue($filteredcontents);

        foreach ($filteredcontents as $key => $content) {
            $contentqueue->insert($content, $key);
        }

        while ($contentqueue->valid()) {

            $content = $contentqueue->extract();
            $classname = $this->get_field_class_name($content->fieldtype);
            $indexfields[] = $classname::get_content_value($content);
        }

        // Limited to 4 fields as a document only has 4 content fields.
        if (count($indexfields) > 4) {
            $indexfields[3] = implode(' ', array_slice($indexfields, 3));
        }
        return $indexfields;
    }
240092
public function fromProtoBuf($entries)
    {
        $values = [];

        foreach ($entries as $entry) {
            $field = $entry->getField();
            $name  = $field->getName();
            $value = $this->convertMapEntry($entry);

            $values[$name] = $value;
        }

        return $values;
    }
1275444
protected function writeReferences(array $entry)
    {
        $result = '';

        if (count($entry['references']) > 0) {
            foreach ($entry['references'] as $ref) {
                $result .= '#: ' . $ref . "\n";
            }
        }

        return $result;
    }
921526
public static function edit(Entry $entry)
    {
        // Update modification date and modification author.
        Symphony::Database()->update(
            array(
                'modification_author_id' => $entry->get('modification_author_id'),
                'modification_date' => $entry->get('modification_date'),
                'modification_date_gmt' => $entry->get('modification_date_gmt')
            ),
            'tbl_entries',
            sprintf(' `id` = %d', (int)$entry->get('id'))
        );

        // Iterate over all data for this entry
        foreach ($entry->getData() as $field_id => $field) {
            // Write data
            static::saveFieldData($entry->get('id'), $field_id, $field);
        }

        return true;
    }
171973
public function getResource(string $name, string $entry = null)
    {
        return $this->get('resources', $name, $entry);
    }
269297
public function unserializeEntry($Entry)
    {
        if (!$Entry || !is_string($Entry) || !preg_match('~^a\:\d+\:\{.*\}$~', $Entry)) {
            return $Entry;
        }
        $Arr = unserialize($Entry);
        if (is_array($Arr)) {
            $this->clearExpired($Arr);
            return $Arr;
        }
        return $Entry;
    }
850486
public function getEntry($Entry)
    {
        if ($this->Using === 'APCu') {
            return $this->unserializeEntry(apcu_fetch($Entry));
        }
        if ($this->Using === 'Memcached' || $this->Using === 'Redis') {
            return $this->unserializeEntry($this->WorkingData->get($Entry));
        }
        if ($this->Using === 'PDO') {
            if ($this->clearExpiredPDO()) {
                $this->Modified = true;
            }
            $PDO = $this->WorkingData->prepare(self::getQuery);
            if ($PDO !== false && $PDO->execute(['key' => $Entry])) {
                $Data = $PDO->fetch(\PDO::FETCH_ASSOC);
                return isset($Data['Data']) ? $this->unserializeEntry($Data['Data']) : false;
            }
            return false;
        }
        if (is_array($this->WorkingData) && isset($this->WorkingData[$Entry])) {
            if (isset($this->WorkingData[$Entry]['Data']) && !empty($this->WorkingData[$Entry]['Time'])) {
                if ($this->WorkingData[$Entry]['Time'] <= 0 || $this->WorkingData[$Entry]['Time'] > time()) {
                    return $this->unserializeEntry($this->WorkingData[$Entry]['Data']);
                }
                unset($this->WorkingData[$Entry]);
                $this->Modified = true;
                return false;
            }
            return $this->unserializeEntry($this->WorkingData[$Entry]);
        }
        return false;
    }
1011135
protected function updateTags($entry)
    {
        if (! empty($entry->tagsChanges['added'])) {
            $this->table('telescope_entries_tags')->insert(
                collect($entry->tagsChanges['added'])->map(function ($tag) use ($entry) {
                    return [
                        'entry_uuid' => $entry->uuid,
                        'tag' => $tag,
                    ];
                })->toArray()
            );
        }

        collect($entry->tagsChanges['removed'])->each(function ($tag) use ($entry) {
            $this->table('telescope_entries_tags')->where([
                'entry_uuid' => $entry->uuid,
                'tag' => $tag,
            ])->delete();
        });
    }
53668
public function add_entry_or_merge($entry)
    {
        if (is_array($entry)) {
            $entry = new EntryTranslations($entry);
        }
        $key = $entry->key();
        if (false === $key) {
            return false;
        }
        if (isset($this->entries[$key])) {
            $this->entries[$key]->merge_with($entry);
        } else {
            $this->entries[$key] = &$entry;
        }

        return true;
    }
612101
public function createKeyFromEntry(PoEntry $entry): string
    {
        return $this->createKey(
            $entry->getAsString(PoTokens::MESSAGE),
            $entry->getAsString(PoTokens::CONTEXT),
            $entry->getAsString(PoTokens::PLURAL)
        );
    }
751138
protected function validateFactoryEntry($entry)
    {
        if (!is_string($entry) && !is_callable($entry) && !$entry instanceof FactoryInterface) {
            $type = is_object($entry) ? get_class($entry) : gettype($entry);
            $message = sprintf('Argument "entry" in "%s" must be a string, a callable or an instance '
                    . 'of "%s"; "%s" was given.', __METHOD__, FactoryInterface::class, $type);
            throw new Exception\InvalidArgumentException($message);
        }

        if (is_string($entry)) {
            if (!class_exists($entry)) {
                throw new Exception\ClassNotFoundException($entry);
            }

            if (!is_subclass_of($entry, FactoryInterface::class)) {
                $message = sprintf('Entry "%s" in "%s" is expected to be an instance of "%s".', $entry, __METHOD__, FactoryInterface::class);
                throw new Exception\InvalidArgumentException($message);
            }
        }
    }
459874
public function characteristicsCreateItemIndex($entry) {
    $insert = $this->connection->insert('site_commerce_characteristics_item_index')->fields($entry);
    return $insert->execute();
  }
165528
public function getValuesLen($entry, $attribute)
    {
        if ($this->suppressErrors) {
            return @ldap_get_values_len($this->getConnection(), $entry, $attribute);
        }

        return ldap_get_values_len($this->getConnection(), $entry, $attribute);
    }
702499
public function resolveEntryNameByContext($entryName, $context = null)
    {
        $resolvers = clone $this->resolvers;

        $result = null;
        foreach ($resolvers as $resolverItem) {
            /** @var EntryNameResolverInterface $resolver */
            $resolver = $resolverItem['instance'];
            $result = $resolver->resolveEntryNameByContext($entryName, $context);
            if (null !== $result) {
                break;
            }
        }

        return $result;
    }