diff --git a/src/classes/items/items.core.class.php b/src/classes/items/items.core.class.php index 1996c3ff..59713cd8 100755 --- a/src/classes/items/items.core.class.php +++ b/src/classes/items/items.core.class.php @@ -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; @@ -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 @@ -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(); @@ -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"]); @@ -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"; } @@ -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"; @@ -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 @@ -1465,7 +1471,7 @@ function getPrices($_options = false) { } // no matching prices found - return false; + return array(); } diff --git a/src/classes/items/itemtype.core.class.php b/src/classes/items/itemtype.core.class.php index dfb2b1a6..3ad7ed81 100755 --- a/src/classes/items/itemtype.core.class.php +++ b/src/classes/items/itemtype.core.class.php @@ -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; } @@ -349,8 +348,6 @@ function save($action) { // create sindex $this->sindex($sindex, $item_id); - - message()->addMessage("Item saved"); // return current item $IC = new Items(); @@ -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(); @@ -446,6 +442,7 @@ function update($action) { // get entities for current value $entities = $this->getModel(); + $names = array(); $values = array(); @@ -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) { @@ -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) { diff --git a/src/classes/system/html.janitor.class.php b/src/classes/system/html.janitor.class.php index bb72b890..8106e630 100755 --- a/src/classes/system/html.janitor.class.php +++ b/src/classes/system/html.janitor.class.php @@ -626,9 +626,9 @@ function editSingleMedia(&$item, $_options = false) { $_ .= '