Exemple #1
0
 function get($data = array())
 {
     $_roleid = param::get_cookie('_roleid');
     $_groupid = param::get_cookie('_groupid');
     $this->data = $data;
     if (isset($data['id'])) {
         $this->id = $data['id'];
     }
     $info = array();
     foreach ($this->fields as $field => $v) {
         if (defined('IN_ADMIN')) {
             if ($v['disabled'] || $v['iscore'] || check_in($_roleid, $v['unsetroleids']) || check_in($_groupid, $v['unsetgroupids'])) {
                 continue;
             }
         } else {
             if ($v['disabled'] || $v['iscore'] || !$v['isadd'] || check_in($_roleid, $v['unsetroleids']) || check_in($_groupid, $v['unsetgroupids'])) {
                 continue;
             }
         }
         $func = $v['formtype'];
         $value = isset($data[$field]) ? new_html_special_chars($data[$field]) : '';
         if ($func == 'pages' && isset($data['maxcharperpage'])) {
             $value = $data['paginationtype'] . '|' . $data['maxcharperpage'];
         }
         if (!method_exists($this, $func)) {
             continue;
         }
         $form = $this->{$func}($field, $value, $v);
         if ($form !== false) {
             $star = $v['minlength'] || $v['pattern'] ? 1 : 0;
             $info[$field] = array('name' => $v['name'], 'tips' => $v['tips'], 'form' => $form, 'star' => $star, 'isbase' => $v['isbase'], 'isomnipotent' => $v['isomnipotent'], 'formtype' => $v['formtype']);
         }
     }
     return $info;
 }
 function get($data, $isimport = 0)
 {
     $this->data = $data = trim_script($data);
     $info = array();
     foreach ($data as $field => $value) {
         if (!isset($this->fields[$field]) && !check_in($field, 'paytype,paginationtype,maxcharperpage,id')) {
             continue;
         }
         $name = $this->fields[$field]['name'];
         $minlength = $this->fields[$field]['minlength'];
         $maxlength = $this->fields[$field]['maxlength'];
         $pattern = $this->fields[$field]['pattern'];
         $errortips = $this->fields[$field]['errortips'];
         if (empty($errortips)) {
             $errortips = $name . ' 不符合要求';
         }
         $length = empty($value) ? 0 : (is_string($value) ? strlen($value) : count($value));
         if ($minlength && $length < $minlength) {
             if ($isimport) {
                 return false;
             } else {
                 showmessage($name . ' 不得少于 ' . $minlength . ' 字符');
             }
         }
         if ($maxlength && $length > $maxlength) {
             if ($isimport) {
                 $value = str_cut($value, $maxlength, '');
             } else {
                 showmessage($name . ' 不得多于 ' . $maxlength . ' 字符');
             }
         } elseif ($maxlength) {
             $value = str_cut($value, $maxlength, '');
         }
         if ($pattern && $length && !preg_match($pattern, $value) && !$isimport) {
             showmessage($errortips);
         }
         // 唯一性判断,和附加函数验证
         /*$MODEL = getcache('model', 'commons');
         		$this->db->table_name = $this->fields[$field]['issystem'] ? $this->db_pre.$MODEL[$this->modelid]['tablename'] : $this->db_pre.$MODEL[$this->modelid]['tablename'].'_data';
         		if($this->fields[$field]['isunique'] && $this->db->get_one(array($field=>$value),$field) && ROUTE_A != 'edit') showmessage($name.L('the_value_must_not_repeat'));*/
         $func = $this->fields[$field]['formtype'];
         if (method_exists($this, $func)) {
             $value = $this->{$func}($field, $value);
         }
         // var_dump($this->fields);
         if ($this->fields[$field]['issystem']) {
             $info['system'][$field] = $value;
         } else {
             $info['model'][$field] = $value;
         }
     }
     //颜色选择为隐藏域 在这里进行取值
     $info['system']['style'] = $_POST['style_color'] ? strip_tags($_POST['style_color']) : '';
     if ($_POST['style_font_weight']) {
         $info['system']['style'] = $info['system']['style'] . ';' . strip_tags($_POST['style_font_weight']);
     }
     return $info;
 }
 function get($data = array())
 {
     $_groupid = param::get_cookie('_groupid');
     $this->data = $data;
     if (isset($data['id'])) {
         $this->id = $data['id'];
     }
     $info = array();
     $this->content_url = $data['url'];
     foreach ($this->fields as $field => $v) {
         if (defined('IN_ADMIN')) {
             if ($v['iscore'] || check_in($_SESSION['roleid'], $v['unsetroleids'])) {
                 continue;
             }
         } else {
             if ($v['iscore'] || !$v['isadd'] || check_in($_groupid, $v['unsetgroupids'])) {
                 continue;
             }
         }
         $func = $v['formtype'];
         $value = isset($data[$field]) ? htmlspecialchars($data[$field], ENT_QUOTES) : '';
         if ($func == 'pages' && isset($data['maxcharperpage'])) {
             $value = $data['paginationtype'] . '|' . $data['maxcharperpage'];
         }
         if (!method_exists($this, $func)) {
             $v['isbase'] ? $info['base'][$field] = array() : ($info['senior'][$field] = array());
             //3.31 实现自定义字段的排序
             continue;
             //3.31 实现自定义字段的排序
         }
         $form = $this->{$func}($field, $value, $v);
         if ($form !== false) {
             if (defined('IN_ADMIN')) {
                 if ($v['isbase']) {
                     $star = $v['minlength'] || $v['pattern'] ? 1 : 0;
                     $info['base'][$field] = array('name' => $v['name'], 'tips' => $v['tips'], 'form' => $form, 'star' => $star, 'isomnipotent' => $v['isomnipotent'], 'formtype' => $v['formtype']);
                 } else {
                     $star = $v['minlength'] || $v['pattern'] ? 1 : 0;
                     $info['senior'][$field] = array('name' => $v['name'], 'tips' => $v['tips'], 'form' => $form, 'star' => $star, 'isomnipotent' => $v['isomnipotent'], 'formtype' => $v['formtype']);
                 }
             } else {
                 $star = $v['minlength'] || $v['pattern'] ? 1 : 0;
                 $info[$field] = array('name' => $v['name'], 'tips' => $v['tips'], 'form' => $form, 'star' => $star, 'isomnipotent' => $v['isomnipotent'], 'formtype' => $v['formtype']);
             }
         }
     }
     /*****3.22  试验*****************/
     //pc_base::load_app_func('add_field');//引入函数
     //add_field($this->modelid,$info,$data);
     /*****3.22  试验end**************************/
     return $info;
 }
 function get($data, $isimport = 0)
 {
     $this->data = $data = trim_script($data);
     $info = array();
     foreach ($data as $field => $value) {
         if (!isset($this->fields[$field]) && !check_in($field, 'paytype,paginationtype,maxcharperpage,id')) {
             continue;
         }
         $name = $this->fields[$field]['name'];
         $minlength = $this->fields[$field]['minlength'];
         $maxlength = $this->fields[$field]['maxlength'];
         $pattern = $this->fields[$field]['pattern'];
         $errortips = $this->fields[$field]['errortips'];
         if (empty($errortips)) {
             $errortips = $name . ' 不符合要求';
         }
         $length = empty($value) ? 0 : (is_string($value) ? strlen($value) : count($value));
         if ($minlength && $length < $minlength) {
             if ($isimport) {
                 return false;
             } else {
                 showmessage($name . ' 不得少于 ' . $minlength . ' 字符');
             }
         }
         if ($maxlength && $length > $maxlength) {
             if ($isimport) {
                 $value = str_cut($value, $maxlength, '');
             } else {
                 showmessage($name . ' 不得多于 ' . $maxlength . ' 字符');
             }
         } elseif ($maxlength) {
             $value = str_cut($value, $maxlength, '');
         }
         if ($pattern && $length && !preg_match($pattern, $value) && !$isimport) {
             showmessage($errortips);
         }
         // 附加函数验证
         $func = $this->fields[$field]['formtype'];
         if (method_exists($this, $func)) {
             $value = $this->{$func}($field, $value);
         }
         $info['system'][$field] = $value;
     }
     //颜色选择为隐藏域 在这里进行取值
     $info['system']['style'] = $_POST['style_color'] ? strip_tags($_POST['style_color']) : '';
     if ($_POST['style_font_weight']) {
         $info['system']['style'] = $info['system']['style'] . ';' . strip_tags($_POST['style_font_weight']);
     }
     return $info;
 }
Exemple #5
0
 public function get($data = array())
 {
     $_groupid = cookie('_groupid');
     $this->data = $data;
     if (isset($data['id'])) {
         $this->id = $data['id'];
     }
     $info = array();
     $this->content_url = isset($data['url']) ? $data['url'] : '';
     foreach ($this->fields as $field => $v) {
         if (defined('IN_ADMIN')) {
             if ($v['iscore'] || check_in($_SESSION['roleid'], $v['unsetroleids'])) {
                 continue;
             }
         } else {
             if ($v['iscore'] || !$v['isadd'] || check_in($_groupid, $v['unsetgroupids'])) {
                 continue;
             }
         }
         $func = $v['formtype'];
         $value = isset($data[$field]) ? htmlspecialchars($data[$field], ENT_QUOTES) : '';
         if ($func == 'pages' && isset($data['maxcharperpage'])) {
             $value = $data['paginationtype'] . '|' . $data['maxcharperpage'];
         }
         if (!method_exists($this, $func)) {
             continue;
         }
         $form = $this->{$func}($field, $value, $v);
         if ($form !== false) {
             if (defined('IN_ADMIN')) {
                 if ($v['isbase']) {
                     $star = $v['minlength'] || $v['pattern'] ? 1 : 0;
                     $info['base'][$field] = array('name' => $v['name'], 'tips' => $v['tips'], 'form' => $form, 'star' => $star, 'isomnipotent' => $v['isomnipotent'], 'formtype' => $v['formtype']);
                 } else {
                     $star = $v['minlength'] || $v['pattern'] ? 1 : 0;
                     $info['senior'][$field] = array('name' => $v['name'], 'tips' => $v['tips'], 'form' => $form, 'star' => $star, 'isomnipotent' => $v['isomnipotent'], 'formtype' => $v['formtype']);
                 }
             } else {
                 $star = $v['minlength'] || $v['pattern'] ? 1 : 0;
                 $info[$field] = array('name' => $v['name'], 'tips' => $v['tips'], 'form' => $form, 'star' => $star, 'isomnipotent' => $v['isomnipotent'], 'formtype' => $v['formtype']);
             }
         }
     }
     return $info;
 }
         $key = str_replace("NEW_", "", $key);
         if ($value == 'yes') {
             ${$key} = true;
         } elseif ($value == 'no') {
             ${$key} = false;
         } else {
             ${$key} = $value;
         }
     }
 }
 //-- delete the cache files for the welcome page blocks
 require_once PGV_ROOT . 'includes/index_cache.php';
 clearCache();
 $logline = AddToLog("Gedcom configuration " . $INDEX_DIRECTORY . $FILE . "_conf.php" . " updated");
 $gedcomconfname = $FILE . "_conf.php";
 check_in($logline, $gedcomconfname, $INDEX_DIRECTORY);
 if (!$errors) {
     $gednews = getUserNews($FILE);
     if (count($gednews) == 0) {
         $news = array();
         $news["title"] = "#default_news_title#";
         $news["username"] = $FILE;
         $news["text"] = "#default_news_text#";
         $news["date"] = client_time();
         addNews($news);
     }
     if ($source == "upload_form") {
         $check = "upload";
     } elseif ($source == "add_form") {
         $check = "add";
     } elseif ($source == "add_new_form") {
 function get($data, $isimport = 0)
 {
     $this->data = $data = trim_script($data);
     $info = array();
     foreach ($data as $field => $value) {
         if (!isset($this->fields[$field]) && !check_in($field, 'paytype,paginationtype,maxcharperpage,id')) {
             continue;
         }
         if (defined('IN_ADMIN')) {
             if (check_in($_SESSION['roleid'], $this->fields[$field]['unsetroleids'])) {
                 continue;
             }
         } else {
             $_groupid = param::get_cookie('_groupid');
             if (check_in($_groupid, $this->fields[$field]['unsetgroupids'])) {
                 continue;
             }
         }
         $name = $this->fields[$field]['name'];
         $minlength = $this->fields[$field]['minlength'];
         $maxlength = $this->fields[$field]['maxlength'];
         $pattern = $this->fields[$field]['pattern'];
         $errortips = $this->fields[$field]['errortips'];
         if (empty($errortips)) {
             $errortips = "请输入正确的{$name}";
         }
         //die;
         $length = empty($value) ? 0 : (is_string($value) ? strlen($value) : count($value));
         if ($minlength && $length < $minlength) {
             if ($isimport) {
                 return false;
             } else {
                 showmessage($name . ' ' . L('not_less_than') . ' ' . $minlength . L('characters'));
             }
         }
         if ($maxlength && $length > $maxlength) {
             if ($isimport) {
                 $value = str_cut($value, $maxlength, '');
             } else {
                 showmessage($name . ' ' . L('not_more_than') . ' ' . $maxlength . L('characters'));
             }
         } elseif ($maxlength) {
             $value = str_cut($value, $maxlength, '');
         }
         if ($pattern && $length && !preg_match($pattern, $value) && !$isimport) {
             showmessage($errortips);
         }
         $MODEL = getcache('model', 'commons');
         $this->db->table_name = $this->fields[$field]['issystem'] ? $this->db_pre . $MODEL[$this->modelid]['tablename'] : $this->db_pre . $MODEL[$this->modelid]['tablename'] . '_data';
         if ($this->fields[$field]['isunique'] && $this->db->get_one(array($field => $value), $field) && ROUTE_A != 'edit') {
             showmessage($name . L('the_value_must_not_repeat'));
         }
         $func = $this->fields[$field]['formtype'];
         if (method_exists($this, $func)) {
             $value = $this->{$func}($field, $value);
         }
         if ($this->fields[$field]['issystem']) {
             $info['system'][$field] = $value;
         } else {
             $info['model'][$field] = $value;
         }
         //颜色选择为隐藏域 在这里进行取值
         $info['system']['style'] = $_POST['style_color'] && preg_match('/^#([0-9a-z]+)/i', $_POST['style_color']) ? $_POST['style_color'] : '';
         if ($_POST['style_font_weight'] == 'bold') {
             $info['system']['style'] = $info['system']['style'] . ';' . strip_tags($_POST['style_font_weight']);
         }
     }
     return $info;
 }
                $extra_qlinks = "\n\t\t\t\t\t\t\t\t\t<tr class='datacell'>\n\t\t\t\t\t\t\t\t\t\t<td><a href='cust-credit-stockinv.php'>New Invoice</a></td>\n\t\t\t\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t\t\t\t<tr class='datacell'>\n\t\t\t\t\t\t\t\t\t\t<td><a href='pos-invoice-new.php'>New POS Invoice</a></td>\n\t\t\t\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t\t\t\t<tr class='datacell'>\n\t\t\t\t\t\t\t\t\t\t<td><a href='nons-invoice-new.php'>New Non Stock Invoice</a></td>\n\t\t\t\t\t\t\t\t\t</tr>";
            }
            break;
        case "client_collect":
            $OUTPUT = client_collect($_POST);
            // Extra quick links
            $extra_qlinks = "\n\t\t\t\t\t\t\t\t<tr class='datacell'>\n\t\t\t\t\t\t\t\t\t<td><a href='cust-credit-stockinv.php'>New Invoice</a></td>\n\t\t\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t\t\t<tr class='datacell'>\n\t\t\t\t\t\t\t\t\t<td><a href='pos-invoice-new.php'>New POS Invoice</a></td>\n\t\t\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t\t\t<tr class='datacell'>\n\t\t\t\t\t\t\t\t\t<td><a href='nons-invoice-new.php'>New Non Stock Invoice</a></td>\n\t\t\t\t\t\t\t\t</tr>";
            break;
        case "status_history":
            $OUTPUT = status_history($_POST);
            break;
        case "edit_notes":
            $OUTPUT = edit_notes($_POST);
            break;
        case "check_in":
            $OUTPUT = check_in($_POST);
            break;
        case "check_out":
            $OUTPUT = check_out($_POST);
            break;
        case "receipt":
            receipt($_POST);
            break;
        case "workshop_report":
            $OUTPUT = workshop_report($_POST);
            break;
    }
} else {
    $OUTPUT = display();
}
if (!isset($extra_qlinks)) {
Exemple #9
0
/**
 * get a list of the reports in the reports directory
 *
 * When $force is false, the function will first try to read the reports list from the$INDEX_DIRECTORY."/reports.dat"
 * data file.  Otherwise the function will parse the report xml files and get the titles.
 * @param boolean $force	force the code to look in the directory and parse the files again
 * @return array 	The array of the found reports with indexes [title] [file]
 */
function get_report_list($force = false)
{
    global $INDEX_DIRECTORY, $report_array, $vars, $xml_parser, $elementHandler, $LANGUAGE;
    $files = array();
    if (!$force) {
        //-- check if the report files have been cached
        if (file_exists($INDEX_DIRECTORY . "/reports.dat")) {
            $reportdat = "";
            $fp = fopen($INDEX_DIRECTORY . "/reports.dat", "r");
            while ($data = fread($fp, 4096)) {
                $reportdat .= $data;
            }
            fclose($fp);
            $files = unserialize($reportdat);
            foreach ($files as $indexval => $file) {
                if (isset($file["title"][$LANGUAGE]) && strlen($file["title"][$LANGUAGE]) > 1) {
                    return $files;
                }
            }
        }
    }
    //-- find all of the reports in the reports directory
    $d = dir("reports");
    while (false !== ($entry = $d->read())) {
        if ($entry[0] != "." && $entry != "CVS" && preg_match('/\\.xml$/i', $entry) > 0) {
            if (!isset($files[$entry]["file"])) {
                $files[$entry]["file"] = "reports/" . $entry;
            }
        }
    }
    $d->close();
    require_once "../reportheader.php";
    $report_array = array();
    if (!function_exists("xml_parser_create")) {
        return $report_array;
    }
    foreach ($files as $file => $r) {
        $report_array = array();
        //-- start the sax parser
        $xml_parser = xml_parser_create();
        //-- make sure everything is case sensitive
        xml_parser_set_option($xml_parser, XML_OPTION_CASE_FOLDING, false);
        //-- set the main element handler functions
        xml_set_element_handler($xml_parser, "startElement", "endElement");
        //-- set the character data handler
        xml_set_character_data_handler($xml_parser, "characterData");
        if (file_exists($r["file"])) {
            //-- open the file
            if (!($fp = fopen($r["file"], "r"))) {
                die("could not open XML input");
            }
            //-- read the file and parse it 4kb at a time
            while ($data = fread($fp, 4096)) {
                if (!xml_parse($xml_parser, $data, feof($fp))) {
                    die(sprintf($data . "\nXML error: %s at line %d", xml_error_string(xml_get_error_code($xml_parser)), xml_get_current_line_number($xml_parser)));
                }
            }
            fclose($fp);
            xml_parser_free($xml_parser);
            if (isset($report_array["title"]) && isset($report_array["access"]) && isset($report_array["icon"])) {
                $files[$file]["title"][$LANGUAGE] = $report_array["title"];
                $files[$file]["access"] = $report_array["access"];
                $files[$file]["icon"] = $report_array["icon"];
            }
        }
    }
    $fp = @fopen($INDEX_DIRECTORY . "/reports.dat", "w");
    @fwrite($fp, serialize($files));
    @fclose($fp);
    $logline = AddToLog("reports.dat updated");
    check_in($logline, "reports.dat", $INDEX_DIRECTORY);
    return $files;
}
        $id = mydb::cxn()->real_escape_string($_GET['itemID']);
        $new_qty = mydb::cxn()->real_escape_string($_GET['newQty']);
        //Get old quantity
        $query = "SELECT quantity FROM inventory WHERE id = " . $id;
        $result = mydb::cxn()->query($query);
        $row = $result->fetch_assoc();
        $old_qty = $row['quantity'];
        //Change quantity
        $query = "UPDATE inventory SET quantity = " . $new_qty . " WHERE id = " . $id;
        $result = mydb::cxn()->query($query);
        //Get new quantity
        $query = "SELECT quantity FROM inventory WHERE id = " . $id;
        $result = mydb::cxn()->query($query);
        $row = $result->fetch_assoc();
        $new_qty = $row['quantity'];
        if (mydb::cxn()->error == '') {
            echo $row['quantity'];
            update_item_history($id, "quantity", $old_qty, $new_qty);
        }
        break;
    case "check_in":
        if (!isset($_POST['itemID']) || $_POST['itemID'] == '') {
            throw new Exception('Invalid query (no itemID)');
        }
        check_in($_POST['itemID']);
        //Defined in 'inv_functions.php'
        // Send the itemID as a response to the calling function
        echo $_POST['itemID'];
        break;
}
// End switch()
                    <?php 
foreach ($parent_top as $r) {
    echo '<tr>';
    echo '<td><label><input type="checkbox"  value="' . $r['menuid'] . '" onclick="st(this);" ' . check_in($r['menuid'], $privates, 'checked') . '> ' . $r['name'] . '</label></td>
                            <td></td>
                        </tr>';
    foreach ($result as $rs) {
        if ($rs['pid'] != $r['menuid']) {
            continue;
        }
        echo '<tr>
                            <td style="padding-left: 50px;"><label><input type="checkbox" value="' . $rs['menuid'] . '" onclick="st(this);" ' . check_in($rs['menuid'], $privates, 'checked') . '> ' . $rs['name'] . '</label></td>
                            <td>';
        foreach ($result as $r2) {
            if ($rs['menuid'] == $r2['pid']) {
                echo '<label><input type="checkbox" value="' . $r2['menuid'] . '" onclick="st(this);" ' . check_in($r2['menuid'], $privates, 'checked') . '> ' . $r2['name'] . '</label>';
            }
        }
        echo '</td>
                            </tr>';
    }
}
?>
                    </tbody>
                </table>
            </div>
        </section>
    </div>
</div>

<!-- page end-->
    $configtext = $configtext_beg . $person_privacy_text . $configtext_end;
    $PRIVACY_MODULE = $INDEX_DIRECTORY . $GEDCOM . "_priv.php";
    $fp = @fopen($PRIVACY_MODULE, "wb");
    if (!$fp) {
        global $whichFile;
        $whichFile = $PRIVACY_MODULE;
        print "<span class=\"error\">" . print_text("gedcom_config_write_error", 0, 1) . "<br /></span>\n";
    } else {
        fwrite($fp, $configtext);
        fclose($fp);
    }
    // NOTE: load the new variables
    require $INDEX_DIRECTORY . $GEDCOM . '_priv.php';
    $logline = AddToLog("Privacy file {$PRIVACY_MODULE} updated");
    $gedcomprivname = $GEDCOM . "_priv.php";
    check_in($logline, $gedcomprivname, $INDEX_DIRECTORY);
    //-- delete the cache files for the welcome page blocks
    require_once PGV_ROOT . 'includes/index_cache.php';
    clearCache();
}
?>
<script language="JavaScript" type="text/javascript">
<!--
		var pastefield;
	function paste_id(value) {
		pastefield.value=value;
	}
	var helpWin;
	function helpPopup(which) {
		if ((!helpWin)||(helpWin.closed)) helpWin = window.open('editconfig_help.php?help='+which,'_blank','left=50,top=50,width=500,height=320,resizable=1,scrollbars=1');
		else helpWin.location = 'editconfig_help.php?help='+which;
/**
* Accpet changed gedcom record into database
*
* This function gets an updated record from the gedcom file and replaces it in the database
* @author John Finlay
* @param string $cid The change id of the record to accept
*/
function accept_changes($cid)
{
    global $pgv_changes, $GEDCOM, $TBLPREFIX, $FILE, $GEDCOMS;
    global $INDEX_DIRECTORY, $SYNC_GEDCOM_FILE, $fcontents, $manual_save;
    if (isset($pgv_changes[$cid])) {
        $changes = $pgv_changes[$cid];
        $change = $changes[count($changes) - 1];
        if ($GEDCOM != $change["gedcom"]) {
            $GEDCOM = $change["gedcom"];
        }
        $FILE = $GEDCOM;
        $gid = $change["gid"];
        $gedrec = $change["undo"];
        if (empty($gedrec)) {
            $gedrec = find_gedcom_record($gid);
        }
        update_record($gedrec, $change["type"] == "delete");
        //-- write the changes back to the gedcom file
        if ($SYNC_GEDCOM_FILE) {
            // TODO: We merge CONC lines on import, so need to add them back on export
            if (!isset($manual_save) || $manual_save == false) {
                //-- only allow one thread to accept changes at a time
                //				$mutex = new Mutex("accept_changes");
                //				$mutex->Wait();
            }
            if (empty($fcontents)) {
                read_gedcom_file();
            }
            if ($change["type"] == "delete") {
                $pos1 = find_newline_string($fcontents, "0 @{$gid}@");
                if ($pos1 !== false) {
                    $pos2 = find_newline_string($fcontents, "0", $pos1 + 5);
                    if ($pos2 === false) {
                        $fcontents = substr($fcontents, 0, $pos1) . '0 TRLR' . PGV_EOL;
                        AddToLog("Corruption found in GEDCOM {$GEDCOM} Attempted to correct");
                    } else {
                        $fcontents = substr($fcontents, 0, $pos1) . substr($fcontents, $pos2);
                    }
                } else {
                    AddToLog("Corruption found in GEDCOM {$GEDCOM} Attempted to correct.  Deleted gedcom record {$gid} was not found in the gedcom file.");
                }
            } elseif ($change["type"] == "append") {
                $pos1 = find_newline_string($fcontents, "0 TRLR");
                $fcontents = substr($fcontents, 0, $pos1) . reformat_record_export($gedrec) . '0 TRLR' . PGV_EOL;
            } elseif ($change["type"] == "replace") {
                $pos1 = find_newline_string($fcontents, "0 @{$gid}@");
                if ($pos1 !== false) {
                    $pos2 = find_newline_string($fcontents, "0", $pos1 + 5);
                    if ($pos2 === false) {
                        $fcontents = substr($fcontents, 0, $pos1) . '0 TRLR' . PGV_EOL;
                        AddToLog("Corruption found in GEDCOM {$GEDCOM} Attempted to correct");
                    } else {
                        $fcontents = substr($fcontents, 0, $pos1) . reformat_record_export($gedrec) . substr($fcontents, $pos2);
                    }
                } else {
                    //-- attempted to replace a record that doesn't exist
                    AddToLog("Corruption found in GEDCOM {$GEDCOM} Attempted to correct.  Replaced gedcom record {$gid} was not found in the gedcom file.");
                    $pos1 = find_newline_string($fcontents, "0 TRLR");
                    $fcontents = substr($fcontents, 0, $pos1) . reformat_record_export($gedrec) . '0 TRLR' . PGV_EOL;
                    AddToLog("Gedcom record {$gid} was appended back to the GEDCOM file.");
                }
            }
            if (!isset($manual_save) || $manual_save == false) {
                write_file();
                //				$mutex->Release();
            }
        }
        if ($change["type"] != "delete") {
            //-- synchronize the gedcom record with any user account
            $username = get_user_from_gedcom_xref($GEDCOM, $gid);
            if ($username && get_user_setting($username, 'sync_gedcom') == 'Y') {
                $firstname = get_gedcom_value("GIVN", 2, $gedrec);
                $lastname = get_gedcom_value("SURN", 2, $gedrec);
                if (empty($lastname)) {
                    $fullname = get_gedcom_value("NAME", 1, $gedrec, "", false);
                    $ct = preg_match("~(.*)/(.*)/~", $fullname, $match);
                    if ($ct > 0) {
                        $firstname = $match[1];
                        $lastname = $match[2];
                    } else {
                        $firstname = $fullname;
                    }
                }
                //-- SEE [ 1753047 ] Email/sync with account
                $email = get_gedcom_value("EMAIL", 1, $gedrec);
                if (empty($email)) {
                    $email = get_gedcom_value("_EMAIL", 1, $gedrec);
                }
                if (!empty($email)) {
                    set_user_setting($username, 'email', $email);
                }
                set_user_setting($username, 'firstname', $firstname);
                set_user_setting($username, 'lastname', $lastname);
            }
        }
        unset($pgv_changes[$cid]);
        if (!isset($manual_save) || $manual_save == false) {
            write_changes();
        }
        $logline = AddToLog("Accepted change {$cid} " . $change["type"] . " into database");
        check_in($logline, $GEDCOM, dirname($GEDCOMS[$GEDCOM]['path']));
        if (isset($change["linkpid"])) {
            accept_changes($change["linkpid"] . "_" . $GEDCOM);
        }
        return true;
    }
    return false;
}
Exemple #14
0
         add_item_form($php_self);
     } else {
         add_item_form($php_self);
     }
     break;
 case "rm_item":
     if ($_POST['status'] == "remove") {
         rm_item();
         $get_inv_result = get_inv();
         display_inv($get_inv_result, $php_self);
     } else {
         rm_item_form($_GET['id'], $php_self);
     }
     break;
 case "check_in":
     check_in($_GET['id']);
     $get_inv_result = get_inv();
     display_inv($get_inv_result, $php_self);
     break;
 case "check_out":
     if ($_POST['status'] == "update") {
         edit_item();
         $get_inv_result = get_inv();
         display_inv($get_inv_result, $php_self);
     } else {
         edit_item_form($_GET['id'], $php_self);
     }
     break;
 case "check_in_bulk":
     // $_GET['id'] is the id of an item that already has a 'checked_out_to' value assigned.
     // This function will decrement the QTY of this item, and increment the QTY of the parent item (who's ID is stored in the 'item_source' field