private function build_view(HTTPRequestCustom $request)
 {
     $id = $request->get_value('id', 0);
     $status = $request->get_value('status', '');
     $old_status = $request->get_value('old_status', '');
     $this->view->put('RESULT', (int) (!empty($id) && $old_status == $status));
 }
 public function execute(HTTPRequestCustom $request)
 {
     $this->load_lang();
     $id_theme = $request->get_value('id_theme', '');
     $id_module = '';
     $file_selected = $request->get_value('file_name', '');
     if (preg_match('`/`', $file_selected)) {
         $split = explode('/', $file_selected);
         $id_module = $split[0];
         $file_name = $split[1] . '.tpl';
     } else {
         $file_name = $file_selected . '.tpl';
     }
     $this->build_form($id_theme, $id_module, $file_name, $file_selected);
     $tpl = new StringTemplate('# INCLUDE MSG # # INCLUDE FORM #');
     $tpl->add_lang($this->lang);
     if (!empty($id_theme) && !empty($file_selected)) {
         if ($this->submit_button->has_been_submited() && $this->form->validate()) {
             $this->save();
             $tpl->put('MSG', MessageHelper::display(LangLoader::get_message('process.success', 'status-messages-common'), MessageHelper::SUCCESS, 4));
         }
     }
     $tpl->put('FORM', $this->form->display());
     return new AdminCustomizationDisplayResponse($tpl, $this->lang['customization.editor.tpl-files']);
 }
 public function execute(HTTPRequestCustom $request)
 {
     $id = $request->get_int('id', 0);
     $page = $request->get_value('page', '');
     $filter = $request->get_value('filter', '');
     $filter_id = $request->get_value('filter_id', '');
     //Add filter
     BugtrackerService::add_filter(array('user_id' => AppContext::get_current_user()->get_id(), 'page' => $page, 'filters' => $filter, 'filters_ids' => $filter_id));
     AppContext::get_response()->redirect($request->get_url_referrer() ? $request->get_url_referrer() : BugtrackerUrlBuilder::unsolved(), LangLoader::get_message('success.add.filter', 'common', 'bugtracker'));
 }
 public function execute(HTTPRequestCustom $request)
 {
     $lang = LangLoader::get('common');
     $is_admin = AppContext::get_current_user()->check_level(User::ADMIN_LEVEL);
     $number_admins = UserService::count_admin_members();
     $suggestions = array();
     try {
         $result = PersistenceContext::get_querier()->select("SELECT user_id, display_name, level, groups FROM " . DB_TABLE_MEMBER . " WHERE display_name LIKE '" . str_replace('*', '%', $request->get_value('value', '')) . "%'");
         while ($row = $result->fetch()) {
             $user_group_color = User::get_group_color($row['groups'], $row['level']);
             $suggestion = '';
             if ($is_admin) {
                 $edit_link = new LinkHTMLElement(UserUrlBuilder::edit_profile($row['user_id']), '', array('title' => $lang['edit']), 'fa fa-edit');
                 if ($row['level'] != User::ADMIN_LEVEL || $row['level'] == User::ADMIN_LEVEL && $number_admins > 1) {
                     $delete_link = new LinkHTMLElement(AdminMembersUrlBuilder::delete($row['user_id']), '', array('title' => $lang['delete'], 'data-confirmation' => 'delete-element'), 'fa fa-delete');
                 } else {
                     $delete_link = new LinkHTMLElement('', '', array('title' => $lang['delete'], 'onclick' => 'return false;'), 'fa fa-delete icon-disabled');
                 }
                 $suggestion .= $edit_link->display() . ' ' . $delete_link->display() . ' ';
             }
             $profile_link = new LinkHTMLElement(UserUrlBuilder::profile($row['user_id'])->rel(), $row['display_name'], array('style' => !empty($user_group_color) ? 'color:' . $user_group_color : ''), UserService::get_level_class($row['level']));
             $suggestion .= $profile_link->display();
             $suggestions[] = $suggestion;
         }
         $result->dispose();
     } catch (Exception $e) {
     }
     return new JSONResponse(array('suggestions' => $suggestions));
 }
 public function execute(HTTPRequestCustom $request)
 {
     $this->load_lang();
     $this->load_config();
     $theme = $request->get_value('theme', 'all');
     if ($theme !== 'all' && !ThemesManager::get_theme_existed($theme)) {
         AppContext::get_response()->redirect(AdminCustomizeUrlBuilder::customize_interface());
     }
     $this->build_form($theme);
     $tpl = new StringTemplate('# INCLUDE MSG # # INCLUDE FORM #');
     $tpl->add_lang($this->lang);
     if ($this->submit_button->has_been_submited() && $this->form->validate()) {
         $header_logo = $this->form->get_value('header_logo', null);
         if ($header_logo !== null) {
             $file_type = new FileType(new File($header_logo->get_name()));
             if ($file_type->is_picture()) {
                 $this->save($header_logo, $theme);
                 AppContext::get_response()->redirect(AdminCustomizeUrlBuilder::customize_interface());
             } else {
                 $tpl->put('MSG', MessageHelper::display(LangLoader::get_message('process.error', 'status-messages-common'), MessageHelper::ERROR, 4));
             }
         } elseif ($this->form->get_value('use_default_logo')) {
             $this->delete_pictures_saved($theme);
             AppContext::get_response()->redirect(AdminCustomizeUrlBuilder::customize_interface());
         } else {
             $tpl->put('MSG', MessageHelper::display(LangLoader::get_message('process.error', 'status-messages-common'), MessageHelper::ERROR, 4));
         }
     }
     $tpl->put('FORM', $this->form->display());
     return new AdminCustomizationDisplayResponse($tpl, $this->lang['customization.interface']);
 }
 private function update_position(HTTPRequestCustom $request)
 {
     $fields = $this->config->get_fields();
     $sorted_fields = array();
     $fields_list = json_decode(TextHelper::html_entity_decode($request->get_value('tree')));
     foreach ($fields_list as $position => $tree) {
         $sorted_fields[$position + 1] = $fields[$tree->id];
     }
     $this->config->set_fields($sorted_fields);
     ContactConfig::save();
 }
 public function execute(HTTPRequestCustom $request)
 {
     $this->check_authorizations();
     $this->init();
     if ($request->get_value('submit', false)) {
         $this->update_position($request);
         $this->tpl->put('MSG', MessageHelper::display(LangLoader::get_message('message.success.position.update', 'status-messages-common'), MessageHelper::SUCCESS, 5));
     }
     $this->build_view($request);
     return $this->generate_response();
 }
 public function execute(HTTPRequestCustom $request)
 {
     $id = $request->get_value('id', 0);
     $name = $request->get_value('name', '');
     $field_name = ContactField::rewrite_field_name($name);
     $result = 0;
     if (!empty($id)) {
         foreach (ContactConfig::load()->get_fields() as $key => $f) {
             if ($key != $id && $f['field_name'] == $field_name) {
                 $result = 1;
             }
         }
     } else {
         foreach (ContactConfig::load()->get_fields() as $key => $f) {
             if ($f['field_name'] == $field_name) {
                 $result = 1;
             }
         }
     }
     return new JSONResponse(array('result' => $result));
 }
 public function execute(HTTPRequestCustom $request)
 {
     $suggestions = array();
     try {
         $result = PersistenceContext::get_querier()->select("SELECT name, rewrited_name FROM " . DB_TABLE_KEYWORDS . " WHERE name LIKE '" . $request->get_value('value', '') . "%'");
         while ($row = $result->fetch()) {
             $suggestions[] = $row['name'];
         }
         $result->dispose();
     } catch (Exception $e) {
     }
     return new JSONResponse(array('suggestions' => $suggestions));
 }
 private function update_positions(HTTPRequestCustom $request)
 {
     if ($request->get_postvalue('submit', false)) {
         $categories = json_decode(TextHelper::html_entity_decode($request->get_value('tree')));
         foreach ($categories as $position => $tree) {
             $id = $tree->id;
             $children = $tree->children[0];
             $category = $this->get_categories_manager()->get_categories_cache()->get_category($id);
             $this->get_categories_manager()->update_position($category, Category::ROOT_CATEGORY, $position + 1);
             $this->update_childrens_positions($children, $category->get_id());
         }
         $this->tpl->put('MSG', MessageHelper::display(LangLoader::get_message('message.success.position.update', 'status-messages-common'), MessageHelper::SUCCESS, 5));
     }
 }
 public function execute(HTTPRequestCustom $request)
 {
     $suggestions = array();
     try {
         $result = PersistenceContext::get_querier()->select("SELECT display_name, level, groups FROM " . DB_TABLE_MEMBER . " WHERE display_name LIKE '" . str_replace('*', '%', $request->get_value('value', '')) . "%'");
         while ($row = $result->fetch()) {
             $user_group_color = User::get_group_color($row['groups'], $row['level']);
             $profile_link = new LinkHTMLElement('', $row['display_name'], array('onclick' => 'return false;', 'style' => !empty($user_group_color) ? 'color:' . $user_group_color : ''), UserService::get_level_class($row['level']));
             $suggestions[] = $profile_link->display();
         }
         $result->dispose();
     } catch (Exception $e) {
     }
     return new JSONResponse(array('suggestions' => $suggestions));
 }
 public function execute(HTTPRequestCustom $request)
 {
     $status = 200;
     $url_to_check = $request->get_value('url_to_check', '');
     if ($url_to_check) {
         $url = new Url($url_to_check);
         $file_headers = get_headers($url->absolute(), true);
         if (is_array($file_headers)) {
             if (preg_match('/^HTTP\\/[12]\\.[01] (\\d\\d\\d)/', $file_headers[0], $matches)) {
                 $status = (int) $matches[1];
             }
         }
     }
     return new JSONResponse(array('status' => $status));
 }
 public function execute(HTTPRequestCustom $request)
 {
     try {
         $this->try_execute();
     } catch (ObjectNotFoundException $exception) {
         $error_controller = new UserErrorController('Menu configuration does not exists', 'The requested menu configuration ' . $request->get_value('menu_config_id') . ' does not exists', UserErrorController::FATAL);
         $error_controller->set_correction_link('Menu configuration list', MenuUrlBuilder::menu_configuration_list()->rel());
         $error_controller->set_response_classname('AdminMenusDisplayResponse');
         return $error_controller->execute($request);
     } catch (UnexistingHTTPParameterException $exception) {
         $error_controller = ClassLoader::new_instance('/admin/menus/controllers/MenuControllerError');
         return $error_controller->execute($request);
     }
     return $this->response;
 }
 public function execute(HTTPRequestCustom $request)
 {
     $this->check_authorizations();
     $this->init();
     $this->build_form();
     $tpl = new StringTemplate('# INCLUDE FORM #');
     $tpl->add_lang($this->lang);
     if ($this->submit_button->has_been_submited() && $this->form->validate()) {
         $type = $request->get_value('type', '');
         if ($type !== '' && ($type == 'html' || $type == 'bbcode' || $type == 'text')) {
             AppContext::get_response()->redirect(NewsletterUrlBuilder::add_newsletter($type));
         }
     }
     $tpl->put('FORM', $this->form->display());
     return $this->build_response($tpl);
 }
 public function execute(HTTPRequestCustom $request)
 {
     $this->init();
     $this->id = $request->get_value('id', null);
     if ($this->exists()) {
         $this->build_form();
         if ($this->submit_button->has_been_submited() && $this->form->validate()) {
             $this->uninstall($this->form->get_value('drop_files')->get_raw_value());
             AppContext::get_response()->redirect(AdminLangsUrlBuilder::list_installed_langs());
         }
         $this->tpl->put('FORM', $this->form->display());
         return new AdminLangsDisplayResponse($this->tpl, $this->lang['langs.delete_lang']);
     } else {
         $error_controller = PHPBoostErrors::unexisting_page();
         DispatchManager::redirect($error_controller);
     }
 }
 public function execute(HTTPRequestCustom $request)
 {
     if (!NewsletterAuthorizationsService::default_authorizations()->create_newsletters()) {
         NewsletterAuthorizationsService::get_errors()->create_newsletters();
     }
     $type = $request->get_value('type', '');
     $this->init();
     $this->build_form($type);
     $tpl = new StringTemplate('# INCLUDE MSG # # INCLUDE FORM #');
     $tpl->add_lang($this->lang);
     if ($this->submit_button->has_been_submited() && $this->form->validate()) {
         $this->send_mail($type);
         $tpl->put('MSG', MessageHelper::display($this->lang['newsletter.message.success.add'], MessageHelper::SUCCESS, 5));
     } else {
         if ($this->send_test_button->has_been_submited() && $this->form->validate()) {
             $this->send_test($type);
             $tpl->put('MSG', MessageHelper::display($this->lang['newsletter.success-send-test'], MessageHelper::SUCCESS, 5));
         }
     }
     $tpl->put('FORM', $this->form->display());
     return $this->build_response($tpl, $type);
 }
 public function execute(HTTPRequestCustom $request)
 {
     $this->init();
     $registration_pass = $request->get_value('registration_pass', '');
     $this->check_activation($registration_pass);
 }