1 | <?php |
---|
2 | /* Virtual AutoGrant */ |
---|
3 | if (!defined('PHPWG_ROOT_PATH') or !defined('VAG_DIR')) die('Hacking attempt!'); |
---|
4 | if ( !function_exists( 'virtual_categories_granted_to_creator' ) ) { |
---|
5 | add_event_handler('invalidate_user_cache', 'virtual_categories_granted_to_creator', 20); |
---|
6 | |
---|
7 | function virtual_categories_granted_to_creator($full) { |
---|
8 | if ( !function_exists( 'ws_categories_add' ) ) return false; |
---|
9 | global $user, $conf; |
---|
10 | if ( $_REQUEST['method'] == 'pwg.categories.add' ) { |
---|
11 | list($inserted_id) = pwg_db_fetch_row(pwg_query('SELECT MAX(id) FROM '.CATEGORIES_TABLE |
---|
12 | . ' WHERE name = \'' .pwg_db_real_escape_string($_REQUEST['name']) . '\';')); |
---|
13 | set_cat_status(array($inserted_id), 'private'); |
---|
14 | $insert[] = array('user_id' => $user['id'], 'cat_id' => $inserted_id); |
---|
15 | $insert[] = array('user_id' => $conf['webmaster_id'], 'cat_id' => $inserted_id); |
---|
16 | mass_inserts(USER_ACCESS_TABLE, array('user_id','cat_id'), $insert); |
---|
17 | } |
---|
18 | if ( $_REQUEST['method'] == 'pwg.images.add' and isset($_REQUEST['original_sum']) ) { |
---|
19 | # image to update |
---|
20 | if ('md5sum' == $conf['uniqueness_mode']) $where_clause = "md5sum = '".pwg_db_real_escape_string($_REQUEST['original_sum'])."'"; |
---|
21 | if ('filename' == $conf['uniqueness_mode'] and isset($_REQUEST['original_filename']) ) |
---|
22 | $where_clause = "file = '".pwg_db_real_escape_string($_REQUEST['original_filename'])."'"; |
---|
23 | if ( !isset($where_clause) or is_webmaster() ) return false; |
---|
24 | if ( $user['level'] == $conf['available_permission_levels'][0] ) return false; |
---|
25 | $r = pwg_query('UPDATE '.IMAGES_TABLE.' SET level = ' . $user['level'] . ' WHERE level < '. $user['level'] |
---|
26 | .' AND ' . $where_clause . ';'); |
---|
27 | } |
---|
28 | } |
---|
29 | } |
---|
30 | ?> |
---|