當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Flyspray::UserNameOrId方法代碼示例

本文整理匯總了PHP中Flyspray::UserNameOrId方法的典型用法代碼示例。如果您正苦於以下問題:PHP Flyspray::UserNameOrId方法的具體用法?PHP Flyspray::UserNameOrId怎麽用?PHP Flyspray::UserNameOrId使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Flyspray的用法示例。


在下文中一共展示了Flyspray::UserNameOrId方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: get_task_list


//.........這裏部分代碼省略.........
             $from .= " LEFT JOIN {field_values} {$ref} ON t.task_id = {$ref}.task_id AND {$ref}.field_id = {$field->id} ";
             $custom_fields_joined[] = $field->id;
             if ($date = array_get($args, 'field' . $field->id . 'from')) {
                 $where[] = "({$ref}.field_value >= ?)";
                 $sql_params[] = Flyspray::strtotime($date);
             }
             if ($date = array_get($args, 'field' . $field->id . 'to')) {
                 $where[] = "({$ref}.field_value <= ? AND {$ref}.field_value > 0)";
                 $sql_params[] = Flyspray::strtotime($date);
             }
         } elseif ($field->prefs['field_type'] == FIELD_LIST) {
             if (in_array('', (array) array_get($args, 'field' . $field->id, array('')))) {
                 continue;
             }
             $from .= " LEFT JOIN {field_values} {$ref} ON t.task_id = {$ref}.task_id AND {$ref}.field_id = {$field->id} ";
             $custom_fields_joined[] = $field->id;
             $fwhere = array();
             foreach ($args['field' . $field->id] as $val) {
                 $fwhere[] = " {$ref}.field_value = ? ";
                 $sql_params[] = $val;
             }
             if (count($fwhere)) {
                 $where[] = ' (' . implode(' OR ', $fwhere) . ') ';
             }
         } else {
             if (!($val = array_get($args, 'field' . $field->id))) {
                 continue;
             }
             $from .= " LEFT JOIN {field_values} {$ref} ON t.task_id = {$ref}.task_id AND {$ref}.field_id = {$field->id} ";
             $custom_fields_joined[] = $field->id;
             $where[] = "({$ref}.field_value LIKE ?)";
             // try to determine a valid user ID if necessary
             if ($field->prefs['field_type'] == FIELD_USER) {
                 $val = Flyspray::UserNameOrId($val);
             }
             $sql_params[] = $val;
         }
     }
     // now join custom fields used in columns
     foreach ($proj->columns as $col => $name) {
         if (preg_match('/^field(\\d+)$/', $col, $match) && (in_array($col, $visible) || $match[1] == $fs->prefs['color_field'])) {
             if (!in_array($match[1], $custom_fields_joined)) {
                 $from .= " LEFT JOIN {field_values} {$col} ON t.task_id = {$col}.task_id AND {$col}.field_id = " . intval($match[1]);
             }
             $from .= " LEFT JOIN {fields} f{$col} ON f{$col}.field_id = {$col}.field_id ";
             // join special tables for certain fields
             if ($proj->fields['field' . $match[1]]->prefs['field_type'] == FIELD_LIST) {
                 $from .= "LEFT JOIN {list_items} li{$col} ON (f{$col}.list_id = li{$col}.list_id AND {$col}.field_value = li{$col}.list_item_id)\n                              LEFT JOIN {list_category} lc{$col} ON (f{$col}.list_id = lc{$col}.list_id AND {$col}.field_value = lc{$col}.category_id) ";
                 if ($proj->fields['field' . $match[1]]->prefs['list_type'] != LIST_CATEGORY) {
                     $select .= " li{$col}.item_name AS {$col}_name, ";
                 } else {
                     $select .= " lc{$col}.category_name AS {$col}_name, ";
                 }
             } else {
                 if ($proj->fields['field' . $match[1]]->prefs['field_type'] == FIELD_USER) {
                     $from .= " LEFT JOIN {users} u{$col} ON {$col}.field_value = u{$col}.user_id ";
                     $select .= " u{$col}.user_name AS {$col}_name, ";
                 }
             }
             $select .= "{$col}.field_value AS {$col}, ";
             // adding data to queries not nice, but otherwise sql_params and joins are not in sync
         }
     }
     // open / closed (never thought that I'd use XOR some time)
     if (in_array('open', array_get($args, 'status', array('open'))) xor in_array('closed', array_get($args, 'status', array()))) {
         $where[] = ' is_closed = ? ';
開發者ID:negram,項目名稱:flyspray,代碼行數:67,代碼來源:class.backend.php

示例2: read

 /**
  * Returns a correct value for the field based on user input
  * @access public
  * @param string $input
  * @return string
  */
 function read($input)
 {
     global $user, $db;
     switch ($this->prefs['field_type']) {
         case FIELD_DATE:
             $value = $input ? Flyspray::strtotime($input) : '';
             // this would be a unix timestamp
             if (is_numeric($input)) {
                 $value = $input;
             }
             break;
         case FIELD_TEXT:
             $value = (string) $input;
             break;
         case FIELD_LIST:
             if ($this->prefs['list_type'] == LIST_CATEGORY) {
                 $check = $db->x->GetOne('SELECT count(*)
                                         FROM {list_category}
                                        WHERE list_id = ? AND category_id = ?', null, array($this->prefs['list_id'], $input));
             } else {
                 $check = $db->x->GetOne('SELECT count(*)
                                         FROM {list_items}
                                        WHERE list_id = ? AND list_item_id = ?', null, array($this->prefs['list_id'], $input));
             }
             $value = $check ? $input : 0;
             break;
         case FIELD_USER:
             // try to determine a valid user ID if necessary
             $value = Flyspray::UserNameOrId($input);
             break;
     }
     if (!$value || $this->prefs['force_default'] && !$user->perms('modify_all_tasks')) {
         $value = $this->prefs['default_value'];
     }
     return $value;
 }
開發者ID:negram,項目名稱:flyspray,代碼行數:42,代碼來源:class.field.php


注:本文中的Flyspray::UserNameOrId方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。