Exemple #1
0
                     } else {
                         // reserved - item_history
                         $listingObject->addColumn(get_opendb_lang_var('not_applicable'));
                     }
                 }
             } else {
                 if ($HTTP_VARS['op'] == 'my_borrowed' || $HTTP_VARS['op'] == 'all_borrowed' || $HTTP_VARS['op'] == 'owner_borrowed') {
                     if (strlen($borrowed_item_r['due_date']) > 0) {
                         $listingObject->addColumn(get_localised_timestamp(get_opendb_config_var('borrow', 'date_mask'), $borrowed_item_r['due_date']));
                     } else {
                         $listingObject->addColumn(get_opendb_lang_var('undefined'));
                     }
                 } else {
                     // Reserved
                     if (is_numeric($borrowed_item_r['borrow_duration']) && $borrowed_item_r['borrow_duration'] > 0) {
                         $duration_attr_type_r = fetch_sfieldtype_item_attribute_type_r($borrowed_item_r['s_item_type'], 'DURATION');
                         $listingObject->addDisplayColumn($duration_attr_type_r['s_attribute_type'], NULL, $duration_attr_type_r['display_type'], $borrowed_item_r['borrow_duration']);
                     } else {
                         $listingObject->addColumn(get_opendb_lang_var('undefined'));
                     }
                 }
             }
         }
         $listingObject->addColumn(nl2br($borrowed_item_r['more_information']));
         $listingObject->endRow();
     }
     // End of while
     @db_free_result($result);
 }
 $listingObject->endListing();
 if ($listingObject->isCheckboxColumns() > 0) {
Exemple #2
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;
}
Exemple #3
0
     echo "<div id=\"checkOutListing\">";
     $listingObject->startListing($page_title);
     $listingObject->addHeaderColumn(get_opendb_lang_var('type'), 's_item_type');
     $listingObject->addHeaderColumn(get_opendb_lang_var('title'), 'title');
     $listingObject->addHeaderColumn(get_opendb_lang_var('owner'), 'owner');
     if (get_opendb_config_var('borrow', 'duration_support')) {
         $listingObject->addHeaderColumn(get_opendb_lang_var('borrow_duration'), 'borrow_duration', FALSE);
     }
     if (is_not_empty_array($altid_item_instance_rs)) {
         while (list(, $item_instance_r) = each($altid_item_instance_rs)) {
             $listingObject->startRow();
             $listingObject->addItemTypeImageColumn($item_instance_r['s_item_type']);
             $listingObject->addTitleColumn($item_instance_r);
             $listingObject->addUserNameColumn($item_instance_r['owner_id']);
             if (is_numeric($item_instance_r['borrow_duration']) && $item_instance_r['borrow_duration'] > 0) {
                 $duration_attr_type_r = fetch_sfieldtype_item_attribute_type_r($item_instance_r['s_item_type'], 'DURATION');
                 $listingObject->addDisplayColumn($duration_attr_type_r['s_attribute_type'], NULL, $duration_attr_type_r['display_type'], $item_instance_r['borrow_duration']);
             } else {
                 $listingObject->addColumn(get_opendb_lang_var('undefined'));
             }
             $listingObject->endRow();
         }
     }
     $listingObject->endListing();
     echo "</div>";
     echo "<ul class=\"listingControls\">";
     if (get_opendb_config_var('listings', 'allow_override_show_item_image') !== FALSE) {
         echo "<li>" . getToggleControl($PHP_SELF, $HTTP_VARS, get_opendb_lang_var('show_item_image'), 'show_item_image', ifempty($HTTP_VARS['show_item_image'], get_opendb_config_var('listings', 'show_item_image') == TRUE ? 'Y' : 'N')) . "</li>";
     }
     echo "</ul>";
 }
Exemple #4
0
        opendb_logger(OPENDB_LOG_ERROR, __FILE__, __FUNCTION__, 'Site plugin class not found', $HTTP_VARS);
    }
}
// *****************************************************************************
// MAIN PROCESS
// *****************************************************************************
if (is_site_enabled()) {
    @set_time_limit(600);
    if (is_opendb_valid_session()) {
        if (is_user_granted_permission(PERM_ITEM_OWNER) || is_user_granted_permission(PERM_ITEM_ADMIN)) {
            if (empty($HTTP_VARS['ajax_op'])) {
                // For a $op == ('site' OR 'site-search' OR 'site-add') where an item is actually defined,
                // it is really a 'refresh' site operation.
                if ($HTTP_VARS['op'] == 'new' || $HTTP_VARS['op'] == 'insert' || ($HTTP_VARS['op'] == 'site-search' || $HTTP_VARS['op'] == 'site-add' || $HTTP_VARS['op'] == 'site-refresh' || $HTTP_VARS['op'] == 'site') && !is_exists_item($HTTP_VARS['item_id'])) {
                    if (strlen($HTTP_VARS['s_status_type']) == 0) {
                        $status_attr_type_r = fetch_sfieldtype_item_attribute_type_r($HTTP_VARS['s_item_type'], 'STATUSTYPE');
                        $HTTP_VARS['s_status_type'] = $HTTP_VARS[get_field_name($status_attr_type_r['s_attribute_type'], $status_attr_type_r['order_no'])];
                    }
                    if (strlen($HTTP_VARS['s_status_type']) > 0) {
                        $status_type_r = fetch_status_type_r($HTTP_VARS['s_status_type']);
                    } else {
                        // Dummy array entry, as the s_status_type will be chosen in the edit form.
                        $status_type_r = array('borrow_ind' => 'Y');
                    }
                    // where we are making a copy of an existing item
                    if (is_exists_item($HTTP_VARS['item_id'])) {
                        $item_r = fetch_item_r($HTTP_VARS['item_id']);
                    } else {
                        $item_r = array(item_id => NULL, title => NULL, s_item_type => trim($HTTP_VARS['s_item_type']));
                    }
                    $item_r['instance_no'] = NULL;
Exemple #5
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;
    }
}
Exemple #6
0
function get_last_num_items_rs($num_of_items, $owner_id = NULL, $s_item_type = NULL, $update_on = NULL, $not_owner_id = NULL, $site_url_prefix = NULL, $title_mask_id = NULL)
{
    if (strlen($owner_id) > 0) {
        $search_vars_r['owner_id'] = $owner_id;
    }
    if (strlen($s_item_type) > 0) {
        $search_vars_r['s_item_type'] = $s_item_type;
    }
    if (strlen($update_on) > 0) {
        $search_vars_r['update_on'] = $update_on;
    }
    if (strlen($not_owner_id) > 0) {
        $search_vars_r['not_owner_id'] = $not_owner_id;
    }
    $dummy_r = NULL;
    $results = fetch_item_listing_rs($search_vars_r, $dummy_r, 'update_on', 'DESC', 0, $num_of_items);
    if ($results) {
        if ($title_mask_id == 'feeds') {
            $title_mask_group = array('feeds', 'item_display');
        } else {
            $title_mask_group = array('last_items_list', 'item_listing');
        }
        $titleMaskCfg = new TitleMask($title_mask_group);
        $image_attribute_type_rs = NULL;
        while ($item_r = db_fetch_assoc($results)) {
            $item_r['title'] = $titleMaskCfg->expand_item_title($item_r);
            $item_r['update_on'] = get_localised_timestamp(get_opendb_config_var('welcome.last_items_list', 'datetime_mask'), $item_r['update_on']);
            $item_r['item_display_url'] = 'item_display.php?item_id=' . $item_r['item_id'] . '&instance_no=' . $item_r['instance_no'];
            if ($site_url_prefix != NULL) {
                $item_r['item_display_url'] = $site_url_prefix . $item_r['item_display_url'];
            }
            $item_type_r = fetch_item_type_r($item_r['s_item_type']);
            $itemtypeimagesrc = theme_image_src($item_type_r['image']);
            $size = @getimagesize($itemtypeimagesrc);
            if (is_array($size)) {
                $item_r['itemtypeimage']['width'] = $size[0];
                $item_r['itemtypeimage']['height'] = $size[1];
            }
            $item_r['itemtypeimage']['url'] = $itemtypeimagesrc;
            if ($site_url_prefix != NULL) {
                $item_r['itemtypeimage']['url'] = $site_url_prefix . $item_r['itemtypeimage']['url'];
            }
            $item_r['itemtypeimage']['title'] = $item_type_r['description'];
            $item_r['itemtypeimage']['s_item_type'] = $item_r['s_item_type'];
            if (get_opendb_config_var('welcome.last_items_list', 'show_item_image') !== FALSE) {
                if (!is_array($image_attribute_type_rs) || !is_array($image_attribute_type_rs[$item_r['s_item_type']])) {
                    $image_attribute_type_rs[$item_r['s_item_type']] = fetch_sfieldtype_item_attribute_type_r($item_r['s_item_type'], 'IMAGE');
                }
                // of a IMAGE s_attribute defined for this s_item_type
                if (is_array($image_attribute_type_rs[$item_r['s_item_type']])) {
                    $attribute_type_r = $image_attribute_type_rs[$item_r['s_item_type']];
                    $imageurl = fetch_attribute_val($item_r['item_id'], NULL, $attribute_type_r['s_attribute_type']);
                    $file_r = file_cache_get_image_r($imageurl, 'display');
                    $item_r['imageurl']['url'] = $file_r['thumbnail']['url'];
                    if ($site_url_prefix != NULL) {
                        $item_r['imageurl']['url'] = $site_url_prefix . $item_r['imageurl']['url'];
                    }
                    $item_r['imageurl']['width'] = $file_r['thumbnail']['width'];
                    $item_r['imageurl']['height'] = $file_r['thumbnail']['height'];
                    $item_r['imageurl']['title'] = $item_r['title'];
                }
            }
            $item_rs[] = $item_r;
            unset($item_r);
        }
        //while
        db_free_result($results);
    }
    return $item_rs;
}
Exemple #7
0
 /**
  * @param $item_r
  */
 function addTitleColumn($item_r)
 {
     $s_item_type = $item_r['s_item_type'];
     $is_item_reviewed = FALSE;
     if (is_item_reviewed($item_r['item_id'])) {
         $is_item_reviewed = TRUE;
     }
     $is_borrowed_or_returned = FALSE;
     if (is_item_borrowed_or_returned_by_user($item_r['item_id'], $item_r['instance_no'], get_opendb_session_var('user_id'))) {
         $is_borrowed_or_returned = TRUE;
     }
     $item_cover_image = FALSE;
     $header_column_r = $this->findHeaderColumnByFieldname('title');
     if ($header_column_r['cover_image_support'] === TRUE) {
         $item_cover_image = NULL;
         if (strlen($this->_item_type_rs[$s_item_type]['image_attribute_type']) === 0) {
             $this->_item_type_rs[$s_item_type]['image_attribute_type_r'] = fetch_sfieldtype_item_attribute_type_r($s_item_type, 'IMAGE');
         }
         if (is_array($this->_item_type_rs[$s_item_type]['image_attribute_type_r'])) {
             $attribute_type_r = $this->_item_type_rs[$s_item_type]['image_attribute_type_r'];
             $item_cover_image = fetch_attribute_val($item_r['item_id'], $item_r['instance_no'], $attribute_type_r['s_attribute_type']);
             // a kludge to use FALSE to test whether a default image should be displayed
             if ($item_cover_image === FALSE) {
                 $item_cover_image = NULL;
             }
         }
     }
     $item_r['title'] = $this->_titleMaskCfg->expand_item_title($item_r);
     $title_href_link = 'item_display.php?item_id=' . $item_r['item_id'] . '&instance_no=' . $item_r['instance_no'];
     if ($item_cover_image !== FALSE) {
         $this->_row_column_rs[] = array(column_type => 'coverimage', title_href_link => $title_href_link, item_cover_image => $item_cover_image);
     }
     $this->_row_column_rs[] = array(column_type => 'title', item_title => $item_r['title'], title_href_link => $title_href_link, is_item_reviewed => $is_item_reviewed, is_borrowed_or_returned => $is_borrowed_or_returned);
 }
Exemple #8
0
function fetch_sfieldtype_item_attribute_type($s_item_type, $s_field_type)
{
    $attribute_type_r = fetch_sfieldtype_item_attribute_type_r($s_item_type, $s_field_type);
    if ($attribute_type_r) {
        return $attribute_type_r['s_attribute_type'];
    } else {
        return FALSE;
    }
}
 function handleImport($include_header_row, $s_item_type)
 {
     // skip the header row if appropriate.
     if ($this->importPlugin->is_header_row() !== TRUE || $include_header_row !== TRUE) {
         $this->importPlugin->read_header($this->fileHandler, $this->_error);
     }
     while (!$this->fileHandler->isEof() && $this->itemImportHandler->isError() != TRUE && ($read_row_r = $this->importPlugin->read_row($this->fileHandler, $this->_error)) !== FALSE) {
         // ensure we have a array that is not empty, or empty except for first element, which is empty.
         // Either no s_item_type restriction applies, or the s_item_type column is the same as
         // the current s_item_type we are processing.
         if (is_not_empty_array($read_row_r) && (count($read_row_r) > 1 || strlen($read_row_r[0]) > 0) && (!is_numeric($this->field_column_r['s_item_type']) || strlen($read_row_r[$this->field_column_r['s_item_type']]) == 0 || strcasecmp($read_row_r[$this->field_column_r['s_item_type']], $s_item_type) === 0)) {
             $this->itemImportHandler->startItem($s_item_type);
             // Now do the title.
             $title_attr_type_r = fetch_sfieldtype_item_attribute_type_r($s_item_type, 'TITLE');
             $title = $this->get_field_value(get_field_name($title_attr_type_r['s_attribute_type'], $title_attr_type_r['order_no']), NULL, $read_row_r);
             $this->itemImportHandler->setTitle($title);
             $results = fetch_item_attribute_type_rs($s_item_type, NULL, FALSE);
             if ($results) {
                 while ($item_attribute_type_r = db_fetch_assoc($results)) {
                     // these field types are references to item_instance values, and not true attribute types.
                     if ($item_attribute_type_r['s_field_type'] != 'TITLE' && $item_attribute_type_r['s_field_type'] != 'STATUSTYPE' && $item_attribute_type_r['s_field_type'] != 'STATUSCMNT' && $item_attribute_type_r['s_field_type'] != 'DURATION' && $item_attribute_type_r['s_field_type'] != 'ITEM_ID') {
                         $value = $this->get_field_value(get_field_name($item_attribute_type_r['s_attribute_type'], $item_attribute_type_r['order_no']), $item_attribute_type_r['s_attribute_type'], $read_row_r);
                         if (strlen($value) > 0) {
                             if ($item_attribute_type_r['lookup_attribute_ind'] == 'Y' || $item_attribute_type_r['multi_attribute_ind'] == 'Y') {
                                 // row based are comma delimited.
                                 $values_r = trim_explode(',', $value);
                             } else {
                                 $values_r = $value;
                             }
                             $this->itemImportHandler->addAttribute($item_attribute_type_r['s_attribute_type'], $item_attribute_type_r['order_no'], $values_r);
                         }
                         //if(strlen($value)>0)
                     }
                 }
                 db_free_result($results);
             }
             //if($results)
             $status_attr_type_r = fetch_sfieldtype_item_attribute_type_r($s_item_type, 'STATUSTYPE');
             $s_status_type = $this->get_field_value(get_field_name($status_attr_type_r['s_attribute_type'], $status_attr_type_r['order_no']), $status_attr_type_r['s_attribute_type'], $read_row_r);
             $status_cmnt_attr_type_r = fetch_sfieldtype_item_attribute_type_r($s_item_type, 'STATUSCMNT');
             $status_comment = $this->get_field_value(get_field_name($status_cmnt_attr_type_r['s_attribute_type'], $status_cmnt_attr_type_r['order_no']), $status_cmnt_attr_type_r['s_attribute_type'], $read_row_r);
             $duration_attr_type_r = fetch_sfieldtype_item_attribute_type_r($s_item_type, 'DURATION');
             $borrow_duration = $this->get_field_value(get_field_name($duration_attr_type_r['s_attribute_type'], $duration_attr_type_r['order_no']), $duration_attr_type_r['s_attribute_type'], $read_row_r);
             $this->itemImportHandler->startItemInstance();
             $this->itemImportHandler->setInstanceStatusType($s_status_type);
             $this->itemImportHandler->setInstanceStatusComment($status_comment);
             $this->itemImportHandler->setInstanceBorrowDuration($borrow_duration);
             $this->itemImportHandler->endItemInstance();
             $this->itemImportHandler->endItem();
         }
     }
     if ($this->itemImportHandler->isError()) {
         // copy the first error in
         $itemImportHandlerErrors =& $this->itemImportHandler->getRawErrors();
         if (is_array($itemImportHandlerErrors)) {
             $this->_error = $itemImportHandlerErrors[0]['error'];
         }
         return FALSE;
     } else {
         return TRUE;
     }
 }
Exemple #10
0
/**
 * @param $borrowed_item_rs Items that this action will be performed against.  It may actually
 * 						be an array of 'sequence_number' values, in which case the borrow
 * 						record for the sequence_number will be fetched.
 * @param $HTTP_VARS
 * */
function more_information_form($op, $borrowed_item_rs, $HTTP_VARS, $email_notification = TRUE)
{
    global $PHP_SELF;
    $duration_attr_type = NULL;
    $default_borrow_duration = NULL;
    echo "\n<form action=\"{$PHP_SELF}\" method=\"POST\">";
    // In case no detail is required.
    echo "\n<input type=\"hidden\" name=\"more_info_requested\" value=\"true\">";
    // Pass all http variables onto next instance...
    // Includes empty fields...
    echo get_url_fields($HTTP_VARS, NULL, NULL);
    // Display the items to be operated on.
    if (is_not_empty_array($borrowed_item_rs)) {
        echo "<div id=\"moreInfoListing\">";
        // no pagination.
        $HTTP_VARS['items_per_page'] = '';
        $listingObject = new HTML_Listing($PHP_SELF, $HTTP_VARS);
        $listingObject->setIncludeHrefLinks(TRUE);
        $listingObject->setIncludeFooter(FALSE);
        $listingObject->startListing();
        $listingObject->addHeaderColumn(get_opendb_lang_var('type'));
        $listingObject->addHeaderColumn(get_opendb_lang_var('title'));
        if ($op == 'reserve' || $op == 'cancel_reserve' || $op == 'quick_check_out') {
            $listingObject->addHeaderColumn(get_opendb_lang_var('owner'));
        } else {
            if ($op == 'check_in') {
                $listingObject->addHeaderColumn(get_opendb_lang_var('borrower'));
            }
        }
        if (get_opendb_config_var('borrow', 'duration_support')) {
            if ($op == 'check_out' || $op == 'quick_check_out') {
                $listingObject->addHeaderColumn(get_opendb_lang_var('borrow_duration'));
            }
        }
        //initialise
        $max_overdue_duration = NULL;
        $default_borrow_duration = NULL;
        reset($borrowed_item_rs);
        while (list(, $borrowed_item_r) = each($borrowed_item_rs)) {
            $listingObject->startRow();
            // If only a sequence_number, we need to fetch the borrow record.
            if (!is_array($borrowed_item_r) && is_numeric($borrowed_item_r)) {
                $borrowed_item_r = fetch_borrowed_item_r($borrowed_item_r);
            }
            // TODO - add borrowed item history this to be displayed as readonly.
            //$results = fetch_borrowed_item_hist_rs($borrowed_item_r['sequence_number']);
            $item_r = fetch_item_instance_r($borrowed_item_r['item_id'], $borrowed_item_r['instance_no']);
            $listingObject->addItemTypeImageColumn($item_r['s_item_type']);
            $listingObject->addTitleColumn($item_r);
            if ($op == 'reserve' || $op == 'cancel_reserve' || $op == 'quick_check_out') {
                $listingObject->addUserNameColumn($item_r['owner_id'], array('bi_sequence_number' => $borrowed_item_r['sequence_number']));
            } else {
                if ($op == 'check_in') {
                    $listingObject->addUserNameColumn($borrowed_item_r['borrower_id'], array('bi_sequence_number' => $borrowed_item_r['sequence_number']));
                }
            }
            if (get_opendb_config_var('borrow', 'duration_support')) {
                if ($op == 'check_out' || $op == 'quick_check_out') {
                    if (is_numeric($item_r['borrow_duration'])) {
                        // todo - change
                        $duration_attr_type_r = fetch_sfieldtype_item_attribute_type_r($item_r['s_item_type'], 'DURATION');
                        $listingObject->addDisplayColumn($duration_attr_type_r['s_attribute_type'], NULL, $duration_attr_type_r['display_type'], $item_r['borrow_duration']);
                    } else {
                        $listingObject->addColumn(get_opendb_lang_var('undefined'));
                    }
                }
            }
            // While we are here, we are going to calculate the default duration value.
            // We want to choose the least duration value.  If any of the items use a
            // different s_attribute_type for duration, then we should not try to get
            // a default value.  This is indicated by the $duration_attr_type===FALSE
            // if we have encountered a difference.
            if (get_opendb_config_var('borrow', 'duration_support') && $duration_attr_type !== FALSE) {
                $new_duration_attr_type = fetch_sfieldtype_item_attribute_type($item_r['s_item_type'], 'DURATION');
                if ($duration_attr_type == NULL) {
                    $duration_attr_type = $new_duration_attr_type;
                } else {
                    if ($duration_attr_type !== $new_duration_attr_type) {
                        // Different s_attribute_type's for DURATION, so cannot display Duration chooser.
                        $duration_attr_type = FALSE;
                    }
                }
                if ($duration_attr_type !== FALSE) {
                    if ($op == 'check_out' || $op == 'quick_check_out') {
                        // The default borrow duration should be the least amount of days or undefined
                        // if no records have a borrow duration.
                        if ($default_borrow_duration === NULL) {
                            $default_borrow_duration = $item_r['borrow_duration'];
                        } else {
                            if ($default_borrow_duration !== '') {
                                // Undefined empty value.
                                if (is_numeric($default_borrow_duration) && is_numeric($item_r['borrow_duration']) && $item_r['borrow_duration'] < $default_borrow_duration) {
                                    $default_borrow_duration = $item_r['borrow_duration'];
                                }
                            }
                        }
                    } else {
                        if ($op == 'extension') {
                            if ($borrowed_item_r['total_duration'] > $borrowed_item_r['borrow_duration']) {
                                $tmp_overdue_duration = $borrowed_item_r['total_duration'] - $borrowed_item_r['borrow_duration'];
                            }
                            // We want to get the max overdue duration, so we can give the User granting the extension a
                            // default, that will bring all selected items back into non-overdue status.
                            if (!is_numeric($max_overdue_duration) || $max_overdue_duration < $tmp_overdue_duration) {
                                $max_overdue_duration = $tmp_overdue_duration;
                            }
                        }
                    }
                }
            }
            //if(get_opendb_config_var('borrow', 'duration_support') && $duration_attr_type!==FALSE)
            $listingObject->endRow();
        }
        //while(list(,$borrowed_item_r) = each($borrowed_item_rs))
        $listingObject->endListing();
        echo "</div>";
    }
    echo "<table class=\"moreInfo\">";
    // Do not display this more information section unless email is enabled.
    if (is_valid_opendb_mailer() && $email_notification !== FALSE) {
        echo get_input_field("more_information", NULL, get_opendb_lang_var('more_information'), "textarea(50,10)", "N", NULL, TRUE);
    }
    // Include a Borrower ID select, minus the current user.
    if ($op == 'quick_check_out') {
        if (strlen($HTTP_VARS['borrower_id']) == 0 || !is_user_granted_permission(PERM_USER_BORROWER, $HTTP_VARS['borrower_id'])) {
            $current_user_mode = EXCLUDE_CURRENT_USER;
            if (get_opendb_config_var('borrow', 'owner_self_checkout') !== FALSE) {
                $current_user_mode = INCLUDE_CURRENT_USER;
            }
            $results = fetch_user_rs(PERM_USER_BORROWER, INCLUDE_ROLE_PERMISSIONS, $current_user_mode, EXCLUDE_DEACTIVATED_USER, 'fullname', 'ASC');
            if ($results) {
                echo format_field(get_opendb_lang_var('borrower'), custom_select('borrower_id', $results, '%fullname% (%user_id%)', 1, NULL, 'user_id'));
            } else {
                echo format_field(get_opendb_lang_var('borrower'), get_opendb_lang_var('no_records_found'));
            }
        }
    }
    //Only for check_out/quick_check_out operations - makes no sense otherwise!
    if (get_opendb_config_var('borrow', 'duration_support') !== FALSE && ($op == 'check_out' || $op == 'quick_check_out' || $op == 'extension')) {
        // Display default borrow duration.
        if (strlen($duration_attr_type) > 0) {
            $duration_attr_type_r = fetch_attribute_type_r($duration_attr_type);
            // We have to find the matching DURATION lookup value, which is at least
            // as many days as the max_overdue value, or the highest possible
            // duration value, if none found as large as the $max_overdue_duration
            if ($op == 'extension') {
                $default_borrow_duration = NULL;
                $result = fetch_attribute_type_lookup_rs($duration_attr_type_r['s_attribute_type'], 'order_no, value ASC');
                if ($result) {
                    while ($lookup_r = db_fetch_assoc($result)) {
                        if (is_numeric($lookup_r['value']) && (!is_numeric($max_overdue_duration) || is_numeric($max_overdue_duration) && $max_overdue_duration <= $lookup_r['value'])) {
                            $default_borrow_duration = $lookup_r['value'];
                            break;
                        }
                        // backup, in case we need to use outside while loop
                        $lookup_r2 = $lookup_r;
                    }
                    db_free_result($result);
                    // If still null, then set to the largest option
                    if ($default_borrow_duration == NULL) {
                        $default_borrow_duration = $lookup_r2['value'];
                    }
                }
            }
            if ($op != 'extension' && strlen(get_opendb_lang_var('default_borrow_duration')) > 0 && is_array($borrowed_item_rs)) {
                $duration_attr_type_r['prompt'] = get_opendb_lang_var('default_borrow_duration');
            }
            $duration_attr_type_r['compulsory_ind'] = 'N';
            echo get_item_input_field("default_borrow_duration", $duration_attr_type_r, NULL, $op != 'quick_check_out' ? $default_borrow_duration : NULL);
            // Not appropriate for extension operation
            if ($op == 'check_out' || $op == 'quick_check_out') {
                echo get_input_field("override_item_duration", NULL, get_opendb_lang_var('override_item_duration'), "simple_checkbox(" . ($default_borrow_duration === NULL ? "CHECKED" : "") . ")", "N", "Y", TRUE);
            }
        } else {
            //otherwise tell checkout to use item_instance borrow duration instead.
            if ($op == 'check_out' || $op == 'quick_check_out') {
                echo "\n<input type=\"hidden\" name=\"override_item_duration\" value=\"N\">";
            }
        }
    }
    echo "</table>";
    echo "<input type=\"submit\" class=\"submit\" value=\"" . get_opendb_lang_var('submit') . "\">";
    echo "</form>";
    echo format_help_block(get_opendb_lang_var('more_information_help'));
}