Retrieve attributes of an organization.

@param Organization $organization
@param array $attributeNames
@return null|array
@throws \Exception
190981
public function getAttributes(Organization $organization, $attributeNames = null)
    {
        $result = array();
        $url = self::makeAttributeUrl($organization->id, $attributeNames);
        $data = $this->service->prepAndSend($url, array(200, 204), 'GET', null, true);
        $jsonObj = json_decode($data);
        if (!empty($jsonObj)) {
            $result = array();
            foreach ($jsonObj->attribute as $attr) {
                $result[] = Attribute::createFromJSON($attr);
            }
            return $result;
        } else {
            return array();
        }
    }
65284
public DbOrganization getDbOrganization(final Organization organization) {
        final DbOrganization dbOrganization = new DbOrganization();
        dbOrganization.setName(organization.getName());
        dbOrganization.getCorporateGroupIdPrefixes().addAll(organization.getCorporateGroupIdPrefixes());

        return dbOrganization;
    }
1282436
private static function buildOrganizationRoles(array $roles, OrganizationInterface $org)
    {
        $orgName = $org->getName();

        if ($org instanceof RoleableInterface) {
            $existingRoles = [];

            foreach ($roles as $role) {
                $existingRoles[] = $role;
            }

            foreach ($org->getRoles() as $orgRole) {
                $roleName = RoleUtil::formatName($orgRole);

                if (!\in_array($roleName, $existingRoles, true)) {
                    $roles[] = $roleName.'__'.$orgName;
                    $existingRoles[] = $roleName;
                }
            }
        }

        return $roles;
    }
869739
public function findWorkspacesWithMostResources($max, $organizations = null)
    {
        $qb = $this
            ->createQueryBuilder('ws')
            ->select('ws.name, ws.code, COUNT(rs.id) AS total')
            ->leftJoin('Claroline\CoreBundle\Entity\Resource\ResourceNode', 'rs', 'WITH', 'ws = rs.workspace')
            ->groupBy('ws.id')
            ->orderBy('total', 'DESC');

        if (null !== $organizations) {
            $qb->leftJoin('ws.organizations', 'orgas')
                ->andWhere('orgas IN (:organizations)')
                ->setParameter('organizations', $organizations);
        }

        if ($max > 1) {
            $qb->setMaxResults($max);
        }

        return $qb->getQuery()->getResult();
    }
239216
public function countByType($organizations = null)
    {
        $qb = $this->createQueryBuilder('wi')
            ->select('wi.id, w.name, COUNT(w.id) AS total, SUM(CASE WHEN wi.isDesktop = TRUE THEN 1 ELSE 0 END) AS totalByDesktop, SUM(CASE WHEN wi.isDesktop = FALSE THEN 1 ELSE 0 END) AS totalByWorkspace')
            ->leftJoin('wi.widget', 'w')
            ->groupBy('w.id')
            ->orderBy('total', 'DESC');

        if (null !== $organizations) {
            $qb->leftJoin('wi.user', 'user')
                ->leftJoin('user.userOrganizationReferences', 'orgaRef')
                ->leftJoin('wi.workspace', 'ws')
                ->leftJoin('ws.organizations', 'orgas')
                ->andWhere($qb->expr()->orX('orgaRef.organization IN (:organizations)', 'orgas IN (:organizations)'))
                ->setParameter('organizations', $organizations);
        }

        return $qb->getQuery()->getResult();
    }
1147503
public function getMembership($userId, $organization = '')
    {
        $contents = $this
            ->call('GET', implode('/', [self::ORGANIZATION_RESOURCE, $this->getOrganizationName($organization), 'memberships', $userId]))
            ->getBody()
            ->getContents();

        return $this->getSingleMemberShipFromJsonResponse($contents);
    }
1208552
public function getValues(array $attribute_names = [])
    {
        $values = [];
        if (!empty($attribute_names)) {
            foreach ($attribute_names as $attribute_name) {
                $values[$attribute_name] = $this->getValue($attribute_name);
            }
        } else {
            foreach ($this->getType()->getAttributes() as $attribute) {
                $values[$attribute->getName()] = $this->getValue($attribute->getName());
            }
        }

        return $values;
    }
542217
public function findOrganizationFile($organizationId, $fileId)
    {
        list($response) = $this->findOrganizationFileWithHttpInfo($organizationId, $fileId);
        return $response;
    }
879885
public function listPublicOrganizationEvents(string $organization): array
    {
        return $this->getApi()->request($this->getApi()->sprintf('/orgs/:org/events', $organization));
    }
731195
protected static function getOrganizationRoles(OrganizationInterface $organization, $roleHierarchy = null)
    {
        $roles = [];

        if ($organization instanceof RoleableInterface && $organization instanceof OrganizationInterface) {
            $roles = self::buildOrganizationRoles([], $organization);

            if ($roleHierarchy instanceof RoleHierarchyInterface) {
                $roles = RoleUtil::formatNames($roleHierarchy->getReachableRoles($roles));
            }
        }

        return $roles;
    }
1042323
static OrganizationSettings getOrganizationSettings(OrganizationName organizationName) {
    try (SecurityCenterClient client = SecurityCenterClient.create()) {
      // Start setting up a request to get OrganizationSettings for.
      // OrganizationName organizationName = OrganizationName.of(/*organizationId=*/"123234324");
      GetOrganizationSettingsRequest.Builder request =
          GetOrganizationSettingsRequest.newBuilder()
              .setName(organizationName.toString() + "/organizationSettings");

      // Call the API.
      OrganizationSettings response = client.getOrganizationSettings(request.build());

      System.out.println("Organization Settings:");
      System.out.println(response);
      return response;
    } catch (IOException e) {
      throw new RuntimeException("Couldn't create client.", e);
    }
  }
634174
public function listOrganizationRepositories(string $organization, string $type = AbstractApi::TYPE_ALL): array
    {
        return $this->getApi()->request($this->getApi()->sprintf('/orgs/:org/repos?:args', $organization,
            http_build_query(['type' => $type])));
    }
1191675
public function parseOrganizationsNode(\DOMDocument $dom)
    {
        $organizationsList = $dom->getElementsByTagName('organizations');
        $resources = $dom->getElementsByTagName('resource');

        if ($organizationsList->length > 0) {
            $organizations = $organizationsList->item(0);
            $organization = $organizations->firstChild;

            if (!is_null($organizations->attributes)
                && !is_null($organizations->attributes->getNamedItem('default'))) {
                $defaultOrganization = $organizations->attributes->getNamedItem('default')->nodeValue;
            } else {
                $defaultOrganization = null;
            }
            // No default organization is defined
            if (is_null($defaultOrganization)) {
                while (!is_null($organization)
                    && 'organization' !== $organization->nodeName) {
                    $organization = $organization->nextSibling;
                }

                if (is_null($organization)) {
                    return $this->parseResourceNodes($resources);
                }
            }
            // A default organization is defined
            // Look for it
            else {
                while (!is_null($organization)
                    && ('organization' !== $organization->nodeName
                        || is_null($organization->attributes->getNamedItem('identifier'))
                        || $organization->attributes->getNamedItem('identifier')->nodeValue !== $defaultOrganization)) {
                    $organization = $organization->nextSibling;
                }

                if (is_null($organization)) {
                    throw new InvalidScormArchiveException('default_organization_not_found_message');
                }
            }

            return $this->parseItemNodes($organization, $resources);
        } else {
            throw new InvalidScormArchiveException('no_organization_found_message');
        }
    }
191393
private function _getJoins( array $attributes, $prefix )
	{
		$iface = 'MW_Common_Criteria_Attribute_Interface';
		$sep = $this->_getKeySeparator();
		$name = $prefix . $sep . 'id';

		if( isset( $attributes[$name] ) && $attributes[$name] instanceof $iface ) {
			return $attributes[$name]->getInternalDeps();
		}
		else if( isset( $attributes['id'] ) && $attributes['id'] instanceof $iface ) {
			return $attributes['id']->getInternalDeps();
		}

		return array();
	}
59735
public function getOrganizationElement()
    {
        $element   = $this->getElement($this->organizationFieldName);
        $orgId     = $this->getCurrentOrganizationId();
        $parentId  = $this->getParentId();
        $childOrgs = $this->getChildOrganizations($parentId);

        if (!empty($childOrgs)) {
            if (count($childOrgs) == 1) {
                $element = new \Zend_Form_Element_Hidden($this->organizationFieldName);
                $this->addElement($element);

                if (! $this->_organizationFromUrl) {
                    $orgIds = array_keys($childOrgs);
                    $orgId  = reset($orgIds);
                }

                $element->setValue($orgId);
                $this->getRequest()->setPost($this->organizationFieldName, $orgId);

            } else {
                $element = new \Zend_Form_Element_Select($this->organizationFieldName);
                $element->setLabel($this->childOrganizationDescription);
                $element->setRegisterInArrayValidator(true);
                $element->setRequired(true);
                $element->setMultiOptions($childOrgs);

                if ($this->organizationMaxLines > 1) {
                    $element->setAttrib('size', min(count($childOrgs) + 1, $this->organizationMaxLines));
                }
                $this->addElement($element);
                $element->setValue($orgId);
            }
            $this->addElement($element);
        }

        return $element;
    }
1276268
public static function hydrateCollection(array $organizations)
    {
        $hydrated = [];

        foreach ($organizations as $organization) {
            $hydrated[] = self::hydrate($organization);
        }

        return $hydrated;
    }
862947
public static function get_scorm_scoes($scormid, $organization = '') {
        global $DB;

        $params = self::validate_parameters(self::get_scorm_scoes_parameters(),
                                            array('scormid' => $scormid, 'organization' => $organization));

        $scoes = array();
        $warnings = array();

        $scorm = $DB->get_record('scorm', array('id' => $params['scormid']), '*', MUST_EXIST);
        $cm = get_coursemodule_from_instance('scorm', $scorm->id);

        $context = context_module::instance($cm->id);
        self::validate_context($context);

        // Check settings / permissions to view the SCORM.
        scorm_require_available($scorm, true, $context);

        if (!$scoes = scorm_get_scoes($scorm->id, $params['organization'])) {
            // Function scorm_get_scoes return false, not an empty array.
            $scoes = array();
        } else {
            $scoreturnstructure = self::get_scorm_scoes_returns();
            foreach ($scoes as $sco) {
                $extradata = array();
                foreach ($sco as $element => $value) {
                    // Check if the element is extra data (not a basic SCO element).
                    if (!isset($scoreturnstructure->keys['scoes']->content->keys[$element])) {
                        $extradata[] = array(
                            'element' => $element,
                            'value' => $value
                        );
                    }
                }
                $sco->extradata = $extradata;
            }
        }

        $result = array();
        $result['scoes'] = $scoes;
        $result['warnings'] = $warnings;
        return $result;
    }