Пример #1
0
 /**
  * Returns the display HTML for this widget.  The optional
  * parameter determines whether or not to automatically display the widget
  * nicely, or whether to simply return the widget (for use in a template).
  * 
  * @access	public
  * @param	boolean	$generate_html
  * @return	string
  * 
  */
 function display($generate_html = 0)
 {
     global $intl, $simple;
     if (!isset($this->data_value)) {
         $this->data_value = $this->default_value;
     }
     $attrstr = $this->getAttrs();
     if (empty($this->data_value)) {
         $this->data_value = session_team();
     }
     if (empty($this->owner)) {
         $this->owner = $this->getOwner($this->owner);
     }
     if (session_role() == 'master') {
         // allow all
         $this->value = assocify(session_get_teams());
     } elseif (session_username() == $this->owner) {
         // allow specific ones
         $this->value = assocify(session_allowed_teams_list(true));
     } else {
         // show info instead
         loader_import('saf.MailForm.Widget.Info');
         $info = new MF_Widget_info($this->name);
         $info->extra = $this->extra;
         $info->setValue($this->data_value);
         return $info->display($generate_html);
     }
     asort($this->value);
     $adv = $this->advanced ? ' class="advanced"' : '';
     if ($generate_html) {
         $data = "\t" . '<tr' . $adv . '>' . "\n\t\t" . '<td class="label"><label for="' . $this->name . '" id="' . $this->name . '-label"' . $this->invalid() . '>' . $simple->fill($this->label_template, $this, '', true) . '</label></td>' . "\n\t\t" . '<td class="field"><select ' . $attrstr . ' ' . $this->extra . ' >' . "\n";
         foreach ($this->value as $value => $display) {
             $display = str_replace('_', ' ', ucwords($display));
             if ($value == $this->data_value) {
                 $selected = ' selected="selected"';
             } else {
                 $selected = '';
             }
             $data .= "\t" . '<option value="' . $value . '"' . $selected . '>' . $display . '</option>' . "\n";
         }
         return $data . '</select></td>' . "\n\t" . '</tr>' . "\n";
     } else {
         $data = '<select ' . $attrstr . ' ' . $this->extra . ' >' . "\n";
         foreach ($this->value as $value => $display) {
             $display = str_replace('_', ' ', ucwords($display));
             if ($value == $this->data_value) {
                 $selected = ' selected="selected"';
             } else {
                 $selected = '';
             }
             $data .= "\t" . '<option value="' . htmlentities_compat($value, ENT_COMPAT, $intl->charset) . '"' . $selected . '>' . $display . '</option>' . "\n";
         }
         return $data . '</select>';
     }
 }
Пример #2
0
 /**
  * Queries the server for the specified search query.
  */
 function query($query, $limit, $offset, $collections = 'all', $domains = 'all')
 {
     // 1. build the query
     $query = $this->_prepare($query);
     $lquery = '(title:(' . $query . ') ' . $this->matchType;
     $lquery .= ' url:(' . $query . ') ' . $this->matchType;
     $lquery .= ' description:(' . $query . ') ' . $this->matchType;
     $lquery .= ' keywords:(' . $query . ') ' . $this->matchType;
     $lquery .= ' body:(' . $query . '))';
     // acls now...
     $access_list = session_allowed_access_list();
     $status_list = session_allowed_status_list();
     $team_list = session_allowed_teams_list();
     if ($access_list[0] != 'all') {
         $lquery .= ' and access:(' . join(' ', $this->_quote($access_list)) . ')';
     }
     if ($status_list[0] != 'all') {
         $lquery .= ' and status:(' . join(' ', $this->_quote($status_list)) . ')';
     }
     if ($team_list[0] != 'all') {
         $lquery .= ' and team:(' . join(' ', $this->_quote($team_list)) . ')';
     }
     if ($collections[0] != 'all') {
         $lquery .= ' and ctype:(' . join(' ', $this->_quote($collections)) . ')';
     }
     if ($domains[0] != 'all') {
         $lquery .= ' and domain:(' . join(' ', $this->_quote($domains)) . ')';
     }
     // 2. execute the query
     $hits = @$this->client->find($lquery);
     $this->total = count($hits);
     $res = array('rows' => array(), 'metadata' => array('hits' => $this->total, 'query' => $query, 'syntax' => $lquery));
     for ($i = $offset; $i < $offset + $limit; $i++) {
         if (!isset($hits[$i])) {
             break;
         }
         $hit = $hits[$i];
         $res['rows'][] = array('title' => $hit->_title, 'url' => $hit->url, 'description' => $hit->_description, 'score' => $hit->score, 'ctype' => $hit->ctype, 'domain' => $hit->domain);
     }
     return $res;
 }
Пример #3
0
// build column headers
$struct = array_keys($rex->getStruct());
$acl = array();
if (!$struct) {
    $struct = array();
} else {
    $acl_list = session_allowed_access_list();
    if (!in_array('all', $acl_list)) {
        foreach ($struct as $k) {
            if ($k == 'sitellite_access') {
                $acl = array('sitellite_access' => new rList('sitellite_access', session_allowed_access_list()));
                break;
            }
        }
    }
    $team_list = session_allowed_teams_list();
    if (!in_array('all', $team_list)) {
        $team_list[] = '';
        foreach ($struct as $k) {
            if ($k == 'sitellite_team') {
                $acl['sitellite_team'] = new rList('sitellite_team', $team_list);
                break;
            }
        }
    }
}
foreach ($rex->info as $key => $vals) {
    if (strpos($key, 'browse:') === 0) {
        $key = substr($key, 7);
        $data['headers'][] = new TableHeader($key, $vals['header']);
        $data['fields'][$key] = $vals;