コード例 #1
0
ファイル: DAO.class.php プロジェクト: rmiddle/feg
 public static function unsetFieldValue($source_ext_id, $source_id, $field_id, $value = null)
 {
     $db = DevblocksPlatform::getDatabaseService();
     if (null == ($field = DAO_CustomField::get($field_id))) {
         return FALSE;
     }
     if (null == ($table_name = self::getValueTableName($field_id))) {
         return FALSE;
     }
     // Delete all values or optionally a specific given value
     $sql = sprintf("DELETE QUICK FROM %s WHERE source_extension = '%s' AND source_id = %d AND field_id = %d %s", $table_name, $source_ext_id, $source_id, $field_id, !is_null($value) ? sprintf("AND field_value = %s ", $db->qstr($value)) : "");
     return $db->Execute($sql);
 }
コード例 #2
0
ファイル: App.php プロジェクト: joegeck/cerb4
 function getReportAction()
 {
     @($field_id = DevblocksPlatform::importGPC($_REQUEST['field_id'], 'integer', 0));
     $tpl = DevblocksPlatform::getTemplateService();
     $tpl->cache_lifetime = "0";
     $tpl->assign('path', $this->tpl_path);
     // Custom Field sources (tickets, orgs, etc.)
     $source_manifests = DevblocksPlatform::getExtensions('cerberusweb.fields.source', false);
     uasort($source_manifests, create_function('$a, $b', "return strcasecmp(\$a->name,\$b->name);\n"));
     $tpl->assign('source_manifests', $source_manifests);
     $field = DAO_CustomField::get($field_id);
     $tpl->assign('field', $field);
     $value_counts = self::_getValueCounts($field_id);
     $tpl->assign('value_counts', $value_counts);
     $tpl->display('file:' . $this->tpl_path . '/reports/custom_fields/usage/html.tpl');
 }
コード例 #3
0
ファイル: Model.class.php プロジェクト: rmiddle/feg
 protected function _doSetCriteriaCustomField($token, $field_id)
 {
     $field = DAO_CustomField::get($field_id);
     @($oper = DevblocksPlatform::importGPC($_POST['oper'], 'string', ''));
     @($value = DevblocksPlatform::importGPC($_POST['value'], 'string', ''));
     $criteria = null;
     switch ($field->type) {
         case Model_CustomField::TYPE_DROPDOWN:
         case Model_CustomField::TYPE_MULTI_PICKLIST:
         case Model_CustomField::TYPE_MULTI_CHECKBOX:
             @($options = DevblocksPlatform::importGPC($_POST['options'], 'array', array()));
             if (!empty($options)) {
                 $criteria = new DevblocksSearchCriteria($token, $oper, $options);
             } else {
                 $criteria = new DevblocksSearchCriteria($token, DevblocksSearchCriteria::OPER_IS_NULL);
             }
             break;
         case Model_CustomField::TYPE_CHECKBOX:
             $criteria = new DevblocksSearchCriteria($token, $oper, !empty($value) ? 1 : 0);
             break;
         case Model_CustomField::TYPE_NUMBER:
             $criteria = new DevblocksSearchCriteria($token, $oper, intval($value));
             break;
         case Model_CustomField::TYPE_DATE:
             @($from = DevblocksPlatform::importGPC($_REQUEST['from'], 'string', ''));
             @($to = DevblocksPlatform::importGPC($_REQUEST['to'], 'string', ''));
             if (empty($from)) {
                 $from = 0;
             }
             if (empty($to)) {
                 $to = 'today';
             }
             $criteria = new DevblocksSearchCriteria($token, $oper, array($from, $to));
             break;
         case Model_CustomField::TYPE_WORKER:
             @($oper = DevblocksPlatform::importGPC($_REQUEST['oper'], 'string', 'eq'));
             @($worker_ids = DevblocksPlatform::importGPC($_POST['worker_id'], 'array', array()));
             $criteria = new DevblocksSearchCriteria($token, $oper, $worker_ids);
             break;
         default:
             // TYPE_SINGLE_LINE || TYPE_MULTI_LINE
             if (($oper == DevblocksSearchCriteria::OPER_LIKE || $oper == DevblocksSearchCriteria::OPER_NOT_LIKE) && false === strpos($value, '*')) {
                 $value = '*' . $value . '*';
             }
             $criteria = new DevblocksSearchCriteria($token, $oper, $value);
             break;
     }
     return $criteria;
 }
コード例 #4
0
ファイル: App.php プロジェクト: Hildy/cerb5
 private function _getValueCounts($field_id)
 {
     $db = DevblocksPlatform::getDatabaseService();
     // Selected custom field
     if (null == ($field = DAO_CustomField::get($field_id))) {
         return;
     }
     if (null == ($table = DAO_CustomFieldValue::getValueTableName($field_id))) {
         return;
     }
     $sql = sprintf("SELECT field_value, count(field_value) AS hits " . "FROM %s " . "WHERE source_extension = %s " . "AND field_id = %d " . "GROUP BY field_value", $table, $db->qstr($field->source_extension), $field->id);
     $rs_values = $db->Execute($sql);
     $value_counts = array();
     while (!$rs_values->EOF) {
         $value = $rs_values->fields['field_value'];
         $hits = intval($rs_values->fields['hits']);
         $value_counts[$value] = intval($hits);
         $rs_values->MoveNext();
     }
     arsort($value_counts);
     return $value_counts;
 }