本文整理汇总了PHP中ExtraField::get_all方法的典型用法代码示例。如果您正苦于以下问题:PHP ExtraField::get_all方法的具体用法?PHP ExtraField::get_all怎么用?PHP ExtraField::get_all使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ExtraField
的用法示例。
在下文中一共展示了ExtraField::get_all方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: array
/**
* Return all content to replace and all content to be replace
* @param int $user_id
* @param int $course_id
* @param bool $is_preview
* @return array
*/
static function get_all_info_to_certificate($user_id, $course_id, $is_preview = false)
{
$info_list = array();
$user_id = intval($user_id);
$course_info = api_get_course_info($course_id);
//info portal
$organization_name = api_get_setting('platform.institution');
$portal_name = api_get_setting('platform.site_name');
// Extra user data information
$extra_user_info_data = UserManager::get_extra_user_data($user_id, false, false, false, true);
// get extra fields
$extraField = new ExtraField('user');
$extraFields = $extraField->get_all(['filter = ? AND visible = ?' => [1, 1]]);
//Student information
$user_info = api_get_user_info($user_id);
$first_name = $user_info['firstname'];
$last_name = $user_info['lastname'];
$official_code = $user_info['official_code'];
//Teacher information
$info_teacher_id = UserManager::get_user_id_of_course_admin_or_session_admin($course_info);
$teacher_info = api_get_user_info($info_teacher_id);
$teacher_first_name = $teacher_info['firstname'];
$teacher_last_name = $teacher_info['lastname'];
// info gradebook certificate
$info_grade_certificate = UserManager::get_info_gradebook_certificate($course_id, $user_id);
$date_certificate = $info_grade_certificate['created_at'];
$date_long_certificate = '';
$date_no_time = api_convert_and_format_date(api_get_utc_datetime(), DATE_FORMAT_LONG_NO_DAY);
if (!empty($date_certificate)) {
$date_long_certificate = api_convert_and_format_date($date_certificate);
$date_no_time = api_convert_and_format_date($date_certificate, DATE_FORMAT_LONG_NO_DAY);
}
if ($is_preview) {
$date_long_certificate = api_convert_and_format_date(api_get_utc_datetime());
$date_no_time = api_convert_and_format_date(api_get_utc_datetime(), DATE_FORMAT_LONG_NO_DAY);
}
$url = api_get_path(WEB_PATH) . 'certificates/index.php?id=' . $info_grade_certificate['id'];
//replace content
$info_to_replace_in_content_html = array($first_name, $last_name, $organization_name, $portal_name, $teacher_first_name, $teacher_last_name, $official_code, $date_long_certificate, $date_no_time, $course_id, $course_info['name'], $info_grade_certificate['grade'], $url, '<a href="' . $url . '" target="_blank">' . get_lang('CertificateOnlineLink') . '</a>', '((certificate_barcode))');
$info_to_be_replaced_in_content_html = array('((user_firstname))', '((user_lastname))', '((gradebook_institution))', '((gradebook_sitename))', '((teacher_firstname))', '((teacher_lastname))', '((official_code))', '((date_certificate))', '((date_certificate_no_time))', '((course_code))', '((course_title))', '((gradebook_grade))', '((certificate_link))', '((certificate_link_html))', '((certificate_barcode))');
if (!empty($extraFields)) {
foreach ($extraFields as $extraField) {
$valueExtra = isset($extra_user_info_data[$extraField['variable']]) ? $extra_user_info_data[$extraField['variable']] : '';
$info_to_be_replaced_in_content_html[] = '((' . strtolower($extraField['variable']) . '))';
$info_to_replace_in_content_html[] = $valueExtra;
}
}
$info_list[] = $info_to_be_replaced_in_content_html;
$info_list[] = $info_to_replace_in_content_html;
return $info_list;
}
示例2: switch
switch ($_POST['action']) {
case 'unsubscribe':
// Make sure we don't unsubscribe current user from the course
if (is_array($_POST['user'])) {
$user_ids = array_diff($_POST['user'], array($user_id));
if (count($user_ids) > 0) {
CourseManager::unsubscribe_user($user_ids, $courseCode);
Display::addFlash(Display::return_message(get_lang('UsersUnsubscribed')));
}
}
}
}
}
// Getting extra fields that have the filter option "on"
$extraField = new ExtraField('user');
$extraFields = $extraField->get_all(array('filter = ?' => 1));
$user_image_pdf_size = 80;
if (api_is_allowed_to_edit(null, true)) {
if (isset($_GET['action'])) {
switch ($_GET['action']) {
case 'set_tutor':
$userId = isset($_GET['user_id']) ? intval($_GET['user_id']) : null;
$isTutor = isset($_GET['is_tutor']) ? intval($_GET['is_tutor']) : 0;
if (!empty($userId)) {
if ($sessionId) {
/*$res = SessionManager::set_coach_to_course_session(
$userId,
$sessionId,
$courseCode,
true
);*/
示例3: Template
$tpl = new Template($plugin->get_lang('plugin_title'));
// Get all sessions
$sessionList = $plugin->listAllSessions();
if (!empty($sessionId)) {
// Get student list in queue
$studentList = $plugin->listAllStudentsInQueueBySession($sessionId);
// Set selected to current session
$sessionList[$sessionId]['selected'] = 'selected="selected"';
$studentList['session']['id'] = $sessionId;
// Assign variables
$fieldsArray = array('description', 'target', 'mode', 'publication_end_date', 'recommended_number_of_participants', 'vacancies');
$sessionArray = api_get_session_info($sessionId);
$extraSession = new ExtraFieldValue('session');
$extraField = new ExtraField('session');
// Get session fields
$fieldList = $extraField->get_all(array('variable IN ( ?, ?, ?, ?, ?, ?)' => $fieldsArray));
// Index session fields
foreach ($fieldList as $field) {
$fields[$field['id']] = $field['variable'];
}
$params = array(' item_id = ? ' => $sessionId);
$sessionFieldValueList = $extraSession->get_all(array('where' => $params));
foreach ($sessionFieldValueList as $sessionFieldValue) {
// Check if session field value is set in session field list
if (isset($fields[$sessionFieldValue['field_id']])) {
$var = $fields[$sessionFieldValue['field_id']];
$val = $sessionFieldValue['value'];
// Assign session field value to session
$sessionArray[$var] = $val;
}
}
示例4: getFilteredExtraFields
/**
* @param $sessionId
* @param array $extraFieldsToInclude
* @return array
*/
public static function getFilteredExtraFields($sessionId, $extraFieldsToInclude = array())
{
$extraData = array();
$variables = array();
$variablePlaceHolders = array();
foreach ($extraFieldsToInclude as $sessionExtraField) {
$variablePlaceHolders[] = "?";
$variables[] = Database::escape_string($sessionExtraField);
}
$sessionExtraField = new ExtraField('session');
$fieldList = $sessionExtraField->get_all(array("variable IN ( " . implode(", ", $variablePlaceHolders) . " ) " => $variables));
$fields = array();
// Index session fields
foreach ($fieldList as $field) {
$fields[$field['id']] = $field['variable'];
}
// Get session field values
$extra = new ExtraFieldValue('session');
$sessionFieldValueList = $extra->get_all(array("field_id IN ( " . implode(", ", $variablePlaceHolders) . " )" => array_keys($fields)));
foreach ($sessionFieldValueList as $sessionFieldValue) {
// Match session field values to session
if ($sessionFieldValue['item_id'] != $sessionId) {
continue;
}
// Check if session field value is set in session field list
if (!isset($fields[$sessionFieldValue['field_id']])) {
continue;
}
$extrafieldVariable = $fields[$sessionFieldValue['field_id']];
$extrafieldValue = $sessionFieldValue['value'];
$extraData[] = array('variable' => $extrafieldVariable, 'value' => $extrafieldValue);
}
return $extraData;
}
示例5: foreach
} else {
echo Display::display_warning_message(get_lang('NoUsersInCourse'));
}
$session_list = SessionManager::get_session_by_course($course_info['real_id']);
$url = api_get_path(WEB_CODE_PATH);
if (!empty($session_list)) {
foreach ($session_list as &$session) {
$session[0] = Display::url($session[0], $url . 'admin/resume_session.php?id_session=' . $session['id']);
unset($session[1]);
}
echo Display::page_subheader(get_lang('Sessions'));
$table = new SortableTableFromArray($session_list, 0, 20, 'user_table');
$table->display();
}
$extra_field = new ExtraField('course');
$extra_fields = $extra_field->get_all();
if (!empty($extra_fields)) {
echo Display::page_subheader(get_lang('ExtraFields'));
echo '<table class="data_table">';
foreach ($extra_fields as $field) {
if ($field['field_visible'] != '1') {
continue;
}
$obj = new ExtraFieldValue($extra_field->type);
$result = $obj->get_values_by_handler_and_field_id($course_info['code'], $field['id'], true);
$value = null;
if ($result) {
$value = $result['field_value'];
if (is_bool($value)) {
$value = $value ? get_lang('Yes') : get_lang('No');
}
示例6: saveFieldValues
/**
* Save the extra fields values
* In order to save this function needs a item_id (user id, course id, etc)
* This function is used with $extraField->addElements()
* @param array $params array for the insertion into the *_field_values table
*
* @return mixed false on empty params, void otherwise
* @assert (array()) === false
*/
public function saveFieldValues($params)
{
foreach ($params as $key => $value) {
$found = strpos($key, '__persist__');
if ($found === false) {
continue;
}
$tempKey = str_replace('__persist__', '', $key);
if (!isset($params[$tempKey])) {
$params[$tempKey] = array();
}
}
if (empty($params['item_id'])) {
return false;
}
$type = $this->getExtraField()->getExtraFieldType();
$extraField = new ExtraField($this->type);
$extraFields = $extraField->get_all(null, 'option_order');
// Parse params.
//foreach ($params as $key => $value) {
foreach ($extraFields as $fieldDetails) {
if ($fieldDetails['visible'] != 1) {
continue;
}
$field_variable = $fieldDetails['variable'];
if (isset($params['extra_' . $field_variable])) {
$value = $params['extra_' . $field_variable];
} else {
$value = '';
}
$extraFieldInfo = $this->getExtraField()->get_handler_field_info_by_field_variable($field_variable);
if (!$extraFieldInfo) {
continue;
}
$commentVariable = 'extra_' . $field_variable . '_comment';
$comment = isset($params[$commentVariable]) ? $params[$commentVariable] : null;
switch ($extraFieldInfo['field_type']) {
case ExtraField::FIELD_TYPE_TAG:
if ($type == EntityExtraField::USER_FIELD_TYPE) {
UserManager::delete_user_tags($params['item_id'], $extraFieldInfo['id']);
UserManager::process_tags($value, $params['item_id'], $extraFieldInfo['id']);
break;
}
$em = Database::getManager();
$currentTags = $em->getRepository('ChamiloCoreBundle:ExtraFieldRelTag')->findBy(['fieldId' => $extraFieldInfo['id'], 'itemId' => $params['item_id']]);
foreach ($currentTags as $extraFieldtag) {
$em->remove($extraFieldtag);
}
$em->flush();
$tagValues = is_array($value) ? $value : [$value];
$tags = [];
foreach ($tagValues as $tagValue) {
$tagsResult = $em->getRepository('ChamiloCoreBundle:Tag')->findBy(['tag' => $tagValue, 'fieldId' => $extraFieldInfo['id']]);
if (empty($tagsResult)) {
$tag = new \Chamilo\CoreBundle\Entity\Tag();
$tag->setFieldId($extraFieldInfo['id']);
$tag->setTag($tagValue);
$tags[] = $tag;
} else {
$tags = array_merge($tags, $tagsResult);
}
}
foreach ($tags as $tag) {
$tagUses = $em->getRepository('ChamiloCoreBundle:ExtraFieldRelTag')->findBy(['tagId' => $tag->getId()]);
$tag->setCount(count($tagUses) + 1);
$em->persist($tag);
}
$em->flush();
foreach ($tags as $tag) {
$fieldRelTag = new Chamilo\CoreBundle\Entity\ExtraFieldRelTag();
$fieldRelTag->setFieldId($extraFieldInfo['id']);
$fieldRelTag->setItemId($params['item_id']);
$fieldRelTag->setTagId($tag->getId());
$em->persist($fieldRelTag);
}
$em->flush();
break;
case ExtraField::FIELD_TYPE_FILE_IMAGE:
$dirPermissions = api_get_permissions_for_new_directories();
switch ($this->type) {
case 'course':
$fileDir = api_get_path(SYS_UPLOAD_PATH) . "courses/";
$fileDirStored = "courses/";
break;
case 'session':
$fileDir = api_get_path(SYS_UPLOAD_PATH) . "sessions/";
$fileDirStored = "sessions/";
break;
case 'user':
$fileDir = UserManager::getUserPathById($params['item_id'], 'system');
$fileDirStored = UserManager::getUserPathById($params['item_id'], 'last');
//.........这里部分代码省略.........
示例7: listAllStudentsInQueueBySession
/**
* Return the list of student, in queue used by admin view
* @param int $sessionId
*
* @return array
*/
public function listAllStudentsInQueueBySession($sessionId)
{
// Filter input variable
$sessionId = intval($sessionId);
// Assign variables
$fieldsArray = array('target', 'publication_end_date', 'mode', 'recommended_number_of_participants', 'vacancies');
$sessionArray = api_get_session_info($sessionId);
$extraSession = new ExtraFieldValue('session');
$extraField = new ExtraField('session');
// Get session fields
$fieldList = $extraField->get_all(array('variable IN ( ?, ?, ?, ?, ?)' => $fieldsArray));
// Index session fields
$fields = array();
foreach ($fieldList as $field) {
$fields[$field['id']] = $field['variable'];
}
$mergedArray = array_merge(array($sessionId), array_keys($fields));
$sessionFieldValueList = $extraSession->get_all(array('item_id = ? field_id IN ( ?, ?, ?, ?, ?, ?, ? )' => $mergedArray));
foreach ($sessionFieldValueList as $sessionFieldValue) {
// Check if session field value is set in session field list
if (isset($fields[$sessionFieldValue['field_id']])) {
$var = $fields[$sessionFieldValue['field_id']];
$val = $sessionFieldValue['value'];
// Assign session field value to session
$sessionArray[$var] = $val;
}
}
$queueTable = Database::get_main_table(TABLE_ADVANCED_SUBSCRIPTION_QUEUE);
$userTable = Database::get_main_table(TABLE_MAIN_USER);
$userJoinTable = $queueTable . ' q INNER JOIN ' . $userTable . ' u ON q.user_id = u.user_id';
$where = array('where' => array('q.session_id = ?' => array($sessionId)), 'order' => 'q.status DESC, u.lastname ASC');
$select = 'u.user_id, u.firstname, u.lastname, q.created_at, q.updated_at, q.status, q.id as queue_id';
$students = Database::select($select, $userJoinTable, $where);
foreach ($students as &$student) {
$status = intval($student['status']);
switch ($status) {
case ADVANCED_SUBSCRIPTION_QUEUE_STATUS_NO_QUEUE:
case ADVANCED_SUBSCRIPTION_QUEUE_STATUS_START:
$student['validation'] = '';
break;
case ADVANCED_SUBSCRIPTION_QUEUE_STATUS_BOSS_DISAPPROVED:
case ADVANCED_SUBSCRIPTION_QUEUE_STATUS_ADMIN_DISAPPROVED:
$student['validation'] = 'No';
break;
case ADVANCED_SUBSCRIPTION_QUEUE_STATUS_BOSS_APPROVED:
case ADVANCED_SUBSCRIPTION_QUEUE_STATUS_ADMIN_APPROVED:
$student['validation'] = 'Yes';
break;
default:
error_log(__FILE__ . ' ' . __FUNCTION__ . ' Student status no detected');
}
}
$return = array('session' => $sessionArray, 'students' => $students);
return $return;
}