function validateClassAttributeHTTPInput($http, $base, $classAttribute)
 {
     //checking if the recaptcha key is set up if recaptcha is enabled
     $ini = eZINI::instance('ezcomments.ini');
     $fields = $ini->variable('FormSettings', 'AvailableFields');
     if (in_array('recaptcha', $fields)) {
         $publicKey = $ini->variable('RecaptchaSetting', 'PublicKey');
         $privateKey = $ini->variable('RecaptchaSetting', 'PrivateKey');
         if ($publicKey === '' || $privateKey === '') {
             eZDebug::writeNotice('reCAPTCHA key is not set up. For help please visit http://projects.ez.no/ezcomments', __METHOD__);
         }
     }
     if ($http->hasPostVariable('StoreButton') || $http->hasPostVariable('ApplyButton')) {
         // find the class and count how many Comments dattype
         $cond = array('contentclass_id' => $classAttribute->attribute('contentclass_id'), 'version' => eZContentClass::VERSION_STATUS_TEMPORARY, 'data_type_string' => $classAttribute->attribute('data_type_string'));
         $classAttributeList = eZContentClassAttribute::fetchFilteredList($cond);
         // if there is more than 1 comment attribute, return it as INVALID
         if (!is_null($classAttributeList) && count($classAttributeList) > 1) {
             if ($classAttributeList[0]->attribute('id') == $classAttribute->attribute('id')) {
                 eZDebug::writeNotice('There are more than 1 comment attribute in the class.', __METHOD__);
                 return eZInputValidator::STATE_INVALID;
             }
         }
     }
     return eZInputValidator::STATE_ACCEPTED;
 }
 public static function removeClassAttribute($class_identifier, $attribute_identifier)
 {
     if (isset($class_identifier)) {
         $class = eZContentClass::fetchByIdentifier($class_identifier);
     }
     if (!is_object($class)) {
         return;
     }
     $classAttributeIdentifier = $attribute_identifier;
     // get attributes of 'temporary' version as well
     $classAttributeList = eZContentClassAttribute::fetchFilteredList(array('contentclass_id' => $class->ID, 'identifier' => $classAttributeIdentifier), true);
     $validation = array();
     foreach ($classAttributeList as $classAttribute) {
         $dataType = $classAttribute->dataType();
         if ($dataType->isClassAttributeRemovable($classAttribute)) {
             $objectAttributes = eZContentObjectAttribute::fetchSameClassAttributeIDList($classAttribute->attribute('id'));
             foreach ($objectAttributes as $objectAttribute) {
                 $objectAttributeID = $objectAttribute->attribute('id');
                 $objectAttribute->removeThis($objectAttributeID);
             }
             $classAttribute->removeThis();
         } else {
             $removeInfo = $dataType->classAttributeRemovableInformation($classAttribute);
         }
     }
 }
 public static function fetchMapMarkers($parentNodeId, $childrenClassIdentifiers)
 {
     foreach ($childrenClassIdentifiers as $key => $value) {
         if (empty($value)) {
             unset($childrenClassIdentifiers[$key]);
         }
     }
     $sortBy = array('name' => 'asc');
     $result = array();
     if ($parentNode = self::getNode($parentNodeId)) {
         if (!empty($childrenClassIdentifiers)) {
             $childrenClassTypes = (array) eZContentClass::fetchList(0, true, false, null, null, $childrenClassIdentifiers);
         } else {
             $childrenClassTypes = self::getChildrenClasses($parentNodeId);
         }
         // ricavo gli attributi delle classi
         $geoAttributes = array();
         foreach ($childrenClassTypes as $classType) {
             if ($classType instanceof eZContentClass) {
                 $geoAttributes = array_merge($geoAttributes, eZContentClassAttribute::fetchFilteredList(array('contentclass_id' => $classType->attribute('id'), 'version' => $classType->attribute('version'), 'data_type_string' => 'ezgmaplocation')));
             }
         }
         if (count($geoAttributes)) {
             // imposto i filtri di ricerca
             $geoFields = $geoFieldsNames = array();
             foreach ($geoAttributes as $geoAttribute) {
                 if ($geoAttribute instanceof eZContentClassAttribute) {
                     $geoFields[$geoAttribute->attribute('identifier')] = $geoAttribute->attribute('name');
                     $geoFieldsNames[] = "subattr_{$geoAttribute->attribute('identifier')}___coordinates____gpt";
                 }
             }
             $childrenParameters = array('SearchSubTreeArray' => array($parentNode->attribute('node_id')), 'Filter' => array('-meta_id_si:' . $parentNode->attribute('contentobject_id')), 'SearchLimit' => 1000, 'AsObjects' => false, 'SortBy' => $sortBy, 'FieldsToReturn' => $geoFieldsNames);
             // cerco i figli
             $solr = new OCSolr();
             $children = $solr->search('', $childrenParameters);
             if ($children['SearchCount'] > 0) {
                 foreach ($children['SearchResult'] as $item) {
                     foreach ($geoFieldsNames as $geoFieldsName) {
                         @(list($longitude, $latitude) = explode(',', $item['fields'][$geoFieldsName][0]));
                         if (intval($latitude) > 0 && intval($longitude) > 0) {
                             $href = isset($item['main_url_alias']) ? $item['main_url_alias'] : $item['main_url_alias_ms'];
                             eZURI::transformURI($href, false, 'full');
                             $popup = isset($item['name']) ? $item['name'] : $item['name_t'];
                             $id = isset($item['id_si']) ? $item['id_si'] : $item['id'];
                             $result[] = array('id' => $id, 'type' => null, 'lat' => floatval($latitude), 'lon' => floatval($longitude), 'lng' => floatval($longitude), 'popupMsg' => $popup, 'title' => $popup, 'description' => "<h3><a href='{$href}'>{$popup}</a></h3>", 'urlAlias' => $href, 'objectID' => $id);
                         }
                     }
                 }
             }
         }
     }
     return array('result' => $result);
 }
/**
 * Returns the ids of content classes that have an xmltext attribute
 * @return array(contentclass_id=>array(contentclassattribute_id))
 */
function getClassList()
{
    $affectedClasses = array();
    $classAttributes = eZContentClassAttribute::fetchFilteredList(array('data_type_string' => 'ezxmltext', 'version' => eZContentClass::VERSION_STATUS_DEFINED), false);
    foreach ($classAttributes as $classAttribute) {
        $contentClassId = $classAttribute['contentclass_id'];
        if (!isset($affectedClasses[$contentClassId])) {
            $affectedClasses[$contentClassId] = array();
        }
        $affectedClasses[$contentClassId][] = $classAttribute['identifier'];
    }
    return $affectedClasses;
}
function getClassConstraintListAsArray($class_identifier = false, $contentclass_id = false, $debug = false)
{
    //todo debug
    if (!$contentclass_id && !$class_identifier) {
        return;
    }
    if ($contentclass_id && $class_identifier) {
        return;
    }
    $ezobjectrelationlist = eZContentClassAttribute::fetchFilteredList(array('data_type_string' => 'ezobjectrelationlist'));
    $return = array();
    if ($contentclass_id) {
        foreach ($ezobjectrelationlist as $attribute) {
            if ($attribute->attribute('contentclass_id') == $contentclass_id) {
                $attributeContent = $attribute->content();
                if (!empty($attributeContent['class_constraint_list'])) {
                    $return = array_merge($return, $attributeContent['class_constraint_list']);
                }
            }
        }
        if (!empty($return)) {
            return $return;
        } else {
            return false;
        }
    }
    if ($class_identifier) {
        foreach ($ezobjectrelationlist as $attribute) {
            $attributeContent = $attribute->content();
            if (!empty($attributeContent['class_constraint_list'])) {
                if (in_array($class_identifier, $attributeContent['class_constraint_list'])) {
                    $class = eZContentClass::fetch($attribute->attribute('contentclass_id'));
                    $classIdentifier = eZContentClass::classIdentifierByID($attribute->attribute('contentclass_id'));
                    $return[$classIdentifier][] = array('class_id' => $attribute->attribute('contentclass_id'), 'class_name' => $class->attribute('name'), 'attribute_identifier' => $attribute->attribute('identifier'), 'attribute_name' => $attribute->attribute('name'), 'class_constraint_list' => $attributeContent['class_constraint_list'], 'search_filter' => $classIdentifier . '/' . $attribute->attribute('identifier') . '/main_node_id');
                }
            }
        }
        //eZDebug::writeNotice( $return, __METHOD__ );
        if (!empty($return)) {
            return $return;
        } else {
            return false;
        }
    }
    return false;
}
 /**
  * Get an array of class attribute identifiers based on either a class attribute
  * list, or a content classes list
  *
  * @param array $classIDArray
  *        Classes to search in. Either an array of class ID, class identifiers,
  *        a class ID or a class identifier.
  *        Using numerical attribute/class identifiers for $classIDArray is more efficient.
  * @param array $classAttributeID
  *        Class attributes to search in. Either an array of class attribute id,
  *        or a single class attribute. Literal identifiers are not allowed.
  * @param array $fieldTypeExcludeList
  *        filter list. List of field types to exclude. ( set to empty array by default ).
  *
  * @return array List of solr field names.
  */
 protected function getClassAttributes($classIDArray = false, $classAttributeIDArray = false, $fieldTypeExcludeList = null)
 {
     eZDebug::createAccumulator('Class attribute list', 'eZ Find');
     eZDebug::accumulatorStart('Class attribute list');
     $fieldArray = array();
     $classAttributeArray = array();
     // classAttributeIDArray = simple integer (content class attribute ID)
     if (is_numeric($classAttributeIDArray) and $classAttributeIDArray > 0) {
         $classAttributeArray[] = eZContentClassAttribute::fetch($classAttributeIDArray);
     } else {
         if (is_array($classAttributeIDArray)) {
             foreach ($classAttributeIDArray as $classAttributeID) {
                 $classAttributeArray[] = eZContentClassAttribute::fetch($classAttributeID);
             }
         }
     }
     // no class attribute list given, we need a class list
     // this block will create the class attribute array based on $classIDArray
     if (empty($classAttributeArray)) {
         // Fetch class list.
         $condArray = array("is_searchable" => 1, "version" => eZContentClass::VERSION_STATUS_DEFINED);
         if (!$classIDArray) {
             $classIDArray = array();
         } else {
             if (!is_array($classIDArray)) {
                 $classIDArray = array($classIDArray);
             }
         }
         // literal class identifiers are converted to numerical ones
         $tmpClassIDArray = $classIDArray;
         $classIDArray = array();
         foreach ($tmpClassIDArray as $key => $classIdentifier) {
             if (!is_numeric($classIdentifier)) {
                 if (!($contentClass = eZContentClass::fetchByIdentifier($classIdentifier, false))) {
                     eZDebug::writeWarning("Unknown content class identifier '{$classIdentifier}'", __METHOD__);
                 } else {
                     $classIDArray[] = $contentClass['id'];
                 }
             } else {
                 $classIDArray[] = $classIdentifier;
             }
         }
         if (!empty($classIDArray)) {
             $condArray['contentclass_id'] = array($classIDArray);
         }
         $classAttributeArray = eZContentClassAttribute::fetchFilteredList($condArray);
     }
     // $classAttributeArray now contains a list of eZContentClassAttribute
     // we can use to construct the list of fields solr should search in
     // @TODO : retrieve sub attributes here. Mind the types !
     foreach ($classAttributeArray as $classAttribute) {
         $fieldArray = array_merge(ezfSolrDocumentFieldBase::getFieldNameList($classAttribute, $fieldTypeExcludeList), $fieldArray);
     }
     // the array is unified + sorted in order to make it consistent
     $fieldArray = array_unique($fieldArray);
     sort($fieldArray);
     eZDebug::accumulatorStop('Class attribute list');
     return $fieldArray;
 }
 function fetchSearchableAttributes($id = false, $asObject = true, $version = eZContentClass::VERSION_STATUS_DEFINED)
 {
     if ($id === false) {
         $id = $this->ID;
         $version = $this->Version;
     }
     return eZContentClassAttribute::fetchFilteredList(array("contentclass_id" => $id, "is_searchable" => 1, "version" => $version), $asObject);
 }
    function updateClassAttributes( $params )
    {
        $classInfo = $params['class'];
        $attributesInfo = $params['attributes'];

        $contentClassID = eZSiteInstaller::classIDbyIdentifier( $classInfo );
        if( $contentClassID )
        {
            foreach( $attributesInfo as $attributeInfo )
            {
                $attributeIdentifier = $attributeInfo['identifier'];
                $name = isset( $attributeInfo['new_name'] ) ? $attributeInfo['new_name'] : false;

                $classAttributeList = eZContentClassAttribute::fetchFilteredList( array( 'contentclass_id' => $contentClassID,
                                                                                         'identifier' => $attributeIdentifier ),
                                                                                  true );
                foreach( $classAttributeList as $attribute )
                {
                    if( $name !== false )
                    {
                        $attribute->setName( $name );
                    }

                    $attribute->store();
                }
            }
        }
    }