/**
  * @todo 当用户拥有大量的课程老师角色时,这个方法效率是有就有问题咯!鉴于短期内用户不会拥有大量的课程老师角色,先这么做着。
  */
 public function cancelTeacherInAllCourses($userId)
 {
     $count = $this->getMemberDao()->findMemberCountByUserIdAndRole($userId, 'teacher', false);
     $members = $this->getMemberDao()->findMembersByUserIdAndRole($userId, 'teacher', 0, $count, false);
     foreach ($members as $member) {
         $course = $this->getCourse($member['courseId']);
         $this->getMemberDao()->deleteMember($member['id']);
         $fields = array('teacherIds' => array_diff($course['teacherIds'], array($member['userId'])));
         $this->getCourseDao()->updateCourse($member['courseId'], CourseSerialize::serialize($fields));
     }
     $this->getLogService()->info('course', 'cancel_teachers_all', "取消用户#{$userId}所有的课程老师角色");
 }
 protected function copyCourse($course, $link = false)
 {
     $fields = ArrayToolkit::parts($course, array('coinPrice', 'originCoinPrice', 'price', 'originPrice', 'title', 'status', 'subtitle', 'type', 'maxStudentNum', 'price', 'coinPrice', 'expiryDay', 'serializeMode', 'lessonNum', 'giveCredit', 'vipLevelId', 'categoryId', 'tags', 'smallPicture', 'middlePicture', 'largePicture', 'about', 'teacherIds', 'goals', 'audiences', 'userId', 'tryLookTime', 'tryLookable'));
     $fields['createdTime'] = time();
     if ($link) {
         $fields['status'] = empty($fields['status']) ? 'draft' : $fields['status'];
         $fields['parentId'] = $course['id'];
         $fields['locked'] = 1;
     } else {
         $fields['status'] = 'draft';
     }
     $fields["coinPrice"] = $fields["originCoinPrice"];
     $fields["price"] = $fields["originPrice"];
     return $this->getCourseDao()->addCourse(CourseSerialize::serialize($fields));
 }