コード例 #1
0
ファイル: pre_process.php プロジェクト: siwiwit/PhreeBooksERP
         if ($_REQUEST['action'] == 'save' && $success) {
             $self_close = true;
         }
     }
     break;
 case 'save_dir':
     $doc_title = db_prepare_input($_POST['doc_title']);
     $doc_ext = db_prepare_input($_POST['doc_ext']);
     $doc_group = db_prepare_input($_POST['doc_group']);
     // check for valid folder name
     if (!$doc_title) {
         $messageStack->add(PHREEFORM_FOLDER_BLANK_ERROR, 'error');
         break;
     }
     // check to see if the directory is being moved below itself
     if (!validate_dir_move($dir_tree, $id, $parent_id)) {
         $messageStack->add(PHREEFORM_DIR_MOVE_ERROR, 'error');
         break;
     }
     $result = $db->Execute("select id from " . TABLE_PHREEFORM . " where doc_group = '" . $doc_group . "'");
     if ($result->RecordCount() > 0) {
         if ($result->fields['id'] != $id) {
             $messageStack->add(PHREEFORM_DIR_GROUP_DUP_ERROR, 'error');
             break;
         }
     }
     // insert/update db
     $sql_array = array('parent_id' => $parent_id, 'doc_title' => $doc_title, 'doc_type' => '0', 'doc_group' => $doc_group, 'doc_ext' => $doc_ext, 'security' => 'u:0;g:0', 'create_date' => date('Y-m-d'));
     if ($id) {
         // update
         db_perform(TABLE_PHREEFORM, $sql_array, 'update', 'id = ' . $id);
コード例 #2
0
ファイル: phreeform.php プロジェクト: siwiwit/PhreeBooksERP
function validate_dir_move($dir_tree, $id, $new_parent)
{
    if ($id != 0 && $new_parent == $id) {
        return false;
    }
    if ($dir_tree[$new_parent] != 0) {
        return validate_dir_move($dir_tree, $id, $dir_tree[$new_parent]);
    }
    return true;
}