public static function getMenu() { $name = null; $user = null; if (CUser::isAuthenticated()) { $name = CUser::getName(); $user = "******"; } $hem = "<li>\n <a href='index.php?p=hem'>Hem</a>\n <ul>\n <li><a href='login.php'>Logga in (webbredaktör)</a></li>\n </ul>\n </li>"; if (CUser::isAuthenticated()) { $hem = "<li>\n <a href='index.php?p=hem'>Hem</a>\n </li>"; } $html = "<nav id='menu-wrap'><ul id=\"menu\">\n {$hem}\n <li>\n <a href=\"#\">Klubben</a>\n <ul>\n <li>\n <a href=\"#\">Bli medlem</a>\n <ul>\n <li><a href='medlem.php?p=klubben'>Anmälningsformulär</a></li>\n </ul>\n </li>\n <li><a href='page.php?p=2'>Styrelse</a></li>\n <li><a href=\"#\">Information</a></li>\n <li><a href=\"#\">Hitta till oss</a></li>\n </ul>\n </li>\n <li><a href='page.php?p=1'>Kurser</a></li>\n <li>\n <a href=\"#\">Tävlingar</a>\n <ul>\n <li><a href=\"#\">Tävlingsekipage</a></li>\n <li><a href=\"#\">Månadscupen</a></li>\n </ul>\n </li>\n <li><a href='calender.php'>Kalender</a></li>\n <li><a href='blog.php'>Blogg</a></li>\n <li><a href='galleri.php'>Galleri</a></li>\n {$user}\n </ul></nav>"; return $html; }
public function actionView() { $set = new CRecordSet(false); $query = new CQuery(); $set->setQuery($query); $query->select("DISTINCT subject.*")->from(TABLE_DISCIPLINES . " as subject")->innerJoin(TABLE_LIBRARY_DOCUMENTS . " as doc", "doc.subj_id = subject.id")->condition("doc.user_id = " . CRequest::getFilter("author"))->order("subject.name asc"); $selectedUser = null; $usersQuery = new CQuery(); $usersQuery->select("user.*")->from(TABLE_USERS . " as user")->order("user.fio asc")->innerJoin(TABLE_LIBRARY_DOCUMENTS . " as doc", "user.id = doc.user_id"); // фильтр по автору if (!is_null(CRequest::getFilter("author"))) { $selectedUser = CRequest::getFilter("author"); $author = CRequest::getFilter("author"); } else { $query->condition("doc.user_id = " . CSession::getCurrentUser()->getId()); $author = CSession::getCurrentUser()->getId(); } $users = array(); foreach ($usersQuery->execute()->getItems() as $ar) { $user = new CUser(new CActiveRecord($ar)); $users[$user->getId()] = $user->getName(); } $folders = new CArrayList(); foreach ($set->getPaginated()->getItems() as $ar) { $folder = new CLibraryFolder(new CTerm($ar)); $folders->add($folders->getCount(), $folder); } $this->addActionsMenuItem(array(array("title" => "Назад", "link" => WEB_ROOT . "_modules/_library/index.php", "icon" => "actions/edit-undo.png"))); if (CSession::isAuth() and (CSession::getCurrentUser()->getLevelForCurrentTask() == ACCESS_LEVEL_WRITE_OWN_ONLY or CSession::getCurrentUser()->getLevelForCurrentTask() == ACCESS_LEVEL_WRITE_ALL)) { $this->addActionsMenuItem(array(array("title" => "Добавить предмет", "link" => WEB_ROOT . "_modules/_library/index.php?action=addDocument&filter=author:" . $author, "icon" => "actions/list-add.png"))); } $this->addCSSInclude(JQUERY_UI_CSS_PATH); $this->addJSInclude(JQUERY_UI_JS_PATH); $this->setData("folders", $folders); $this->setData("users", $users); $this->setData("selectedUser", $selectedUser); $this->setData("author", $author); $this->setData("paginator", $set->getPaginator()); $this->renderView("_library/view.tpl"); }
/** * This is a Orange pagecontroller. * */ // Include the essential config-file which also creates the $Orange variable with its defaults. include __DIR__ . '/config.php'; $Orange['title'] = "Startsida"; $message = ""; if (isset($_POST['username']) && isset($_POST['password'])) { $username = $_POST['username']; $password = $_POST['password']; $user = new CUser(); $res = $user->login($username, $password); if ($res) { $user->setSessionVariablesAtLogin($res); $name = $user->getName(); header('Location: login.php'); } else { $message = "Wrong username or password"; } } if (CUser::isAuthenticated()) { $message = "<p>Inloggad som: " . CUser::getName(); $Orange['main'] = <<<EOD <h1></h1> <fieldset> <legend>Login</legend> <p>{$message}</p> </fieldset> </form>
<?php /** * This is a Branax pagecontroller. * */ // Include the essential config-file which also creates the $branax variable with its defaults. include __DIR__ . '/config.php'; // Create the user object $user = new CUser($branax['database']); // Check if user is authenticated. $output = $user->isAuthenticated() ? "Du är inloggad som: {$user->getAcronym()} ({$user->getName()})" : "Du är INTE inloggad."; // Check if user and password is okey and login the user if (isset($_POST['login'])) { $user->login($_POST['acronym'], $_POST['password']); header('Location: user_status.php'); } // Do it and store it all in variables in the Branax container. $branax['title'] = "Login"; $branax['main'] = <<<EOD <h1>{$branax['title']}</h1> <form method=post> <fieldset> <legend>Login</legend> <p><label>Användare:<br/><input type='text' name='acronym' value=''/></label></p> <p><label>Lösenord:<br/><input type='password' name='password' value=''/></label></p> <p><input type='submit' name='login' value='Login'/></p> <p><a href='user_logout.php'>Logout</a></p> <p><a href='user_register.php'>Skapa ny användare</a></p> <output><b>{$output}</b></output>
<?php /** * This is a Branax pagecontroller. * */ // Include the essential config-file which also creates the $branax variable with its defaults. include __DIR__ . '/config.php'; // Create the user object $user = new CUser($branax['database']); // Check if logged in user $admin = $user->isAdmin() ? 'med administratörsrättigheter' : null; $output = $user->isUser() ? "Du är inloggad som {$user->getAcronym()} ({$user->getName()}) {$admin}" : "Du är INTE inloggad."; // Do it and store it all in variables in the Anax container. $branax['title'] = "User status"; $branax['main'] = <<<EOD <h1>{$branax['title']}</h1> <form method=post> <fieldset> <legend>Login status</legend> <output><b>{$output}</b></output> <p><a href='user_login.php'>Login</a></p> <p><a href='user_logout.php'>Logout</a></p> </fieldset> </form> EOD; // Finally, leave it all to the rendering phase of Branax. include BRANAX_THEME_PATH;
public function actionIndex() { $set = new CRecordSet(false); $query = new CQuery(); $selectedUser = null; $query->select("quest.*")->from(TABLE_QUESTION_TO_USERS . " as quest")->order("quest.datetime_quest desc")->condition("quest.status=5"); $set->setQuery($query); $showAll = false; if (CRequest::getString("order") == "quest.user_id") { $direction = "asc"; if (CRequest::getString("direction") != "") { $direction = CRequest::getString("direction"); } $query->innerJoin(TABLE_USERS . " as user", "quest.user_id = user.id"); $query->order("user.fio " . $direction); } elseif (CRequest::getString("order") == "datetime_quest") { $direction = "asc"; if (CRequest::getString("direction") != "") { $direction = CRequest::getString("direction"); } $query->order("datetime_quest " . $direction); } elseif (CRequest::getString("order") == "datetime_answ") { $direction = "asc"; if (CRequest::getString("direction") != "") { $direction = CRequest::getString("direction"); } $query->order("datetime_answ " . $direction); } elseif (CRequest::getString("order") == "question_text") { $direction = "asc"; if (CRequest::getString("direction") != "") { $direction = CRequest::getString("direction"); } $query->order("question_text " . $direction); } elseif (CRequest::getString("order") == "contact_info") { $direction = "asc"; if (CRequest::getString("direction") != "") { $direction = CRequest::getString("direction"); } $query->order("contact_info " . $direction); } elseif (CRequest::getString("order") == "st.name") { $direction = "asc"; if (CRequest::getString("direction") != "") { $direction = CRequest::getString("direction"); } $query->leftJoin(TABLE_QUESTION_STATUS . " as st", "quest.status = st.id"); $query->order("st.name " . $direction); } elseif (CRequest::getString("order") == "answer_text") { $direction = "asc"; if (CRequest::getString("direction") != "") { $direction = CRequest::getString("direction"); } $query->order("answer_text " . $direction); } // фильтр по пользователю if (!is_null(CRequest::getFilter("user"))) { $query->innerJoin(TABLE_USERS . " as user", "quest.user_id = user.id and user.id = " . CRequest::getFilter("user")); $selectedUser = CRequest::getFilter("user"); } // фильтр по вопросу if (!is_null(CRequest::getFilter("question"))) { $query->condition("quest.id = " . CRequest::getFilter("question")); } // фильтр по ответу if (!is_null(CRequest::getFilter("answer"))) { $query->condition("quest.id = " . CRequest::getFilter("answer")); } // фильтр по контактам if (!is_null(CRequest::getFilter("contact"))) { $query->condition("quest.id = " . CRequest::getFilter("contact")); } $quests = new CArrayList(); $isArchive = CRequest::getString("isArchive") == "1"; if (!$isArchive) { if (CSession::getCurrentUser()->getLevelForCurrentTask() == ACCESS_LEVEL_READ_OWN_ONLY or CSession::getCurrentUser()->getLevelForCurrentTask() == ACCESS_LEVEL_WRITE_OWN_ONLY) { $query->condition('quest.user_id = "' . CSession::getCurrentUser()->getId() . '" and (quest.datetime_quest > "' . date("Y-m-d", strtotime(CUtils::getCurrentYear()->date_start)) . '" or quest.datetime_quest is NULL) and quest.status!=5'); } else { $query->condition('(quest.datetime_quest > "' . date("Y-m-d", strtotime(CUtils::getCurrentYear()->date_start)) . '" or quest.datetime_quest is NULL) and quest.status!=5'); } } else { if (CSession::getCurrentUser()->getLevelForCurrentTask() == ACCESS_LEVEL_READ_OWN_ONLY or CSession::getCurrentUser()->getLevelForCurrentTask() == ACCESS_LEVEL_WRITE_OWN_ONLY) { $query->condition('quest.user_id = "' . CSession::getCurrentUser()->getId() . '" and quest.status!=5'); } else { $query->condition("quest.status!=5"); } } if (CRequest::getInt("showAll") == 1) { if (!$isArchive) { if (CSession::getCurrentUser()->getLevelForCurrentTask() == ACCESS_LEVEL_READ_OWN_ONLY or CSession::getCurrentUser()->getLevelForCurrentTask() == ACCESS_LEVEL_WRITE_OWN_ONLY) { $query->condition('quest.user_id = "' . CSession::getCurrentUser()->getId() . '" and (quest.datetime_quest > "' . date("Y-m-d", strtotime(CUtils::getCurrentYear()->date_start)) . '" or quest.datetime_quest is NULL)'); } else { $query->condition('quest.datetime_quest > "' . date("Y-m-d", strtotime(CUtils::getCurrentYear()->date_start)) . '" or quest.datetime_quest is NULL'); } } else { if (CSession::getCurrentUser()->getLevelForCurrentTask() == ACCESS_LEVEL_READ_OWN_ONLY or CSession::getCurrentUser()->getLevelForCurrentTask() == ACCESS_LEVEL_WRITE_OWN_ONLY) { $query->condition('quest.user_id = "' . CSession::getCurrentUser()->getId() . '"'); } } $showAll = true; } foreach ($set->getPaginated()->getItems() as $ar) { $quest = new CQuestion($ar); $quests->add($quest->getId(), $quest); } if ($isArchive) { $requestParams = array(); foreach (CRequest::getGlobalRequestVariables()->getItems() as $key => $value) { if ($key != "isArchive") { $requestParams[] = $key . "=" . $value; } } $this->addActionsMenuItem(array(array("title" => "Текущий год", "link" => "?" . implode("&", $requestParams), "icon" => "mimetypes/x-office-calendar.png"))); } else { $requestParams = array(); foreach (CRequest::getGlobalRequestVariables()->getItems() as $key => $value) { $requestParams[] = $key . "=" . $value; } $requestParams[] = "isArchive=1"; $this->addActionsMenuItem(array(array("title" => "Архив", "link" => "?" . implode("&", $requestParams), "icon" => "devices/media-floppy.png"))); } $usersQuery = new CQuery(); $usersQuery->select("user.*")->from(TABLE_USERS . " as user")->order("user.fio asc")->innerJoin(TABLE_QUESTION_TO_USERS . " as quest", "user.id = quest.user_id"); $users = array(); foreach ($usersQuery->execute()->getItems() as $ar) { $user = new CUser(new CActiveRecord($ar)); $users[$user->getId()] = $user->getName(); } $this->setData("isArchive", $isArchive); $this->setData("showAll", $showAll); $this->setData("quests", $quests); $this->setData("users", $users); $this->setData("selectedUser", $selectedUser); $this->setData("paginator", $set->getPaginator()); $this->renderView("_question_answ/index.tpl"); }