Beispiel #1
0
function new_utils_get_new_releases($start_time, &$select, &$from, &$where)
{
    $frsrf = new FRSReleaseFactory();
    $select = "SELECT groups.group_name AS group_name, " . "groups.group_id AS group_id, " . "groups.unix_group_name AS unix_group_name, " . "frs_release.release_id AS release_id, " . "frs_release.name AS release_version, " . "frs_release.release_date AS release_date, " . "frs_package.package_id AS package_id ";
    $from = "FROM groups,frs_package,frs_release ";
    $where = "WHERE frs_release.release_date > " . db_ei($start_time) . " " . "AND frs_release.package_id = frs_package.package_id " . "AND frs_package.group_id = groups.group_id " . "AND frs_release.status_id=" . $frsrf->STATUS_ACTIVE . " " . "AND groups.is_public=1 ";
}
Beispiel #2
0
function session_require($req)
{
    global $Language;
    /*
    	Codendi admins always return true
    */
    if (user_is_super_user()) {
        return true;
    }
    if (isset($req['group']) && $req['group']) {
        $query = "SELECT user_id FROM user_group WHERE user_id=" . user_getid() . " AND group_id=" . db_ei($req['group']);
        if (isset($req['admin_flags']) && $req['admin_flags']) {
            $query .= " AND admin_flags = '" . db_escape_string($req['admin_flags']) . "'";
        }
        if (db_numrows(db_query($query)) < 1 || !$req['group']) {
            exit_error($Language->getText('include_session', 'insufficient_g_access'), $Language->getText('include_session', 'no_perm_to_view'));
        }
    } elseif (isset($req['user']) && $req['user']) {
        if (user_getid() != $req['user']) {
            exit_error($Language->getText('include_session', 'insufficient_u_access'), $Language->getText('include_session', 'no_perm_to_view'));
        }
    } elseif (isset($req['isloggedin']) && $req['isloggedin']) {
        if (!user_isloggedin()) {
            exit_error($Language->getText('include_session', 'required_login'), $Language->getText('include_session', 'login'));
        }
    } else {
        exit_error($Language->getText('include_session', 'insufficient_access'), $Language->getText('include_session', 'no_access'));
    }
}
Beispiel #3
0
/**
* Copyright (c) Xerox Corporation, Codendi Team, 2001-2009. All rights reserved
* 
* 
* 
*/
function service_create_service($arr, $group_id, $template, $force_enable = false)
{
    // Convert link to real values
    // NOTE: if you change link variables here, change them also in src/www/project/admin/servicebar.php and src/www/include/Layout.class.php
    $link = $arr['link'];
    $pm = ProjectManager::instance();
    if ($template['system']) {
        $link = str_replace('$projectname', $pm->getProject($group_id)->getUnixName(), $link);
        $link = str_replace('$sys_default_domain', $GLOBALS['sys_default_domain'], $link);
        $link = str_replace('$group_id', $group_id, $link);
        if ($GLOBALS['sys_force_ssl']) {
            $sys_default_protocol = 'https';
        } else {
            $sys_default_protocol = 'http';
        }
        $link = str_replace('$sys_default_protocol', $sys_default_protocol, $link);
    } else {
        //for non-system templates
        $link = service_replace_template_name_in_link($link, $template, $pm->getProject($group_id));
    }
    $is_used = isset($template['is_used']) ? $template['is_used'] : $arr['is_used'];
    $server_id = isset($template['server_id']) ? $template['server_id'] : $arr['server_id'];
    $sql = "INSERT INTO service (group_id, label, description, short_name, link, is_active, is_used, scope, rank, location, server_id, is_in_iframe) VALUES (" . db_ei($group_id) . ", '" . db_es($arr['label']) . "', '" . db_es($arr['description']) . "', '" . db_es($arr['short_name']) . "', '" . db_es($link) . "', " . db_ei($arr['is_active']) . ", " . ($force_enable ? 1 : db_ei($is_used)) . ", '" . db_es($arr['scope']) . "', " . db_ei($arr['rank']) . ",  '" . db_es($arr['location']) . "', " . db_ei($server_id) . ", " . db_ei($arr['is_in_iframe']) . ")";
    $result = db_query($sql);
    if ($result) {
        // activate corresponding references
        $reference_manager =& ReferenceManager::instance();
        if ($arr['short_name'] != "") {
            $reference_manager->addSystemReferencesForService($template['id'], $group_id, $arr['short_name']);
        }
        return true;
    } else {
        return false;
    }
}
Beispiel #4
0
function svn_data_get_revision_detail($group_id, $commit_id, $rev_id = 0, $order = '')
{
    $order_str = "";
    if ($order) {
        if ($order != 'filename') {
            // SQLi Warning: no real possibility to escape $order here.
            // We rely on a proper filtering of user input by calling methods.
            $order_str = " ORDER BY " . $order;
        } else {
            $order_str = " ORDER BY dir, file";
        }
    }
    //check user access rights
    $pm = ProjectManager::instance();
    $project = $pm->getProject($group_id);
    $forbidden = svn_utils_get_forbidden_paths(user_getname(), $project->getSVNRootPath());
    $where_forbidden = "";
    if (!empty($forbidden)) {
        while (list($no_access, ) = each($forbidden)) {
            $where_forbidden .= " AND svn_dirs.dir not like '%" . db_es(substr($no_access, 1)) . "%' ";
        }
    }
    // if the subversion revision id is given then it akes precedence on
    // the internal commit_id (this is to make it easy for users to build
    // URL to access a revision
    if ($rev_id) {
        // To be done -> get the commit ID from the svn-commit table
        $sql = "SELECT svn_commits.description, svn_commits.date, svn_commits.revision, svn_checkins.type,svn_checkins.commitid,svn_dirs.dir,svn_files.file " . "FROM svn_dirs, svn_files, svn_checkins, svn_commits " . "WHERE svn_checkins.fileid=svn_files.id " . "AND svn_checkins.dirid=svn_dirs.id " . "AND svn_checkins.commitid=svn_commits.id " . "AND svn_commits.revision=" . db_ei($rev_id) . " " . "AND svn_commits.group_id=" . db_ei($group_id) . " " . $where_forbidden . $order_str;
    } else {
        $sql = "SELECT svn_commits.description, svn_commits.date, svn_commits.revision, svn_checkins.type,svn_checkins.commitid,svn_dirs.dir,svn_files.file " . "FROM svn_dirs, svn_files, svn_checkins, svn_commits " . "WHERE svn_checkins.fileid=svn_files.id " . "AND svn_checkins.dirid=svn_dirs.id " . "AND svn_checkins.commitid=svn_commits.id " . "AND svn_commits.id=" . db_ei($commit_id) . " " . $where_forbidden . $order_str;
    }
    $result = db_query($sql);
    return $result;
}
Beispiel #5
0
function snippet_data_get_license_from_id($license_id)
{
    $license_id = (int) $license_id;
    $sql = "SELECT license_name FROM snippet_license WHERE license_id=" . db_ei($license_id);
    $result = db_query($sql);
    return db_result($result, 0, 0);
}
 public function getContent()
 {
     $request =& HTTPRequest::instance();
     $group_id = $request->get('group_id');
     $pm = ProjectManager::instance();
     $project = $pm->getProject($group_id);
     $res_admin = db_query("SELECT user.user_id AS user_id,user.user_name AS user_name, user.realname as realname " . "FROM user,user_group " . "WHERE user_group.user_id=user.user_id AND user_group.group_id=" . db_ei($group_id) . " AND " . "user_group.admin_flags = 'A'");
     if (db_numrows($res_admin) > 0) {
         $user_helper = UserHelper::instance();
         $hp = Codendi_HTMLPurifier::instance();
         $em = EventManager::instance();
         echo '<span class="develtitle">' . $GLOBALS['Language']->getText('include_project_home', 'proj_admins') . ':</span><br />';
         while ($row_admin = db_fetch_array($res_admin)) {
             $display_name = '';
             $em->processEvent('get_user_display_name', array('user_id' => $row_admin['user_id'], 'user_name' => $row_admin['user_name'], 'realname' => $row_admin['realname'], 'user_display_name' => &$display_name));
             if (!$display_name) {
                 $display_name = $hp->purify($user_helper->getDisplayNameFromUserId($row_admin['user_id']));
             }
             echo '<a href="/users/' . $row_admin['user_name'] . '/">' . $display_name . '</a><br />';
         }
     }
     echo '<span class="develtitle">' . $GLOBALS['Language']->getText('include_project_home', 'proj_members') . ':</span><br />';
     // count of developers on this project
     $res_count = db_query("SELECT user_id FROM user_group WHERE group_id=" . db_ei($group_id));
     echo db_numrows($res_count);
     echo ' <a href="/project/memberlist.php?group_id=' . $group_id . '">[' . $GLOBALS['Language']->getText('include_project_home', 'view_members') . ']</a>';
 }
Beispiel #7
0
function forum_show_nested_messages($thread_id, $msg_id)
{
    global $total_rows, $Language;
    $sql = "SELECT user.user_name,forum.has_followups,user.realname,user.user_id,forum.msg_id,forum.group_forum_id,forum.subject,forum.thread_id,forum.body,forum.date,forum.is_followup_to, forum_group_list.group_id " . "FROM forum,user,forum_group_list WHERE forum.thread_id=" . db_ei($thread_id) . " AND user.user_id=forum.posted_by AND forum.is_followup_to=" . db_ei($msg_id) . " AND forum_group_list.group_forum_id = forum.group_forum_id " . "ORDER BY forum.date ASC;";
    $result = db_query($sql);
    $rows = db_numrows($result);
    $ret_val = '';
    if ($result && $rows > 0) {
        $ret_val .= '
			<UL>';
        /*
        	iterate and show the messages in this result
        	for each message, recurse to show any submessages
        */
        for ($i = 0; $i < $rows; $i++) {
            //	increment the global total count
            $total_rows++;
            //	show the actual nested message
            $ret_val .= forum_show_a_nested_message($result, $i) . '<P>';
            if (db_result($result, $i, 'has_followups') > 0) {
                //	Call yourself if there are followups
                $ret_val .= forum_show_nested_messages($thread_id, db_result($result, $i, 'msg_id'));
            }
        }
        $ret_val .= '
			</UL>';
    }
    return $ret_val;
}
 public function searchNotification($tracker_id, $user_id)
 {
     $tracker_id = $this->da->escapeInt($tracker_id);
     $user_id = $this->da->escapeInt($user_id);
     $sql = "SELECT role_label,event_label,notify \n                FROM {$this->table_name}" . "_role AS r, {$this->table_name}" . "_event AS e, {$this->table_name} AS n \n                WHERE n.tracker_id=" . db_ei($tracker_id) . " \n                  AND n.user_id=" . db_ei($user_id) . " \n                  AND n.role_id=r.role_id \n                  AND r.tracker_id=" . db_ei($tracker_id) . " \n                  AND n.event_id=e.event_id \n                  AND e.tracker_id=" . db_ei($tracker_id);
     return $this->retrieve($sql);
 }
Beispiel #9
0
function printnode($nodeid, $text, $depth = 0, $delete_ok = false)
{
    global $Language;
    $purifier = Codendi_HTMLPurifier::instance();
    // print current node, then all subnodes
    print '<BR>';
    for ($i = 0; $i < $depth; $i++) {
        print "&nbsp; &nbsp; ";
    }
    html_image('ic/cfolder15.png', array());
    print '&nbsp; ' . $purifier->purify($text) . " ";
    if ($nodeid != 0) {
        print '&nbsp; <A href="trove_cat_edit.php?trove_cat_id=' . $nodeid . '">[' . $Language->getText('admin_trove_cat_list', 'edit') . ']</A> ';
    }
    if ($delete_ok) {
        print '&nbsp; <A href="trove_cat_delete.php?trove_cat_id=' . $nodeid . '">[' . $Language->getText('admin_trove_cat_list', 'delete') . ']</A> ';
    }
    if ($nodeid != 0) {
        print '&nbsp;' . help_button('trove_cat', $nodeid) . "\n";
    }
    $res_child = db_query("SELECT trove_cat_id,fullname,parent FROM trove_cat " . "WHERE parent='" . db_ei($nodeid) . "' ORDER BY fullpath");
    while ($row_child = db_fetch_array($res_child)) {
        $delete_ok = $row_child["parent"] != 0;
        printnode($row_child["trove_cat_id"], $row_child["fullname"], $depth + 1, $delete_ok);
    }
}
 /**
  * Fill the arrays $this->source_refs_datas and $this->target_refs_datas
  * for the current CrossReferenceFactory  
  */
 function fetchDatas()
 {
     $sql = "SELECT * \n                FROM cross_references \n                WHERE  (target_gid=" . db_ei($this->entity_gid) . " AND target_id='" . db_ei($this->entity_id) . "' AND target_type='" . db_es($this->entity_type) . "' )\n                     OR (source_gid=" . db_ei($this->entity_gid) . " AND source_id='" . db_ei($this->entity_id) . "' AND source_type='" . db_es($this->entity_type) . "' )";
     $res = db_query($sql);
     if ($res && db_numrows($res) > 0) {
         $this->source_refs_datas = array();
         $this->target_refs_datas = array();
         while ($field_array = db_fetch_array($res)) {
             $target_id = $field_array['target_id'];
             $target_gid = $field_array['target_gid'];
             $target_type = $field_array['target_type'];
             $target_key = $field_array['target_keyword'];
             $source_id = $field_array['source_id'];
             $source_gid = $field_array['source_gid'];
             $source_type = $field_array['source_type'];
             $source_key = $field_array['source_keyword'];
             $user_id = $field_array['user_id'];
             $created_at = $field_array['created_at'];
             if ($target_id == $this->entity_id && $target_gid == $this->entity_gid && $target_type == $this->entity_type) {
                 $this->source_refs_datas[] = new CrossReference($source_id, $source_gid, $source_type, $source_key, $target_id, $target_gid, $target_type, $target_key, $user_id);
             }
             if ($source_id == $this->entity_id && $source_gid == $this->entity_gid && $source_type == $this->entity_type) {
                 $this->target_refs_datas[] = new CrossReference($source_id, $source_gid, $source_type, $source_key, $target_id, $target_gid, $target_type, $target_key, $user_id);
             }
         }
     }
 }
 function Widget_MySurveys()
 {
     $this->Widget('mysurveys');
     $no_survey = true;
     // Get id and title of the survey that will be promoted to user page. default = survey whose id=1
     if ($GLOBALS['sys_my_page_survey']) {
         $developer_survey_id = $GLOBALS['sys_my_page_survey'];
     } else {
         $developer_survey_id = "1";
     }
     $survey = SurveySingleton::instance();
     $sql = "SELECT * from surveys WHERE survey_id=" . db_ei($developer_survey_id);
     $result = db_query($sql);
     $group_id = db_result($result, 0, 'group_id');
     $purifier = Codendi_HTMLPurifier::instance();
     $survey_title = $purifier->purify($survey->getSurveyTitle(db_result($result, 0, 'survey_title')));
     // Check that the survey is active
     $devsurvey_is_active = db_result($result, 0, 'is_active');
     if ($devsurvey_is_active == 1) {
         $sql = "SELECT * FROM survey_responses " . "WHERE survey_id='" . db_ei($developer_survey_id) . "' AND user_id='" . db_ei(user_getid()) . "'";
         $result = db_query($sql);
         if (db_numrows($result) < 1) {
             $no_survey = false;
             $this->content .= '<a href="/survey/survey.php?group_id=' . $group_id . '&survey_id=' . $developer_survey_id . '">' . $survey_title . '</a>';
         }
     }
     if ($no_survey) {
         $this->content .= $GLOBALS['Language']->getText('my_index', 'no_survey');
     }
 }
 /**
  * Delete artifact from artifact_date_reminder_processing table
  * 
  *  @param field_id: the field id
  *  @param artifact_id: the artifact id
  *  @param group_artifact_id: the tracker id
  * 
  * @return nothing
  */
 function deleteArtifactFromDateReminderProcessing($field_id, $artifact_id, $group_artifact_id)
 {
     if ($field_id == 0) {
         $del = sprintf('DELETE FROM artifact_date_reminder_processing' . ' WHERE artifact_id=%d' . ' AND group_artifact_id=%d', db_ei($artifact_id), db_ei($group_artifact_id));
     } else {
         $del = sprintf('DELETE FROM artifact_date_reminder_processing' . ' WHERE artifact_id=%d' . ' AND field_id=%d' . ' AND group_artifact_id=%d', db_ei($artifact_id), db_ei($field_id), db_ei($group_artifact_id));
     }
     $result = db_query($del);
 }
Beispiel #13
0
function listallchilds($nodeid, &$list)
{
    // list current node and then all subnodes
    $res_child = db_query("SELECT trove_cat_id, parent, shortname FROM trove_cat " . "WHERE parent='" . db_ei($nodeid) . "'");
    while ($row_child = db_fetch_array($res_child)) {
        $list[] = $row_child['trove_cat_id'];
        listallchilds($row_child['trove_cat_id'], $list);
    }
}
 function cacheFieldsWithNotification($group_artifact_id)
 {
     $sql = 'SELECT field_id' . ' FROM artifact_date_reminder_settings' . ' WHERE group_artifact_id = ' . db_ei($group_artifact_id);
     $res = db_query($sql);
     if ($res && !db_error($res)) {
         while ($row = db_fetch_array($res)) {
             $this->fieldsWithNotification[$row['field_id']] = true;
         }
     }
 }
Beispiel #15
0
 /**
  * Record when user log on Codendi
  *
  * @param Integer $userId Id of the user
  * @param Integer $date   Date of login (timestamp)
  * 
  * @return Boolean
  */
 function setLoginDate($userId, $date)
 {
     $sql = 'UPDATE plugin_ldap_user' . ' SET login_confirmation_date = ' . db_ei($date) . ' WHERE user_id = ' . db_ei($userId);
     $updated = $this->update($sql);
     if (!$updated) {
         // Try to insert
         $updated = $this->createLdapUser($userId, $date);
     }
     return $updated;
 }
 function getProjectAdmins($groupId)
 {
     $admins = array();
     $um = UserManager::instance();
     $sql = 'SELECT u.user_id FROM user u JOIN user_group ug USING(user_id) WHERE ug.admin_flags="A" AND u.status IN ("A", "R") AND ug.group_id = ' . db_ei($groupId);
     $res = db_query($sql);
     while ($row = db_fetch_array($res)) {
         $admins[] = $um->getUserById($row['user_id']);
     }
     return $admins;
 }
 /**
  * Search all the links that point to $groupId project
  * 
  * @param  Integer $groupId Group id
  * @return DataAccessResult
  */
 function searchBackLinks($groupId)
 {
     $sql = 'SELECT reverse_name AS link_name, type, groups.group_id,
               group_name, unix_group_name, uri_plus, link_id, creation_date,
               master_group_id, target_group_id,  link_type.link_type_id
             FROM plugin_projectlinks_relationship AS rel
               INNER JOIN plugin_projectlinks_link_type AS link_type 
                 USING (link_type_id)
               INNER JOIN groups
                 ON (groups.group_id = rel.master_group_id)
             WHERE target_group_id = ' . db_ei($groupId) . '
               AND status = "A"
         ORDER BY name, type, group_name';
     return $this->retrieve($sql);
 }
 protected function updateSpecificProperties($row)
 {
     $db_update_needed = false;
     foreach (array('field_base') as $prop) {
         if (isset($row[$prop]) && $this->{$prop} != $row[$prop]) {
             $this->{$prop} = $row[$prop];
             $db_update_needed = true;
         }
     }
     if ($db_update_needed) {
         $sql = sprintf("UPDATE plugin_graphontrackers_pie_chart SET\n                       field_base = '%s'\n                       WHERE id = %d", db_es($this->field_base), db_ei($this->id));
         $res = db_query($sql);
         return db_affected_rows($res);
     }
     return false;
 }
Beispiel #19
0
function send_new_project_email($group_id)
{
    global $Language;
    $res_grp = db_query("SELECT * FROM groups WHERE group_id='" . db_ei($group_id) . "'");
    if (db_numrows($res_grp) < 1) {
        echo $Language->getText('include_proj_email', 'g_not_exist', $group_id);
    }
    $row_grp = db_fetch_array($res_grp);
    $res_admins = db_query("SELECT user.user_name,user.email FROM user,user_group WHERE " . "user.user_id=user_group.user_id AND user_group.group_id='" . db_ei($group_id) . "' AND " . "user_group.admin_flags='A'");
    $nb_recipients = db_numrows($res_admins);
    if ($nb_recipients < 1) {
        echo $Language->getText('include_proj_email', 'no_admin', $group_id);
    }
    // send one email per admin
    $nb_mail_failed = 0;
    $pm = ProjectManager::instance();
    while ($row_admins = db_fetch_array($res_admins)) {
        $server = get_server_url();
        $p = $pm->getProject($group_id);
        $host = $GLOBALS['sys_default_domain'];
        if ($p && $p->usesService('svn')) {
            $sf = new ServerFactory();
            if ($s =& $sf->getServerById($p->services['svn']->getServerId())) {
                $host = URL::getHost($s->getUrl(session_issecure()));
            }
        }
        if ($GLOBALS['sys_force_ssl']) {
            $svn_url = 'https://' . $host;
        } else {
            $svn_url = 'http://svn.' . $row_grp['unix_group_name'] . '.' . $host;
        }
        $svn_url .= '/svnroot/' . $row_grp['unix_group_name'];
        // $message is defined in the content file
        include $Language->getContent('include/new_project_email');
        // LJ Uncomment to test
        //echo $message; return
        $mail = new Mail();
        $mail->setTo($row_admins['email']);
        $mail->setSubject($GLOBALS['sys_name'] . ' ' . $Language->getText('include_proj_email', 'proj_approve', $row_grp['unix_group_name']));
        $mail->setBody($message);
        $mail->setFrom($GLOBALS['sys_email_admin']);
        if (!$mail->send()) {
            $nb_mail_failed++;
        }
    }
    return $nb_mail_failed < $nb_recipients;
}
 function getAllProject($offset, $limit, $condition, $pattern)
 {
     $projects = array();
     if (count($condition) > 0) {
         $statements = '(';
         $i = 0;
         $nbConditions = count($condition) - 1;
         for ($i; $i < $nbConditions; $i++) {
             $statements .= db_es($condition[$i]) . ' LIKE "%' . db_es($pattern) . '%" OR ';
         }
         $statements .= db_es($condition[$i]) . ' LIKE "%' . db_es($pattern) . '%") AND ';
     }
     $sql = 'SELECT SQL_CALC_FOUND_ROWS group_name, group_id, unix_group_name, is_public FROM groups WHERE ' . $statements . ' status = "A" ORDER BY register_time DESC LIMIT ' . db_ei($offset) . ', ' . db_ei($limit);
     $res = db_query($sql);
     $sql = 'SELECT FOUND_ROWS() as nb';
     $res_numrows = db_query($sql);
     $row = db_fetch_array($res_numrows);
     return array('projects' => $res, 'numrows' => $row['nb']);
 }
Beispiel #21
0
function register_valid($user_id)
{
    $request =& HTTPRequest::instance();
    if (!$request->isPost() || !$request->exist('Update')) {
        return 0;
    }
    // check against old pw
    $res = db_query("SELECT user_pw, status FROM user WHERE status IN ('A', 'R') AND user_id=" . db_ei($user_id));
    if (!$res || db_numrows($res) != 1) {
        $GLOBALS['Response']->addFeedback('error', "Internal error: Cannot locate user in database.");
        return 0;
    }
    $row_pw = db_fetch_array();
    if ($row_pw['user_pw'] != md5($request->get('form_oldpw'))) {
        $GLOBALS['Response']->addFeedback('error', "Old password is incorrect.");
        return 0;
    }
    if ($row_pw['status'] != 'A' && $row_pw['status'] != 'R') {
        $GLOBALS['Response']->addFeedback('error', "Account must be active to change password.");
        return 0;
    }
    if (!$request->exist('form_pw')) {
        $GLOBALS['Response']->addFeedback('error', "You must supply a password.");
        return 0;
    }
    if ($request->get('form_pw') != $request->get('form_pw2')) {
        $GLOBALS['Response']->addFeedback('error', "Passwords do not match.");
        return 0;
    }
    if (!account_pwvalid($request->get('form_pw'), $errors)) {
        foreach ($errors as $e) {
            $GLOBALS['Response']->addFeedback('error', $e);
        }
        return 0;
    }
    // if we got this far, it must be good
    if (!account_set_password($user_id, $request->get('form_pw'))) {
        $GLOBALS['Response']->addFeedback('error', "Internal error: Could not update password.");
        return 0;
    }
    return 1;
}
 /**
  *  updateDateFieldReminderSettings - use this to update the date-fields reminder settings in the database.
  *
  *  @param  $field_id   The date field concerned by the notification.
  *  @param  $group_artifact_id  The tracker id
  *  @param  $start  When will the notification start taking effect, with regards to date occurence (in days)
  *  @param  $type   What is the type of the notification (after date occurence, before date occurence)
  *  @param  $frequency  At which frequency (in days) the notification wil occur
  *  @param  $recurse    How many times the notification mail will be sent
  *  @param  $submitter  Is submitter notified ?
  *  @param  $assignee   Is assignee notified ?
  *  @param  $cc Is cc notified ?
  *  @param  $commenter  Is commetner notified ?
  *
  *  @return true on success, false on failure.
  */
 function updateDateFieldReminderSettings(ArtifactType $at, ArtifactField $field, $group_artifact_id, $start, $notif_type, $frequency, $recurse, $people_notified)
 {
     $res = $this->getDateFieldReminderSettings($field->getID(), $group_artifact_id);
     if ($res && !db_error($res)) {
         $notified_users = implode(",", $people_notified);
         if (db_numrows($res) == 0) {
             // No reminder, create it
             $insert = 'INSERT INTO artifact_date_reminder_settings' . '(field_id, group_artifact_id, notification_start, notification_type, frequency, recurse, notified_people)' . ' VALUES' . ' (' . db_ei($field->getId()) . ',' . db_ei($group_artifact_id) . ',' . db_ei($start) . ',' . db_ei($notif_type) . ',' . db_ei($frequency) . ',' . db_ei($recurse) . ',"' . db_es($notified_users) . '")';
             $inserted = db_query($insert);
             if ($inserted) {
                 $this->populateProcessingForField($at, $field->getId(), $group_artifact_id);
                 return true;
             }
             return false;
         } else {
             //update reminder settings
             $update = sprintf('UPDATE artifact_date_reminder_settings' . ' SET notification_start=%d' . ' , notification_type=%d' . ' , frequency=%d' . ' , recurse=%d' . ' , notified_people="%s"' . ' WHERE group_artifact_id=%d' . ' AND field_id=%d', db_ei($start), db_ei($notif_type), db_ei($frequency), db_ei($recurse), db_es($notified_users), db_ei($group_artifact_id), db_ei($field->getId()));
             $result = db_query($update);
             return $result;
         }
     } else {
         return false;
     }
 }
 /**
  * TODO : adapt it to the new tracker structure when ready
  */
 function getArtifactKeyword($artifact_id, $group_id)
 {
     $sql = "SELECT group_artifact_id FROM artifact WHERE artifact_id= " . db_ei($artifact_id);
     $result = db_query($sql);
     if (db_numrows($result) > 0) {
         $row = db_fetch_array($result);
         $tracker_id = $row['group_artifact_id'];
         $project = new Project($group_id);
         $tracker = new ArtifactType($project, $tracker_id);
         $tracker_short_name = $tracker->getItemName();
         $reference_dao =& $this->_getReferenceDao();
         $dar = $reference_dao->searchByKeywordAndGroupId($tracker_short_name, $group_id);
         if ($dar && $dar->rowCount() >= 1) {
             return $tracker_short_name;
         } else {
             return null;
         }
     } else {
         return null;
     }
 }
Beispiel #24
0
 /**
  *	fetchData - re-fetch the data for this ArtifactFile from the database.
  *
  *	@param	int	The file_id.
  *	@return	boolean	success.
  */
 function fetchData($id)
 {
     global $Language;
     $sql = "SELECT af.id, af.artifact_id, af.description, af.bin_data, af.filename, af.filesize, af.filetype, af.adddate, af.submitted_by, user.user_name, user.realname \n                FROM artifact_file af, user \n                WHERE (af.submitted_by = user.user_id) and af.id=" . db_ei($id);
     //echo $sql;
     $res = db_query($sql);
     if (!$res || db_numrows($res) < 1) {
         $this->setError('ArtifactFile: ' . $Language->getText('tracker_common_file', 'invalid_id'));
         return false;
     }
     $this->data_array = db_fetch_array($res);
     db_free_result($res);
     return true;
 }
Beispiel #25
0
function stats_site_projects($span = 7, $orderby = "ranking", $offset = 0, $projects = 0, $trove_cat = 0)
{
    global $Language;
    $sql = "SELECT s.month AS month, s.week AS week, s.day AS day, s.group_id AS group_id, " . "g.group_name AS group_name, m.ranking AS ranking, m.percentile AS percentile, SUM(s.downloads) AS downloads, " . "SUM(s.site_views) AS site_views, SUM(s.subdomain_views) AS subdomain_views, " . "SUM(s.msg_posted) AS msg_posted, SUM(s.bugs_opened) AS bugs_opened, " . "SUM(s.bugs_closed) AS bugs_closed, SUM(s.support_opened) AS support_opened, " . "SUM(s.support_closed) AS support_closed, SUM(s.patches_opened) AS patches_opened, " . "SUM(s.patches_closed) AS patches_closed, SUM(s.tasks_opened) AS tasks_opened, " . "SUM(s.tasks_closed) AS tasks_closed, SUM(s.cvs_checkouts) AS cvs_checkouts, " . "SUM(s.cvs_commits) AS cvs_commits, SUM(s.cvs_adds) AS cvs_adds, " . "SUM(s.svn_access_count) AS svn_access_count " . "FROM stats_project AS s,groups AS g,project_metric AS m ";
    // Get information about the date $span days ago
    $begin_date = localtime(time() - $span * 86400, 1);
    $year = $begin_date["tm_year"] + 1900;
    $month = sprintf("%02d", $begin_date["tm_mon"] + 1);
    $day = $begin_date["tm_mday"];
    $sql .= "WHERE ( ";
    if ($span != "All") {
        $sql .= "( ( month = " . $year . $month . " AND day >= " . $day . " ) OR ( month > " . $year . $month . " ) ) ";
    }
    $sql .= "AND ( s.group_id = g.group_id ) ";
    $sql .= "AND ( s.group_id = m.group_id ) ";
    if (is_array($projects)) {
        $sql .= "AND ( s.group_id IN (" . db_ei_implode($projects) . ") ) ";
    } else {
        $sql .= "AND g.type = 1 ";
    }
    $sql .= " ) ";
    $sql .= "GROUP BY s.group_id ";
    $valid_orderby_value = new Rule_WhiteList(stats_site_projects_orderby_values());
    if (!$valid_orderby_value->isValid($orderby)) {
        $orderby = 'ranking';
    }
    if ($orderby == "ranking") {
        $sql .= "ORDER BY {$orderby} ASC ";
    } else {
        $sql .= "ORDER BY {$orderby} DESC ";
    }
    if ($offset > 0) {
        $sql .= "LIMIT " . db_ei($offset) . ",50";
    } else {
        $sql .= "LIMIT 50";
    }
    // Executions will continue until morale improves.
    $res = db_query($sql);
    // if there are any rows, we have valid data (or close enough).
    if (($valid_days = db_numrows($res)) > 1) {
        $purifier = Codendi_HTMLPurifier::instance();
        print "<P><B>" . $Language->getText('stats_site_stats_utils', 'proj_stats_for') . " ";
        if ($span == $Language->getText('stats_site_stats_utils', 'all')) {
            print $Language->getText('stats_site_stats_utils', 'all_time');
        } else {
            print $Language->getText('stats_site_stats_utils', 'past_x_days', $purifier->purify($span));
        }
        print " " . $Language->getText('stats_site_stats_utils', 'sorted_by', $purifier->purify($orderby));
        if ($trove_cat > 0) {
            print " " . $Language->getText('stats_site_stats_utils', 'within_cat', $purifier->purify(stats_trove_cat_to_name($trove_cat)));
        }
        if (is_array($projects) && $trove_cat <= 0) {
            print "<br> " . $Language->getText('stats_site_stats_utils', 'for_group', $purifier->purify(implode(", ", $projects)));
        }
        print ". </B></P><BR>";
        print '<P><TABLE width="100%" cellpadding=0 cellspacing=0 border=0>';
        print '<TR valign="top" class="boxitem">' . '<TD><B>' . $Language->getText('stats_site_stats_utils', 'proj_name') . '</B></TD>' . '<TD align="right"><B>' . $Language->getText('stats_site_stats_utils', 'ranking') . '</B></TD>' . '<TD align="right" COLSPAN="2"><B>' . $Language->getText('stats_site_stats_utils', 'page_views') . '</B></TD>' . '<TD align="right"><B>' . $Language->getText('stats_site_stats_utils', 'downl') . '</B></TD>' . '<TD align="center" COLSPAN="2"><B>' . $Language->getText('stats_site_stats_utils', 'bugs') . '</B></TD>' . '<TD align="center" COLSPAN="2"><B>' . $Language->getText('stats_site_stats_utils', 'support') . '</B></TD>' . '<TD align="center" COLSPAN="2"><B>' . $Language->getText('stats_site_stats_utils', 'patches') . '</B></TD>' . '<TD align="center" COLSPAN="2"><B>' . $Language->getText('stats_site_stats_utils', 'tasks') . '</B></TD>' . '<TD align="center" COLSPAN="3"><B>' . $Language->getText('stats_site_stats_utils', 'cvs') . '</B></TD>' . '<TD align="center" COLSPAN="3"><B>' . $Language->getText('stats_site_stats_utils', 'svn') . '</B></TD>' . '</TR>' . "\n";
        // Build the query string to resort results.
        $uri_string = "projects.php?span=" . urlencode($span);
        if ($trove_cat > 0) {
            $uri_string .= "&trovecatid=" . urlencode($trove_cat);
        }
        if ($trove_cat == -1) {
            $uri_string .= "&projects=" . urlencode(implode(" ", $projects));
        }
        $uri_string .= "&orderby=";
        print '<TR valign="top" class="boxitem">' . '<TD align="right">&nbsp;</TD>' . '<TD align="right"><A HREF="' . $uri_string . 'ranking">' . $Language->getText('stats_site_stats_utils', 'rank') . '</A></TD>' . '<TD align="right"><A HREF="' . $uri_string . 'site_views">' . $Language->getText('stats_site_stats_utils', 'site') . '</A></TD>' . '<TD align="right"><A HREF="' . $uri_string . 'subdomain_views">' . $Language->getText('stats_site_stats_utils', 'subdomain') . '</TD>' . '<TD align="right"><A HREF="' . $uri_string . 'downloads">' . $Language->getText('stats_site_stats_utils', 'total') . '</TD>' . '<TD align="right"><A HREF="' . $uri_string . 'bugs_opened">' . $Language->getText('stats_site_stats_utils', 'opn') . '</TD>' . '<TD align="right"><A HREF="' . $uri_string . 'bugs_closed">' . $Language->getText('stats_site_stats_utils', 'cls') . '</TD>' . '<TD align="right"><A HREF="' . $uri_string . 'support_opened">' . $Language->getText('stats_site_stats_utils', 'opn') . '</TD>' . '<TD align="right"><A HREF="' . $uri_string . 'support_closed">' . $Language->getText('stats_site_stats_utils', 'cls') . '</TD>' . '<TD align="right"><A HREF="' . $uri_string . 'patches_opened">' . $Language->getText('stats_site_stats_utils', 'opn') . '</TD>' . '<TD align="right"><A HREF="' . $uri_string . 'patches_closed">' . $Language->getText('stats_site_stats_utils', 'cls') . '</TD>' . '<TD align="right"><A HREF="' . $uri_string . 'tasks_opened">' . $Language->getText('stats_site_stats_utils', 'opn') . '</TD>' . '<TD align="right"><A HREF="' . $uri_string . 'tasks_closed">' . $Language->getText('stats_site_stats_utils', 'cls') . '</TD>' . '<TD align="right"><A HREF="' . $uri_string . 'cvs_checkouts">' . $Language->getText('stats_site_stats_utils', 'co') . '</TD>' . '<TD align="right"><A HREF="' . $uri_string . 'cvs_commits">' . $Language->getText('stats_site_stats_utils', 'comms') . '</TD>' . '<TD align="right"><A HREF="' . $uri_string . 'cvs_adds">' . $Language->getText('stats_site_stats_utils', 'adds') . '</TD>' . '<TD align="right"><A HREF="' . $uri_string . 'svn_access_count">' . $Language->getText('stats_site_stats_utils', 'access_cnt') . '</TD>' . '</TR>' . "\n";
        $i = $offset;
        $sum = array();
        while ($row = db_fetch_array($res)) {
            print '<TR class="' . util_get_alt_row_color($i) . '">' . '<TD>' . ($i + 1) . '. <A HREF="/project/stats/?group_id=' . $row["group_id"] . '">' . $row["group_name"] . '</A></TD>' . '<TD align="right">&nbsp;&nbsp;' . number_format($i + 1) . ' (' . $row["percentile"] . '%) </TD>' . '<TD align="right">&nbsp;&nbsp;' . number_format($row["site_views"]) . '</TD>' . '<TD align="right">&nbsp;&nbsp;' . number_format($row["subdomain_views"]) . '</TD>' . '<TD align="right">&nbsp;&nbsp;' . number_format($row["downloads"]) . '</TD>' . '<TD align="right">&nbsp;&nbsp;' . number_format($row["bugs_opened"]) . '</TD>' . '<TD align="right">&nbsp;&nbsp;' . number_format($row["bugs_closed"]) . '</TD>' . '<TD align="right">&nbsp;&nbsp;' . number_format($row["support_opened"]) . '</TD>' . '<TD align="right">&nbsp;&nbsp;' . number_format($row["support_closed"]) . '</TD>' . '<TD align="right">&nbsp;&nbsp;' . number_format($row["patches_opened"]) . '</TD>' . '<TD align="right">&nbsp;&nbsp;' . number_format($row["patches_closed"]) . '</TD>' . '<TD align="right">&nbsp;&nbsp;' . number_format($row["tasks_opened"]) . '</TD>' . '<TD align="right">&nbsp;&nbsp;' . number_format($row["tasks_opened"]) . '</TD>' . '<TD align="right">&nbsp;&nbsp;' . number_format($row["cvs_checkouts"]) . '</TD>' . '<TD align="right">&nbsp;&nbsp;' . number_format($row["cvs_commits"]) . '</TD>' . '<TD align="right">&nbsp;&nbsp;' . number_format($row["cvs_adds"]) . '</TD>' . '<TD align="right">&nbsp;&nbsp;' . number_format($row["svn_access_count"]) . '</TD>' . '</TR>' . "\n";
            $i++;
            $sum = stats_util_sum_array($sum, $row);
        }
        if ($trove_cat == -1) {
            print '<TR><TD COLSPAN="16">&nbsp;</TD></TR>' . "\n";
            print '<TR><TD COLSPAN="16" align="center"></TD></TR>' . "\n";
            print '<TR class="' . util_get_alt_row_color($i) . '">' . '<TD><B>' . $Language->getText('stats_site_stats_utils', 'totals') . '</B></TD>' . '<TD>&nbsp;</TD>' . '<TD align="right">&nbsp;&nbsp;' . number_format($sum["site_views"]) . '</TD>' . '<TD align="right">&nbsp;&nbsp;' . number_format($sum["subdomain_views"]) . '</TD>' . '<TD align="right">&nbsp;&nbsp;' . number_format($sum["downloads"]) . '</TD>' . '<TD align="right">&nbsp;&nbsp;' . number_format($sum["bugs_opened"]) . '</TD>' . '<TD align="right">&nbsp;&nbsp;' . number_format($sum["bugs_closed"]) . '</TD>' . '<TD align="right">&nbsp;&nbsp;' . number_format($sum["support_opened"]) . '</TD>' . '<TD align="right">&nbsp;&nbsp;' . number_format($sum["support_closed"]) . '</TD>' . '<TD align="right">&nbsp;&nbsp;' . number_format($sum["patches_opened"]) . '</TD>' . '<TD align="right">&nbsp;&nbsp;' . number_format($sum["patches_closed"]) . '</TD>' . '<TD align="right">&nbsp;&nbsp;' . number_format($sum["tasks_opened"]) . '</TD>' . '<TD align="right">&nbsp;&nbsp;' . number_format($sum["tasks_opened"]) . '</TD>' . '<TD align="right">&nbsp;&nbsp;' . number_format($sum["cvs_checkouts"]) . '</TD>' . '<TD align="right">&nbsp;&nbsp;' . number_format($sum["cvs_commits"]) . '</TD>' . '<TD align="right">&nbsp;&nbsp;' . number_format($sum["cvs_adds"]) . '</TD>' . '<TD align="right">&nbsp;&nbsp;' . number_format($sum["svn_access_count"]) . '</TD>' . '</TR>' . "\n";
        }
        print '</TABLE>';
    } else {
        echo $Language->getText('stats_site_stats_utils', 'no_valid_data') . "\n";
    }
}
Beispiel #26
0
                        if (!$result || db_affected_rows($result) < 1) {
                            $GLOBALS['Response']->addFeedback('error', $Language->getText('news_admin_index', 'update_err') . ' ' . db_error());
                        } else {
                            $GLOBALS['Response']->addFeedback('info', $Language->getText('news_admin_index', 'newsbyte_deleted'));
                        }
                    }
                }
                $GLOBALS['Response']->redirect('/news/admin');
            }
        }
        news_header(array('title' => $Language->getText('news_admin_index', 'title')));
        if ($request->get('approve')) {
            /*
            	Show the submit form
            */
            $sql = "SELECT groups.unix_group_name,news_bytes.* " . "FROM news_bytes,groups WHERE id=" . db_ei($id) . " " . "AND news_bytes.group_id=groups.group_id ";
            $result = db_query($sql);
            if (db_numrows($result) < 1) {
                exit_error($Language->getText('global', 'error'), $Language->getText('news_admin_index', 'not_found_err'));
            }
            $username = user_getname(db_result($result, 0, 'submitted_by'));
            $news_date = util_timestamp_to_userdateformat(db_result($result, 0, 'date'), true);
            echo '
		<H3>' . $Language->getText('news_admin_index', 'approve') . '</H3>
		<P>
		<FORM ACTION="" METHOD="POST">
		<INPUT TYPE="HIDDEN" NAME="for_group" VALUE="' . db_result($result, 0, 'group_id') . '">
		<INPUT TYPE="HIDDEN" NAME="id" VALUE="' . db_result($result, 0, 'id') . '">
		<B>' . $Language->getText('news_admin_index', 'submitted_for_group') . ':</B> <a href="/projects/' . strtolower(db_result($result, 0, 'unix_group_name')) . '/">' . $pm->getProject(db_result($result, 0, 'group_id'))->getPublicName() . '</a><BR>
		<B>' . $Language->getText('news_admin_index', 'submitted_by') . ':</B> <a href="/users/' . $username . '">' . $username . '</a><BR>
        <B>' . $Language->getText('news_admin_index', 'submitted_on') . ':</B> ' . $news_date . '<BR>        
Beispiel #27
0
<?php

// ## export sf front page news in RSS
require_once 'pre.php';
header("Content-Type: text/xml");
// ## group_id must be specified
$res_grp = db_query("SELECT group_id,group_name FROM groups '\n\t.'WHERE access != '" . db_es(Project::ACCESS_PRIVATE) . "' AND status='A' AND group_id=" . db_ei($group_id));
if (db_numrows($res_grp) < 1) {
    print $Language->getText('export_nitf_sfforums', 'g_id_err');
    exit;
} else {
    $row_grp = db_fetch_array($res_grp);
}
print '<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE sf_forum SYSTEM "' . get_server_url() . '/exports/sf_forum_0.1.dtd">
';
print "<group name=\"{$row_grp['group_name']}\">";
$res_forum = db_query('SELECT group_forum_id,forum_name FROM forum_group_list ' . 'WHERE group_id=' . $group_id);
while ($row_forum = db_fetch_array($res_forum)) {
    print " <forum name=\"{$row_forum['forum_name']}\">\n";
    $res_post = db_query('SELECT forum.msg_id AS msg_id,forum.subject AS subject,' . 'forum.body AS body,forum.date AS date,user.user_name AS user_name,' . 'user.realname AS realname FROM forum,user ' . 'WHERE forum.posted_by=user.user_id AND forum.group_forum_id=' . $row_forum[group_forum_id]);
    // ## item outputs
    while ($row_post = db_fetch_array($res_post)) {
        print "  <nitf version=\"XMLNews/DTD XMLNEWS-STORY 1.8//EN\">\n";
        print "   <head>\n";
        print "    <title>{$row_post['subject']}</title>\n";
        print "   </head>\n";
        print "   <body><body.content><block>\n";
        print $row_post[body];
        print "   </block></body.content></body>\n";
        print "  </nitf>\n";
Beispiel #28
0
        $usage = (int) $request->exist('truncated_emails');
        if ($currentproject->getTruncatedEmailsUsage() != $usage) {
            $project_manager->setTruncatedEmailsUsage($currentproject, $usage);
            $update_success = true;
        }
    }
    if (!$update_success) {
        $GLOBALS['Response']->addFeedback('error', $Language->getText('project_admin_editgroupinfo', 'upd_fail', db_error() ? db_error() : ' '));
    } else {
        $GLOBALS['Response']->addFeedback('info', $Language->getText('project_admin_editgroupinfo', 'upd_success'));
    }
}
$project_manager->clearProjectFromCache($currentproject->getID());
$currentproject = $project_manager->getProject($currentproject->getID());
// update info for page
$res_grp = db_query("SELECT * FROM groups WHERE group_id='" . db_ei($group_id) . "'");
if (db_numrows($res_grp) < 1) {
    exit_no_group();
}
$row_grp = db_fetch_array($res_grp);
$descfieldsvalue = $currentproject->getProjectsDescFieldsValue();
project_admin_header(array('title' => $Language->getText('project_admin_editgroupinfo', 'editing_g_info'), 'group' => $group_id, 'help' => 'project-admin.html#project-public-information'));
echo '<FORM action="?group_id=' . $group_id . '" method="post" id="project_info_form">';
$renderer = TemplateRendererFactory::build()->getRenderer(ForgeConfig::get('codendi_dir') . '/src/templates/project/');
if ($user_can_choose_visibility) {
    $presenter = new ProjectVisibilityPresenter($Language, ForgeConfig::areRestrictedUsersAllowed(), $currentproject->getAccess());
    echo $renderer->renderToString('project_visibility', $presenter);
}
if ($user_can_choose_truncated_emails) {
    $truncated_mails_impacted_services = array();
    $file_service = $currentproject->getService(Service::FILE);
 function templateWikiHaveAttachments()
 {
     $res = db_query('SELECT count(*) AS nb FROM plugin_phpwiki_attachment' . ' WHERE group_id=' . db_ei($this->template_id));
     $tmpl_wiki_attach_exist = db_result($res, 0, 'nb') > 0;
     return $tmpl_wiki_attach_exist;
 }
Beispiel #30
0
$params = array('title' => $Language->getText('survey_admin_show_questions', 's_quest'), 'pv' => '1', 'group' => $group_id);
site_project_header($params);
if (!user_isloggedin() || !user_ismember($group_id, 'A')) {
    echo '<H1>' . $Language->getText('survey_admin_add_question', 'perm_denied') . '</H1>';
    survey_footer(array());
    exit;
}
?>

<H2><?php 
echo $Language->getText('survey_admin_show_questions', 'exist_q');
?>
</H2>
<P>
<?php 
echo $Language->getText('survey_admin_show_questions', 'exist_q_comm');
?>
<P>
<B><span class="highlight"><?php 
echo $Language->getText('survey_admin_show_questions', 'q_id');
?>
</span></B>
<P> 
<?php 
/*
	Select this survey from the database
*/
$sql = "SELECT survey_questions.question_id,survey_questions.question,survey_question_types.id AS question_type_id " . "FROM survey_questions,survey_question_types " . "WHERE survey_question_types.id=survey_questions.question_type AND survey_questions.group_id='" . db_ei($group_id) . "' " . "ORDER BY survey_questions.question_id DESC";
$result = db_query($sql);
survey_utils_show_questions($result, false, false);
site_project_footer($params);