本文整理汇总了PHP中ExtraFieldValue::get_values_by_handler_and_field_variable方法的典型用法代码示例。如果您正苦于以下问题:PHP ExtraFieldValue::get_values_by_handler_and_field_variable方法的具体用法?PHP ExtraFieldValue::get_values_by_handler_and_field_variable怎么用?PHP ExtraFieldValue::get_values_by_handler_and_field_variable使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ExtraFieldValue
的用法示例。
在下文中一共展示了ExtraFieldValue::get_values_by_handler_and_field_variable方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: get_extra_user_data_by_value
/** Get extra user data by value
* @param string the internal variable name of the field
* @param string the internal value of the field
* @return array with extra data info of a user i.e array('field_variable'=>'value');
*/
public static function get_extra_user_data_by_value($field_variable, $field_value, $all_visibility = true)
{
$extraField = new ExtraFieldValue('user');
$data = $extraField->get_values_by_handler_and_field_variable($field_variable, $field_value, null, true, intval($all_visibility));
$result = [];
if (!empty($data)) {
foreach ($data as $data) {
$result[] = $data['item_id'];
}
}
return $result;
}
示例2: api_check_term_condition
/**
* Checks whether we already approved the last version term and condition
* @param int user id
* @return bool true if we pass false otherwise
*/
function api_check_term_condition($user_id)
{
if (api_get_setting('registration.allow_terms_conditions') == 'true') {
//check if exists terms and conditions
if (LegalManager::count() == 0) {
return true;
}
$extraFieldValue = new ExtraFieldValue('user');
$data = $extraFieldValue->get_values_by_handler_and_field_variable($user_id, 'legal_accept');
if (!empty($data) && isset($data['value'])) {
$rowv = $data['value'];
$user_conditions = explode(':', $rowv);
$version = $user_conditions[0];
$lang_id = $user_conditions[1];
$real_version = LegalManager::get_last_version($lang_id);
return $version >= $real_version;
}
return false;
}
return false;
}
示例3: isSpecialCourse
/**
* check if a course is special (autoregister)
* @param int $courseId
* @return bool
*/
public static function isSpecialCourse($courseId)
{
$extraFieldValue = new ExtraFieldValue('course');
$result = $extraFieldValue->get_values_by_handler_and_field_variable($courseId, 'special_course');
if (!empty($result)) {
if ($result['value'] == 1) {
return true;
}
}
return false;
}
示例4: getFormatedSessionsBlock
/**
* Get the formated data for sessions block to be displayed on Session Catalog page
* @param array $sessions The session list
* @return array
*/
private function getFormatedSessionsBlock(array $sessions)
{
$extraFieldValue = new ExtraFieldValue('session');
$userId = api_get_user_id();
$sessionsBlocks = [];
$entityManager = Database::getManager();
$sessionRelCourseRepo = $entityManager->getRepository('ChamiloCoreBundle:SessionRelCourse');
$extraFieldRepo = $entityManager->getRepository('ChamiloCoreBundle:ExtraField');
$extraFieldRelTagRepo = $entityManager->getRepository('ChamiloCoreBundle:ExtraFieldRelTag');
$tagsField = $extraFieldRepo->findOneBy(['extraFieldType' => Chamilo\CoreBundle\Entity\ExtraField::COURSE_FIELD_TYPE, 'variable' => 'tags']);
/** @var \Chamilo\CoreBundle\Entity\Session $session */
foreach ($sessions as $session) {
$sessionDates = SessionManager::parseSessionDates(['display_start_date' => $session->getDisplayStartDate(), 'display_end_date' => $session->getDisplayEndDate(), 'access_start_date' => $session->getAccessStartDate(), 'access_end_date' => $session->getAccessEndDate(), 'coach_access_start_date' => $session->getCoachAccessStartDate(), 'coach_access_end_date' => $session->getCoachAccessEndDate()]);
$imageField = $extraFieldValue->get_values_by_handler_and_field_variable($session->getId(), 'image');
$sessionCourseTags = [];
if (!is_null($tagsField)) {
$sessionRelCourses = $sessionRelCourseRepo->findBy(['session' => $session]);
foreach ($sessionRelCourses as $sessionRelCourse) {
$courseTags = $extraFieldRelTagRepo->getTags($tagsField, $sessionRelCourse->getCourse()->getId());
foreach ($courseTags as $tag) {
$sessionCourseTags[] = $tag->getTag();
}
}
}
if (!empty($sessionCourseTags)) {
$sessionCourseTags = array_unique($sessionCourseTags);
}
$repo = $entityManager->getRepository('ChamiloCoreBundle:SequenceResource');
$sequences = $repo->getRequirementsAndDependenciesWithinSequences($session->getId(), SequenceResource::SESSION_TYPE);
$hasRequirements = false;
foreach ($sequences['sequences'] as $sequence) {
if (count($sequence['requirements']) === 0) {
continue;
}
$hasRequirements = true;
break;
}
$sessionsBlock = array('id' => $session->getId(), 'name' => $session->getName(), 'image' => isset($imageField['value']) ? $imageField['value'] : null, 'nbr_courses' => $session->getNbrCourses(), 'nbr_users' => $session->getNbrUsers(), 'coach_name' => $session->getGeneralCoach()->getCompleteName(), 'is_subscribed' => SessionManager::isUserSubscribedAsStudent($session->getId(), $userId), 'icon' => $this->getSessionIcon($session->getName()), 'date' => $sessionDates['display'], 'subscribe_button' => $this->getRegisteredInSessionButton($session->getId(), $session->getName(), $hasRequirements), 'show_description' => $session->getShowDescription(), 'tags' => $sessionCourseTags);
$sessionsBlock = array_merge($sessionsBlock, $sequences);
$sessionsBlocks[] = $sessionsBlock;
}
return $sessionsBlocks;
}
示例5: foreach
$var = $fields[$sessionFieldValue['field_id']];
$val = $sessionFieldValue['value'];
// Assign session field value to session
$sessionArray[$var] = $val;
}
}
$adminsArray = UserManager::get_all_administrators();
$data['action'] = 'confirm';
$data['sessionId'] = $sessionId;
$data['currentUserId'] = api_get_user_id();
$isWesternNameOrder = api_is_western_name_order();
foreach ($studentList['students'] as &$student) {
$studentId = intval($student['user_id']);
$data['studentUserId'] = $studentId;
$fieldValue = new ExtraFieldValue('user');
$areaField = $fieldValue->get_values_by_handler_and_field_variable($studentId, 'area', true);
$student['area'] = $areaField['value'];
$student['userLink'] = api_get_path(WEB_CODE_PATH) . 'social/profile.php?u=' . $studentId;
$data['queueId'] = intval($student['queue_id']);
$data['newStatus'] = ADVANCED_SUBSCRIPTION_QUEUE_STATUS_ADMIN_APPROVED;
$data['profile_completed'] = 100;
$student['acceptUrl'] = $plugin->getQueueUrl($data);
$data['newStatus'] = ADVANCED_SUBSCRIPTION_QUEUE_STATUS_ADMIN_DISAPPROVED;
$student['rejectUrl'] = $plugin->getQueueUrl($data);
$student['complete_name'] = $isWesternNameOrder ? $student['firstname'] . ', ' . $student['lastname'] : $student['lastname'] . ', ' . $student['firstname'];
}
$tpl->assign('session', $sessionArray);
$tpl->assign('students', $studentList['students']);
}
// Assign variables
$tpl->assign('sessionItems', $sessionList);
示例6: isset
/* For licensing terms, see /license.txt */
/**
* Session view
* @package chamilo.session
* @author Julio Montoya <gugli100@gmail.com> Beeznest
*/
use ChamiloSession as Session;
$cidReset = true;
//require_once '../inc/global.inc.php';
if (empty($_GET['session_id'])) {
api_not_allowed();
}
$session_id = isset($_GET['session_id']) ? intval($_GET['session_id']) : null;
$sessionField = new ExtraFieldValue('session');
$valueAllowVisitors = $sessionField->get_values_by_handler_and_field_variable($session_id, 'allow_visitors');
$allowVisitors = $valueAllowVisitors != false;
if (!$allowVisitors) {
// Only users who are logged in can proceed.
api_block_anonymous_users();
}
$this_section = SECTION_COURSES;
$htmlHeadXtra[] = api_get_jqgrid_js();
$course_id = isset($_GET['course_id']) ? intval($_GET['course_id']) : null;
Session::write('id_session', $session_id);
// Clear the exercise session just in case
Session::erase('objExercise');
$userId = api_get_user_id();
$session_info = SessionManager::fetch($session_id);
$session_list = SessionManager::get_sessions_by_coach(api_get_user_id());
$course_list = SessionManager::get_course_list_by_session_id($session_id);
示例7: array
$group = array();
$group[] = $form->createElement('radio', 'subscribe', get_lang('Subscription'), get_lang('Allowed'), 1);
$group[] = $form->createElement('radio', 'subscribe', null, get_lang('Denied'), 0);
$form->addGroup($group, '', get_lang('Subscription'), '<br />');
$group = array();
$group[] = $form->createElement('radio', 'unsubscribe', get_lang('Unsubscription'), get_lang('AllowedToUnsubscribe'), 1);
$group[] = $form->createElement('radio', 'unsubscribe', null, get_lang('NotAllowedToUnsubscribe'), 0);
$form->addGroup($group, '', get_lang('Unsubscription'), '<br />');
$form->addElement('text', 'disk_quota', array(get_lang('CourseQuota'), null, get_lang('MB')));
$form->addRule('disk_quota', get_lang('ThisFieldIsRequired'), 'required');
$form->addRule('disk_quota', get_lang('ThisFieldShouldBeNumeric'), 'numeric');
$specialCourseField = new ExtraField('course');
$specialCourseFieldInfo = $specialCourseField->get_handler_field_info_by_field_variable('special_course');
if (!empty($specialCourseFieldInfo)) {
$specialCourseValue = new ExtraFieldValue('course');
$specialCourseValueInfo = $specialCourseValue->get_values_by_handler_and_field_variable($course_code, 'special_course');
$specialCourseAttributes = array();
if (!empty($specialCourseValueInfo) && $specialCourseValueInfo['value'] == 1) {
$specialCourseAttributes['checked'] = '';
}
$form->addElement('checkbox', 'extra_special_course', array(null, get_lang('AllUsersAreAutomaticallyRegistered')), get_lang('SpecialCourse'), $specialCourseAttributes);
}
//Extra fields
$extra_field = new ExtraField('course');
$extra = $extra_field->addElements($form, $courseId, ['special_course']);
$htmlHeadXtra[] = '
<script>
$(function() {
' . $extra['jquery_ready_content'] . '
});
</script>';
示例8: getSessionInfo
/**
* Get session info
* @param array $sessionId The session ID
* @return array
*/
public function getSessionInfo($sessionId)
{
$entityManager = Database::getManager();
$session = $entityManager->find('ChamiloCoreBundle:Session', $sessionId);
if (empty($session)) {
return [];
}
$item = $this->getItemByProduct($session->getId(), self::PRODUCT_TYPE_SESSION);
if (empty($item)) {
return [];
}
$sessionDates = SessionManager::parseSessionDates(['display_start_date' => $session->getDisplayStartDate(), 'display_end_date' => $session->getDisplayEndDate(), 'access_start_date' => $session->getAccessStartDate(), 'access_end_date' => $session->getAccessEndDate(), 'coach_access_start_date' => $session->getCoachAccessStartDate(), 'coach_access_end_date' => $session->getCoachAccessEndDate()]);
$sessionInfo = ['id' => $session->getId(), 'name' => $session->getName(), 'dates' => $sessionDates, 'courses' => [], 'price' => $item['price'], 'currency' => $item['iso_code'], 'image' => null];
$fieldValue = new ExtraFieldValue('session');
$sessionImage = $fieldValue->get_values_by_handler_and_field_variable($session->getId(), 'image');
if (!empty($sessionImage)) {
$sessionInfo['image'] = api_get_path(WEB_UPLOAD_PATH) . $sessionImage['value'];
}
$sessionCourses = $session->getCourses();
foreach ($sessionCourses as $sessionCourse) {
$course = $sessionCourse->getCourse();
$sessionCourseData = ['title' => $course->getTitle(), 'coaches' => []];
$userCourseSubscriptions = $session->getUserCourseSubscriptionsByStatus($course, Chamilo\CoreBundle\Entity\Session::COACH);
foreach ($userCourseSubscriptions as $userCourseSubscription) {
$user = $userCourseSubscription->getUser();
$sessionCourseData['coaches'][] = $user->getCompleteName();
}
$sessionInfo['courses'][] = $sessionCourseData;
}
return $sessionInfo;
}
示例9: generateProfileEditingURL
/**
* Generate the URL for profile editing
* @return string If the URL is obtained return the drupal_user_id. Otherwise return false
*/
public function generateProfileEditingURL()
{
$userId = api_get_user_id();
$userExtraFieldValue = new ExtraFieldValue('user');
$drupalUserIdData = $userExtraFieldValue->get_values_by_handler_and_field_variable($userId, 'drupal_user_id');
if ($drupalUserIdData === false) {
return false;
}
$drupalUserId = $drupalUserIdData['field_value'];
$url = "{$this->protocol}{$this->domain}/user/{$drupalUserId}/edit";
return $url;
}
示例10: generateProfileEditingURL
/**
* Generate the URL for profile editing for a any user or the current user
* @param int $userId Optional. The user id
* @param boolean $asAdmin Optional. Whether get the URL for the platform admin
* @return string If the URL is obtained return the drupal_user_id. Otherwise return false
*/
public function generateProfileEditingURL($userId = 0, $asAdmin = false)
{
$userId = intval($userId);
if (empty($userId)) {
$userId = api_get_user_id();
}
$userExtraFieldValue = new ExtraFieldValue('user');
$drupalUserIdData = $userExtraFieldValue->get_values_by_handler_and_field_variable($userId, 'drupal_user_id');
// If this is an administrator, allow him to make some changes in
// the Chamilo profile
if ($asAdmin && api_is_platform_admin(true)) {
return api_get_path(WEB_CODE_PATH) . "admin/user_edit.php?user_id={$userId}";
}
// If the user doesn't match a Drupal user, give the normal profile
// link
if ($drupalUserIdData === false) {
return api_get_path(WEB_CODE_PATH) . 'auth/profile.php';
}
// In all other cases, generate a link to the Drupal profile edition
$drupalUserId = $drupalUserIdData['value'];
$url = "{$this->protocol}{$this->domain}/user/{$drupalUserId}/edit";
return $url;
}
示例11: function
Session::write('is_allowed_in_course', $is_allowed_in_course);
Session::write('is_sessionAdmin', $is_sessionAdmin);
}
};
/**
* Deletes the exam_password user extra field *only* to students
* @todo move to the login hook system
* @param Request $request
*/
$afterLogin = function (Request $request) use($app) {
if (isset($app['current_user']) && isset($app['current_user']['user_id']) && $app['current_user']['status'] == STUDENT) {
$extraField = new ExtraField('user');
$extraFieldData = $extraField->get_handler_field_info_by_field_variable('exam_password');
if ($extraFieldData && !empty($extraFieldData)) {
$extraField = new ExtraFieldValue('user');
$extraFieldValue = $extraField->get_values_by_handler_and_field_variable($app['current_user']['user_id'], 'exam_password');
if (!empty($extraFieldValue)) {
$extraField->delete_values_by_handler_and_field_id($app['current_user']['user_id'], $extraFieldValue['id']);
}
}
}
};
/** Removes the cid reset and other session values */
$removeCidReset = function (Request $request) use($app) {
// Deleting course info.
Session::erase('_cid');
Session::erase('_real_cid');
Session::erase('_course');
if (!empty($_SESSION)) {
foreach ($_SESSION as $key => $item) {
if (strpos($key, 'lp_autolunch_') === false) {
示例12: sendPushNotification
/**
* Send the push notifications to MobileMessaging app
* @param array $userIds The IDs of users who will be notified
* @param string $title The notification title
* @param string $content The notification content
* @return int The number of success notifications. Otherwise returns false
*/
public static function sendPushNotification(array $userIds, $title, $content)
{
if (api_get_configuration_value('messaging_allow_send_push_notification') !== 'true') {
return false;
}
$gdcApiKey = api_get_configuration_value('messaging_gdc_api_key');
if ($gdcApiKey === false) {
return false;
}
$content = str_replace(['<br>', '<br/>', '<br />'], "\n", $content);
$content = strip_tags($content);
$content = html_entity_decode($content, ENT_QUOTES);
$gcmRegistrationIds = [];
foreach ($userIds as $userId) {
$extraFieldValue = new ExtraFieldValue('user');
$valueInfo = $extraFieldValue->get_values_by_handler_and_field_variable($userId, self::EXTRA_FIELD_GCM_REGISTRATION);
if (empty($valueInfo)) {
continue;
}
$gcmRegistrationIds[] = $valueInfo['value'];
}
$headers = ['Authorization: key=' . $gdcApiKey, 'Content-Type: application/json'];
$fields = json_encode(['registration_ids' => $gcmRegistrationIds, 'data' => ['title' => $title, 'message' => $content]]);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://gcm-http.googleapis.com/gcm/send');
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_POSTFIELDS, $fields);
$result = curl_exec($ch);
curl_close($ch);
$decodedResult = json_decode($result);
return $decodedResult->success;
}
示例13: getVacancy
/**
* Return the remaining vacancy
* @param $sessionId
* @return bool|int
*/
public function getVacancy($sessionId)
{
if (!empty($sessionId)) {
$extra = new ExtraFieldValue('session');
$var = $extra->get_values_by_handler_and_field_variable($sessionId, 'vacancies');
$vacancy = intval($var['value']);
if (!empty($vacancy)) {
$vacancy -= $this->countQueueByParams(array('sessions' => array($sessionId), 'status' => array(ADVANCED_SUBSCRIPTION_QUEUE_STATUS_ADMIN_APPROVED)));
if ($vacancy >= 0) {
return $vacancy;
} else {
return 0;
}
}
}
return false;
}
示例14: array
$data = array('sessionId' => $queueItem['session_id']);
$data['session'] = api_get_session_info($queueItem['session_id']);
$data['student'] = api_get_user_info($queueItem['student_id']);
$plugin->sendMail($data, ADVANCED_SUBSCRIPTION_ACTION_REMINDER_STUDENT);
break;
default:
break;
}
}
/**
* Remind superiors
*/
// Get recommended number of participants
$sessionRecommendedNumber = array();
foreach ($queueList as $queueItem) {
$row = $sessionExtraFieldValue->get_values_by_handler_and_field_variable($queueItem['session_id'], 'recommended_number_of_participants');
$sessionRecommendedNumber[$queueItem['session_id']] = $row['value'];
}
// Group student by superior and session
$queueBySuperior = array();
foreach ($queueList as $queueItem) {
$queueBySuperior[$queueItem['session_id']][$queueItem['superior_id']][$queueItem['student_id']]['status'] = $queueItem['status'];
}
foreach ($queueBySuperior as $sessionId => $superiorStudents) {
$data = array('sessionId' => $sessionId, 'session' => $sessionInfoList[$sessionId], 'students' => array());
$dataUrl = array('action' => 'confirm', 'sessionId' => $sessionId, 'currentUserId' => 0, 'newStatus' => ADVANCED_SUBSCRIPTION_QUEUE_STATUS_BOSS_APPROVED, 'studentUserId' => 0, 'is_connected' => true, 'profile_completed' => 0);
foreach ($superiorStudents as $superiorId => $students) {
$data['superior'] = api_get_user_info($superiorId);
// Check if superior has at least one student
if (count($students) > 0) {
foreach ($students as $studentId => $studentInfo) {