Exemplo n.º 1
0
    function renderIssues($status)
    {
        $content = array();
        $t_project_id = helper_get_current_project();
        $t_bug_table = db_get_table('mantis_bug_table');
        $t_user_id = auth_get_current_user_id();
        $specific_where = helper_project_specific_where($t_project_id, $t_user_id);
        if ($this->severity) {
            $severityCond = '= ' . $this->severity;
        } else {
            $severityCond = '> -1';
        }
        $query = "SELECT *\n\t\t\tFROM {$t_bug_table}\n\t\t\tWHERE {$specific_where}\n\t\t\tAND status = {$status}\n\t\t\tAND severity {$severityCond}\n\t\t\tORDER BY last_updated DESC\n\t\t\tLIMIT 20";
        $result = db_query_bound($query);
        $category_count = db_num_rows($result);
        for ($i = 0; $i < $category_count; $i++) {
            $row = db_fetch_array($result);
            //pre_var_dump($row);
            $content[] = '<div class="portlet ui-helper-clearfix" id="' . $row['id'] . '">
			<div class="portlet-header">' . string_get_bug_view_link($row['id']) . ': ' . $row['summary'] . '</div>
			<div class="portlet-content">' . ($row['reporter_id'] ? 'Reporter: ' . user_get_name($row['reporter_id']) . BR : '') . ($row['handler_id'] ? 'Assigned: ' . user_get_name($row['handler_id']) . BR : '') . '</div></div>';
        }
        if ($row) {
            //pre_var_dump(array_keys($row));
        }
        return $content;
    }
Exemplo n.º 2
0
/**
 * Perform a single batch operation.
 *
 * Callback for batch_set().
 *
 * @param $MULTIPLE_PARAMS
 *   Additional parameters specific to the batch. These are specified in the
 *   array passed to batch_set().
 * @param $context
 *   The batch context array, passed by reference. This contains the following
 *   properties:
 *   - 'finished': A float number between 0 and 1 informing the processing
 *     engine of the completion level for the operation. 1 (or no value
 *     explicitly set) means the operation is finished: the operation will not
 *     be called again, and execution passes to the next operation or the
 *     callback_batch_finished() implementation. Any other value causes this
 *     operation to be called again; however it should be noted that the value
 *     set here does not persist between executions of this callback: each time
 *     it is set to 1 by default by the batch system.
 *   - 'sandbox': This may be used by operations to persist data between
 *     successive calls to the current operation. Any values set in
 *     $context['sandbox'] will be there the next time this function is called
 *     for the current operation. For example, an operation may wish to store a
 *     pointer in a file or an offset for a large query. The 'sandbox' array key
 *     is not initially set when this callback is first called, which makes it
 *     useful for determining whether it is the first call of the callback or
 *     not:
 *     @code
 *       if (empty($context['sandbox'])) {
 *         // Perform set-up steps here.
 *       }
 *     @endcode
 *     The values in the sandbox are stored and updated in the database between
 *     http requests until the batch finishes processing. This avoids problems
 *     if the user navigates away from the page before the batch finishes.
 *   - 'message': A text message displayed in the progress page.
 *   - 'results': The array of results gathered so far by the batch processing.
 *     This array is highly useful for passing data between operations. After
 *     all operations have finished, this is passed to callback_batch_finished()
 *     where results may be referenced to display information to the end-user,
 *     such as how many total items were processed.
 */
function callback_batch_operation($MULTIPLE_PARAMS, &$context)
{
    if (!isset($context['sandbox']['progress'])) {
        $context['sandbox']['progress'] = 0;
        $context['sandbox']['current_node'] = 0;
        $context['sandbox']['max'] = db_query('SELECT COUNT(DISTINCT nid) FROM {node}')->fetchField();
    }
    // For this example, we decide that we can safely process
    // 5 nodes at a time without a timeout.
    $limit = 5;
    // With each pass through the callback, retrieve the next group of nids.
    $result = db_query_range("SELECT nid FROM {node} WHERE nid > %d ORDER BY nid ASC", $context['sandbox']['current_node'], 0, $limit);
    while ($row = db_fetch_array($result)) {
        // Here we actually perform our processing on the current node.
        $node = node_load($row['nid'], NULL, TRUE);
        $node->value1 = $options1;
        $node->value2 = $options2;
        node_save($node);
        // Store some result for post-processing in the finished callback.
        $context['results'][] = check_plain($node->title);
        // Update our progress information.
        $context['sandbox']['progress']++;
        $context['sandbox']['current_node'] = $node->nid;
        $context['message'] = t('Now processing %node', array('%node' => $node->title));
    }
    // Inform the batch engine that we are not finished,
    // and provide an estimation of the completion level we reached.
    if ($context['sandbox']['progress'] != $context['sandbox']['max']) {
        $context['finished'] = $context['sandbox']['progress'] / $context['sandbox']['max'];
    }
}
Exemplo n.º 3
0
/**
 * Retrieves what Twitter accounts the given user can post to.
 */
function hook_twitter_accounts($drupal_user, $full_access = FALSE) {
  $accounts = array();
  if (user_access('use global twitter account') &&
      ($name = variable_get('twitter_global_name', NULL)) &&
      ($pass = variable_get('twitter_global_password', NULL))) {

    $accounts[$name] = array(
      'screen_name' => $name,
      'password' => $pass,
    );
  }

  $sql = " SELECT ta.*, tu.uid, tu.password, tu.import FROM {twitter_user} tu ";
  $sql .= "LEFT JOIN {twitter_account} ta ON (tu.screen_name = ta.screen_name) ";
  $sql .= "WHERE tu.uid = %d";

  if ($full_access) {
    $sql .= " AND tu.password IS NOT NULL";
  }
  $args = array($drupal_user->uid);
  $results = db_query($sql, $args);

  while ($account = db_fetch_array($results)) {
    $accounts[$account['screen_name']] = $account;
  }
  return $accounts;
}
function prayerlist_mod($perpage)
{
    global $list_prefix;
    //this is a module so we should already know if the user is logged in.
    //start main code here.
    //lets search for request that expire prior to right now.
    $sql = "SELECT * FROM " . $list_prefix . "prayer_list WHERE `expired` = '0' AND `expiredate` < '" . time() . "';";
    $result = db_query($sql);
    @($rows = db_num_rows($result));
    $j = 0;
    while ($j < $rows) {
        $row = db_fetch_array($result);
        //mail the user here if they are not anonymous
        if (0 != strcmp($row['requested_by'], 'anonymous')) {
            mailuser($row['requested_by'], $row);
        }
        //We need to change this to make the request historical rather than deleting it.
        $sql = "UPDATE " . $list_prefix . "prayer_list SET `expired` = '1' WHERE `id`='" . $row['id'] . "';";
        //end of change.
        $result2 = db_query($sql);
        $j++;
    }
    $MOD['title'] = "Prayer Request";
    $MOD['content'] = showlist($perpage);
    return $MOD;
}
 function getContent()
 {
     $html = '';
     $i = 1;
     $UH = UserHelper::instance();
     $hp = Codendi_HTMLPurifier::instance();
     while ($data = db_fetch_array($this->getLatestRevisions())) {
         $html .= '<div class="' . util_get_alt_row_color($i++) . '" style="border-bottom:1px solid #ddd">';
         $html .= '<div style="font-size:0.98em;">';
         $html .= '<a href="' . $this->_getLinkToCommit($data) . '">#' . $data['revision'] . '</a>';
         $html .= ' by ';
         if (isset($data['whoid'])) {
             $name = $UH->getDisplayNameFromUserId($data['whoid']);
         } else {
             $name = $UH->getDisplayNameFromUserName($data['who']);
         }
         $html .= $hp->purify($name, CODENDI_PURIFIER_CONVERT_HTML) . ' on ';
         //In the db, svn dates are stored as int whereas cvs dates are stored as timestamp
         $html .= format_date($GLOBALS['Language']->getText('system', 'datefmt'), is_numeric($data['date']) ? $data['date'] : strtotime($data['date']));
         $html .= '</div>';
         $html .= '<div style="padding-left:20px; padding-bottom:4px; color:#555">';
         $html .= util_make_links(substr($data['description'], 0, 255), $this->group_id);
         if (strlen($data['description']) > 255) {
             $html .= '&nbsp;[...]';
         }
         $html .= '</div>';
         $html .= '</div>';
     }
     $html .= '<div style="text-align:center" class="' . util_get_alt_row_color($i++) . '">';
     $html .= '<a href="' . $this->_getLinkToMore() . '">[ More ]</a>';
     $html .= '</div>';
     return $html;
 }
 /**
  * increments the load count in table "layer_load_count" for
  * each layer in the WMC document by one. 
  */
 function increment($layer_id)
 {
     if (!is_numeric($layer_id)) {
         return false;
     }
     //check if an entry exists for the current layer id
     $sql = "SELECT COUNT(layer_id) AS i FROM layer WHERE layer_id = \$1";
     $v = array($layer_id);
     $t = array('i');
     $res = db_prep_query($sql, $v, $t);
     $row = db_fetch_array($res);
     if (intval($row["i"]) === 0) {
         return false;
     }
     //check if an entry exists for the current layer id
     $sql = "SELECT load_count FROM layer_load_count WHERE fkey_layer_id = \$1";
     $v = array($layer_id);
     $t = array('i');
     $res = db_prep_query($sql, $v, $t);
     $row = db_fetch_array($res);
     //if yes, increment the load counter
     if ($row) {
         $currentCount = $row["load_count"];
         $sql = "UPDATE layer_load_count SET load_count = \$1 WHERE fkey_layer_id = \$2";
         $v = array(intval($currentCount + 1), $layer_id);
         $t = array('i', 'i');
         $res = db_prep_query($sql, $v, $t);
     } else {
         $sql = "INSERT INTO layer_load_count (fkey_layer_id, load_count) VALUES (\$1, 1)";
         $v = array($layer_id);
         $t = array('i');
         $res = db_prep_query($sql, $v, $t);
     }
 }
Exemplo n.º 7
0
    function by_tag()
    {
        $tag = @$this->path[1];
        $sql = '
			SELECT note.*, user.name as author_name
			FROM
				note INNER JOIN
				note_to_tag nt ON nt.note_id = note.id INNER JOIN
				tag ON tag.id = nt.tag_id LEFT JOIN
				user ON user.id = note.user_id 
			WHERE tag.name = "' . db_escape($tag) . '"
			ORDER BY id DESC
			LIMIT 20
		';
        $notes = db_fetch_all($sql);
        foreach ($notes as $i => $note) {
            $notes[$i]->tags = db_fetch_array('
				SELECT tag.name
				FROM tag INNER JOIN note_to_tag n ON n.tag_id = tag.id
				WHERE n.note_id = ' . $note->id . '
			');
        }
        $this->tpl->add('index', $notes);
        $this->tpl->view('note.index');
    }
Exemplo n.º 8
0
 function SiteblogBrowseForm()
 {
     parent::MailForm();
     $this->parseSettings('inc/app/siteblog/forms/browse/settings.php');
     echo '<h2> Search for Posts </h2>';
     $years = array();
     $years[] = 'All Years';
     $currYear = date('Y');
     for ($i = 2000; $i <= $currYear + 1; $i++) {
         $years[$i] = $i;
     }
     $months = array(0 => 'All Months', 1 => 'January', 2 => 'February', 3 => 'March', 4 => 'April', 5 => 'May', 6 => 'June', 7 => 'July', 8 => 'August', 9 => 'September', 10 => 'October', 11 => 'November', 12 => 'December');
     $authors[] = 'All Users';
     foreach (db_shift_array('select distinct author from siteblog_post') as $a) {
         $authors[$a] = $a;
     }
     $cats = db_fetch_array('select * from siteblog_category');
     $newcats = array();
     foreach ($cats as $c) {
         $newcats[$c->id] = $c->title;
     }
     $this->widgets['author']->setValues($authors);
     $this->widgets['month']->setValues($months);
     $this->widgets['year']->setValues($years);
     $this->widgets['category']->setValues($newcats);
 }
Exemplo n.º 9
0
 public function get($request)
 {
     /**
      *      Returns a Response with the list of user URIs.
      *
      *      @param $request - The Request we're responding to
      */
     if (!access_has_global_level(config_get('manage_user_threshold'))) {
         throw new HTTPException(403, "Access denied to user list");
     }
     $sql_to_add = $this->_build_sql_from_querystring($request->query);
     /*		$conditions = array();
     		parse_str($request->query, $qs_pairs);
     		foreach ($qs_pairs as $k => $v) {
     			$condition = $this->_get_query_condition($k, $v);
     			if ($condition) {
     				$conditions[] = $condition;
     			}
     		} */
     $user_table = config_get('mantis_user_table');
     $query = "SELECT u.id\n\t\t\tFROM {$user_table} u\n\t\t\t{$sql_to_add};";
     $result = db_query($query);
     $row = db_fetch_array($result);
     $this->rsrc_data['results'] = array();
     foreach ($result as $row) {
         $this->rsrc_data['results'][] = User::get_url_from_mantis_id($row[0]);
     }
     $resp = new Response();
     $resp->status = 200;
     $resp->body = $this->_repr($request);
     return $resp;
 }
Exemplo n.º 10
0
 private function deleteNodes()
 {
     $result = db_query("SELECT nid FROM {node} WHERE type = 'blog'");
     while ($row = db_fetch_array($result)) {
         $this->node_delete($row['nid']);
     }
 }
Exemplo n.º 11
0
function displayResultsCore($query, $fields)
{
    $result = db_query_bound($query);
    $nbRows = 0;
    while ($row = db_fetch_array($result)) {
        $nbRows++;
        $t_bug = bug_get($row['id']);
        print "<tr> \n";
        print '<td><a href="' . string_get_bug_view_url($row['id']) . '">' . bug_format_id($row['id']) . '</a></td>';
        //print "<td> ".string_get_bug_view_url( ))." </td>\n";
        print "<td> " . string_display_line(get_enum_element('status', $t_bug->status)) . " </td>\n";
        print "<td> " . category_get_row($t_bug->category_id)['name'] . " </td>\n";
        print "<td> " . $t_bug->summary . " </td>\n";
        print "<td> " . user_get_field($t_bug->reporter_id, 'username') . " </td>\n";
        if ($t_bug->handler_id != null) {
            print "<td> " . user_get_field($t_bug->handler_id, 'username') . " </td>\n";
        }
        if (sizeof($fields) > 0) {
            for ($i = 0; $i < sizeof($fields); $i++) {
                print "<td> " . $row[$fields[$i]] . " </td>\n";
            }
        }
        print "</tr>\n";
    }
    return $nbRows;
}
Exemplo n.º 12
0
 function __construct($data = array(), $files = array(), $opts = array())
 {
     $status_choices = array('a' => 'a (active)', 'h' => 'h (hidden)', 'd' => 'd (duplicate)');
     $publication_choices = array();
     $publication_choices[''] = "-- automatic, from permalink --";
     $r = db_query("SELECT id,shortname FROM organisation ORDER BY shortname");
     while ($row = db_fetch_array($r)) {
         $publication_choices[$row['id']] = $row['shortname'];
     }
     parent::__construct($data, $files, $opts);
     $this->error_css_class = 'errors';
     $this->fields['id'] = new IntegerField(array('widget' => new HiddenInput(), 'required' => FALSE));
     $this->fields['status'] = new ChoiceField(array('choices' => $status_choices));
     $this->fields['permalink'] = new URLField(array('max_length' => 400));
     $this->fields['title'] = new CharField(array('max_length' => 200));
     $this->fields['pubdate'] = new DateField(array('help_text' => "YYYY-MM-DD, 'today', 'yesterday'"));
     $this->fields['authors'] = new CharField(array('max_length' => 400, 'required' => FALSE, 'validators' => array(array(new CommaSeparatedJournoValidator(), "execute")), 'help_text' => 'eg "fred-bloggs,bob-smith"'));
     $this->fields['srcorg'] = new ChoiceField(array('label' => 'Publication', 'choices' => $publication_choices, 'required' => FALSE));
     $this->fields['byline'] = new CharField(array('required' => FALSE, 'max_length' => 200, 'label' => 'Raw Byline', 'help_text' => "byline doesn't affect attributed authors, so you can leave this blank"));
     $this->fields['description'] = new CharField(array('widget' => new Textarea(array('cols' => '80')), 'required' => FALSE));
     //        $this->fields['firstseen'] = new DateField(array('required'=>FALSE));
     //        $this->fields['lastseen'] = new DateField(array('required'=>FALSE));
     //        $this->fields['srcurl'] = new URLField(array('required'=>FALSE, 'max_length'=>400, ));
     //        $this->fields['srcid'] = new CharField(array('required'=>FALSE));
     //        $this->fields['lastscraped'] = new DateField(array('required'=>FALSE));
     //        $this->fields['wordcount'] = new IntegerField(array('required'=>FALSE));
     //        $this->fields['total_bloglinks'] = new IntegerField(array('required'=>FALSE));
     //        $this->fields['total_comments'] = new IntegerField(array('required'=>FALSE));
     //        $this->fields['last_comment_check'] = new DateField(array('required'=>FALSE));
     //        $this->fields['last_similar'] = new DateField(array('required'=>FALSE));
     // others:
     // journo_attr
     // article_content
     // article_url
 }
 protected function extractDataFromResult($res, $ids, $column)
 {
     $data = array();
     if ($res && db_numrows($res)) {
         db_reset_result($res);
         while ($d = db_fetch_array($res)) {
             if (!isset($data[$d['day']])) {
                 $data[$d['day']] = array();
                 foreach ($ids as $id) {
                     $data[$d['day']][$id] = 0;
                 }
             }
             $data[$d['day']][$d['id']] += $d[$column];
         }
         ksort($data);
         $previous = array();
         foreach ($data as $k => $d) {
             if (count($previous)) {
                 foreach ($d as $id => $v) {
                     if ($v == 0 && $previous[$id]) {
                         $data[$k][$id] = $previous[$id];
                     }
                 }
             }
             $previous = $data[$k];
         }
     }
     return $data;
 }
Exemplo n.º 14
0
function get_multigraph($userid)
{
    $result = db_query("SELECT feedlist FROM multigraph WHERE userid='{$userid}'");
    $result = db_fetch_array($result);
    $feedlist = $result['feedlist'];
    return $feedlist;
}
Exemplo n.º 15
0
 function ResultSetExporter($sql, $headers, $filter = false)
 {
     $this->headers = array_values($headers);
     if ($s = strpos(strtoupper($sql), ' LIMIT ')) {
         $sql = substr($sql, 0, $s);
     }
     # TODO: If $filter, add different LIMIT clause to query
     $this->_res = db_query($sql);
     if ($row = db_fetch_array($this->_res)) {
         $query_fields = array_keys($row);
         $this->headers = array();
         $this->keys = array();
         $this->lookups = array();
         foreach ($headers as $field => $name) {
             if (isset($row[$field])) {
                 $this->headers[] = $name;
                 $this->keys[] = $field;
                 # Remember the location of this header in the query results
                 # (column-wise) so we don't have to do hashtable lookups for every
                 # column of every row.
                 $this->lookups[] = array_search($field, $query_fields);
             }
         }
         db_data_reset($this->_res);
     }
 }
Exemplo n.º 16
0
/**
 * @file guifi_funders.inc.php
 * Manage guifi_funders fieldssets, validations, etc...
 */
function guifi_funders_load($id, $subject_type, $ret = "txt")
{
    $qsql = sprintf('SELECT * FROM {guifi_funders} ' . 'WHERE subject_id = %d ' . ' AND subject_type = "%s" ' . 'ORDER BY id', $id, $subject_type);
    $result = db_query($qsql);
    guifi_log(GUIFILOG_TRACE, 'function guifi_funders_load(sql)', $qsql);
    while ($m = db_fetch_array($result)) {
        switch ($ret) {
            case "txt":
                if (!empty($m['supplier_id'])) {
                    $m['supplier'] = $m['supplier_id'] . '-' . budgets_supplier_get_suppliername($m['supplier_id']);
                }
                if (!empty($m['user_id'])) {
                    $u = user_load($m['user_id']);
                    $m['user'] = $m['user_id'] . '-' . $u->name . ' (' . $u->mail . ') ';
                }
                $funders[] = $m;
                break;
            case "uid":
                if (!empty($m['supplier_id'])) {
                    $s = node_load($m['supplier_id']);
                    $funders[] = $s->uid;
                }
                if (!empty($m['user_id'])) {
                    $funders[] = $m['user_id'];
                }
                guifi_log(GUIFILOG_TRACE, 'function guifi_funders_load(funders)', $funders);
                break;
        }
    }
    return $funders;
}
/**
 * If access to the WFS conf is restricted, modify the filter.
 * TODO: this function is also in mod_wfs_result!! Maybe merge someday.
 */
function checkAccessConstraint($filter, $wfs_conf_id)
{
    /* wfs_conf_element */
    $sql = "SELECT * FROM wfs_conf_element ";
    $sql .= "JOIN wfs_element ON wfs_conf_element.f_id = wfs_element.element_id ";
    $sql .= "WHERE wfs_conf_element.fkey_wfs_conf_id = \$1 ";
    $sql .= "ORDER BY wfs_conf_element.f_respos";
    $v = array($wfs_conf_id);
    $t = array('i');
    $res = db_prep_query($sql, $v, $t);
    while ($row = db_fetch_array($res)) {
        if (!empty($row["f_auth_varname"])) {
            $auth_varname = $row["f_auth_varname"];
            $element_name = $row["element_name"];
        }
    }
    if (!empty($auth_varname)) {
        if (isValidVarName($auth_varname)) {
            $user = eval("return " . $auth_varname . ";");
            if ($user) {
                $pattern = "(<ogc:Filter[^>]*>)(.*)(</ogc:Filter>)";
                $replacement = "\\1<And>\\2<ogc:PropertyIsEqualTo><ogc:PropertyName>" . $element_name . "</ogc:PropertyName><ogc:Literal>" . $user . "</ogc:Literal></ogc:PropertyIsEqualTo></And>\\3";
                $filter = mb_eregi_replace($pattern, $replacement, $filter);
            } else {
                $e = new mb_exception("mod_wfsGazetteerEditor_server: checkAccessConstraint: invalid value of variable containing user information!");
            }
        } else {
            $e = new mb_exception("mod_wfsGazetteerEditor_server: checkAccessConstraint: var name is not valid! (" . $auth_varname . ")");
        }
    }
    return $filter;
}
Exemplo n.º 18
0
function Skin_ParseList()
{
    global $bbs, $RCD_DATA, $LimitArr, $table, $gSkinImg, $Vauth;
    global $Field_Arr, $Seted_Arr, $Seted_Num;
    $j = $i = 0;
    $NoticeFlag = 'Notice';
    if (trim($bbs[NoticeUid])) {
        while ($RCD = db_fetch_array(getNoticeData($LimitArr[$j]))) {
            echo Skin_DotLine($i, $j, 1, $Seted_Num);
            echo "<tr height='26' align=center class='" . $NoticeFlag . "'>";
            for ($k = 0; $k < $Seted_Num; $k++) {
                Skin_List($Seted_Arr[$k], $RCD, $i, $NoticeFlag);
            }
            echo "</tr>\n\n";
            $j++;
        }
    }
    $NoticeFlag = '';
    while ($RCD = @db_fetch_array($RCD_DATA)) {
        $keys = array_pop(array_keys($LimitArr, $RCD[BB_UID]));
        if ($LimitArr[$keys]) {
            continue;
        }
        echo Skin_DotLine($i, $j, 1, $Seted_Num);
        echo "<tr height='26' align=center class='Notice'>";
        for ($k = 0; $k < $Seted_Num; $k++) {
            Skin_List($Seted_Arr[$k], $RCD, $i, $NoticeFlag);
        }
        echo "</tr>\n\n";
        $i++;
    }
}
 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>';
 }
Exemplo n.º 20
0
function op_renderpapertrail()
{
    if (!get_input_bool('showsql', 'should show sql', $showsql, 'y')) {
        return;
    }
    $sql = 'select * from alextreg_papertrail order by entrydate';
    $query = do_dbquery($sql);
    if ($query == false) {
        return;
    }
    // error output is handled in database.php ...
    echo "<u>Current paper trail (oldest entries first)...</u>\n";
    echo "<ul>\n";
    while (($row = db_fetch_array($query)) != false) {
        $htmlaction = htmlentities($row['action'], ENT_QUOTES);
        $htmlauthor = htmlentities($row['author'], ENT_QUOTES);
        $htmlentrydate = htmlentities($row['entrydate'], ENT_QUOTES);
        $htmlsql = '';
        if ($showsql) {
            $htmlsql = "<br>\n<code>'" . htmlentities($row['sqltext'], ENT_QUOTES) . "'</code>";
        }
        echo "  <li><b>{$htmlaction}</b>: <i>by {$htmlauthor}, on {$htmlentrydate}</i>{$htmlsql}\n";
    }
    // while
    db_free_result($query);
    echo "</ul>\n";
    echo "<p>End of papertrail.\n";
}
Exemplo n.º 21
0
function emit_articles($offset, $limit)
{
    print "<?xml version=\"1.0\"?>\n";
    print "<rss version=\"2.0\" xmlns:jl=\"http://www.journalisted.com/jlns#\">\n";
    print "\t<channel>\n";
    printf("\t\t<title>Recent articles</title>\n");
    printf("\t\t<link>http://%s</link>\n", OPTION_WEB_DOMAIN);
    printf("\t\t<description></description>\n");
    print "\t\t<language>en-gb</language>\n";
    $params = array();
    $sql = "SELECT id,title,description,pubdate,permalink,srcorg,wordcount " . "FROM article " . "WHERE status='a' AND " . "pubdate>(NOW()-interval '24 hours') AND pubdate<=NOW() " . "ORDER BY pubdate DESC";
    if ($limit != 'all') {
        $sql .= ' LIMIT ?';
        $params[] = $limit;
        $sql .= ' OFFSET ?';
        $params[] = $offset;
    }
    $q = db_query($sql, $params);
    while ($art = db_fetch_array($q)) {
        print "\t\t<item>\n";
        printf("\t\t\t<title>%s</title>\n", $art['title']);
        printf("\t\t\t<link>%s</link>\n", $art['permalink']);
        printf("\t\t\t<description>%s</description>\n", $art['description']);
        printf("\t\t\t<pubDate>%s</pubDate>\n", $art['pubdate']);
        printf("\t\t\t<guid>%s</guid>\n", $art['permalink']);
        printf("\t\t\t<jl:wordcount>%s</jl:wordcount>\n", $art['wordcount']);
        print "\t\t</item>\n";
    }
    print "\t</channel>\n";
    print "</rss>\n";
}
Exemplo n.º 22
0
 function onSubmit($vals)
 {
     if (!$vals['group']) {
         $res = db_fetch_array('select distinct first_name, last_name, email_address, address_line1, address_line2, city, state, country, zip, company, job_title, phone_number, daytime_phone, evening_phone, mobile_phone, fax_number from sitellite_form_submission');
         $name = 'all';
     } else {
         $res = db_fetch_array('select distinct first_name, last_name, email_address, address_line1, address_line2, city, state, country, zip, company, job_title, phone_number, daytime_phone, evening_phone, mobile_phone, fax_number from sitellite_form_submission where form_type = ?', $vals['group']);
         $name = preg_replace('/[^a-z0-9]+/', '-', strtolower(db_shift('select name from sitellite_form_type where id = ?', $vals['group'])));
     }
     set_time_limit(0);
     header('Cache-control: private');
     header('Content-type: text/plain');
     header('Content-Disposition: attachment; filename=' . $name . '-' . date('Y-m-d') . '.csv');
     echo "First Name,Last Name,Email Address,Address Line 1,Address Line 2,City,State,Country,Zip,Company,Job Title,Phone Number,Daytime Phone,Evening Phone,Mobile Phone,Fax Number\n";
     foreach ($res as $row) {
         $r = (array) $row;
         foreach (array_keys($r) as $k) {
             $r[$k] = str_replace('"', '""', $r[$k]);
             if (strpos($r[$k], ',') !== false) {
                 $r[$k] = '"' . $r[$k] . '"';
             }
         }
         echo str_replace(array("\r", "\n"), array('\\r', '\\n'), join(',', $r)) . "\n";
     }
     exit;
 }
Exemplo n.º 23
0
 /**
  * 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=" . $this->entity_gid . " AND target_id='" . $this->entity_id . "' AND target_type='" . $this->entity_type . "' ) \n                     OR (source_gid=" . $this->entity_gid . " AND source_id='" . $this->entity_id . "' AND source_type='" . $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);
             }
         }
     }
 }
Exemplo n.º 24
0
 function load($var = '')
 {
     if (!$var && !($var = $this->getId())) {
         return false;
     }
     $sql = 'SELECT staff.created as added, grp.*, staff.* ' . ' FROM ' . STAFF_TABLE . ' staff ' . ' LEFT JOIN ' . GROUP_TABLE . ' grp ON(grp.group_id=staff.group_id)
            WHERE ';
     if (is_numeric($var)) {
         $sql .= 'staff_id=' . db_input($var);
     } elseif (Validator::is_email($var)) {
         $sql .= 'email=' . db_input($var);
     } else {
         $sql .= 'username=' . db_input($var);
     }
     if (!($res = db_query($sql)) || !db_num_rows($res)) {
         return NULL;
     }
     $this->ht = db_fetch_array($res);
     $this->id = $this->ht['staff_id'];
     $this->teams = $this->ht['teams'] = array();
     $this->group = $this->dept = null;
     $this->departments = $this->stats = array();
     //WE have to patch info here to support upgrading from old versions.
     if ($time = strtotime($this->ht['passwdreset'] ? $this->ht['passwdreset'] : $this->ht['added'])) {
         $this->ht['passwd_change'] = time() - $time;
     }
     //XXX: check timezone issues.
     if ($this->ht['timezone_id']) {
         $this->ht['tz_offset'] = Timezone::getOffsetById($this->ht['timezone_id']);
     } elseif ($this->ht['timezone_offset']) {
         $this->ht['tz_offset'] = $this->ht['timezone_offset'];
     }
     return $this->id;
 }
 /**
  * build pie chart properties
  *
  * @param Pie_Engine $engine object
  */
 function buildProperties($engine)
 {
     parent::buildProperties($engine);
     $engine->data = array();
     $engine->legend = null;
     $result = array();
     $ff = Tracker_FormElementFactory::instance();
     $af = $ff->getFormElementById($this->chart->getField_base());
     if ($af && $af->userCanRead()) {
         $select = " SELECT count(a.id) AS nb, " . $af->getQuerySelect();
         $from = " FROM tracker_artifact AS a INNER JOIN tracker_changeset AS c ON (c.artifact_id = a.id) " . $af->getQueryFrom();
         $where = " WHERE a.id IN (" . $this->artifacts['id'] . ") \n                          AND c.id IN (" . $this->artifacts['last_changeset_id'] . ") ";
         $sql = $select . $from . $where . ' GROUP BY ' . $af->getQueryGroupBy();
         $res = db_query($sql);
         while ($data = db_fetch_array($res)) {
             if ($data[$af->name] !== null) {
                 $engine->data[] = $data['nb'];
                 $engine->legend[] = $af->fetchRawValue($data[$af->name]);
             } else {
                 $engine->data[] = $data['nb'];
                 $engine->legend[] = $GLOBALS['Language']->getText('global', 'none');
             }
         }
     }
     return $result;
 }
Exemplo n.º 26
0
    /**
     * It display a table with commit related to this tracker or task_extra_detail
     *
     * @param   string   $Query Query to be executed to get the commit entries.
     * @param   integer  $group_id Group_id of the actual Group_id
     *
     */
    function getCommitEntries($Query, $group_id)
    {
        $group =& group_get_object($group_id);
        if (!$group->usesPlugin($this->name)) {
            return;
        }
        $DBResult = db_query($Query);
        $Rows = db_numrows($DBResult);
        if ($Rows > 0) {
            echo '<tr><td colspan="2">';
            echo '<h4>' . _('Links to related CVS commits') . ':</h4>';
            $title_arr = $this->getTitleArr();
            echo $GLOBALS['HTML']->listTableTop($title_arr);
            for ($i = 0; $i < $Rows; $i++) {
                $Row = db_fetch_array($DBResult);
                echo '<tr ' . $GLOBALS['HTML']->boxGetAltRowStyle($i) . '>' . '<td>' . $this->getFileLink($group->getUnixName(), $Row['file'], $Row['actual_version']) . '</td>' . '<td>' . date(_('Y-m-d'), $Row['cvs_date']) . '</td>' . '<td>' . $this->getDiffLink($group->getUnixName(), $Row['file'], $Row['prev_version'], $Row['actual_version']) . '</td>' . '<td>' . $this->getActualVersionLink($group->getUnixName(), $Row['file'], $Row['actual_version']) . '</td>
				<td>' . htmlspecialchars($Row['log_text']) . '</td>
				<td>' . util_make_link_u($Row['author'], user_get_object_by_name($Row['author'])->getId(), $Row['author']) . '</td>
				</tr>';
            }
            echo $GLOBALS['HTML']->listTableBottom();
            echo '</td></tr>';
        } else {
            echo '<h4>' . _('No commits have been made.') . '</h4>';
        }
    }
Exemplo n.º 27
0
 function ArtifactFromID($id, $data = false)
 {
     if ($data) {
         $art_arr =& $data;
     } else {
         $res = db_query("SELECT * FROM artifact_vw WHERE artifact_id='{$id}'");
         if (!$res || db_numrows($res) < 1) {
             $this->setError("Invalid Artifact ID");
             return false;
         } else {
             $art_arr =& db_fetch_array($res);
         }
     }
     $at = artifactType_get_object($art_arr['group_artifact_id']);
     if (!$at || !is_object($at)) {
         $this->setError("Could Not Create ArtifactType");
         return false;
     } elseif ($at->isError()) {
         $this->setError($at->getErrorMessage());
         return false;
     }
     $this->ArtifactType =& $at;
     $a = artifact_get_object($id, $art_arr);
     if (!$a || !is_object($a)) {
         $this->setError("Could Not Create Artifact");
         return false;
     } elseif ($a->isError()) {
         $this->setError($a->getErrorMessage());
         return false;
     }
     $this->Artifact =& $a;
     return true;
 }
 function loadContent($id)
 {
     $this->content_id = $id;
     $sql = "SELECT * FROM plugin_hudson_widget WHERE widget_name='" . $this->widget_id . "' AND owner_id = " . $this->owner_id . " AND owner_type = '" . $this->owner_type . "' AND id = " . $id;
     $res = db_query($sql);
     if ($res && db_numrows($res)) {
         $data = db_fetch_array($res);
         $this->job_id = $data['job_id'];
         $jobs = $this->getAvailableJobs();
         if (array_key_exists($this->job_id, $jobs)) {
             try {
                 $used_job = $jobs[$this->job_id];
                 $this->job_url = $used_job->getUrl();
                 $this->job = $used_job;
                 $this->last_build_url = $this->job_url . '/lastBuild/';
                 $this->build = new HudsonBuild($this->last_build_url);
             } catch (Exception $e) {
                 $this->job = null;
                 $this->build = null;
             }
         } else {
             $this->job = null;
             $this->build = null;
         }
     }
 }
Exemplo n.º 29
0
function register_valid()
{
    if (!$GLOBALS["Update"]) {
        return 0;
    }
    // check against old pw
    $res = db_query("SELECT user_pw, status FROM users WHERE user_id=" . user_getid());
    $row_pw = db_fetch_array($res);
    if ($row_pw[user_pw] != md5($GLOBALS[form_oldpw])) {
        $GLOBALS[register_error] = "Old password is incorrect.";
        return 0;
    }
    if ($row_pw[status] != 'A') {
        $GLOBALS[register_error] = "Account must be active to change password.";
        return 0;
    }
    if (!$GLOBALS[form_pw]) {
        $GLOBALS[register_error] = "You must supply a password.";
        return 0;
    }
    if ($GLOBALS[form_pw] != $GLOBALS[form_pw2]) {
        $GLOBALS[register_error] = "Passwords do not match.";
        return 0;
    }
    if (!account_pwvalid($GLOBALS[form_pw])) {
        return 0;
    }
    // if we got this far, it must be good
    $user =& user_get_object(user_getid());
    if (!$user->setPasswd($GLOBALS['form_pw'])) {
        $GLOBALS['register_error'] = $user->getErrorMessage();
        return 0;
    }
    return 1;
}
Exemplo n.º 30
0
 private function deleteVocabs()
 {
     $result = db_query("SELECT vid FROM {vocabulary}");
     while ($vid = db_fetch_array($result)) {
         taxonomy_del_vocabulary($vid['vid']);
     }
 }