コード例 #1
0
ファイル: cat_options.php プロジェクト: lcorbasson/Piwigo
} else {
    if (isset($_POST['trueify']) and isset($_POST['cat_false']) and count($_POST['cat_false']) > 0) {
        switch ($_GET['section']) {
            case 'comments':
                $query = '
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=';
コード例 #2
0
ファイル: cat_perm.php プロジェクト: donseba/Piwigo
include_once PHPWG_ROOT_PATH . 'admin/include/functions.php';
// +-----------------------------------------------------------------------+
// | Check Access and exit when user status is not ok                      |
// +-----------------------------------------------------------------------+
check_status(ACCESS_ADMINISTRATOR);
// +-----------------------------------------------------------------------+
// |                       variable initialization                         |
// +-----------------------------------------------------------------------+
$page['cat'] = $category['id'];
// +-----------------------------------------------------------------------+
// |                           form submission                             |
// +-----------------------------------------------------------------------+
if (!empty($_POST)) {
    check_pwg_token();
    if ($category['status'] != $_POST['status']) {
        set_cat_status(array($page['cat']), $_POST['status']);
        $category['status'] = $_POST['status'];
    }
    if ('private' == $_POST['status']) {
        //
        // manage groups
        //
        $query = '
SELECT group_id
  FROM ' . GROUP_ACCESS_TABLE . '
  WHERE cat_id = ' . $page['cat'] . '
;';
        $groups_granted = array_from_query($query, 'group_id');
        if (!isset($_POST['groups'])) {
            $_POST['groups'] = array();
        }
コード例 #3
0
ファイル: functions.php プロジェクト: lcorbasson/Piwigo
/**
 * Change the parent category of the given categories. The categories are
 * supposed virtual.
 *
 * @param int[] $category_ids
 * @param int $new_parent (-1 for root)
 */
function move_categories($category_ids, $new_parent = -1)
{
    global $page;
    if (count($category_ids) == 0) {
        return;
    }
    $new_parent = $new_parent < 1 ? 'NULL' : $new_parent;
    $categories = array();
    $query = '
SELECT id, id_uppercat, status, uppercats
  FROM ' . CATEGORIES_TABLE . '
  WHERE id IN (' . implode(',', $category_ids) . ')
;';
    $result = pwg_query($query);
    while ($row = pwg_db_fetch_assoc($result)) {
        $categories[$row['id']] = array('parent' => empty($row['id_uppercat']) ? 'NULL' : $row['id_uppercat'], 'status' => $row['status'], 'uppercats' => $row['uppercats']);
    }
    // is the movement possible? The movement is impossible if you try to move
    // a category in a sub-category or itself
    if ('NULL' != $new_parent) {
        $query = '
SELECT uppercats
  FROM ' . CATEGORIES_TABLE . '
  WHERE id = ' . $new_parent . '
;';
        list($new_parent_uppercats) = pwg_db_fetch_row(pwg_query($query));
        foreach ($categories as $category) {
            // technically, you can't move a category with uppercats 12,125,13,14
            // into a new parent category with uppercats 12,125,13,14,24
            if (preg_match('/^' . $category['uppercats'] . '(,|$)/', $new_parent_uppercats)) {
                $page['errors'][] = l10n('You cannot move an album in its own sub album');
                return;
            }
        }
    }
    $tables = array(USER_ACCESS_TABLE => 'user_id', GROUP_ACCESS_TABLE => 'group_id');
    $query = '
UPDATE ' . CATEGORIES_TABLE . '
  SET id_uppercat = ' . $new_parent . '
  WHERE id IN (' . implode(',', $category_ids) . ')
;';
    pwg_query($query);
    update_uppercats();
    update_global_rank();
    // status and related permissions management
    if ('NULL' == $new_parent) {
        $parent_status = 'public';
    } else {
        $query = '
SELECT status
  FROM ' . CATEGORIES_TABLE . '
  WHERE id = ' . $new_parent . '
;';
        list($parent_status) = pwg_db_fetch_row(pwg_query($query));
    }
    if ('private' == $parent_status) {
        set_cat_status(array_keys($categories), 'private');
    }
    $page['infos'][] = l10n_dec('%d album moved', '%d albums moved', count($categories));
}