Пример #1
0
function build_new_items_feed($URL, $datemask)
{
    $rssout = '';
    $last_items_list_conf_r = get_opendb_config_var('feeds.new_items');
    $list_item_rs = get_last_num_items_rs($last_items_list_conf_r['total_num_items'], NULL, NULL, NULL, NULL, NULL, 'feeds');
    if (is_not_empty_array($list_item_rs)) {
        reset($list_item_rs);
        while (list(, $list_item_r) = @each($list_item_rs)) {
            $rssout .= "\n\t<item>" . "\n\t\t<title>" . rss_encoded($list_item_r['title']) . "</title>" . "\n\t\t<link>" . rss_encoded($URL . $list_item_r['item_display_url']) . "</link>" . "\n\t\t<pubDate>" . $list_item_r['update_on'] . " " . date('T') . "</pubDate>" . "\n\t\t<guid>" . rss_encoded($URL . $list_item_r['item_display_url']) . "</guid>" . "\n\t\t<description>";
            $results = fetch_item_attribute_type_rs($list_item_r['s_item_type'], 'rss_ind');
            if ($results) {
                $attribute_block = '';
                while ($item_attribute_type_r = db_fetch_assoc($results)) {
                    if (has_role_permission($item_attribute_type_r['view_perm'])) {
                        if (strlen($attribute_block) > 0) {
                            $attribute_block .= "\n";
                        }
                        $attributes_r = fetch_attribute_val_r($list_item_r['item_id'], $list_item_r['instance_no'], $item_attribute_type_r['s_attribute_type'], $item_attribute_type_r['order_no']);
                        if (is_array($attributes_r)) {
                            $attribute = "";
                            while (list(, $value) = each($attributes_r)) {
                                if (strlen($attribute) > 0) {
                                    $attribute .= ", ";
                                }
                                $attribute .= rss_encoded($value);
                            }
                            $attribute_block .= $attribute;
                        }
                    }
                }
                //while
                db_free_result($results);
                $rssout .= $attribute_block;
            }
            $rssout .= "\n\t\t</description>" . "\n\t</item>";
        }
    }
    return $rssout;
}
Пример #2
0
/**
 * 
 */
function copy_item_to_http_vars($old_item_r, $new_item_type)
{
    $HTTP_VARS = array();
    $results = fetch_item_attribute_type_rs($old_item_r['s_item_type'], 'not_instance_field_types');
    if ($results) {
        $attr_order_no_r = array();
        while ($item_attribute_type_r = db_fetch_assoc($results)) {
            if ($item_attribute_type_r['s_field_type'] == 'TITLE') {
                $order_no = fetch_s_item_attribute_type_next_order_no($new_item_type, $item_attribute_type_r['s_attribute_type']);
                $fieldname = get_field_name($item_attribute_type_r['s_attribute_type'], $order_no);
                $HTTP_VARS[$fieldname] = $old_item_r['title'];
            } else {
                $last_order_no = NULL;
                if (is_numeric($attr_order_no_r[$item_attribute_type_r['s_attribute_type']])) {
                    $last_order_no = $attr_order_no_r[$item_attribute_type_r['s_attribute_type']];
                }
                $order_no = fetch_s_item_attribute_type_next_order_no($new_item_type, $item_attribute_type_r['s_attribute_type'], $last_order_no);
                if ($order_no !== FALSE) {
                    $fieldname = get_field_name($item_attribute_type_r['s_attribute_type'], $order_no);
                    // update with latest order no
                    $attr_order_no_r[$item_attribute_type_r['s_attribute_type']] = $order_no;
                    if ($item_attribute_type_r['lookup_attribute_ind'] == 'Y' || $item_attribute_type_r['multi_attribute_ind'] == 'Y') {
                        $attribute_val_r = fetch_attribute_val_r($old_item_r['item_id'], $old_item_r['instance_no'], $item_attribute_type_r['s_attribute_type'], $item_attribute_type_r['order_no']);
                        if (is_not_empty_array($attribute_val_r)) {
                            $HTTP_VARS[$fieldname] = $attribute_val_r;
                        }
                    } else {
                        $attribute_val = fetch_attribute_val($old_item_r['item_id'], $old_item_r['instance_no'], $item_attribute_type_r['s_attribute_type'], $item_attribute_type_r['order_no']);
                        if (strlen($attribute_val) > 0) {
                            $HTTP_VARS[$fieldname] = $attribute_val;
                        }
                    }
                }
            }
        }
        db_free_result($results);
    }
    return $HTTP_VARS;
}
Пример #3
0
         }
         $listingObject->addAttrDisplayColumn($item_r, $attribute_type_r, fetch_review_rating($item_r['item_id']));
     } else {
         $listingObject->addColumn();
     }
 } else {
     if ($v_column_display_config_rs[$i]['s_field_type'] == 'ITEM_ID') {
         $attribute_type_r = fetch_cached_attribute_type_r($v_column_display_config_rs[$i]['s_attribute_type']);
         if (strlen($attribute_type_r['display_type']) == 0 || $attribute_type_r['display_type'] == 'hidden') {
             $attribute_type_r['display_type'] = 'display';
             $attribute_type_r['display_type_arg1'] = '%value%';
         }
         $listingObject->addAttrDisplayColumn($item_r, $attribute_type_r, $item_r['item_id']);
     } else {
         if ($v_column_display_config_rs[$i]['s_field_type'] == 'CATEGORY') {
             $listingObject->addAttrDisplayColumn($item_r, fetch_cached_attribute_type_r($item_r['catia_s_attribute_type']), fetch_attribute_val_r($item_r['item_id'], $item_r['instance_no'], $item_r['catia_s_attribute_type'], $item_r['catia_order_no']));
         } else {
             if ($v_column_display_config_rs[$i]['s_field_type'] == 'STATUSTYPE') {
                 $listingObject->addThemeImageColumn($status_type_rs[$item_r['s_status_type']]['img'], $status_type_rs[$item_r['s_status_type']]['description'], $status_type_rs[$item_r['s_status_type']]['description'], 's_status_type');
                 //type
             } else {
                 if ($v_column_display_config_rs[$i]['s_field_type'] == 'STATUSCMNT') {
                     // If a comment is allowed and defined, add it in.
                     if ($status_type_rs[$item_r['s_status_type']]['status_comment_ind'] == 'Y' || get_opendb_session_var('user_id') === $item_r['owner_id'] || is_user_granted_permission(PERM_ITEM_ADMIN)) {
                         // support newlines in this field
                         $listingObject->addColumn(nl2br($item_r['status_comment']));
                     } else {
                         $listingObject->addColumn(get_opendb_lang_var('not_applicable'));
                     }
                 } else {
                     if ($v_column_display_config_rs[$i]['s_field_type'] == 'ITEMTYPE') {
Пример #4
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;
    }
}
Пример #5
0
function get_item_row($export_columns, $is_all_item_types, $item_id, $instance_no, $owner_id, $s_item_type, $title, $borrow_duration, $s_status_type, $status_comment)
{
    if (!is_array($export_columns) || $export_columns['item_id'] == 'Y') {
        $row[] = $item_id;
    }
    if (!is_array($export_columns) || $export_columns['instance_no'] == 'Y') {
        $row[] = $instance_no;
    }
    if (!is_array($export_columns) || $export_columns['owner_id'] == 'Y') {
        $row[] = $owner_id;
    }
    if (!is_array($export_columns) || $export_columns['s_item_type'] == 'Y') {
        $row[] = $s_item_type;
    }
    if ($is_all_item_types !== TRUE) {
        $results = fetch_item_attribute_type_rs($s_item_type);
        if ($results) {
            while ($item_attribute_type_r = db_fetch_assoc($results)) {
                $fieldname = get_field_name($item_attribute_type_r['s_attribute_type'], $item_attribute_type_r['order_no']);
                if (!is_array($export_columns) || $export_columns[$fieldname] == 'Y') {
                    if ($item_attribute_type_r['s_field_type'] != 'ITEM_ID') {
                        if ($item_attribute_type_r['s_field_type'] == 'TITLE') {
                            $row[] = $title;
                        } else {
                            if ($item_attribute_type_r['s_field_type'] == 'DURATION') {
                                $row[] = $borrow_duration;
                            } else {
                                if ($item_attribute_type_r['s_field_type'] == 'STATUSTYPE') {
                                    $row[] = $s_status_type;
                                } else {
                                    if ($item_attribute_type_r['s_field_type'] == 'STATUSCMNT') {
                                        $row[] = $status_comment;
                                    } else {
                                        $item_attribute_val_r = fetch_attribute_val_r($item_id, $instance_no, $item_attribute_type_r['s_attribute_type'], $item_attribute_type_r['order_no']);
                                        if (is_not_empty_array($item_attribute_val_r)) {
                                            // the plugins will have to handle a array, and format it appropriately.
                                            $row[] = $item_attribute_val_r;
                                        } else {
                                            $row[] = '';
                                            // nothing.
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
            db_free_result($results);
        }
    } else {
        if (!is_array($export_columns) || $export_columns['title'] == 'Y') {
            $row[] = $title;
        }
    }
    return $row;
}
Пример #6
0
 while ($item_attribute_type_r = db_fetch_assoc($results)) {
     if (has_role_permission($item_attribute_type_r['view_perm'])) {
         $display_type = trim($item_attribute_type_r['display_type']);
         if ($HTTP_VARS['mode'] == 'printable' && $item_attribute_type_r['printable_ind'] != 'Y' || strlen($display_type) == 0 && $item_attribute_type_r['input_type'] == 'hidden') {
             // We allow the get_display_field to handle hidden variable, in case at some stage
             // we might want to change the functionality of 'hidden' to something other than ignore.
             $display_type = 'hidden';
         }
         if ($item_attribute_type_r['s_field_type'] == 'ITEM_ID') {
             $value = $item_r['item_id'];
         } else {
             if ($item_attribute_type_r['s_field_type'] == 'UPDATE_ON') {
                 $value = $item_r['update_on'];
             } else {
                 if (is_multivalue_attribute_type($item_attribute_type_r['s_attribute_type'])) {
                     $value = fetch_attribute_val_r($item_r['item_id'], $item_r['instance_no'], $item_attribute_type_r['s_attribute_type'], $item_attribute_type_r['order_no']);
                 } else {
                     $value = fetch_attribute_val($item_r['item_id'], $item_r['instance_no'], $item_attribute_type_r['s_attribute_type'], $item_attribute_type_r['order_no']);
                 }
             }
         }
         if (is_not_empty_array($value) || !is_array($value) && strlen($value) > 0) {
             $item_attribute_type_r['display_type'] = $display_type;
             $item_attribute_type_r['compulsory_ind'] = 'N';
             $field = get_item_display_field($item_r, $item_attribute_type_r, $value, FALSE);
             if (strlen($field) > 0) {
                 echo format_item_data_field($item_attribute_type_r, $field, $prompt_mask, NULL);
                 // field mask
             }
         }
     }
Пример #7
0
function get_edit_item_form($op, $item_r, $HTTP_VARS, &$upload_file_fields)
{
    // is at least one field a compulsory field?
    $compulsory_fields = FALSE;
    $upload_file_fields = FALSE;
    $results = fetch_item_attribute_type_rs($item_r['s_item_type'], 'not_instance_field_types');
    if ($results) {
        $formContents .= "\n<table>";
        while ($item_attribute_type_r = db_fetch_assoc($results)) {
            if ($item_attribute_type_r['s_field_type'] == 'ITEM_ID') {
                continue;
            }
            // need to provide a proper encoded form if upload encountered, assume upload where file attribute encountered
            if ($item_attribute_type_r['file_attribute_ind'] == 'Y') {
                $upload_file_fields = TRUE;
            }
            if ($op == 'refresh' || $op == 'edit' || $op == 'newinstance') {
                if (is_multivalue_attribute_type($item_attribute_type_r['s_attribute_type'])) {
                    $item_attribute_type_r['attribute_val'] = fetch_attribute_val_r($item_r['item_id'], $item_r['instance_no'], $item_attribute_type_r['s_attribute_type'], $item_attribute_type_r['order_no']);
                } else {
                    $item_attribute_type_r['attribute_val'] = fetch_attribute_val($item_r['item_id'], $item_r['instance_no'], $item_attribute_type_r['s_attribute_type'], $item_attribute_type_r['order_no']);
                }
            }
            if ($op == 'refresh') {
                $old_value = get_old_field_value($item_r, $item_attribute_type_r['s_field_type'], $item_attribute_type_r['attribute_val']);
                $new_value = get_field_value($op, $item_r, $item_attribute_type_r['s_attribute_type'], $item_attribute_type_r['order_no'], $item_attribute_type_r['s_field_type'], $item_attribute_type_r['attribute_val'], $HTTP_VARS);
                // this represents multiple selections for a single value, lookup / multi value attributes will
                // be dealt with together.
                if (is_not_empty_array($new_value) && !is_multivalue_attribute_type($item_attribute_type_r['s_attribute_type'])) {
                    foreach ($new_value as $key => $val) {
                        $new_value[$key] = filter_item_input_field($item_attribute_type_r, $val);
                    }
                } else {
                    $new_value = filter_item_input_field($item_attribute_type_r, $new_value);
                    // If no HTTP value, especially where FILE UPLOAD is being concerned, attempt to get from database again.
                    if (($op == 'edit' || $op == 'newinstance') && $new_value === NULL) {
                        $new_value = get_old_field_value($item_r, $item_attribute_type_r['s_field_type'], $item_attribute_type_r['attribute_val']);
                    }
                }
            } else {
                //if($op == 'refresh')
                $old_value = FALSE;
                $new_value = get_field_value($op, $item_r, $item_attribute_type_r['s_attribute_type'], $item_attribute_type_r['order_no'], $item_attribute_type_r['s_field_type'], $item_attribute_type_r['attribute_val'], $HTTP_VARS);
                if (is_not_empty_array($new_value) && !is_multivalue_attribute_type($item_attribute_type_r['s_attribute_type'])) {
                    foreach ($new_value as $key => $val) {
                        $new_value[$key] = filter_item_input_field($item_attribute_type_r, $val);
                    }
                } else {
                    $new_value = filter_item_input_field($item_attribute_type_r, $new_value);
                    // If no HTTP value, especially where FILE UPLOAD is being concerned, attempt to get from database again.
                    if (($op == 'edit' || $op == 'newinstance') && $new_value === NULL) {
                        $new_value = get_old_field_value($item_r, $item_attribute_type_r['s_field_type'], $item_attribute_type_r['attribute_val']);
                    }
                }
            }
            // Enforce compulsory indicator for TITLE.
            if ($item_attribute_type_r['s_field_type'] == 'TITLE') {
                $item_attribute_type_r['compulsory_ind'] = 'Y';
                $override_title_articles_r = get_opendb_config_var('item_input', 'title_articles');
                if (is_not_empty_array($override_title_articles_r)) {
                    if (is_not_empty_array($new_value)) {
                        foreach ($new_value as $key => $val) {
                            $new_value[$key] = trim(format_title_grammar_article($val, $override_title_articles_r));
                        }
                    } else {
                        $new_value = trim(format_title_grammar_article($new_value, $override_title_articles_r));
                    }
                }
            }
            $formContents .= get_item_form_row($op, $item_r, $item_attribute_type_r, $old_value, $new_value);
            if ($item_attribute_type_r['compulsory_ind'] == 'Y') {
                $compulsory_fields = TRUE;
            }
        }
        //while
        db_free_result($results);
        $formContents .= "\n</table>";
        $help_block_r = NULL;
        if ($op == 'refresh') {
            $help_block_r[] = array('img' => 'rs.gif', 'text' => get_opendb_lang_var('refreshed'));
        }
        $help_block_r[] = array('img' => 'compulsory.gif', 'text' => get_opendb_lang_var('compulsory_field'), id => 'compulsory');
        $formContents .= format_help_block($help_block_r);
        return $formContents;
    } else {
        return FALSE;
    }
}
Пример #8
0
/**
	Will return the attribute_val for the record, or FALSE if no found.

	Note: $s_attribute_type should be UPPERCASE
*/
function fetch_attribute_val($item_id, $instance_no, $s_attribute_type, $order_no = NULL)
{
    $attribute_val_r = fetch_attribute_val_r($item_id, $instance_no, $s_attribute_type, $order_no);
    if (is_array($attribute_val_r)) {
        return $attribute_val_r[0];
    } else {
        return $attribute_val_r;
    }
}