/**
 * __wp_supercustom_cms_get_all_user_roles_names() - Returns an array with all user roles_names in it.
 * Inclusive self defined roles (for example with the 'Role Manager' plugin).
 * @uses $wp_roles
 * @return $user_roles_names
 */
function __wp_supercustom_cms_get_all_user_roles_names()
{
    global $wp_roles;
    $user_roles_names = array();
    foreach ($wp_roles->role_names as $role_name => $data) {
        if (function_exists('translate_user_role')) {
            $data = translate_user_role($data);
        } else {
            $data = translate_with_context($data);
        }
        array_push($user_roles_names, $data);
    }
    return $user_roles_names;
}
Exemple #2
0
            }
        }
        unset($users_of_blog);
        $current_role = false;
        $class = empty($role) ? ' class="current"' : '';
        $role_links[] = "<li><a href='users.php'{$class}>" . sprintf(__ngettext('All <span class="count">(%s)</span>', 'All <span class="count">(%s)</span>', $total_users), number_format_i18n($total_users)) . '</a>';
        foreach ($wp_roles->get_names() as $this_role => $name) {
            if (!isset($avail_roles[$this_role])) {
                continue;
            }
            $class = '';
            if ($this_role == $role) {
                $current_role = $role;
                $class = ' class="current"';
            }
            $name = translate_with_context($name);
            $name = sprintf(_c('%1$s <span class="count">(%2$s)</span>|user role with count'), $name, $avail_roles[$this_role]);
            $role_links[] = "<li><a href='users.php?role={$this_role}'{$class}>{$name}</a>";
        }
        echo implode(" |</li>\n", $role_links) . '</li>';
        unset($role_links);
        ?>
</ul>
</form>
</div>

<form class="search-form" action="" method="get">
<p class="search-box">
	<label class="hidden" for="user-search-input"><?php 
        _e('Search Users');
        ?>
Exemple #3
0
function WP_members_list_list()
{
    global $wp_roles, $getWP, $tern_wp_msg, $tern_wp_members_defaults, $current_user, $notice;
    get_currentuserinfo();
    $o = $getWP->getOption('tern_wp_members', $tern_wp_members_defaults);
    $wps = new WP_User_Search($_GET['query'], $_GET['userspage'], $_GET['role']);
    $paging_text = paginate_links(array('total' => ceil($wps->total_users_for_query / $wps->users_per_page), 'current' => $wps->page, 'base' => 'admin.php?page=members-list-edit-members-list&%_%', 'format' => 'userspage=%#%', 'add_args' => $args));
    if ($paging_text) {
        $paging_text = sprintf('<span class="displaying-num">' . __('Displaying %s&#8211;%s of %s') . '</span>%s', number_format_i18n(($wps->page - 1) * $wps->users_per_page + 1), number_format_i18n(min($wps->page * $wps->users_per_page, $wps->total_users_for_query)), number_format_i18n($wps->total_users_for_query), $paging_text);
    }
    ?>
	<div class="wrap">
		<div id="icon-users" class="icon32"><br /></div>
		<h2>Members List</h2>
		<?php 
    if (!empty($notice)) {
        ?>
<div id="notice" class="error"><p><?php 
        echo $notice;
        ?>
</p></div><?php 
    }
    ?>
		<p>Here you are able to select which of your members you'd like to show or hide in your members list. By default all members are showm.</p>
		<?php 
    if (!empty($tern_wp_msg)) {
        echo '<div id="message" class="updated fade"><p>' . $tern_wp_msg . '</p></div>';
    }
    ?>
		<div class="filter">
			<form id="list-filter" action="" method="get">
				<ul class="subsubsub">
					<?php 
    $l = array();
    $a = array();
    $u = get_users_of_blog();
    $t = count($u);
    foreach ((array) $u as $c) {
        $d = unserialize($c->meta_value);
        foreach ((array) $d as $e => $v) {
            if (!isset($a[$e])) {
                $a[$e] = 0;
            }
            $a[$e]++;
        }
    }
    unset($u);
    $current_role = false;
    $class = empty($role) ? ' class="current"' : '';
    $l[] = "<li><a href='admin.php?page=members-list-edit-members-list'{$class}>" . sprintf(__ngettext('All<span class="count">(%s)</span>', 'All <span class="count">(%s)</span>', $t), number_format_i18n($t)) . '</a>';
    foreach ($wp_roles->get_names() as $s => $name) {
        if (!isset($a[$s])) {
            continue;
        }
        $class = '';
        if ($s == $role) {
            $current_role = $role;
            $class = ' class="current"';
        }
        $name = translate_with_context($name);
        $name = sprintf(_c('%1$s <span class="count">(%2$s)</span>|user role with count'), $name, $a[$s]);
        $l[] = "<li><a href='admin.php?page=members-list-edit-members-list&role={$s}'{$class}>{$name}</a>";
    }
    echo implode(" |</li>\n", $l) . '</li>';
    unset($l);
    ?>
				</ul>
			</form>
		</div>
		<form class="search-form" action="" method="get">
			<p class="search-box">
				<label class="hidden" for="user-search-input">Search Users:</label>
				<input type="text" class="search-input" id="user-search-input" name="query" value="" />
				<input type="hidden" id="page" name="page" value="<?php 
    echo $_REQUEST['page'];
    ?>
" />
				<input type="submit" value="Search Users" class="button" />
			</p>
		</form>
		<form id="posts-filter" action="" method="get">
			<div class="tablenav">
				<?php 
    if ($wps->results_are_paged()) {
        ?>
					<div class="tablenav-pages"><?php 
        echo $paging_text;
        ?>
</div>
				<?php 
    }
    ?>
				<div class="alignleft actions">
					<select name="action">
						<option value="" selected="selected">Bulk Actions</option>
						<option value="show">Show</option>
						<option value="hide">Hide</option>
					</select>
					<input type="submit" value="Apply" name="doaction" id="doaction" class="button-secondary action" />
				</div>
				<br class="clear" />
			</div>
			<table class="widefat fixed" cellspacing="0">
				<thead>
				<tr class="thead">
					<th scope="col" id="cb" class="manage-column column-cb check-column" style=""><input type="checkbox" /></th>
					<th scope="col" id="username" class="manage-column column-username" style="">Username</th>
					<th scope="col" id="name" class="manage-column column-name" style="">Name</th>
					<th scope="col" id="email" class="manage-column column-email" style="">E-mail</th>
					<th scope="col" id="role" class="manage-column column-role" style="">Role</th>
					<th scope="col" id="displayed" class="manage-column column-displayed" style="">Displayed</th>
				</tr>
				</thead>
				<tfoot>
				<tr class="thead">
					<th scope="col"  class="manage-column column-cb check-column" style=""><input type="checkbox" /></th>
					<th scope="col"  class="manage-column column-username" style="">Username</th>
					<th scope="col"  class="manage-column column-name" style="">Name</th>
					<th scope="col"  class="manage-column column-email" style="">E-mail</th>
					<th scope="col"  class="manage-column column-role" style="">Role</th>
					<th scope="col" id="displayed" class="manage-column column-displayed" style="">Displayed</th>
				</tr>
				</tfoot>
				<tbody id="users" class="list:user user-list">
<?php 
    //
    $c = 0;
    //foreach($m as $u) {
    foreach ($wps->get_results() as $u) {
        $u = new WP_User($u);
        $r = $u->roles;
        $r = array_shift($r);
        if (!empty($_REQUEST['role']) and $_REQUEST['role'] != $r) {
            continue;
        }
        $d = is_float($c / 2) ? '' : ' class="alternate"';
        $nu = $current_user;
        $e = $u->ID == $nu->ID ? 'profile.php' : 'user-edit.php?user_id=' . $u->ID . '&#038;wp_http_referer=' . wp_get_referer();
        ?>
		<tr id='user-<?php 
        echo $u->ID;
        ?>
'<?php 
        echo $d;
        ?>
>
			<th scope='row' class='check-column'><input type='checkbox' name='users[]' id='user_<?php 
        echo $u->ID;
        ?>
' class='administrator' value='<?php 
        echo $u->ID;
        ?>
' /></th>
			<td class="username column-username">
				<?php 
        echo get_avatar($u->ID, 32);
        ?>
				<strong>
					<a href="<?php 
        echo $e;
        ?>
"><?php 
        echo $u->user_nicename;
        ?>
</a>
				</strong><br />
				<div class="row-actions">
					<span class='edit'><a href="admin.php?page=members-list-edit-members-list&users%5B%5D=<?php 
        echo $u->ID;
        ?>
&action=show&_wpnonce=<?php 
        echo wp_create_nonce('tern_wp_members_nonce');
        ?>
">Show</a> | </span>
					<span class='edit'><a href="admin.php?page=members-list-edit-members-list&users%5B%5D=<?php 
        echo $u->ID;
        ?>
&action=hide&_wpnonce=<?php 
        echo wp_create_nonce('tern_wp_members_nonce');
        ?>
">Hide</a></span>
				</div>
			</td>
			<td class="name column-name"><?php 
        echo $u->first_name . ' ' . $u->last_name;
        ?>
</td>
			<td class="email column-email"><a href='mailto:<?php 
        echo $u->user_email;
        ?>
' title='e-mail: <?php 
        echo $u->user_email;
        ?>
'><?php 
        echo $u->user_email;
        ?>
</a></td>
			<td class="role column-role"><?php 
        echo $r;
        ?>
</td>
			<td class="role column-displayed"><?php 
        if (!empty($o['hidden']) and in_array($u->ID, $o['hidden'])) {
            echo 'no';
        } else {
            echo 'yes';
        }
        ?>
</td>
		</tr>
<?php 
        $c++;
    }
    ?>
				</tbody>
			</table>
			<div class="tablenav">
				<div class="alignleft actions">
					<select name="action2">
						<option value="" selected="selected">Bulk Actions</option>
						<option value="show">Show</option>
						<option value="hide">Hide</option>
					</select>
					<input type="hidden" id="page" name="page" value="members-list-edit-members-list" />
					<input type="hidden" id="_wpnonce" name="_wpnonce" value="<?php 
    echo wp_create_nonce('tern_wp_members_nonce');
    ?>
" />
					<input type="submit" value="Apply" name="doaction2" id="doaction2" class="button-secondary action" />
				</div>
				<br class="clear" />
			</div>
		</form>
	</div>
<?php 
}
/**
 * {@internal Missing Short Description}}
 *
 * @since unknown
 *
 * @param unknown_type $default
 */
function wp_dropdown_roles( $default = false ) {
	global $wp_roles;
	$p = '';
	$r = '';
	foreach( $wp_roles->role_names as $role => $name ) {
		$name = translate_with_context($name);
		if ( $default == $role ) // Make default first in list
			$p = "\n\t<option selected='selected' value='$role'>$name</option>";
		else
			$r .= "\n\t<option value='$role'>$name</option>";
	}
	echo $p . $r;
}
Exemple #5
0
/**
 * Retrieve context translated string.
 *
 * Quite a few times, there will be collisions with similar translatable text
 * found in more than two places but with different translated context.
 *
 * In order to use the separate contexts, the _c() function is used and the
 * translatable string uses a pipe ('|') which has the context the string is in.
 *
 * When the translated string is returned, it is everything before the pipe, not
 * including the pipe character. If there is no pipe in the translated text then
 * everything is returned.
 *
 * @since 2.2.0
 *
 * @param string $text Text to translate
 * @param string $domain Optional. Domain to retrieve the translated text
 * @return string Translated context string without pipe
 */
function _c($text, $domain = 'default')
{
    return translate_with_context($text, $domain);
}
/**
* Display user management interfaces based on options.
*/
function wp_super_edit_user_management_ui()
{
    global $wp_roles, $wp_super_edit;
    switch ($wp_super_edit->management_mode) {
        case 'single':
            $user_management_text = __('This arrangement of visual editor buttons will apply to all users');
            break;
        case 'roles':
            $user_management_text = __('The arrangement of visual editor buttons will apply to all users in the selected Role or Default user button setting.<br />');
            $roles = array();
            $roles['wp_super_edit_default'] = __('Default Button Settings');
            foreach ($wp_roles->role_names as $role => $name) {
                $name = translate_with_context($name);
                $roles[$role] = $name;
                if ($_REQUEST['wp_super_edit_manage_role'] == $role || $_REQUEST['wp_super_edit_user'] == $role) {
                    $selected = $role;
                }
            }
            $role_select = wp_super_edit_form_select('wp_super_edit_manage_role', $roles, $selected, true);
            $submit_button = wp_super_edit_submit_button(__('Load Button Settings'), '', true);
            $submit_button_group = wp_super_edit_html_tag(array('tag' => 'p', 'tag_content' => __('Select User Role to Edit: ') . $role_select . $submit_button, 'return' => true));
            $user_management_text .= wp_super_edit_form('role_select', $submit_button_group, true, 'submitButtonConfig();');
            break;
        case 'users':
            $user_management_text = __('Users can arrange buttons under the Users tab. Changes to this button arrangement will only affect the defult button settings.');
            break;
        default:
            break;
    }
    $user_management_text = '<strong>' . $wp_super_edit->management_modes[$wp_super_edit->management_mode] . ':</strong> ' . $user_management_text;
    wp_super_edit_html_tag(array('tag' => 'div', 'id' => 'wp_super_edit_user_management', 'tag_content' => $user_management_text));
}
            <th scope="col" class="manage-column column-name" style="">Name</th>
            <th scope="col" class="manage-column column-email" style="">E-mail</th>
            <th scope="col" class="manage-column column-role" style="">Role</th>
            <th scope="col" class="manage-column column-role" style=""><input type="submit" name="reset_explicit_edit" value="reset explicit" class="button-secondary" style="padding: 3px 5px"/></th>
            <th scope="col" class="manage-column column-role" style=""><input type="submit" name="reset_explicit_php" value="reset explicit" class="button-secondary" style="padding: 3px 5px"/></th>
        </tr>
    </tfoot>
    
    <tbody id="users" class="list:user user-list">

<?php 
        $editOtherConflict = false;
        foreach ($search->get_results() as $id) {
            $user = new WP_User($id);
            $role = $user->roles[0];
            $roleName = isset($wp_roles->role_names[$role]) ? translate_with_context($wp_roles->role_names[$role]) : __('None');
            $user_has_php_cap = $php_exec_admin->item_has_cap($user, PHP_EXECUTION_CAPABILITY);
            $php_is_explicit_cap = $php_exec_admin->is_explicit_cap($user, PHP_EXECUTION_CAPABILITY);
            $user_has_edit_cap = $php_exec_admin->item_has_either_caps($user, $EDIT_CAPS);
            $edit_is_explicit_cap = $php_exec_admin->user_has_either_role_caps($user, $EDIT_CAPS);
            $edit_is_explicit_cap = $user_has_edit_cap != $edit_is_explicit_cap;
            switch (true) {
                // no permission inherited from role
                case !$php_is_explicit_cap && !$user_has_php_cap:
                    $permission = '<img src="' . PHP_EXECUTION_BASE_URL . '/assets/cross.png" /> <input type="submit" name="userPHP[' . $id . ']" value="enable" class="button-secondary"/> ';
                    break;
                    // no permission explicitly set
                // no permission explicitly set
                case $php_is_explicit_cap && !$user_has_php_cap:
                    $permission = '<img src="' . PHP_EXECUTION_BASE_URL . '/assets/delete.png" /> <input type="submit" name="userPHP[' . $id . ']" value="enable" class="button-secondary"/> ';
                    break;
function wpmuLdapAddGenRoleBox($id)
{
    global $wp_roles;
    echo '<select name="user[' . $id . ']" id="' . $id . '">';
    foreach ($wp_roles->role_names as $role => $name) {
        $name = translate_with_context($name);
        $selected = '';
        if ($role == 'subscriber') {
            $selected = 'selected="selected"';
        }
        echo "<option {$selected} value=\"{$role}\">{$name}</option>";
    }
    echo '</select>';
}
Exemple #9
0
 function groupe_role_option($disible = false)
 {
     global $wp_roles, $xoops_db;
     if ($disible) {
         $disible_str = ' disabled="disabled"';
     } else {
         $disible_str = '';
     }
     $form = '';
     $form .= '<tr><th><label for="role">' . __('Role Setting at Login', 'xpressme') . '</label></th>';
     $form .= '<td>';
     $form .= "<table>\n";
     $form .= "<tr>\n";
     if (xpress_is_multiblog_root()) {
         $form .= "<td>" . __('XOOPS administrators role is set as all blog administrators.', 'xpressme') . "</td>\n";
         $form .= "<td>\n";
         $form .= $this->yes_no_radio_option_sub('admin_set_all_blog_admin', __('YES', 'xpressme'), __('NO', 'xpressme'));
         $form .= "</td>\n";
         $form .= "</tr>\n";
     }
     $form .= '<tr><td>' . __('XOOPS Groupe', 'xpressme') . '</td><td>' . __('WordPress Role', 'xpressme') . '</td><td>' . __('Role is set at each login', 'xpressme') . "</td></tr>\n";
     foreach ($this->groupe_role as $groupe) {
         if ($groupe->group_type == 'module_inhibit') {
             $form .= "<tr>";
             $form .= "<td> {$groupe->name} </td>";
             $form .= "<td>" . __('module cannot be read', 'xpressme') . "</td>";
             $form .= "</tr>\n";
             continue;
         }
         $form .= "<tr>";
         $form .= "<td> {$groupe->name} </td>";
         $form .= "<td>\n" . '<select name="role_gid_' . $groupe->groupid . '" id="role_gid_' . $groupe->groupid . '"' . $disible_str . '>' . "\n";
         $role_list = '';
         $group_has_role = false;
         $select_value = $groupe->role;
         foreach ($wp_roles->role_names as $role => $name) {
             if (function_exists('translate_user_role')) {
                 $name = translate_user_role($name);
             } else {
                 $name = translate_with_context($name);
             }
             if ($role == $select_value) {
                 $selected = ' selected="selected"';
                 $group_has_role = true;
             } else {
                 $selected = '';
             }
             $admin_select_role = $this->admin_select_groupe_role();
             if ($admin_select_role || $groupe->group_type != 'module_admin' || !empty($selected)) {
                 $role_list .= "<option value=\"{$role}\"{$selected}>{$name}</option>\n";
             }
             if (!$admin_select_role && $groupe->group_type == 'module_admin') {
                 if ($role == 'administrator') {
                     $role_list .= "<option value=\"{$role}\" selected=\"selected\">{$name}</option>\n";
                 }
             }
         }
         if ($this->admin_select_groupe_role() || $groupe->group_type != 'module_admin') {
             if ($group_has_role) {
                 $role_list .= '<option value="default">' . __('Default Role of WordPress', 'xpressme') . "</option>\n";
                 $role_list .= '<option value="">' . __('Group User Doesn\'t Register', 'xpressme') . "</option>\n";
             } else {
                 if ($select_value == 'default') {
                     $role_list .= '<option value="default" selected="selected">' . __('Default Role of WordPress', 'xpressme') . "</option>\n";
                     $role_list .= '<option value="">' . __('Group User Doesn\'t Register', 'xpressme') . "</option>\n";
                 } else {
                     $role_list .= '<option value="default">' . __('Default Role of WordPress', 'xpressme') . "</option>\n";
                     $role_list .= '<option value="" selected="selected">' . __('Group User Doesn\'t Register', 'xpressme') . "</option>\n";
                 }
             }
         }
         $form .= $role_list . "</select>\n</td>";
         if ($groupe->login_all) {
             $form .= '<td> <input type="checkbox" name="login_all_gid_' . $groupe->groupid . '" value="1" checked ></td>';
         } else {
             $form .= '<td> <input type="checkbox" name="login_all_gid_' . $groupe->groupid . '" value="1"></td>';
         }
         $form .= "</tr>\n";
     }
     if ($disible) {
         $form .= '<tr><p>' . __('Only the Admin can set Group Role Setting', 'xpressme') . "</p></tr>\n";
     }
     $form .= "</table></td></tr>\n";
     return $form;
 }
Exemple #10
0
/**
 * _mw_adminimize_get_all_user_roles_names() - Returns an array with all user roles_names in it.
 * Inclusive self defined roles (for example with the 'Role Manager' plugin).
 * @uses $wp_roles
 * @return $user_roles_names
 */
function _mw_adminimize_get_all_user_roles_names()
{
    global $wp_roles;
    $user_roles_names = array();
    foreach ($wp_roles->role_names as $role_name => $data) {
        if (function_exists('translate_user_role')) {
            $data = translate_user_role($data);
        } else {
            $data = translate_with_context($data);
        }
        array_push($user_roles_names, $data);
    }
    // exclude the new bbPress roles
    $user_roles_names = array_diff($user_roles_names, array(__('Keymaster', 'bbpress'), __('Moderator', 'bbpress'), __('Participant', 'bbpress'), __('Spectator', 'bbpress'), __('Blocked', 'bbpress')));
    return $user_roles_names;
}
Exemple #11
0
        _e('User&nbsp;Login:'******'Role:');
        ?>
</th>
							<td>
								<select name="new_role" id="new_role">
								<?php 
        reset($editblog_roles);
        foreach ($editblog_roles as $role => $role_assoc) {
            $name = translate_with_context($role_assoc['name']);
            $selected = $role == $editblog_default_role ? 'selected="selected"' : '';
            echo "<option {$selected} value=\"{$role}\">{$name}</option>";
        }
        ?>
								</select>
							</td>
						</tr>
					</table>

					<h3><?php 
        _e('Misc Blog Actions');
        ?>
</h3>
					<table class="form-table">
						<?php 
 /**
  * Register new user settings in users database table based on management mode.
  * @param string $user_name 
  */
 function register_new_user($user_name)
 {
     global $wpdb, $wp_roles, $userdata;
     if (!$this->is_installed) {
         return false;
     }
     switch ($this->management_mode) {
         case 'single':
             return;
         case 'roles':
             if (isset($wp_roles->role_names[$user_name])) {
                 if ($this->check_registered('user', $user_name)) {
                     return;
                 }
                 $nice_name = translate_with_context($wp_roles->role_names[$user_name]);
                 $user_settings = $this->get_user_settings('wp_super_edit_default');
                 $editor_options = maybe_unserialize($user_settings->editor_options);
                 $this->register_user_settings($user_name, $nice_name, $editor_options, $this->management_mode);
             }
             break;
         case 'users':
             if ($this->check_registered('user', $user_name)) {
                 return;
             }
             $user_settings = $this->get_user_settings('wp_super_edit_default');
             $editor_options = maybe_unserialize($user_settings->editor_options);
             $this->register_user_settings($userdata->user_login, 'user', $editor_options, $this->management_mode);
             break;
         default:
             break;
     }
 }
/**
 * Retrieve translated string with vertical bar context
 *
 * Quite a few times, there will be collisions with similar translatable text
 * found in more than two places but with different translated context.
 *
 * In order to use the separate contexts, the _c() function is used and the
 * translatable string uses a pipe ('|') which has the context the string is in.
 *
 * When the translated string is returned, it is everything before the pipe, not
 * including the pipe character. If there is no pipe in the translated text then
 * everything is returned.
 *
 * @since 2.2.0
 * @deprecated 2.9.0
 *
 * @param string $text Text to translate
 * @param string $domain Optional. Domain to retrieve the translated text
 * @return string Translated context string without pipe
 */
function _c($text, $domain = 'default')
{
    _deprecated_function(__FUNCTION__, '2.9', '_x');
    return translate_with_context($text, $domain);
}
function tdomf_show_manage_user_menu()
{
    global $wp_roles;
    $limit = 15;
    if (isset($_REQUEST['limit'])) {
        $limit = intval($_REQUEST['limit']);
    }
    $offset = 0;
    if (isset($_REQUEST['offset'])) {
        $offset = intval($_REQUEST['offset']);
    }
    if (isset($_REQUEST['f']) && $_REQUEST['f'] == "1") {
        $users = tdomf_get_users_banned($offset, $limit);
        $max = tdomf_get_users_banned_count();
    } else {
        if (isset($_REQUEST['f']) && $_REQUEST['f'] == "2") {
            $users = tdomf_get_users_trusted($offset, $limit);
            $max = tdomf_get_users_trusted_count();
        } else {
            $users = tdomf_get_users_submitted($offset, $limit);
            $max = tdomf_get_users_submitted_count();
        }
    }
    ?>

   <div class="wrap">

   <?php 
    if (isset($_REQUEST['f']) && $_REQUEST['f'] == "1") {
        ?>
       <h2><?php 
        if ($offset > 0) {
            _e("Previous Banned Users", "tdomf");
        } else {
            printf(__('Last %d Banned Users', 'tdomf'), $limit);
        }
        ?>
</h2>
   <?php 
    } else {
        if (isset($_REQUEST['f']) && $_REQUEST['f'] == "2") {
            ?>
       <h2><?php 
            if ($offset > 0) {
                _e("Previous Trusted Users", "tdomf");
            } else {
                printf(__('Last %d Trusted Users', 'tdomf'), $limit);
            }
            ?>
</h2>
   <?php 
        } else {
            ?>
       <h2><?php 
            if ($offset > 0) {
                _e("Previous Submitters", "tdomf");
            } else {
                printf(__('Last %d Submitters', 'tdomf'), $limit);
            }
            ?>
</h2>
   <?php 
        }
    }
    ?>

    <p><?php 
    _e("You can ban (and un-ban) any registered user. This means the user cannot use the forms. It has no impact on anything else. i.e. they can still read, comment and post. You can also make a user \"trusted\". This means that anything they submit using the form is automatically published.", "tdomf");
    ?>
</p>

    <p><a href="admin.php?page=tdomf_show_manage_menu&mode=ip"><?php 
    _e("Manage Submitter IPs &raquo;", "tdomf");
    ?>
</a>
    
   <form method="post" action="admin.php?page=tdomf_show_manage_menu" id="filterusers" name="filterusers" >
   <fieldset>
	  <b><?php 
    _e("Filter Users", "tdomf");
    ?>
</b>
      <select name="f">
      <option value="0" <?php 
    if (!isset($_REQUEST['f']) || isset($_REQUEST['f']) && $_REQUEST['f'] == "0") {
        ?>
 selected <?php 
    }
    ?>
><?php 
    _e("All Submitters", "tdomf");
    ?>
        <option value="1" <?php 
    if (isset($_REQUEST['f']) && $_REQUEST['f'] == "1") {
        ?>
 selected <?php 
    }
    ?>
><?php 
    _e("Banned Users", "tdomf");
    ?>
        <option value="2" <?php 
    if (isset($_REQUEST['f']) && $_REQUEST['f'] == "2") {
        ?>
 selected <?php 
    }
    ?>
><?php 
    _e("Trusted Users", "tdomf");
    ?>
      </select>
      <input type="submit" name="submit" value="Show" />
   </fieldset>
   </form>

   <br/>

   <?php 
    if (count($users) <= 0) {
        _e("There are no users to moderate with this filter.", "tdomf");
    } else {
        ?>

<script type="text/javascript">
<!--
function checkAll(form)
{
	for (i = 0, n = form.elements.length; i < n; i++) {
		if(form.elements[i].type == "checkbox") {
			if(form.elements[i].checked == true)
				form.elements[i].checked = false;
			else
				form.elements[i].checked = true;
		}
	}
}

function getNumChecked(form)
{
	var num = 0;
	for (i = 0, n = form.elements.length; i < n; i++) {
		if(form.elements[i].type == "checkbox") {
			if(form.elements[i].checked == true)
				num++;
		}
	}
	return num;
}
//-->
</script>


   <form method="post" action="admin.php?page=tdomf_show_manage_menu" id="moderateusers" name="moderateusers" >

   <table class="widefat">
   <tr>
    <th scope="col" style="text-align: center"><input type="checkbox" onclick="checkAll(document.getElementById('moderateusers'));" /></th>

    <th scope="col"><?php 
        _e("ID", "tdomf");
        ?>
</th>
	<th scope="col"><?php 
        _e("Login", "tdomf");
        ?>
</th>
	<th scope="col"><?php 
        _e("Display Name", "tdomf");
        ?>
</th>
	<th scope="col"><?php 
        _e("Role", "tdomf");
        ?>
</th>
	<th scope="col"><?php 
        _e("Status", "tdomf");
        ?>
</th>
    <th scope="col"><?php 
        _e("Submitted<br/>Approved/Total", "tdomf");
        ?>
</th>
    <th scope="col"><?php 
        _e("Contributed<br/>Approved/Total", "tdomf");
        ?>
</th>
    <th scope="col" colspan="2" style="text-align: center">Actions</th>
   </tr>

   <?php 
        $i = 0;
        foreach ($users as $u) {
            $i++;
            if ($i % 2 == 0) {
                ?>
		  <tr id='x' class=''>
	     <?php 
            } else {
                ?>
		  <tr id='x' class='alternate'>
         <?php 
            }
            ?>

               <?php 
            $u = get_userdata($u->user_id);
            ?>

               <td><input type="checkbox" name="moderateusers[]" value="<?php 
            echo $u->ID;
            ?>
" /></td>
               <th scope="row"><?php 
            echo $u->ID;
            ?>
</th>
		       <td><a href="edit.php?author=<?php 
            echo $u->ID;
            ?>
" ><?php 
            echo $u->user_login;
            ?>
</a></td>
		       <td><a href="user-edit.php?user_id=<?php 
            echo $u->ID;
            ?>
" ><?php 
            echo $u->display_name;
            ?>
</a></td>

               <td>
		       <?php 
            if (!isset($wp_roles)) {
                $wp_roles = new WP_Roles();
            }
            $roles = $wp_roles->role_objects;
            $userrole = new WP_User($u->ID);
            foreach ($roles as $role) {
                if ($userrole->has_cap($role->name)) {
                    if (function_exists('translate_with_context')) {
                        $user_role = translate_with_context($wp_roles->role_names[$role->name]);
                    } else {
                        $user_role = $wp_roles->role_names[$role->name];
                    }
                    break;
                }
            }
            ?>
		       <?php 
            echo $user_role;
            ?>
		       </td>

		       <td>
		       <?php 
            if ($userrole->has_cap('edit_others_posts')) {
                _e("N/A", "tdomf");
            } else {
                if (!get_usermeta($u->ID, TDOMF_KEY_STATUS)) {
                    _e("-", "tdomf");
                } else {
                    _e(get_usermeta($u->ID, TDOMF_KEY_STATUS), "tdomf");
                }
            }
            ?>
		       </td>

             <td>
             <a href="<?php 
            tdomf_get_mod_posts_url(array('echo' => true, 'user_id' => $u->ID));
            ?>
">
             <?php 
            echo tdomf_get_users_published_posts_count($u->ID);
            ?>
/<?php 
            echo tdomf_get_users_submitted_posts_count($u->ID);
            ?>
             </a>
             </td>

             <td><?php 
            echo tdomf_get_edits(array('user_id' => $u->ID, 'count' => true, 'state' => 'approved'));
            ?>
/<?php 
            echo tdomf_get_edits(array('user_id' => $u->ID, 'count' => true));
            ?>
</td>
                 
           <?php 
            if (isset($_REQUEST['f'])) {
                $farg = "&f=" . $_REQUEST['f'];
            }
            ?>
                 
                 
		       <td>
		       <?php 
            if ($userrole->has_cap('edit_others_posts')) {
                ?>
 N/A
		       <?php 
            } else {
                if (get_usermeta($u->ID, TDOMF_KEY_STATUS) == TDOMF_USER_STATUS_BANNED) {
                    ?>
             <a href="<?php 
                    echo wp_nonce_url("admin.php?page=tdomf_show_manage_menu&action=reset&user={$u->ID}{$farg}&offset={$offset}&limit={$limit}", 'tdomf-reset-user_' . $u->ID);
                    ?>
"><?php 
                    _e("Un-ban", "tdomf");
                    ?>
</a>
		       <?php 
                } else {
                    ?>
             <a href="<?php 
                    echo wp_nonce_url("admin.php?page=tdomf_show_manage_menu&action=ban&user={$u->ID}{$farg}&offset={$offset}&limit={$limit}", 'tdomf-ban-user_' . $u->ID);
                    ?>
"><?php 
                    _e("Ban", "tdomf");
                    ?>
</a>
           <?php 
                }
            }
            ?>
		       </td>

		       <td>
		       <?php 
            if ($userrole->has_cap('edit_others_posts')) {
                ?>
 N/A
		       <?php 
            } else {
                if (get_usermeta($u->ID, TDOMF_KEY_STATUS) == TDOMF_USER_STATUS_TRUSTED) {
                    ?>
             <a href="<?php 
                    echo wp_nonce_url("admin.php?page=tdomf_show_manage_menu&action=reset&user={$u->ID}{$farg}&offset={$offset}&limit={$limit}", 'tdomf-reset-user_' . $u->ID);
                    ?>
"><?php 
                    _e("Un-trust", "tdomf");
                    ?>
</a>
		       <?php 
                } else {
                    ?>
             <a href="<?php 
                    echo wp_nonce_url("admin.php?page=tdomf_show_manage_menu&action=trust&user={$u->ID}{$farg}&offset={$offset}&limit={$limit}", 'tdomf-trust-user_' . $u->ID);
                    ?>
"><?php 
                    _e("Trust", "tdomf");
                    ?>
</a>
           <?php 
                }
            }
            ?>
		       </td>

           </tr>

         <?php 
        }
        ?>

   </table>

   <?php 
        $farg = "0";
        if (isset($_REQUEST['f'])) {
            $farg = $_REQUEST['f'];
        }
        ?>

   <input type="hidden" name="limit" id="limit" value="<?php 
        echo $limit;
        ?>
" />
   <input type="hidden" name="offset" id="offset" value="<?php 
        echo $offset;
        ?>
" />
   <input type="hidden" name="f" id="f" value="<?php 
        echo $farg;
        ?>
" />
   <?php 
        if (function_exists('wp_nonce_field')) {
            wp_nonce_field('tdomf-manage-bulk_users');
        }
        ?>

   <p class="submit">
    <input type="submit" name="ban_button" class="delete" value="<?php 
        _e("Ban");
        ?>
" onclick="var numchecked = getNumChecked(document.getElementById('moderateusers')); if(numchecked < 1) { alert('Please select some users to ban'); return false } return confirm('You are about to ban ' + numchecked + ' users \n  \'Cancel\' to stop, \'OK\' to ban.')" />
    <input type="submit" name="trust_button" value="<?php 
        _e("Trust");
        ?>
" onclick="var numchecked = getNumChecked(document.getElementById('moderateusers')); if(numchecked < 1) { alert('Please select some users to trust'); return false } return confirm('You are about to trust ' + numchecked + ' users \n  \'Cancel\' to stop, \'OK\' to trust')" />
    <input type="submit" name="clear_button" value="<?php 
        _e("Reset");
        ?>
" onclick="var numchecked = getNumChecked(document.getElementById('moderateusers')); if(numchecked < 1) { alert('Please select some users to reset'); return false } return confirm('You are about to reset the status of ' + numchecked + ' users \n  \'Cancel\' to stop, \'OK\' to reset')" />
   </p>

   </form>

   <br/><br/>

   <div class="navigation">
   <?php 
        if ($max - ($offset + $limit) > 0) {
            ?>
      <div class="alignleft"><a href="admin.php?page=tdomf_show_manage_menu&offset=<?php 
            echo $offset + $limit;
            if (isset($_REQUEST['f'])) {
                echo "&f=" . $_REQUEST['f'];
            }
            ?>
">&laquo; <?php 
            _e("Previous Entries", "tdomf");
            ?>
</a></div>
   <?php 
        }
        ?>

   <?php 
        if ($offset > 0) {
            ?>
      <div class="alignright"><a href="admin.php?page=tdomf_show_manage_menu&offset=<?php 
            echo $offset - $limit;
            if (isset($_REQUEST['f'])) {
                echo "&f=" . $_REQUEST['f'];
            }
            ?>
"><?php 
            _e("Next Entries", "tdomf");
            ?>
 &raquo;</a></div>
   <?php 
        }
        ?>
   </div>

   <br/><br/>

   <?php 
    }
    ?>

   </div> <!-- wrap -->

   <?php 
}
function tdomf_show_form_options($form_id)
{
    global $wp_version;
    if (!tdomf_form_exists($form_id)) {
        ?>
    <div class="wrap"><font color="red"><?php 
        printf(__("Form id %d does not exist!", "tdomf"), $form_id);
        ?>
</font></div>
  <?php 
    } else {
        ?>
    
    <?php 
        $pages = tdomf_get_option_form(TDOMF_OPTION_CREATEDPAGES, $form_id);
        $updated_pages = false;
        if ($pages != false) {
            $updated_pages = array();
            foreach ($pages as $page_id) {
                if (get_permalink($page_id) != false) {
                    $updated_pages[] = $page_id;
                }
            }
            if (count($updated_pages) == 0) {
                $updated_pages = false;
            }
            tdomf_set_option_form(TDOMF_OPTION_CREATEDPAGES, $updated_pages, $form_id);
        }
        ?>

    
    <div class="wrap">
    
    <h2><?php 
        printf(__("Form %d Options", "tdomf"), $form_id);
        ?>
</h2>
    
    <?php 
        tdomf_forms_under_title_toolbar($form_id);
        ?>
     
          <?php 
        if ($updated_pages == false) {
            ?>
          
             <?php 
            $create_form_link = "admin.php?page=tdomf_show_form_options_menu&action=create_form_page&form={$form_id}";
            if (function_exists('wp_nonce_url')) {
                $create_form_link = wp_nonce_url($create_form_link, 'tdomf-create-form-page');
            }
            ?>
    <p><a href="<?php 
            echo $create_form_link;
            ?>
"><?php 
            _e("Create a page with this form automatically &raquo;", "tdomf");
            ?>
</a></p>
          <?php 
        }
        ?>
          
    <?php 
        if (tdomf_wp23()) {
            ?>
          <p><a href="admin.php?page=tdomf_show_form_menu&form=<?php 
            echo $form_id;
            ?>
"><?php 
            printf(__("Widgets for Form %d &raquo;", "tdomf"), $form_id);
            ?>
</a></p>
    <?php 
        }
        ?>
    
    <br/>
    
    <form method="post" action="admin.php?page=tdomf_show_form_options_menu&form=<?php 
        echo $form_id;
        ?>
">

    <input type="hidden" id="tdomf_form_id" name="tdomf_form_id" value="<?php 
        echo $form_id;
        ?>
" />
    <?php 
        if (function_exists('wp_nonce_field')) {
            wp_nonce_field('tdomf-options-save');
        }
        ?>
    
    <div id="form_options_tabs" class="tabs">
    <ul>
        <li><a href="#form_gen"><span><?php 
        _e('General', 'tdomf');
        ?>
</span></a></li>
        <li><a href="#form_access"><span><?php 
        _e('Access Control', 'tdomf');
        ?>
</span></a></li>
        <li><a href="#form_new"><span><?php 
        _e('Submitting', 'tdomf');
        ?>
</span></a></li>
        <li><a href="#form_edit"><span><?php 
        _e('Editing', 'tdomf');
        ?>
</span></a></li>
        <li><a href="#form_moderation"><span><?php 
        _e('Moderation', 'tdomf');
        ?>
</span></a></li>
        <li><a href="#form_throttling"><span><?php 
        _e('Throttling', 'tdomf');
        ?>
</span></a></li>
        <li><a href="#form_spam"><span><?php 
        _e('Spam Protection', 'tdomf');
        ?>
</span></a></li>
    </ul>

    <div id="form_gen">

<?php 
        $form_name = tdomf_get_option_form(TDOMF_OPTION_NAME, $form_id);
        ?>
    <p>
        <label for="tdomf_form_name">
            <?php 
        _e("Form Name:", "tdomf");
        ?>
        </label>
        <input type="text" name="tdomf_form_name" id="tdomf_form_name" value="<?php 
        if ($form_name) {
            echo htmlentities(stripslashes($form_name), ENT_QUOTES, get_bloginfo('charset'));
        }
        ?>
" />
	</p>    
     
   <?php 
        $form_descp = tdomf_get_option_form(TDOMF_OPTION_DESCRIPTION, $form_id);
        ?>
   <p>
        <label for="tdomf_form_descp">   
            <?php 
        _e('Form Description', "tdomf");
        ?>
<br/>
        </label>
        <textarea cols="80" rows="3" name="tdomf_form_descp" id="tdomf_form_descp"><?php 
        if ($form_descp) {
            echo htmlentities(stripslashes($form_descp), ENT_NOQUOTES, get_bloginfo('charset'));
        }
        ?>
</textarea>
   </p>

    <script type="text/javascript">
         //<![CDATA[
        
          function tdomf_enable_use_type_posts() {
            var flag = document.getElementById("tdomf_use_type_posts").checked;
            var flag_edit = document.getElementById("tdomf_mode_edit").checked;
            var flag_new = document.getElementById("tdomf_mode_new").checked;
            if(flag_new) {
                document.getElementById("tdomf_def_cat").disabled = !flag;
            }
            if(flag_edit) {
                //document.getElementById("tdomf_edit_cat_only").disabled = !flag;
                document.getElementById("tdomf_edit_cats").disabled = !flag;
            }
          }
          
          function tdomf_enable_edit() {
            var flag = !document.getElementById("tdomf_mode_edit").checked;
            var flag_posts = document.getElementById("tdomf_use_type_posts").checked;
            
            // disable 'new' options
            
            var flag_posts = document.getElementById("tdomf_use_type_posts").checked;
            if(flag_posts) {
                document.getElementById("tdomf_def_cat").disabled = !flag;
            }
            document.getElementById("tdomf_queue_period").disabled = !flag;
            document.getElementById("tdomf_queue_on_all").disabled = !flag;

            // re-enable 'edit' options
            
            document.getElementById("tdomf_edit_tdomf_only").disabled = flag;
            if(flag_posts) {
                //document.getElementById("tdomf_edit_cat_only").disabled = flag;
                document.getElementById("tdomf_edit_cats").disabled = flag;
            }
            
            document.getElementById("tdomf_ajax_edit").disabled = flag;
            document.getElementById("tdomf_add_edit_link_none").disabled = flag;
            <?php 
        if (get_option(TDOMF_OPTION_YOUR_SUBMISSIONS)) {
            ?>
 
                document.getElementById("tdomf_add_edit_link_your_submissions").disabled = flag;
            <?php 
        }
        ?>
            document.getElementById("tdomf_add_edit_link_custom").disabled = flag;
            document.getElementById("tdomf_add_edit_link_custom_url").disabled = flag;
            
            document.getElementById("tdomf_auto_edit_link_none").disabled = flag;
            <?php 
        if (get_option(TDOMF_OPTION_YOUR_SUBMISSIONS)) {
            ?>
 
                document.getElementById("tdomf_auto_edit_link_your_submissions").disabled = flag;
            <?php 
        }
        ?>
            document.getElementById("tdomf_auto_edit_link_custom").disabled = flag;
            document.getElementById("tdomf_auto_edit_link_custom_url").disabled = flag;
            
            document.getElementById("tdomf_author_edit").disabled = flag;
            document.getElementById("tdomf_time_edit").disabled = flag;

            // enable / disable tabs
            
            <?php 
        if (version_compare($wp_version, "2.8-beta2", ">=")) {
            ?>
            var selected = jQuery("#form_options_tabs").data('selected.tabs');
            if(!flag) {
                jQuery("#form_options_tabs").tabs("enable",3);
                if(selected == 1) {
                    jQuery("#form_options_tabs").tabs("select",3);
                }
                jQuery("#form_options_tabs").tabs("disable",2);
            } else {
                jQuery("#form_options_tabs").tabs("enable",2);
                if(selected == 2) {
                    jQuery("#form_options_tabs").tabs("select",2);
                }
                jQuery("#form_options_tabs").tabs("disable",3);
            }
            <?php 
        } else {
            ?>
            var selected = jQuery("#form_options_tabs > ul").data('selected.tabs');                
            if(!flag) {
                jQuery("#form_options_tabs > ul").tabs("enable",3);
                if(selected == 1) {
                    jQuery("#form_options_tabs > ul").tabs("select",3);
                }
                jQuery("#form_options_tabs > ul").tabs("disable",2);
            } else {
                jQuery("#form_options_tabs > ul").tabs("enable",2);
                if(selected == 2) {
                    jQuery("#form_options_tabs > ul").tabs("select",2);
                }
                jQuery("#form_options_tabs > ul").tabs("disable",3);
            }
            <?php 
        }
        ?>
          }
          
          function tdomf_enable_new() {
            var flag = !document.getElementById("tdomf_mode_new").checked;
            
            // re-enable 'new' options
            
            var flag_posts = document.getElementById("tdomf_use_type_posts").checked;
            if(flag_posts) {
                document.getElementById("tdomf_def_cat").disabled = flag;
            }
            document.getElementById("tdomf_queue_period").disabled = flag;
            document.getElementById("tdomf_queue_on_all").disabled = flag;            
            
            // disable 'edit' options
            
            document.getElementById("tdomf_edit_tdomf_only").disabled = !flag;
            if(flag_posts) {
                //document.getElementById("tdomf_edit_cat_only").disabled = !flag;
                document.getElementById("tdomf_edit_cats").disabled = !flag;
            }
            
            document.getElementById("tdomf_ajax_edit").disabled = flag;
            document.getElementById("tdomf_add_edit_link_none").disabled = flag;
            <?php 
        if (get_option(TDOMF_OPTION_YOUR_SUBMISSIONS)) {
            ?>
 
                document.getElementById("tdomf_add_edit_link_your_submissions").disabled = flag;
            <?php 
        }
        ?>
            document.getElementById("tdomf_add_edit_link_custom").disabled = flag;
            document.getElementById("tdomf_add_edit_link_custom_url").disabled = flag;
            
            document.getElementById("tdomf_auto_edit_link_none").disabled = flag;
            <?php 
        if (get_option(TDOMF_OPTION_YOUR_SUBMISSIONS)) {
            ?>
 
                document.getElementById("tdomf_auto_edit_link_your_submissions").disabled = flag;
            <?php 
        }
        ?>
            document.getElementById("tdomf_auto_edit_link_custom").disabled = flag;
            document.getElementById("tdomf_auto_edit_link_custom_url").disabled = flag;
            
            document.getElementById("tdomf_author_edit").disabled = !flag;
            document.getElementById("tdomf_time_edit").disabled = !flag;
            
            // enable / disable tabs
            
            <?php 
        if (version_compare($wp_version, "2.8-beta2", ">=")) {
            ?>
            var selected = jQuery("#form_options_tabs").data('selected.tabs');
            if(!flag) {
                jQuery("#form_options_tabs").tabs("enable",2);
                if(selected == 2) {
                    jQuery("#form_options_tabs").tabs("select",2);
                }
                jQuery("#form_options_tabs").tabs("disable",3);
            } else {
                jQuery("#form_options_tabs").tabs("enable",3);
                if(selected == 1) {
                    jQuery("#form_options_tabs").tabs("select",3);
                }
                jQuery("#form_options_tabs").tabs("disable",2);
            }                
            <?php 
        } else {
            ?>
            var selected = jQuery("#form_options_tabs > ul").data('selected.tabs');
            if(!flag) {
                jQuery("#form_options_tabs > ul").tabs("enable",2);
                if(selected == 2) {
                    jQuery("#form_options_tabs > ul").tabs("select",2);
                }
                jQuery("#form_options_tabs > ul").tabs("disable",3);
            } else {
                jQuery("#form_options_tabs > ul").tabs("enable",3);
                if(selected == 1) {
                    jQuery("#form_options_tabs > ul").tabs("select",3);
                }
                jQuery("#form_options_tabs > ul").tabs("disable",2);
            }
            <?php 
        }
        ?>
          }
    //-->
    </script>
   
    <?php 
        $use_page = tdomf_get_option_form(TDOMF_OPTION_SUBMIT_PAGE, $form_id);
        ?>
    <?php 
        $edit_form = tdomf_get_option_form(TDOMF_OPTION_FORM_EDIT, $form_id);
        ?>
    
    
    <script type="text/javascript">
         //<![CDATA[
         jQuery(document).ready(function(){
         <?php 
        if (!$edit_form) {
            ?>
           <?php 
            if (version_compare($wp_version, "2.8-beta2", ">=")) {
                ?>
           jQuery("#form_options_tabs").tabs("disable",3);               
           <?php 
            } else {
                ?>
           jQuery("#form_options_tabs > ul").tabs("disable",3);
           <?php 
            }
            ?>
         <?php 
        } else {
            ?>
           <?php 
            if (version_compare($wp_version, "2.8-beta2", ">=")) {
                ?>
           jQuery("#form_options_tabs").tabs("disable",2);               
           <?php 
            } else {
                ?>
           jQuery("#form_options_tabs > ul").tabs("disable",2);
           <?php 
            }
            ?>
         <?php 
        }
        ?>
         });
    //-->
    </script>
    
	<p>
        <?php 
        _e('This form will be used to', 'tdomf');
        ?>
        <input type="radio" name="tdomf_mode" id="tdomf_mode_new" value="new" <?php 
        if (!$edit_form) {
            echo "checked";
        }
        ?>
 onChange="tdomf_enable_new();" ><?php 
        _e('submit new or', 'tdomf');
        ?>
        <input type="radio" name="tdomf_mode" id="tdomf_mode_edit" value="edit" <?php 
        if ($edit_form) {
            echo "checked";
        }
        ?>
 onChange="tdomf_enable_edit();" ><?php 
        _e('edit existing ', 'tdomf');
        ?>
        <input type="radio" name="tdomf_use_type" id="tdomf_use_type_posts" value="post" <?php 
        if (!$use_page) {
            echo "checked";
        }
        ?>
 onChange="tdomf_enable_use_type_posts();" ><?php 
        _e('Posts or', 'tdomf');
        ?>
        <input type="radio" name="tdomf_use_type" id="tdomf_use_type_pages" value="page" <?php 
        if ($use_page) {
            echo "checked";
        }
        ?>
 onChange="tdomf_enable_use_type_posts();" ><?php 
        _e('Pages', 'tdomf');
        ?>
    </p>   

     <p>
    </p>  
    
    <p>
        <?php 
        $on_preview = tdomf_get_option_form(TDOMF_OPTION_PREVIEW, $form_id);
        ?>
        <input type="checkbox" name="tdomf_preview" id="tdomf_preview"  <?php 
        if ($on_preview) {
            echo "checked";
        }
        ?>
 >
        <label for="tdomf_include_sub">
            <?php 
        _e("Enable Preview", "tdomf");
        ?>
        </label>
        <br/>
        
        <?php 
        if (get_option(TDOMF_OPTION_YOUR_SUBMISSIONS)) {
            ?>
            <?php 
            $inc_sub = tdomf_get_option_form(TDOMF_OPTION_INCLUDED_YOUR_SUBMISSIONS, $form_id);
            ?>
            <input type="checkbox" name="tdomf_include_sub" id="tdomf_include_sub" <?php 
            if ($inc_sub) {
                echo "checked";
            }
            ?>
 >
            <label for="tdomf_include_sub">
               <?php 
            _e("Include on 'Your Submissions' page", "tdomf");
            ?>
            </label>
            <br/>
        <?php 
        }
        ?>
        
        <?php 
        $ajax = tdomf_get_option_form(TDOMF_OPTION_AJAX, $form_id);
        ?>
        <input type="checkbox" name="tdomf_ajax" id="tdomf_ajax"  <?php 
        if ($ajax) {
            echo "checked";
        }
        ?>
 >
        <label for="tdomf_ajax">
            <?php 
        _e("Enable AJAX", "tdomf");
        ?>
        </label>
    </p>
        
    <?php 
        $from_email = tdomf_get_option_form(TDOMF_OPTION_FROM_EMAIL, $form_id);
        ?>
    <p>
        <label for="tdomf_from_email">
	        <?php 
        _e("'From Email' Address to use in notifications to users. Leave blank for Wordpress default.", "tdomf");
        ?>
<br/>
        </label>
        <input type="text" name="tdomf_from_email" id="tdomf_from_email" size="80" value="<?php 
        if ($from_email) {
            echo htmlentities($from_email, ENT_QUOTES, get_bloginfo('charset'));
        }
        ?>
" >
	</p>
  
    <?php 
        $widget_count = tdomf_get_option_form(TDOMF_OPTION_WIDGET_INSTANCES, $form_id);
        if ($widget_count == false) {
            $widget_count = 9;
        }
        ?>
	<p>
        <label for="tdomf_widget_count">
            <?php 
        _e("Number of multiple-instances Widgets to have on Form Widgets page:", "tdomf");
        ?>
        </label>
        <input type="text" name="tdomf_widget_count" id="tdomf_widget_count" size="3" value="<?php 
        echo htmlentities(strval($widget_count), ENT_QUOTES, get_bloginfo('charset'));
        ?>
" />
	</p>
    
    </div><!-- /form_gen -->
    
    <div id="form_access">
    
    <p><?php 
        _e("You can control access to the form based on user roles, capabilities or by specific users. You can chose \"Unregistered Users\" if you want anyone to be able to access the form, including visitors to your site that do not have user accounts. The old behaviour of TDO Mini Forms allowed any user with the ability to publish posts automatic access to the form. This behaviour can now be turned off or on as required.", "tdomf");
        ?>
</p>
   
	<?php 
        if (!isset($wp_roles)) {
            $wp_roles = new WP_Roles();
        }
        $roles = $wp_roles->role_objects;
        $access_roles = array();
        $publish_roles = array();
        foreach ($roles as $role) {
            if (!isset($role->capabilities['publish_posts'])) {
                if ($role->name != get_option('default_role')) {
                    array_push($access_roles, $role->name);
                } else {
                    $def_role = $role->name;
                }
            } else {
                array_push($publish_roles, $role->name);
            }
        }
        rsort($access_roles);
        rsort($publish_roles);
        $caps = tdomf_get_all_caps();
        $can_reg = get_option('users_can_register');
        ?>


          
          <script type="text/javascript">
         //<![CDATA[
          function tdomf_unreg_user() {
            var flag = document.getElementById("tdomf_special_access_anyone").checked;
            var flag2 = document.getElementById("tdomf_user_publish_override").checked;
            <?php 
        if (isset($def_role)) {
            ?>
            document.getElementById("tdomf_access_<?php 
            echo $def_role;
            ?>
").disabled = flag;
            document.getElementById("tdomf_access_<?php 
            echo $def_role;
            ?>
").checked = flag;
            <?php 
        }
        ?>
            <?php 
        foreach ($access_roles as $role) {
            ?>
            document.getElementById("tdomf_access_<?php 
            echo $role;
            ?>
").disabled = flag;
            document.getElementById("tdomf_access_<?php 
            echo $role;
            ?>
").checked = flag;
            <?php 
        }
        ?>
            <?php 
        foreach ($caps as $cap) {
            ?>
            document.getElementById("tdomf_access_caps_<?php 
            echo $cap;
            ?>
").disabled = flag;
            document.getElementById("tdomf_access_caps_<?php 
            echo $cap;
            ?>
").checked = flag;
            <?php 
        }
        ?>
            document.getElementById("tdomf_access_users_list").disabled = flag;
            if(flag) {
               document.getElementById("tdomf_access_users_list").value = "";
            }
            if(!flag2) {
            <?php 
        foreach ($publish_roles as $role) {
            ?>
            document.getElementById("tdomf_access_<?php 
            echo $role;
            ?>
").disabled = flag;
            document.getElementById("tdomf_access_<?php 
            echo $role;
            ?>
").checked = flag;
            <?php 
        }
        ?>
            }
           }
           <?php 
        if (isset($def_role) && $can_reg) {
            ?>
           function tdomf_def_role() {
              var flag = document.getElementById("tdomf_access_<?php 
            echo $def_role;
            ?>
").checked;
              var flag2 = document.getElementById("tdomf_user_publish_override").checked;
              <?php 
            foreach ($access_roles as $role) {
                ?>
               document.getElementById("tdomf_access_<?php 
                echo $role;
                ?>
").checked = flag;
              <?php 
            }
            ?>
                 if(!flag2) {
                 <?php 
            foreach ($publish_roles as $role) {
                ?>
                    document.getElementById("tdomf_access_<?php 
                echo $role;
                ?>
").checked = flag;
                 <?php 
            }
            ?>
                 }
              <?php 
            foreach ($caps as $cap) {
                ?>
             document.getElementById("tdomf_access_caps_<?php 
                echo $cap;
                ?>
").disabled = flag;
             document.getElementById("tdomf_access_caps_<?php 
                echo $cap;
                ?>
").checked = flag;
             <?php 
            }
            ?>
              <?php 
            foreach ($access_roles as $role) {
                ?>
              document.getElementById("tdomf_access_<?php 
                echo $role;
                ?>
").disabled = flag;
              <?php 
            }
            ?>
              if(!flag2) {
              <?php 
            foreach ($publish_roles as $role) {
                ?>
                 document.getElementById("tdomf_access_<?php 
                echo $role;
                ?>
").disabled = flag;
              <?php 
            }
            ?>
              }
             document.getElementById("tdomf_access_users_list").disabled = flag;
            if(flag) {
               document.getElementById("tdomf_access_users_list").value = "";
            }
           }
           <?php 
        }
        ?>
           
           function tdomf_publish_user() {
            var flag = document.getElementById("tdomf_user_publish_override").checked;
            <?php 
        if (isset($def_role) && $can_reg) {
            ?>
            var flag2 = document.getElementById("tdomf_access_<?php 
            echo $def_role;
            ?>
").checked;
            if(!flag2) {
            <?php 
        }
        ?>
                <?php 
        foreach ($publish_roles as $role) {
            ?>
                document.getElementById("tdomf_access_<?php 
            echo $role;
            ?>
").checked = flag;
                document.getElementById("tdomf_access_<?php 
            echo $role;
            ?>
").disabled = flag;
                <?php 
        }
        ?>

            <?php 
        if (isset($def_role) && $can_reg) {
            ?>
            }
            <?php 
        }
        ?>
           }
           //-->
           </script>

           <p>
           
          <label for="tdomf_special_access_anyone">
   <input value="tdomf_special_access_anyone" type="checkbox" name="tdomf_special_access_anyone" id="tdomf_special_access_anyone" <?php 
        if (tdomf_get_option_form(TDOMF_OPTION_ALLOW_EVERYONE, $form_id) != false) {
            ?>
checked<?php 
        }
        ?>
 onClick="tdomf_unreg_user();" />
   <?php 
        _e("Unregistered Users (i.e. everyone)", "tdomf");
        ?>
           </label>
           
           <br/>

           <?php 
        $author_edit = tdomf_get_option_form(TDOMF_OPTION_ALLOW_AUTHOR, $form_id);
        ?>
           
           <input type="checkbox" name="tdomf_author_edit" id="tdomf_author_edit" <?php 
        if (!$edit_form) {
            echo 'disabled';
        }
        ?>
 <?php 
        if ($author_edit) {
            echo 'checked';
        }
        ?>
 />
          <label for="tdomf_author_edit">
          <?php 
        _e("Original Submitter (registered users only)", "tdomf");
        ?>
          </label>   
           
          <br/>
          
          <?php 
        $can_publish = tdomf_get_option_form(TDOMF_OPTION_ALLOW_PUBLISH, $form_id);
        ?>
          
          <input type="checkbox" 
                 name="tdomf_user_publish_override" id="tdomf_user_publish_override"
                 <?php 
        if ($can_publish) {
            ?>
 checked <?php 
        }
        ?>
                 onClick="tdomf_publish_user();" />
          <label for="tdomf_user_publish_override">
          <?php 
        _e("Users with rights to publish posts.", "tdomf");
        ?>
          </label>   

           </p>
          
           <div id="options_access_tabs" class="tabs">
              <ul>
                <li><a href="#access_roles"><span><?php 
        _e('Roles', 'tdomf');
        ?>
</span></a></li>
                <li><a href="#access_caps"><span><?php 
        _e('Capabilities', 'tdomf');
        ?>
</span></a></li>
                <li><a href="#access_users"><span><?php 
        _e('Specific Users', 'tdomf');
        ?>
</span></a></li>
              </ul>
           
           <div id="access_roles">
           <p><?php 
        _e('Select roles that can access the form. If you allow free user registration and pick the default role, this means that a user must just be logged in to access the form.', 'tdomf');
        ?>
</p>
           
           <p>
          <?php 
        if (isset($def_role)) {
            ?>
             <label for="tdomf_access_<?php 
            echo $def_role;
            ?>
">
             <input value="tdomf_access_<?php 
            echo $def_role;
            ?>
" type="checkbox"
                    name="tdomf_access_<?php 
            echo $def_role;
            ?>
" id="tdomf_access_<?php 
            echo $def_role;
            ?>
"  
                    <?php 
            if (isset($wp_roles->role_objects[$def_role]->capabilities[TDOMF_CAPABILITY_CAN_SEE_FORM . '_' . $form_id])) {
                ?>
 checked <?php 
            }
            ?>
 
                    onClick="tdomf_def_role()" 
                    <?php 
            if (tdomf_get_option_form(TDOMF_OPTION_ALLOW_EVERYONE, $form_id) != false) {
                ?>
 checked disabled <?php 
            }
            ?>
 />
             <?php 
            if (function_exists('translate_with_context')) {
                $role_name = translate_with_context($wp_roles->role_names[$def_role]);
            } else {
                $role_name = $wp_roles->role_names[$def_role];
            }
            ?>
             <?php 
            echo $role_name . " " . __("(newly registered users)");
            ?>
             </label><br/>
          <?php 
        }
        ?>

          <?php 
        foreach ($access_roles as $role) {
            ?>
             <label for="tdomf_access_<?php 
            echo $role;
            ?>
">
             <input value="tdomf_access_<?php 
            echo $role;
            ?>
" type="checkbox" 
                    name="tdomf_access_<?php 
            echo $role;
            ?>
" id="tdomf_access_<?php 
            echo $role;
            ?>
" 
                    <?php 
            if (isset($wp_roles->role_objects[$role]->capabilities[TDOMF_CAPABILITY_CAN_SEE_FORM . '_' . $form_id])) {
                ?>
 checked <?php 
            }
            ?>
                    <?php 
            if (isset($def_role) && isset($wp_roles->role_objects[$def_role]->capabilities[TDOMF_CAPABILITY_CAN_SEE_FORM . '_' . $form_id]) && $can_reg) {
                ?>
 checked disabled <?php 
            }
            ?>
                    <?php 
            if (tdomf_get_option_form(TDOMF_OPTION_ALLOW_EVERYONE, $form_id) != false) {
                ?>
 checked disabled <?php 
            }
            ?>
 />
             <?php 
            if (function_exists('translate_with_context')) {
                echo translate_with_context($wp_roles->role_names[$role]);
            } else {
                echo $wp_roles->role_names[$role];
            }
            ?>
             </label><br/>
          <?php 
        }
        ?>
          
          <?php 
        foreach ($publish_roles as $role) {
            ?>
             <label for="tdomf_access_<?php 
            echo $role;
            ?>
">
             <input value="tdomf_access_<?php 
            echo $role;
            ?>
" type="checkbox" 
                    name="tdomf_access_<?php 
            echo $role;
            ?>
" id="tdomf_access_<?php 
            echo $role;
            ?>
"
                    <?php 
            if ($can_publish) {
                ?>
 checked disabled <?php 
            }
            ?>
                    <?php 
            if (isset($wp_roles->role_objects[$role]->capabilities[TDOMF_CAPABILITY_CAN_SEE_FORM . '_' . $form_id])) {
                ?>
 checked <?php 
            }
            ?>
                    <?php 
            if (isset($def_role) && isset($wp_roles->role_objects[$def_role]->capabilities[TDOMF_CAPABILITY_CAN_SEE_FORM . '_' . $form_id]) && $can_reg) {
                ?>
 checked disabled <?php 
            }
            ?>
                    <?php 
            if (tdomf_get_option_form(TDOMF_OPTION_ALLOW_EVERYONE, $form_id) != false) {
                ?>
 checked disabled <?php 
            }
            ?>
 />
             <?php 
            if (function_exists('translate_with_context')) {
                printf(__('%s (can publish posts)', 'tdomf'), translate_with_context($wp_roles->role_names[$role]));
            } else {
                printf(__('%s (can publish posts)', 'tdomf'), $wp_roles->role_names[$role]);
            }
            ?>
             </label><br/>
          <?php 
        }
        ?>
          </p>
          </div> <!-- access_roles -->
           
          <div id="access_caps">
          <p><?php 
        _e('Capabilities are specific access rights. Roles are groupings of capabilities. Individual users can be given individual capabilities outside their assigned Role using external plugins. You can optionally select additional capabilities that give access to the form.', 'tdomf');
        ?>
</p>
          
          <?php 
        $access_caps = tdomf_get_option_form(TDOMF_OPTION_ALLOW_CAPS, $form_id);
        if ($access_caps == false) {
            $access_caps = array();
        }
        ?>
          
          <div id="access_caps_list"><p>
          <?php 
        foreach ($caps as $cap) {
            ?>
             <input value="tdomf_access_caps_<?php 
            echo $cap;
            ?>
" type="checkbox" 
                    name="tdomf_access_caps_<?php 
            echo $cap;
            ?>
" id="tdomf_access_caps_<?php 
            echo $cap;
            ?>
"
                    <?php 
            if (isset($def_role) && isset($wp_roles->role_objects[$def_role]->capabilities[TDOMF_CAPABILITY_CAN_SEE_FORM . '_' . $form_id]) && $can_reg) {
                ?>
 checked disabled <?php 
            }
            ?>
                    <?php 
            if (in_array($cap, $access_caps)) {
                ?>
 checked <?php 
            }
            ?>
                    <?php 
            if (tdomf_get_option_form(TDOMF_OPTION_ALLOW_EVERYONE, $form_id) != false) {
                ?>
 checked disabled <?php 
            }
            ?>
 />
             <label for="tdomf_access_caps_<?php 
            echo $cap;
            ?>
">
             <?php 
            if (function_exists('translate_with_context')) {
                echo translate_with_context($cap);
            } else {
                echo $cap;
            }
            ?>
             </label><br/>
          <?php 
        }
        ?>
          </p></div> <!-- access_caps_list -->
          
          </div> <!-- access_caps -->
          
          <div id="access_users">
          
          <?php 
        $allow_users = tdomf_get_option_form(TDOMF_OPTION_ALLOW_USERS, $form_id);
        $tdomf_access_users_list = "";
        if (is_array($allow_users)) {
            $tdomf_access_users_list = array();
            foreach ($allow_users as $allow_user) {
                $allow_user = get_userdata($allow_user);
                $tdomf_access_users_list[] = $allow_user->user_login;
            }
            sort($tdomf_access_users_list);
            $tdomf_access_users_list = join(' ', $tdomf_access_users_list);
        }
        ?>
          
          <p><?php 
        _e('You can specify additional specific users who can access the form. Just list their login names seperated by spaces in the box provide', 'tdomf');
        ?>
</p>
          
          <textarea cols="80" rows="3" 
                    name="tdomf_access_users_list" id="tdomf_access_users_list"
                    <?php 
        if (isset($def_role) && isset($wp_roles->role_objects[$def_role]->capabilities[TDOMF_CAPABILITY_CAN_SEE_FORM . '_' . $form_id]) && $can_reg) {
            ?>
 checked disabled /></textarea>
                    <?php 
        } else {
            if (tdomf_get_option_form(TDOMF_OPTION_ALLOW_EVERYONE, $form_id) != false) {
                ?>
 checked disabled /></textarea> 
                    <?php 
            } else {
                ?>
 /><?php 
                echo $tdomf_access_users_list;
                ?>
</textarea><?php 
            }
        }
        ?>
          
          </div> <!-- access_users -->
          
       </div> <!-- options_access_tabs -->
           
       <p>
       
          <?php 
        $allow_time = tdomf_get_option_form(TDOMF_OPTION_ALLOW_TIME, $form_id);
        if ($allow_time === false || $allow_time < 0) {
            $allow_time = "";
        }
        ?>
       
          <label for="tdomf_time_edit">
          <?php 
        _e('Allow post or page to be edited for ');
        ?>
          <input type="text" name="tdomf_time_edit" id="tdomf_time_edit" size="5" value="<?php 
        echo $allow_time;
        ?>
" <?php 
        if (!$edit_form) {
            ?>
disabled <?php 
        }
        ?>
 />
          <?php 
        _e(' Seconds (1 hour = 3600 seconds) after post is published.');
        ?>
          </label>

       </p>
    
    </div> <!-- form_access -->

    <div id="form_new">
    
    <?php 
        $def_cat = tdomf_get_option_form(TDOMF_DEFAULT_CATEGORY, $form_id);
        ?>
    <p>
       <label for="tdomf_def_cat">
	       <?php 
        _e("Default Category of new submissions", "tdomf");
        ?>
       </label>
	   <SELECT NAME="tdomf_def_cat" id="tdomf_def_cat" <?php 
        if ($use_page) {
            ?>
disabled<?php 
        }
        ?>
 >
	   <?php 
        $cats = get_categories("get=all");
        if (!empty($cats)) {
            foreach ($cats as $c) {
                if ($c->term_id == $def_cat) {
                    echo "<OPTION VALUE=\"{$c->term_id}\" selected>{$c->category_nicename}\n";
                } else {
                    echo "<OPTION VALUE=\"{$c->term_id}\">{$c->category_nicename}\n";
                }
            }
        }
        ?>
        </select>
    </p>
    
	<p>
	<?php 
        _e('You can set submissions from this form that are published/approved to be queued before appearing on the site. Just set the period of time between each post and TDOMF will schedule approved submissions from this form. A value of 0 or -1 disables this option. You can also choose to schedule posts after any post in the system or just TDOMF posts.', "tdomf");
        ?>
	</p>
    
    <?php 
        $tdomf_queue_on_all = tdomf_get_option_form(TDOMF_OPTION_QUEUE_ON_ALL, $form_id);
        ?>
        <input type="checkbox" name="tdomf_queue_on_all" id="tdomf_queue_on_all"  <?php 
        if ($tdomf_queue_on_all) {
            echo "checked";
        }
        ?>
 >
        <label for="tdomf_queue_on_all">
            <?php 
        _e("Queue after all posts (i.e. not just posts submitted to TDOMF)", "tdomf");
        ?>
        </label>
    
    <?php 
        $tdomf_queue_period = intval(tdomf_get_option_form(TDOMF_OPTION_QUEUE_PERIOD, $form_id));
        ?>
	<p>
	<input type="text" name="tdomf_queue_period" id="tdomf_queue_period" size="5" value="<?php 
        echo htmlentities($tdomf_queue_period, ENT_QUOTES, get_bloginfo('charset'));
        ?>
" />
    <?php 
        _e("Seconds (1 day = 86400 seconds)", "tdomf");
        ?>
	</p>
    
    </div> <!-- form_new -->
    
    <div id="form_edit">
    
       <p>
        <?php 
        $edit_restrict_tdomf = tdomf_get_option_form(TDOMF_OPTION_EDIT_RESTRICT_TDOMF, $form_id);
        ?>
        <input type="checkbox" name="tdomf_edit_tdomf_only" id="tdomf_edit_tdomf_only" <?php 
        if ($edit_restrict_tdomf) {
            ?>
checked<?php 
        }
        ?>
 >
        <label for="tdomf_edit_tdomf_only"><?php 
        _e("Restrict editing to posts or pages that were submitted by TDO Mini Forms", "tdomf");
        ?>
</label>
        
        <br/>

        <?php 
        $edit_restrict_cats = tdomf_get_option_form(TDOMF_OPTION_EDIT_RESTRICT_CATS, $form_id);
        if (!is_array($edit_restrict_cats)) {
            $edit_restrict_cats = "";
        } else {
            $edit_restrict_cats = join(",", $edit_restrict_cats);
        }
        ?>
        
                
        <?php 
        $edit_page_form = tdomf_get_option_form(TDOMF_OPTION_EDIT_PAGE_FORM, $form_id);
        ?>
        <input type="checkbox" name="tdomf_edit_page_form" id="tdomf_edit_page_form" <?php 
        if ($edit_page_form) {
            ?>
checked<?php 
        }
        ?>
 >
        <label for="tdomf_edit_tdomf_only"><?php 
        _e("Allow editing of pages (or posts) that contain TDO-Mini-Form forms", "tdomf");
        ?>
</label>
        
        <br/><br/>
        
               
        <label for="tdomf_edit_cats">
        <?php 
        _e("Restrict editing to posts in these categories only:", "tdomf");
        ?>
<br/>
        <small><?php 
        _e("(List category ids seperated by a comma)", "tdomf");
        ?>
<br/></small>
        </label>
        <input type="text" name="tdomf_edit_cats" id="tdomf_edit_cats" size="80" value="<?php 
        echo $edit_restrict_cats;
        ?>
" <?php 
        if ($use_page) {
            ?>
disabled<?php 
        }
        ?>
 />

        <br/><br/>
        
        <?php 
        $ajax_edit = tdomf_get_option_form(TDOMF_OPTION_AJAX_EDIT, $form_id);
        ?>
        <input type="checkbox" name="tdomf_ajax_edit" id="tdomf_ajax_edit" <?php 
        if ($ajax_edit) {
            ?>
checked<?php 
        }
        ?>
 >
        <label for="tdomf_ajax_edit"><?php 
        _e("Inline Editing (requires javascript in browser, will fall back to one of the options below)", "tdomf");
        ?>
</label>
        <br/>
        
        <?php 
        $add_edit_link = tdomf_get_option_form(TDOMF_OPTION_ADD_EDIT_LINK, $form_id);
        if (get_option(TDOMF_OPTION_YOUR_SUBMISSIONS) == false && $add_edit_link == 'your_submissions') {
            $add_edit_link = 'none';
        }
        if ($updated_pages == false && $auto_edit_link == 'page') {
            $add_edit_link = 'none';
        }
        ?>
        
        <input type="radio" name="tdomf_add_edit_link" id="tdomf_add_edit_link_none" value="none" <?php 
        if (!$add_edit_link || $add_edit_link == 'none') {
            ?>
checked<?php 
        }
        ?>
 >
        <label for="tdomf_add_edit_link_none">
            <?php 
        _e('Do not add a link to edit form at end of post', 'tdomf');
        ?>
        </label>
        <br/>
        <?php 
        if (get_option(TDOMF_OPTION_YOUR_SUBMISSIONS)) {
            ?>
            <input type="radio" name="tdomf_add_edit_link" id="tdomf_add_edit_link_your_submissions" value="your_submissions" <?php 
            if ($add_edit_link == 'your_submissions') {
                ?>
checked<?php 
            }
            ?>
>
            <label for="tdomf_add_edit_link_your_submissions">
                <?php 
            _e('Add a link to Form on Your Submissions at end of post', 'tdomf');
            ?>
            </label>
            <br/>
        <?php 
        }
        ?>
        <?php 
        if ($updated_pages != false) {
            ?>
            <input type="radio" name="tdomf_add_edit_link" id="tdomf_add_edit_link_page" value="page" <?php 
            if ($add_edit_link == 'page') {
                ?>
checked<?php 
            }
            ?>
>
            <label for="tdomf_add_edit_link_page">
                <?php 
            _e('Add a link to Page created for Form at end of post', 'tdomf');
            ?>
            </label>
            <br/>
        <?php 
        }
        ?>
        <input type="radio" name="tdomf_add_edit_link" id="tdomf_add_edit_link_custom" value="custom" 
            <?php 
        if ($add_edit_link !== false && $add_edit_link != 'none' && $add_edit_link != 'page' && $add_edit_link != 'your_submissions') {
            ?>
checked<?php 
        }
        ?>
>
        <label for="tdomf_add_edit_link_custom">
            <?php 
        _e('Add a link to a Custom URL at the end of post', 'tdomf');
        ?>
        </label>
        <br/>
        <input type="text" name="tdomf_add_edit_link_custom_url" id="tdomf_add_edit_link_custom_url" size="80" 
            <?php 
        if ($add_edit_link !== false && $add_edit_link != 'none' && $add_edit_link != 'page' && $add_edit_link != 'your_submissions') {
            ?>
value="<?php 
            echo $add_edit_link;
            ?>
" <?php 
        } else {
            ?>
value="http://" <?php 
        }
        ?>
/>

            <br/><br/>
        
        <p>
        <?php 
        _e('If your theme supports it, the edit link can be automatically updated to point to a TDOMF form instead of Wordpress\' backend. But TDOMF cannot change the permissions under which it shows. I.e. This edit link will appear according to Wordpress access rules and not the rules you set here.', 'tdomf');
        ?>
        </p>
        
        <?php 
        $auto_edit_link = tdomf_get_option_form(TDOMF_OPTION_AUTO_EDIT_LINK, $form_id);
        if (get_option(TDOMF_OPTION_YOUR_SUBMISSIONS) == false && $auto_edit_link == 'your_submissions') {
            $auto_edit_link = 'none';
        }
        if ($updated_pages == false && $auto_edit_link == 'page') {
            $auto_edit_link = 'none';
        }
        ?>
        
        <input type="radio" name="tdomf_auto_edit_link" id="tdomf_auto_edit_link_none" value="none" <?php 
        if (!$auto_edit_link || $auto_edit_link == 'none') {
            ?>
checked<?php 
        }
        ?>
>
        <label for="tdomf_auto_edit_link_none">
            <?php 
        _e('Do not auto-modify \'Edit Post\' link', 'tdomf');
        ?>
        </label>
        <br/>
        <?php 
        if (get_option(TDOMF_OPTION_YOUR_SUBMISSIONS)) {
            ?>
            <input type="radio" name="tdomf_auto_edit_link" id="tdomf_auto_edit_link_your_submissions" value="your_submissions" <?php 
            if ($auto_edit_link == 'your_submissions') {
                ?>
checked<?php 
            }
            ?>
>
            <label for="tdomf_auto_edit_link_your_submissions">
                <?php 
            _e('Auto-modify \'Edit Post\' link (if avaliable in theme) to point to Form on Your Submissions', 'tdomf');
            ?>
            </label>
            <br/>
        <?php 
        }
        ?>
        <?php 
        if ($updated_pages != false) {
            ?>
            <input type="radio" name="tdomf_auto_edit_link" id="tdomf_auto_edit_link_page" value="page" <?php 
            if ($auto_edit_link == 'page') {
                ?>
checked<?php 
            }
            ?>
>
            <label for="tdomf_auto_edit_link_page">
                <?php 
            _e('Auto-modify \'Edit Post\' link (if avaliable in theme) to point to Page created for Form', 'tdomf');
            ?>
            </label>
            <br/>
        <?php 
        }
        ?>
        <input type="radio" name="tdomf_auto_edit_link" id="tdomf_auto_edit_link_custom" value="custom" 
            <?php 
        if ($auto_edit_link !== false && $auto_edit_link != 'none' && $auto_edit_link != 'page' && $auto_edit_link != 'your_submissions') {
            ?>
checked<?php 
        }
        ?>
>
        <label for="tdomf_auto_edit_link_custom">
            <?php 
        _e('Auto-modify \'Edit Post\' link (if avaliable in theme) to point to a custom URL', 'tdomf');
        ?>
        </label>
        <br/>
        <input type="text" name="tdomf_auto_edit_link_custom_url" id="tdomf_auto_edit_link_custom_url" size="80"
            <?php 
        if ($auto_edit_link !== false && $auto_edit_link != 'none' && $auto_edit_link != 'page' && $auto_edit_link != 'your_submissions') {
            ?>
value="<?php 
            echo $auto_edit_link;
            ?>
" <?php 
        } else {
            ?>
value="http://" <?php 
        }
        ?>
/>

        <br/>
        
       </p>
    
    </div> <!-- form_edit -->
    
    <div id="form_moderation">

    <?php 
        $on_mod = tdomf_get_option_form(TDOMF_OPTION_MODERATION, $form_id);
        ?>
	
    <p>
        <input type="checkbox" name="tdomf_moderation" id="tdomf_moderation"  	<?php 
        if ($on_mod) {
            echo "checked";
        }
        ?>
 >
        <label for="tdomf_moderation">
            <?php 
        _e("Enable Moderation", "tdomf");
        ?>
        </label>
    </p>
    
    <p>
    
    <?php 
        $user_publish_auto = tdomf_get_option_form(TDOMF_OPTION_PUBLISH_NO_MOD, $form_id);
        ?>
    <input type="checkbox" name="tdomf_user_publish_auto" id="tdomf_user_publish_auto" <?php 
        if ($user_publish_auto) {
            ?>
 checked <?php 
        }
        ?>
 />
    <label for="tdomf_user_publish_auto">
        <?php 
        _e("Users with publish rights will have their posts automatically published", "tdomf");
        ?>
<br/>
    </label>
    
    <?php 
        $redirect = tdomf_get_option_form(TDOMF_OPTION_REDIRECT, $form_id);
        ?>
    <input type="checkbox" name="tdomf_redirect" id="tdomf_redirect" <?php 
        if ($redirect) {
            echo "checked";
        }
        ?>
 >
    <label for="tdomf_redirect">
        <?php 
        _e("If automatically published, redirect to Published Post", "tdomf");
        ?>
<br/>
    </label>
    
    <?php 
        $mod_email_on_pub = tdomf_get_option_form(TDOMF_OPTION_MOD_EMAIL_ON_PUB, $form_id);
        ?>
    <input type="checkbox" name="tdomf_mod_email_on_pub" id="tdomf_mod_email_on_pub" <?php 
        if ($mod_email_on_pub) {
            echo "checked";
        }
        ?>
 >
    <label for="tdomf_mod_email_on_pub">
        <?php 
        _e("Send Moderation Email even for automatically Published Post", "tdomf");
        ?>
<br/>
    </label>
    
	</p>

    <p>
    <b><?php 
        _e('Send Moderation Email Notification to:', 'tdomf');
        ?>
</b><br/><br/>

	 <?php 
        $notify_roles = tdomf_get_option_form(TDOMF_NOTIFY_ROLES, $form_id);
        if ($notify_roles != false) {
            $notify_roles = explode(';', $notify_roles);
        }
        $admin_emails = tdomf_get_option_form(TDOMF_OPTION_ADMIN_EMAILS, $form_id);
        ?>

	 <?php 
        foreach ($roles as $role) {
            if (isset($role->capabilities['edit_others_posts']) && isset($role->capabilities['publish_posts'])) {
                ?>
		     <input value="tdomf_notify_<?php 
                echo $role->name;
                ?>
" type="checkbox" name="tdomf_notify_<?php 
                echo $role->name;
                ?>
" id="tdomf_notify_<?php 
                echo $role->name;
                ?>
" <?php 
                if ($notify_roles != false && in_array($role->name, $notify_roles)) {
                    ?>
checked<?php 
                }
                ?>
 />
             <label for="tdomf_notify_<?php 
                echo $role->name;
                ?>
">
          <?php 
                if (function_exists('translate_with_context')) {
                    echo translate_with_context($wp_roles->role_names[$role->name]);
                } else {
                    echo $wp_roles->role_names[$role->name];
                }
                ?>
          <br/>
		     </label>
		     <?php 
            }
        }
        ?>
         <br/>

    <?php 
        _e("Specific Email Addresses (seperate with spaces)", "tdomf");
        ?>
</b>
	<input type="text" name="tdomf_admin_emails" id="tdomf_admin_emails" size="80" value="<?php 
        if ($admin_emails) {
            echo htmlentities(stripslashes($admin_emails), ENT_QUOTES, get_bloginfo('charset'));
        }
        ?>
" />
         
	 </p>

    
    </div> <!-- form_moderation -->
    
    <div id="form_throttling">

	<p>
	<?php 
        _e('You can add rules to throttle input based on registered user accounts and/or IP addresses. Make sure you save any form configuration changes to your form before adding or removing any throttling rules.', "tdomf");
        ?>
	</p>
   
    <?php 
        printf(__("<table border=\"0\">\n                     <tr><td>Only %s submissions/contributions per</td>\n                     <td>%s</td>\n                     <td>%s(optionally) per %s Seconds (1 hour = 3600 seconds)</td>\n                     <td>%s</td>\n                     </tr>\n                     </table>", "tdomf"), '<input type="text" name="tdomf_throttle_rule_count" id="tdomf_throttle_rule_count" size="3" value="10" /> 
                      <select id="tdomf_throttle_rule_sub_type" name="tdomf_throttle_rule_sub_type" >
                      <option value="unapproved" selected />' . __("unapproved", "tdomf") . '
                      <option value="any" />' . __("any", "tdomf") . '
                      </select>', '<input type="radio" name="tdomf_throttle_rule_user_type" id="tdomf_throttle_rule_user_type" value="user" />' . __("registered user", "tdomf") . '<br/>
                      <input type="radio" name="tdomf_throttle_rule_user_type" id="tdomf_throttle_rule_user_type" value="ip" checked />' . __("IP", "tdomf"), '<input type="checkbox" name="tdomf_throttle_rule_opt1" id="tdomf_throttle_rule_opt1" checked >', '<input type="text" name="tdomf_throttle_rule_time" id="tdomf_throttle_rule_time" size="3" value="3600" />', '<input type="submit" name="tdomf_add_throttle_rule" id="tdomf_add_throttle_rule" value="' . __("Add", "tdomf") . ' &raquo;">');
        ?>

    <?php 
        $throttle_rules = tdomf_get_option_form(TDOMF_OPTION_THROTTLE_RULES, $form_id);
        if (is_array($throttle_rules) && !empty($throttle_rules)) {
            ?>
    
    <p><b><?php 
            _e("Current Throttle Rules", "tdomf");
            ?>
</b>
    <ul>
    <?php 
            foreach ($throttle_rules as $id => $throttle_rule) {
                $option_string = "";
                if ($throttle_rule['opt1']) {
                    $option_string = sprintf(__("per %s Seconds", "tdomf"), $throttle_rule['time']);
                }
                ?>
        <li>
        <?php 
                printf(__("(%d) Only %d %s submissions/contributions per %s %s", "tdomf"), $id, $throttle_rule['count'], $throttle_rule['sub_type'], $throttle_rule['type'], $option_string);
                ?>
        <input type="submit" name="tdomf_remove_throttle_rule_<?php 
                echo $id;
                ?>
" id="tdomf_remove_throttle_rule_<?php 
                echo $id;
                ?>
" value="<?php 
                _e("Remove", "tdomf");
                ?>
 &raquo;">
        </li>
    <?php 
            }
            ?>
    </ul>
    </p>
    
          <?php 
        } else {
            ?>
              <p><b><?php 
            _e("No Throttling Rules currently set.", "tdomf");
            ?>
</b></p>
          <?php 
        }
        ?>
        
    </div> <!-- form_throttling -->
    
    <div id="form_spam">
    
    <?php 
        tdomf_show_spam_options($form_id);
        ?>
    
    </div> <!-- form_spam -->
    
    <br/>
    
  <table border="0"><tr>

    <td>
    <input type="hidden" name="save_settings" value="0" />
    <input type="submit" name="tdomf_save_button" id="tdomf_save_button" value="<?php 
        _e("Save", "tdomf");
        ?>
 &raquo;" />
	</form>
    </td>

    <td>
    <form method="post" action="admin.php?page=tdomf_show_form_options_menu&form=<?php 
        echo $form_id;
        ?>
">
    <input type="submit" name="refresh" value="Refresh" />
    </form>
    </td>

    </tr></table>

    </div> <!-- wrap -->
    
  <?php 
    }
}
Exemple #16
0
/**
 * Print out <option> html elements for role selectors based on $wp_roles
 *
 * @package WordPress
 * @subpackage Administration
 * @since 2.1
 *
 * @uses $wp_roles
 * @param string $default slug for the role that should be already selected
 */
function wp_dropdown_roles($selected = false)
{
    global $wp_roles;
    $p = '';
    $r = '';
    $editable_roles = get_editable_roles();
    foreach ($editable_roles as $role => $details) {
        $name = translate_with_context($details['name']);
        if ($selected == $role) {
            // Make default first in list
            $p = "\n\t<option selected='selected' value='{$role}'>{$name}</option>";
        } else {
            $r .= "\n\t<option value='{$role}'>{$name}</option>";
        }
    }
    echo $p . $r;
}