Exemplo n.º 1
0
 public static function switchRank($id1, $id2)
 {
     $record1 = StructuredField::readRecord($id1);
     $record2 = StructuredField::readRecord($id2);
     $rank1 = $record1[2];
     $rank2 = $record2[2];
     $query = "UPDATE structured_field SET rank={$rank2} WHERE id={$id1};";
     $result1 = mysql_query($query) or die(sqlError(__FILE__, __LINE__, $query));
     $query = "UPDATE structured_field SET rank={$rank1} WHERE id={$id2};";
     $result2 = mysql_query($query) or die(sqlError(__FILE__, __LINE__, $query));
 }
if ($type) {
    switch ($type) {
        case 'createRecord':
            $rank = StructuredField::createRecord($id, $name, $rank);
            $result = "Record for unit with id {$id} at rank={$rank} with name={$name} has been created";
            break;
        case 'updateRecord':
            $rank = StructuredField::updateRecord($id, $name, $rank);
            $result = "Record {$id} has been updated with rank={$rank}, and name={$name}";
            break;
        case 'moveRankUp':
            StructuredField::moveRankUp($id, $rank);
            $result = "rank #{$rank} has been freed";
            break;
        case 'readRecord':
            $record = StructuredField::readRecord($id);
            if ($record) {
                $result = implode(",", $record);
            } else {
                $result = "no record found";
            }
            break;
        case 'getSortedRecords':
            $recordArray = StructuredField::getSortedRecords($id);
            if (!$recordArray) {
                $result = "no record for the unit with id={$id}";
            } else {
                foreach ($recordArray as $record) {
                    $recordFields[] = implode(",", $record);
                }
                $result = implode("<br/>", $recordFields);
Exemplo n.º 3
0
}
// rename/lock/unlock record
if ($save) {
    $recordName = $_POST['recordName'];
    $selectedRecord = StructuredField::readRecord($init);
    if ($isAdmin) {
        $lockVal = $_POST['lock'];
    } else {
        $lockVal = $selectedRecord[4];
    }
    StructuredField::updateRecord($selectedRecord[0], $recordName, $selectedRecord[2], $lockVal);
    $records = StructuredField::getSortedRecords($id, $isAdmin);
}
//get default values for the textareas (either from the selecting record, or from the first record)
if ($init) {
    $selectedRecord = StructuredField::readRecord($init);
} else {
    $selectedRecord = $records[0];
    $init = $selectedRecord[0];
}
if ($init) {
    $textArray = StructuredFieldValue::getValues($init);
    $assetArray = StructuredFieldAsset::getAssets($init);
    $selectedRecordName = displayValue($selectedRecord[3]);
    // don't show locked record for non-admin users or there is no record name in the URL
    $lock = $selectedRecord[4];
    if (empty($name) || $lock == 1 && !$isAdmin) {
        header('location:index.php');
    }
}
?>