Ejemplo n.º 1
0
 function view($args)
 {
     $id = array_shift($args);
     $permission = R::load('permission', $id);
     if (!is_numeric($id) && !$permission->getID()) {
         $this->redirect(PACKAGE_URL);
     }
     $allgroups = R::findAll('group');
     foreach ($allgroups as $key => $group) {
         foreach ($permission->sharedGroup as $group_c) {
             if ($group->id == $group_c->id) {
                 $allgroups[$key]->checked = true;
             }
         }
     }
     //		echo $permission->name;exit;
     $view = new G2_TwigView('pages/view');
     $view->permission = $permission;
     $view->allGroups = $allgroups;
     $form = new G2_FormMagic($view->get_render());
     if ($form->is_posted()) {
         $groups = R::loadAll('group', array_keys($form->data()['groups']));
         $permission->sharedGroup = $groups;
         R::store($permission);
         Admin_Alert::add_message("\"{$permission->name}\" permission was updated");
         $this->redirect(PACKAGE_URL);
     }
     echo $form->parse();
 }
Ejemplo n.º 2
0
 public function select($id = null)
 {
     // no id and no other params
     if ($id == null) {
         $items = R::loadAll($this->table, array());
         return $items;
     } else {
         $item = R::load($this->table, $id);
         return $item;
     }
 }
Ejemplo n.º 3
0
 public static function batchFindByIds($ids)
 {
     return $users = R::loadAll('user', $ids);
 }
Ejemplo n.º 4
0
 static function getUserProgress($id = 0, $complete = 0)
 {
     $data = R::duplicate($_SESSION['user']);
     $out = "<div class='col-sm-12'>\r\n            <div class=\"list-group\"><ul style='padding-left:0;'>";
     $out .= "<li class=\"list-group-item active\">";
     if ($id == 0 && $complete == 0) {
         $out .= "<h4 class=\"list-group-item-heading \"><a role='button' href='?ctrl=cabinet&action=GetCabinet' class='btn btn-info back_button'><span class=\"glyphicon glyphicon-arrow-left\" aria-hidden=\"true\"></span></a>В кабинет </h4>";
     }
     if ($complete == 1) {
         $out .= "<h4 class=\"list-group-item-heading \"><a role='button' href='?ctrl=cabinet&action=GetCabinet' class='btn btn-info back_button'><span class=\"glyphicon glyphicon-arrow-left\" aria-hidden=\"true\"></span></a>В кабинет</h4>";
     }
     if ($id != 0) {
         $out .= "<h4 class=\"list-group-item-heading \"><a role='button' href='?ctrl=cabinet&action=GetUserInformation' class='btn btn-info back_button'><span class=\"glyphicon glyphicon-arrow-left\" aria-hidden=\"true\"></span></a>Вернуться к списку</h4>";
     }
     //?ctrl=cabinet&action=GetUserInformation
     $out .= '</li></ul></div>';
     if ($id == 0) {
         $preWisdom = $data->ownInformation_userList;
         $arrayId = array();
         foreach ($preWisdom as $value) {
             if ($complete == 0) {
                 if (is_null($value->status) && is_null($value->education_id) && is_null($value->lesson_id)) {
                     $arrayId[] = $value->information_id;
                 }
             } else {
                 if (!is_null($value->status) && is_null($value->education_id) && is_null($value->lesson_id)) {
                     $arrayId[] = $value->information_id;
                 }
             }
         }
         $wisdom = R::loadAll('information', $arrayId);
     } else {
         // проверяем записан ли пользователь на данный УМ
         $userInfo = $data->ownInformation_userList;
         foreach ($userInfo as $value) {
             if ($value->information_id == $id) {
                 $wisdom = R::findAll('information', 'where id = ?', [$id]);
             }
         }
     }
     $typeMenu = '6';
     $typeMenu1 = '';
     if ($complete == 0) {
         if ($id === 0) {
             switch ($_SESSION['user']->status) {
                 case "student":
                     $typeMenu = 3;
                     $typeMenu1 = '';
                     break;
                 case "teacher":
                     $typeMenu = 7;
                     $typeMenu1 = 8;
                     break;
                 case "moderator":
                     $typeMenu = 4;
                     //                        $typeMenu1=8;
                     break;
                 case "admin":
                     $typeMenu = 9;
                     $typeMenu1 = 8;
                     break;
             }
         }
     }
     $bigMenu = new menu("SELECT menu_item.*\r\n        FROM  `menu` ,  `menu_item`\r\n        WHERE menu_item.menu_id = ?\r\n       AND menu.menu_id = menu_item.menu_id", [$typeMenu]);
     $bigMenu->ul_tpl = "<ul class=\"nav nav-tabs nav-justified menu_heavy\">";
     if (!empty($wisdom)) {
         foreach ($wisdom as $item) {
             $typeData = wisdom::getType($item);
             if ($typeData[3]->id == 6 && $id != 0) {
                 header('Location:?ctrl=wisdom&action=GetWisdomById&id=' . $id);
             }
             if ($id != 0) {
                 $itemClone = '';
                 if ($typeData[3]->id != 1) {
                     $itemClone = $item;
                 }
                 $modul = self::getInfoEducation($item, $itemClone);
             }
             if ($_SESSION['user']->status !== 'author') {
                 $autor = wisdom::getAuthorName($item->id);
                 $author = "<br><a  href='?ctrl=cabinet&action=UserInfo&id=" . $autor['id'] . "'>" . $autor['login'] . "</a> |\r\n                    <a  href='?ctrl=cabinet&action=UserInfo&id=" . $autor['id'] . "'> " . $autor['surname'] . " " . $autor['name'] . " " . $autor['andername'] . " </a> ";
             }
             $short_description = !empty($item->shortdescription) ? $item->shortdescription : 'Краткое описание отсутствует';
             $out .= "<li class=\"list-group-item\">\r\n                <ol class=\"breadcrumb\">\r\n                    <li><a href=\"?ctrl=wisdom&action=WisdomType&type=" . $typeData[3]->id . "&page=1\" > " . $typeData[3]->name . "</a></li>\r\n                    <li><a href=\"?ctrl=wisdom&action=WisdomType&type=" . $typeData[3]->id . "&subtype=" . $typeData[2]->id . "&page=1\" > " . $typeData[2]->name . "</a></li>\r\n                    <li><a href=\"?ctrl=wisdom&action=WisdomType&type=" . $typeData[3]->id . "&subtype=" . $typeData[2]->id . "&category=" . $typeData[1]->id . "&page=1\" > " . $typeData[1]->name . "</a></li>\r\n                    <li><a href=\"?ctrl=wisdom&action=WisdomType&type=" . $typeData[3]->id . "&subtype=" . $typeData[2]->id . "&category=" . $typeData[1]->id . "&subcategory=" . $typeData[0]->id . "&page=1\" > " . $typeData[0]->name . "</a></li>\r\n\r\n                </ol>\r\n            <h4 class=\"list-group-item-heading\"><a href='?ctrl=wisdom&action=GetWisdomById&id=" . $item->id . "'>" . $item->name . "</a></h4><h5>" . $author . "</h5>\r\n    <p class=\"list-group-item-text\">" . $short_description . "</p>" . $modul;
             if ($id === 0) {
                 $bigMenu->li_tpl = "<li  class=\"dropdown primary\"  role=\"presentation\"><a data-toggle=\"tooltip\" href='%s" . $item->id . "'>%s %s</a>%s</li>";
                 $out .= $bigMenu->render();
             }
             if ($_SESSION['user']->status !== 'student' && !empty($_SESSION['user']->status) && $id != 0) {
                 $out .= "<a role='button' href='?ctrl=teacher&action=AddModul&id=" . $id . "' class='btn btn-info btn-block'>Добавить модуль</a>";
             }
             $out .= "</li>";
             $out .= "</ul></div></div></div>";
         }
     }
     if (empty($wisdom)) {
         $out .= "Вы не подписанны на данный учебный материал";
     }
     return $out;
 }
Ejemplo n.º 5
0
 /**
  * Test batch alias loadAll.
  * 
  * @return void
  */
 public function testBatchAliasLoadAll()
 {
     $ids = R::storeAll(R::dispense('page', 2));
     $pages = R::loadAll('page', $ids);
     asrt(is_array($pages), true);
     asrt(count($pages), 2);
     asrt($pages[$ids[0]] instanceof RedBean_OODBBean, true);
 }