Exemplo n.º 1
0
 /**
  * Method to untag an item
  *
  * @param   integer          $contentId  ID of the content item being untagged
  * @param   JTableInterface  $table      JTable object being untagged
  * @param   array            $tags       Array of tags to be untagged. Use an empty array to untag all existing tags.
  *
  * @return  boolean  true on success, otherwise false.
  *
  * @since   3.1
  */
 public function unTagItem($contentId, JTableInterface $table, $tags = array())
 {
     $key = $table->getKeyName();
     $id = $table->{$key};
     $db = JFactory::getDbo();
     $query = $db->getQuery(true)->delete('#__contentitem_tag_map')->where($db->quoteName('type_alias') . ' = ' . $db->quote($this->typeAlias))->where($db->quoteName('content_item_id') . ' = ' . (int) $id);
     if (is_array($tags) && count($tags) > 0) {
         JArrayHelper::toInteger($tags);
         $query->where($db->quoteName('tag_id') . ' IN ' . implode(',', $tags));
     }
     $db->setQuery($query);
     return (bool) $db->execute();
 }