Index: /extensions/SmartAlbums/admin/template/album.tpl
===================================================================
--- /extensions/SmartAlbums/admin/template/album.tpl	(revision 28062)
+++ /extensions/SmartAlbums/admin/template/album.tpl	(revision 28063)
@@ -70,5 +70,10 @@
       }
       else if (type == "album") {
+        var values = value.split(','),
+            recursive = values.splice(0, 1)[0];
+        value = values.join(',');
+
         select_options($block, value);
+        $block.find('.filter-value input[type="checkbox"]').prop('checked', recursive=="true");
       }
       else if (type == "level") {
Index: /extensions/SmartAlbums/admin/template/filters.inc.tpl
===================================================================
--- /extensions/SmartAlbums/admin/template/filters.inc.tpl	(revision 28062)
+++ /extensions/SmartAlbums/admin/template/filters.inc.tpl	(revision 28063)
@@ -82,4 +82,6 @@
       {html_options options=$all_albums}
     </select>
+    
+    <label><input type="checkbox" name="filters[iiii][recursive]"> {'include child albums'|translate}</label>
   </span>
 </li>
Index: /extensions/SmartAlbums/admin/template/style.css
===================================================================
--- /extensions/SmartAlbums/admin/template/style.css	(revision 28062)
+++ /extensions/SmartAlbums/admin/template/style.css	(revision 28063)
@@ -27,10 +27,10 @@
   padding-left:0px;
 }
-#filtersList li {
+#filtersList>li {
   padding:3px 0;
   border-bottom:1px dotted rgba(100, 100, 100, 0.5);
   display:block;
 }
-#filtersList li>span {
+#filtersList>li>span {
   display:inline-block;
   vertical-align:middle;
Index: /extensions/SmartAlbums/include/functions.inc.php
===================================================================
--- /extensions/SmartAlbums/include/functions.inc.php	(revision 28062)
+++ /extensions/SmartAlbums/include/functions.inc.php	(revision 28063)
@@ -277,4 +277,8 @@
       case 'album':
       {
+        $filter['values'] = explode(',', $filter['value']);
+        $filter['recursive'] = array_shift($filter['values']) == "true";
+        $filter['value'] = implode(',', $filter['values']);
+
         switch ($filter['cond'])
         {
@@ -282,11 +286,14 @@
           case 'all':
           {
-            $albums_arr = explode(',', $filter['value']);
-            foreach($albums_arr as $value)
-            {
+            foreach ($filter['values'] as $value)
+            {
+              if ($filter['recursive'])
+              {
+                $value = get_subcat_ids_query(array($value));
+              }
               $sub_query = '
       SELECT image_id
         FROM '.IMAGE_CATEGORY_TABLE.'
-        WHERE category_id = '.$value.'
+        WHERE category_id IN('.$value.')
       ';
               $where[] = 'i.id IN ('.$sub_query.')';
@@ -298,8 +305,16 @@
           case 'one':
           {
+            if ($filter['recursive'])
+            {
+              $value = get_subcat_ids_query($filter['values']);
+            }
+            else
+            {
+              $value = $filter['value'];
+            }
             $sub_query = '
       SELECT image_id
         FROM '.IMAGE_CATEGORY_TABLE.'
-        WHERE category_id IN('.$filter['value'].')
+        WHERE category_id IN('.$value.')
       ';
             $where[] = 'i.id IN ('.$sub_query.')';
@@ -310,8 +325,16 @@
           case 'none':
           {
+            if ($filter['recursive'])
+            {
+              $value = get_subcat_ids_query($filter['values']);
+            }
+            else
+            {
+              $value = $filter['value'];
+            }
             $sub_query = '
       SELECT image_id
         FROM '.IMAGE_CATEGORY_TABLE.'
-        WHERE category_id IN('.$filter['value'].')
+        WHERE category_id IN('.$value.')
       ';
             $where[] = 'i.id NOT IN ('.$sub_query.')';
@@ -322,14 +345,25 @@
           case 'only':
           {
+            if ($filter['recursive'])
+            {
+              $value = get_subcat_ids_query($filter['values']);
+            }
+            else
+            {
+              $value = $filter['value'];
+            }
             $sub_query = '
       SELECT image_id
         FROM '.IMAGE_CATEGORY_TABLE.'
-        WHERE category_id NOT IN('.$filter['value'].')
+        WHERE category_id NOT IN('.$value.')
       ';
             $where[] = 'i.id NOT IN ('.$sub_query.')';
 
-            $albums_arr = explode(',', $filter['value']);
-            foreach($albums_arr as $value)
-            {
+            foreach ($filter['values'] as $value)
+            {
+              if ($filter['recursive'])
+              {
+                $value = get_subcat_ids_query(array($value));
+              }
               $sub_query = '
       SELECT image_id
@@ -544,4 +578,5 @@
       else
       {
+        array_unshift($filter['value'], boolean_to_string(isset($filter['recursive'])));
         $filter['value'] = implode(',', $filter['value']);
       }
@@ -651,2 +686,26 @@
   }
 }
+
+/**
+ * Returns SQL query returning all subcategory identifiers of given category ids
+ *
+ * @param int[] $ids
+ * @return int[]
+ */
+function get_subcat_ids_query($ids)
+{
+  $query = '
+SELECT DISTINCT(id)
+  FROM '.CATEGORIES_TABLE.'
+  WHERE ';
+  foreach ($ids as $num => $category_id)
+  {
+    if ($num > 0)
+    {
+      $query.= '
+    OR ';
+    }
+    $query.= 'uppercats '.DB_REGEX_OPERATOR.' \'(^|,)'.$category_id.'(,|$)\'';
+  }
+  return $query;
+}
Index: /extensions/SmartAlbums/maintain.inc.php
===================================================================
--- /extensions/SmartAlbums/maintain.inc.php	(revision 28062)
+++ /extensions/SmartAlbums/maintain.inc.php	(revision 28063)
@@ -119,4 +119,10 @@
     pwg_query('UPDATE `' . $this->table . '` SET cond = "" WHERE type = "limit" AND cond = "limit";');
     pwg_query('ALTER TABLE `' . $this->table . '` CHANGE `cond` `cond` VARCHAR(32) NULL ;');
+    
+    $result = pwg_query('SELECT COUNT(*) FROM `' . $this->table . '` WHERE type="album" AND (value NOT LIKE "true,%" OR value NOT LIKE "false,%");');
+    if (pwg_db_num_rows(pwg_query($query)))
+    {
+      pwg_query('UPDATE `' . $this->table . '` SET value = CONCAT("false,", value) WHERE type="album";');
+    }
 
     $this->installed = true;
