本文整理汇总了PHP中UserGroup::subscribe_users_to_usergroup方法的典型用法代码示例。如果您正苦于以下问题:PHP UserGroup::subscribe_users_to_usergroup方法的具体用法?PHP UserGroup::subscribe_users_to_usergroup怎么用?PHP UserGroup::subscribe_users_to_usergroup使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UserGroup
的用法示例。
在下文中一共展示了UserGroup::subscribe_users_to_usergroup方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: save_data
/**
* Save imported class data to database
*
* @param $classes
*
* @return int
*/
function save_data($classes)
{
$count = 0;
$usergroup = new UserGroup();
foreach ($classes as $index => $class) {
$usersToAdd = isset($class['users']) ? $class['users'] : null;
unset($class['users']);
$id = $usergroup->save($class);
if ($id) {
if (!empty($usersToAdd)) {
$usersToAddList = explode(',', $usersToAdd);
$userIdList = array();
foreach ($usersToAddList as $username) {
$userInfo = api_get_user_info_from_username($username);
$userIdList[] = $userInfo['user_id'];
}
if (!empty($userIdList)) {
$usergroup->subscribe_users_to_usergroup($id, $userIdList, false);
}
}
$count++;
}
}
return $count;
}
示例2: updateUsers
/**
* Update users from the imported data
* @param array $users List of users
* @return void
* @uses global variable $inserted_in_course, which returns the list of courses the user was inserted in
*/
function updateUsers($users)
{
global $insertedIn_course;
// Not all scripts declare the $inserted_in_course array (although they should).
if (!isset($inserted_in_course)) {
$inserted_in_course = array();
}
$usergroup = new UserGroup();
$send_mail = $_POST['sendMail'] ? true : false;
if (is_array($users)) {
foreach ($users as $user) {
$user = complete_missing_data($user);
$user['Status'] = api_status_key($user['Status']);
$userName = $user['UserName'];
$userInfo = api_get_user_info_from_username($userName);
$user_id = $userInfo['user_id'];
if ($user_id == 0) {
return false;
}
$firstName = isset($user['FirstName']) ? $user['FirstName'] : $userInfo['firstname'];
$lastName = isset($user['LastName']) ? $user['LastName'] : $userInfo['lastname'];
$userName = isset($user['NewUserName']) ? $user['NewUserName'] : $userInfo['username'];
$password = isset($user['Password']) ? $user['Password'] : $userInfo['password'];
$authSource = isset($user['AuthSource']) ? $user['AuthSource'] : $userInfo['auth_source'];
$email = isset($user['Email']) ? $user['Email'] : $userInfo['email'];
$status = isset($user['Status']) ? $user['Status'] : $userInfo['status'];
$officialCode = isset($user['OfficialCode']) ? $user['OfficialCode'] : $userInfo['official_code'];
$phone = isset($user['PhoneNumber']) ? $user['PhoneNumber'] : $userInfo['phone'];
$pictureUrl = isset($user['PictureUri']) ? $user['PictureUri'] : $userInfo['picture_uri'];
$expirationDate = isset($user['ExpiryDate']) ? $user['ExpiryDate'] : $userInfo['expiration_date'];
$active = isset($user['Active']) ? $user['Active'] : $userInfo['active'];
$creatorId = $userInfo['creator_id'];
$hrDeptId = $userInfo['hr_dept_id'];
$language = isset($user['Language']) ? $user['Language'] : $userInfo['language'];
$sendEmail = isset($user['SendEmail']) ? $user['SendEmail'] : $userInfo['language'];
$userUpdated = UserManager::update_user($user_id, $firstName, $lastName, $userName, $password, $authSource, $email, $status, $officialCode, $phone, $pictureUrl, $expirationDate, $active, $creatorId, $hrDeptId, null, $language, '', '', '');
if (!is_array($user['Courses']) && !empty($user['Courses'])) {
$user['Courses'] = array($user['Courses']);
}
if (is_array($user['Courses'])) {
foreach ($user['Courses'] as $course) {
if (CourseManager::course_exists($course)) {
CourseManager::subscribe_user($user_id, $course, $user['Status']);
$course_info = CourseManager::get_course_information($course);
$inserted_in_course[$course] = $course_info['title'];
}
}
}
if (!empty($user['ClassId'])) {
$classId = explode('|', trim($user['ClassId']));
foreach ($classId as $id) {
$usergroup->subscribe_users_to_usergroup($id, array($user_id), false);
}
}
// Saving extra fields.
global $extra_fields;
// We are sure that the extra field exists.
foreach ($extra_fields as $extras) {
if (isset($user[$extras[1]])) {
$key = $extras[1];
$value = $user[$extras[1]];
UserManager::update_extra_field_value($user_id, $key, $value);
}
}
}
}
}
示例3: save_data
/**
* Saves imported data.
*/
function save_data($users_classes, $deleteUsersNotInList = false)
{
global $purification_option_for_usernames;
// Table definitions.
$user_table = Database::get_main_table(TABLE_MAIN_USER);
$usergroup = new UserGroup();
// Data parsing: purification + conversion (UserName, ClassName) --> (user_is, class_id)
$csv_data = array();
if (!empty($users_classes)) {
foreach ($users_classes as $user_class) {
$sql1 = "SELECT user_id FROM {$user_table}\n WHERE username = '" . Database::escape_string(UserManager::purify_username($user_class['UserName'], $purification_option_for_usernames)) . "'";
$res1 = Database::query($sql1);
$obj1 = Database::fetch_object($res1);
$usergroup = new UserGroup();
$id = $usergroup->get_id_by_name($user_class['ClassName']);
if ($obj1 && $id) {
$csv_data[$id]['user_list'][] = $obj1->user_id;
$csv_data[$id]['user_list_name'][] = $user_class['UserName'];
$csv_data[$id]['class_name'] = $user_class['ClassName'];
}
}
}
// Logic for processing the request (data + UI options).
$message = null;
if (!empty($csv_data)) {
foreach ($csv_data as $class_id => $user_data) {
$user_list = $user_data['user_list'];
$class_name = $user_data['class_name'];
$user_list_name = $user_data['user_list_name'];
$usergroup->subscribe_users_to_usergroup($class_id, $user_list, $deleteUsersNotInList);
$message .= Display::return_message(get_lang('Class') . ': ' . $class_name . '<br />', 'normal', false);
$message .= Display::return_message(get_lang('Users') . ': ' . implode(', ', $user_list_name));
}
}
return $message;
}
示例4: save_data
/**
* Save the imported data
* @param array $users List of users
* @return void
* @uses global variable $inserted_in_course, which returns the list of courses the user was inserted in
*/
function save_data($users)
{
global $inserted_in_course;
// Not all scripts declare the $inserted_in_course array (although they should).
if (!isset($inserted_in_course)) {
$inserted_in_course = array();
}
$usergroup = new UserGroup();
$send_mail = $_POST['sendMail'] ? true : false;
if (is_array($users)) {
foreach ($users as $user) {
$user = complete_missing_data($user);
$user['Status'] = api_status_key($user['Status']);
$user_id = UserManager::create_user($user['FirstName'], $user['LastName'], $user['Status'], $user['Email'], $user['UserName'], $user['Password'], $user['OfficialCode'], $user['language'], $user['PhoneNumber'], '', $user['AuthSource'], $user['ExpiryDate'], 1, 0, null, null, $send_mail);
if (!is_array($user['Courses']) && !empty($user['Courses'])) {
$user['Courses'] = array($user['Courses']);
}
if (is_array($user['Courses'])) {
foreach ($user['Courses'] as $course) {
if (CourseManager::course_exists($course)) {
CourseManager::subscribe_user($user_id, $course, $user['Status']);
$course_info = CourseManager::get_course_information($course);
$inserted_in_course[$course] = $course_info['title'];
}
}
}
if (!empty($user['ClassId'])) {
$classId = explode('|', trim($user['ClassId']));
foreach ($classId as $id) {
$usergroup->subscribe_users_to_usergroup($id, array($user_id), false);
}
}
// Saving extra fields.
global $extra_fields;
// We are sure that the extra field exists.
foreach ($extra_fields as $extras) {
if (isset($user[$extras[1]])) {
$key = $extras[1];
$value = $user[$extras[1]];
UserManager::update_extra_field_value($user_id, $key, $value);
}
}
}
}
}
示例5: UserGroup
}
$usergroup = new UserGroup();
if (empty($id)) {
api_not_allowed(true);
}
$first_letter_user = '';
if (isset($_POST['form_sent']) && $_POST['form_sent']) {
$form_sent = $_POST['form_sent'];
$elements_posted = isset($_POST['elements_in_name']) ? $_POST['elements_in_name'] : null;
$first_letter_user = $_POST['firstLetterUser'];
if (!is_array($elements_posted)) {
$elements_posted = array();
}
if ($form_sent == 1) {
//added a parameter to send emails when registering a user
$usergroup->subscribe_users_to_usergroup($id, $elements_posted, true, $relation);
header('Location: usergroups.php');
exit;
}
}
if (isset($_GET['action']) && $_GET['action'] == 'export') {
$groupInfo = $usergroup->get($id);
$users = $usergroup->getUserListByUserGroup($id);
if (!empty($users)) {
$data = array(array('UserName', 'ClassName'));
foreach ($users as $user) {
$data[] = array($user['username'], $groupInfo['name']);
}
$filename = 'export_user_class_' . api_get_local_time();
Export::arrayToCsv($data, $filename);
exit;
示例6: array
$link_add_type_unique = Display::return_icon('single.gif') . get_lang('SessionAddTypeUnique');
$link_add_type_multiple = '<a href="' . api_get_self() . '?add_type=multiple">' . Display::return_icon('multiple.gif') . get_lang('SessionAddTypeMultiple') . '</a>';
}
echo '<div class="actions">';
echo '<a href="usergroups.php">' . Display::return_icon('back.png', get_lang('Back'), array(), ICON_SIZE_MEDIUM) . '</a>';
echo '<a href="usergroup_user_import.php">' . Display::return_icon('import_csv.png', get_lang('Import'), array(), ICON_SIZE_MEDIUM) . '</a>';
echo '</div>';
$form = new FormValidator('add_users_to_usergroup', 'post', api_get_self() . '?id=' . $id);
$form->addElement('hidden', 'id', $id);
$form->addElement('hidden', 'form_sent', '1');
$form->addElement('hidden', 'add_type', null);
$userList = array();
if (!empty($complete_user_list)) {
foreach ($complete_user_list as $user) {
$userList[$user['user_id']] = api_get_person_name($user['firstname'], $user['lastname']);
}
}
$form->addDoubleMultipleSelect('user_groups', get_lang('GroupTutors'), $userList);
$form->addElement('checkbox', 'user_with_any_group', null, get_lang('UsersRegisteredInAnyGroup'), array('onchange' => 'checked_in_no_group(this.checked);'));
$form->addElement('button', 'submit', get_lang('SubscribeUsersToClass'));
$defaults = array('user_groups' => array_keys($elements_in));
$form->setDefaults($defaults);
$form->display();
if ($form->validate()) {
$values = $form->getSubmitValues();
$users = $values['user_groups'];
$usergroup->subscribe_users_to_usergroup($id, $users);
header('Location: usergroups.php');
exit;
}
Display::display_footer();
示例7: UserGroup
}
}
}
$usergroup = new UserGroup();
$id = intval($_GET['id']);
$first_letter_user = '';
if (isset($_POST['form_sent']) && $_POST['form_sent']) {
$form_sent = $_POST['form_sent'];
$elements_posted = $_POST['elements_in_name'];
$first_letter_user = $_POST['firstLetterUser'];
if (!is_array($elements_posted)) {
$elements_posted = array();
}
if ($form_sent == 1) {
//added a parameter to send emails when registering a user
$usergroup->subscribe_users_to_usergroup($id, $elements_posted);
header('Location: usergroups.php');
exit;
}
}
//Filter by Extra Fields
$use_extra_fields = false;
if (is_array($extra_field_list)) {
if (is_array($new_field_list) && count($new_field_list) > 0) {
foreach ($new_field_list as $new_field) {
$varname = 'field_' . $new_field['variable'];
if (UserManager::is_extra_field_available($new_field['variable'])) {
if (isset($_POST[$varname]) && $_POST[$varname] != '0') {
$use_extra_fields = true;
$extra_field_result[] = UserManager::get_extra_user_data_by_value($new_field['variable'], $_POST[$varname]);
}