示例#1
0
function print_user_option_list($p_user_id, $p_project_id = null, $p_access = ANYBODY)
{
    $t_current_user = auth_get_current_user_id();
    if (null === $p_project_id) {
        $p_project_id = helper_get_current_project();
    }
    if ($p_project_id === ALL_PROJECTS) {
        $t_projects = user_get_accessible_projects($t_current_user);
        # Get list of users having access level for all accessible projects
        $t_users = array();
        foreach ($t_projects as $t_project_id) {
            $t_project_users_list = project_get_all_user_rows($t_project_id, $p_access);
            # Do a 'smart' merge of the project's user list, into an
            # associative array (to remove duplicates)
            # Use a while loop for better performance
            $i = 0;
            while (isset($t_project_users_list[$i])) {
                $t_users[$t_project_users_list[$i]['id']] = $t_project_users_list[$i];
                $i++;
            }
            unset($t_project_users_list);
        }
        unset($t_projects);
    } else {
        $t_users = project_get_all_user_rows($p_project_id, $p_access);
    }
    $t_display = array();
    $t_sort = array();
    $t_show_realname = ON == config_get('show_realname');
    $t_sort_by_last_name = ON == config_get('sort_by_last_name');
    foreach ($t_users as $t_key => $t_user) {
        $t_user_name = string_attribute($t_user['username']);
        $t_sort_name = utf8_strtolower($t_user_name);
        if ($t_show_realname && $t_user['realname'] != '') {
            $t_user_name = string_attribute($t_user['realname']);
            if ($t_sort_by_last_name) {
                $t_sort_name_bits = explode(' ', utf8_strtolower($t_user_name), 2);
                $t_sort_name = (isset($t_sort_name_bits[1]) ? $t_sort_name_bits[1] . ', ' : '') . $t_sort_name_bits[0];
            } else {
                $t_sort_name = utf8_strtolower($t_user_name);
            }
        }
        $t_display[] = $t_user_name;
        $t_sort[] = $t_sort_name;
    }
    array_multisort($t_sort, SORT_ASC, SORT_STRING, $t_users, $t_display);
    unset($t_sort);
    $t_count = count($t_users);
    for ($i = 0; $i < $t_count; $i++) {
        $t_row = $t_users[$i];
        echo '<option value="' . $t_row['id'] . '" ';
        check_selected($p_user_id, $t_row['id']);
        echo '>' . $t_display[$i] . '</option>';
    }
}
示例#2
0
function print_user_option_list($p_user_id, $p_project_id = null, $p_access = ANYBODY)
{
    $t_users = array();
    if (null === $p_project_id) {
        $p_project_id = helper_get_current_project();
    }
    $t_users = project_get_all_user_rows($p_project_id, $p_access);
    # handles ALL_PROJECTS case
    $t_display = array();
    $t_sort = array();
    $t_show_realname = ON == config_get('show_realname');
    $t_sort_by_last_name = ON == config_get('sort_by_last_name');
    foreach ($t_users as $t_user) {
        $t_user_name = string_attribute($t_user['username']);
        $t_sort_name = utf8_strtolower($t_user_name);
        if ($t_show_realname && $t_user['realname'] != '') {
            $t_user_name = string_attribute($t_user['realname']);
            if ($t_sort_by_last_name) {
                $t_sort_name_bits = explode(' ', utf8_strtolower($t_user_name), 2);
                $t_sort_name = (isset($t_sort_name_bits[1]) ? $t_sort_name_bits[1] . ', ' : '') . $t_sort_name_bits[0];
            } else {
                $t_sort_name = utf8_strtolower($t_user_name);
            }
        }
        $t_display[] = $t_user_name;
        $t_sort[] = $t_sort_name;
    }
    array_multisort($t_sort, SORT_ASC, SORT_STRING, $t_users, $t_display);
    $t_count = count($t_sort);
    for ($i = 0; $i < $t_count; $i++) {
        $t_row = $t_users[$i];
        echo '<option value="' . $t_row['id'] . '" ';
        check_selected($p_user_id, (int) $t_row['id']);
        echo '>' . $t_display[$i] . '</option>';
    }
}
示例#3
0
echo lang_get('email');
?>
			</td>
			<td>
				<?php 
echo lang_get('access_level');
?>
			</td>
			<td class="center">
				<?php 
echo lang_get('actions');
?>
			</td>
		</tr>
<?php 
$t_users = project_get_all_user_rows($f_project_id, ANYBODY, $f_show_global_users);
$t_display = array();
$t_sort = array();
foreach ($t_users as $t_user) {
    $t_user_name = string_attribute($t_user['username']);
    $t_sort_name = utf8_strtolower($t_user_name);
    if (isset($t_user['realname']) && $t_user['realname'] > "" && ON == config_get('show_realname')) {
        $t_user_name = string_attribute($t_user['realname']) . " (" . $t_user_name . ")";
        if (ON == config_get('sort_by_last_name')) {
            $t_sort_name_bits = explode(' ', utf8_strtolower($t_user_name), 2);
            $t_sort_name = $t_sort_name_bits[1] . ', ' . $t_sort_name_bits[1];
        } else {
            $t_sort_name = utf8_strtolower($t_user_name);
        }
    }
    $t_display[] = $t_user_name;
示例#4
0
/**
 * This populates an option list with the appropriate users by access level
 * @todo from print_reporter_option_list
 * @param integer|array $p_user_id    A user identifier or a list of them.
 * @param integer       $p_project_id A project identifier.
 * @param integer       $p_access     An access level.
 * @return void
 */
function print_user_option_list($p_user_id, $p_project_id = null, $p_access = ANYBODY)
{
    $t_current_user = auth_get_current_user_id();
    if (null === $p_project_id) {
        $p_project_id = helper_get_current_project();
    }
    if ($p_project_id === ALL_PROJECTS) {
        $t_projects = user_get_accessible_projects($t_current_user);
        # Get list of users having access level for all accessible projects
        $t_users = array();
        foreach ($t_projects as $t_project_id) {
            $t_project_users_list = project_get_all_user_rows($t_project_id, $p_access);
            # Do a 'smart' merge of the project's user list, into an
            # associative array (to remove duplicates)
            foreach ($t_project_users_list as $t_id => $t_user) {
                $t_users[$t_id] = $t_user;
            }
            # Clear the array to release memory
            unset($t_project_users_list);
        }
        unset($t_projects);
    } else {
        $t_users = project_get_all_user_rows($p_project_id, $p_access);
    }
    # Add the specified user ID to the list
    # If we have an array of user IDs, then we've been called from a filter
    # so don't add anything
    if (!is_array($p_user_id) && $p_user_id != NO_USER && !array_key_exists($p_user_id, $t_users)) {
        $t_row = user_get_row($p_user_id);
        if ($t_row === false) {
            # User doesn't exist - create a dummy record for display purposes
            $t_name = user_get_name($p_user_id);
            $t_row = array('id' => $p_user_id, 'username' => $t_name, 'realname' => $t_name);
        }
        $t_users[$p_user_id] = $t_row;
    }
    $t_display = array();
    $t_sort = array();
    $t_show_realname = ON == config_get('show_realname');
    $t_sort_by_last_name = ON == config_get('sort_by_last_name');
    foreach ($t_users as $t_key => $t_user) {
        $t_user_name = string_attribute($t_user['username']);
        $t_sort_name = utf8_strtolower($t_user_name);
        if ($t_show_realname && $t_user['realname'] != '') {
            $t_user_name = string_attribute($t_user['realname']);
            if ($t_sort_by_last_name) {
                $t_sort_name_bits = explode(' ', utf8_strtolower($t_user_name), 2);
                $t_sort_name = (isset($t_sort_name_bits[1]) ? $t_sort_name_bits[1] . ', ' : '') . $t_sort_name_bits[0];
            } else {
                $t_sort_name = utf8_strtolower($t_user_name);
            }
        }
        $t_display[] = $t_user_name;
        $t_sort[] = $t_sort_name;
    }
    array_multisort($t_sort, SORT_ASC, SORT_STRING, $t_users, $t_display);
    unset($t_sort);
    $t_count = count($t_users);
    for ($i = 0; $i < $t_count; $i++) {
        $t_row = $t_users[$i];
        echo '<option value="' . $t_row['id'] . '" ';
        check_selected($p_user_id, (int) $t_row['id']);
        echo '>' . $t_display[$i] . '</option>';
    }
}
示例#5
0
/**
 * notify the selected group a new user has signup
 * @param string $p_username
 * @param string $p_email
 * @return null
 */
function email_notify_new_account($p_username, $p_email)
{
    global $g_path;
    $t_threshold_min = config_get('notify_new_user_created_threshold_min');
    $t_threshold_users = project_get_all_user_rows(ALL_PROJECTS, $t_threshold_min);
    foreach ($t_threshold_users as $t_user) {
        lang_push(user_pref_get_language($t_user['id']));
        $t_recipient_email = user_get_email($t_user['id']);
        $t_subject = '[' . config_get('window_title') . '] ' . lang_get('new_account_subject');
        $t_message = lang_get('new_account_signup_msg') . "\n\n" . lang_get('new_account_username') . ' ' . $p_username . "\n" . lang_get('new_account_email') . ' ' . $p_email . "\n" . lang_get('new_account_IP') . ' ' . $_SERVER["REMOTE_ADDR"] . "\n" . $g_path . "\n\n" . lang_get('new_account_do_not_reply');
        if (!is_blank($t_recipient_email)) {
            email_store($t_recipient_email, $t_subject, $t_message);
            log_event(LOG_EMAIL, sprintf('New Account Notify for email = \'%s\'', $t_recipient_email));
            if (OFF == config_get('email_send_using_cronjob')) {
                email_send_all();
            }
        }
        lang_pop();
    }
}
示例#6
0
/**
 * Get appropriate users assigned to a project by access level.
 *
 * @param string $p_username  The name of the user trying to access the versions.
 * @param string $p_password  The password of the user.
 * @param integer $p_project_id  The id of the project to retrieve the users for.
 * @param integer $p_access Minimum access level.
 * @return Array  representing a ProjectAttachmentDataArray structure.
 */
function mc_project_get_users($p_username, $p_password, $p_project_id, $p_access)
{
    $t_user_id = mci_check_login($p_username, $p_password);
    if ($t_user_id === false) {
        return mci_soap_fault_login_failed();
    }
    $t_users = array();
    $t_users = project_get_all_user_rows($p_project_id, $p_access);
    # handles ALL_PROJECTS case
    $t_display = array();
    $t_sort = array();
    $t_show_realname = ON == config_get('show_realname');
    $t_sort_by_last_name = ON == config_get('sort_by_last_name');
    foreach ($t_users as $t_user) {
        $t_user_name = string_attribute($t_user['username']);
        $t_sort_name = strtolower($t_user_name);
        if ($t_show_realname && $t_user['realname'] != "") {
            $t_user_name = string_attribute($t_user['realname']);
            if ($t_sort_by_last_name) {
                $t_sort_name_bits = explode(' ', strtolower($t_user_name), 2);
                $t_sort_name = (isset($t_sort_name_bits[1]) ? $t_sort_name_bits[1] . ', ' : '') . $t_sort_name_bits[0];
            } else {
                $t_sort_name = strtolower($t_user_name);
            }
        }
        $t_display[] = $t_user_name;
        $t_sort[] = $t_sort_name;
    }
    array_multisort($t_sort, SORT_ASC, SORT_STRING, $t_users, $t_display);
    $t_result = array();
    for ($i = 0; $i < count($t_sort); $i++) {
        $t_row = $t_users[$i];
        // This is not very performant - But we have to assure that the data returned is exactly
        // the same as the data that comes with an issue (test for equality - $t_row[] does not
        // contain email fields).
        $t_result[] = mci_account_get_array_by_id($t_row['id']);
    }
    return $t_result;
}
示例#7
0
    echo ' | <a href="summary_page.php?project_id=', $f_project_id, '">', lang_get('summary_link'), '</a>';
}
# Manage Project Page
if (access_has_project_level(config_get('manage_project_threshold'), $f_project_id)) {
    echo ' | <a href="manage_proj_edit_page.php?project_id=', $f_project_id, '">', lang_get('manage_link'), '</a>';
}
echo '</p>';
# @@@ Add status, view state, versions, sub-projects, parent projects, and news.
# @@@ Schema change: add home page, license,
$t_description = project_get_field($f_project_id, 'description');
if (!is_blank($t_description)) {
    echo '<h2>', lang_get('description'), '</h2>';
    echo '<p>', string_display($t_description), '</p>';
}
$t_access_level_for_dev_team = config_get('development_team_threshold');
$t_users = project_get_all_user_rows($f_project_id, $t_access_level_for_dev_team);
$t_show_real_names = config_get('show_realname') == ON;
if (count($t_users) > 0) {
    echo '<h2>', lang_get('development_team'), '</h2>';
    # @@@ sort users in DESC order by access level, then ASC by username/realname.
    foreach ($t_users as $t_user_data) {
        $t_user_id = $t_user_data['id'];
        if ($t_show_real_names && !is_blank($t_user_data['realname'])) {
            $t_user_name = $t_user_data['realname'];
        } else {
            $t_user_name = $t_user_data['username'];
        }
        echo $t_user_name, ' (', get_enum_element('access_levels', $t_user_data['access_level']), ')<br />';
    }
}
html_page_bottom1(__FILE__);
echo lang_get('email');
?>
			</td>
			<td>
				<?php 
echo lang_get('access_level');
?>
			</td>
			<td class="center">
				<?php 
echo lang_get('actions');
?>
			</td>
		</tr>
<?php 
$t_users = project_get_all_user_rows($f_project_id);
$t_display = array();
$t_sort = array();
foreach ($t_users as $t_user) {
    $t_user_name = string_attribute($t_user['username']);
    $t_sort_name = strtolower($t_user_name);
    if (isset($t_user['realname']) && $t_user['realname'] > "" && ON == config_get('show_realname')) {
        $t_user_name = string_attribute($t_user['realname']) . " (" . $t_user_name . ")";
        if (ON == config_get('sort_by_last_name')) {
            $t_sort_name_bits = split(' ', strtolower($t_user_name), 2);
            $t_sort_name = $t_sort_name_bits[1] . ', ' . $t_sort_name_bits[1];
        } else {
            $t_sort_name = strtolower($t_user_name);
        }
    }
    $t_display[] = $t_user_name;
示例#9
0
     $t_projects = user_get_accessible_projects($t_current_user);
     # Get list of users having access level for all accessible projects
     $t_users = array();
     foreach ($t_projects as $t_project_id) {
         $t_project_users_list = project_get_all_user_rows($t_project_id, DEVELOPER);
         # Do a 'smart' merge of the project's user list, into an
         # associative array (to remove duplicates)
         # Use a foreach loop for correctness
         foreach ($t_project_users_list as $t_key => $t_user) {
             $t_users[$t_user['id']] = $t_user;
         }
         unset($t_project_users_list);
     }
     unset($t_projects);
 } else {
     $t_users = project_get_all_user_rows($p_project_id, DEVELOPER);
 }
 $t_show_realname = ON == config_get('show_realname');
 $t_sort_by_last_name = ON == config_get('sort_by_last_name');
 foreach ($t_users as $t_key => $t_user) {
     $t_user_name = string_attribute($t_user['username']);
     $t_sort_name = utf8_strtolower($t_user_name);
     if ($t_show_realname && $t_user['realname'] != '') {
         $t_user_name = string_attribute($t_user['realname']);
         if ($t_sort_by_last_name) {
             $t_sort_name_bits = explode(' ', utf8_strtolower($t_user_name), 2);
             $t_sort_name = (isset($t_sort_name_bits[1]) ? $t_sort_name_bits[1] . ', ' : '') . $t_sort_name_bits[0];
         } else {
             $t_sort_name = utf8_strtolower($t_user_name);
         }
     }
$p_level = 0;
$p_cache = null;
if (null == $p_projects) {
    $t_project_id = helper_get_current_project();
    if (ALL_PROJECTS == $t_project_id) {
        $p_projects = current_user_get_accessible_projects();
    } else {
        $p_projects = array($t_project_id);
    }
}
//TODO
//$t_users = project_get_all_user_rows( $p_project_id = ALL_PROJECTS, $p_access_level = ANYBODY, $p_include_global_users = true );
$todo_project_id = ALL_PROJECTS;
$todo_version_id = null;
$todo_inherited = null;
$t_users = project_get_all_user_rows($todo_project_id, ANYBODY);
//returns array of (id, username, realname, access_level)
foreach ($t_users as $t_user) {
    ?>
        <tr valign="top">
          <td class="category"><?php 
    echo $t_user['username'];
    ?>
</td>
          <td>
            <table>
<?php 
    ?>
  		
          		<tr <?php 
    echo helper_alternate_class();
示例#11
0
     echo 'ERROR: Contact your Mantis administrator';
 }
 $t_message = ob_get_contents();
 ob_end_clean();
 $t_template_file = $t_template_dir . 'html_inc.php';
 ob_start();
 if (file_exists($t_template_file)) {
     include $t_template_file;
 } else {
     echo 'ERROR: Contact your Mantis administrator';
 }
 $t_html_message = ob_get_contents();
 ob_end_clean();
 $t_id_list = array();
 if (plugin_config_get('notify_handler', PLUGINS_RELEASEMGT_NOTIFY_HANDLER_DEFAULT) == ON) {
     $t_user_list = project_get_all_user_rows($t_project_id, config_get('handle_bug_threshold'));
     foreach ($t_user_list as $t_user) {
         $t_id_list[] = $t_user['id'];
     }
 }
 // Get reporter
 if (plugin_config_get('notify_reporter', PLUGINS_RELEASEMGT_NOTIFY_REPORTER_DEFAULT) == ON) {
     if ($t_version == 0) {
         $t_query = 'SELECT reporter_id FROM ' . db_get_table('mantis_bug_table') . ' WHERE project_id=' . db_prepare_int($t_project_id) . ' AND fixed_in_version=\'\'';
     } else {
         $t_query = 'SELECT reporter_id FROM ' . db_get_table('mantis_bug_table') . ' WHERE project_id=' . db_prepare_int($t_project_id) . ' AND fixed_in_version=\'' . db_prepare_string(version_get_field($t_version, 'version')) . '\'';
     }
     $t_result = db_query($t_query);
     while ($t_row = db_fetch_array($t_result)) {
         $t_id_list[] = $t_row['reporter_id'];
     }
示例#12
0
/**
 * notify the selected group a new user has signup
 * @param string $p_username Username of new user.
 * @param string $p_email    Email address of new user.
 * @return void
 */
function email_notify_new_account($p_username, $p_email)
{
    log_event(LOG_EMAIL, 'New account for user %s', $p_username);
    $t_threshold_min = config_get('notify_new_user_created_threshold_min');
    $t_threshold_users = project_get_all_user_rows(ALL_PROJECTS, $t_threshold_min);
    $t_user_ids = array_keys($t_threshold_users);
    user_cache_array_rows($t_user_ids);
    user_pref_cache_array_rows($t_user_ids);
    foreach ($t_threshold_users as $t_user) {
        lang_push(user_pref_get_language($t_user['id']));
        $t_recipient_email = user_get_email($t_user['id']);
        $t_subject = '[' . config_get('window_title') . '] ' . lang_get('new_account_subject');
        $t_message = lang_get('new_account_signup_msg') . "\n\n" . lang_get('new_account_username') . ' ' . $p_username . "\n" . lang_get('new_account_email') . ' ' . $p_email . "\n" . lang_get('new_account_IP') . ' ' . $_SERVER['REMOTE_ADDR'] . "\n" . config_get_global('path') . "\n\n" . lang_get('new_account_do_not_reply');
        if (!is_blank($t_recipient_email)) {
            email_store($t_recipient_email, $t_subject, $t_message);
            log_event(LOG_EMAIL, 'New Account Notify for email = \'%s\'', $t_recipient_email);
        }
        lang_pop();
    }
}
            $t_sort_name_bits = explode(' ', utf8_strtolower($t_user_name), 2);
            $t_sort_name = $t_sort_name_bits[1] . ', ' . $t_sort_name_bits[1];
        } else {
            $t_sort_name = utf8_strtolower($t_user_name);
        }
    }
    $t_display[] = $t_user_name;
    $t_sort[] = $t_sort_name;
}
array_multisort($t_sort, SORT_ASC, SORT_STRING, $t_users, $t_display);
$t_users_count = count($t_sort);
$t_removable_users_exist = false;
# If including global users, fetch here all local user to later distinguish them
$t_local_users = array();
if ($f_show_global_users) {
    $t_local_users = project_get_all_user_rows($f_project_id, ANYBODY, false);
}
$t_token_remove_user = form_security_token('manage_proj_user_remove');
for ($i = 0; $i < $t_users_count; $i++) {
    $t_user = $t_users[$i];
    ?>
			<tr>
				<td>
					<a href="manage_user_edit_page.php?user_id=<?php 
    echo $t_user['id'];
    ?>
">
						<?php 
    echo $t_display[$i];
    ?>
					</a>