diff --git a/include/common.inc.php b/include/common.inc.php index 06eed3757..285d1bdb3 100644 --- a/include/common.inc.php +++ b/include/common.inc.php @@ -172,7 +172,7 @@ include(PHPWG_ROOT_PATH.'include/user.inc.php'); // language files load_language('common.lang'); -if (defined('IN_ADMIN') and IN_ADMIN) +if ( is_admin() || (defined('IN_ADMIN') and IN_ADMIN) ) { load_language('admin.lang'); } diff --git a/include/ws_functions.inc.php b/include/ws_functions.inc.php index dc10719b6..72540f2da 100644 --- a/include/ws_functions.inc.php +++ b/include/ws_functions.inc.php @@ -824,6 +824,35 @@ SELECT * FROM '.IMAGES_TABLE.' ); } +function ws_images_setPrivacyLevel($params, &$service) +{ + if (!is_admin() || is_adviser() ) + { + return new PwgError(401, 'Access denied'); + } + if ( empty($params['image_id']) ) + { + return new PwgError(WS_ERR_INVALID_PARAM, "Invalid image_id"); + } + global $conf; + if ( !in_array( (int)$params['level'], $conf['available_permission_levels']) ) + { + return new PwgError(WS_ERR_INVALID_PARAM, "Invalid level"); + } + $query = ' +UPDATE '.IMAGES_TABLE.' + SET level='.(int)$params['level'].' + WHERE id IN ('.implode(',',$params['image_id']).')'; + $result = pwg_query($query); + $affected_rows = mysql_affected_rows(); + if ($affected_rows) + { + include_once(PHPWG_ROOT_PATH.'admin/include/functions.php'); + invalidate_user_cache(); + } + return $affected_rows; +} + /** * perform a login (web service method) */ diff --git a/picture.php b/picture.php index 1e6e1c811..84dd43c04 100644 --- a/picture.php +++ b/picture.php @@ -25,7 +25,6 @@ define('PHPWG_ROOT_PATH','./'); include_once(PHPWG_ROOT_PATH.'include/common.inc.php'); include(PHPWG_ROOT_PATH.'include/section_init.inc.php'); include_once(PHPWG_ROOT_PATH.'include/functions_picture.inc.php'); -include_once(PHPWG_ROOT_PATH.'include/functions_session.inc.php'); // Check Access and exit when user status is not ok check_status(ACCESS_GUEST); @@ -530,14 +529,17 @@ foreach (array('first','previous','next','last', 'current') as $which_image) { $template->assign( $which_image, - array( - 'TITLE' => $picture[$which_image]['name'], - 'THUMB_SRC' => $picture[$which_image]['thumbnail'], - // Params slideshow was transmit to navigation buttons - 'U_IMG' => - add_url_params( - $picture[$which_image]['url'], $slideshow_url_params), - 'U_DOWNLOAD' => @$picture['current']['download_url'], + array_merge( + $picture[$which_image], + array( + 'TITLE' => $picture[$which_image]['name'], + 'THUMB_SRC' => $picture[$which_image]['thumbnail'], + // Params slideshow was transmit to navigation buttons + 'U_IMG' => + add_url_params( + $picture[$which_image]['url'], $slideshow_url_params), + 'U_DOWNLOAD' => @$picture['current']['download_url'], + ) ) ); } @@ -806,21 +808,21 @@ if ( count($tags) ) { $template->append( 'related_tags', - array( - 'ID' => $tag['id'], - 'NAME' => $tag['name'], - 'U_TAG' => make_index_url( + array_merge( $tag, + array( + 'URL' => make_index_url( array( 'tags' => array($tag) ) ), - 'U_TAG_IMAGE' => duplicate_picture_url( + 'U_TAG_IMAGE' => duplicate_picture_url( array( 'section' => 'tags', 'tags' => array($tag) ) ) ) + ) ); } } @@ -868,6 +870,10 @@ $element_content = trigger_event( ); $template->assign( 'ELEMENT_CONTENT', $element_content ); +if (is_admin()) +{ + $template->assign('available_permission_levels', $conf['available_permission_levels']); +} // +-----------------------------------------------------------------------+ // | sub pages | // +-----------------------------------------------------------------------+ diff --git a/template-common/scripts.js b/template-common/scripts.js index 83f4815e7..452be1699 100644 --- a/template-common/scripts.js +++ b/template-common/scripts.js @@ -72,3 +72,108 @@ function popuphelp(url) ); } + + +Function.prototype.pwgBind = function() { + var __method = this, object = arguments[0], args = new Array(); + for (var i=1; i {if isset($related_tags)} {foreach from=$related_tags item=tag name=tag_loop}{if !$smarty.foreach.tag_loop.first}, {/if} - {$tag.NAME}{/foreach} + {$tag.name}{/foreach} {/if} @@ -137,6 +137,32 @@ {'Visits'|@translate} {$INFO_VISITS} + {if isset($available_permission_levels) } + + {'Privacy level'|@translate}: + + + + + {/if} {if isset($rate_summary) } {'Average rate'|@translate} diff --git a/ws.php b/ws.php index 80f543f06..45601a1cb 100644 --- a/ws.php +++ b/ws.php @@ -115,6 +115,12 @@ function ws_addDefaultMethods( $arr ) ), 'Returns elements for the corresponding query search.' ); + $service->addMethod('pwg.images.setPrivacyLevel', 'ws_images_setPrivacyLevel', + array( + 'image_id' => array('flags'=>WS_PARAM_FORCE_ARRAY), + 'level' => array('maxValue'=>$conf['available_permission_levels']), + ), + 'sets the privacy levels for the images' ); $service->addMethod('pwg.session.getStatus', 'ws_session_getStatus', null, '' ); $service->addMethod('pwg.session.login', 'ws_session_login',