Changeset 9372 for extensions/community/main.inc.php
- Timestamp:
- Feb 25, 2011, 12:22:52 AM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
extensions/community/main.inc.php
r6050 r9372 15 15 16 16 define('COMMUNITY_PATH' , PHPWG_PLUGINS_PATH.basename(dirname(__FILE__)).'/'); 17 include_once (COMMUNITY_PATH.'/include/constants.php'); 17 18 global $prefixeTable; 19 define('COMMUNITY_TABLE', $prefixeTable.'community'); 20 define('COMMUNITY_PERMISSIONS_TABLE', $prefixeTable.'community_permissions'); 21 define('COMMUNITY_PENDINGS_TABLE', $prefixeTable.'community_pendings'); 18 22 19 23 /* Plugin admin */ … … 26 30 array( 27 31 'NAME' => 'Community', 28 'URL' => get_ admin_plugin_menu_link(dirname(__FILE__).'/admin.php')32 'URL' => get_root_url().'admin.php?page=plugin-community' 29 33 ) 30 34 ); … … 32 36 return $menu; 33 37 } 38 39 add_event_handler('loc_end_section_init', 'community_section_init'); 40 function community_section_init() 41 { 42 global $tokens, $page; 43 44 if ($tokens[0] == 'add_photos') 45 { 46 $page['section'] = 'add_photos'; 47 } 48 } 49 50 add_event_handler('loc_end_index', 'community_index'); 51 function community_index() 52 { 53 global $page; 54 55 if (isset($page['section']) and $page['section'] == 'add_photos') 56 { 57 include(COMMUNITY_PATH.'add_photos.php'); 58 } 59 } 60 61 add_event_handler('blockmanager_apply' , 'community_gallery_menu'); 62 function community_gallery_menu($menu_ref_arr) 63 { 64 global $conf, $user; 65 66 // conditional : depending on community permissions, display the "Add 67 // photos" link in the gallery menu 68 69 // admins are not concerned about community permissions 70 if (!is_admin()) 71 { 72 // what are the user groups? 73 $query = ' 74 SELECT 75 group_id 76 FROM '.USER_GROUP_TABLE.' 77 WHERE user_id = '.$user['id'].' 78 ;'; 79 $user_group_ids = array_from_query($query, 'group_id'); 80 81 $query = ' 82 SELECT 83 COUNT(*) 84 FROM '.COMMUNITY_PERMISSIONS_TABLE.' 85 WHERE (type = \'any_visitor\')'; 86 87 if ($user['id'] != $conf['guest_id']) 88 { 89 $query.= ' 90 OR (type = \'any_registered_user\') 91 OR (type = \'user\' AND user_id = '.$user['id'].') 92 OR (type = \'group\' AND group_id IN ('.implode(',', $user_group_ids).')) 93 '; 94 } 95 96 $query.= ' 97 ;'; 98 99 list($counter) = pwg_db_fetch_row(pwg_query($query)); 100 if (0 == $counter) 101 { 102 return; 103 } 104 } 105 106 $menu = & $menu_ref_arr[0]; 107 108 if (($block = $menu->get_block('mbMenu')) != null ) 109 { 110 load_language('plugin.lang', COMMUNITY_PATH); 111 112 array_splice( 113 $block->data, 114 count($block->data), 115 0, 116 array( 117 '' => array( 118 'URL' => make_index_url(array('section' => 'add_photos')), 119 'TITLE' => l10n('Upload your own photos'), 120 'NAME' => l10n('Upload Photos') 121 ) 122 ) 123 ); 124 } 125 } 126 34 127 35 128 add_event_handler('ws_invoke_allowed', 'community_switch_user_to_admin', EVENT_HANDLER_PRIORITY_NEUTRAL, 3);
Note: See TracChangeset
for help on using the changeset viewer.