/**
  * {@inheritdoc}
  */
 public function handle(\Input $input)
 {
     $removeNames = $input->post('packages') ? explode(',', $input->post('packages')) : array($input->post('remove'));
     // filter undeletable packages
     $removeNames = array_filter($removeNames, function ($removeName) {
         return !in_array($removeName, InstalledController::$UNDELETABLE_PACKAGES);
     });
     // skip empty
     if (empty($removeNames)) {
         $this->redirect('contao/main.php?do=composer');
     }
     // make a backup
     copy(TL_ROOT . '/' . $this->configPathname, TL_ROOT . '/' . $this->configPathname . '~');
     // update requires
     $json = new JsonFile(TL_ROOT . '/' . $this->configPathname);
     $config = $json->read();
     if (!array_key_exists('require', $config)) {
         $config['require'] = array();
     }
     foreach ($removeNames as $removeName) {
         unset($config['require'][$removeName]);
     }
     $json->write($config);
     $_SESSION['TL_INFO'][] = sprintf($GLOBALS['TL_LANG']['composer_client']['removeCandidate'], implode(', ', $removeNames));
     $_SESSION['COMPOSER_OUTPUT'] .= $this->io->getOutput();
     $this->redirect('contao/main.php?do=composer');
 }
 /**
  * {@inheritdoc}
  */
 public function handle(\Input $input)
 {
     $this->handleRunOnce();
     // PATCH
     if ($input->post('FORM_SUBMIT') == 'database-update') {
         $count = 0;
         $sql = deserialize($input->post('sql'));
         if (is_array($sql)) {
             foreach ($sql as $key) {
                 if (isset($_SESSION['sql_commands'][$key])) {
                     $this->Database->query(str_replace('DEFAULT CHARSET=utf8;', 'DEFAULT CHARSET=utf8 COLLATE ' . $GLOBALS['TL_CONFIG']['dbCollation'] . ';', $_SESSION['sql_commands'][$key]));
                     $count++;
                 }
             }
         }
         $_SESSION['sql_commands'] = array();
         Messages::addConfirmation(sprintf($GLOBALS['TL_LANG']['composer_client']['databaseUpdated'], $count));
         $this->reload();
     }
     /** @var \Contao\Database\Installer $installer */
     $installer = \System::importStatic('Database\\Installer');
     $form = $installer->generateSqlForm();
     if (empty($form)) {
         Messages::addInfo($GLOBALS['TL_LANG']['composer_client']['databaseUptodate']);
         $this->redirect('contao/main.php?do=composer');
     }
     $form = preg_replace('#(<label for="sql_\\d+")>(CREATE TABLE)#', '$1 class="create_table">$2', $form);
     $form = preg_replace('#(<label for="sql_\\d+")>(ALTER TABLE `[^`]+` ADD)#', '$1 class="alter_add">$2', $form);
     $form = preg_replace('#(<label for="sql_\\d+")>(ALTER TABLE `[^`]+` DROP)#', '$1 class="alter_drop">$2', $form);
     $form = preg_replace('#(<label for="sql_\\d+")>(DROP TABLE)#', '$1 class="drop_table">$2', $form);
     $template = new \BackendTemplate('be_composer_client_update');
     $template->composer = $this->composer;
     $template->form = $form;
     return $template->parse();
 }
 /**
  * {@inheritdoc}
  *
  * @SuppressWarnings(PHPMD.LongVariable)
  */
 public function handle(\Input $input)
 {
     $packageName = $input->get('install');
     if ($packageName == 'contao/core') {
         $this->redirect('contao/main.php?do=composer');
     }
     if ($input->post('version')) {
         $version = base64_decode(rawurldecode($input->post('version')));
         // make a backup
         copy(TL_ROOT . '/' . $this->configPathname, TL_ROOT . '/' . $this->configPathname . '~');
         // update requires
         $json = new JsonFile(TL_ROOT . '/' . $this->configPathname);
         $config = $json->read();
         if (!array_key_exists('require', $config)) {
             $config['require'] = array();
         }
         $config['require'][$packageName] = $version;
         ksort($config['require']);
         $json->write($config);
         Messages::addInfo(sprintf($GLOBALS['TL_LANG']['composer_client']['added_candidate'], $packageName, $version));
         $_SESSION['COMPOSER_OUTPUT'] .= $this->io->getOutput();
         $this->redirect('contao/main.php?do=composer');
     }
     $installationCandidates = $this->searchPackage($packageName);
     if (empty($installationCandidates)) {
         Messages::addError(sprintf($GLOBALS['TL_LANG']['composer_client']['noInstallationCandidates'], $packageName));
         $_SESSION['COMPOSER_OUTPUT'] .= $this->io->getOutput();
         $this->redirect('contao/main.php?do=composer');
     }
     $template = new \BackendTemplate('be_composer_client_install');
     $template->composer = $this->composer;
     $template->packageName = $packageName;
     $template->candidates = $installationCandidates;
     return $template->parse();
 }
Beispiel #4
0
 /**
  * Generate the module
  *
  * @return string
  */
 public function run()
 {
     /** @var BackendTemplate|object $objTemplate */
     $objTemplate = new \BackendTemplate('be_maintenance_mode');
     $objTemplate->action = ampersand(\Environment::get('request'));
     $objTemplate->headline = $GLOBALS['TL_LANG']['tl_maintenance']['maintenanceMode'];
     $objTemplate->isActive = $this->isActive();
     try {
         $driver = \System::getContainer()->get('lexik_maintenance.driver.factory')->getDriver();
         $isLocked = $driver->isExists();
     } catch (\Exception $e) {
         return '';
     }
     // Toggle the maintenance mode
     if (\Input::post('FORM_SUBMIT') == 'tl_maintenance_mode') {
         if ($isLocked) {
             $driver->unlock();
         } else {
             $driver->lock();
         }
         $this->reload();
     }
     if ($isLocked) {
         $objTemplate->class = 'tl_confirm';
         $objTemplate->explain = $GLOBALS['TL_LANG']['MSC']['maintenanceEnabled'];
         $objTemplate->submit = $GLOBALS['TL_LANG']['tl_maintenance']['maintenanceDisable'];
     } else {
         $objTemplate->class = 'tl_info';
         $objTemplate->explain = $GLOBALS['TL_LANG']['MSC']['maintenanceDisabled'];
         $objTemplate->submit = $GLOBALS['TL_LANG']['tl_maintenance']['maintenanceEnable'];
     }
     return $objTemplate->parse();
 }
Beispiel #5
0
 /**
  * Run the controller and parse the template
  */
 public function run()
 {
     $this->Template = new BackendTemplate('be_picker');
     $this->Template->main = '';
     // Ajax request
     if ($_POST && Environment::get('isAjaxRequest')) {
         $this->objAjax = new Ajax(Input::post('action'));
         $this->objAjax->executePreActions();
     }
     $strTable = Input::get('table');
     $strField = Input::get('field');
     $this->loadDataContainer($strTable);
     $objDca = new DC_Table($strTable);
     // AJAX request
     if ($_POST && Environment::get('isAjaxRequest')) {
         $this->objAjax->executePostActions($objDca);
     }
     $objFileTree = new $GLOBALS['BE_FFL']['fileSelector'](array('strId' => $strField, 'strTable' => $strTable, 'strField' => $strField, 'strName' => $strField, 'varValue' => explode(',', Input::get('value'))), $objDca);
     $this->Template->main = $objFileTree->generate();
     $this->Template->theme = $this->getTheme();
     $this->Template->base = Environment::get('base');
     $this->Template->language = $GLOBALS['TL_LANGUAGE'];
     $this->Template->title = specialchars($GLOBALS['TL_LANG']['MSC']['filepicker']);
     $this->Template->headline = $GLOBALS['TL_LANG']['MSC']['ppHeadline'];
     $this->Template->charset = $GLOBALS['TL_CONFIG']['characterSet'];
     $this->Template->options = $this->createPageList();
     $this->Template->expandNode = $GLOBALS['TL_LANG']['MSC']['expandNode'];
     $this->Template->collapseNode = $GLOBALS['TL_LANG']['MSC']['collapseNode'];
     $this->Template->loadingData = $GLOBALS['TL_LANG']['MSC']['loadingData'];
     $this->Template->search = $GLOBALS['TL_LANG']['MSC']['search'];
     $this->Template->action = ampersand(Environment::get('request'));
     $this->Template->value = $this->Session->get('file_selector_search');
     $GLOBALS['TL_CONFIG']['debugMode'] = false;
     $this->Template->output();
 }
 function login($req, $res, $args)
 {
     if ($req->isPost()) {
         $form_username = Input::post('req_username');
         $form_password = Input::post('req_password');
         $save_pass = (bool) Input::post('save_pass');
         // If form was correctly filled
         if ($form_username && $form_password) {
             $user = AuthModel::get_user_from_name($form_username);
             // Compare user pass with form data
             $form_password_hash = Random::hash($form_password);
             // Will result in a SHA-1 hash
             if ($user->password == $form_password_hash) {
                 $expire = $save_pass ? time() + 1209600 : time() + 1800;
                 $jwt = AuthModel::generate_jwt($user);
                 AuthModel::feather_setcookie('Bearer ' . $jwt, $expire);
                 return Router::redirect(Router::pathFor('home'), 'Welcome ' . $user->username . '!');
             } else {
                 throw new \Exception('Wrong user/pass', 403);
             }
         } else {
             throw new \Exception("Username and password are required fields.", 1);
         }
     } elseif ($req->isGet()) {
         return View::setPageInfo(['title' => 'Login', 'active_nav' => 'login'])->addTemplate('login.php')->display();
     }
 }
Beispiel #7
0
 public function action_edit($id = null)
 {
     $student = Model_Student::find('first', ['where' => ['user_id' => $id]]);
     if (!$student) {
         $student = Model_Student::forge(['user_id' => $id]);
     }
     $val = Model_Student::validate('edit');
     if ($val->run()) {
         $student->user_id = Input::post('user_id');
         $student->year_level = Input::post('year_level');
         $student->course_id = Input::post('course_id');
         if ($student->save()) {
             Session::set_flash('success', e('Updated student #' . $id));
             Response::redirect('site/student');
         } else {
             Session::set_flash('error', e('Could not update student #' . $id));
         }
     } else {
         if (Input::method() == 'POST') {
             $student->user_id = $val->validated('user_id');
             $student->year_level = $val->validated('year_level');
             $student->course_id = $val->validated('course_id');
             Session::set_flash('error', $val->error());
         }
         $this->template->set_global('student', $student, false);
     }
     $this->template->title = "Students";
     $this->template->content = View::forge('site/student/edit');
 }
 public function action_search()
 {
     //main.jsから投げられたpostdataを取得
     $category = Input::post('category');
     $refine = Input::post('refine');
     $text = Input::post('text');
     //検索条件の生成
     $query = ['limit' => '', 'order' => 'year', 'column' => 'category', 'value' => $category, 'column2' => '', 'value2' => ''];
     if ($category == 'all') {
         $query['column'] = '';
         $query['value'] = '';
     }
     //テキストボックスに何も入力されていなかったら
     if ($text) {
         if ($refine == 'all') {
             $query['value2'] = '%' . $text . '%';
             //生成した検索条件をModel(paperadministration/papsersearch/papersearch)に渡す
             $contents['papers'] = Model_Paperadministration_Papersearch::find_all($query);
         } else {
             $query['column2'] = $refine;
             $query['value2'] = '%' . $text . '%';
             //生成した検索条件をModel(paperadministration/papsersearch/papersearch)に渡す
             $contents['papers'] = Model_Paperadministration_Papersearch::find_paper($query);
         }
     } else {
         //生成した検索条件をModel(paperadministration/papsersearch/papersearch)に渡す
         $contents['papers'] = Model_Paperadministration_Papersearch::find_paper($query);
     }
     $contents['pagetitle'] = '';
     //検索してきた論文たちをViewのコンテンツ部分(paperadministration/parts/newpaper)に渡す
     $data['content'] = View::forge('paperadministration/parts/content', $contents);
     //main.jsに検索結果を挿入済みのコンテンツ部分を渡す
     return $data['content'];
 }
Beispiel #9
0
 public function action_edit($id = null)
 {
     is_null($id) and Response::redirect('userstationlog');
     if (!($userstationlog = Model_Userstationlog::find($id))) {
         Session::set_flash('error', 'Could not find userstationlog #' . $id);
         Response::redirect('userstationlog');
     }
     $val = Model_Userstationlog::validate('edit');
     if ($val->run()) {
         $userstationlog->id = Input::post('id');
         $userstationlog->base_line = Input::post('base_line');
         $userstationlog->station_id = Input::post('station_id');
         $userstationlog->station_id_index = Input::post('station_id_index');
         if ($userstationlog->save()) {
             Session::set_flash('success', 'Updated userstationlog #' . $id);
             Response::redirect('userstationlog');
         } else {
             Session::set_flash('error', 'Could not update userstationlog #' . $id);
         }
     } else {
         if (Input::method() == 'POST') {
             $userstationlog->id = $val->validated('id');
             $userstationlog->base_line = $val->validated('base_line');
             $userstationlog->station_id = $val->validated('station_id');
             $userstationlog->station_id_index = $val->validated('station_id_index');
             Session::set_flash('error', $val->error());
         }
         $this->template->set_global('userstationlog', $userstationlog, false);
     }
     $this->template->title = "Userstationlogs";
     $this->template->content = View::forge('userstationlog/edit');
 }
Beispiel #10
0
 public function action_edit($id = null)
 {
     $usermyroute = $this->_get_user_my_rouet_data_by_id($id);
     //		$val = Model_Form::validate('edit');
     $val = true;
     //		if ($val->run())
     if ($val == true) {
         $usermyroute->departure = Input::post('departure');
         $usermyroute->arrival = Input::post('arrival');
         $usermyroute->fare = Input::post('fare');
         $usermyroute->via = Input::post('via');
         $usermyroute->vehicle = Input::post('vehicle');
         if ($usermyroute->save()) {
             Session::set_flash('success', e('Updated form #' . $id));
             Response::redirect('admin/myroute');
         } else {
             Session::set_flash('error', e('Could not update form #' . $id));
         }
     } else {
         if (Input::method() == 'POST') {
             $form->name = $val->validated('name');
             $form->email = $val->validated('email');
             $form->comment = $val->validated('comment');
             $form->ip_address = $val->validated('ip_address');
             $form->user_agent = $val->validated('user_agent');
             Session::set_flash('error', $val->error());
         }
         $this->template->set_global('form', $form, false);
     }
     $this->template->title = "Forms";
     $this->template->content = View::forge('admin/myroute/edit');
 }
Beispiel #11
0
 public function action_edit($id = null)
 {
     is_null($id) and Response::redirect('News');
     $news = Model_News::find($id);
     $val = Model_News::validate('edit');
     if ($val->run()) {
         $news->title = Input::post('title');
         $news->article = Input::post('article');
         $news->call_center_id = Input::post('call_center_id');
         $news->user_id = Input::post('user_id');
         if ($news->save()) {
             Session::set_flash('success', 'Updated news #' . $id);
             Response::redirect('news');
         } else {
             Session::set_flash('error', 'Could not update news #' . $id);
         }
     } else {
         if (Input::method() == 'POST') {
             $news->title = $val->validated('title');
             $news->article = $val->validated('article');
             $news->call_center_id = $val->validated('call_center_id');
             $news->user_id = $val->validated('user_id');
             Session::set_flash('error', $val->error());
         }
         $this->template->set_global('news', $news, false);
     }
     $this->template->title = "News";
     $this->template->content = View::forge('news/edit');
 }
Beispiel #12
0
 public function action_edit($id = null)
 {
     is_null($id) and Response::redirect('point');
     if (!($point = Model_Point::find($id))) {
         Session::set_flash('error', 'Could not find point #' . $id);
         Response::redirect('point');
     }
     $val = Model_Point::validate('edit');
     if ($val->run()) {
         $point->user_id = Input::post('user_id');
         $point->point = Input::post('point');
         if ($point->save()) {
             Session::set_flash('success', 'Updated point #' . $id);
             Response::redirect('point');
         } else {
             Session::set_flash('error', 'Could not update point #' . $id);
         }
     } else {
         if (Input::method() == 'POST') {
             $point->user_id = $val->validated('user_id');
             $point->point = $val->validated('point');
             Session::set_flash('error', $val->error());
         }
         $this->template->set_global('point', $point, false);
     }
     $this->template->title = "Points";
     $this->template->content = View::forge('point/edit');
 }
Beispiel #13
0
 public function action_edit($id = null)
 {
     $form = Model_Form::find($id);
     $val = Model_Form::validate('edit');
     if ($val->run()) {
         $form->name = Input::post('name');
         $form->email = Input::post('email');
         $form->comment = Input::post('comment');
         $form->ip_address = Input::post('ip_address');
         $form->user_agent = Input::post('user_agent');
         if ($form->save()) {
             Session::set_flash('success', e('Updated form #' . $id));
             Response::redirect('admin/form');
         } else {
             Session::set_flash('error', e('Could not update form #' . $id));
         }
     } else {
         if (Input::method() == 'POST') {
             $form->name = $val->validated('name');
             $form->email = $val->validated('email');
             $form->comment = $val->validated('comment');
             $form->ip_address = $val->validated('ip_address');
             $form->user_agent = $val->validated('user_agent');
             Session::set_flash('error', $val->error());
         }
         $this->template->set_global('form', $form, false);
     }
     $this->template->title = "Forms";
     $this->template->content = View::forge('admin/form/edit');
 }
Beispiel #14
0
 public function action_login()
 {
     $data["subnav"] = array('login' => 'active');
     $auth = Auth::instance();
     if (Auth::instance()->check()) {
         Session::set_flash('success', 'You are already logged in, ' . $auth->get_screen_name());
         Response::redirect('/admin');
     }
     $view = View::forge('admin/users/login', $data);
     $form = Form::forge('login');
     $form->add('username', 'Username:'******'class' => 'form-control'));
     $form->add('password', 'Password:'******'type' => 'password', 'class' => 'form-control'));
     $form->add('submit', ' ', array('type' => 'submit', 'value' => 'Login', 'class' => 'btn btn-primary'));
     if (Input::post()) {
         if ($auth->login(Input::post('username'), Input::post('password'))) {
             Session::set_flash('success', 'Successfully logged in! Welcome ' . $auth->get_screen_name());
             Response::redirect('/');
         } else {
             Session::set_flash('error', 'Username or password incorrect.');
         }
     }
     $view->set('form', $form, false);
     $this->template->title = 'User &raquo; Login';
     $this->template->content = $view;
 }
 public function action_edit($id = null)
 {
     $currency = Model_Currency::find($id);
     $val = Model_Currency::validate('edit');
     if ($val->run()) {
         $currency->name = Input::post('name');
         $currency->symbol = Input::post('symbol');
         $currency->country = Input::post('country');
         $currency->is_default = Input::post('is_default');
         $currency->exchange_rate = Input::post('exchange_rate');
         if ($currency->save()) {
             Session::set_flash('success', e('Updated currency #' . $id));
             Response::redirect('admin/currencies');
         } else {
             Session::set_flash('error', e('Could not update currency #' . $id));
         }
     } else {
         if (Input::method() == 'POST') {
             $currency->name = $val->validated('name');
             $currency->symbol = $val->validated('symbol');
             $currency->country = $val->validated('country');
             $currency->is_default = $val->validated('is_default');
             $currency->exchange_rate = $val->validated('exchange_rate');
             Session::set_flash('error', $val->error());
         }
         $this->template->set_global('currency', $currency, false);
     }
     $countries = Model_Country::find('all', array('order_by' => array(array('name', 'asc'))));
     $this->template->set_global('countries', $countries);
     $this->template->set_global('yes_no', array('0' => 'No', '1' => 'Yes'));
     $this->template->title = "Currencies";
     $this->template->content = View::forge('admin/currencies/edit');
 }
Beispiel #16
0
 /**
  * Return an array if the "multiple" attribute is set
  *
  * @param mixed $varInput
  *
  * @return mixed
  */
 protected function validator($varInput)
 {
     // Store the order value
     if ($this->orderField != '') {
         $arrNew = array_map('StringUtil::uuidToBin', explode(',', \Input::post($this->strOrderName)));
         // Only proceed if the value has changed
         if ($arrNew !== $this->{$this->orderField}) {
             $this->Database->prepare("UPDATE {$this->strTable} SET tstamp=?, {$this->orderField}=? WHERE id=?")->execute(time(), serialize($arrNew), $this->activeRecord->id);
             $this->objDca->createNewVersion = true;
             // see #6285
         }
     }
     // Return the value as usual
     if ($varInput == '') {
         if ($this->mandatory) {
             $this->addError(sprintf($GLOBALS['TL_LANG']['ERR']['mandatory'], $this->strLabel));
         }
         return '';
     } elseif (strpos($varInput, ',') === false) {
         $varInput = \StringUtil::uuidToBin($varInput);
         return $this->multiple ? array($varInput) : $varInput;
     } else {
         $arrValue = array_filter(explode(',', $varInput));
         return $this->multiple ? array_map('StringUtil::uuidToBin', $arrValue) : \StringUtil::uuidToBin($arrValue[0]);
     }
 }
Beispiel #17
0
 public function action_edit($id = null)
 {
     is_null($id) and Response::redirect('news/category');
     if (!($news_category = Model_News_Category::find($id))) {
         Session::set_flash('error', 'Could not find news_category #' . $id);
         Response::redirect('news/category');
     }
     $val = Model_News_Category::validate('edit');
     if ($val->run()) {
         $news_category->name = Input::post('name');
         if ($news_category->save()) {
             Session::set_flash('success', 'Updated news_category #' . $id);
             Response::redirect('news/category');
         } else {
             Session::set_flash('error', 'Could not update news_category #' . $id);
         }
     } else {
         if (Input::method() == 'POST') {
             $news_category->name = $val->validated('name');
             Session::set_flash('error', $val->error());
         }
         $this->template->set_global('news_category', $news_category, false);
     }
     $this->template->title = "News_categories";
     $this->template->content = View::forge('news/category/edit');
 }
 public function subir($contrato_id)
 {
     $this->contrato = $contrato_id;
     if (Input::hasPost('oculto')) {
         //para saber si se envió el form
         $_FILES['archivo']['name'] = date("Y_m_d_H_i_s_") . $_FILES['archivo']['name'];
         $archivo = Upload::factory('archivo');
         //llamamos a la libreria y le pasamos el nombre del campo file del formulario
         $archivo->setExtensions(array('pdf'));
         //le asignamos las extensiones a permitir
         $url = '/files/upload/';
         $archivo->setPath(getcwd() . $url);
         if ($archivo->isUploaded()) {
             if ($archivo->save()) {
                 Flash::valid('Archivo subido correctamente!!!');
                 $nuevo_documento = new Documentos(Input::post("documentos"));
                 // $nuevo_documento->contratos_id = $contrato_id;
                 // $nuevo_documento->subido_por = Auth::get("id");
                 // $nuevo_documento->tipo_documento = ;
                 $nuevo_documento->url = $url . $_FILES['archivo']['name'];
                 if ($nuevo_documento->save()) {
                     Flash::valid("Documento Guardado");
                 } else {
                     Flash::error("No se pudo guardar el documento");
                 }
             }
         } else {
             Flash::warning('No se ha Podido Subir el Archivo...!!!');
         }
     }
 }
 public function executePostActionsHook($strAction, \DataContainer $dc)
 {
     if ($strAction == FieldPalette::$strFieldpaletteRefreshAction) {
         if (\Input::post('field')) {
             \Controller::loadDataContainer($dc->table);
             $strName = \Input::post('field');
             $arrField = $GLOBALS['TL_DCA'][$dc->table]['fields'][$strName];
             // Die if the field does not exist
             if (!is_array($arrField)) {
                 header('HTTP/1.1 400 Bad Request');
                 die('Bad Request');
             }
             /** @var \Widget $strClass */
             $strClass = $GLOBALS['BE_FFL'][$arrField['inputType']];
             // Die if the class is not defined or inputType is not fieldpalette
             if ($arrField['inputType'] != 'fieldpalette' || !class_exists($strClass)) {
                 header('HTTP/1.1 400 Bad Request');
                 die('Bad Request');
             }
             $arrData = \Widget::getAttributesFromDca($arrField, $strName, $dc->activeRecord->{$strName}, $strName, $dc->table, $dc);
             /** @var \Widget $objWidget */
             $objWidget = new $strClass($arrData);
             $objWidget->currentRecord = $dc->id;
             die(json_encode(array('field' => $strName, 'target' => '#ctrl_' . $strName, 'content' => $objWidget->generate())));
         }
         header('HTTP/1.1 400 Bad Request');
         die('Bad Request');
     }
 }
Beispiel #20
0
 public function action_edit($id = null)
 {
     is_null($id) and Response::redirect('faculty');
     if (!($faculty = Model_Faculty::find($id))) {
         Session::set_flash('error', 'Could not find faculty #' . $id);
         Response::redirect('faculty');
     }
     $val = Model_Faculty::validate('edit');
     if ($val->run()) {
         $faculty->name = Input::post('name');
         $faculty->phone = Input::post('phone');
         $faculty->email = Input::post('email');
         $faculty->hotline = Input::post('hotline');
         $faculty->address = Input::post('address');
         if ($faculty->save()) {
             Session::set_flash('success', 'Updated faculty #' . $id);
             Response::redirect('faculty');
         } else {
             Session::set_flash('error', 'Could not update faculty #' . $id);
         }
     } else {
         if (Input::method() == 'POST') {
             $faculty->name = $val->validated('name');
             $faculty->phone = $val->validated('phone');
             $faculty->email = $val->validated('email');
             $faculty->hotline = $val->validated('hotline');
             $faculty->address = $val->validated('address');
             Session::set_flash('error', $val->error());
         }
         $this->template->set_global('faculty', $faculty, false);
     }
     $this->template->title = "Faculties";
     $this->template->content = View::forge('faculty/edit');
 }
Beispiel #21
0
 /**
  * Редактирование записи
  * 
  * @param int $id
  */
 public function action_edit($id = null)
 {
     is_null($id) and \Response::redirect_back('admin/videos');
     if (!($video = \Model_Video::find($id))) {
         \Session::set_flash('error', 'Невозможно найти видео #' . $id);
         \Response::redirect_back('admin/videos');
     }
     $val = \Model_Video::validate('edit');
     if ($val->run()) {
         $video->videoid = \Input::post('videoid');
         if ($video->save()) {
             \Session::set_flash('success', 'Видео обновлено.');
             \Response::redirect_back('admin/videos');
         } else {
             \Session::set_flash('error', 'Could not update video #' . $id);
         }
     } else {
         if (\Input::method() == 'POST') {
             $video->videoid = $val->validated('videoid');
             \Session::set_flash('error', $val->error());
         }
         $this->template->set_global('video', $video, false);
     }
     $this->template->content = \View::forge('videos/edit');
 }
 public function executePostActionsHook($strAction, \DataContainer $dc)
 {
     if ($strAction !== static::$uploadAction) {
         return false;
     }
     // Check whether the field is allowed for regular users
     if (!isset($GLOBALS['TL_DCA'][$dc->table]['fields'][\Input::post('field')]) || $GLOBALS['TL_DCA'][$dc->table]['fields'][\Input::post('field')]['exclude'] && !\BackendUser::getInstance()->hasAccess($dc->table . '::' . \Input::post('field'), 'alexf')) {
         \System::log('Field "' . \Input::post('field') . '" is not an allowed selector field (possible SQL injection attempt)', __METHOD__, TL_ERROR);
         $objResponse = new ResponseError();
         $objResponse->setMessage('Bad Request');
         $objResponse->output();
     }
     $this->name = \Input::post('field');
     $this->id = \Input::post('field');
     $this->field = \Input::post('field');
     if ($dc->activeRecord === null) {
         $dc->activeRecord = General::getModelInstance($dc->table, $dc->id);
     }
     // add dca attributes
     $this->addAttributes(\Widget::getAttributesFromDca($GLOBALS['TL_DCA'][$dc->table]['fields'][$this->name], $this->name));
     $objResponse = $this->upload();
     /** @var Response */
     if ($objResponse instanceof Response) {
         $objResponse->output();
     }
 }
 public function action_edit($id = null)
 {
     $setting = Model_Setting::find($id);
     $val = Model_Setting::validate('edit');
     if ($val->run()) {
         $setting->setting_key = Input::post('setting_key');
         $setting->setting_title = Input::post('setting_title');
         $setting->setting_value = Input::post('setting_value');
         $setting->setting_data_type_id = Input::post('setting_data_type_id');
         if ($setting->save()) {
             Session::set_flash('success', e('Updated setting #' . $id));
             Response::redirect('admin/settings/view/' . $setting->id);
         } else {
             Session::set_flash('error', e('Could not update setting #' . $id));
         }
     } else {
         if (Input::method() == 'POST') {
             $setting->setting_key = $val->validated('setting_key');
             $setting->setting_title = $val->validated('setting_title');
             $setting->setting_value = $val->validated('setting_value');
             $setting->setting_data_type_id = $val->validated('setting_data_type_id');
             Session::set_flash('error', $val->error());
         }
         $this->template->set_global('setting', $setting, false);
     }
     $this->template->set_global('data_types', Model_Setting_Data_Type::find('all', array('order_by' => array(array('name', 'asc')))));
     $this->template->title = "Settings";
     $this->template->content = View::forge('admin/settings/edit');
 }
Beispiel #24
0
 protected function update_sort_order()
 {
     if (!($ids = \Util_Array::cast_values(explode(',', \Input::post('ids')), 'int', true))) {
         throw new \HttpInvalidInputException('Invalid input data.');
     }
     return \Site_Model::update_sort_order($ids, \News\Model_NewsCategory::forge());
 }
Beispiel #25
0
 public function action_login()
 {
     // Already logged in
     Auth::check() and Response::redirect('admin');
     $val = Validation::forge();
     if (Input::method() == 'POST') {
         $val->add('email', 'Email or Username')->add_rule('required');
         $val->add('password', 'Password')->add_rule('required');
         if ($val->run()) {
             if (!Auth::check()) {
                 if (Auth::login(Input::post('email'), Input::post('password'))) {
                     // assign the user id that lasted updated this record
                     foreach (\Auth::verified() as $driver) {
                         if (($id = $driver->get_user_id()) !== false) {
                             // credentials ok, go right in
                             $current_user = Model\Auth_User::find($id[1]);
                             Session::set_flash('success', e('Welcome, ' . $current_user->username));
                             Response::redirect_back('admin');
                         }
                     }
                 } else {
                     $this->template->set_global('login_error', 'Login failed!');
                 }
             } else {
                 $this->template->set_global('login_error', 'Already logged in!');
             }
         }
     }
     $this->template->title = 'ITNT Timesheets Login';
     $this->template->content = View::forge('admin/login', array('val' => $val), false);
 }
Beispiel #26
0
 public function action_edit($id = null)
 {
     is_null($id) and Response::redirect('Survey');
     if (!($survey = Model_Survey::find($id))) {
         Session::set_flash('error', 'Could not find survey #' . $id);
         Response::redirect('Survey');
     }
     $val = Model_Survey::validate('edit');
     if ($val->run()) {
         $survey->title = Input::post('title');
         $survey->description = Input::post('description');
         $survey->type = Input::post('type');
         if ($survey->save()) {
             Session::set_flash('success', 'Updated survey #' . $id);
             Response::redirect('survey');
         } else {
             Session::set_flash('error', 'Could not update survey #' . $id);
         }
     } else {
         if (Input::method() == 'POST') {
             $survey->title = $val->validated('title');
             $survey->description = $val->validated('description');
             $survey->type = $val->validated('type');
             Session::set_flash('error', $val->error());
         }
         $this->template->set_global('survey', $survey, false);
     }
     $this->template->title = "Surveys";
     $this->template->content = View::forge('survey/edit');
 }
Beispiel #27
0
 public function action_repass($onepass)
 {
     if (!Model_User::count(array('where' => array('onepass' => $onepass)))) {
         Response::redirect('user/login/without');
     }
     if (Input::method() == 'POST') {
         $val = Model_User::validate('repass');
         $val->add_field('email', 'Eメール', 'required|valid_email');
         if ($val->run()) {
             $user = Model_User::find('first', array('where' => array('onepass' => $onepass)));
             $last_login = mb_substr($user['last_login'], -4);
             $reset = Input::post('reset');
             if ($last_login == $reset) {
                 $username = Input::post('username');
                 $email = Input::post('email');
                 $password = Input::post('password');
                 if ($username == $user['username'] && $email == $user['email']) {
                     $user->onepass = md5(time());
                     $user->save();
                     $auth = Auth::instance();
                     $old = $auth->reset_password($username);
                     $auth->change_password($old, $password, $username);
                     Response::redirect('user/login');
                 } else {
                     Session::set_flash('na', '<p><span class="alert-error">該当者がいません</span></p>');
                 }
             } else {
                 Session::set_flash('error', "<p>" . $val->show_errors() . "</p>");
             }
         }
         return Model_User::theme('admin/template', 'user/login/repass');
     }
 }
Beispiel #28
0
 /**
  * Run the controller and parse the login template
  */
 public function run()
 {
     $this->Template = new BackendTemplate('be_login');
     // Show a cookie warning
     if (Input::get('referer', true) != '' && empty($_COOKIE)) {
         $this->Template->noCookies = $GLOBALS['TL_LANG']['MSC']['noCookies'];
     }
     $strHeadline = sprintf($GLOBALS['TL_LANG']['MSC']['loginTo'], Config::get('websiteTitle'));
     $this->Template->theme = Backend::getTheme();
     $this->Template->messages = Message::generate();
     $this->Template->base = Environment::get('base');
     $this->Template->language = $GLOBALS['TL_LANGUAGE'];
     $this->Template->languages = System::getLanguages(true);
     $this->Template->title = specialchars($strHeadline);
     $this->Template->charset = Config::get('characterSet');
     $this->Template->action = ampersand(Environment::get('request'));
     $this->Template->userLanguage = $GLOBALS['TL_LANG']['tl_user']['language'][0];
     $this->Template->headline = $strHeadline;
     $this->Template->curLanguage = Input::post('language') ?: str_replace('-', '_', $GLOBALS['TL_LANGUAGE']);
     $this->Template->curUsername = Input::post('username') ?: '';
     $this->Template->uClass = $_POST && empty($_POST['username']) ? ' class="login_error"' : '';
     $this->Template->pClass = $_POST && empty($_POST['password']) ? ' class="login_error"' : '';
     $this->Template->loginButton = specialchars($GLOBALS['TL_LANG']['MSC']['loginBT']);
     $this->Template->username = $GLOBALS['TL_LANG']['tl_user']['username'][0];
     $this->Template->password = $GLOBALS['TL_LANG']['MSC']['password'][0];
     $this->Template->feLink = $GLOBALS['TL_LANG']['MSC']['feLink'];
     $this->Template->frontendFile = Environment::get('base');
     $this->Template->disableCron = Config::get('disableCron');
     $this->Template->ie6warning = sprintf($GLOBALS['TL_LANG']['ERR']['ie6warning'], '<a href="http://ie6countdown.com">', '</a>');
     $this->Template->default = $GLOBALS['TL_LANG']['MSC']['default'];
     $this->Template->output();
 }
Beispiel #29
0
 public function action_edit($id = null)
 {
     $pay = Model_Part::find($id);
     $val = Model_Part::validate('edit');
     if ($val->run()) {
         $pay->status = Input::post('status');
         $pay->price = Input::post('price');
         $pay->ship_number = Input::post('ship_number');
         $pay->box_number = Input::post('box_number');
         $pay->tracking = Input::post('tracking');
         $pay->memo = Input::post('memo');
         if ($pay->save()) {
             Session::set_flash('success', e('Updated pay #' . $id));
             Response::redirect('admin/pay');
         } else {
             Session::set_flash('error', e('Could not update pay #' . $id));
         }
     } else {
         if (Input::method() == 'POST') {
             $pay->status = $val->validated('status');
             $pay->price = $val->validated('price');
             $pay->ship_number = $val->validated('ship_number');
             $pay->box_number = $val->validated('box_number');
             $pay->tracking = $val->validated('tracking');
             $pay->memo = $val->validated('memo');
             Session::set_flash('error', $val->error());
         }
         $this->template->set_global('pay', $pay, false);
     }
     $this->template->title = "pays";
     $this->template->content = View::forge('admin/pay/edit');
 }
Beispiel #30
0
 public function action_edit($id = null)
 {
     parent::has_access("add_leave");
     is_null($id) and Response::redirect('leaves');
     if (!($leave = Model_Leave::find($id))) {
         Session::set_flash('error', 'Could not find leave #' . $id);
         Response::redirect('leaves');
     }
     $val = Model_Leave::validate('edit');
     if ($val->run()) {
         $var_dol_day = Input::post('dol_day');
         $var_dol_month = Input::post('dol_month');
         $var_dol_year = Input::post('dol_year');
         $var_dol = $var_dol_year . '-' . $var_dol_month . '-' . $var_dol_day;
         $leave->date_of_leave = $var_dol;
         $leave->time = Input::post('time');
         $leave->type = Input::post('type');
         if ($leave->save()) {
             Session::set_flash('success', 'Updated leave #' . $id);
             Response::redirect('leaves/view/' . $leave->employee_id);
         } else {
             Session::set_flash('error', 'Could not update leave #' . $id);
         }
     } else {
         if (Input::method() == 'POST') {
             $leave->date_of_leave = $val->validated('date_of_leave');
             $leave->time = $val->validated('time');
             $leave->type = $val->validated('type');
             Session::set_flash('error', $val->error());
         }
         $this->template->set_global('leave', $leave, false);
     }
     $this->template->title = "Leaves";
     $this->template->content = View::forge('leaves/edit');
 }