Retrieve an array of key/value pairs for gsu_id_survey and gsu_survey_name
that are active and are insertable

@param int $organizationId Optional organization id
@return array
508151
public function getInsertableSurveys($organizationId = null)
    {
        $cacheId = __CLASS__ . '_' . __FUNCTION__ . '_' . $organizationId;

        if ($results = $this->cache->load($cacheId)) {
            return $results;
        }

        if (null === $organizationId) {
            $orgWhere = '';
        } else {
            $orgId    = intval($organizationId);
            $orgWhere = "AND gsu_insert_organizations LIKE '%|$orgId|%'";
        }
        $select = "SELECT gsu_id_survey, gsu_survey_name
            FROM gems__surveys
            WHERE gsu_active = 1 AND gsu_insertable = 1 $orgWhere
            ORDER BY gsu_survey_name";

        $results = $this->db->fetchPairs($select);
        $this->cache->save($results, $cacheId, array('surveys'));
        return $results;
    }
1298442
public function createFork(string $organization = ''): array
    {
        return $this->getApi()->request($this->getApi()->sprintf('/repos/:owner/:repo/forks',
            $this->getRepositories()->getOwner(), $this->getRepositories()->getRepo()), Request::METHOD_POST,
            ['organization' => $organization]);
    }
259945
public function getOrganization($id, array $params = array())
    {
        return $this->get($this->getPath().'/'.rawurlencode($id).'/organization', $params);
    }
1285841
protected function getJunctionKeys($id): array
	{
		$ids = [];

		foreach((is_array($id) ? $id : [$id]) as $value)
		{
			if($value instanceof $this->model)
			{
				$value = $value->getPrimaryKeyValue();
			}

			$ids[] = $value;
		}

		return $ids;
	}
1373089
public function allBySubjectKeyIdentifier(string $id): array
    {
        $map = $this->_getKeyIdMap();
        if (!isset($map[$id])) {
            return array();
        }
        return $map[$id];
    }
254998
public function getSurveysFor($organizationId)
    {
        if ($organizationId !== null) {
            $where = "AND EXISTS (SELECT 1 FROM gems__rounds
                INNER JOIN gems__tracks ON gro_id_track = gtr_id_track
                WHERE gro_id_survey = gsu_id_survey AND
                gtr_organizations LIKE '%|" . (int) $organizationId . "|%')";
        } else {
            $where = "";
        }

        $sql = "SELECT gsu_id_survey, gsu_survey_name FROM gems__surveys WHERE gsu_active = 1 " .
            $where . " ORDER BY gsu_survey_name ASC";

        return $this->_getSelectPairsCached(__FUNCTION__. '_' . $organizationId, $sql, array(), 'surveys');
    }
778690
public function findOrganizationMenu($organizationId, $menuId)
    {
        list($response) = $this->findOrganizationMenuWithHttpInfo($organizationId, $menuId);
        return $response;
    }
36922
public Organization getOrganization(long id) {
        return complete(submit(req("GET", tmpl("/organizations/{id}.json").set("id", id)),
                handle(Organization.class, "organization")));
    }
359993
public function getGroup($groupId)
    {
        static $groups = array();

        if (! isset($groups[$groupId])) {
            $groups[$groupId] = $this->_loadClass('Group', true, array($groupId));
    }

        return $groups[$groupId];
    }
1322837
public function getIndexes( $oid )
    {

        // load primary keys
        $query = new Query(
            "SELECT string_to_array( indkey::text, ' ') AS keys, * FROM pg_index WHERE indrelid = %oid:int%",
            array( 'oid' => $this->get('oid') )
        );

        $indexes = $this->db->query( $query )->fetch(Result::TYPE_DETECT);

        foreach( $this->indexes as &$index ) {

            $index['columns'] = array();

            foreach( $index['keys'] as $columnIndex ) {
                $index['columns'][] = sprintf(
                    '%s.%s',
                    $oid,
                    $columnIndex
                );
            }

        }

        return $indexes;

    }
301696
public function getAggregateActualResponses($key = null, $operationId = null, $types = ['headers', 'body'])
    {
        if ($this->valid && isset($this->aggregateActualResponses)) {
            if (null !== $key) {
                foreach ($types as $type) {
                    if (null !== $operationId) {
                        if (isset($this->aggregateActualResponses[$operationId][$type][$key])) {
                            return $this->aggregateActualResponses[$operationId][$type][$key];
                        }
                    } else {
                        foreach (array_reverse($this->aggregateActualResponses) as $values) {
                            if (isset($values[$type][$key])) {
                                return $values[$type][$key];
                            }
                        }
                    }
                }
            } else {
                // Get the entire result, separated by types.
                $result = [];
                foreach ($types as $type) {
                    if (isset($this->aggregateActualResponses[$operationId][$type])) {
                        $result[$type] = $this->aggregateActualResponses[$operationId][$type];
                    }
                }

                return $result;
            }
        }

        return null;
    }
439217
public function nextVenues($venueId)
    {

        $resource = '/venues/' . $venueId . '/nextvenues';
        $response = $this->makeApiRequest($resource);

        if(property_exists($response, 'nextVenues')) {
            return $response->nextVenues->items;
        }

        return array();

    }
916535
public function getOrganizationFileData($organizationId, $fileId)
    {
        list($response) = $this->getOrganizationFileDataWithHttpInfo($organizationId, $fileId);
        return $response;
    }
215231
public function getUserGroups(string $userId = ''): array
    {
        // if not specified, get current user's id
        if (empty($userId)) {
            $userId = $this->Auth->user('id');
        }

        $groups = TableRegistry::get('Groups.Groups');

        $query = $groups->find('list', [
            'keyField' => 'id',
            'valueField' => 'name'
        ]);
        $query->matching('Users', function ($q) use ($userId) {
            return $q->where(['Users.id' => $userId]);
        });

        return $query->toArray();
    }
1306335
public function getTopOrganizations()
    {
        try {
            $organizations = $this->db->fetchPairs('SELECT gor_id_organization, gor_name FROM gems__organizations WHERE gor_active=1 AND gor_has_login=1 AND (gor_accessible_by IS NULL OR gor_accessible_by = "::") ORDER BY gor_name');
        } catch (\Exception $e) {
            try {
                // 1.4 fallback
                $organizations = $this->db->fetchPairs('SELECT gor_id_organization, gor_name FROM gems__organizations WHERE gor_active=1 AND gor_accessible_by IS NULL ORDER BY gor_name');
            } catch (\Exception $e) {
                $organizations = array();
            }
        }

        natsort($organizations);

        return $organizations;
    }
435279
public function get(string $org): array
    {
        return $this->getApi()->request($this->getApi()->sprintf('/orgs/:org', $org));
    }
1074546
public function getRespondentOrganizations()
    {

        if (! $this->_hasVar('__allowedRespOrgs')) {
            $availableOrganizations = $this->util->getDbLookup()->getOrganizationsWithRespondents();
            $allowedOrganizations   = $this->getAllowedOrganizations();

            $this->_setVar('__allowedRespOrgs', array_intersect($availableOrganizations, $allowedOrganizations));
        }
        // \MUtil_Echo::track($this->_getVar('__allowedOrgs'));

        return $this->_getVar('__allowedRespOrgs');
    }