Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 14 additions & 8 deletions src/classes/items/items.core.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,7 @@ function extendItem($item, $_options = false) {
case "ratings" : $ratings = $_value; break;
case "comments" : $comments = $_value; break;
case "subscription_method" : $subscription_method = $_value; break;


case "user" : $user = $_value; break;
case "readstate" : $readstate = $_value; break;
Expand All @@ -217,11 +218,16 @@ function extendItem($item, $_options = false) {

// get the specific type data
$typeObject = $this->TypeObject($item["itemtype"]);

if(method_exists($typeObject, "get")) {
$item = array_merge($item, $typeObject->get($item["id"]));
}
else {
$item = array_merge($item, $this->getSimpleType($item["id"], $typeObject));
$tmp_simple_item = $this->getSimpleType($item["id"], $typeObject);

if(count($tmp_simple_item)) {
$item = array_merge($item, $tmp_simple_item);
}
}

// add mediae
Expand Down Expand Up @@ -260,7 +266,6 @@ function extendItem($item, $_options = false) {
$item["subscription_method"] = $this->getSubscriptionMethod(array("item_id" => $item["id"]));
}


// add user nickname
if($all || $user) {
$UC = $this->getUserClass();
Expand Down Expand Up @@ -317,6 +322,7 @@ function getSimpleType($item_id, $typeObject) {
$query = new Query();

$sql = "SELECT * FROM ".$typeObject->db." WHERE item_id = $item_id";

if($query->sql($sql)) {
$item = $query->result(0);
unset($item["id"]);
Expand Down Expand Up @@ -609,10 +615,12 @@ function getItems($_options = false) {
// }

if(isset($itemtype)) {
// add main itemtype table to enable sorting based on local values
$WHERE[] = "items.itemtype = '$itemtype'";
$WHERE[] = "items.id = ".$itemtype.".item_id";
$FROM[] = $this->typeObject($itemtype)->db." as ".$itemtype;

// add main itemtype table to enable sorting based on local values
$LEFTJOIN[] = $this->typeObject($itemtype)->db." as ".$itemtype." ON items.id = ".$itemtype.".item_id";
// $LEFTJOIN[] = $this->typeObject($itemtype)->db." as ".$itemtype." ON items.id = ".$itemtype.".item_id";
}


Expand Down Expand Up @@ -710,7 +718,7 @@ function getItems($_options = false) {

}

$ORDER[] = "items.published_at DESC";
$ORDER[] = "items.published_at DESC, items.id";

if(isset($limit)) {
$limit = " LIMIT $limit";
Expand All @@ -722,12 +730,10 @@ function getItems($_options = false) {
$items = array();

$sql = $query->compileQuery($SELECT, $FROM, array("LEFTJOIN" => $LEFTJOIN, "WHERE" => $WHERE, "HAVING" => $HAVING, "GROUP_BY" => $GROUP_BY, "ORDER" => $ORDER)) . $limit;
// debug($sql);

$query->sql($sql);
$items = $query->results();


// TODO: consider if this could be integrated in primary query
// - but might give issues with flexibility and query load on mixed lists
// needs to be investigated
Expand Down Expand Up @@ -1465,7 +1471,7 @@ function getPrices($_options = false) {
}

// no matching prices found
return false;
return array();
}


Expand Down
9 changes: 2 additions & 7 deletions src/classes/items/itemtype.core.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,11 @@ function status($action) {
if($query->sql("SELECT id FROM ".UT_ITEMS." WHERE id = $item_id AND itemtype = '$this->itemtype'")) {
$query->sql("UPDATE ".UT_ITEMS." SET status = $status WHERE id = $item_id");

message()->addMessage("Item ".$this->status_states[$status]);
return true;
}
}

message()->addMessage("Item could not be ".$this->status_states[$status], array("type" => "error"));
message()->addMessage("Item Status could not be changed." , array("type" => "error"));
return false;

}
Expand Down Expand Up @@ -349,8 +348,6 @@ function save($action) {
// create sindex
$this->sindex($sindex, $item_id);


message()->addMessage("Item saved");
// return current item
$IC = new Items();

Expand Down Expand Up @@ -431,7 +428,6 @@ function saveItem() {
// TODO: implement itemtype checks
function update($action) {
global $page;

// Get posted values to make them available for models
$this->getPostedEntities();

Expand All @@ -446,6 +442,7 @@ function update($action) {

// get entities for current value
$entities = $this->getModel();

$names = array();
$values = array();

Expand Down Expand Up @@ -961,7 +958,6 @@ function addMedia($action) {
$item_id = $action[1];

$query->checkDbExistence(UT_ITEMS_MEDIAE);

if($this->validateList(array("mediae"), $item_id)) {
$uploads = $this->upload($item_id, array("input_name" => "mediae", "auto_add_variant" => true));
if($uploads) {
Expand Down Expand Up @@ -1185,7 +1181,6 @@ function upload($item_id, $_options) {


if(isset($_FILES[$_input_name])) {
// print "input_name:" . $_input_name;
// print_r($_FILES[$_input_name]);

foreach($_FILES[$_input_name]["name"] as $index => $value) {
Expand Down
4 changes: 2 additions & 2 deletions src/classes/system/html.janitor.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -626,9 +626,9 @@ function editSingleMedia(&$item, $_options = false) {
$_ .= '<div class="media single_media '.$variant.' '.$class.' variant:'.$variant.' item_id:'.$item["id"].' format:'.($media ? $media["format"] : "").'"'.$this->jsData().'>';
$_ .= '<h2>'.$label.'</h2>';

$_ .= $model->formStart($this->path."/addSingleMedia/".$item["id"]."/".$variant, array("class" => "upload labelstyle:inject"));
$_ .= $model->formStart($this->path."/addSingleMedia/".$item["id"]."/".$variant, array("class" => "upload labelstyle:inject", "id" => $item["id"]));
$_ .= '<fieldset>';
$_ .= $model->input($variant, array("value" => $media));
$_ .= $model->input($variant, array("value" => $media, "id" => "single_media_".$item["id"]));
$_ .= '</fieldset>';
$_ .= $model->formEnd();

Expand Down
2 changes: 2 additions & 0 deletions src/classes/system/model.class.php
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,8 @@ function getPostedEntities() {
}
}
}

return true;
}


Expand Down
1 change: 1 addition & 0 deletions src/config/database.constants.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@




// TAGS
define("UT_TAG", SITE_DB.".tags"); // Item tags
define("UT_TAGGINGS", SITE_DB.".taggings"); // Item tags relations
Expand Down