Ejemplo n.º 1
0
 public function index()
 {
     requirePermission("view");
     $this->template->setTitle(lang("user_panel", "ucp"));
     $cache = $this->cache->get("profile_characters_" . $this->user->getId());
     if ($cache !== false) {
         $characters = $cache;
     } else {
         $characters_data = array("characters" => $this->realms->getTotalCharacters(), "realms" => $this->realms->getRealms(), "url" => $this->template->page_url, "realmObj" => $this->realms);
         $characters = $this->template->loadPage("ucp_characters.tpl", $characters_data);
         $this->cache->save("profile_characters_" . $this->user->getId(), $characters, 60 * 60);
     }
     $links = $this->menu_model->getMenuLinks();
     if ($links) {
         foreach ($links as $key => $value) {
             // Check if we have  the permission, otherwise unset the row
             if ($value['permission'] != '') {
                 if (hasPermission($value['permission'], $value['permissionModule']) !== true) {
                     unset($links[$key]);
                     continue;
                 }
             }
             // Add the website path if internal link
             if (!preg_match("/https?:\\/\\//", $value['link'])) {
                 $links[$key]['link'] = $this->template->page_url . $value['link'];
             }
             $links[$key]['name'] = langColumn($links[$key]['name']);
         }
     }
     $data = array("username" => $this->user->getNickname(), "expansion" => $this->realms->getEmulator()->getExpansionName($this->external_account_model->getExpansion()), "vp" => $this->internal_user_model->getVp(), "dp" => $this->internal_user_model->getDp(), "url" => $this->template->page_url, "location" => $this->internal_user_model->getLocation(), "groups" => $this->acl_model->getGroupsByUser($this->user->getId()), "register_date" => $this->user->getRegisterDate(), "status" => $this->user->getAccountStatus(), "characters" => $characters, "avatar" => $this->user->getAvatar($this->user->getId()), "id" => $this->user->getId(), "menu_links" => $links, "config" => array("vote" => $this->config->item('ucp_vote'), "donate" => $this->config->item('ucp_donate'), "store" => $this->config->item('ucp_store'), "settings" => $this->config->item('ucp_settings'), "expansion" => $this->config->item('ucp_expansion'), "teleport" => $this->config->item('ucp_teleport'), "admin" => $this->config->item('ucp_admin'), "gm" => $this->config->item('ucp_gm')));
     $this->template->view($this->template->loadPage("page.tpl", array("module" => "default", "headline" => lang("user_panel", "ucp"), "content" => $this->template->loadPage("ucp.tpl", $data))), "modules/ucp/css/ucp.css");
 }
Ejemplo n.º 2
0
 public function index($page = "error")
 {
     if ($page == "error") {
         redirect('error');
     } else {
         $cache = $this->cache->get("page_" . $page . "_" . getLang());
         if ($cache !== false) {
             $this->template->setTitle($cache['title']);
             $out = $cache['content'];
             if ($cache['permission'] && !hasViewPermission($cache['permission'], "--PAGE--")) {
                 $this->template->showError(lang("permission_denied", "error"));
             }
         } else {
             $page_content = $this->cms_model->getPage($page);
             if ($page_content == false) {
                 redirect('error');
             } else {
                 $this->template->setTitle(langColumn($page_content['name']));
                 $page_data = array("module" => "default", "headline" => langColumn($page_content['name']), "content" => langColumn($page_content['content']));
                 $out = $this->template->loadPage("page.tpl", $page_data);
                 $this->cache->save("page_" . $page . "_" . getLang(), array("title" => langColumn($page_content['name']), "content" => $out, "permission" => $page_content['permission']));
                 if ($page_content['permission'] && !hasViewPermission($page_content['permission'], "--PAGE--")) {
                     $this->template->showError(lang("permission_denied", "error"));
                 }
             }
         }
     }
     $this->template->view($out);
 }
Ejemplo n.º 3
0
 public function view()
 {
     // Get the custom data
     $data = $this->custom_model->getCustomData($this->id);
     // Return the custom data
     return langColumn($data['content']);
 }
Ejemplo n.º 4
0
 /**
  * Edit a news post with the given id.
  * @param bool $id
  */
 public function edit($id = false)
 {
     requirePermission("canEditArticle");
     if (!$id || !is_numeric($id)) {
         die;
     }
     $article = $this->news_model->getArticle($id);
     if ($article == false) {
         show_error("There is no article with ID " . $id);
         die;
     }
     // Change the title
     $this->administrator->setTitle(langColumn($article['headline']));
     // Prepare my data
     $data = array('url' => $this->template->page_url, 'article' => $article);
     // Load my view
     $output = $this->template->loadPage("admin_edit.tpl", $data);
     // Put my view in the main box with a headline
     $content = $this->administrator->box('<a href="' . $this->template->page_url . 'news/admin">News articles</a> &rarr; ' . langColumn($article['headline']), $output);
     // Output my content. The method accepts the same arguments as template->view
     $this->administrator->view($content, false, "modules/news/js/admin.js");
 }
Ejemplo n.º 5
0
 public function edit($id = false)
 {
     requirePermission("editSideboxes");
     if (!is_numeric($id) || !$id) {
         die;
     }
     $sidebox = $this->sidebox_model->getSidebox($id);
     $sideboxCustomText = $this->sidebox_model->getCustomText($id);
     if (!$sidebox) {
         show_error("There is no sidebox with ID " . $id);
         die;
     }
     $this->sideboxModules = $this->getSideboxModules();
     // Change the title
     $this->administrator->setTitle(langColumn($sidebox['displayName']));
     $fusionEditor = $this->fusioneditor->create("text", false, 250, $sideboxCustomText);
     // Prepare my data
     $data = array('url' => $this->template->page_url, 'sidebox' => $sidebox, 'sideboxModules' => $this->sideboxModules, 'fusionEditor' => $fusionEditor);
     // Load my view
     $output = $this->template->loadPage("sidebox/edit_sidebox.tpl", $data);
     // Put my view in the main box with a headline
     $content = $this->administrator->box('<a href="' . $this->template->page_url . 'admin/sidebox">Sideboxes</a> &rarr; ' . langColumn($sidebox['displayName']), $output);
     // Output my content. The method accepts the same arguments as template->view
     $this->administrator->view($content, false, "modules/admin/js/sidebox.js");
 }
Ejemplo n.º 6
0
 public function edit($id = false)
 {
     requirePermission("editMenuLinks");
     if (!is_numeric($id) || !$id) {
         die;
     }
     $link = $this->menu_model->getMenuLink($id);
     if (!$link) {
         show_error("There is no link with ID " . $id);
         die;
     }
     // Change the title
     $this->administrator->setTitle(langColumn($link['name']));
     // Prepare my data
     $data = array('url' => $this->template->page_url, 'link' => $link);
     // Load my view
     $output = $this->template->loadPage("menu/edit_menu.tpl", $data);
     // Put my view in the main box with a headline
     $content = $this->administrator->box('<a href="' . $this->template->page_url . 'admin/menu">Menu links</a> &rarr; ' . langColumn($link['name']), $output);
     // Output my content. The method accepts the same arguments as template->view
     $this->administrator->view($content, false, "modules/admin/js/menu.js");
 }
Ejemplo n.º 7
0
 public function edit($id = false)
 {
     if (!is_numeric($id) || !$id) {
         die;
     }
     $link = $this->menu_model->getMenuLink($id);
     if (!$link) {
         show_error("There is no link with ID " . $id);
         die;
     }
     // Change the title
     $this->administrator->setTitle(langColumn($link['name']));
     // Get all the roles/permissions and format em
     $Permissions = $this->getAllPermissions();
     $PermissionOptions = array();
     foreach ($Permissions as $module => $moduleData) {
         if ($moduleData['permissions'] && count($moduleData['permissions']) > 0) {
             // Start the option group
             $PermissionOptions[] = '<optgroup label="' . $moduleData['name'] . '">';
             // Set the children
             foreach ($moduleData['permissions'] as $permission => $permissionData) {
                 $PermissionOptions[] = '<option value="' . $module . ':' . $permission . '" ' . ($module == $link['permissionModule'] && $permission == $link['permission'] ? 'selected="selected"' : '') . '>' . $permission . ' (' . $permissionData['description'] . ')</option>';
             }
             // Close the option group
             $PermissionOptions[] = '</optgroup>';
         }
     }
     // Prepare my data
     $data = array('url' => $this->template->page_url, 'link' => $link, 'PermissionOptions' => $PermissionOptions, 'images' => $this->GetGalleryImages());
     // Load my view
     $output = $this->template->loadPage("admin_edit.tpl", $data);
     // Put my view in the main box with a headline
     $content = $this->administrator->box('<a href="' . $this->template->page_url . 'ucp/admin">User Control Panel Management</a> &rarr; ' . langColumn($link['name']), $output);
     // Output my content. The method accepts the same arguments as template->view
     $this->administrator->view($content, self::MODULE_PATH . "/css/admin.css", self::MODULE_PATH . "/js/admin.js");
 }
Ejemplo n.º 8
0
 /**
  * Load the image slider
  */
 public function getSlider()
 {
     // Load the slides from the database
     $slides_arr = $this->CI->cms_model->getSlides();
     foreach ($slides_arr as $key => $image) {
         if (!preg_match("/http:\\/\\//i", $image['link']) || !preg_match("/https:\\/\\//i", $image['link'])) {
             $slides_arr[$key]['link'] = $this->page_url . $image['link'];
         }
         $slides_arr[$key]['text'] = langColumn($image['text']);
         // Replace {path} by the theme image path
         $slides_arr[$key]['image'] = preg_replace("/\\{path\\}/", $this->image_path, $image['image']);
     }
     return $slides_arr;
 }
Ejemplo n.º 9
0
 /**
  * Load the image slider
  */
 public function getSlider()
 {
     // Load the slides from the database
     $slides_arr = $this->CI->cms_model->getSlides();
     foreach ($slides_arr as $key => $image) {
         if (!preg_match('|^http(s)?://[a-z0-9-]+(.[a-z0-9-]+)*(:[0-9]+)?(/.*)?$|i', $image['link'])) {
             $slides_arr[$key]['link'] = $this->page_url . $image['link'];
         }
         $slides_arr[$key]['text'] = langColumn($image['text']);
         // Replace {path} by the theme image path
         $slides_arr[$key]['image'] = preg_replace("/\\{path\\}/", $this->image_path, $image['image']);
     }
     return $slides_arr;
 }
Ejemplo n.º 10
0
 private function getNews()
 {
     // Init pagination
     $config = $this->initPagination();
     // Decide our starting index of the news
     $this->startIndex = $this->uri->segment($config['uri_segment']);
     if (empty($this->startIndex)) {
         $this->startIndex = 0;
     }
     // Get the articles with the lower and upper limit decided by our pagination.
     $this->news_articles = $this->news_model->getArticles($this->startIndex, $this->startIndex + $config['per_page']);
     // For each key we need to add the special values that we want to print
     foreach ($this->news_articles as $key => $article) {
         $this->news_articles[$key]['headline'] = langColumn($article['headline']);
         $this->news_articles[$key]['content'] = langColumn($article['content']);
         $this->news_articles[$key]['date'] = date("Y/m/d", $article['timestamp']);
         $this->news_articles[$key]['author'] = $this->user->getNickname($article['author_id']);
         $this->news_articles[$key]['link'] = $article['comments'] == -1 ? '' : "href='javascript:void(0)' onClick='Ajax.showComments(" . $article['id'] . ")'";
         $this->news_articles[$key]['comments_id'] = "id='comments_" . $article['id'] . "'";
         $this->news_articles[$key]['comments_button_id'] = "id='comments_button_" . $article['id'] . "'";
         $this->news_articles[$key]['tags'] = $this->news_model->getTags($article['id']);
     }
 }