예제 #1
0
 public function action_create()
 {
     // Check if the user has a character already.
     if ($this->character->loaded()) {
         $this->request->redirect('character/create');
     }
     $character = Jelly::factory('character');
     $post = Validate::factory($_POST)->filter(TRUE, 'trim')->rule('name', 'not_empty')->rule('name', 'min_length', array(3))->rule('name', 'max_length', array(20))->rule('gender', 'not_empty')->rule('race', 'not_empty')->callback('race', array($this, 'valid_race'));
     if ($post->check()) {
         try {
             $values = array('name' => $post['name'], 'gender' => $post['gender'], 'race' => $post['race'], 'user' => $this->user->id, 'money' => 1000, 'hp' => 100, 'max_hp' => 100, 'level' => 1, 'xp' => 0, 'energy' => 100, 'alignment' => 5000, 'zone' => 1);
             $character->set($values);
             $character->save();
             $this->MG->add_history('Created the character: ' . $post['name']);
             $this->request->redirect('character');
         } catch (Validate_Exception $e) {
             // Get the errors using the Validate::errors() method
             $this->errors = $e->array->errors('register');
         }
     } else {
         $this->errors = $post->errors('character/create');
     }
     // Get the races the user can choose from.
     $races = $this->getRaces();
     $this->template->content = View::factory('character/create')->set('post', $post)->set('races', $races);
 }
예제 #2
0
 public function action_add($id)
 {
     // Find the parent
     $parent = Jelly::select('kohanut_page', $id);
     if (!$parent->loaded()) {
         return $this->admin_error(__('Could not find page with ID :id.', array(':id' => $id)));
     }
     // Create the new page object
     $page = Jelly::factory('kohanut_page');
     // Create the view
     $this->view->title = __('Adding New Page');
     $this->view->body = new View('kohanut/pages/add', array('errors' => false, 'success' => false, 'parent' => $parent, 'page' => $page));
     if ($_POST) {
         try {
             $page->set($_POST);
             $page->create_at($parent, Arr::get($_POST, 'location', 'last'));
             // Page was created successfully, redirect to edit
             $this->request->redirect(Route::get('kohanut-admin')->uri(array('controller' => 'pages', 'action' => 'edit', 'params' => $page->id)));
         } catch (Validate_Exception $e) {
             $this->view->body->errors = $e->array->errors('page');
         } catch (Kohanut_Exception $e) {
             $this->view->body->errors = array($e->getMessage());
         }
     }
 }
예제 #3
0
 public function action_register()
 {
     if ($this->user) {
         Request::instance()->redirect('');
     }
     // Experimental facebook connection
     $this->facebook = new Fb();
     // User accessed from facebook!
     if ($this->facebook->validate_fb_params()) {
         $this->facebook->require_frame();
         $_SESSION['fb_uid'] = $this->facebook->require_login();
     } elseif (!isset($_SESSION['fb_uid'])) {
         Request::instance()->redirect('');
     }
     // Check if the user got an account.
     $user_facebook = Jelly::select('user_facebook')->where('facebook_id', '=', $_SESSION['fb_uid'])->load();
     // If we found it, log him in.
     if ($user_facebook->loaded()) {
         $this->a1->force_login($user_facebook->user->username);
         $_SESSION['facebook'] = 'TRUE';
         // Used for verifying if logged in using facebook.
         Request::instance()->redirect('');
     }
     $user = Jelly::factory('user');
     // Validate the form input
     $post = Validate::factory($_POST)->filter(TRUE, 'trim')->rule('username', 'not_empty')->rule('username', 'min_length', array(3))->rule('username', 'max_length', array(20))->rule('username', 'alpha_numeric')->rule('email', 'email')->rule('tos', 'not_empty');
     if ($post->check()) {
         $values = array('username' => $post['username'], 'email' => $post['email']);
         // Assign the validated data to the sprig object
         $user->set($values);
         // Hash the password
         $user->password = '';
         // Set the default role for registered user.
         $user->role = 'facebook';
         try {
             // Create the new user
             $testy = $user->save();
             //print_r($testy);
             $user_id = mysql_insert_id();
             $ufb = Jelly::factory('user_facebook');
             $ufb->facebook_id = $_SESSION['fb_uid'];
             $ufb->user = $user_id;
             $ufb->save();
             $this->a1->force_login($values['username']);
             $_SESSION['facebook'] = 'TRUE';
             // Used for verifying if logged in using facebook.
             // Redirect the user to the login page
             $this->request->redirect('');
         } catch (Validate_Exception $e) {
             // Get the errors using the Validate::errors() method
             $this->errors = $e->array->errors('register');
         }
     } else {
         $this->errors = $post->errors('account/register');
     }
     if (!empty($this->errors)) {
         Message::set(Message::ERROR, $this->errors);
     }
     $this->template->content = View::factory('facebook/register')->set('post', $post->as_array());
 }
예제 #4
0
파일: supplies.php 프로젝트: TdroL/hurtex
 public function action_create()
 {
     $this->content->bind('form', $supply);
     // uzywajac bind() widok zapamieta referencje a nie wartosc
     $this->content->bind('suppliers', $suppliers);
     $this->content->bind('errors', $errors);
     // czyli: jesli zmienimy tutaj wartosc zmiennych $supply
     // lub $error to bedzie to w widoku te zmienne tez beda zmienione
     $supply = Jelly::factory('supply');
     $id = $this->request->param('id');
     $supply->product = Jelly::select('product', $id);
     if (!$supply->product->loaded()) {
         $this->request->redirect($this->_base);
     }
     if ($_POST and !$this->session->get($_POST['seed'], FALSE)) {
         try {
             $supply->set($_POST);
             $supply->save();
             $this->session->set($_POST['seed'], TRUE);
             // 'seed' jest zintegrowany w formularz
             $this->request->redirect($this->_base);
         } catch (Validate_Exception $e) {
             $errors = $e->errors();
         }
     }
 }
예제 #5
0
 /**
  * Create a new post.
  */
 public function action_reply($id)
 {
     $topic = Jelly::select('forum_topic')->where('id', '=', $id)->load();
     // Make sure the topic exists
     if (!$topic->loaded()) {
         Message::set(Message::ERROR, 'Topic does not exist');
         $this->request->redirect('forum');
     }
     $this->title = 'Forum - Reply to ' . $topic->title;
     // Validate the form input
     $post = Validate::factory($_POST)->filter(TRUE, 'trim')->filter(TRUE, 'htmlspecialchars', array(ENT_QUOTES))->rule('title', 'not_empty')->rule('title', 'min_length', array(3))->rule('title', 'max_length', array(20))->rule('content', 'not_empty')->rule('content', 'min_length', array(5))->rule('content', 'max_length', array(1000));
     if ($post->check()) {
         $values = array('title' => $post['title'], 'content' => $post['content'], 'user' => $this->user->id, 'topic' => $id);
         $message = Jelly::factory('forum_post');
         // Assign the validated data to the Jelly object
         $message->set($values);
         $message->save();
         $topic_id = $id;
         $topic = Jelly::select('forum_topic')->where('id', '=', $topic_id)->load();
         $topic->posts = $topic->posts + 1;
         $topic->save();
         Message::set(Message::SUCCESS, 'You posted a new reply.');
         $this->request->redirect('forum/topic/' . $id);
     } else {
         $this->errors = $post->errors('forum');
     }
     if (!empty($this->errors)) {
         Message::set(Message::ERROR, $this->errors);
     }
     $this->template->content = View::factory('forum/post/create')->set('post', $post->as_array());
 }
예제 #6
0
 /**
  * Create a new topic.
  */
 public function action_new_topic($id)
 {
     $this->title = 'Forum - New Topic';
     $category = Jelly::select('forum_category')->where('id', '=', $id)->load();
     if (!$category->loaded()) {
         Message::set(Message::ERROR, 'Category does not exist');
         $this->request->redirect('forum');
     }
     // Validate the form input
     $post = Validate::factory($_POST)->filter(TRUE, 'trim')->filter(TRUE, 'htmlspecialchars', array(ENT_QUOTES))->rule('title', 'not_empty')->rule('title', 'min_length', array(3))->rule('title', 'max_length', array(20))->rule('content', 'not_empty')->rule('content', 'min_length', array(5))->rule('content', 'max_length', array(1000));
     if ($post->check()) {
         $topic_values = array('title' => $post['title'], 'user' => $this->user->id, 'category' => $id, 'status' => 'open', 'posts' => '1');
         $topic = Jelly::factory('forum_topic');
         // Assign the validated data to the sprig object
         $topic->set($topic_values);
         $topic->save();
         $topic_id = $topic->id;
         $post_values = array('title' => $post['title'], 'content' => $post['content'], 'user' => $this->user->id, 'topic' => $topic_id);
         $message = Jelly::factory('forum_post');
         // Assign the validated data to the sprig object
         $message->set($post_values);
         $message->save();
         Message::set(Message::SUCCESS, 'You created a topic.');
         $this->request->redirect('forum/category/' . $id);
     } else {
         $this->errors = $post->errors('forum');
     }
     if (!empty($this->errors)) {
         Message::set(Message::ERROR, $this->errors);
     }
     $this->template->content = View::factory('forum/topic/create')->set('post', $post->as_array());
 }
예제 #7
0
파일: api.php 프로젝트: netbiel/core
 /**
  * Construct controller
  */
 public function before()
 {
     // Log request
     Jelly::factory('api_request')->set(array('ip' => Request::$client_ip, 'request' => $this->request->uri . (empty($_GET) ? '' : '?' . http_build_query($_GET))))->save();
     // Rate limit
     $rate_span = Kohana::config('api.rate_span');
     $rate_limit = Kohana::config('api.rate_limit');
     $requests = Model_API_Request::request_count(time() - $rate_span, Request::$client_ip);
     $requests_left = $rate_limit - $requests;
     if ($requests_left < 0) {
         throw new Controller_API_Exception('Request limit reached');
     }
     // Check version
     $this->version = $this->request->param('version');
     if (!in_array($this->version, self::$_versions)) {
         throw new Controller_API_Exception('Invalid version');
     }
     // Check format
     $this->format = $this->request->param('format');
     !$this->format and $this->format = self::FORMAT_JSON;
     if (!in_array($this->format, self::$_formats)) {
         throw new Controller_API_Exception('Invalid format');
     }
     // Set result defaults
     $this->data = array('version' => $this->version, 'requests' => $requests, 'requests_left' => $requests_left, 'request_window' => $rate_span);
     return parent::before();
 }
예제 #8
0
 public function action_register()
 {
     // There are no errors by default
     $errors = FALSE;
     // Create an instance of Model_Auth_User
     $user = Jelly::factory('user');
     // Check if the form was submitted
     if ($_POST) {
         /**
          * Load the $_POST values into our model.
          * 
          * We use Arr::extract() and specify the fields to add
          * by hand so that a malicious user can't do (for example)
          * `$_POST['roles'][] = 2;` and make themselves an administrator.
          */
         $user->set(Arr::extract($_POST, array('email', 'username', 'password', 'password_confirm')));
         // Add the 'login' role to the user model
         $user->add('roles', 1);
         try {
             // Try to save our user model
             $user->save();
             // Redirect to the index page
             $this->request->redirect(Route::get('default')->uri(array('action' => 'index')));
         } catch (Validate_Exception $e) {
             // Load custom error messages from `messages/forms/user/register.php`
             $errors = $e->array->errors('forms/user/register');
         }
     }
     // Set template title
     $this->template->title = 'Register';
     // Display the 'register' template
     $this->template->content = View::factory('user/register')->set('user', $user)->set('errors', $errors);
 }
예제 #9
0
파일: flickr.php 프로젝트: azuya/mmi-api
 /**
  * Verify the Flickr credentials.
  *
  * @throws	Kohana_Exception
  * @return	boolean
  */
 public function verify()
 {
     // Set the service
     $service = $this->_service;
     if (empty($service)) {
         MMI_Log::log_error(__METHOD__, __LINE__, 'Service not set');
         throw new Kohana_Exception('Service not set in :method.', array(':method' => __METHOD__));
     }
     // Ensure the frob is set
     $frob = NULL;
     if (array_key_exists('frob', $_GET)) {
         $frob = urldecode(Security::xss_clean($_GET['frob']));
     }
     if (empty($frob)) {
         MMI_Log::log_error(__METHOD__, __LINE__, 'Frob parameter missing');
         throw new Kohana_Exception('Frob parameter missing in :method.', array(':method' => __METHOD__));
     }
     // Load existing data from the database
     $auth_config = $this->_auth_config;
     $username = Arr::get($auth_config, 'username');
     $model;
     if (!empty($username)) {
         $model = Model_MMI_API_Tokens::select_by_service_and_username($service, $username, FALSE);
     } else {
         $model = Jelly::factory('MMI_API_Tokens');
     }
     $success = FALSE;
     if ($model->loaded()) {
         // Check if the credentials were previously verified
         $previously_verified = $model->verified;
         if ($previously_verified) {
             $success = TRUE;
         } else {
             // Create a dummy verification code
             $verification_code = $service . '-' . time();
         }
         // Do database update
         if (!$previously_verified) {
             // Get an access token
             $svc = MMI_API::factory($service);
             $token = $svc->get_access_token($verification_code, array('token_key' => $frob, 'token_secret' => $service . '-' . time()));
             // Update the token credentials in the database
             if (isset($token) and $svc->is_valid_token($token)) {
                 $model->token_key = $token->key;
                 $model->token_secret = Encrypt::instance()->encode($token->secret);
                 $model->verified = 1;
                 $model->verification_code = $verification_code;
                 if (!empty($token->attributes)) {
                     $model->attributes = $token->attributes;
                 }
                 $success = MMI_Jelly::save($model, $errors);
                 if (!$success and $this->_debug) {
                     MMI_Debug::dead($errors);
                 }
             }
         }
     }
     return $success;
 }
예제 #10
0
 /**
  * Provider for test type
  */
 public function provider_construction()
 {
     // Set database connection name
     $db = parent::$database_connection;
     // Set result
     $result = DB::select()->from('test_posts');
     return array(array(new Jelly_Collection($result->execute($db), 'Model_Test_Post'), 'Model_Test_Post'), array(new Jelly_Collection($result->execute($db), Jelly::factory('test_post')), 'Model_Test_Post'), array(new Jelly_Collection($result->execute($db)), FALSE), array(new Jelly_Collection($result->as_object()->execute($db)), 'stdClass'), array(new Jelly_Collection($result->execute($db), 'Model_Test_Post'), 'Model_Test_Post'));
 }
예제 #11
0
 /**
  * Attempt to find a page in the CMS, return the response
  *
  * @param  string  The url to load, will be autodetected if needed
  * @return void
  */
 public function action_view($url = NULL)
 {
     if (Kohana::$profiling === TRUE) {
         // Start a new benchmark
         $benchmark = Profiler::start('Kohanut', 'Kohanut Controller');
     }
     // If no $url is passed, default to the server request uri
     if ($url === NULL) {
         $url = $_SERVER['REQUEST_URI'];
     }
     // Trim off Kohana::$base_url
     $url = preg_replace('#^' . Kohana::$base_url . '#', '', $url);
     // Ensure no trailing slash
     $url = preg_replace('/\\/$/', '', $url);
     // Ensure no leading slash
     $url = preg_replace('/^\\//', '', $url);
     // Remove anything ofter a ? or #
     $url = preg_replace('/[\\?#].+/', '', $url);
     // Try to find what to do on this url
     try {
         // Make sure the url is clean. See http://www.faqs.org/rfcs/rfc2396.html see section 2.3
         // TODO - this needs to be better
         if (preg_match("/[^\\/A-Za-z0-9-_\\.!~\\*\\(\\)]/", $url)) {
             Kohana::$log->add('INFO', "Kohanut - Request had unknown characters. '{$url}'");
             throw new Kohanut_Exception("Url request had unknown characters '{$url}'", array(), 404);
         }
         // Check for a redirect on this url
         Jelly::factory('kohanut_redirect')->set(array('url', $url))->go();
         // Find the page that matches this url, and isn't an external link
         $page = Jelly::select('kohanut_page')->where('url', '=', $url)->where('islink', '=', 0)->limit(1)->execute();
         if (!$page->loaded()) {
             // Could not find page in database, throw a 404
             Kohana::$log->add('INFO', "Kohanut - Could not find '{$url}' (404)");
             throw new Kohanut_Exception("Could not find '{$page->url}'", array(), 404);
         }
         // Set the status to 200, rather than 404, which was set by the router with the reflectionexception
         Kohanut::status(200);
         header('Last-Modified: ' . date(DateTime::RFC2822, $page->edited));
         $out = $page->render();
     } catch (Kohanut_Exception $e) {
         // Find the error page
         $error = Jelly::select('kohanut_page')->where('url', '=', 'error')->limit(1)->execute();
         // If i couldn't find the error page, just give a generic message
         if (!$error->loaded()) {
             Kohanut::status(404);
             $this->request->response = View::factory('kohanut/generic404');
             return;
         }
         // Set the response
         $out = $error->render();
     }
     if (isset($benchmark)) {
         // Stop the benchmark
         Profiler::stop($benchmark);
     }
     // Set the response
     $this->request->response = $out;
 }
예제 #12
0
파일: settings.php 프로젝트: jonlb/JxCMS
 public static function set($key, $value, $description = '')
 {
     $setting = Jelly::select('setting')->where('setting', '=', $key)->limit(1)->execute();
     if (!$setting->loaded()) {
         Jelly::factory('setting')->set(array('setting' => $key, 'value' => $value, 'description' => $description))->save();
     } else {
         $setting->value = $value;
         $setting->save();
     }
 }
예제 #13
0
파일: price.php 프로젝트: TdroL/hurtex
 public function save($model, $value, $loaded)
 {
     if ($model->price->changed()) {
         $values = array('value' => $model->price->value, 'vat' => $model->price->vat);
         $price = Jelly::factory('price')->set($values)->save();
         $value = $price->id;
         $model->_late_update[] = array($price, 'product', 'id');
     }
     return $value;
 }
예제 #14
0
 public function action_add_item($feed_id)
 {
     $form = Uniform::factory('Krss_Item');
     //check form and feed
     if ($form->sent() and $data = $form->bind($_POST)->check() and $feed = Jelly::select('krss_feed', $feed_id) and $feed->loaded()) {
         $data['feed'] = $feed;
         Jelly::factory('krss_item')->set($data)->save();
         $redirect_to = isset($_GET['redirect_to']) ? $_GET['redirect_to'] : KRSS . '/feed/show/' . $feed_id;
         Url::redirect($redirect_to);
     }
     $this->template->content = View::factory('krss/add_item')->set(array('form' => $form));
 }
예제 #15
0
파일: jelly.php 프로젝트: smgladkovskiy/A1
 /**
  * Loading user by name
  *
  * @param string $username
  * @param string $password
  * @return object / NULL
  */
 public function load_user($username, $password)
 {
     $user = Jelly::select($this->_config['user_model'])->where($this->_config['columns']['username'], '=', $username)->limit(1)->execute();
     if ($user->loaded()) {
         return $user;
     } else {
         // Creating default user
         // @todo: move this shit to install method
         if (Jelly::select('user')->count() === 0) {
             Jelly::factory('user', array('email' => $this->_config['admin']['email'], 'password' => $this->_config['admin']['password'], 'password_confirm' => $this->_config['admin']['password']))->save();
         }
         return NULL;
     }
 }
예제 #16
0
 public function action_create()
 {
     $this->content->bind('form', $torn);
     $category = Jelly::factory('category');
     $torn = new Torn($category);
     if ($torn->check()) {
         try {
             $category->set($_POST);
             $category->save();
             $this->request->redirect(Route::get('protected')->uri(array('controller' => 'category')));
         } catch (Validate_Exception $e) {
             $torn->catch_errors($e);
         }
     }
 }
예제 #17
0
 /**
  * Tests that NULL values are preserved properly when setting, 
  * and that empty strings, NULLs, etc can be changed freely
  */
 public function testIssue51()
 {
     $author = Jelly::factory('author');
     $author->name = NULL;
     $author->save();
     // Re-find the author to ensure it comes back as NULL
     $this->assertEquals(NULL, Jelly::select('author', $author->id)->name);
     // Save to an empty string
     $author->name = '';
     $author->save();
     // Re-find the author to ensure it comes back as NULL
     $this->assertEquals('', Jelly::select('author', $author->id)->name);
     // Cleanup
     $author->delete();
 }
예제 #18
0
파일: account.php 프로젝트: TdroL/hurtex
 public function action_login()
 {
     $this->content->from = $this->request->param('from');
     if ($_POST) {
         $client = Jelly::factory('client')->set($_POST);
         if ($client->login()) {
             if (!empty($this->content->from)) {
                 $this->request->redirect($this->content->from);
             }
             $this->request->redirect($this->_base);
         }
         $this->content->error = TRUE;
     }
     if (!empty($this->content->from)) {
         $this->content->from = '/from:' . $this->content->from;
     }
 }
예제 #19
0
 public function action_register_employer()
 {
     // The user is already logged in
     if ($this->auth->logged_in()) {
         Message::set(Message::NOTICE, 'If you want to sign up somebody else, please, sign out yourself first.');
         $this->request->redirect('');
     }
     // Show form
     $this->template->content = View::factory('user/register_employer')->bind('post', $post)->bind('employer', $employer)->bind('errors', $errors);
     // Create an instance of Model_Auth_User
     $user = Jelly::factory('user');
     // Create an instance of Model_Employer
     $employer = Jelly::factory('employer');
     // Check if the form was submitted
     if ($_POST) {
         $user->set(Arr::extract($_POST, array('email', 'username', 'password', 'password_confirm')));
         $employer->set(Arr::extract($_POST, array('company', 'description', 'website', 'person', 'address', 'city', 'zipcode', 'country', 'telephone')));
         // Add the 'login' role to the user model
         $user->add('roles', 1);
         // login role - always included
         $user->add('roles', 3);
         // employer role - attached when registered as employer
         // Validate Employer data fields
         // This is a manual check because I cant find any way to do this with jelly using 2 models
         $field = Validate::factory($_POST)->filter(TRUE, 'trim')->rule('company', 'not_empty')->rule('description', 'not_empty')->rule('website', 'not_empty')->rule('website', 'url')->rule('person', 'not_empty')->rule('address', 'not_empty')->rule('city', 'not_empty')->rule('zipcode', 'not_empty')->rule('zipcode', 'numeric')->rule('country', 'not_empty')->rule('telephone', 'not_empty');
         if ($field->check()) {
             try {
                 // Try to save our user model
                 $user->save();
                 // Save User Id to Employer table
                 $employer->user = $user->id;
                 // Try to save our employer model
                 $employer->save();
                 Message::set(Message::SUCCESS, 'You are now registered! Please signin below');
                 // Redirect to the index page
                 Request::instance()->redirect('user/signin');
             } catch (Validate_Exception $e) {
                 // Load custom error messages from `messages/forms/user/register.php`
                 $errors = $e->array->errors('forms/user/register');
             }
         } else {
             // There were errors while posting the employers field - show errors
             $errors = $field->errors('forms/user/register');
         }
     }
 }
예제 #20
0
 public function action_new()
 {
     $redirect = Jelly::factory('kohanut_redirect');
     $errors = false;
     if ($_POST) {
         try {
             $redirect->set($_POST);
             $redirect->save();
             $this->request->redirect(Route::get('kohanut-admin')->uri(array('controller' => 'redirects')));
         } catch (Validate_Exception $e) {
             $errors = $e->array->errors('redirect');
         }
     }
     $this->view->title = "New Redirect";
     $this->view->body = View::factory('/kohanut/redirects/new');
     $this->view->body->redirect = $redirect;
     $this->view->body->errors = $errors;
 }
예제 #21
0
 public function action_create()
 {
     $this->content->bind('form', $torn);
     $project = Jelly::factory('project');
     $torn = new Torn($project);
     if ($torn->check()) {
         try {
             Transaction::begin();
             $project->set($_FILES + $_POST);
             $project->save();
             Transaction::commit();
             $this->request->redirect(Route::get('protected')->uri(array('controller' => 'project')));
         } catch (Validate_Exception $e) {
             Transaction::rollback();
             $torn->catch_errors($e);
         }
     }
 }
예제 #22
0
 /**
  * Tests that passwords are not re-hashed accidentally.
  * 
  * Addresses issue #8
  */
 public function test_change_password()
 {
     $model = Jelly::factory('test_author');
     // Set the password, which should be hashed on save()
     $model->password = '******';
     $model->save();
     // The password should match this sha1 hash
     $this->assertSame('a9993e364706816aba3e25717850c26c9cd0d89d', $model->password);
     // Ensure it's not re-hashed when retrieving
     $this->assertSame('a9993e364706816aba3e25717850c26c9cd0d89d', Jelly::factory('test_author', $model->id)->password);
     // Test updates now
     $model->password = '******';
     $model->save();
     // The password should match this sha1 hash
     $this->assertSame('8cb2237d0679ca88db6464eac60da96345513964', $model->password);
     // Cleanup
     $model->delete();
 }
예제 #23
0
 public function action_new()
 {
     $user = Jelly::factory('kohanut_user');
     $errors = false;
     if ($_POST) {
         try {
             $user->set($_POST);
             $user->set(array('roles' => Jelly::select('kohanut_role')->where('name', '=', 'login')->limit(1)->execute()));
             $user->save();
             Request::instance()->redirect(Route::get('kohanut-admin')->uri(array('controller' => 'users')));
         } catch (Validate_Exception $e) {
             $errors = $e->array->errors('user');
         }
     }
     $this->view->title = "Create New User";
     $this->view->body = new View('kohanut/users/new');
     $this->view->body->user = $user;
     $this->view->body->errors = $errors;
 }
예제 #24
0
 /**
  * @return  void
  */
 public function before()
 {
     parent::before();
     // Start a session
     Session::instance();
     // Load Auth instance
     $this->auth = Auth::instance();
     // Get the currently logged in user or set up a new one.
     // Note that get_user will also do an auto_login check.
     if (($this->user = $this->auth->get_user()) === FALSE) {
         $this->user = Jelly::factory('user');
     }
     if ($this->auto_render) {
         // Initialize default values
         $this->template->title = 'Ninjas-Corner';
         $this->template->content = '';
         $this->template->bind_global('user', $this->user);
     }
 }
예제 #25
0
 public function action_new()
 {
     $layout = Jelly::factory('kohanut_layout');
     // Create the view
     $this->view->title = "New Layout";
     $this->view->body = new View('kohanut/layouts/new', array('layout' => $layout, 'errors' => false));
     if ($_POST) {
         $layout->set($_POST);
         // Try to save the layout
         try {
             $layout->save();
             $this->request->redirect(Route::get('kohanut-admin')->uri(array('controller' => 'layouts')));
         } catch (Validate_Exception $e) {
             $this->view->body->errors = $e->array->errors('layout');
         } catch (Kohanut_Exception $e) {
             $this->view->body->errors = array($e->getMessage());
         }
     }
 }
예제 #26
0
 /**
  * Tests that timestamp auto create and auto update work as expected.
  */
 public function test_auto_create_and_update()
 {
     $post = Jelly::factory('test_post')->set(array('name' => 'test post', 'slug' => 'test-post'));
     // Save time so we can sanity check the created timestamp
     $time = time();
     $post->save();
     // Test timestamp has been set on create
     $this->assertInternalType('integer', $post->created);
     $this->assertGreaterThanOrEqual($time, $post->created);
     // Store created so we can prove it doesn't change on update
     $created = $post->created;
     sleep(1);
     // Wait one second to ensure the next tests are valid
     $post->save();
     $this->assertInternalType('integer', $post->updated);
     $this->assertGreaterThan($post->created, $post->updated);
     $this->assertEquals($created, $post->created);
     // Clean up to ensure other tests don't fail
     $post->delete();
 }
예제 #27
0
 public function action_create()
 {
     $this->content->bind('form', $rolesgroup);
     // uzywajac bind() widok zapamieta referencje a nie wartosc
     $this->content->bind('errors', $errors);
     // czyli: jesli zmienimy tutaj wartosc zmiennych $rolesgroup
     // lub $error to bedzie to w widoku te zmienne tez beda zmienione
     $rolesgroup = Jelly::factory('rolesgroup');
     if ($_POST and !$this->session->get($_POST['seed'], FALSE)) {
         try {
             $rolesgroup->set($_POST);
             $rolesgroup->save();
             $this->session->set($_POST['seed'], TRUE);
             // 'seed' jest zintegrowany w formularz
             $this->request->redirect($this->_base);
         } catch (Validate_Exception $e) {
             $errors = $e->errors();
         }
     }
 }
예제 #28
0
 public function action_create(Params $param)
 {
     $this->content->bind('form', $torn);
     $this->content->bind('project', $project);
     $project = Jelly::select('project')->link($param->id)->load();
     if (!$project->loaded()) {
         throw new Error404_Exception();
     }
     $image = Jelly::factory('image');
     $torn = new Torn($image);
     if ($torn->check()) {
         try {
             $image->set($_FILES + $_POST);
             $image->project = $project;
             $image->save();
             $this->request->redirect(Route::get('protected')->uri(array('controller' => 'image', 'id' => $project->link)));
         } catch (Validate_Exception $e) {
             $torn->catch_errors($e);
         }
     }
 }
예제 #29
0
 public function action_index()
 {
     $view = new View('kohanut/install');
     $post = Validate::factory($_POST)->rule('password', 'not_empty')->rule('repeat', 'not_empty')->rule('password', 'min_length', array(6))->rule('password', 'matches', array('repeat'));
     // No post, just show the install form
     if (!$_POST) {
         $this->request->response = $view;
         return;
     } else {
         if (!$post->check()) {
             $view->errors = $post->errors('kohanut/error');
             $this->request->response = $view;
             return;
         }
     }
     // Everything looks good, lets do it:
     // Create the tables
     DB::query(NULL, "\n\t\t\tCREATE TABLE `kohanut_layouts` (\n\t\t\t\t`id` int(10) unsigned NOT NULL AUTO_INCREMENT,\n\t\t\t\t`name` varchar(50) NOT NULL,\n\t\t\t\t`desc` varchar(256) DEFAULT NULL,\n\t\t\t\t`code` text,\n\t\t\t\tPRIMARY KEY (`id`),\n\t\t\t\tUNIQUE KEY `name` (`name`)\n\t\t\t) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci;")->execute();
     DB::query(NULL, "\n\t\t\tCREATE TABLE `kohanut_pages` (\n\t\t\t\t`id` int(10) unsigned NOT NULL AUTO_INCREMENT,\n\t\t\t\t`url` varchar(256) DEFAULT NULL,\n\t\t\t\t`name` varchar(128) NOT NULL,\n\t\t\t\t`layout` int(10) unsigned DEFAULT '0',\n\t\t\t\t`islink` tinyint(1) unsigned DEFAULT '0',\n\t\t\t\t`showmap` tinyint(3) unsigned DEFAULT '1',\n\t\t\t\t`shownav` tinyint(3) unsigned DEFAULT '1',\n\t\t\t\t`title` varchar(256) DEFAULT NULL,\n\t\t\t\t`metadesc` text,\n\t\t\t\t`metakw` text,\n\t\t\t\t`lft` int(10) unsigned DEFAULT NULL,\n\t\t\t\t`rgt` int(10) unsigned DEFAULT NULL,\n\t\t\t\t`lvl` int(10) unsigned DEFAULT NULL,\n\t\t\t\t`scp` int(10) unsigned DEFAULT NULL,\n\t\t\t\tPRIMARY KEY (`id`),\n\t\t\t\tKEY `Page-Layout` (`layout`),\n\t\t\t\tCONSTRAINT `Page-Layout` FOREIGN KEY (`layout`) REFERENCES `kohanut_layouts` (`id`) ON UPDATE NO ACTION\n\t\t\t) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci;")->execute();
     DB::query(NULL, "\n\t\t\tCREATE TABLE `kohanut_redirects` (\n\t\t\t\t`id` int(10) unsigned NOT NULL AUTO_INCREMENT,\n\t\t\t\t`url` varchar(255) NOT NULL,\n\t\t\t\t`newurl` varchar(255) NOT NULL,\n\t\t\t\t`type` enum('301','302') NOT NULL DEFAULT '302',\n\t\t\t\tPRIMARY KEY (`id`)\n\t\t\t) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci;")->execute();
     DB::query(NULL, "\n            CREATE TABLE `kohanut_roles` (\n            `id` int(11) UNSIGNED NOT NULL AUTO_INCREMENT,\n            `name` varchar(32) NOT NULL,\n            `description` varchar(255) NOT NULL,\n            PRIMARY KEY  (`id`),\n            UNIQUE KEY `uniq_name` (`name`)\n            ) ENGINE=InnoDB  DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci;")->execute();
     DB::query(NULL, "\n            CREATE TABLE IF NOT EXISTS `kohanut_users` (\n            `id` int(11) UNSIGNED NOT NULL AUTO_INCREMENT,\n            `email` varchar(127) NOT NULL,\n            `username` varchar(32) NOT NULL DEFAULT '',\n            `password` char(50) NOT NULL,\n            `logins` int(10) UNSIGNED NOT NULL DEFAULT '0',\n            `last_login` int(10) UNSIGNED,\n            PRIMARY KEY  (`id`),\n            UNIQUE KEY `uniq_username` (`username`),\n            UNIQUE KEY `uniq_email` (`email`)\n            ) ENGINE=InnoDB  DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci;")->execute();
     DB::query(NULL, "\n            CREATE TABLE IF NOT EXISTS `kohanut_roles_users` (\n            `user_id` int(11) UNSIGNED NOT NULL,\n            `role_id` int(11) UNSIGNED NOT NULL,\n            PRIMARY KEY  (`user_id`,`role_id`),\n            KEY `fk_role_id` (`role_id`)\n          ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci;")->execute();
     DB::query(NULL, "\n\t\t\tCREATE TABLE `kohanut_blocks` (\n\t\t\t\t`id` int(11) NOT NULL AUTO_INCREMENT,\n\t\t\t\t`page` int(11) NOT NULL,\n\t\t\t\t`area` int(11) NOT NULL,\n\t\t\t\t`order` int(11) NOT NULL,\n\t\t\t\t`elementtype` int(11) NOT NULL,\n\t\t\t\t`element` int(11) NOT NULL,\n\t\t\t\tPRIMARY KEY (`id`)\n\t\t\t) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci;")->execute();
     DB::query(NULL, "\n\t\t\tCREATE TABLE `kohanut_element_content` (\n\t\t\t\t`id` int(10) unsigned NOT NULL AUTO_INCREMENT,\n\t\t\t\t`code` text NOT NULL,\n\t\t\t\t`markdown` int(1) unsigned NOT NULL DEFAULT '1',\n\t\t\t\t`twig` int(1) unsigned NOT NULL DEFAULT '1',\n\t\t\t\tPRIMARY KEY (`id`)\n\t\t\t) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci;")->execute();
     DB::query(NULL, "\n\t\t\tCREATE TABLE `kohanut_element_snippet` (\n\t\t\t\t`id` int(10) unsigned NOT NULL AUTO_INCREMENT,\n\t\t\t\t`code` text NOT NULL,\n\t\t\t\t`name` varchar(127) NOT NULL,\n\t\t\t\t`markdown` tinyint(1) unsigned NOT NULL DEFAULT '1',\n\t\t\t\t`twig` tinyint(1) unsigned NOT NULL DEFAULT '1',\n\t\t\t\tPRIMARY KEY (`id`)\n\t\t\t) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci;")->execute();
     DB::query(NULL, "\n\t\t\tCREATE TABLE `kohanut_element_request` (\n\t\t\t\t`id` int(10) unsigned NOT NULL AUTO_INCREMENT,\n\t\t\t\t`url` text NOT NULL,\n\t\t\t\tPRIMARY KEY (`id`)\n\t\t\t) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci;")->execute();
     DB::query(NULL, "\n\t\t\tCREATE TABLE `kohanut_elementtypes` (\n\t\t\t\t`id` int(10) unsigned NOT NULL AUTO_INCREMENT,\n\t\t\t\t`name` varchar(127) NOT NULL,\n\t\t\t\tPRIMARY KEY (`id`)\n\t\t\t) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci;")->execute();
     // Create sample layouts, pages, and content
     $queries = explode(";\n", trim("\n\t\t\t\n\t\t\tINSERT INTO `kohanut_blocks` (`id`, `page`, `area`, `order`, `elementtype`, `element`) VALUES\n\t\t\t\t(1, 1, 1, 3, 1, 1),\n\t\t\t\t(7, 11, 1, 1, 1, 5),\n\t\t\t\t(8, 13, 1, 1, 1, 7),\n\t\t\t\t(15, 15, 1, 1, 1, 11),\n\t\t\t\t(16, 18, 1, 1, 1, 13),\n\t\t\t\t(17, 21, 1, 1, 1, 14),\n\t\t\t\t(19, 17, 1, 1, 2, 1),\n\t\t\t\t(24, 24, 1, 3, 3, 2),\n\t\t\t\t(25, 24, 1, 1, 1, 20),\n\t\t\t\t(26, 24, 1, 4, 3, 2),\n\t\t\t\t(28, 20, 1, 1, 1, 22),\n\t\t\t\t(29, 16, 1, 1, 1, 23);\n\t\t\t\n\t\t\tINSERT INTO `kohanut_elementtypes` (`id`, `name`) VALUES\n\t\t\t\t(1, 'content'), (2, 'request'), (3, 'snippet');\n\t\t\t\n\t\t\tINSERT INTO `kohanut_element_content` (`id`, `code`, `markdown`, `twig`) VALUES (1, '# Thanks for Using Kohanut!\n\nIf you are seeing this message that Kohanut has been successfully installed and is ready to go!  You can browse around the default site using the navigation at the top of the screen.  To log in to the admin and start making changes simply browse to [/admin](/admin) and log in using the password you entered during the install.  Enjoy!', 1, 0);\n\t\t\tINSERT INTO `kohanut_element_content` (`id`, `code`, `markdown`, `twig`) VALUES (5, '# Page not found\n\nThe page could not be found.  You could try going [Home](/) or see our [Products](/products).\n\n{{ Kohanut.status(404) }}', 1, 1);\n\t\t\tINSERT INTO `kohanut_element_content` (`id`, `code`, `markdown`, `twig`) VALUES (7, '# Our story\n\nLorem ipsum [dolor sit amet](/about), consectetur adipiscing elit. Pellentesque vitae arcu eros. Nam in arcu id nulla commodo molestie. Donec imperdiet leo et est **iaculis at facilisis** eros imperdiet. Vivamus ultrices commodo dolor, ut egestas tortor lacinia non. Aliquam condimentum gravida velit, id faucibus purus feugiat sit amet. \n\nEtiam eu lacus ultrices enim tincidunt ullamcorper. Aliquam feugiat, nunc ut sodales dictum, velit magna ultrices leo, a laoreet sapien arcu non lorem. \n\n*   Vestibulum _sed rhoncus metus_. Morbi pellentesque molestie elit in ultrices. Praesent mauris ante, vestibulum ac condimentum quis, vestibulum non urna. Duis quis tortor viverra nunc consectetur aliquet sit amet non massa. \n*   Etiam nec dolor eu est porta suscipit vitae in orci. Nam molestie pretium consectetur. \n    1.  Integer velit nunc, lobortis ac viverra vitae, ornare ut elit. \n    2.  Fusce at vestibulum lectus. \n    3.  Vivamus interdum bibendum auctor.', 1, 0);\n\t\t\tINSERT INTO `kohanut_element_content` (`id`, `code`, `markdown`, `twig`) VALUES (11, '# Frequently Asked Questions\n\n#### Lorem Ipsum?\n\nLorem ipsum dolor sit amet consectetor\n\n#### Dolor sit?\n\nBlah blah blah blah blah\n', 1, 0);\n\t\t\tINSERT INTO `kohanut_element_content` (`id`, `code`, `markdown`, `twig`) VALUES (13, '{{ Kohanut.site_map() }}', 0, 1);\n\t\t\tINSERT INTO `kohanut_element_content` (`id`, `code`, `markdown`, `twig`) VALUES (14, '# Header 1\nIf you login to the admin and edit this page you will see that it shows a variety of different elements and how you achieve them in [markdown syntax](http://kohanut.com/docs/using.markdown).  So without further ado, lots of different headers, tables, lists and quotes filled with various Latin phrases.  Enjoy!\n\n## Header 2\nLorem ipsum dolor sit amet, consectetur adipiscing elit.\n\n### Header 3\nLorem ipsum dolor sit amet, consectetur adipiscing elit.\n\n#### Header 4\nLorem ipsum dolor sit amet, consectetur adipiscing elit.\n\n##### Header 5\nLorem ipsum dolor sit amet, consectetur adipiscing elit.\n\n##### Header 6\nLorem ipsum dolor sit amet, consectetur adipiscing elit.\n\n----------\n\n## Blockquote\n\n> Praesent orci nisi, interdum quis, tristique vitae, consectetur sed, arcu. Ut at sapien non dolor semper sollicitudin. Etiam semper erat quis odio. Quisque commodo suscipit velit. Nulla facilisi.\n>\n> \\- *Duis justo quam*\n\n-----------\n\n## Code Segment\n\n    public function()\n    {\n       echo \"You create code by indenting several lines \" .\n            \"by 4 spaces, then all white space after that \" .\n            \"will be preserved.\"; \n    }\n\n-----------\n\n## Lists\n\n### Unsorted List\n*  Blandit in, interdum a\n*  Ultrices non lectus\n*  Nunc id odio\n*  Fusce ultricies\n\n### Ordered list\n1.  Blandit in, interdum a\n2.  Ultrices non lectus\n3.  Nunc id odio\n4.  Fusce ultricies\n   *  Sub list\n      1.  Etcetera\n\n### Definition List\nTitle\n:   Definition of something\n\nTitle 1\nTitle 2\n:   1- Lorem ipsum dolor sit amet.\n:   2- It can also mean this\n\n------------\n\n## Tables\n\n  Property 1   | Property 2     | Property 3    | Property 4\n---------------|----------------|---------------|--------------\n  Lorem ipsum  |Dolor sit amet  |Consectetuer   |Adipiscing elit\nDolor sit amet |Consectetuer    |Adipiscing elit|  Lorem ipsum\nConsectetuer   |Adipiscing elit |  Lorem ipsum  | Dolor sit amet', 1, 0);\n\t\t\tINSERT INTO `kohanut_element_content` (`id`, `code`, `markdown`, `twig`) VALUES (20, '<h1>Basic Samples</h1>\n\n</p>These is a standard content element. It doesn\\'t even use markdown or anything, if you look at it in the admin, you will see it uses regular old html</p>', 1, 0);\n\t\t\tINSERT INTO `kohanut_element_content` (`id`, `code`, `markdown`, `twig`) VALUES (22, '## Samples\n\n*  To see some basic content and snippet examples, click on \"Basic\" from the \"Samples\" category.\n*  The \"About\" link in the navigation doesn\\'t actually represent a page, it just links to \"/about/story\".  Navigation items don\\'t have to actually be a page.\n*  To see a sample of an External Link, click on \"External Link\" in the \"Samples\" category.  It\\'s usually a bad idea to do this from the main nav, but it can be useful.\n*  To see an example of Integrating Kohana, you can see the [contact form](/contact), which uses a sub request, or the [override example](/samples/override).\n\n## Navigation Samples\n\nAs an example, the Home template has a secondary nav (on the right side of the page) with the header turned off, and the depth set to 2.  The code for this nav is like this:\n\n    {{ Kohanut.nav(\\'header=0, depth=2\\') }}\n\nWhere as on all the other pages in this demo the nav has a header and a depth of 1, like this:\n\n    {{ Kohanut.nav(\\'header=1, header_class=nav-header, depth=1\\') }}\n\nSee the complete list of the [navigation options].', 1, 0);\n\t\t\tINSERT INTO `kohanut_element_content` (`id`, `code`, `markdown`, `twig`) VALUES (23, '# Privacy Policy\n\nLorem ipsum dolor sit amet, consectetur adipiscing elit. Vivamus nec justo a est rhoncus rutrum. Mauris vel vehicula diam. Phasellus tristique, augue nec convallis luctus, ante nisi commodo est, a feugiat lacus ipsum sit amet sem. Integer pretium condimentum ante, eu sagittis elit pretium pharetra. In congue semper viverra. Cras tincidunt ligula nec justo placerat vehicula. Vestibulum urna nisl, fermentum in blandit a, accumsan id massa. \n\n*   Praesent adipiscing scelerisque mi. Vivamus aliquam, neque sit amet ultrices viverra, ante lorem condimentum purus, sit amet dapibus purus est ut erat. Mauris odio orci, posuere nec malesuada at, sollicitudin eu mi. Suspendisse eget massa id ante porta sodales. \n*   Aliquam hendrerit dui vitae risus dignissim nec scelerisque dolor dapibus. \n*   Maecenas libero diam, euismod non porttitor a, sollicitudin non tortor. Proin massa leo, consectetur at dapibus non, bibendum ac velit. Sed posuere euismod neque, at ultrices mauris semper sed. Donec purus justo, malesuada sed interdum et, tempus vel sem.', 1, 0);\n\t\t\t\n\t\t\t\n\t\t\tINSERT INTO `kohanut_element_request` (`id`, `url`) VALUES\n\t\t\t\t(1, 'actions/contact');\n\t\t\t\n\t\t\tINSERT INTO `kohanut_element_snippet` (`id`, `code`, `name`, `markdown`, `twig`) VALUES (1, '<div class=\"left\">\n&copy; 2010 Company Name - A slogan is a powerful tool!\n</div>\n\n<div class=\"right\" markdown=\"1\">\nSite by Michael Peters | \nPowered by [Kohanut](http://kohanut.com \"{{ Kohanut.render_stats() }}\") |\nTemplate by [Arcsin](http://arcsin.se/)\n</div>\n\n\n', 'Footer', 1, 1),\n\t\t\t\t(2, '## This is a sample snippet.  \n\nFeatures of snippets:\n\n*   They are handy for things that need to be *reused*. Anything that might appear in **several places**.  For example, the header and footer are both snippets because all the layouts use them, so if you want to change the header or footer, you edit the snippet, rather than editing every layout.\n*   They can use markdown or twig, if you desire.\n', 'Sample Snippet', 1, 0),\n\t\t\t\t(3, '<div id=\"toplinks\">\n   <div id=\"toplinks_inner\" markdown=\"1\">\n[Sitemap](/sitemap) | \n[Privacy Policy](/about/privacy) | \n[FAQ](/about/faq)</div>\n</div>\n<div class=\"clearer\">&nbsp;</div>\n<div id=\"site_title\">\n   <h1><a href=\"/\">Kohanut <span>Sample Site</span></a></h1>\n   <p>Showcasing the power and flexibility of Kohanut CMS</p>\n</div>', 'Header', 1, 0),\n\t\t\t\t(4, '<div class=\"col3 left\"><div class=\"col3_content\" markdown=\"1\">\n\n#### Tincidunt\n\n*  [Consequat molestie](#)\n*  [Sem justo](#)\n*  [Semper eros](#)\n*  [Magna sed purus](#)\n*  [Tincidunt morbi](#)\n\n</div></div>\n\n<div class=\"col3mid left\"><div class=\"col3_content\" markdown=\"1\">\n\n#### Fermentum\n\n*  [Semper fermentum](#)\n*  [Sem justo](#)\n*  [Magna sed purus](#)\n*  [Tincidunt nisl](#)               \n*  [Consequat molestie](#)\n\n</div></div>\n\n<div class=\"col3 right\"><div class=\"col3_content\" markdown=\"1\">\n\n#### Praesent\n\n*  [Semper lobortis](#)\n*  [Consequat molestie](#)          \n*  [Magna sed purus](#)\n*  [Sem morbi](#)\n*  [Tincidunt sed](#)\n\n</div></div>\n\n<div class=\"clear\"></div>', 'Dashboard', 1, 0);\n\t\t\t\n\t\t\tINSERT INTO `kohanut_layouts` (`id`, `name`, `desc`, `code`) VALUES\n\t\t\t\t(1, 'Home', 'Home page', '{{ Kohanut.style(\\'theme/style.css\\') }}\n\n<div id=\"header\">\n   {{ Kohanut.element(\\'snippet\\',\\'header\\') }}\n</div>\n<div id=\"navigation\">\n   {{ Kohanut.main_nav() }}\n   <div class=\"clear\"></div>\n</div>\n<div class=\"clear\"></div>\n\n<div id=\"main_wrapper_outer\"><div id=\"main_wrapper_inner\">\t\n   <div class=\"center_wrapper\">\t\n      <div id=\"main\"><div id=\"main_content\">\n         {{ Kohanut.element_area(1,\\'Main Column\\') }}\n      </div></div>\n      <div id=\"sidebar\"><div id=\"sidebar_content\">\n         <div class=\"box\">\n         <div class=\"left-nav\">{{ Kohanut.nav(\\'header=0, header_class=nav-header, header_elem=h3, depth=2\\') }}</div>\n         </div>\n         {{ Kohanut.element_area(2,\\'Side Column\\') }}\n      </div></div>\n      <div class=\"clear\"></div>\n   </div>\n</div></div>\n\n<div id=\"dashboard\"><div id=\"dashboard_content\">\n   {{ Kohanut.element(\\'snippet\\',\\'dashboard\\') }}\n</div></div>\n\n<div class=\"clear\"></div>\n\n<div id=\"footer\"><div class=\"center_wrapper\">\n   {{ Kohanut.element(\\'snippet\\',\\'footer\\') }}\n</div></div>'),\n\t\t\t\t(2, 'Two Column', 'Standard two column template', '{{ Kohanut.style(\\'theme/style.css\\') }}\n\n<div id=\"header\">\n   {{ Kohanut.element(\\'snippet\\',\\'header\\') }}\n</div>\n<div id=\"navigation\">\n   {{ Kohanut.main_nav() }}\n   <div class=\"clear\"></div>\n</div>\n<div class=\"clear\"></div>\n\n<div id=\"main_wrapper_outer\"><div id=\"main_wrapper_inner\">\t\n   <div class=\"center_wrapper\">\t\n      <div id=\"main\"><div id=\"main_content\">\n         <div id=\"breadcrumbs\" class=\"box_title\">\n            {{ Kohanut.bread_crumbs() }}\n         </div>\n         {{ Kohanut.element_area(1,\\'Main Column\\') }}\n      </div></div>\n      <div id=\"sidebar\"><div id=\"sidebar_content\">\n         <div class=\"box\">\n         <div class=\"left-nav\">{{ Kohanut.nav(\\'header=1, header_class=nav-header, header_elem=h3, depth=1\\') }}</div>\n         </div>\n         {{ Kohanut.element_area(2,\\'Side Column\\') }}\n      </div></div>\n      <div class=\"clear\"></div>\n   </div>\n</div></div>\n\n<div id=\"dashboard\"><div id=\"dashboard_content\">\n   {{ Kohanut.element(\\'snippet\\',\\'dashboard\\') }}\n</div></div>\n\n<div class=\"clear\"></div>\n\n<div id=\"footer\"><div class=\"center_wrapper\">\n   {{ Kohanut.element(\\'snippet\\',\\'footer\\') }}\n</div></div>'),\n\t\t\t\t(3, 'Error', 'error layout', '{{ Kohanut.style(\\'theme/style.css\\') }}\n\n<div id=\"header\">\n   {{ Kohanut.element(\\'snippet\\',\\'header\\') }}\n</div>\n<div id=\"navigation\">\n   {{ Kohanut.main_nav() }}\n   <div class=\"clear\"></div>\n</div>\n<div class=\"clear\"></div>\n\n<div id=\"main_wrapper_outer\"><div id=\"main_wrapper_inner\">\t\n   <div class=\"center_wrapper\">\t\n      \n         {{ Kohanut.element_area(1,\\'Main Column\\') }}\n      \n   </div>\n</div></div>\n\n<div id=\"dashboard\"><div id=\"dashboard_content\">\n   {{ Kohanut.element(\\'snippet\\',\\'dashboard\\') }}\n</div></div>\n\n<div class=\"clear\"></div>\n\n<div id=\"footer\"><div class=\"center_wrapper\">\n   {{ Kohanut.element(\\'snippet\\',\\'footer\\') }}\n</div></div>');\n\t\t\t\n\t\t\tINSERT INTO `kohanut_pages` (`id`, `url`, `name`, `layout`, `islink`, `showmap`, `shownav`, `title`, `metadesc`, `metakw`, `lft`, `rgt`, `lvl`, `scp`) VALUES\n\t\t\t\t(1, '', 'Home', 1, 0, 1, 1, 'Sample Site', 'Meta description!', 'key, words, go, here', 1, 28, 0, 1),\n\t\t\t\t(4, 'http://kohanut.com', 'External Link', 3, 1, 1, 1, '', '', '', 11, 12, 2, 1),\n\t\t\t\t(5, 'about/story', 'About', 2, 1, 1, 1, '', '', '', 14, 21, 1, 1),\n\t\t\t\t(6, '', 'Home', 2, 1, 1, 1, '', '', '', 2, 3, 1, 1),\n\t\t\t\t(11, 'error', 'Error', 3, 0, 0, 0, 'Page not found', '', '', 24, 25, 1, 1),\n\t\t\t\t(13, 'about/story', 'Story', 2, 0, 1, 1, 'Sample - Story', '', '', 15, 16, 2, 1),\n\t\t\t\t(15, 'about/faq', 'FAQ', 2, 0, 1, 1, 'Sample - FAQ', '', '', 17, 18, 2, 1),\n\t\t\t\t(16, 'about/privacy', 'Privacy Policy', 2, 0, 1, 1, 'Sample - Privacy', '', '', 19, 20, 2, 1),\n\t\t\t\t(17, 'contact', 'Contact', 2, 0, 1, 1, 'Sample - Contact', '', '', 22, 23, 1, 1),\n\t\t\t\t(18, 'sitemap', 'Site Map', 2, 0, 0, 0, 'Sample - Site Map', '', '', 26, 27, 1, 1),\n\t\t\t\t(20, 'samples', 'Samples', 2, 0, 1, 1, 'Sample - Samples', '', '', 4, 13, 1, 1),\n\t\t\t\t(21, 'samples/markdown', 'Markdown', 2, 0, 1, 1, 'Sample - Markdown', '', '', 7, 8, 2, 1),\n\t\t\t\t(23, 'samples/override', 'Override', 2, 1, 1, 1, '', '', '', 9, 10, 2, 1),\n\t\t\t\t(24, 'samples/basic', 'Basic', 2, 0, 1, 1, 'Sample - Basic', '', '', 5, 6, 2, 1);\n\t\t\t\n\t\t\tINSERT INTO `kohanut_redirects` (`id`, `url`, `newurl`, `type`) VALUES\n\t\t\t\t(1, 'test', 'about', '301');\n                \n            INSERT INTO `kohanut_roles` (`id`, `name`, `description`) VALUES(1, 'login', 'Login privileges, granted after account confirmation');\n            INSERT INTO `kohanut_roles` (`id`, `name`, `description`) VALUES(2, 'admin', 'Administrative user, has access to everything.');\n\n            ALTER TABLE `kohanut_roles_users`\n                ADD CONSTRAINT `roles_users_ibfk_1` FOREIGN KEY (`user_id`) REFERENCES `kohanut_users` (`id`) ON DELETE CASCADE,\n                ADD CONSTRAINT `roles_users_ibfk_2` FOREIGN KEY (`role_id`) REFERENCES `kohanut_roles` (`id`) ON DELETE CASCADE;\n\n\t\t\t\n\t\t"));
     foreach ($queries as $query) {
         DB::query(NULL, $query)->execute();
     }
     // Create the admin user
     $admin = Jelly::factory('kohanut_user')->set(array('username' => 'admin', 'password' => $_POST['password'], 'password_confirm' => $_POST['password'], 'email' => '', 'roles' => array(1)));
     $admin->save();
     $this->request->response = new View('kohanut/install-success');
     return;
 }
예제 #30
0
파일: roles.php 프로젝트: netbiel/core
 /**
  * Action: edit
  */
 public function action_edit()
 {
     $this->history = false;
     // Load role
     $role_id = (int) $this->request->param('id', 0);
     if ($role_id) {
         $role = Jelly::select('role', $role_id);
         if (!$role->loaded()) {
             throw new Model_Exception($role, $role_id);
         }
         Permission::required($role, Model_Role::PERMISSION_UPDATE, self::$user);
     } else {
         $role = Jelly::factory('role');
         Permission::required($role, Model_Role::PERMISSION_CREATE, self::$user);
     }
     // Handle post
     $errors = array();
     if ($_POST) {
         $role->set($_POST);
         try {
             $role->save();
             $this->request->redirect(Route::get('roles')->uri());
         } catch (Validate_Exception $e) {
             $errors = $e->array->errors('validate');
         }
     }
     // Set title
     $this->page_title = __('Role') . ($role->name ? ': ' . HTML::chars($role->name) : '');
     // Set actions
     if ($role->loaded() && Permission::has($role, Model_Role::PERMISSION_DELETE, self::$user)) {
         $this->page_actions[] = array('link' => Route::model($role, 'delete', false), 'text' => __('Delete role'), 'class' => 'role-delete');
     }
     // Build form
     $form = array('values' => $role, 'errors' => $errors, 'cancel' => Request::back(Route::get('roles')->uri(), true), 'groups' => array(array('fields' => array('name' => array(), 'description' => array()))));
     //Widget::add('main', View_Module::factory('roles/edit', array('role' => $role, 'errors' => $errors)));
     Widget::add('main', View_Module::factory('form/anqh', array('form' => $form)));
 }