######### db_input.php ###########

Find

[code]
        if (GALLERY_ADMIN_MODE) {
            $query = "UPDATE {$CONFIG['TABLE_ALBUMS']} SET title='$title', description='$description', category='$category', thumb='$thumb', uploads='$uploads', comments='$comments', votes='$votes', visibility='$visibility', alb_password='$password', alb_password_hint='$password_hint', keyword='$keyword' WHERE aid='$aid' LIMIT 1";
[/code]

replace with

[code]
        if (GALLERY_ADMIN_MODE) {
            $moderator_group = $_POST['moderator_group'];
            $query = "UPDATE {$CONFIG['TABLE_ALBUMS']} SET title='$title', description='$description', category='$category', thumb='$thumb', uploads='$uploads', comments='$comments', votes='$votes', visibility='$visibility', alb_password='$password', alb_password_hint='$password_hint', keyword='$keyword', moderator_group='$moderator_group' WHERE aid='$aid' LIMIT 1";
[/code]


############## editpics.php ##############

Add

[code]
if (is_array($USER_DATA['allowed_albums']) && count($USER_DATA['allowed_albums'])) {

    define('MODERATOR_MODE', 1);
    $albStr = implode(",", $USER_DATA['allowed_albums']);
    $albStr = "($albStr)";

    if (isset($_REQUEST['album']) && in_array($_REQUEST['album'], $USER_DATA['allowed_albums'])) {
      define('MODERATOR_EDIT_MODE', 1);
    } else {
      define('MODERATOR_EDIT_MODE', 0);
    }
} else {
    define('MODERATOR_MODE', 0);
    define('MODERATOR_EDIT_MODE', 0);
}
[/code]

after

[code]
require('include/init.inc.php');
[/code]

Replace

[code]
if (!(GALLERY_ADMIN_MODE || USER_ADMIN_MODE)) cpg_die(ERROR, $lang_errors['access_denied'], __FILE__, __LINE__);
[/code]

with

[code]
if (!(GALLERY_ADMIN_MODE || USER_ADMIN_MODE || MODERATOR_MODE)) cpg_die(ERROR, $lang_errors['access_denied'], __FILE__, __LINE__);
[/code]

Replace

[code]
if (UPLOAD_APPROVAL_MODE && !GALLERY_ADMIN_MODE) cpg_die(ERROR, $lang_errors['access_denied'], __FILE__, __LINE__);
[/code]

with

[code]
if (UPLOAD_APPROVAL_MODE && !GALLERY_ADMIN_MODE && !MODERATOR_MODE) cpg_die(ERROR, $lang_errors['access_denied'], __FILE__, __LINE__);
[/code]

Replace

[code]
if ($cat != FIRST_USER_CAT + USER_ID && !GALLERY_ADMIN_MODE) cpg_die(ERROR, $lang_errors['perm_denied'], __FILE__, __LINE__);
[/code]

with

[code]
if ($cat != FIRST_USER_CAT + USER_ID && !GALLERY_ADMIN_MODE && !MODERATOR_EDIT_MODE) cpg_die(ERROR, $lang_errors['perm_denied'], __FILE__, __LINE__);
[/code]

Replace

[code]
if (!GALLERY_ADMIN_MODE) {
                        if ($pic['category'] != FIRST_USER_CAT + USER_ID) cpg_die(ERROR, $lang_errors['perm_denied']."<br />(picture category = {$pic['category']}/ $pid)", __FILE__, __LINE__);
                        if (!isset($user_album_set[$aid])) cpg_die(ERROR, $lang_errors['perm_denied']."<br />(target album = $aid)", __FILE__, __LINE__);
                }
[/code]

with

[code]
if (!GALLERY_ADMIN_MODE && !MODERATOR_MODE) {
                        if ($pic['category'] != FIRST_USER_CAT + USER_ID) cpg_die(ERROR, $lang_errors['perm_denied']."<br />(picture category = {$pic['category']}/ $pid)", __FILE__, __LINE__);
                        if (!isset($user_album_set[$aid])) cpg_die(ERROR, $lang_errors['perm_denied']."<br />(target album = $aid)", __FILE__, __LINE__);
                }
[/code]

replace

[code]
function get_user_albums($user_id = '') {
        global $CONFIG, $user_albums_list;
[/code]

with

[code]
function get_user_albums($user_id = '') {
        global $CONFIG, $user_albums_list, $albStr;
[/code]

replace

[code]
$user_albums = cpg_db_query("SELECT aid, title FROM {$CONFIG['TABLE_ALBUMS']} WHERE category='".(FIRST_USER_CAT + USER_ID)."' $or ORDER BY title");
[/code]

with

[code]
if (MODERATOR_MODE && UPLOAD_APPROVAL_MODE || MODERATOR_EDIT_MODE) {
    $user_albums = cpg_db_query("SELECT aid, title FROM {$CONFIG['TABLE_ALBUMS']} WHERE aid IN $albStr AND category > '".FIRST_USER_CAT."' OR category='".(FIRST_USER_CAT + USER_ID)."' ORDER BY title");
} else {
    $user_albums = cpg_db_query("SELECT aid, title FROM {$CONFIG['TABLE_ALBUMS']} WHERE category='".(FIRST_USER_CAT + USER_ID)."' $or ORDER BY title");
}
[/code]

replace

[code]
if (GALLERY_ADMIN_MODE) {
    $public_albums = cpg_db_query("SELECT DISTINCT aid, title, IF(category = 0, CONCAT('&gt; ', title), CONCAT(name,' &lt; ',title)) AS cat_title FROM {$CONFIG['TABLE_ALBUMS']}, {$CONFIG['TABLE_CATEGORIES']} WHERE category < '" . FIRST_USER_CAT . "' AND (category = 0 OR category = cid) ORDER BY cat_title");
        if (mysql_num_rows($public_albums)) {
            $public_albums_list=cpg_db_fetch_rowset($public_albums);
        } else {
                $public_albums_list = array();
        }
        mysql_free_result($public_albums);
[/code]

with

[code]
if (GALLERY_ADMIN_MODE) {
    $public_albums = cpg_db_query("SELECT DISTINCT aid, title, IF(category = 0, CONCAT('&gt; ', title), CONCAT(name,' &lt; ',title)) AS cat_title FROM {$CONFIG['TABLE_ALBUMS']}, {$CONFIG['TABLE_CATEGORIES']} WHERE category < '" . FIRST_USER_CAT . "' AND (category = 0 OR category = cid) ORDER BY cat_title");
        if (mysql_num_rows($public_albums)) {
            $public_albums_list=cpg_db_fetch_rowset($public_albums);
        } else {
                $public_albums_list = array();
        }
        mysql_free_result($public_albums);
} elseif (MODERATOR_MODE) {
    $public_albums = cpg_db_query("SELECT DISTINCT aid, title, IF(category = 0, CONCAT('&gt; ', title), CONCAT(name,' &lt; ',title)) AS cat_title FROM {$CONFIG['TABLE_ALBUMS']}, {$CONFIG['TABLE_CATEGORIES']} WHERE aid IN $albStr AND category < '" . FIRST_USER_CAT . "' AND (category = 0 OR category = cid) ORDER BY cat_title");
    if (mysql_num_rows($public_albums)) {
        $public_albums_list=cpg_db_fetch_rowset($public_albums);
    } else {
            $public_albums_list = array();
    }
    mysql_free_result($public_albums);
[/code]

replace

[code]
if (UPLOAD_APPROVAL_MODE) {
        $result=cpg_db_query("SELECT count(*) FROM {$CONFIG['TABLE_PICTURES']} WHERE approved = 'NO'");
[/code]

with

[code]
if (UPLOAD_APPROVAL_MODE) {
        if (MODERATOR_MODE) {
            $result=cpg_db_query("SELECT count(*) FROM {$CONFIG['TABLE_PICTURES']} WHERE approved = 'NO' AND aid IN $albStr");
        } else {
            $result=cpg_db_query("SELECT count(*) FROM {$CONFIG['TABLE_PICTURES']} WHERE approved = 'NO'");
        }
[/code]

replace

[code]
    $sql =  "SELECT * ".
                        "FROM {$CONFIG['TABLE_PICTURES']} ".
                        "WHERE approved = 'NO' ".
                        "ORDER BY pid ".
                        "LIMIT $start, $count";
[/code]

with

[code]
        if (MODERATOR_MODE) {
            $sql =  "SELECT * ".
                                "FROM {$CONFIG['TABLE_PICTURES']} ".
                                "WHERE approved = 'NO' AND aid IN $albStr".
                                "ORDER BY pid ".
                                "LIMIT $start, $count";
        } else {
            $sql =  "SELECT * ".
                                "FROM {$CONFIG['TABLE_PICTURES']} ".
                                "WHERE approved = 'NO' ".
                                "ORDER BY pid ".
                                "LIMIT $start, $count";
        }
[/code]

 
############ index.php ##############

Add

[code]
/**
 * html_albummenu2()
 *
 * This function draws the links for moderator menu of Albums
 *
 * @param integer $id ID of the album for which the links are being drawn
 * @return string The evaluated template block with links
 **/
function html_albummenu2($id) {
    global $lang_album_admin_menu;

    /**
     * This template variable can be defined in theme.php of respective theme.
     * This is done here for simplicity.
     */    
    $template_album_moderator_menu = <<<EOT
        <table border="0" cellpadding="0" cellspacing="1">
                <tr>
                        <td align="center" valign="middle" class="admin_menu">
                                <a href="editpics.php?album={ALBUM_ID}"  class="adm_menu">{EDIT_PICS}</a>
                        </td>
                </tr>
        </table>                        
EOT;
    
    
    static $template = '';

    if ($template == '') {
        $params = array(
            '{EDIT_PICS}' => $lang_album_admin_menu['edit_pics'],
            );

        $template = template_eval($template_album_moderator_menu, $params);
    }

    $params = array('{ALBUM_ID}' => $id,
        );

    return template_eval($template, $params);  
}
[/code]

just after

[code]
define('IN_COPPERMINE', true);
[/code]

replace (there will be 4 instances of this code and you need to replace all 4 instances)

[code]
$alb_list[$alb_idx]['album_adm_menu'] = (GALLERY_ADMIN_MODE || (USER_ADMIN_MODE && $cat == USER_ID + FIRST_USER_CAT)) ? html_albummenu($alb_thumb['aid']) : '';
[/code]

with

[code]
$alb_list[$alb_idx]['album_adm_menu'] = (GALLERY_ADMIN_MODE || (USER_ADMIN_MODE && $cat == USER_ID + FIRST_USER_CAT)) ? html_albummenu($alb_thumb['aid']) : (in_array($alb_thumb['aid'], $USER_DATA['allowed_albums']) ? html_albummenu2($alb_thumb['aid']) : '');
[/code]

 
######### modifyalb.php ###########

Add

[code]
if (GALLERY_ADMIN_MODE) {
  $data[] = array($lang_modifyalb_php['can_moderate'], 'moderator_group', 8);
}
[/code]

just before

[code]
function get_subcat_data($parent, $ident = '')
[/code]

Add

[code]
function form_moderator($text, $name) {
    global $CONFIG,$ALBUM_DATA,$lang_modifyalb_php;
    $result = cpg_db_query("SELECT group_id, group_name FROM {$CONFIG['TABLE_USERGROUPS']} WHERE group_id > 1");
    $options[0] = $lang_modifyalb_php['none'];
    while ($group = mysql_fetch_array($result)) {
        $options[$group['group_id']] = sprintf($lang_modifyalb_php['groupp_only'], $group['group_name']);
    } // while

    echo <<<EOT
        <tr>
                <td class="tableb">
                        $text
                </td>
                <td class="tableb" valign="top">
                        <select name="$name" class="listbox">

EOT;
    foreach ($options as $value => $caption) {
        echo '                                <option value ="' . $value . '"' . ($ALBUM_DATA['moderator_group'] == $value ? ' selected': '') . '>' . $caption . "</option>\n";
    }
    echo <<<EOT
                        </select>
                </td>
        </tr>

EOT;
}
[/code]

just before

[code]
function create_form(&$data)
[/code]

Add

[code]
                case 8 :
                    form_moderator($element[0], $element[1]);
                    break;
[/code]

just before

[code]
                default:
                    cpg_die(CRITICAL_ERROR, 'Invalid action for form creation', __FILE__, __LINE__);
[/code]


################## include/functions.inc.php ###############

replace

[code]
function get_pic_data($album, &$count, &$album_name, $limit1=-1, $limit2=-1, $set_caption = true)
{
        global $USER, $CONFIG, $ALBUM_SET, $META_ALBUM_SET, $CURRENT_CAT_NAME, $CURRENT_ALBUM_KEYWORD, $HTML_SUBST, $THEME_DIR, $FAVPICS, $FORBIDDEN_SET_DATA;
[/code]

with

[code]
function get_pic_data($album, &$count, &$album_name, $limit1=-1, $limit2=-1, $set_caption = true)
{
        global $USER, $CONFIG, $ALBUM_SET, $META_ALBUM_SET, $CURRENT_CAT_NAME, $CURRENT_ALBUM_KEYWORD, $HTML_SUBST, $THEME_DIR, $FAVPICS, $FORBIDDEN_SET_DATA, $USER_DATA;
[/code]

replace

[code]
$approved = GALLERY_ADMIN_MODE ? '' : 'AND approved=\'YES\'';
[/code]

with

[code]
                if (is_array($USER_DATA['allowed_albums']) && in_array($album,$USER_DATA['allowed_albums'])) {
                  $approved = '';
                } else {
                  $approved = GALLERY_ADMIN_MODE ? '' : 'AND approved=\'YES\'';
                }
[/code]


############## include/init.inc.php ###############

Add

[code]
if (!GALLERY_ADMIN_MODE) {
  $result = cpg_db_query("SELECT DISTINCT(aid) FROM {$CONFIG['TABLE_ALBUMS']} WHERE moderator_group IN ".USER_GROUP_SET);
  if (mysql_num_rows($result)) {
    while ($row = mysql_fetch_array($result)) {
      $USER_DATA['allowed_albums'][] = $row['aid'];
    }
  }
}
[/code]

just before

[code]
// Process theme selection if present in URI or in user profile
if (!empty($_GET['theme'])) {
[/code]


############### lang/english.php (or your language file) ##############

Add

[code]
  'can_moderate' => 'Album can be moderated by',
  'none' => 'None',
[/code]

just after

[code]
  'parent_category' =>'Parent category', //cpg1.4
  'thumbnail_view' =>'Thumbnail view', //cpg1.4
[/code]