Turba_Data_Ldif::nextStep PHP Method

nextStep() public method

Takes all necessary actions for the given import step, parameters and form values and returns the next necessary step.
public nextStep ( integer $action, array $param = [] ) : mixed
$action integer The current step. One of the IMPORT_* constants.
$param array An associative array containing needed parameters for the current step.
return mixed Either the next step as an integer constant or imported data set after the final step.
    public function nextStep($action, array $param = array())
    {
        switch ($action) {
            case Horde_Data::IMPORT_FILE:
                parent::nextStep($action, $param);
                $f_data = $this->importFile($_FILES['import_file']['tmp_name']);
                $data = array();
                foreach ($f_data as $record) {
                    $turbaHash = array();
                    foreach ($this->_turbaAttr as $value) {
                        switch ($value) {
                            case 'homeAddress':
                                // These are the keys we're interested in.
                                $keys = array('homeStreet', 'mozillaHomeStreet2', 'mozillaHomeLocalityName', 'mozillaHomeState', 'mozillaHomePostalCode', 'mozillaHomeCountryName');
                                // Grab all of them that exist in $record.
                                $values = array_intersect_key($record, array_flip($keys));
                                // Special handling for State if both State
                                // and Locality Name are set.
                                if (isset($values['mozillaHomeLocalityName']) && isset($values['mozillaHomeState'])) {
                                    $values['mozillaHomeLocalityName'] .= ', ' . $values['mozillaHomeState'];
                                    unset($values['mozillaHomeState']);
                                }
                                if ($values) {
                                    $turbaHash[$value] = implode("\n", $values);
                                }
                                break;
                            case 'workAddress':
                                // These are the keys we're interested in.
                                $keys = array('street', 'mozillaWorkStreet2', 'l', 'st', 'postalCode', 'c');
                                // Grab all of them that exist in $record.
                                $values = array_intersect_key($record, array_flip($keys));
                                // Special handling for "st" if both "st" and
                                // "l" are set.
                                if (isset($values['l']) && isset($values['st'])) {
                                    $values['l'] .= ', ' . $values['st'];
                                    unset($values['st']);
                                }
                                if ($values) {
                                    $turbaHash[$value] = implode("\n", $values);
                                }
                                break;
                            default:
                                if (isset($record[$this->_turbaMozillaMap[$value]])) {
                                    $turbaHash[$value] = $record[$this->_turbaMozillaMap[$value]];
                                }
                                break;
                        }
                    }
                    $data[] = $turbaHash;
                }
                $this->storage->set('data', null);
                return $data;
            default:
                return parent::nextStep($action, $param);
        }
    }