/**
  * (non-PHPdoc)
  * @see DropDownBatchAttributeValueDataAnalyzer::analyzeByValue()
  */
 protected function analyzeByValue($value)
 {
     if ($value != null) {
         $customFieldValues = MultiSelectDropDownSanitizerUtil::getCustomFieldValuesFromValueString($value);
         foreach ($customFieldValues as $aValue) {
             $lowerCaseMissingValuesToMap = ArrayUtil::resolveArrayToLowerCase($this->missingDropDownInstructions[DropDownSanitizerUtil::ADD_MISSING_VALUE]);
             if (!in_array(strtolower($aValue), $this->dropDownValues) && !in_array(strtolower($aValue), $lowerCaseMissingValuesToMap)) {
                 $this->missingDropDownInstructions[DropDownSanitizerUtil::ADD_MISSING_VALUE][] = $aValue;
                 $this->messageCountData[static::INVALID]++;
             }
         }
     }
 }
 /**
  * @param RedBean_OODBBean $rowBean
  */
 public function analyzeByRow(RedBean_OODBBean $rowBean)
 {
     if ($rowBean->{$this->columnName} != null) {
         $customFieldData = CustomFieldDataModelUtil::getDataByModelClassNameAndAttributeName($this->modelClassName, $this->attributeName);
         $lowerCaseDropDownValues = ArrayUtil::resolveArrayToLowerCase(unserialize($customFieldData->serializedData));
         $customFieldValues = MultiSelectDropDownSanitizerUtil::getCustomFieldValuesFromValueString($rowBean->{$this->columnName});
         foreach ($customFieldValues as $aValue) {
             if (!in_array(strtolower($aValue), $lowerCaseDropDownValues)) {
                 $label = Zurmo::t('ImportModule', '{value} is new. This value will be added upon import.', array('{value}' => $aValue));
                 $this->analysisMessages[] = $label;
                 $this->missingCustomFieldValues[] = $aValue;
             }
         }
     }
 }
 /**
  * Check if picklist modification caused some issues with workflow triggers and if yes notify users
  * @return array
  * @throws NotSupportedException
  */
 public static function getWorkflowsWithInvalidTriggerCustomFieldValue()
 {
     $savedWorkflows = SavedWorkflow::getAll();
     $workflows = array();
     foreach ($savedWorkflows as $savedWorkflow) {
         $workflow = SavedWorkflowToWorkflowAdapter::makeWorkflowBySavedWorkflow($savedWorkflow);
         $hasInvalidCustomFieldValue = false;
         foreach ($workflow->getTriggers() as $trigger) {
             $modelClassName = $trigger->getModelClassName();
             $customFieldAttributeNames = CustomFieldUtil::getCustomFieldAttributeNames($modelClassName);
             $triggerAttributeName = $trigger->getAttribute();
             if (in_array($triggerAttributeName, $customFieldAttributeNames)) {
                 $customFieldData = CustomFieldDataModelUtil::getDataByModelClassNameAndAttributeName($modelClassName, $triggerAttributeName);
                 $allCustomFieldValues = unserialize($customFieldData->serializedData);
                 // Check with triggers that allow single value
                 if (in_array($trigger->getOperator(), array(OperatorRules::TYPE_EQUALS, OperatorRules::TYPE_DOES_NOT_EQUAL, OperatorRules::TYPE_BECOMES, OperatorRules::TYPE_WAS))) {
                     if (!in_array($trigger->value, $allCustomFieldValues)) {
                         $hasInvalidCustomFieldValue = true;
                         break;
                     }
                 } elseif (in_array($trigger->getOperator(), array(OperatorRules::TYPE_BECOMES_ONE_OF, OperatorRules::TYPE_WAS_ONE_OF, OperatorRules::TYPE_ONE_OF))) {
                     $triggerSelectedCustomFieldValues = MultiSelectDropDownSanitizerUtil::getCustomFieldValuesFromValueString($trigger->value);
                     foreach ($triggerSelectedCustomFieldValues as $triggerValue) {
                         if (!in_array($triggerValue, $allCustomFieldValues)) {
                             $hasInvalidCustomFieldValue = true;
                             break 2;
                         }
                     }
                 }
             }
         }
         if ($hasInvalidCustomFieldValue) {
             $workflows[] = $workflow;
         }
     }
     return $workflows;
 }