コード例 #1
0
ファイル: cat_options.php プロジェクト: lcorbasson/Piwigo
UPDATE ' . CATEGORIES_TABLE . '
  SET commentable = \'true\'
  WHERE id IN (' . implode(',', $_POST['cat_false']) . ')
;';
                pwg_query($query);
                break;
            case 'visible':
                set_cat_visible($_POST['cat_false'], 'true');
                break;
            case 'status':
                set_cat_status($_POST['cat_false'], 'public');
                break;
            case 'representative':
                // theoretically, all categories in $_POST['cat_false'] contain at
                // least one element, so Piwigo can find a representant.
                set_random_representant($_POST['cat_false']);
                break;
        }
    }
}
// +-----------------------------------------------------------------------+
// |                             template init                             |
// +-----------------------------------------------------------------------+
$template->set_filenames(array('cat_options' => 'cat_options.tpl', 'double_select' => 'double_select.tpl'));
$page['section'] = isset($_GET['section']) ? $_GET['section'] : 'status';
$base_url = PHPWG_ROOT_PATH . 'admin.php?page=cat_options&section=';
$template->assign(array('U_HELP' => get_root_url() . 'admin/popuphelp.php?page=cat_options', 'F_ACTION' => $base_url . $page['section']));
// TabSheet
$tabsheet = new tabsheet();
$tabsheet->set_id('cat_options');
$tabsheet->select($page['section']);
コード例 #2
0
ファイル: picture_modify.php プロジェクト: donseba/Piwigo
    set_tags($tag_ids, $_GET['image_id']);
    // association to albums
    if (!isset($_POST['associate'])) {
        $_POST['associate'] = array();
    }
    check_input_parameter('associate', $_POST, true, PATTERN_ID);
    move_images_to_categories(array($_GET['image_id']), $_POST['associate']);
    invalidate_user_cache();
    // thumbnail for albums
    if (!isset($_POST['represent'])) {
        $_POST['represent'] = array();
    }
    check_input_parameter('represent', $_POST, true, PATTERN_ID);
    $no_longer_thumbnail_for = array_diff($represented_albums, $_POST['represent']);
    if (count($no_longer_thumbnail_for) > 0) {
        set_random_representant($no_longer_thumbnail_for);
    }
    $new_thumbnail_for = array_diff($_POST['represent'], $represented_albums);
    if (count($new_thumbnail_for) > 0) {
        $query = '
UPDATE ' . CATEGORIES_TABLE . '
  SET representative_picture_id = ' . $_GET['image_id'] . '
  WHERE id IN (' . implode(',', $new_thumbnail_for) . ')
;';
        pwg_query($query);
    }
    $represented_albums = $_POST['represent'];
    $page['infos'][] = l10n('Photo informations updated');
}
// tags
$query = '
コード例 #3
0
ファイル: pwg.categories.php プロジェクト: squidjam/Piwigo
/**
 * API method
 *
 * Find a new album thumbnail.
 *
 * @param mixed[] $params
 *    @option int category_id
 */
function ws_categories_refreshRepresentative($params, &$service)
{
    global $conf;
    // does the category really exist?
    $query = '
SELECT id
  FROM ' . CATEGORIES_TABLE . '
  WHERE id = ' . $params['category_id'] . '
;';
    $result = pwg_query($query);
    if (pwg_db_num_rows($result) == 0) {
        return new PwgError(404, 'category_id not found');
    }
    $query = '
SELECT
    DISTINCT category_id
  FROM ' . IMAGE_CATEGORY_TABLE . '
  WHERE category_id = ' . $params['category_id'] . '
  LIMIT 1
;';
    $result = pwg_query($query);
    $has_images = pwg_db_num_rows($result) > 0 ? true : false;
    if (!$has_images) {
        return new PwgError(401, 'not permitted');
    }
    include_once PHPWG_ROOT_PATH . 'admin/include/functions.php';
    set_random_representant(array($params['category_id']));
    // return url of the new representative
    $query = '
SELECT *
  FROM ' . CATEGORIES_TABLE . '
  WHERE id = ' . $params['category_id'] . '
;';
    $category = pwg_db_fetch_assoc(pwg_query($query));
    return get_category_representant_properties($category['representative_picture_id']);
}
コード例 #4
0
        set_cat_visible(array($_GET['cat_id']), $_POST['visible']);
    }
    // in case the use moves his album to the gallery root, we force
    // $_POST['parent'] from 0 to null to be compared with
    // $cat_info['id_uppercat']
    if (empty($_POST['parent'])) {
        $_POST['parent'] = null;
    }
    // only move virtual albums
    if (empty($cat_info['dir']) and $cat_info['id_uppercat'] != $_POST['parent']) {
        move_categories(array($_GET['cat_id']), $_POST['parent']);
    }
    $_SESSION['page_infos'][] = l10n('Album updated successfully');
    $redirect = true;
} elseif (isset($_POST['set_random_representant'])) {
    set_random_representant(array($_GET['cat_id']));
    $redirect = true;
} elseif (isset($_POST['delete_representant'])) {
    $query = '
UPDATE ' . CATEGORIES_TABLE . '
  SET representative_picture_id = NULL
  WHERE id = ' . $_GET['cat_id'] . '
;';
    pwg_query($query);
    $redirect = true;
}
if (isset($redirect)) {
    redirect($admin_album_base_url . '-properties');
}
// nullable fields
foreach (array('comment', 'dir', 'site_id', 'id_uppercat') as $nullable) {
コード例 #5
0
ファイル: functions.php プロジェクト: lcorbasson/Piwigo
/**
 * Verifies that the representative picture really exists in the db and
 * picks up a random representative if possible and based on config.
 *
 * @param 'all'|int|int[] $ids
 */
function update_category($ids = 'all')
{
    global $conf;
    if ($ids == 'all') {
        $where_cats = '1=1';
    } elseif (!is_array($ids)) {
        $where_cats = '%s=' . $ids;
    } else {
        if (count($ids) == 0) {
            return false;
        }
        $where_cats = '%s IN(' . wordwrap(implode(', ', $ids), 120, "\n") . ')';
    }
    // find all categories where the setted representative is not possible :
    // the picture does not exist
    $query = '
SELECT DISTINCT c.id
  FROM ' . CATEGORIES_TABLE . ' AS c LEFT JOIN ' . IMAGES_TABLE . ' AS i
    ON c.representative_picture_id = i.id
  WHERE representative_picture_id IS NOT NULL
    AND ' . sprintf($where_cats, 'c.id') . '
    AND i.id IS NULL
;';
    $wrong_representant = query2array($query, null, 'id');
    if (count($wrong_representant) > 0) {
        $query = '
UPDATE ' . CATEGORIES_TABLE . '
  SET representative_picture_id = NULL
  WHERE id IN (' . wordwrap(implode(', ', $wrong_representant), 120, "\n") . ')
;';
        pwg_query($query);
    }
    if (!$conf['allow_random_representative']) {
        // If the random representant is not allowed, we need to find
        // categories with elements and with no representant. Those categories
        // must be added to the list of categories to set to a random
        // representant.
        $query = '
SELECT DISTINCT id
  FROM ' . CATEGORIES_TABLE . ' INNER JOIN ' . IMAGE_CATEGORY_TABLE . '
    ON id = category_id
  WHERE representative_picture_id IS NULL
    AND ' . sprintf($where_cats, 'category_id') . '
;';
        $to_rand = query2array($query, null, 'id');
        if (count($to_rand) > 0) {
            set_random_representant($to_rand);
        }
    }
}