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


PHP CourseManager::separateUsersGroups方法代码示例

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


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

示例1: saveInvitations

 /**
  * This function saves all the invitations of course users and additional users in the database
  * and sends the invitations by email
  *
  * @param	array	Users array can be both a list of course uids AND a list of additional emailaddresses
  * @param 	string	Title of the invitation, used as the title of the mail
  * @param 	string	Text of the invitation, used as the text of the mail.
  * 				 The text has to contain a **link** string or this will automatically be added to the end
  *
  * @author Patrick Cool <patrick.cool@UGent.be>, Ghent University
  * @author Julio Montoya - Adding auto-generated link support
  * @version January 2007
  *
  */
 public static function saveInvitations($users_array, $invitation_title, $invitation_text, $reminder = 0, $sendmail = 0, $remindUnAnswered = 0)
 {
     if (!is_array($users_array)) {
         // Should not happen
         return 0;
     }
     // Getting the survey information
     $survey_data = SurveyManager::get_survey($_GET['survey_id']);
     $survey_invitations = SurveyUtil::get_invitations($survey_data['survey_code']);
     $already_invited = SurveyUtil::get_invited_users($survey_data['code']);
     // Remind unanswered is a special version of remind all reminder
     $exclude_users = array();
     if ($remindUnAnswered == 1) {
         // Remind only unanswered users
         $reminder = 1;
         $exclude_users = SurveyManager::get_people_who_filled_survey($_GET['survey_id']);
     }
     $counter = 0;
     // Nr of invitations "sent" (if sendmail option)
     $course_id = api_get_course_int_id();
     $session_id = api_get_session_id();
     $result = CourseManager::separateUsersGroups($users_array);
     $groupList = $result['groups'];
     $users_array = $result['users'];
     foreach ($groupList as $groupId) {
         $userGroupList = GroupManager::getStudents($groupId);
         $userGroupIdList = array_column($userGroupList, 'user_id');
         $users_array = array_merge($users_array, $userGroupIdList);
         $params = array('c_id' => $course_id, 'session_id' => $session_id, 'group_id' => $groupId, 'survey_code' => $survey_data['code']);
         $invitationExists = self::invitationExists($course_id, $session_id, $groupId, $survey_data['code']);
         if (empty($invitationExists)) {
             self::save_invitation($params);
         }
     }
     $users_array = array_unique($users_array);
     foreach ($users_array as $key => $value) {
         if (!isset($value) || $value == '') {
             continue;
         }
         // Skip user if reminding only unanswered people
         if (in_array($value, $exclude_users)) {
             continue;
         }
         // Get the unique invitation code if we already have it
         if ($reminder == 1 && array_key_exists($value, $survey_invitations)) {
             $invitation_code = $survey_invitations[$value]['invitation_code'];
         } else {
             $invitation_code = md5($value . microtime());
         }
         $new_user = false;
         // User not already invited
         // Store the invitation if user_id not in $already_invited['course_users'] OR email is not in $already_invited['additional_users']
         $addit_users_array = isset($already_invited['additional_users']) && !empty($already_invited['additional_users']) ? explode(';', $already_invited['additional_users']) : array();
         $my_alredy_invited = $already_invited['course_users'] == null ? array() : $already_invited['course_users'];
         if (is_numeric($value) && !in_array($value, $my_alredy_invited) || !is_numeric($value) && !in_array($value, $addit_users_array)) {
             $new_user = true;
             if (!array_key_exists($value, $survey_invitations)) {
                 $params = array('c_id' => $course_id, 'session_id' => $session_id, 'user' => $value, 'survey_code' => $survey_data['code'], 'invitation_code' => $invitation_code, 'invitation_date' => api_get_utc_datetime());
                 self::save_invitation($params);
             }
         }
         // Send the email if checkboxed
         if (($new_user || $reminder == 1) && $sendmail != 0) {
             // Make a change for absolute url
             if (isset($invitation_text)) {
                 $invitation_text = api_html_entity_decode($invitation_text, ENT_QUOTES);
                 $invitation_text = str_replace('src="../../', 'src="' . api_get_path(WEB_PATH), $invitation_text);
                 $invitation_text = trim(stripslashes($invitation_text));
             }
             SurveyUtil::send_invitation_mail($value, $invitation_code, $invitation_title, $invitation_text);
             $counter++;
         }
     }
     return $counter;
     // Number of invitations sent
 }
开发者ID:jloguercio,项目名称:chamilo-lms,代码行数:90,代码来源:survey.lib.php

示例2: edit_announcement

 /**
  * This function stores the announcement item in the announcement table
  * and updates the item_property table
  *
  * @param int 	id of the announcement
  * @param string email
  * @param string content
  * @param array 	users that will receive the announcement
  * @param mixed 	attachment
  * @param string file comment
  */
 public static function edit_announcement($id, $emailTitle, $newContent, $to, $file = array(), $file_comment = '', $sendToUsersInSession = false)
 {
     $_course = api_get_course_info();
     $course_id = api_get_course_int_id();
     $tbl_item_property = Database::get_course_table(TABLE_ITEM_PROPERTY);
     $tbl_announcement = Database::get_course_table(TABLE_ANNOUNCEMENT);
     $id = intval($id);
     $params = ['title' => $emailTitle, 'content' => $newContent];
     Database::update($tbl_announcement, $params, ['c_id = ? AND id = ?' => [$course_id, $id]]);
     // save attachment file
     $row_attach = self::get_attachment($id);
     $id_attach = 0;
     if ($row_attach) {
         $id_attach = intval($row_attach['id']);
     }
     if (!empty($file)) {
         if (empty($id_attach)) {
             self::add_announcement_attachment_file($id, $file_comment, $file);
         } else {
             self::edit_announcement_attachment_file($id_attach, $file, $file_comment);
         }
     }
     // we remove everything from item_property for this
     $sql = "DELETE FROM {$tbl_item_property}\n                WHERE c_id = {$course_id} AND ref='{$id}' AND tool='announcement'";
     Database::query($sql);
     if ($sendToUsersInSession) {
         self::addAnnouncementToAllUsersInSessions($id);
     }
     // store in item_property (first the groups, then the users
     if (!is_null($to)) {
         // !is_null($to): when no user is selected we send it to everyone
         $send_to = CourseManager::separateUsersGroups($to);
         // storing the selected groups
         if (is_array($send_to['groups'])) {
             foreach ($send_to['groups'] as $group) {
                 api_item_property_update($_course, TOOL_ANNOUNCEMENT, $id, "AnnouncementUpdated", api_get_user_id(), $group);
             }
         }
         // storing the selected users
         if (is_array($send_to['users'])) {
             foreach ($send_to['users'] as $user) {
                 api_item_property_update($_course, TOOL_ANNOUNCEMENT, $id, "AnnouncementUpdated", api_get_user_id(), 0, $user);
             }
         }
     } else {
         // the message is sent to everyone, so we set the group to 0
         api_item_property_update($_course, TOOL_ANNOUNCEMENT, $id, "AnnouncementUpdated", api_get_user_id(), '0');
     }
 }
开发者ID:secuencia24,项目名称:chamilo-lms,代码行数:60,代码来源:AnnouncementManager.php


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