当前位置: 首页>>代码示例>>PHP>>正文


PHP ExtraField::get方法代码示例

本文整理汇总了PHP中ExtraField::get方法的典型用法代码示例。如果您正苦于以下问题:PHP ExtraField::get方法的具体用法?PHP ExtraField::get怎么用?PHP ExtraField::get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ExtraField的用法示例。


在下文中一共展示了ExtraField::get方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: save

 /**
  * Save values in the *_field_values table
  * @param array Structured array with the values to save
  * @param boolean Whether to show the insert query (passed to the parent save() method)
  * @result mixed The result sent from the parent method
  * @assert (array()) === false
  */
 public function save($params, $show_query = false)
 {
     $extra_field = new ExtraField($this->type);
     // Setting value to insert.
     $value = $params['field_value'];
     $value_to_insert = null;
     if (is_array($value)) {
         $value_to_insert = implode(';', $value);
     } else {
         $value_to_insert = Database::escape_string($value);
     }
     $params['field_value'] = $value_to_insert;
     //If field id exists
     $extra_field_info = $extra_field->get($params['field_id']);
     if ($extra_field_info) {
         switch ($extra_field_info['field_type']) {
             case ExtraField::FIELD_TYPE_RADIO:
             case ExtraField::FIELD_TYPE_SELECT:
             case ExtraField::FIELD_TYPE_SELECT_MULTIPLE:
                 //$field_options = $session_field_option->get_field_options_by_field($params['field_id']);
                 //$params['field_value'] = split(';', $value_to_insert);
                 /*
                                         if ($field_options) {
                                             $check = false;
                                             foreach ($field_options as $option) {
                                                 if (in_array($option['option_value'], $values)) {
                                                     $check = true;
                                                     break;
                                                 }
                                            }
                                            if (!$check) {
                                                return false; //option value not found
                                            }
                                        } else {
                                            return false; //enumerated type but no option found
                                        }*/
                 break;
             case ExtraField::FIELD_TYPE_TEXT:
             case ExtraField::FIELD_TYPE_TEXTAREA:
                 break;
             case ExtraField::FIELD_TYPE_DOUBLE_SELECT:
                 if (is_array($value)) {
                     if (isset($value['extra_' . $extra_field_info['field_variable']]) && isset($value['extra_' . $extra_field_info['field_variable'] . '_second'])) {
                         $value_to_insert = $value['extra_' . $extra_field_info['field_variable']] . '::' . $value['extra_' . $extra_field_info['field_variable'] . '_second'];
                     } else {
                         $value_to_insert = null;
                     }
                 }
                 break;
             default:
                 break;
         }
         if ($extra_field_info['field_type'] == ExtraField::FIELD_TYPE_TAG) {
             $field_values = self::getAllValuesByItemAndFieldAndValue($params[$this->handler_id], $params['field_id'], $value);
         } else {
             $field_values = self::get_values_by_handler_and_field_id($params[$this->handler_id], $params['field_id']);
         }
         $params['field_value'] = $value_to_insert;
         $params['tms'] = api_get_utc_datetime();
         $params[$this->author_id] = api_get_user_id();
         // Insert
         if (empty($field_values)) {
             if ($extra_field_info['field_loggeable'] == 1) {
                 switch ($this->type) {
                     case 'question':
                         $extraFieldValue = new QuestionFieldValues();
                         $extraFieldValue->setUserId(api_get_user_id());
                         $extraFieldValue->setQuestionId($params[$this->handler_id]);
                         break;
                     case 'course':
                         $extraFieldValue = new CourseFieldValues();
                         $extraFieldValue->setUserId(api_get_user_id());
                         $extraFieldValue->setQuestionId($params[$this->handler_id]);
                         break;
                     case 'user':
                         $extraFieldValue = new UserFieldValues();
                         $extraFieldValue->setUserId($params[$this->handler_id]);
                         $extraFieldValue->setAuthorId(api_get_user_id());
                         break;
                     case 'session':
                         $extraFieldValue = new SessionFieldValues();
                         $extraFieldValue->setUserId(api_get_user_id());
                         $extraFieldValue->setSessionId($params[$this->handler_id]);
                         break;
                 }
                 if (isset($extraFieldValue)) {
                     if (!empty($params['field_value'])) {
                         $extraFieldValue->setComment($params['comment']);
                         $extraFieldValue->setFieldValue($params['field_value']);
                         $extraFieldValue->setFieldId($params['field_id']);
                         $extraFieldValue->setTms(api_get_utc_datetime(null, false, true));
                         Database::getManager()->persist($extraFieldValue);
                         Database::getManager()->flush();
//.........这里部分代码省略.........
开发者ID:ragebat,项目名称:chamilo-lms,代码行数:101,代码来源:extra_field_value.lib.php

示例2: get_sessions_admin_complete

 /**
  * Gets the admin session list callback of the session/session_list.php
  * page with all user/details in the right fomat
  * @param array
  * @result array Array of rows results
  * @asset ('a') === false
  */
 public static function get_sessions_admin_complete($options = array())
 {
     if (!is_array($options)) {
         return false;
     }
     $tbl_session = Database::get_main_table(TABLE_MAIN_SESSION);
     $tbl_session_category = Database::get_main_table(TABLE_MAIN_SESSION_CATEGORY);
     $tbl_user = Database::get_main_table(TABLE_MAIN_USER);
     $tbl_session_rel_course = Database::get_main_table(TABLE_MAIN_SESSION_COURSE);
     $tbl_course = Database::get_main_table(TABLE_MAIN_COURSE);
     $tbl_session_field_values = Database::get_main_table(TABLE_MAIN_SESSION_FIELD_VALUES);
     $tbl_session_field_options = Database::get_main_table(TABLE_MAIN_SESSION_FIELD_OPTIONS);
     $where = 'WHERE 1 = 1 ';
     $user_id = api_get_user_id();
     if (!api_is_platform_admin()) {
         if (api_is_session_admin() && api_get_setting('allow_session_admins_to_manage_all_sessions') == 'false') {
             $where .= " AND s.session_admin_id = {$user_id} ";
         }
     }
     $coach_name = " CONCAT(u.lastname , ' ', u.firstname) as coach_name ";
     if (api_is_western_name_order()) {
         $coach_name = " CONCAT(u.firstname, ' ', u.lastname) as coach_name ";
     }
     $today = api_get_utc_datetime();
     $inject_extra_fields = null;
     $extra_fields = array();
     $extra_fields_info = array();
     //for now only sessions
     $extra_field = new ExtraField('session');
     $double_fields = array();
     $extra_field_option = new ExtraFieldOption('session');
     if (isset($options['extra'])) {
         $extra_fields = $options['extra'];
         if (!empty($extra_fields)) {
             foreach ($extra_fields as $extra) {
                 $inject_extra_fields .= " IF (fv.field_id = {$extra['id']}, fvo.option_display_text, NULL ) as {$extra['field']} , ";
                 if (isset($extra_fields_info[$extra['id']])) {
                     $info = $extra_fields_info[$extra['id']];
                 } else {
                     $info = $extra_field->get($extra['id']);
                     $extra_fields_info[$extra['id']] = $info;
                 }
                 if ($info['field_type'] == ExtraField::FIELD_TYPE_DOUBLE_SELECT) {
                     $double_fields[$info['id']] = $info;
                 }
             }
         }
     }
     $options_by_double = array();
     foreach ($double_fields as $double) {
         $my_options = $extra_field_option->get_field_options_by_field($double['id'], true);
         $options_by_double['extra_' . $double['field_variable']] = $my_options;
     }
     //sc.name as category_name,
     $select = "\n                SELECT * FROM (\n                    SELECT DISTINCT\n                         IF (\n                            (s.access_start_date <= '{$today}' AND '{$today}' < s.access_end_date) OR\n                            (s.access_start_date  = '0000-00-00 00:00:00' AND s.access_end_date  = '0000-00-00 00:00:00' ) OR\n                            (s.access_start_date  IS NULL AND s.access_end_date IS NULL) OR\n                            (s.access_start_date <= '{$today}' AND ('0000-00-00 00:00:00' = s.access_end_date OR s.access_end_date IS NULL )) OR\n                            ('{$today}' < s.access_end_date AND ('0000-00-00 00:00:00' = s.access_start_date OR s.access_start_date IS NULL) )\n                        , 1, 0) as session_active,\n                s.name,\n                s.nbr_courses,\n                s.nbr_users,\n                s.display_start_date,\n                s.display_end_date,\n                {$coach_name},\n                access_start_date,\n                access_end_date,\n                s.visibility,\n                u.user_id,\n                {$inject_extra_fields}\n                c.title as course_title,\n                s.id ";
     if (!empty($options['where'])) {
         if (!empty($options['extra'])) {
             $options['where'] = str_replace(' 1 = 1  AND', '', $options['where']);
             $options['where'] = str_replace('AND', 'OR', $options['where']);
             foreach ($options['extra'] as $extra) {
                 $options['where'] = str_replace($extra['field'], 'fv.field_id = ' . $extra['id'] . ' AND fvo.option_value', $options['where']);
             }
         }
         $options['where'] = str_replace('course_title', 'c.title', $options['where']);
         $where .= ' AND ' . $options['where'];
     }
     if (!empty($options['limit'])) {
         $where .= " LIMIT " . $options['limit'];
     }
     $query = "{$select} FROM {$tbl_session} s\n                    LEFT JOIN {$tbl_session_field_values} fv ON (fv.session_id = s.id)\n                    LEFT JOIN {$tbl_session_field_options} fvo ON (fv.field_id = fvo.field_id)\n                    LEFT JOIN {$tbl_session_rel_course} src ON (src.id_session = s.id)\n                    LEFT JOIN {$tbl_course} c ON (src.c_id = c.id)\n                    LEFT JOIN {$tbl_session_category} sc ON (s.session_category_id = sc.id)\n                    INNER JOIN {$tbl_user} u ON (s.id_coach = u.user_id) " . $where;
     if (api_is_multiple_url_enabled()) {
         $table_access_url_rel_session = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_SESSION);
         $access_url_id = api_get_current_access_url_id();
         if ($access_url_id != -1) {
             $where .= " AND ar.access_url_id = {$access_url_id} ";
             $query = "{$select}\n                    FROM {$tbl_session} s\n                    LEFT JOIN {$tbl_session_field_values} fv ON (fv.session_id = s.id)\n                    LEFT JOIN {$tbl_session_field_options} fvo ON (fv.field_id = fvo.field_id)\n                    LEFT JOIN {$tbl_session_rel_course} src ON (src.id_session = s.id)\n                    LEFT JOIN {$tbl_course} c ON (src.c_id = c.id)\n                    LEFT JOIN {$tbl_session_category} sc ON (s.session_category_id = sc.id)\n                    INNER JOIN {$tbl_user} u ON (s.id_coach = u.user_id)\n                    INNER JOIN {$table_access_url_rel_session} ar ON (ar.session_id = s.id)\n                    {$where}";
         }
     }
     $query .= ") AS session_table";
     if (!empty($options['order'])) {
         $query .= " ORDER BY " . $options['order'];
     }
     //error_log($query);
     //echo $query;
     $result = Database::query($query);
     $formatted_sessions = array();
     if (Database::num_rows($result)) {
         $sessions = Database::store_result($result, 'ASSOC');
         foreach ($sessions as $session) {
             $session_id = $session['id'];
             $session['name'] = Display::url($session['name'], "resume_session.php?id_session=" . $session['id']);
             $session['coach_name'] = Display::url($session['coach_name'], "user_information.php?user_id=" . $session['user_id']);
             if ($session['session_active'] == 1) {
//.........这里部分代码省略.........
开发者ID:ilosada,项目名称:chamilo-lms-icpna,代码行数:101,代码来源:sessionmanager.lib.php

示例3: parseConditions

 /**
  * @param array $options
  * @return array
  */
 public function parseConditions($options)
 {
     $inject_extra_fields = null;
     $extraFieldOption = new ExtraFieldOption($this->type);
     $double_fields = array();
     if (isset($options['extra'])) {
         $extra_fields = $options['extra'];
         if (!empty($extra_fields)) {
             $counter = 1;
             foreach ($extra_fields as &$extra) {
                 $extra_field_obj = new ExtraField($this->type);
                 $extra_field_info = $extra_field_obj->get($extra['id']);
                 $extra['extra_field_info'] = $extra_field_info;
                 if (isset($extra_field_info['field_type']) && in_array($extra_field_info['field_type'], array(ExtraField::FIELD_TYPE_SELECT, ExtraField::FIELD_TYPE_SELECT, ExtraField::FIELD_TYPE_DOUBLE_SELECT))) {
                     $inject_extra_fields .= " fvo{$counter}.option_display_text as {$extra['field']}, ";
                 } else {
                     $inject_extra_fields .= " fv{$counter}.field_value as {$extra['field']}, ";
                 }
                 if (isset($extra_fields_info[$extra['id']])) {
                     $info = $extra_fields_info[$extra['id']];
                 } else {
                     $info = $this->get($extra['id']);
                     $extra_fields_info[$extra['id']] = $info;
                 }
                 if (isset($info['field_type']) && $info['field_type'] == ExtraField::FIELD_TYPE_DOUBLE_SELECT) {
                     $double_fields[$info['id']] = $info;
                 }
                 $counter++;
             }
         }
     }
     $options_by_double = array();
     foreach ($double_fields as $double) {
         $my_options = $extraFieldOption->get_field_options_by_field($double['id'], true);
         $options_by_double['extra_' . $double['field_variable']] = $my_options;
     }
     $field_value_to_join = array();
     //filter can be all/any = and/or
     $inject_joins = null;
     $inject_where = null;
     $where = null;
     if (!empty($options['where'])) {
         if (!empty($options['extra'])) {
             // Removing double 1=1
             $options['where'] = str_replace(' 1 = 1  AND', '', $options['where']);
             // Always OR
             $counter = 1;
             foreach ($extra_fields as $extra_info) {
                 $extra_field_info = $extra_info['extra_field_info'];
                 $inject_joins .= " INNER JOIN {$this->table_field_values} fv{$counter} ON (s." . $this->primaryKey . " = fv{$counter}." . $this->handler_id . ") ";
                 //Add options
                 if (isset($extra_field_info['field_type']) && in_array($extra_field_info['field_type'], array(ExtraField::FIELD_TYPE_SELECT, ExtraField::FIELD_TYPE_SELECT, ExtraField::FIELD_TYPE_DOUBLE_SELECT))) {
                     $options['where'] = str_replace($extra_info['field'], 'fv' . $counter . '.field_id = ' . $extra_info['id'] . ' AND fvo' . $counter . '.option_value', $options['where']);
                     $inject_joins .= " INNER JOIN {$this->table_field_options} fvo{$counter} " . " ON (fv{$counter}.field_id = fvo{$counter}.field_id AND fv{$counter}.field_value = fvo{$counter}.option_value) ";
                 } else {
                     //text, textarea, etc
                     $options['where'] = str_replace($extra_info['field'], 'fv' . $counter . '.field_id = ' . $extra_info['id'] . ' AND fv' . $counter . '.field_value', $options['where']);
                 }
                 $field_value_to_join[] = " fv{$counter}.{$this->handler_id} ";
                 $counter++;
             }
             if (!empty($field_value_to_join)) {
                 //$inject_where .= " AND s.id = ".implode(' = ', $field_value_to_join);
             }
         }
         $where .= ' AND ' . $options['where'];
     }
     $order = null;
     if (!empty($options['order'])) {
         $order = " ORDER BY " . $options['order'];
     }
     $limit = null;
     if (!empty($options['limit'])) {
         $limit = " LIMIT " . $options['limit'];
     }
     return array('order' => $order, 'limit' => $limit, 'where' => $where, 'inject_where' => $inject_where, 'inject_joins' => $inject_joins, 'field_value_to_join' => $field_value_to_join, 'inject_extra_fields' => $inject_extra_fields);
 }
开发者ID:ragebat,项目名称:chamilo-lms,代码行数:81,代码来源:extra_field.lib.php

示例4: api_protect_admin_script

api_protect_admin_script();
//Add the JS needed to use the jqgrid
$htmlHeadXtra[] = api_get_jqgrid_js();
// setting breadcrumbs
$interbreadcrumb[] = array('url' => 'index.php', 'name' => get_lang('PlatformAdmin'));
$tool_name = null;
$action = isset($_GET['action']) ? $_GET['action'] : null;
$field_id = isset($_GET['field_id']) ? $_GET['field_id'] : null;
if (empty($field_id)) {
    api_not_allowed();
}
if (!in_array($type, ExtraField::getValidExtraFieldTypes())) {
    api_not_allowed();
}
$extra_field = new ExtraField($type);
$extra_field_info = $extra_field->get($field_id);
$check = Security::check_token('request');
$token = Security::get_token();
if ($action == 'add') {
    $interbreadcrumb[] = array('url' => 'extra_fields.php?type=' . $extra_field->type, 'name' => $extra_field->pageName);
    $interbreadcrumb[] = array('url' => 'extra_fields.php?type=' . $extra_field->type . '&action=edit&id=' . $extra_field_info['id'], 'name' => $extra_field_info['field_display_text']);
    $interbreadcrumb[] = array('url' => 'extra_field_options.php?type=' . $extra_field->type . '&field_id=' . $extra_field_info['id'], 'name' => get_lang('EditExtraFieldOptions'));
    $interbreadcrumb[] = array('url' => '#', 'name' => get_lang('Add'));
} elseif ($action == 'edit') {
    $interbreadcrumb[] = array('url' => 'extra_fields.php?type=' . $extra_field->type, 'name' => $extra_field->pageName);
    $interbreadcrumb[] = array('url' => 'extra_fields.php?type=' . $extra_field->type . '&action=edit&id=' . $extra_field_info['id'], 'name' => $extra_field_info['field_display_text']);
    $interbreadcrumb[] = array('url' => 'extra_field_options.php?type=' . $extra_field->type . '&field_id=' . $extra_field_info['id'], 'name' => get_lang('EditExtraFieldOptions'));
    $interbreadcrumb[] = array('url' => '#', 'name' => get_lang('Edit'));
} else {
    $interbreadcrumb[] = array('url' => 'extra_fields.php?type=' . $extra_field->type, 'name' => $extra_field->pageName);
    $interbreadcrumb[] = array('url' => 'extra_fields.php?type=' . $extra_field->type . '&action=edit&id=' . $extra_field_info['id'], 'name' => $extra_field_info['field_display_text']);
开发者ID:ragebat,项目名称:chamilo-lms,代码行数:31,代码来源:extra_field_options.php

示例5: get_field_options_by_field_to_string

 /**
  * Get options for a specific field as string split by ;
  * @param int $field_id
  * @param string $ordered_by Extra query bit for reordering
  * @return string HTML string of options
  * @assert (0, '') === null
  */
 public function get_field_options_by_field_to_string($field_id, $ordered_by = null)
 {
     $field = new ExtraField($this->type);
     $field_info = $field->get($field_id);
     $options = self::get_field_options_by_field($field_id, false, $ordered_by);
     $elements = array();
     if (!empty($options)) {
         switch ($field_info['field_type']) {
             case ExtraField::FIELD_TYPE_DOUBLE_SELECT:
                 $html = ExtraField::extra_field_double_select_convert_array_to_string($options);
                 break;
             default:
                 foreach ($options as $option) {
                     $elements[] = $option['option_value'];
                 }
                 $html = implode(';', $elements);
                 break;
         }
         return $html;
     }
     return null;
 }
开发者ID:annickvdp,项目名称:Chamilo1.9.10,代码行数:29,代码来源:extra_field_option.lib.php

示例6: isset

$this_section = SECTION_PLATFORM_ADMIN;
$type = isset($_REQUEST['type']) ? $_REQUEST['type'] : null;
api_protect_admin_script();
// setting breadcrumbs
$interbreadcrumb[] = array('url' => 'index.php', 'name' => get_lang('PlatformAdmin'));
$tool_name = null;
$action = isset($_GET['action']) ? $_GET['action'] : null;
$field_id = isset($_GET['field_id']) ? $_GET['field_id'] : null;
if (empty($field_id)) {
    api_not_allowed();
}
if (!in_array($type, ExtraField::getValidExtraFieldTypes())) {
    api_not_allowed();
}
$extraField = new ExtraField($type);
$extraFieldInfo = $extraField->get($field_id);
$check = Security::check_token('request');
$token = Security::get_token();
if ($action == 'add') {
    $interbreadcrumb[] = array('url' => 'extra_fields.php?type=' . $extraField->type, 'name' => $extraField->pageName);
    $interbreadcrumb[] = array('url' => 'extra_fields.php?type=' . $extraField->type . '&action=edit&id=' . $extraFieldInfo['id'], 'name' => $extraFieldInfo['field_display_text']);
    $interbreadcrumb[] = array('url' => 'extra_field_options.php?type=' . $extraField->type . '&field_id=' . $extraFieldInfo['id'], 'name' => get_lang('EditExtraFieldOptions'));
    $interbreadcrumb[] = array('url' => '#', 'name' => get_lang('Add'));
} elseif ($action == 'edit') {
    $interbreadcrumb[] = array('url' => 'extra_fields.php?type=' . $extraField->type, 'name' => $extraField->pageName);
    $interbreadcrumb[] = array('url' => 'extra_fields.php?type=' . $extraField->type . '&action=edit&id=' . $extraFieldInfo['id'], 'name' => $extraFieldInfo['field_display_text']);
    $interbreadcrumb[] = array('url' => 'extra_field_options.php?type=' . $extraField->type . '&field_id=' . $extraFieldInfo['id'], 'name' => get_lang('EditExtraFieldOptions'));
    $interbreadcrumb[] = array('url' => '#', 'name' => get_lang('Edit'));
} else {
    $interbreadcrumb[] = array('url' => 'extra_fields.php?type=' . $extraField->type, 'name' => $extraField->pageName);
    $interbreadcrumb[] = array('url' => 'extra_fields.php?type=' . $extraField->type . '&action=edit&id=' . $extraFieldInfo['id'], 'name' => $extraFieldInfo['field_display_text']);
开发者ID:ilosada,项目名称:chamilo-lms-icpna,代码行数:31,代码来源:extra_field_workflow.php


注:本文中的ExtraField::get方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。