0) { $style = 'background-color:#666;'; $style.= 'color:white;'; $style.= 'padding:1px 5px;'; $style.= '-moz-border-radius:10px;'; $style.= '-webkit-border-radius:10px;'; $style.= '-border-radius:10px;'; $style.= 'margin-left:5px;'; $name.= ''.$page['community_nb_pendings'].''; if (defined('IN_ADMIN') and IN_ADMIN and $page['page'] == 'intro') { global $template; $template->set_prefilter('intro', 'community_pendings_on_intro'); $template->assign( array( 'COMMUNITY_PENDINGS' => sprintf( ''.l10n('%u pending photos').'', get_root_url().'admin.php?page=plugin-community-pendings', $page['community_nb_pendings'] ), ) ); } } array_push( $menu, array( 'NAME' => $name, 'URL' => get_root_url().'admin.php?page=plugin-community' ) ); return $menu; } function community_pendings_on_intro($content, &$smarty) { $pattern = '#
  • \s*{\$DB_ELEMENTS\}#ms'; $replacement = '
  • {$COMMUNITY_PENDINGS}
  • {$DB_ELEMENTS}'; return preg_replace($pattern, $replacement, $content); } add_event_handler('loc_end_section_init', 'community_section_init'); function community_section_init() { global $tokens, $page; if ($tokens[0] == 'add_photos') { $page['section'] = 'add_photos'; } } add_event_handler('loc_end_index', 'community_index'); function community_index() { global $page; if (isset($page['section']) and $page['section'] == 'add_photos') { include(COMMUNITY_PATH.'add_photos.php'); } } add_event_handler('blockmanager_apply' , 'community_gallery_menu'); function community_gallery_menu($menu_ref_arr) { global $conf, $user; // conditional : depending on community permissions, display the "Add // photos" link in the gallery menu $user_permissions = community_get_user_permissions($user['id']); if (!$user_permissions['upload_whole_gallery'] and count($user_permissions['upload_categories']) == 0) { return; } $menu = & $menu_ref_arr[0]; if (($block = $menu->get_block('mbMenu')) != null ) { load_language('plugin.lang', COMMUNITY_PATH); array_splice( $block->data, count($block->data), 0, array( '' => array( 'URL' => make_index_url(array('section' => 'add_photos')), 'TITLE' => l10n('Upload your own photos'), 'NAME' => l10n('Upload Photos') ) ) ); } } add_event_handler('ws_invoke_allowed', 'community_switch_user_to_admin', EVENT_HANDLER_PRIORITY_NEUTRAL, 3); function community_switch_user_to_admin($res, $methodName, $params) { global $user; $methods_of_permission_level[1] = array( 'pwg.categories.getList', 'pwg.tags.getAdminList', 'pwg.tags.add', 'pwg.images.exist', 'pwg.images.add', 'pwg.images.setInfo', 'pwg.images.addChunk', 'pwg.images.checkUpload', ); // permission_level 2 has all methods of level 1 + others $methods_of_permission_level[2] = array_merge( $methods_of_permission_level[1], array( 'pwg.categories.add', 'pwg.categories.setInfo', ) ); $query = ' SELECT permission_level FROM '.COMMUNITY_TABLE.' WHERE user_id = '.$user['id'].' ;'; $result = pwg_query($query); if (1 == mysql_num_rows($result)) { list($permission_level) = mysql_fetch_row($result); if (in_array($methodName, $methods_of_permission_level[$permission_level])) { $user['status'] = 'admin'; } } return $res; } add_event_handler('delete_user', 'community_delete_user'); function community_delete_user($user_id) { $query = ' DELETE FROM '.COMMUNITY_PERMISSIONS_TABLE.' WHERE user_id = '.$user_id.' ;'; pwg_query($query); community_reject_user_pendings($user_id); } ?>