function update($new_other_cat_ids) { $new_other_cat_ids = array_diff($new_other_cat_ids, array("0" => $this->cat_id)); // Get the new other cats $removes = array_diff($this->other_cat_ids, $new_other_cat_ids); foreach ($removes as $remove) { $this->_db->setQuery("DELETE FROM #__mt_cl WHERE link_id = " . $this->_db->Quote($this->link_id) . " AND cat_id = " . $this->_db->Quote($remove) . " AND main = '0'"); $this->_db->query(); mtUpdateLinkCount($remove, -1); } // Get the soon to be removed cats $adds = array_diff($new_other_cat_ids, $this->other_cat_ids); foreach ($adds as $add) { if (!is_null($add) && is_numeric($add)) { $this->_db->setQuery("INSERT INTO #__mt_cl ( link_id, cat_id, main ) VALUES(" . $this->_db->Quote($this->link_id) . ", " . $this->_db->Quote($add) . ", '0')"); $this->_db->query(); mtUpdateLinkCount($add, 1); } } }
function approve_links($link_id, $publish = 0, $option) { global $mainframe; $database =& JFactory::getDBO(); if (!is_array($link_id) || count($link_id) < 1) { echo "<script> alert('" . JText::_('Select an item to approve') . "'); window.history.go(-1);</script>\n"; exit; } if (count($link_id)) { foreach ($link_id as $lid) { $mtLinks = new mtLinks($database); $mtLinks->load($lid); $mtLinks->publishLink($publish); // Only increase Link count if this is an approval to a new listing if ($mtLinks->link_approved == 0) { $mtLinks->updateLinkCount(1); } elseif ($mtLinks->link_approved < 0) { // Check if there is any category change during modification $database->setQuery("SELECT cat_id FROM #__mt_cl WHERE link_id = ABS(" . $mtLinks->link_approved . ") AND main = '1'"); $ori_cat_id = $database->loadResult(); if ($ori_cat_id != $mtLinks->cat_id) { $mtLinks->updateLinkCount(1); mtUpdateLinkCount($ori_cat_id, -1); } } $mtLinks->approveLink(); unset($mtLinks); } } $mainframe->redirect("index2.php?option={$option}&task=listpending_links", sprintf(JText::_('Links have been aprroved'), count($link_id))); }