Exemplo n.º 1
0
         $listingObject->addHeaderColumn(get_opendb_lang_var('overdue_duration'));
     } else {
         if ($HTTP_VARS['op'] == 'my_borrowed' || $HTTP_VARS['op'] == 'all_borrowed' || $HTTP_VARS['op'] == 'owner_borrowed') {
             $listingObject->addHeaderColumn(get_opendb_lang_var('due_date'), 'due_date');
         } else {
             // reserved!
             $listingObject->addHeaderColumn(get_opendb_lang_var('borrow_duration'));
         }
     }
 }
 $listingObject->addHeaderColumn(get_opendb_lang_var('more_information'));
 // If mysql resultset or static $item_reservation_rs array defined, we can continue.
 if ($result) {
     while ($borrowed_item_r = db_fetch_assoc($result)) {
         $listingObject->startRow();
         $status_type_r = fetch_status_type_r($borrowed_item_r['s_status_type']);
         if ($checkbox_column !== FALSE) {
             if ($HTTP_VARS['op'] == 'my_reserve_basket' || $HTTP_VARS['op'] == 'my_reserved' || $HTTP_VARS['op'] == 'owner_borrowed' || $HTTP_VARS['op'] == 'owner_reserved' && !is_item_borrowed($borrowed_item_r['item_id'], $borrowed_item_r['instance_no'])) {
                 $listingObject->addCheckboxColumn($borrowed_item_r['sequence_number'], FALSE);
             } else {
                 $listingObject->addColumn();
             }
         }
         if ($HTTP_VARS['op'] != 'my_item_history') {
             // Type
             $listingObject->addItemTypeImageColumn($borrowed_item_r['s_item_type']);
             if ($HTTP_VARS['op'] == 'my_borrowed' || $HTTP_VARS['op'] == 'my_history') {
                 $listingObject->addTitleColumn($borrowed_item_r);
             } else {
                 $listingObject->addTitleColumn($borrowed_item_r);
             }
Exemplo n.º 2
0
 function endItem()
 {
     if ($this->_is_item_finished !== TRUE) {
         if ($this->_item_obj != NULL) {
             // instance was not closed, close it now!
             if ($this->_is_item_instance) {
                 $this->_is_item_instance = FALSE;
             }
             // if not item instance, create one
             if (is_empty_array($this->_instance_item_obj_rs)) {
                 $this->startItemInstance();
                 $this->endItemInstance();
             }
             // The item is finished, no more additions are allowed, until the
             // startItem method is called again.
             $this->_is_item_finished = TRUE;
             $item_vars = $this->__getItemHTTPVars($this->_item_obj);
             $item_vars['trial_run'] = $this->_cfg_is_trial_run ? 'true' : 'false';
             $item_vars['confirmed'] = $this->_cfg_ignore_duplicate_title ? 'true' : 'false';
             $item_r = array(s_item_type => $this->_item_obj->getItemType(), owner_id => $this->getOwner(), title => $this->_item_obj->getTitle());
             $instance_valid = FALSE;
             $errors = array();
             $return_val = handle_item_insert($item_r, $item_vars, $errors);
             if ($return_val === TRUE) {
                 // store item id for later use
                 if ($this->_cfg_is_trial_run !== TRUE && is_numeric($item_r['item_id'])) {
                     $this->_item_id_list_r[] = $item_r['item_id'];
                 }
                 for ($i = 0; $i < count($this->_instance_item_obj_rs); $i++) {
                     $instanceObj = $this->_instance_item_obj_rs[$i];
                     // if status type is to be overriden, do it here!
                     if ($this->_cfg_override_status_type) {
                         $status_type_r = $this->_cfg_default_status_type_r;
                     } else {
                         $status_type_r = fetch_status_type_r($instanceObj->getStatusType());
                         // if illegal type, then override by default.
                         if ($status_type_r['closed_ind'] == 'Y') {
                             $status_type_r = $this->_cfg_default_status_type_r;
                         }
                     }
                     $item_r['owner_id'] = $instanceObj->getOwnerID();
                     $item_r['s_status_type'] = $status_type_r['s_status_type'];
                     $instance_vars = $this->__getItemHTTPVars($instanceObj);
                     // we are missing instance attributes if already set in item
                     $instance_vars = array_merge($instance_vars, $item_vars);
                     $return_val = handle_item_instance_insert($item_r, $status_type_r, $item_vars, $errors);
                     if ($return_val !== FALSE) {
                         $item_r['instance_no'] = $this->_cfg_is_trial_run ? $i + 1 : $item_r['instance_no'];
                         //$instanceObj->setInstanceNo($this->_cfg_is_trial_run?$i+1:$item_r['instance_no']);
                         $this->__listing_item_import_result_row($item_r, $status_type_r, $instance_vars, NULL);
                         // indicates at least one instance inserted.
                         $instance_valid = TRUE;
                     } else {
                         $item_r['instance_no'] = $this->_cfg_is_trial_run ? $i + 1 : $item_r['instance_no'];
                         //$instanceObj->setInstanceNo($this->_cfg_is_trial_run?$i+1:$item_r['instance_no']);
                         $this->__listing_item_import_result_row($item_r, $status_type_r, $instance_vars, $errors);
                     }
                 }
             } else {
                 $this->__listing_item_import_result_row($item_r, NULL, $item_vars, $errors);
             }
             $this->_item_obj = NULL;
             // end of parent item.
             return TRUE;
         } else {
             $this->_item_obj = NULL;
             $this->addError('endItem', get_opendb_lang_var('undefined_error'));
             return FALSE;
         }
     } else {
         // if($this->_is_item_finished !== TRUE)
         return FALSE;
     }
 }
Exemplo n.º 3
0
function handle_item_instance_update($item_r, $status_type_r, $HTTP_VARS, &$errors)
{
    if (is_not_empty_array($item_r)) {
        if ($item_r['owner_id'] == get_opendb_session_var('user_id') || is_user_granted_permission(PERM_ITEM_ADMIN)) {
            $update_status_type = $HTTP_VARS['s_status_type'];
            // Do not allow use of default s_status_type, it needs to be explicitly specified.
            if (strlen($update_status_type) > 0 && $item_r['s_status_type'] != $update_status_type) {
                $update_status_type_r = fetch_status_type_r($update_status_type);
            } else {
                // Otherwise s_status_type is not being udated
                $update_status_type = $status_type_r['s_status_type'];
                $update_status_type_r = $status_type_r;
                // current s_status_type
            }
            // If $update_status_type_r not defined, then we are not updating the s_status_type, only the status_comment
            if ($item_r['s_status_type'] == $update_status_type || is_update_status_type_valid($item_r['item_id'], $item_r['instance_no'], $item_r['owner_id'], $status_type_r, $update_status_type_r, $errors)) {
                // assume validation attribute function converts borrow duration to a single element array.
                if (is_array($HTTP_VARS['borrow_duration']) && count($HTTP_VARS['borrow_duration']) == 1) {
                    $borrow_duration = $HTTP_VARS['borrow_duration'][0];
                } else {
                    $borrow_duration = $HTTP_VARS['borrow_duration'];
                }
                $borrow_duration = ifempty($borrow_duration, $item_r['borrow_duration']);
                if (!is_numeric($borrow_duration)) {
                    $borrow_duration = FALSE;
                    // Not defined, so do not update
                }
                $status_comment = $HTTP_VARS['status_comment'];
                // trigger change owner processing at this point.
                if (strlen($HTTP_VARS['owner_id']) && $HTTP_VARS['owner_id'] != $item_r['owner_id']) {
                    if ($status_type_r['change_owner_ind'] == 'Y') {
                        if (!is_item_borrowed($item_r['item_id'], $item_r['instance_no'])) {
                            if (!update_item_instance_owner($item_r['item_id'], $item_r['instance_no'], $item_r['owner_id'], $HTTP_VARS['owner_id'])) {
                                $errors = array('error' => get_opendb_lang_var('item_instance_owner_not_changed'));
                            }
                        } else {
                            $errors = array('error' => get_opendb_lang_var('item_instance_owner_not_changed'));
                        }
                    } else {
                        $errors = array('error' => get_opendb_lang_var('operation_not_avail_change_owner'), 'detail' => '');
                    }
                }
                if (update_item_instance($item_r['item_id'], $item_r['instance_no'], $update_status_type, $status_comment, $borrow_duration)) {
                    handle_item_attributes('updateinstance', $item_r, $HTTP_VARS, $errors);
                    return TRUE;
                } else {
                    $db_error = db_error();
                    $errors = array('error' => get_opendb_lang_var('item_instance_not_updated'), 'detail' => $db_error);
                    return FALSE;
                }
            } else {
                return FALSE;
            }
        } else {
            $errors = array('error' => get_opendb_lang_var('cannot_update_item_not_owned'), detail => '');
            opendb_logger(OPENDB_LOG_WARN, __FILE__, __FUNCTION__, 'User attempted to update item instance they do not own', $item_r);
            return FALSE;
        }
    } else {
        //if(is_not_empty_array($item_r))
        $errors = array('error' => get_opendb_lang_var('item_not_found'), 'detail' => '');
        return FALSE;
    }
}
Exemplo n.º 4
0
function is_item_instance_checkoutable($item_instance_r, &$errors)
{
    if (!is_item_borrowed($item_instance_r['item_id'], $item_instance_r['instance_no'])) {
        $status_type_r = fetch_status_type_r($item_instance_r['s_status_type']);
        if ($status_type_r['borrow_ind'] == 'Y') {
            return TRUE;
        } else {
            if (is_array($status_type_r)) {
                $errors[] = get_opendb_lang_var('s_status_type_items_cannot_be_borrowed', 's_status_type_desc', $status_type_r['description']);
            } else {
                $errors[] = get_opendb_lang_var('invalid_s_status_type', 's_status_type', $item_instance_r['s_status_type']);
            }
        }
    } else {
        $errors[] = get_opendb_lang_var('item_is_already_checked_out');
    }
    //else
    return FALSE;
}
Exemplo n.º 5
0
                    $errors[] = array('error' => 'Invalid Status Type specified');
                }
                $HTTP_VARS['op'] = 'new';
            }
        } else {
            if ($HTTP_VARS['op'] == 'installsql') {
                execute_sql_install($ADMIN_TYPE, $HTTP_VARS['sqlfile'], $errors);
                $HTTP_VARS['op'] = NULL;
            }
        }
    }
}
if ($HTTP_VARS['op'] == 'new' || $HTTP_VARS['op'] == 'edit') {
    echo "<p>[<a href=\"{$PHP_SELF}?type={$ADMIN_TYPE}\">Back to Main</a>]</p>";
    if ($HTTP_VARS['op'] == 'edit') {
        $status_type_r = fetch_status_type_r($HTTP_VARS['s_status_type']);
        if ($status_type_r === FALSE) {
            $errors[] = 'Status Type (' . $HTTP_VARS['s_status_type'] . ') not found';
        }
        echo "\n<h3>Edit Status Type</h3>";
        $save_op = 'update';
        $save_button = 'Update';
    } else {
        echo "\n<h3>New Status Type</h3>";
        $save_op = 'insert';
        $save_button = 'Insert';
    }
    if (is_not_empty_array($errors)) {
        echo format_error_block($errors);
    }
    echo "\n<form name=\"s_status_type\" action=\"{$PHP_SELF}\" method=\"POST\">";
Exemplo n.º 6
0
/**
* Used by all insert/update item_instance functions to make sure the data is valid.  Will
* also update $status_comment / $borrow_duration and set them to a legal value for the
* specified $s_status_type
*/
function validate_item_instance_fields($s_status_type, &$status_comment, &$borrow_duration)
{
    // At this point, a specific $s_status_type MUST be supplied.
    if (strlen($s_status_type) > 0) {
        $status_type_r = fetch_status_type_r($s_status_type);
    }
    if (is_not_empty_array($status_type_r)) {
        // A $borrow_duration explicitly set to FALSE, is
        // an indication that nothing should be done with it.
        if ($borrow_duration !== FALSE && $borrow_duration !== NULL) {
            //if already null, no need to check again.
            // Ensure we have a valid $borrow_duration
            if (is_numeric($borrow_duration)) {
                //column cannot handle more than 999
                if ($borrow_duration > 999) {
                    $borrow_duration = '999';
                }
            } else {
                $borrow_duration = NULL;
            }
        }
        $status_comment = addslashes(substr(replace_newlines(trim(strip_tags($status_comment))), 0, 255));
        return TRUE;
    } else {
        opendb_logger(OPENDB_LOG_ERROR, __FILE__, __FUNCTION__, 'Invalid Status Type', array($s_status_type));
        return FALSE;
    }
}
Exemplo n.º 7
0
function get_search_query_matrix($HTTP_VARS)
{
    function get_match_type($match)
    {
        if ($match == 'word') {
            return get_opendb_lang_var('word_match');
        } else {
            if ($match == 'partial') {
                return get_opendb_lang_var('partial_match');
            } else {
                if ($match == 'exact') {
                    return get_opendb_lang_var('exact_match');
                } else {
                    return NULL;
                }
            }
        }
    }
    $searches = array();
    if (strlen($HTTP_VARS['title']) > 0) {
        // Default title match is exact match.
        $HTTP_VARS['title_match'] = ifempty($HTTP_VARS['title_match'], 'exact');
        if ($HTTP_VARS['title_match'] == 'word' || $HTTP_VARS['title_match'] == 'partial') {
            if (is_null($HTTP_VARS['title_case'])) {
                $searches[] = array(prompt => get_opendb_lang_var('title') . ' (<em>' . get_match_type($HTTP_VARS['title_match']) . '</em>)', field => $HTTP_VARS['title']);
            } else {
                $searches[] = array(prompt => get_opendb_lang_var('title') . ' (<em>' . get_match_type($HTTP_VARS['title_match']) . ', ' . get_opendb_lang_var('case_sensitive') . '</em>)', field => $HTTP_VARS['title']);
            }
        } else {
            $searches[] = array(prompt => get_opendb_lang_var('title'), field => $HTTP_VARS['title']);
        }
    }
    if (strlen($HTTP_VARS['category']) > 0) {
        // If s_item_type defined, we can get at the s_attribute_type of the category value.
        if (strlen($HTTP_VARS['s_item_type']) > 0) {
            $attribute_type_r = fetch_sfieldtype_item_attribute_type_r($HTTP_VARS['s_item_type'], 'CATEGORY');
            $searches[] = array(prompt => get_opendb_lang_var('category'), field => get_item_display_field(NULL, $attribute_type_r, $HTTP_VARS['category'], FALSE));
        } else {
            $searches[] = array(prompt => get_opendb_lang_var('category'), field => $HTTP_VARS['category']);
        }
    }
    if (strlen($HTTP_VARS['owner_id']) > 0) {
        $username = fetch_user_name($HTTP_VARS['owner_id']);
        if (strlen($username) > 0) {
            $searches[] = array(prompt => get_opendb_lang_var('owner'), field => $username . ' (' . $HTTP_VARS['owner_id'] . ')');
        }
    }
    if (strlen($HTTP_VARS['s_item_type_group']) > 0) {
        $searches[] = array(prompt => get_opendb_lang_var('s_item_type_group'), field => $HTTP_VARS['s_item_type_group']);
    }
    if (is_array($HTTP_VARS['s_item_type'])) {
        $field = '';
        for ($i = 0; $i < count($HTTP_VARS['s_item_type']); $i++) {
            $item_type_r = fetch_item_type_r($HTTP_VARS['s_item_type'][$i]);
            $field .= theme_image($item_type_r['image'], $item_type_r['description'], 's_item_type');
        }
        $searches[] = array(prompt => get_opendb_lang_var('s_item_type'), field => $field);
    } else {
        if (strlen($HTTP_VARS['s_item_type']) > 0) {
            $item_type_r = fetch_item_type_r($HTTP_VARS['s_item_type']);
            $searches[] = array(prompt => get_opendb_lang_var('s_item_type'), field => theme_image($item_type_r['image'], $item_type_r['description'], 's_item_type'));
        }
    }
    if (is_numeric($HTTP_VARS['rating'])) {
        $attribute_type_r = fetch_cached_attribute_type_r('S_RATING');
        $searches[] = array(prompt => $attribute_type_r['prompt'], field => get_display_field($attribute_type_r['s_attribute_type'], NULL, 'review()', $HTTP_VARS['rating'], FALSE));
    }
    $attribute_type_r = NULL;
    if (strlen($HTTP_VARS['attribute_type']) > 0) {
        $attribute_type_r = fetch_cached_attribute_type_r($HTTP_VARS['attribute_type']);
        if (is_not_empty_array($attribute_type_r)) {
            $attribute_type_r['listing_link_ind'] = 'N';
            // Default title match is exact match.
            $HTTP_VARS['attr_match'] = ifempty($HTTP_VARS['attr_match'], 'exact');
            // Special category search, but ignore if category variable actually specified.
            if (strlen($HTTP_VARS['category']) == 0 && strlen($HTTP_VARS['attribute_val']) > 0 && $HTTP_VARS['attr_match'] == 'category') {
                // We do not want the Listing Link to be added to this display field
                $searches[] = array(prompt => $attribute_type_r['prompt'], field => get_item_display_field(NULL, $attribute_type_r, stripslashes($HTTP_VARS['attribute_val']), FALSE));
            } else {
                if (strlen($HTTP_VARS['attribute_val']) > 0) {
                    $HTTP_VARS['attribute_val'] = stripslashes($HTTP_VARS['attribute_val']);
                    if (starts_with($HTTP_VARS['attribute_val'], '"') && ends_with($HTTP_VARS['attribute_val'], '"')) {
                        $HTTP_VARS['attribute_val'] = substr($HTTP_VARS['attribute_val'], 1, -1);
                    }
                    $search = ifempty(get_item_display_field(NULL, $attribute_type_r, $HTTP_VARS['attribute_val'], FALSE), $HTTP_VARS['attribute_val']);
                } else {
                    if (strlen($HTTP_VARS['lookup_attribute_val']) > 0) {
                        $search = get_item_display_field(NULL, $attribute_type_r, stripslashes($HTTP_VARS['lookup_attribute_val']), FALSE);
                    }
                }
                if (!is_lookup_attribute_type($HTTP_VARS['attribute_type']) && $HTTP_VARS['attr_match'] != 'exact') {
                    $searches[] = array(prompt => $attribute_type_r['prompt'] . ' (<em>' . get_match_type($HTTP_VARS['attr_match']) . '</em>)', field => $search);
                } else {
                    $searches[] = array(prompt => $attribute_type_r['prompt'], field => $search);
                }
            }
        }
        //if(is_not_empty_array($attribute_type_r))
    } else {
        if (strlen($HTTP_VARS['attribute_val']) > 0) {
            // specified a search term without attribute type, this is a global search.
            if (is_null($HTTP_VARS['attr_case'])) {
                $searches[] = array(prompt => get_opendb_lang_var('attribute_val') . ' (<em>' . get_match_type(ifempty($HTTP_VARS['attr_match'], 'exact')) . '</em>)', field => stripslashes($HTTP_VARS['attribute_val']));
            } else {
                $searches[] = array(prompt => get_opendb_lang_var('attribute_val') . ' (<em>' . get_match_type(ifempty($HTTP_VARS['attr_match'], 'exact')) . ', ' . get_opendb_lang_var('case_sensitive') . '</em>)', field => stripslashes($HTTP_VARS['attribute_val']));
            }
        }
    }
    // add another search field if update_on value also specified.
    if (strlen($HTTP_VARS['attr_update_on']) > 0) {
        if (is_not_empty_array($attribute_type_r)) {
            $prompt = get_opendb_lang_var('attribute_prompt_updated', array('s_attribute_type' => $attribute_type_r['s_attribute_type'], 'prompt' => $attribute_type_r['prompt']));
        } else {
            $prompt = get_opendb_lang_var('attributes_updated');
        }
        if (strlen($HTTP_VARS['datetimemask']) > 0) {
            $searches[] = array(prompt => $prompt, field => $HTTP_VARS['attr_update_on'] . ' (' . $HTTP_VARS['datetimemask'] . ')');
        } else {
            $searches[] = array(prompt => $prompt, field => $HTTP_VARS['attr_update_on']);
        }
    } else {
        if (is_numeric($HTTP_VARS['attr_update_on_days'])) {
            if (is_not_empty_array($attribute_type_r)) {
                $prompt = get_opendb_lang_var('attribute_prompt_updated', array('s_attribute_type' => $attribute_type_r['s_attribute_type'], 'prompt' => $attribute_type_r['prompt']));
            } else {
                $prompt = get_opendb_lang_var('attributes_updated');
            }
            if ($HTTP_VARS['attr_update_on_days'] == '1') {
                $field = get_opendb_lang_var('one_day_ago');
            } else {
                if ($HTTP_VARS['attr_update_on_days'] == '7') {
                    $field = get_opendb_lang_var('one_week_ago');
                } else {
                    if ($HTTP_VARS['attr_update_on_days'] == '28') {
                        $field = get_opendb_lang_var('one_month_ago');
                    } else {
                        if ($HTTP_VARS['attr_update_on_days'] == '365') {
                            $field = get_opendb_lang_var('one_year_ago');
                        }
                    }
                }
            }
            $searches[] = array(prompt => $prompt, field => $field);
        }
    }
    if (strlen($HTTP_VARS['update_on']) > 0) {
        if (strlen($HTTP_VARS['datetimemask']) > 0) {
            $searches[] = array(prompt => get_opendb_lang_var('updated'), field => $HTTP_VARS['update_on'] . ' (' . $HTTP_VARS['datetimemask'] . ')');
        } else {
            $searches[] = array(prompt => get_opendb_lang_var('updated'), field => $HTTP_VARS['update_on']);
        }
    } else {
        if (is_numeric($HTTP_VARS['update_on_days'])) {
            if ($HTTP_VARS['update_on_days'] == '1') {
                $field = get_opendb_lang_var('one_day_ago');
            } else {
                if ($HTTP_VARS['update_on_days'] == '7') {
                    $field = get_opendb_lang_var('one_week_ago');
                } else {
                    if ($HTTP_VARS['update_on_days'] == '28') {
                        $field = get_opendb_lang_var('one_month_ago');
                    } else {
                        if ($HTTP_VARS['update_on_days'] == '365') {
                            $field = get_opendb_lang_var('one_year_ago');
                        }
                    }
                }
            }
            $searches[] = array(prompt => get_opendb_lang_var('updated'), field => $field);
        }
    }
    if (is_not_empty_array($HTTP_VARS['s_status_type']) > 0) {
        $search = '';
        for ($i = 0; $i < count($HTTP_VARS['s_status_type']); $i++) {
            if (strlen($search) > 0) {
                $search .= ' ';
            }
            $status_type_r = fetch_status_type_r($HTTP_VARS['s_status_type'][$i]);
            if (is_not_empty_array($status_type_r)) {
                $search .= format_display_value('%img%', $status_type_r['img'], 'Y', $status_type_r['description'], 's_status_type');
            }
        }
        if (strlen($search) > 0) {
            $searches[] = array(prompt => get_opendb_lang_var('s_status_type'), field => $search);
        }
    }
    if (strlen($HTTP_VARS['status_comment']) > 0) {
        // Default status_comment match is exact match.
        $HTTP_VARS['status_comment_match'] = ifempty($HTTP_VARS['status_comment_match'], 'exact');
        if ($HTTP_VARS['status_comment_match'] == 'word' || $HTTP_VARS['status_comment_match'] == 'partial' || $HTTP_VARS['status_comment_match'] == 'exact') {
            if (is_null($HTTP_VARS['status_comment_case'])) {
                $searches[] = array(prompt => get_opendb_lang_var('status_comment') . ' (<em>' . get_match_type($HTTP_VARS['status_comment_match']) . '</em>)', field => $HTTP_VARS['status_comment']);
            } else {
                $searches[] = array(prompt => get_opendb_lang_var('status_comment') . ' (<em>' . get_match_type($HTTP_VARS['status_comment_match']) . ', ' . get_opendb_lang_var('case_sensitive') . '</em>)', field => $HTTP_VARS['status_comment']);
            }
        } else {
            $searches[] = array(prompt => get_opendb_lang_var('status_comment'), field => $HTTP_VARS['status_comment']);
        }
    }
    if (is_numeric($HTTP_VARS['interest_level']) && $HTTP_VARS['interest_level'] > 0) {
        $searches[] = array(prompt => get_opendb_lang_var('interest'), field => theme_image("interest_1.gif", get_opendb_lang_var('interest'), 's_item_type'));
    }
    return $searches;
}
Exemplo n.º 8
0
function get_related_items_listing($item_r, $HTTP_VARS, $related_mode)
{
    global $PHP_SELF;
    $buffer = '';
    $results = fetch_item_instance_relationship_rs($item_r['item_id'], $item_r['instance_no'], $related_mode);
    if ($results) {
        $listingObject = new HTML_Listing($PHP_SELF, $HTTP_VARS);
        $listingObject->setBufferOutput(TRUE);
        $listingObject->setNoRowsMessage(get_opendb_lang_var('no_items_found'));
        $listingObject->setShowItemImages(TRUE);
        $listingObject->setIncludeFooter(FALSE);
        $listingObject->addHeaderColumn(get_opendb_lang_var('type'), 'type', FALSE);
        $listingObject->addHeaderColumn(get_opendb_lang_var('title'), 'title', FALSE);
        $listingObject->addHeaderColumn(get_opendb_lang_var('action'), 'action', FALSE);
        $listingObject->addHeaderColumn(get_opendb_lang_var('status'), 'status', FALSE);
        $listingObject->addHeaderColumn(get_opendb_lang_var('status_comment'), 'status_comment', FALSE);
        $listingObject->addHeaderColumn(get_opendb_lang_var('category'), 'category', FALSE);
        $listingObject->startListing(NULL);
        while ($related_item_r = db_fetch_assoc($results)) {
            $listingObject->startRow();
            $listingObject->addItemTypeImageColumn($related_item_r['s_item_type']);
            $listingObject->addTitleColumn($related_item_r);
            $action_links_rs = NULL;
            if (is_user_granted_permission(PERM_ITEM_OWNER) && get_opendb_session_var('user_id') === $item_r['owner_id'] || is_user_granted_permission(PERM_ITEM_ADMIN)) {
                $action_links_rs[] = array(url => 'item_input.php?op=edit&item_id=' . $related_item_r['item_id'] . '&instance_no=' . $related_item_r['instance_no'], img => 'edit.gif', text => get_opendb_lang_var('edit'));
                if (get_opendb_config_var('listings', 'show_refresh_actions') && is_item_legal_site_type($related_item_r['s_item_type'])) {
                    $action_links_rs[] = array(url => 'item_input.php?op=site-refresh&item_id=' . $related_item_r['item_id'] . '&instance_no=' . $related_item_r['instance_no'], img => 'refresh.gif', text => get_opendb_lang_var('refresh'));
                }
                $action_links_rs[] = array(url => 'item_input.php?op=delete&item_id=' . $related_item_r['item_id'] . '&instance_no=' . $related_item_r['instance_no'] . '&parent_item_id=' . $item_r['item_id'] . '&parent_instance_no=' . $item_r['instance_no'], img => 'delete.gif', text => get_opendb_lang_var('delete'));
                $action_links_rs[] = array(url => 'item_input.php?op=delete-relation&item_id=' . $item_r['item_id'] . '&instance_no=' . $item_r['instance_no'] . '&parent_item_id=' . $related_item_r['item_id'] . '&parent_instance_no=' . $related_item_r['instance_no'], img => 'delete.gif', text => get_opendb_lang_var('delete_relationship'));
            }
            $listingObject->addActionColumn($action_links_rs);
            $status_type_r = fetch_status_type_r($related_item_r['s_status_type']);
            $listingObject->addThemeImageColumn($status_type_r['img'], $status_type_r['description'], $status_type_r['description'], 's_status_type');
            //type
            // If a comment is allowed and defined, add it in.
            if ($status_type_r['status_comment_ind'] == 'Y' || get_opendb_session_var('user_id') === $related_item_r['owner_id'] || is_user_granted_permission(PERM_ITEM_ADMIN)) {
                // support newlines in this field
                $listingObject->addColumn(nl2br($related_item_r['status_comment']));
            } else {
                $listingObject->addColumn(get_opendb_lang_var('not_applicable'));
            }
            $attribute_type_r = fetch_sfieldtype_item_attribute_type_r($related_item_r['s_item_type'], 'CATEGORY');
            if (is_array($attribute_type_r)) {
                if ($attribute_type_r['lookup_attribute_ind'] === 'Y') {
                    $attribute_val = fetch_attribute_val_r($related_item_r['item_id'], $related_item_r['instance_no'], $attribute_type_r['s_attribute_type'], $attribute_type_r['order_no']);
                } else {
                    $attribute_val = fetch_attribute_val($related_item_r['item_id'], $related_item_r['instance_no'], $attribute_type_r['s_attribute_type'], $attribute_type_r['order_no']);
                }
                $listingObject->addAttrDisplayColumn($related_item_r, $attribute_type_r, $attribute_val);
            }
            $listingObject->endRow();
        }
        $listingObject->endListing();
        $buffer =& $listingObject->getContents();
        unset($listingObject);
        return $buffer;
    } else {
        return NULL;
    }
}
Exemplo n.º 9
0
 // we want to display all items - no pagination.
 $HTTP_VARS['items_per_page'] = '';
 $listingObject = new HTML_Listing($PHP_SELF, $HTTP_VARS);
 $listingObject->setNoRowsMessage(get_opendb_lang_var('no_items_found'));
 $cfg_include_header_row = strcmp($HTTP_VARS['include_header_row'], 'Y') === 0 ? TRUE : FALSE;
 $cfg_ignore_duplicate_title = strcmp($HTTP_VARS['ignore_duplicate_title'], 'Y') === 0 ? TRUE : FALSE;
 $cfg_is_trial_run = strcmp($HTTP_VARS['trial_run'], 'Y') === 0 ? TRUE : FALSE;
 $cfg_override_status_type = strcmp($HTTP_VARS['override_status_type'], 'Y') === 0 ? TRUE : FALSE;
 // force disable of duplicate titles.
 set_opendb_config_ovrd_var('item_input', 'duplicate_title_support', $cfg_ignore_duplicate_title);
 set_opendb_config_ovrd_var('listings', 'show_item_image', FALSE);
 //set_opendb_config_ovrd_var('item_input', 'confirm_duplicate_insert', TRUE);
 if (is_valid_s_status_type($HTTP_VARS['s_status_type'])) {
     $cfg_default_status_type_r = fetch_status_type_r($HTTP_VARS['s_status_type']);
 } else {
     $cfg_default_status_type_r = fetch_status_type_r(fetch_default_status_type());
 }
 $itemImportHandler = new ItemImportHandler($HTTP_VARS['owner_id'], $cfg_is_trial_run, $cfg_ignore_duplicate_title, $cfg_override_status_type, $cfg_default_status_type_r, $listingObject);
 if (strcmp($HTTP_VARS['owner_id'], get_opendb_session_var('user_id')) === 0) {
     $page_title = get_opendb_lang_var('type_import', array('description' => $importPlugin->get_display_name()));
 } else {
     $page_title = get_opendb_lang_var('type_import_items_for_name', array('description' => $importPlugin->get_display_name(), 'fullname' => fetch_user_name($HTTP_VARS['owner_id']), 'user_id' => $HTTP_VARS['owner_id']));
 }
 echo _theme_header($page_title);
 echo "<h2>" . $page_title . "</h2>\n";
 echo get_import_choices_table($importPlugin, $cfg_include_header_row, $cfg_ignore_duplicate_title, $cfg_is_trial_run, $cfg_override_status_type, $cfg_default_status_type_r);
 $listingObject->startListing();
 $listingObject->addHeaderColumn('', 'flag', FALSE);
 // Success or Failure column
 $listingObject->addHeaderColumn(get_opendb_lang_var('type'), 's_item_type', FALSE);
 $listingObject->addHeaderColumn(get_opendb_lang_var('title'), 'title', FALSE);
Exemplo n.º 10
0
/**
* A handle_quick_checkout will only ever handle one request at a time, because
* they are initiated from item_display & listings.php, but not borrow.php
*/
function handle_quick_checkout($item_id, $instance_no, $borrower_id, $borrow_duration, $more_information, &$errors)
{
    if (!is_user_valid($borrower_id)) {
        $errors = get_opendb_lang_var('invalid_borrower_user', 'user_id', $borrower_id);
        return FALSE;
    } else {
        if (!is_user_granted_permission(PERM_USER_BORROWER, $borrower_id)) {
            $errors = get_opendb_lang_var('user_must_be_borrower', 'user_id', $borrower_id);
            return FALSE;
        } else {
            if (!is_user_allowed_to_checkout_item($item_id, $instance_no)) {
                $errors = get_opendb_lang_var('not_owner_of_item');
                return FALSE;
            } else {
                if (is_user_owner_of_item($item_id, $instance_no, $borrower_id) && get_opendb_config_var('borrow', 'owner_self_checkout') !== TRUE) {
                    $errors = get_opendb_lang_var('cannot_checkout_items_you_own');
                    return FALSE;
                } else {
                    if (is_item_borrowed($item_id, $instance_no)) {
                        $errors = get_opendb_lang_var('item_is_already_checked_out');
                        return FALSE;
                    }
                }
            }
        }
    }
    $sequence_number = fetch_borrowed_item_seq_no($item_id, $instance_no, 'R', $borrower_id);
    if ($sequence_number !== FALSE) {
        if (get_opendb_config_var('borrow', 'quick_checkout_use_existing_reservation') !== FALSE) {
            if (check_out_item($sequence_number, $borrow_duration, $more_information)) {
                return $sequence_number;
            } else {
                return FALSE;
            }
        } else {
            $errors = get_opendb_lang_var('user_has_reservation', 'user_id', $borrower_id);
            return FALSE;
        }
    } else {
        //if($sequence_number !== FALSE)
        $status_type_r = fetch_status_type_r(fetch_item_s_status_type($item_id, $instance_no));
        if ($status_type_r['borrow_ind'] == 'Y') {
            $new_borrowed_item_id = quick_check_out_item($item_id, $instance_no, $borrower_id, $borrow_duration, $more_information);
            if ($new_borrowed_item_id !== FALSE) {
                return $new_borrowed_item_id;
            } else {
                return FALSE;
            }
        } else {
            $errors = get_opendb_lang_var('s_status_type_items_cannot_be_borrowed', 's_status_type_desc', $status_type_r['description']);
            return FALSE;
        }
    }
}
Exemplo n.º 11
0
     } else {
         $item_r = array(item_id => NULL, title => NULL, s_item_type => trim($HTTP_VARS['s_item_type']));
     }
     $item_r['instance_no'] = NULL;
     // if a new copy / clone let insert process work out next instance no
     $item_r['owner_id'] = ifempty($HTTP_VARS['owner_id'], get_opendb_session_var('user_id'));
     $item_r['s_status_type'] = $status_type_r['s_status_type'];
     $item_r['status_comment'] = NULL;
 } else {
     //otherwise either a site refresh operation or an edit/update/delete
     $item_r = fetch_item_instance_r($HTTP_VARS['item_id'], $HTTP_VARS['instance_no']);
     // a new copy should be for the current user
     if ($HTTP_VARS['op'] == 'newinstance') {
         $item_r['owner_id'] = get_opendb_session_var('user_id');
     }
     $status_type_r = fetch_status_type_r($item_r['s_status_type']);
 }
 // Includes 'new' because we artificially construct an $item_r array.
 if (is_not_empty_array($item_r)) {
     // We need a valid $status_type_r as well at this point, and should not continue without it.
     if (is_not_empty_array($status_type_r)) {
         $footer_links_r = NULL;
         // construct single instance of this object to use throughout the script.
         $titleMaskCfg = new TitleMask('item_display');
         switch ($HTTP_VARS['op']) {
             case 'insert':
                 perform_insert_process($item_r, $status_type_r, $HTTP_VARS, $footer_links_r);
                 break;
             case 'delete':
                 perform_delete_process($item_r, $status_type_r, $HTTP_VARS, $footer_links_r);
                 break;