Пример #1
0
 public function userGroupsDeleteAction($rcid = false)
 {
     $views = $this->getView();
     $data = $this->getRequest();
     $members = MembersManage::instance();
     $app = $members->getCurrentSession();
     if (!$app) {
         exit;
     }
     $control = new AdminUserManage();
     if ($rcid) {
         $deleteId = $control->deleteUserRole($rcid);
     }
     exit;
 }
Пример #2
0
 public function lessonPostAction($cid = false, $action = 'base')
 {
     $views = $this->getView();
     $data = $this->getRequest();
     $rest = Restful::instance();
     $members = MembersManage::instance();
     $app = $members->getCurrentSession();
     $courseControl = AdminCourseManage::instance();
     $users = new AdminUserManage();
     $course = $courseControl->getCourseRow(array('course.cid' => $cid));
     $user = $category = $menus = array();
     if ($course) {
         $user = $users->getUserForId($course['uid']);
     }
     $image = new ImagesManage();
     if ($action and $tmp = explode("?", $action)) {
         $action = $tmp[0];
     }
     if ($data->isPost()) {
         switch ($action) {
             case 'base':
                 $courseControl->updateCourse($cid, $data->getPost());
                 break;
             case 'chapter':
                 $aid = $courseControl->createArticle($cid, $data->getPost());
                 break;
             case 'sort':
                 $action = 'chapter';
                 $page = $data->getQuery('page') ? $data->getQuery('page') - 1 : 0;
                 $limit = $data->getQuery('limit') ? $data->getQuery('limit') : 10;
                 $menus = $data->getPost('ids');
                 $menulist = array();
                 foreach ($menus as $key => $value) {
                     $menu_id = explode("-", $value);
                     $menulist[$key + ($page * $limit + 1)] = intval($menu_id[2]);
                 }
                 $courseControl->updateChapterSort($cid, $menulist);
                 exit;
                 break;
             case 'picture':
                 $file = $data->getFiles('picture');
                 $path = $image->save($file, $user['id'], 'tmp');
                 $scaled = getimagesize(ImagesManage::getRealPath($path));
                 if ($scaled[0] >= 1200 or $scaled[1] >= 1200) {
                     MessageManage::createResponse($views, '上传格式错误', '上传图片格式错误,图片长宽小于 1200px。');
                     ImagesManage::unlink($path);
                 } else {
                     if (!ImagesManage::hasImageType($scaled[2], true)) {
                         MessageManage::createResponse($views, '上传格式错误', '上传图片格式错误,请上传jpg, gif, png格式的文件。');
                     }
                 }
                 if ($path) {
                     header('Location: /lesson/' . $cid . '/manage/upload' . '?file=' . $path);
                     exit;
                 }
                 break;
             case 'upload':
                 $action = 'picture-crop';
                 if ($file = $data->getQuery('file')) {
                     $avatar_id = $image->saveImagesCourseFromCut($data->getQuery('file'), $data->getPost('x'), $data->getPost('y'), $data->getPost('width'), $data->getPost('height'), $user['id'], $cid, 1, true);
                     if ($avatar_id) {
                         $courseControl->updateCourse($cid, array('cover' => $avatar_id));
                         ImagesManage::unlink(ImagesManage::getRealPath($file));
                     }
                     header("Location: /lesson/{$cid}/manage/picture");
                     exit;
                 }
                 break;
             default:
                 # code...
                 break;
         }
         $course = $courseControl->getCourseRow(array('course.cid' => $cid));
     }
     switch ($action) {
         case 'base':
             $category = $courseControl->getCategory();
             $views->assign('categories', $category);
             break;
         case 'chapter':
             $page = $data->getQuery('page') ? $data->getQuery('page') : 1;
             $limit = $data->getQuery('limit') ? $data->getQuery('limit') : 10;
             $menus = $courseControl->getChapterForCID($cid, $limit, $page);
             $pages = new pagesControl("lesson/{$cid}/manage/chapter", $courseControl->getChapterCountForCID($cid), $limit, $page, true);
             $views->assign('menus', $menus);
             $views->assign('paginator', $pages);
             break;
         case 'picture':
             $courseImage = $image->getImagesCourseForCID($cid, 1);
             $coverPath = isset($courseImage['path']) ? ImagesManage::getRelativeImage($courseImage['path']) : false;
             $views->assign('image', $coverPath);
             break;
         case 'upload':
             $action = 'picture-crop';
             if ($file = $data->getQuery('file')) {
                 $views->assign('scaled', ImagesManage::getImageSizeForPath($file, 480));
                 $views->assign('file', ImagesManage::getRelativeImage($file));
             }
             break;
         default:
             # code...
             break;
     }
     $views->assign('title', '');
     $views->assign('app', $app);
     $views->assign('course', $course);
     $views->assign('user', $user);
     $views->display('index/lessonmanage/' . $action . '.html.twig');
 }