public function schema()
 {
     return [['CreateTableSQL', [plugin_table('tasks'), 'id I UNSIGNED PRIMARY NOTNULL AUTOINCREMENT,
             bug_id I UNSIGNED NOTNULL DEFAULT \'0\',
             description C(120) NOTNULL DEFAULT \'\',
             finished L DEFAULT 0', ['mysql' => 'ENGINE=MyISAM DEFAULT CHARSET=utf8', 'pgsql' => 'WITHOUT OIDS']]], ['CreateIndexSQL', ['idx_tasks_bug_id', plugin_table('tasks'), 'bug_id']]];
 }
 /**
  * @param $table
  * @return string
  */
 private function get_mantis_plugin_table($table)
 {
     if ($this->get_mantis_version() == '1.2.') {
         $mantis_plugin_table = plugin_table($table, 'SpecManagement');
     } else {
         $mantis_plugin_table = db_get_table('plugin_SpecManagement_' . $table);
     }
     return $mantis_plugin_table;
 }
 /**
  * @author Lennard Bredenkamp, BFE
  * NOT USED AT THE MOMENT (loadRelations is used to load multiple relations instead)
  * get single tts_relation object from DB
  * @param $p_bug_id
  * @param $tts_exec_id
  * @return TTSrelation object
  */
 static function loadRelation($p_bug_id, $tts_exec_id)
 {
     $t_project_table = plugin_table('project', 'TTSintegr');
     $its_id = $p_bug_id;
     $t_query = "SELECT * FROM {$t_project_table} WHERE its_id=" . db_param() . " AND tts_exec_id=" . db_param();
     $t_result = db_query_bound($t_query, array($its_id, $tts_exec_id));
     $t_row = db_fetch_array($t_result);
     $t_relation = new TTSrelation($t_row['its_id'], $t_row['tts_exec_id'], $t_row['tts_tproject_id']);
     return $t_relation;
 }
Esempio n. 4
0
/**
 * Created by PhpStorm.
 * User: wb-liuyuguang
 * Date: 14-7-31
 * Time: 下午1:30
 */
function get_project_package_list($p_package_id)
{
    $t_acra_prj_table = plugin_table("project");
    $query = "SELECT * FROM {$t_acra_prj_table} WHERE `project_id` = {$p_package_id} LIMIT 0, 1";
    $result = db_query_bound($query);
    $result = db_fetch_array($result);
    if ($result === false) {
        return;
    }
    $packages = $result['packages'];
    return handle_project_package_list($packages);
}
 function schema()
 {
     require_once __DIR__ . DIRECTORY_SEPARATOR . 'core' . DIRECTORY_SEPARATOR . 'wmApi.php';
     $tableArray = array();
     $whiteboardMenuTable = array('CreateTableSQL', array(plugin_table('menu', 'whiteboard'), "\n            id                   I       NOTNULL UNSIGNED AUTOINCREMENT PRIMARY,\n            plugin_name          C(250)  DEFAULT '',\n            plugin_access_level  I       UNSIGNED,\n            plugin_show_menu     I       UNSIGNED,\n            plugin_menu_path     C(250)  DEFAULT ''\n            "));
     $boolArray = wmApi::checkWhiteboardTablesExist();
     # add whiteboardmenu table if it does not exist
     if (!$boolArray[0]) {
         array_push($tableArray, $whiteboardMenuTable);
     }
     return $tableArray;
 }
Esempio n. 6
0
function getAcraIssueList()
{
    $t_acra_issue_table = plugin_table("issue");
    $query = "SELECT * FROM {$t_acra_issue_table} WHERE `custom_data` REGEXP 'url'  ORDER BY `id` DESC";
    $result = db_query_bound($query);
    $list = array();
    while (true) {
        $row = db_fetch_array($result);
        if ($row === false) {
            break;
        }
        $list[] = $row;
    }
    return $list;
}
Esempio n. 7
0
function getAcraIssueList($page_num, $total_count)
{
    global $acra_id;
    $acra_id = $_GET['acra_hash'];
    $t_acra_issue_table = plugin_table("issue");
    $where = getFilterQueryString();
    $query = "SELECT * FROM {$t_acra_issue_table} WHERE `report_fingerprint`='" . $acra_id . "'" . $where . buildOrderString() . buildPageQueryString($page_num, $total_count);
    $result = db_query_bound($query);
    $list = array();
    while (true) {
        $row = db_fetch_array($result);
        if ($row === false) {
            break;
        }
        $list[] = $row;
    }
    return $list;
}
Esempio n. 8
0
 public function create()
 {
     $t_issue_ext_table = plugin_table("issue");
     # Insert the rest of the data
     $query = "INSERT INTO {$t_issue_ext_table}\n\t\t\t\t\t    ( project_id ,              issue_id,       report_id,   report_fingerprint,\n                        file_path,               phone_model,    phone_build, phone_brand,\n                        product_name,            total_mem_size, available_mem_size, custom_data,\n                        initial_configuration,   crash_configuration, display, user_comment,\n                        dumpsys_meminfo,         dropbox,        eventslog,    radiolog,\n                        is_silent,               device_id,      installation_id,  user_email,\n                        device_features,         environment,    settings_system, settings_secure,\n                        shared_preferences,      android_version,app_version,     crash_date,\n                        report_date,             install_date\n\t\t\t\t\t    )\n\t\t\t\t\t  VALUES\n\t\t\t\t\t    ( " . db_param() . ',' . db_param() . ',' . db_param() . ',' . db_param() . ",\n\t\t\t\t\t      " . db_param() . ',' . db_param() . ',' . db_param() . ',' . db_param() . ",\n\t\t\t\t\t      " . db_param() . ',' . db_param() . ',' . db_param() . ',' . db_param() . ",\n\t\t\t\t\t      " . db_param() . ',' . db_param() . ',' . db_param() . ',' . db_param() . ",\n\t\t\t\t\t      " . db_param() . ',' . db_param() . ',' . db_param() . ',' . db_param() . ",\n\t\t\t\t\t      " . db_param() . ',' . db_param() . ',' . db_param() . ',' . db_param() . ",\n\t\t\t\t\t      " . db_param() . ',' . db_param() . ',' . db_param() . ',' . db_param() . ",\n\t\t\t\t\t      " . db_param() . ',' . db_param() . ',' . db_param() . ',' . db_param() . ",\n\t\t\t\t\t      " . 'now()' . ',' . db_param() . ')';
     $t_display_errors = config_get_global('display_errors');
     $t_on_error_handler = $t_display_errors[E_USER_ERROR];
     $t_display_errors[E_USER_ERROR] = "none";
     config_set_global('display_errors', $t_display_errors);
     $t_result = db_query_bound($query, array($this->project_id, $this->issue_id, $this->report_id, $this->report_fingerprint, $this->file_path, $this->phone_model, $this->phone_build, $this->phone_brand, $this->product_name, $this->total_mem_size, $this->available_mem_size, $this->custom_data, $this->initial_configuration, $this->crash_configuration, $this->display, $this->user_comment, $this->dumpsys_meminfo, $this->dropbox, $this->eventslog, $this->radiolog, $this->is_silent, $this->device_id, $this->installation_id, $this->user_email, $this->device_features, $this->environment, $this->settings_system, $this->settings_secure, $this->shared_preferences, $this->android_version, $this->app_version, $this->crash_date . $this->report_date, $this->install_date));
     $t_display_errors[E_USER_ERROR] = $t_on_error_handler;
     config_set_global('display_errors', $t_display_errors);
     if ($t_result === false) {
         return false;
     }
     $this->id = db_insert_id($t_issue_ext_table);
     return true;
 }
/**
 * Check user from projects table.
 */
function check_user_from_projects_table($bug_id)
{
    $user_id = bug_get_field($bug_id, 'reporter_id');
    $proj_id = bug_get_field($bug_id, 'project_id');
    $user_proj_table = plugin_table('user_proj', 'JabberNotifierSystem');
    $query = "SELECT proj_id FROM {$user_proj_table} WHERE user_id = {$user_id} LIMIT 1;";
    $res = db_query($query);
    if (db_num_rows($res) != 0) {
        $row = db_fetch_array($res);
        $arr = explode(',', $row['proj_id']);
        if (in_array($proj_id, $arr)) {
            return true;
        } else {
            return false;
        }
    }
    return true;
}
Esempio n. 10
0
/**
* Returns an array of time tracking stats
* @param int $p_project_id project id
* @param string $p_from Starting date (yyyy-mm-dd) inclusive, if blank, then ignored.
* @param string $p_to Ending date (yyyy-mm-dd) inclusive, if blank, then ignored.
* @return array array of bugnote stats
* @access public
*/
function plugin_TimeTracking_stats_get_project_array($p_project_id, $p_from, $p_to)
{
    $c_project_id = db_prepare_int($p_project_id);
    $c_to = "'" . date("Y-m-d", strtotime("{$p_to}") + SECONDS_PER_DAY - 1) . "'";
    $c_from = "'" . $p_from . "'";
    //strtotime( $p_from )
    if ($c_to === false || $c_from === false) {
        error_parameters(array($p_form, $p_to));
        trigger_error(ERROR_GENERIC, ERROR);
    }
    $t_timereport_table = plugin_table('data', 'TimeTracking');
    $t_bug_table = db_get_table('mantis_bug_table');
    $t_user_table = db_get_table('mantis_user_table');
    $t_project_table = db_get_table('mantis_project_table');
    if (!is_blank($c_from)) {
        $t_from_where = " AND expenditure_date >= {$c_from}";
    } else {
        $t_from_where = '';
    }
    if (!is_blank($c_to)) {
        $t_to_where = " AND expenditure_date <= {$c_to}";
    } else {
        $t_to_where = '';
    }
    if (ALL_PROJECTS != $c_project_id) {
        $t_project_where = " AND b.project_id = '{$c_project_id}'  ";
    } else {
        $t_project_where = '';
    }
    if (!access_has_global_level(plugin_config_get('view_others_threshold'))) {
        $t_user_id = auth_get_current_user_id();
        $t_user_where = " AND user = '******'  ";
    } else {
        $t_user_where = '';
    }
    $t_results = array();
    $query = "SELECT u.username, p.name as project_name, bug_id, expenditure_date, hours, timestamp, info \nFROM {$t_timereport_table} tr, {$t_bug_table} b, {$t_user_table} u, {$t_project_table} p\nWHERE tr.bug_id=b.id and tr.user=u.id AND p.id = b.project_id\n{$t_project_where} {$t_from_where} {$t_to_where} {$t_user_where}\nORDER BY user, expenditure_date, bug_id";
    $result = db_query($query);
    while ($row = db_fetch_array($result)) {
        $t_results[] = $row;
    }
    return $t_results;
}
Esempio n. 11
0
function getList($where, $what)
{
    if (strlen($where) > 0) {
        $where = "WHERE `report_fingerprint`='" . $_GET['acra_hash'] . "' AND " . $where;
    } else {
        $where = "WHERE `report_fingerprint`='" . $_GET['acra_hash'] . "'";
    }
    $t_acra_issue_table = plugin_table("issue");
    $query = "SELECT `{$what}` FROM {$t_acra_issue_table} {$where} GROUP BY  `{$what}`";
    $result = db_query_bound($query);
    $list = array();
    while (true) {
        $row = db_fetch_array($result);
        if ($row === false) {
            break;
        }
        $list[] = $row[$what];
    }
    return $list;
}
 public function cache($p_bugs)
 {
     if (count($p_bugs) < 1) {
         return;
     }
     $t_bug_table = plugin_table('bug', 'Source');
     $t_bug_ids = array();
     foreach ($p_bugs as $t_bug) {
         $t_bug_ids[] = $t_bug->id;
     }
     $t_bug_ids = implode(',', $t_bug_ids);
     $t_query = "SELECT * FROM {$t_bug_table} WHERE bug_id IN ( {$t_bug_ids} )";
     $t_result = db_query_bound($t_query);
     while ($t_row = db_fetch_array($t_result)) {
         if (isset($this->changeset_cache[$t_row['bug_id']])) {
             $this->changeset_cache[$t_row['bug_id']]++;
         } else {
             $this->changeset_cache[$t_row['bug_id']] = 1;
         }
     }
 }
Esempio n. 13
0
function print_users_in_group_option_list($usergroup_id)
{
    if (plugin_config_get('assign_to_groups', '') == 1 && plugin_config_get('assign_group_threshold', '') <= user_get_access_level(auth_get_current_user_id())) {
        $show_groups = 1;
    } else {
        $show_groups = 0;
    }
    $t_table_users = plugin_table('users');
    $t_user_table = db_get_table('mantis_user_table');
    $query = "SELECT * FROM (";
    $query .= "    SELECT u.id, u.username, u.realname, ug.group_user_id";
    $query .= "    FROM {$t_user_table} AS u";
    $query .= "        LEFT JOIN {$t_table_users} AS ug ON (u.id=ug.user)";
    //if( plugin_config_get('assign_to_groups', '') == 0  || plugin_config_get('assign_group_threshold','') > user_get_access_level( auth_get_current_user_id() ) )
    if ($show_groups == 0) {
        $query .= "    WHERE u.username NOT LIKE " . db_param();
    }
    $query .= ") AS t1 WHERE group_user_id=" . db_param() . " OR group_user_id IS NULL ORDER BY username ASC";
    if ($show_groups == 0) {
        $result = db_query_bound($query, array(plugin_config_get('group_prefix') . '%', (int) $usergroup_id));
    } else {
        $result = db_query_bound($query, array((int) $usergroup_id));
    }
    $count = db_num_rows($result);
    for ($i = 0; $i < $count; $i++) {
        $row = db_fetch_array($result);
        if ($row['id'] == $usergroup_id) {
            continue;
            //usergroup must not be nested with itself
        }
        echo '<option value="' . $row['id'] . '" ';
        if (!is_null($row['group_user_id'])) {
            echo 'selected="selected"';
        } else {
            echo '';
        }
        echo '>' . $row['username'] . '</option>';
    }
}
Esempio n. 14
0
<?php

access_ensure_project_level(plugin_config_get('serials_view_threshold'));
header('Content-Type: application/json');
$g_mantis_serials_customer = plugin_table('customer');
$g_mantis_serials_assembly = plugin_table('assembly');
$g_mantis_serials_format = plugin_table('format');
$g_mantis_serials_serial = plugin_table('serial');
$p_assembly_id = gpc_get_string('assembly_id');
function get_format($p_assembly_id)
{
    $t_assembly_id = $p_assembly_id;
    global $g_mantis_serials_format;
    $query = "SELECT format, format_id, format_example\n\t\t\t\tFROM {$g_mantis_serials_format}\n\t\t\t\tWHERE assembly_id='{$t_assembly_id}'";
    $result = mysql_query($query) or die(mysql_error());
    //Create an array
    $json_response = array();
    while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
        $row_array['format'] = $row['format'];
        $row_array['format_id'] = $row['format_id'];
        $row_array['format_example'] = $row['format_example'];
        //push the values in the array
        array_push($json_response, $row_array);
    }
    $jsonString = json_encode($json_response);
    echo $jsonString;
}
echo get_format($p_assembly_id);
 /**
  * Returns an array of all users from the group user id param. Calls itself,
  * if it detects a nested group.
  * @param int $p_group_user_id user_id of a group
  * @return array Array of users in the group
  */
 function get_all_users_from_group($p_group_user_id)
 {
     $t_table_users = plugin_table('users');
     $t_all_groups = $this->get_all_groups(TRUE);
     $query = "SELECT user FROM {$t_table_users} WHERE group_user_id=" . db_param();
     $result = db_query_bound($query, array($p_group_user_id));
     $count = db_num_rows($result);
     $t_users = array();
     for ($i = 0; $i < $count; $i++) {
         $row = db_fetch_array($result);
         if (in_array($row['user'], $t_all_groups)) {
             $t_users = $t_users + $this->get_all_users_from_group($row['user']);
         } else {
             $t_users[] = $row['user'];
         }
     }
     return $t_users;
 }
Esempio n. 16
0
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   See the License for the specific language governing permissions and
   limitations under the License.
*/
$xmpp_login = gpc_get_string('xmpp_login', '');
$user_id = gpc_get_string('user_id', '');
// Get user login
$user_table = db_get_table('mantis_user_table');
$query_rep_user_name = "SELECT username FROM {$user_table} WHERE id = {$user_id};";
$res_user_name = db_query($query_rep_user_name);
while ($row_user_name = db_fetch_array($res_user_name)) {
    $user_name = $row_user_name['username'];
}
// Add xmpp login
if ($xmpp_login != '') {
    $xmpp_table = plugin_table('xmpp_login', 'JabberNotifierSystem');
    $query_xmpp_login = "******";
    $res_xmpp_login = db_query($query_xmpp_login);
    if (db_num_rows($res_xmpp_login) == 0) {
        if ($xmpp_login != $user_name) {
            $add_user_query = "INSERT INTO {$xmpp_table} (user_id, xmpp_login, chng_login) VALUES ({$user_id}, \"{$xmpp_login}\", 0);";
            db_query($add_user_query);
            print_successful_redirect('account_page.php');
        } else {
            print_successful_redirect('account_page.php');
            exit;
        }
    } else {
        $add_user_query = "UPDATE {$xmpp_table} SET xmpp_login = \"{$xmpp_login}\" WHERE user_id = {$user_id};";
        db_query_bound($add_user_query);
        print_successful_redirect('account_page.php');
 function schema()
 {
     return array(array('CreateTableSQL', array(plugin_table('src'), "\n            id              I       NOTNULL UNSIGNED AUTOINCREMENT PRIMARY,\n            bug_id          I       NOTNULL UNSIGNED,\n            p_version_id    I       UNSIGNED,\n            work_package    C(250)  DEFAULT ''\n            ")), array('CreateTableSQL', array(plugin_table('ptime'), "\n            id       I    NOTNULL UNSIGNED AUTOINCREMENT PRIMARY,\n            bug_id   I    NOTNULL UNSIGNED,\n            time     I    NOTNULL UNSIGNED\n            ")), array('CreateTableSQL', array(plugin_table('vers'), "\n            id          I   NOTNULL UNSIGNED AUTOINCREMENT PRIMARY,\n            project_id  I   NOTNULL UNSIGNED,\n            version_id  I   NOTNULL UNSIGNED,\n            type_id     I   UNSIGNED\n            ")), array('CreateTableSQL', array(plugin_table('type'), "\n            id           I       NOTNULL UNSIGNED AUTOINCREMENT PRIMARY,\n            type         C(250)  NOTNULL DEFAULT '',\n            opt          C(250)  DEFAULT ''\n            ")));
 }
 public function import_full($p_repo)
 {
     echo '<pre>';
     $t_branch = $p_repo->info['master_branch'];
     if (is_blank($t_branch)) {
         $t_branch = 'master';
     }
     if ($t_branch != '*') {
         $t_branches = array_map('trim', explode(',', $t_branch));
     } else {
         $t_heads_url = $this->uri_base($p_repo) . 'a=heads';
         $t_branches_input = url_get($t_heads_url);
         $t_branches_input = str_replace(array(PHP_EOL, '&lt;', '&gt;', '&nbsp;'), array('', '<', '>', ' '), $t_branches_input);
         $t_branches_input_p1 = strpos($t_branches_input, '<table class="heads">');
         $t_branches_input_p2 = strpos($t_branches_input, '<div class="page_footer">');
         $t_gitweb_heads = substr($t_branches_input, $t_branches_input_p1, $t_branches_input_p2 - $t_branches_input_p1);
         preg_match_all('/<a class="list name".*>(.*)<\\/a>/iU', $t_gitweb_heads, $t_matches, PREG_SET_ORDER);
         $t_branches = array();
         foreach ($t_matches as $match) {
             $t_branch = trim($match[1]);
             if ($match[1] != 'origin' and !in_array($t_branch, $t_branches)) {
                 $t_branches[] = $t_branch;
             }
         }
     }
     $t_changesets = array();
     $t_changeset_table = plugin_table('changeset', 'Source');
     foreach ($t_branches as $t_branch) {
         $t_query = "SELECT parent FROM {$t_changeset_table}\n\t\t\t\tWHERE repo_id=" . db_param() . ' AND branch=' . db_param() . 'ORDER BY timestamp ASC';
         $t_result = db_query_bound($t_query, array($p_repo->id, $t_branch), 1);
         $t_commits = array($t_branch);
         if (db_num_rows($t_result) > 0) {
             $t_parent = db_result($t_result);
             echo "Oldest '{$t_branch}' branch parent: '{$t_parent}'\n";
             if (!empty($t_parent)) {
                 $t_commits[] = $t_parent;
             }
         }
         $t_changesets = array_merge($t_changesets, $this->import_commits($p_repo, $this->uri_base($p_repo), $t_commits, $t_branch));
     }
     echo '</pre>';
     return $t_changesets;
 }
# loop through all users
foreach ($a_users as $i_userId => $a_properties) {
    # get all mite projects and services of the user
    ################################################
    $s_query = "SELECT type, name, mite_project_id , mite_service_id FROM " . plugin_table(Mantis2mitePlugin::DB_TABLE_PS) . " WHERE user_id = " . $i_userId;
    $r_result = db_query_bound($s_query);
    $b_userHasMiteData = db_num_rows($r_result) > 0;
    while ($b_userHasMiteData && ($a_row = db_fetch_array($r_result))) {
        $s_type = $a_row['type'];
        $s_rsrcTypeFieldName = Mantis2mitePlugin::$a_fieldNamesMiteRsrcTypes[$s_type];
        $a_userMiteData[$s_type][$a_row[$s_rsrcTypeFieldName]] = $a_row['name'];
    }
    # get time entries for this bug and
    # build a modifieable list as output
    ####################################
    $s_query = "\n\t\t\tSELECT * FROM " . plugin_table(Mantis2mitePlugin::DB_TABLE_TE) . "\n\t\t\tWHERE user_id = {$i_userId} AND bug_id = {$i_bugId} ORDER BY created_at DESC";
    $r_result = db_query_bound($s_query);
    $b_pageHasUserTimeEnries = db_num_rows($r_result) > 0;
    $s_patternTwoDigits = '%d:%02d';
    while ($b_pageHasUserTimeEnries && ($a_row = db_fetch_array($r_result))) {
        if ($i_counter == 0) {
            $s_cssClass = " class='firstRow'";
        }
        $i_totalTime += $a_row['mite_duration'];
        if ($a_row['mite_note']) {
            $s_noteToggler = "\n\t    \t\t\t<a href='#' class='plugin_mite_time_entry_show_note'>" . lang_get('plugin_mite_time_entry_show_note') . "\n\t    \t\t\t\t<span>" . html_entity_decode($a_row['mite_note'], ENT_QUOTES, 'UTF-8') . "</span>\n\t\t    \t\t</a>";
        }
        $s_userEntries .= "\n\t    \t\t<tr>\n\t    \t\t\t<td" . $s_cssClass . ">";
        if ($i_currentUserId == $i_userId) {
            $s_userEntries .= "\n\t    \t\t\t<form>\n\t    \t\t\t\t<button class='plugin_mite_delete_time_entry'>" . lang_get('plugin_mite_delete_time_entry') . "</button>\n\t    \t\t\t\t<input type='hidden' name = 'mite_id' value = '" . $a_row['mite_time_entry_id'] . "' />\n\t\t\t\t\t</form>";
        }
Esempio n. 20
0
 function schema()
 {
     return array(array('CreateTableSQL', array(plugin_table('repository'), "\n\t\t\t\tid\t\t\tI\t\tNOTNULL UNSIGNED AUTOINCREMENT PRIMARY,\n\t\t\t\ttype\t\tC(8)\tNOTNULL DEFAULT \" '' \" PRIMARY,\n\t\t\t\tname\t\tC(128)\tNOTNULL DEFAULT \" '' \" PRIMARY,\n\t\t\t\turl\t\t\tC(250)\tDEFAULT \" '' \",\n\t\t\t\tinfo\t\tXL\t\tNOTNULL\n\t\t\t\t", array('mysql' => 'DEFAULT CHARSET=utf8'))), array('CreateTableSQL', array(plugin_table('changeset'), "\n\t\t\t\tid\t\t\tI\t\tNOTNULL UNSIGNED AUTOINCREMENT PRIMARY,\n\t\t\t\trepo_id\t\tI\t\tNOTNULL UNSIGNED PRIMARY,\n\t\t\t\trevision\tC(250)\tNOTNULL PRIMARY,\n\t\t\t\tbranch\t\tC(250)\tNOTNULL DEFAULT \" '' \",\n\t\t\t\tuser_id\t\tI\t\tNOTNULL UNSIGNED DEFAULT '0',\n\t\t\t\ttimestamp\tT\t\tNOTNULL,\n\t\t\t\tauthor\t\tC(250)\tNOTNULL DEFAULT \" '' \",\n\t\t\t\tmessage\t\tXL\t\tNOTNULL,\n\t\t\t\tinfo\t\tXL\t\tNOTNULL\n\t\t\t\t", array('mysql' => 'DEFAULT CHARSET=utf8'))), array('CreateIndexSQL', array('idx_changeset_stamp_author', plugin_table('changeset'), 'timestamp, author')), array('CreateTableSQL', array(plugin_table('file'), "\n\t\t\t\tid\t\t\tI\t\tNOTNULL UNSIGNED AUTOINCREMENT PRIMARY,\n\t\t\t\tchange_id\tI\t\tNOTNULL UNSIGNED,\n\t\t\t\trevision\tC(250)\tNOTNULL,\n\t\t\t\tfilename\tXL\t\tNOTNULL\n\t\t\t\t", array('mysql' => 'DEFAULT CHARSET=utf8'))), array('CreateIndexSQL', array('idx_file_change_revision', plugin_table('file'), 'change_id, revision')), array('CreateTableSQL', array(plugin_table('bug'), "\n\t\t\t\tchange_id\tI\t\tNOTNULL UNSIGNED PRIMARY,\n\t\t\t\tbug_id\t\tI\t\tNOTNULL UNSIGNED PRIMARY\n\t\t\t\t", array('mysql' => 'DEFAULT CHARSET=utf8'))), array('AddColumnSQL', array(plugin_table('file'), "\n\t\t\t\taction\t\tC(8)\tNOTNULL DEFAULT \" '' \"\n\t\t\t\t")), array('AddColumnSQL', array(plugin_table('changeset'), "\n\t\t\t\tparent\t\tC(250)\tNOTNULL DEFAULT \" '' \"\n\t\t\t\t")), array('AddColumnSQL', array(plugin_table('changeset'), "\n\t\t\t\tported\t\tC(250)\tNOTNULL DEFAULT \" '' \"\n\t\t\t\t")), array('AddColumnSQL', array(plugin_table('changeset'), "\n\t\t\t\tauthor_email\tC(250)\tNOTNULL DEFAULT \" '' \"\n\t\t\t\t")), array('AddColumnSQL', array(plugin_table('changeset'), "\n\t\t\t\tcommitter\t\tC(250)\tNOTNULL DEFAULT \" '' \",\n\t\t\t\tcommitter_email\tC(250)\tNOTNULL DEFAULT \" '' \",\n\t\t\t\tcommitter_id\tI\t\tNOTNULL UNSIGNED DEFAULT '0'\n\t\t\t\t")), array('CreateTableSQL', array(plugin_table('branch'), "\n\t\t\t\trepo_id\t\tI\t\tNOTNULL UNSIGNED PRIMARY,\n\t\t\t\tbranch\t\tC(128)\tNOTNULL PRIMARY,\n\t\t\t\ttype\t\tI\t\tNOTNULL UNSIGNED DEFAULT '0',\n\t\t\t\tversion\t\tC(64)\tNOTNULL DEFAULT \" '' \",\n\t\t\t\tregex\t\tC(128)\tNOTNULL DEFAULT \" '' \"\n\t\t\t\t", array('mysql' => 'DEFAULT CHARSET=utf8'))), array('CreateTableSQL', array(plugin_table('user'), "\n\t\t\t\tuser_id\t\tI\t\tNOTNULL UNSIGNED PRIMARY,\n\t\t\t\tusername\tC(64)\tNOTNULL DEFAULT \" '' \"\n\t\t\t\t", array('mysql' => 'DEFAULT CHARSET=utf8'))), array('CreateIndexSQL', array('idx_source_user_username', plugin_table('user'), 'username', array('UNIQUE'))), array('UpdateSQL', array(plugin_table('repository'), " SET type='websvn' WHERE type='svn'")), array('AddColumnSQL', array(plugin_table('branch'), "\n\t\t\t\tpvm_version_id\tI\t\tNOTNULL UNSIGNED DEFAULT '0'\n\t\t\t\t")));
 }
Esempio n. 21
0
function plugins_releasemgt_file_add($p_tmp_file, $p_file_name, $p_file_type, $p_project_id, $p_version_id, $p_description, $p_file_error)
{
    if (php_version_at_least('4.2.0')) {
        switch ((int) $p_file_error) {
            case UPLOAD_ERR_INI_SIZE:
            case UPLOAD_ERR_FORM_SIZE:
                trigger_error(ERROR_FILE_TOO_BIG, ERROR);
                break;
            case UPLOAD_ERR_PARTIAL:
            case UPLOAD_ERR_NO_FILE:
                trigger_error(ERROR_FILE_NO_UPLOAD_FAILURE, ERROR);
                break;
            default:
                break;
        }
    }
    if ('' == $p_tmp_file || '' == $p_file_name) {
        trigger_error(ERROR_FILE_NO_UPLOAD_FAILURE, ERROR);
    }
    if (!is_readable($p_tmp_file)) {
        trigger_error(ERROR_UPLOAD_FAILURE, ERROR);
    }
    if (!plugins_releasemgt_file_is_name_unique($p_file_name, $p_project_id, $p_version_id)) {
        trigger_error(ERROR_DUPLICATE_FILE, ERROR);
    }
    $c_version_id = db_prepare_int($p_version_id);
    $c_project_id = db_prepare_int($p_project_id);
    $c_file_type = db_prepare_string($p_file_type);
    $c_title = db_prepare_string($p_file_name);
    $c_desc = db_prepare_string($p_description);
    $t_file_path = dirname(plugin_config_get('disk_dir', PLUGINS_RELEASEMGT_DISK_DIR_DEFAULT) . DIRECTORY_SEPARATOR . '.') . DIRECTORY_SEPARATOR;
    $c_file_path = db_prepare_string($t_file_path);
    $c_new_file_name = db_prepare_string($p_file_name);
    $t_file_hash = $p_version_id . '-' . $t_project_id;
    $t_disk_file_name = $t_file_path . plugins_releasemgt_file_generate_unique_name($t_file_hash . '-' . $p_file_name, $t_file_path);
    $c_disk_file_name = db_prepare_string($t_disk_file_name);
    $t_file_size = filesize($p_tmp_file);
    if (0 == $t_file_size) {
        trigger_error(ERROR_FILE_NO_UPLOAD_FAILURE, ERROR);
    }
    $t_max_file_size = (int) min(ini_get_number('upload_max_filesize'), ini_get_number('post_max_size'), config_get('max_file_size'));
    if ($t_file_size > $t_max_file_size) {
        trigger_error(ERROR_FILE_TOO_BIG, ERROR);
    }
    $c_file_size = db_prepare_int($t_file_size);
    $t_method = plugin_config_get('upload_method', PLUGINS_RELEASEMGT_UPLOAD_METHOD_DEFAULT);
    switch ($t_method) {
        case FTP:
        case DISK:
            file_ensure_valid_upload_path($t_file_path);
            if (!file_exists($t_disk_file_name)) {
                if (FTP == $t_method) {
                    $conn_id = plugins_releasemgt_file_ftp_connect();
                    file_ftp_put($conn_id, $t_disk_file_name, $p_tmp_file);
                    file_ftp_disconnect($conn_id);
                }
                if (!move_uploaded_file($p_tmp_file, $t_disk_file_name)) {
                    trigger_error(FILE_MOVE_FAILED, ERROR);
                }
                chmod($t_disk_file_name, 0644);
                $c_content = '';
            } else {
                trigger_error(ERROR_FILE_DUPLICATE, ERROR);
            }
            break;
        case DATABASE:
            $c_content = db_prepare_string(fread(fopen($p_tmp_file, 'rb'), $t_file_size));
            break;
        default:
            trigger_error(ERROR_GENERIC, ERROR);
    }
    $t_file_table = plugin_table('file');
    $query = "INSERT INTO {$t_file_table}\n\t\t\t\t\t\t(project_id, version_id, title, description, diskfile, filename, folder, filesize, file_type, date_added, content)\n\t\t\t\t\t  VALUES\n\t\t\t\t\t\t({$c_project_id}, {$c_version_id}, '{$c_title}', '{$c_desc}', '{$c_disk_file_name}', '{$c_new_file_name}', '{$c_file_path}', {$c_file_size}, '{$c_file_type}', '" . date("Y-m-d H:i:s") . "', '{$c_content}')";
    db_query($query);
    $t_file_id = db_insert_id();
    return $t_file_id;
}
 public function import_full($p_repo)
 {
     echo '<pre>';
     $t_branch = $p_repo->info['master_branch'];
     if (is_blank($t_branch)) {
         $t_branch = 'master';
     }
     # if we're not allowed everything, populate an array of what we are allowed
     if ($t_branch != '*') {
         $t_branches_allowed = array_map('trim', explode(',', $t_branch));
     }
     # Always pull back full list of repos
     $t_repoid = $p_repo->info['hub_repoid'];
     $t_uri = $this->api_uri($p_repo, "projects/{$t_repoid}/repository/branches");
     $t_member = null;
     $t_json = json_url($t_uri, $t_member);
     $t_branches = array();
     foreach ($t_json as $t_branch) {
         if (empty($t_branches_allowed) || in_array($t_branch->name, $t_branches_allowed)) {
             $t_branches[] = $t_branch;
         }
     }
     $t_changesets = array();
     $t_changeset_table = plugin_table('changeset', 'Source');
     foreach ($t_branches as $t_branch) {
         $t_query = "SELECT parent FROM {$t_changeset_table}\n\t\t\t\tWHERE repo_id=" . db_param() . ' AND branch=' . db_param() . ' ORDER BY timestamp ASC';
         $t_result = db_query_bound($t_query, array($p_repo->id, $t_branch->name), 1);
         $t_commits = array($t_branch->commit->id);
         if (db_num_rows($t_result) > 0) {
             $t_parent = db_result($t_result);
             echo "Oldest '{$t_branch->name}' branch parent: '{$t_parent}'\n";
             if (!empty($t_parent)) {
                 $t_commits[] = $t_parent;
                 echo "Parents not empty";
             }
             echo "Parents  empty";
         }
         $t_changesets = array_merge($t_changesets, $this->import_commits($p_repo, $t_commits, $t_branch->name));
     }
     echo '</pre>';
     return $t_changesets;
 }
Esempio n. 23
0
       http://www.apache.org/licenses/LICENSE-2.0

   Unless required by applicable law or agreed to in writing, software
   distributed under the License is distributed on an "AS IS" BASIS,
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   See the License for the specific language governing permissions and
   limitations under the License.

   Notes: Based on the Time Tracking plugin by Elmar:
   2005 by Elmar Schumacher - GAMBIT Consulting GmbH
   http://www.mantisbt.org/forums/viewtopic.php?f=4&t=589	
*/
form_security_validate('plugin_TimeTracking_delete_record');
$f_bug_id = gpc_get_int('bug_id');
$f_delete_id = gpc_get_int('delete_id');
$table = plugin_table('data', 'TimeTracking');
$query_pull_timerecords = "SELECT * FROM {$table} WHERE id = {$f_delete_id} ORDER BY timestamp DESC";
$result_pull_timerecords = db_query($query_pull_timerecords);
$row = db_fetch_array($result_pull_timerecords);
$t_user_id = auth_get_current_user_id();
if ($row[user] == $t_user_id) {
    access_ensure_bug_level(plugin_config_get('admin_own_threshold'), $f_bug_id);
} else {
    access_ensure_bug_level(plugin_config_get('admin_threshold'), $f_bug_id);
}
$query_delete = "DELETE FROM {$table} WHERE id = {$f_delete_id}";
db_query($query_delete);
history_log_event_direct($f_bug_id, plugin_lang_get('history') . " " . plugin_lang_get('deleted'), date(config_get("short_date_format"), strtotime($row["expenditure_date"])) . ": " . number_format($row["hours"], 2, ',', '.') . " h.", "deleted", $user);
form_security_purge('plugin_TimeTracking_delete_record');
$t_url = string_get_bug_view_url($f_bug_id, auth_get_current_user_id());
print_successful_redirect($t_url . "#timerecord");
Esempio n. 24
0
    private function add_msg_id($p_bug_id, $p_msg_id)
    {
        if ($this->_mail_use_message_id) {
            if (!is_blank($p_msg_id)) {
                // Check whether the msg_id is already in the database table
                $t_bug_id = $this->get_bug_id_from_references($p_msg_id);
                if ($t_bug_id === FALSE) {
                    // Add the Messag-ID to the table for future reference
                    $query = 'INSERT
						INTO ' . plugin_table('msgids') . '
						( issue_id, msg_id )
						VALUES
						( ' . db_param() . ', ' . db_param() . ')';
                    db_query_bound($query, array($p_bug_id, $p_msg_id));
                }
            }
        }
    }
?>
		<input type="hidden" name="user_id" value="<?php 
echo gpc_get_string('user_id', '');
?>
"/>
	</td>
</tr>
<tr class="row-1">
	<td class="category" width="30%"><?php 
echo plugin_lang_get('projects');
?>
</td>
	<td>
<?php 
$proj_table_mantis = db_get_table('mantis_project_table');
$proj_table_plug = plugin_table('user_proj', 'JabberNotifierSystem');
$user_id = gpc_get_string('user_id', '');
$query_proj = "SELECT proj_id FROM {$proj_table_plug} WHERE user_id = {$user_id};";
$res = db_query($query_proj);
while ($row = db_fetch_array($res)) {
    $proj_str = $row['proj_id'];
}
$query = "SELECT id, name FROM {$proj_table_mantis} WHERE id not in ({$proj_str}) order by name;";
$res = db_query($query);
$arr = explode(',', $proj_str);
if (db_num_rows($res) != 0) {
    echo '<select name="project_id[]" multiple="multiple" size="8">';
    while ($row = db_fetch_array($res)) {
        echo '<option value="' . $row['id'] . '">' . $row['name'] . '</option>';
    }
    echo '</select>';
 static function buildFilterArrayForInvoice($invoice)
 {
     $bug_table = db_get_table('mantis_bug_table');
     $data_table = plugin_table('bug_data');
     return array('join' => "LEFT JOIN {$data_table} dtd ON {$bug_table}.id = dtd.bug_id", 'where' => "dtd.invoice = '{$invoice}'");
 }
Esempio n. 27
0
 function schema()
 {
     return array(array('CreateTableSQL', array(plugin_table('results'), "\n        id\t\t\t\tI\t\tNOTNULL UNSIGNED ZEROFILL AUTOINCREMENT PRIMARY,\n        log_type\t\tI\t\tNOTNULL UNSIGNED ZEROFILL ,\n        project_id\t\tI\t\tNOTNULL UNSIGNED ZEROFILL ,\n        poster_id\t\tI\t\tNOTNULL UNSIGNED ZEROFILL ,\n        log_begin\t\tT\t\tNOTNULL,\n        log_end\t\tT\t\tNOTNULL,\n        date_posted\t\tT\t\tNOTNULL,\n        last_modified\tT\t\tNOTNULL,\n        ref_issue_ids\t\tC(150)\tDEFAULT \" '' \",\n        ref_log_ids\t\tC(150)\tDEFAULT \" '' \",\n        subject\t\tC(50)\tDEFAULT \" '' \",\n        content\t\tXL\tDEFAULT \" '' \",\n        view_access\t\tI\t\tNOTNULL UNSIGNED ZEROFILL DEFAULT \" '10' \"\n        visits_count\t\tI\t\tNOTNULL UNSIGNED ZEROFILL DEFAULT \" '0' \"\n        good_count\t\tI\t\tNOTNULL UNSIGNED ZEROFILL DEFAULT \" '0' \"\n        bad_count\t\tI\t\tNOTNULL UNSIGNED ZEROFILL DEFAULT \" '0' \"\n        ")));
 }
 public function import_full($p_repo, $p_use_cache = true)
 {
     echo '<pre>';
     $t_branch = $p_repo->info['master_branch'];
     if (is_blank($t_branch)) {
         $t_branch = 'master';
     }
     if ($t_branch != '*') {
         $t_branches = array_map('trim', explode(',', $t_branch));
     } else {
         $t_username = $p_repo->info['bit_username'];
         $t_reponame = $p_repo->info['bit_reponame'];
         $t_uri = $this->api_url10("repositories/{$t_username}/{$t_reponame}/branches");
         $t_json = $this->api_json_url($p_repo, $t_uri);
         $t_branches = array();
         foreach ($t_json as $t_branchname => $t_branch) {
             if (isset($t_branchname)) {
                 if (strpos($t_branchname, '/') !== FALSE) {
                     $t_branches[] = $t_branch->raw_node;
                 } else {
                     $t_branches[] = $t_branchname;
                 }
             }
         }
         $t_branches = array_unique($t_branches);
     }
     $t_changesets = array();
     $t_changeset_table = plugin_table('changeset', 'Source');
     foreach ($t_branches as $t_branch) {
         $t_query = "SELECT parent FROM {$t_changeset_table}\n\t\t\t\tWHERE repo_id=" . db_param() . ' AND branch=' . db_param() . ' ORDER BY timestamp ASC';
         $t_result = db_query_bound($t_query, array($p_repo->id, $t_branch), 1);
         $t_commits = array($t_branch);
         if (db_num_rows($t_result) > 0) {
             $t_parent = db_result($t_result);
             echo "Oldest '{$t_branch}' branch parent: '{$t_parent}'\n";
             if (!empty($t_parent)) {
                 $t_commits[] = $t_parent;
             }
         }
         if ($p_use_cache) {
             foreach ($t_commits as $t_commit_id) {
                 $this->load_all_commits($p_repo, $t_commit_id);
             }
         }
         $t_changesets = array_merge($t_changesets, $this->import_commits($p_repo, $t_commits, $t_branch));
     }
     echo '</pre>';
     return $t_changesets;
 }
Esempio n. 29
0
 /**
  * Persist a user object to the database.  If the user object contains a blank
  * username, then delete any existing data from the database to minimize storage.
  */
 function save()
 {
     $t_user_table = plugin_table('user', 'Source');
     # handle new objects
     if ($this->new) {
         if (is_blank($this->username)) {
             # do nothing
             return;
         } else {
             # insert new entry
             $t_query = "INSERT INTO {$t_user_table} ( user_id, username ) VALUES (" . db_param() . ', ' . db_param() . ')';
             db_query_bound($t_query, array($this->user_id, $this->username));
             $this->new = false;
         }
         # handle loaded objects
     } else {
         if (is_blank($this->username)) {
             # delete existing entry
             $t_query = "DELETE FROM {$t_user_table} WHERE user_id=" . db_param();
             db_query_bound($t_query, array($this->user_id));
         } else {
             # update existing entry
             $t_query = "UPDATE {$t_user_table} SET username=" . db_param() . ' WHERE user_id=' . db_param();
             db_query_bound($t_query, array($this->username, $this->user_id));
         }
     }
 }
Esempio n. 30
0
 public function import_full($p_repo)
 {
     echo '<pre>';
     $t_branch = $p_repo->info['master_branch'];
     if (is_blank($t_branch)) {
         $t_branch = 'master';
     }
     $t_branches = array_map('trim', explode(',', $t_branch));
     $t_changesets = array();
     $t_changeset_table = plugin_table('changeset', 'Source');
     foreach ($t_branches as $t_branch) {
         $t_query = "SELECT parent FROM {$t_changeset_table}\n\t\t\t\tWHERE repo_id=" . db_param() . ' AND branch=' . db_param() . 'ORDER BY timestamp ASC';
         $t_result = db_query_bound($t_query, array($p_repo->id, $t_branch), 1);
         $t_commits = array($t_branch);
         if (db_num_rows($t_result) > 0) {
             $t_parent = db_result($t_result);
             echo "Oldest '{$t_branch}' branch parent: '{$t_parent}'\n";
             if (!empty($t_parent)) {
                 $t_commits[] = $t_parent;
             }
         }
         $t_changesets = array_merge($t_changesets, $this->import_commits($p_repo, $this->uri_base($p_repo), $t_commits, $t_branch));
     }
     echo '</pre>';
     return $t_changesets;
 }