Decode a multienum from Sugar

@param string $multiselect MultiEnum from DB

@return array Multienum as Array
169753
public function multiselectToArray($values)
    {
        // Unencode
        $values = unencodeMultienum($values);

        // First clean the array
        foreach ($values as $k => $v) {
            if (empty($v)) {
                unset($values[$k]);
            }
        }

        // Then return the array
        return $values;
    }
158956
protected function parseLimit(SQLSelect $query)
    {
        $limit = '';
        $offset = '0';
        if (is_array($query->getLimit())) {
            $limitArr = $query->getLimit();
            if (isset($limitArr['limit'])) {
                $limit = $limitArr['limit'];
            }
            if (isset($limitArr['start'])) {
                $offset = $limitArr['start'];
            }
        } elseif (preg_match('/^([0-9]+) offset ([0-9]+)$/i', trim($query->getLimit()), $matches)) {
            $limit = $matches[1];
            $offset = $matches[2];
        } else {
            //could be a comma delimited string
            $bits = explode(',', $query->getLimit());
            if (sizeof($bits) > 1) {
                list($offset, $limit) = $bits;
            } else {
                $limit = $bits[0];
            }
        }
        return array($limit, $offset);
    }
282870
public function decode($query): array
    {
        foreach (explode("&", $query) as $keyValuePair) {
            list($key, $value) = $this->decodePair($keyValuePair);
            $this->values->addValue($key, $value);
        }
        return $this->values->getValues();
    }
799034
public static function enum()
    {
      $result = array();
      $r = self::getDbConnection()->executeQuery('SELECT * FROM dir_data A WHERE is_server<>0 ORDER BY tag');
      while($fields = $r->fetch()) {
          $result[] = self::fetch($fields);
      }      

      return $result;
    }
1104937
private void decodeSelection(final FacesContext context, final Sheet sheet, final String jsonSelection) {
        if (LangUtils.isValueBlank(jsonSelection)) {
            return;
        }

        try {
            // data comes in: [ [row, col, oldValue, newValue] ... ]
            final JSONArray array = new JSONArray(jsonSelection);
            sheet.setSelectedRow(array.getInt(0));
            sheet.setSelectedColumn(sheet.getMappedColumn(array.getInt(1)));
            sheet.setSelectedLastRow(array.getInt(2));
            sheet.setSelectedLastColumn(array.getInt(3));
            sheet.setSelection(jsonSelection);
        }
        catch (final JSONException e) {
            throw new FacesException("Failed parsing Ajax JSON message for cell selection event:" + e.getMessage(), e);
        }
    }
870288
public function select(array $select = ['*'])
    {
        if (count($select) == 0) {
            return $this;
        }

        if (count($select) == 1 && $select[0] == '*') {
            $this->select = '*';
        } else {
            $this->select = '`' . implode('`, `', $select) . '`';
        }

        return $this;
    }
750312
private function buildSelect()
	{
		$selects = [];

		foreach ($this->select as $select)
		{
			$string = ($select['count']) ? "COUNT({$select['column']})" : $select['column'];

			// See if we're including an alias
			if (isset($select['as']))
			{
				$string .= " AS {$select['as']}";
			}

			// @FIXME: not quoting name here because we could have a function here as well
			// $selects[] = $this->connection->quoteName($string, $select['as']);
			$selects[] = $string;
		}

		return 'SELECT ' . implode(',', $selects);
	}
223455
public function decode_uhex($s)
	{
		preg_match_all('/\\\u([0-9a-f]{4})/i', $s, $matches);
		$matches = $matches[count($matches) - 1];
		$map = array();

		foreach ($matches as $match)
		{
			if (!isset($map[$match]))
			{
				$map['\u' . $match] = html_entity_decode('&#' . hexdec($match) . ';', ENT_NOQUOTES, 'UTF-8');
			}
		}

		return str_replace(array_keys($map), $map, $s);
	}
18143
function decodeBER($encoded)
    {
        if (is_object($encoded) && strtolower(get_class($encoded)) == 'file_asn1_element') {
            $encoded = $encoded->element;
        }

        $this->encoded = $encoded;
        // encapsulate in an array for BC with the old decodeBER
        return array($this->_decode_ber($encoded));
    }
930755
public function decode(string $data, string $contentType): array
    {
        if (isset($this->decoderTypes[$contentType])) {
            return $this->decoderTypes[$contentType]->decode($data);
        }

        throw DeserializerLogicException::createMissingContentType($contentType);
    }
59218
private function parseSelectQuery()
    {
        // Parse select ?
        $selectSql = Column::generateQueryString($this->query->select);

        // Parse table
        $fromSql = Table::generateQueryString($this->query->table);

        $whereSql = null;
        $whereBind = array();


        $sql = [
            'select' => $selectSql,
            'from' => $fromSql,
            'where' => $whereSql
            // TODO: Add other parts.
        ];

        $this->bind = array_merge(
            $this->bind,
            $whereBind
        );

        $this->sql = $this->combineSelectQuery($sql);
    }
49443
public function serialize(EntityContract $entity, Collection $select = null)
    {
        $bag = parent::serialize($entity, $select);
        $bag->set('url', $entity->getFullUrl());
        $bag->set('media', $entity->media->count() > 0 ? $entity->media[0]->toArray() : null);

        return $bag;
    }
1136646
public function select($multiple = false)
	{
		if ( !$this->isSelected() ) {
			if ( $this->select === null ) {
				throw new SelectException(
					'No SELECT element association defined',
					SelectException::TYPE_UNBOUND_OPTION
				);
			}

			$this->select->getWrappedElement()->selectOption($this->getValue(), $multiple);
		}

		return $this;
	}
701147
public function multiselect(String $name = NULL, Array $options = [], $selected = NULL, Array $_attributes = [])
    {
        return $this->select($name, $options, $selected, $_attributes, true);
    }
81450
private function encodeMulticall(array $requests) {

        $composed_requests = [];

    	$this->logger->debug("Performing an XML multicall");

    	$this->logger->debug("Data dump before encoding", $requests);

        foreach ($requests as $request) {

            $composed_requests[] = [
                $request->getMethod(),
                $request->getParameters()
            ];

            foreach ( $request->getSpecialTypes() as $key => $value ) {
                $this->encoder->setValueType($key, $value);
            }

        }

        try {

            $encoded_requests = $this->encoder
                ->setEncoding($this->getEncoding())
                ->encodeMulticall($composed_requests);

        } catch (XmlrpcException $xe) {

            throw $xe;

        }

        $this->logger->debug("Data dump after encoding: ".$encoded_requests);

        return $encoded_requests;

    }
702790
function getForcedMods($multicall = false)
    {
        if ($multicall) {
            return $this->execute(ucfirst(__FUNCTION__), array(), function ($v) {
                $v['Mods'] = Structures\Mod::fromArrayOfArray($v['Mods']);
                return $v;
            });
        }
        $result = $this->execute(ucfirst(__FUNCTION__));
        $result['Mods'] = Structures\Mod::fromArrayOfArray($result['Mods']);
        return $result;
    }
249564
protected function processSelect($select, $context)
    {
        if ($select instanceof Aggregate) {
            $column = $this->processColumnOrSubQuery($select->column, $context);
            if ($column === $select->column) {
                return $select;
            } else {
                return new Aggregate($select->function, $column);
            }
        }

        return $this->processColumnOrSubQuery($select, $context);
    }