Exemple #1
0
         while (($prefix = next($prefixes)) !== false) {
             $prefix = substr($firstprefix, 0, -strlen($prefix)) . $prefix;
             $result[$name][$sell_price][] = $prefix;
             // CHECK FOR DUPLICATE PREFIXES
             if (isset($prefixList[$prefix])) {
                 $warnings['duplicate_item'][$prefix]['prefix'] = $prefix;
                 $warnings['duplicate_item'][$prefix]['group'][$name] = $name;
                 $warnings['duplicate_item'][$prefix]['group'][$prefixList[$firstprefix]] = $prefixList[$firstprefix];
             } else {
                 $prefixList[$prefix] = $name;
             }
         }
     }
 }
 // BUILD GROUPS FROM PREFIX ARRAY
 $groups = buildGroups($result);
 // FIND ALREADY EXISTS PREFIXES
 $tmp = findAlreadyExists($prefixList);
 if ($tmp) {
     $warnings['already_exists'] = $tmp;
 }
 if ($warnings) {
     $SMARTY->assign('warnings', $warnings);
 } else {
     $DB->BeginTrans();
     $DB->execute('delete from voip_tariff where tariffid =4');
     // GENERATE INSERT QUERY TO `voip_prefix` TABLE
     $voip_prefix = 'INSERT INTO voip_prefixes (prefix, name, description) VALUES ';
     foreach ($groups as $groupName => $v) {
         foreach ($v as $prefixArray) {
             foreach ($prefixArray as $singlePrefix) {
$docid = $modx->getOption('docid', $scriptProperties, $docid);
if ($resource = $modx->getObject('modResource', $docid)) {
    $record = $resource->toArray();
    $resource_properties = $resource->getProperties('migxrecipes');
    $recipe_fields = json_decode($modx->getOption('recipe', $resource_properties, ''), true);
    if (is_array($recipe_fields)) {
        $record = array_merge($record, $recipe_fields);
    }
    //incgredients
    $tpl_prefix = $modx->getOption('migxrecipes.tpl_prefix', null, 'migxrecipes_');
    //$items = json_decode($modx->getOption('recipe_ingredients', $data, ''), true);
    $items = json_decode($modx->getOption('recipe_ingredients_groups', $record, ''), true);
    $group_output = buildGroups($items, $tpl_prefix . 'ingredientTpl', $tpl_prefix . 'ingredientsGroupTpl', 'ingredients');
    $record['recipe_ingredients'] = implode("\n", $group_output);
    $items = json_decode($modx->getOption('recipe_instructions_groups', $record, ''), true);
    $group_output = buildGroups($items, $tpl_prefix . 'instructionTpl', $tpl_prefix . 'instructionsGroupTpl', 'instructions');
    $record['recipe_instructions'] = implode("\n", $group_output);
    $content = $modx->getChunk($tpl_prefix . 'contentTpl', $record);
    if (is_object($modx->resource) && $modx->resource->get('id') == $docid) {
        //we are at the resource itself
        $modx->resource->setContent($content);
        $modx->resource->save();
    } else {
        $resource->set('content', $content);
        $resource->save();
    }
}
function buildGroups($groups, $innerTpl, $outerTpl, $itemsfield = 'items')
{
    global $modx;
    $group_output = array();
function getData($_int, $_gr, $_vi, $_ft)
{
    if ($_int) {
        buildInternalUsers();
    }
    if ($_gr) {
        buildGroups();
    }
    if ($_vi) {
        buildTracking();
    }
    if ($_ft) {
        buildFilter();
    }
}
Exemple #4
0
if ($_SESSION['MenuFinIDo']) {
    $Sessions['I'] = true;
}
if ($_SESSION['MenuFinTDo']) {
    $Sessions['T'] = true;
}
echo '</select>';
if ($SesRow) {
    echo '<table id="Groups" class="Tabella">';
    echo '<tr>
		<th class="Title" rowspan="2" colspan="2">' . get_text('API-Group', 'Api') . '</th>
		<th class="Title" colspan="' . count($SesRow->Range) . '">' . get_text('API-Targets', 'Api') . '</th>
		</tr>';
    echo '<tr>';
    foreach ($SesRow->Range as $Target) {
        echo '<th class="Title">' . $Target . '</th>';
    }
    echo '</tr>';
    echo buildGroups($SesType, $Session, $ElPhase, $SesRow->Range);
    echo '<tr>';
    echo '<th><img title="' . get_text('CmdAdd', 'Tournament') . '" alt="add" src="' . $CFG->ROOT_DIR . 'Common/Images/Enabled1.png" height="20" alt="add" onclick="AddGroup(this)"></th>';
    echo '<th><input type="text" id="GrName"></th>';
    foreach ($SesRow->Range as $Target) {
        $tgtno = sprintf($tgt, $Target);
        echo '<td><input type="radio" onclick="UpdateGroup(this, \'delete\')" name="tgt[' . $SesType . '][' . $ElPhase . '][' . $tgtno . ']" value="***Group***"></td>';
    }
    echo '</tr>';
    echo '</table>';
}
// debug_svela($SesRow);
include 'Common/Templates/tail.php';
Exemple #5
0
function loadFromFile($list_id)
{
    $prefixList = array();
    $error = array();
    $lines = file($_FILES['file']['tmp_name']);
    if (empty($lines)) {
        return 1;
    }
    while (($line = next($lines)) !== false) {
        if (empty($line)) {
            continue;
        }
        $row = parseRow($line);
        $name = $row['name'];
        $prefix = $row['prefix'];
        $sell = $row['sell'];
        $result[$name][$sell][] = $prefix;
        // CHECK FOR DUPLICATE PREFIXES
        if (isset($prefixList[$prefix])) {
            $error['duplicate_item'][] = $prefix;
        } else {
            $prefixList[$prefix] = $name;
        }
    }
    if ($error) {
        return $error;
    }
    $DB = LMSDB::getInstance();
    $groups = buildGroups($result);
    // -----------------------------------------------------
    // GENERATE INSERT QUERY TO `voip_prefix_groups` TABLE
    // -----------------------------------------------------
    $voip_prefix_group = 'INSERT INTO voip_prefix_groups (name, description) VALUES ';
    foreach ($groups as $groupName => $prefixArray) {
        $voip_prefix_group .= "('{$groupName}', ''),";
    }
    $voip_prefix_group = rtrim($voip_prefix_group, ',') . ';';
    $DB->execute($voip_prefix_group);
    // -----------------------------------------------------
    // GENERATE INSERT QUERY TO `voip_prefix_groups` TABLE
    // -----------------------------------------------------
    $groupHelperArray = $DB->GetAllByKey("SELECT id, name FROM voip_prefix_groups", "name");
    $voip_prefix = 'INSERT INTO voip_prefixes (prefix, groupid) VALUES ';
    foreach ($groups as $groupName => $v) {
        foreach ($v as $prefixArray) {
            foreach ($prefixArray as $singlePrefix) {
                $voip_prefix .= "('{$singlePrefix}', " . $groupHelperArray[$groupName]['id'] . "),";
            }
        }
    }
    $voip_prefix = rtrim($voip_prefix, ',') . ';';
    $DB->execute($voip_prefix);
    // -----------------------------------------------------
    // CREATE TARIFFS
    // -----------------------------------------------------
    $voip_tariff = 'INSERT INTO voip_price_groups (prefix_group_id, voip_tariff_id, price, unitsize) VALUES ';
    foreach ($groups as $groupName => $prefixArray) {
        $price = key($prefixArray);
        $voip_tariff .= '(' . $groupHelperArray[$groupName]['id'] . ", {$list_id}, {$price}, 60),";
    }
    $voip_tariff = rtrim($voip_tariff, ',') . ';';
    $DB->execute($voip_tariff);
    return 0;
}