Ejemplo n.º 1
0
function is_valid_item_type_structure($s_item_type)
{
    if (is_exists_item_type($s_item_type)) {
        if (fetch_sfieldtype_item_attribute_type($s_item_type, 'TITLE')) {
            if (fetch_sfieldtype_item_attribute_type($s_item_type, 'STATUSTYPE')) {
                if (fetch_sfieldtype_item_attribute_type($s_item_type, 'STATUSCMNT')) {
                    if (fetch_sfieldtype_item_attribute_type($s_item_type, 'CATEGORY')) {
                        if (get_opendb_config_var('borrow', 'enable') !== FALSE && get_opendb_config_var('borrow', 'duration_support') !== FALSE) {
                            if (fetch_sfieldtype_item_attribute_type($s_item_type, 'DURATION')) {
                                // At this point all the required s_field_type mappings have been provided.
                                return TRUE;
                            }
                        } else {
                            // At this point $borrow functionality is not enabled, so we do not
                            // have to do anymore testing.
                            return TRUE;
                        }
                    }
                }
            }
        }
    }
    //else
    return FALSE;
}
Ejemplo n.º 2
0
function check_item_type_structure($s_item_type, &$error)
{
    if (is_exists_item_type($s_item_type)) {
        $missing_s_field_types = NULL;
        if (!fetch_sfieldtype_item_attribute_type($s_item_type, 'TITLE')) {
            $missing_s_field_types[] = 'TITLE';
        }
        if (!fetch_sfieldtype_item_attribute_type($s_item_type, 'STATUSTYPE')) {
            $missing_s_field_types[] = 'STATUSTYPE';
        }
        if (!fetch_sfieldtype_item_attribute_type($s_item_type, 'STATUSCMNT')) {
            $missing_s_field_types[] = 'STATUSCMNT';
        }
        if (!fetch_sfieldtype_item_attribute_type($s_item_type, 'CATEGORY')) {
            $missing_s_field_types[] = 'CATEGORY';
        }
        if (get_opendb_config_var('borrow', 'enable') !== FALSE && get_opendb_config_var('borrow', 'duration_support') !== FALSE) {
            if (!fetch_sfieldtype_item_attribute_type($s_item_type, 'DURATION')) {
                $missing_s_field_types[] = 'DURATION';
            }
        }
        if (is_not_empty_array($missing_s_field_types)) {
            $error = array('error' => 'The following Field Type attribute relationships are missing.', 'detail' => $missing_s_field_types);
            return FALSE;
        } else {
            // No errors so no problem.
            return TRUE;
        }
    } else {
        // no message if s_item_type does not even exist.
        return FALSE;
    }
}
Ejemplo n.º 3
0
/**
	This function is to be called from listings.php, for either a s_item_type_group or
	s_item_type.  if s_item_type is defined, thats used first, otherwise we rely on
	s_item_type_group
*/
function get_s_item_listing_column_conf_rs($s_item_type_group, $s_item_type)
{
    $silc_id = NULL;
    if (strlen($s_item_type) > 0 && $s_item_type != '*' && is_exists_item_type($s_item_type)) {
        $silc_id = fetch_s_item_listing_conf_id(NULL, $s_item_type);
    } else {
        if (strlen($s_item_type_group) > 0 && $s_item_type_group != '*' && is_exists_item_type_group($s_item_type_group)) {
            $silc_id = fetch_s_item_listing_conf_id($s_item_type_group, NULL);
        }
    }
    if (!is_numeric($silc_id)) {
        // get the default
        $silc_id = fetch_s_item_listing_conf_id(NULL, NULL);
    }
    if (is_exists_s_item_listing_column_conf($silc_id)) {
        $results = fetch_s_item_listing_column_conf_rs($silc_id);
        if ($results) {
            while ($item_listing_column_conf_r = db_fetch_assoc($results)) {
                // special indicator that this column is an item listings configuration column and should be
                // left in the listings page even if exact match on this column is being performed.
                $item_listing_column_conf_r['item_listing_conf_ind'] = 'Y';
                $item_listing_column_conf_rs[] = $item_listing_column_conf_r;
            }
            db_free_result($results);
        }
        return $item_listing_column_conf_rs;
    } else {
        return array(array(column_type => 's_field_type', s_field_type => 'TITLE'), array(column_type => 'action_links'), array(column_type => 's_field_type', s_field_type => 'OWNER'), array(column_type => 's_field_type', s_field_type => 'STATUSTYPE'), array(column_type => 's_field_type', s_field_type => 'CATEGORY'));
    }
}
Ejemplo n.º 4
0
 /**
  * need to work out page_no, items_per_page, offset, etc
  *
  * This method will set the $this->_is_next_page and $this->is_previous_page
  * flags.
  */
 function _queryListing(&$HTTP_VARS)
 {
     // reset errors
     $this->_errors = NULL;
     $at_least_one_search_field_populated = FALSE;
     $input_field_values_r = array();
     $this->_search_query = NULL;
     // need to get a list of all input field values to pass into the querySite call.
     $results = fetch_site_plugin_input_field_rs($this->_type);
     if ($results) {
         while ($input_field_r = db_fetch_assoc($results)) {
             if (isset($HTTP_VARS[$input_field_r['field']]) && strlen($HTTP_VARS[$input_field_r['field']]) > 0) {
                 $field_value = trim($HTTP_VARS[$input_field_r['field']]);
                 $at_least_one_search_field_populated = TRUE;
                 if ($input_field_r['field_type'] == 'scan-isbn' || $input_field_r['field_type'] == 'scan-upc') {
                     // Determine type of scanner.
                     if (strrpos($HTTP_VARS[$input_field_r['field']], '.')) {
                         // cuecat
                         if ($input_field_r['field_type'] == 'scan-isbn') {
                             $scanCode = get_cuecat_isbn_code($field_value);
                         } else {
                             $scanCode = get_cuecat_upc_code($field_value);
                         }
                     } else {
                         //non-cuecat or modified cuecat
                         if ($input_field_r['field_type'] == 'scan-isbn') {
                             $scanCode = get_isbn_code($field_value);
                         } else {
                             $scanCode = get_upc_code($field_value);
                         }
                     }
                     if ($scanCode !== FALSE) {
                         $field_value = $scanCode;
                     }
                 }
                 $input_field_values_r[$input_field_r['field']] = $field_value;
                 $this->_search_query[] = array('field' => $input_field_r['field'], 'value' => $field_value, 'prompt' => $input_field_r['prompt'], 'field_type' => $input_field_r['field_type']);
             }
         }
         //while
         db_free_result($results);
     }
     // only continue if at least one input field was populated with a value.
     if ($at_least_one_search_field_populated) {
         unset($this->_item_list_rs);
         // initialise if not set.
         if (!is_numeric($HTTP_VARS['page_no'])) {
             $this->_page_no = 1;
         } else {
             $this->_page_no = $HTTP_VARS['page_no'];
         }
         if ($this->_page_no > 1) {
             $this->_is_previous_page = TRUE;
         } else {
             $this->_is_previous_page = FALSE;
         }
         // default, must be overriden by the individual plugins.
         $this->_is_next_page = FALSE;
         $offset = 0;
         if ($this->_items_per_page > 0 && $this->_page_no > 1) {
             $offset = $this->_items_per_page * ($HTTP_VARS['page_no'] - 1) + 1;
         }
         $this->_total_count = 0;
         // if its not a legal type, don't pass it on
         if (!is_exists_item_type($HTTP_VARS['s_item_type'])) {
             unset($HTTP_VARS['s_item_type']);
         }
         $this->_http_vars = $HTTP_VARS;
         // do not want to pass page_no through
         $this->_http_vars['page_no'] = NULL;
         // now at this point we need to grab the $items_per_page and
         // page_no values.
         if ($this->queryListing($this->_page_no, $this->_items_per_page, $offset, $HTTP_VARS['s_item_type'], $input_field_values_r)) {
             // no need for this anymore
             $this->_http_vars = NULL;
             // if a single item returned, we will populate the itemData at this point too
             if ($this->getRowCount() == 1 && $this->isPreviousPage() === FALSE) {
                 $rowData = $this->getRowData(0);
                 $this->_item_data_r = NULL;
                 // call the queryItem function directly here.
                 $return_val = $this->_queryItem($rowData['attributes'], $HTTP_VARS['s_item_type']);
                 if ($return_val) {
                     return TRUE;
                 } else {
                     return FALSE;
                 }
             } else {
                 // in some cases, the plugin will not be able to provide this
                 // information, but where it can, we can derive the is_next_page flag,
                 // other plugins, would have to call setNextPage() function instead.
                 if ($this->_items_per_page > 0 && $this->_total_count > $offset + $this->_items_per_page) {
                     $this->_is_next_page = TRUE;
                 }
                 // expect the call to querySite to set the is_next_page flag
                 return TRUE;
             }
         } else {
             // no need for this anymore
             $this->_http_vars = NULL;
             return FALSE;
         }
     } else {
         // if($at_least_one_search_field_populated)
         // nothing found.
         return TRUE;
     }
 }
Ejemplo n.º 5
0
 function __getItemTypeAttribs($s_item_type)
 {
     if (!is_array($this->_item_type_structure_rs[$s_item_type])) {
         if (is_exists_item_type($s_item_type)) {
             $results = fetch_item_attribute_type_rs($s_item_type, NULL, 's_attribute_type');
             if ($results) {
                 while ($item_attribute_type_r = db_fetch_assoc($results)) {
                     $this->_item_type_structure_rs[$s_item_type][] = $item_attribute_type_r;
                 }
                 db_free_result($results);
             }
         } else {
             return NULL;
         }
     }
     return $this->_item_type_structure_rs[$s_item_type];
 }
Ejemplo n.º 6
0
function insert_s_title_display_mask_item($stdm_id, $s_item_type_group, $s_item_type, $display_mask)
{
    if (strlen($stdm_id) > 0 && strlen($s_item_type_group) > 0 && strlen($s_item_type) > 0 && strlen($display_mask) > 0) {
        // ensure parent record exists
        if (is_exists_s_title_display_mask($stdm_id)) {
            if (($s_item_type_group == '*' || is_exists_item_type_group($s_item_type_group)) && ($s_item_type == '*' || is_exists_item_type($s_item_type))) {
                $query = "INSERT INTO s_title_display_mask_item (stdm_id, s_item_type_group, s_item_type, display_mask) " . "VALUES ('{$stdm_id}', '{$s_item_type_group}', '{$s_item_type}', '" . addslashes(trim(strip_tags($display_mask))) . "')";
                $insert = db_query($query);
                if ($insert && db_affected_rows() > 0) {
                    opendb_logger(OPENDB_LOG_INFO, __FILE__, __FUNCTION__, NULL, array($stdm_id, $s_item_type_group, $s_item_type, $display_mask));
                    return TRUE;
                } else {
                    opendb_logger(OPENDB_LOG_ERROR, __FILE__, __FUNCTION__, db_error(), array($stdm_id, $s_item_type_group, $s_item_type, $display_mask));
                    return FALSE;
                }
            } else {
                opendb_logger(OPENDB_LOG_ERROR, __FILE__, __FUNCTION__, 'Invalid s_item_type_group or s_item_type', array($stdm_id, $s_item_type_group, $s_item_type, $display_mask));
                return FALSE;
            }
        } else {
            opendb_logger(OPENDB_LOG_ERROR, __FILE__, __FUNCTION__, 'Parent s_title_display_mask not found', array($stdm_id, $s_item_type_group, $s_item_type, $display_mask));
            return FALSE;
        }
    }
    //else
    return FALSE;
}
Ejemplo n.º 7
0
 if ($HTTP_VARS['op'] == 'update_site_plugin_item_types') {
     $site_plugin_r = fetch_site_plugin_r($HTTP_VARS['site_type']);
     if (is_not_empty_array($site_plugin_r)) {
         $results = fetch_site_attribute_type_rs($HTTP_VARS['site_type']);
         if ($results) {
             $site_attribute_type_r = array();
             while ($site_plugin_attribute_type_r = db_fetch_assoc($results)) {
                 $site_attribute_type_r[] = $site_plugin_attribute_type_r['s_attribute_type'];
             }
             db_free_result($results);
         }
         if (is_not_empty_array($site_attribute_type_r)) {
             if (is_not_empty_array($HTTP_VARS['s_item_type'])) {
                 reset($HTTP_VARS['s_item_type']);
                 while (list($v_s_item_type, $value) = each($HTTP_VARS['s_item_type'])) {
                     if (is_exists_item_type($v_s_item_type)) {
                         // now we need to transfer in
                         if ($value == 'exclude') {
                             $site_item_attribute_type_rs = array();
                             // so this is the list of attributes currently attached to the s_item_type
                             $results2 = fetch_site_item_attribute_type_rs($HTTP_VARS['site_type'], $v_s_item_type);
                             if ($results2) {
                                 while ($attribute_type_r = db_fetch_assoc($results2)) {
                                     $site_item_attribute_type_rs[] = $attribute_type_r;
                                 }
                                 db_free_result($results2);
                             }
                             $delete = TRUE;
                             reset($site_item_attribute_type_rs);
                             while (list(, $site_item_attribute_type_r) = each($site_item_attribute_type_rs)) {
                                 if (!is_s_item_attribute_type_deletable($v_s_item_type, $site_item_attribute_type_r['s_attribute_type'], $site_item_attribute_type_r['order_no'])) {
Ejemplo n.º 8
0
                    //delete parent too
                    delete_s_item_listing_conf($HTTP_VARS['silc_id']);
                }
            }
        }
        $HTTP_VARS['op'] = 'edit';
    } else {
        //if(is_exists_s_item_listing_conf($HTTP_VARS['silc_id']))
        // error no item found!
        $HTTP_VARS['op'] = '';
    }
}
// in edit mode, either its a new entry, in which case s_item_type_group / s_item_type is chosen, or its
// an existing item, in which case the silc_id will be provided.
if ($HTTP_VARS['op'] == 'edit') {
    if (($HTTP_VARS['s_item_type_group'] == '*' || is_exists_item_type_group($HTTP_VARS['s_item_type_group'])) && ($HTTP_VARS['s_item_type'] == '*' || is_exists_item_type($HTTP_VARS['s_item_type']))) {
        echo get_javascript("admin/s_item_listing_conf/rowutils.js");
        echo '<style>
					.dataHighlight {background-color: #BDC7F7;font-size: x-small;font-weight: normal;font-family: Verdana, Arial, Helvetica, sans-serif; padding-left: 4px; padding-right: 4px;}
			</style>';
        echo "<p>[<a href=\"{$PHP_SELF}?type={$ADMIN_TYPE}\">Back to Main</a>]</p>";
        if ($HTTP_VARS['s_item_type_group'] != '*') {
            echo "\n<h3>Edit Item Type Group " . $HTTP_VARS['s_item_type_group'] . " Item Listing Configuration</h3>";
        } else {
            if ($HTTP_VARS['s_item_type'] != '*') {
                echo "\n<h3>Edit Item Type " . $HTTP_VARS['s_item_type'] . " Item Listing Configuration</h3>";
            } else {
                echo "\n<h3>Edit Default Item Listing Configuration</h3>";
            }
        }
        if (is_not_empty_array($errors)) {
Ejemplo n.º 9
0
function insert_s_item_listing_conf($s_item_type_group, $s_item_type)
{
    if (strlen($s_item_type_group) > 0 && strlen($s_item_type) > 0) {
        if (($s_item_type_group == '*' || is_exists_item_type_group($s_item_type_group)) && ($s_item_type == '*' || is_exists_item_type($s_item_type))) {
            $query = "INSERT INTO s_item_listing_conf (s_item_type_group, s_item_type) " . "VALUES ('{$s_item_type_group}', '{$s_item_type}')";
            $insert = db_query($query);
            if ($insert && db_affected_rows() > 0) {
                $new_sequence_number = db_insert_id();
                opendb_logger(OPENDB_LOG_INFO, __FILE__, __FUNCTION__, NULL, array($s_item_type_group, $s_item_type));
                return $new_sequence_number;
            } else {
                opendb_logger(OPENDB_LOG_ERROR, __FILE__, __FUNCTION__, db_error(), array($s_item_type_group, $s_item_type));
                return FALSE;
            }
        } else {
            return FALSE;
        }
    }
    //else
    return FALSE;
}
Ejemplo n.º 10
0
function perform_cloneitem_process(&$item_r, &$status_type_r, &$HTTP_VARS, &$footer_links_r)
{
    global $PHP_SELF;
    if (!is_exists_item_type($HTTP_VARS['s_item_type'])) {
        do_op_title($item_r, $status_type_r, 'clone_item');
        echo '<form action="' . $PHP_SELF . '">';
        echo '<input type="hidden" name="op" value="clone_item">';
        echo '<input type="hidden" name="item_id" value="' . $item_r['item_id'] . '">';
        echo '<input type="hidden" name="instance_no" value="' . $item_r['instance_no'] . '">';
        echo '<table class="cloneItemForm">';
        echo '<tr><th class="prompt">' . get_opendb_lang_var('item_type') . '</th>' . '<td class="data">' . custom_select('s_item_type', fetch_item_type_rs(), '%s_item_type% - %description%', '1', $item_r['s_item_type'], 's_item_type', NULL, NULL, NULL, FALSE, 'clone-s_item_type') . '</td></tr>';
        echo '</table>';
        echo '<input type="submit" class="submit" value="' . get_opendb_lang_var('submit') . '">';
        echo '</form>';
        echo format_help_block(get_opendb_lang_var('clone_item_help'));
        $footer_links_r[] = array(url => "item_display.php?item_id=" . $item_r['item_id'] . "&instance_no=" . $item_r['instance_no'], text => get_opendb_lang_var('back_to_item'));
    } else {
        // at this point we need to populate $HTTP_VARS with all data corresponding to a mapping between the old and possible new item type
        $HTTP_VARS = array_merge($HTTP_VARS, copy_item_to_http_vars($item_r, $HTTP_VARS['s_item_type']));
        // insert item for item type as specified in previous dialog
        $item_r['s_item_type'] = $HTTP_VARS['s_item_type'];
        do_op_title($item_r, $status_type_r, 'clone_item');
        $item_r['title'] = NULL;
        // fix for clone reverting to source item on insert.
        $item_r['item_id'] = NULL;
        $item_r['instance_no'] = NULL;
        $errors = NULL;
        $formContents = handle_new_or_site($HTTP_VARS['op'], $item_r, $status_type_r, $HTTP_VARS, $errors);
        if ($formContents !== FALSE) {
            echo $formContents;
        } else {
            echo format_error_block($errors);
        }
    }
}
Ejemplo n.º 11
0
 function is_not_exists_item_type($type)
 {
     return !is_exists_item_type($type, FALSE);
 }