Exemple #1
0
 public function action_list()
 {
     $view = View::forge('admin/list');
     if (Session::get('status')) {
         $view->set_global('status', Session::get('status'));
         Session::delete('status');
     }
     if (\Input::post()) {
         if (Auth::delete_user(\Input::param('username'))) {
             Session::set('status', array('css' => 'success', 'msg' => 'ユーザ削除に成功しました'));
             Response::redirect('admin/list');
         } else {
             Session::set('status', array('css' => 'danger', 'msg' => 'ユーザ削除に失敗しました'));
             Response::redirect('admin/list');
         }
     }
     $list = DB::select('id', 'username', 'email', 'group')->from('users')->where('group', '!=', 100);
     $total = $list->execute()->count();
     $config = array('per_page' => 20, 'num_links' => 10, 'show_first' => true, 'show_last' => true, 'total_items' => $total, 'uri_segment' => 3);
     $pagination = Pagination::forge('mypagination', $config);
     $list->limit($pagination->per_page)->offset($pagination->offset);
     $result = $list->execute()->as_array();
     $view->set_global('list', $result);
     $view->set_global('pagination', $pagination);
     return $view;
 }
Exemple #2
0
 public function before()
 {
     if (!\CMF\Auth::check(null, 'view', 'admin_site')) {
         \Response::redirect("/admin/login?next=" . \Uri::string(), 'location');
     }
     \Lang::$autosave = false;
     // Find the lang from the session, or from the user
     if ($this->lang_enabled = \Config::get('cmf.languages.enabled', false)) {
         $lang = \Session::get('cmf.admin.language');
         if ($lang === null) {
             $user = \CMF\Auth::current_user();
             $lang = $user->default_language;
         }
         if (!empty($lang) && strlen($lang) !== 0 && $lang !== null) {
             \CMF::setLang($lang);
         }
     }
     // Allows us to set the interface template via an integer
     $this->mode = \Input::param('_mode', 'default');
     $this->interface_template = \Config::get('cmf.admin.interface_templates.' . $this->mode);
     // A unique ID that can be passed through
     $this->cid = \Input::param('_cid', 'none');
     // Lang info
     $this->current_lang = \Lang::get_lang();
     $this->fallback_lang = \Lang::$fallback;
     $this->lang_lines = \Lang::$lines;
 }
 public function action_login()
 {
     $url_redirect = \Uri::create('system/index/index');
     if (\Auth::check()) {
         \Response::redirect($url_redirect);
     }
     if (\Input::is_ajax()) {
         $val = \Validation::forge('validate_login');
         $val->add_field('email', 'Email', 'required|valid_email');
         $val->add_field('password', 'Password', 'required');
         if ($val->run(array())) {
             if (\Auth::instance()->login(\Input::param('email'), \Input::param('password'))) {
                 if (\Input::param('remember', false)) {
                     \Auth::remember_me();
                 } else {
                     \Auth::dont_remember_me();
                 }
                 $response = array('status' => 'success', 'url' => $url_redirect);
             } else {
                 $messages = \Auth::get_error();
                 $response = array('status' => 'error', 'msg' => $messages);
             }
         } else {
             $messages = $val->error_message();
             $response = array('status' => 'error', 'msg' => $messages);
         }
         return \Response::forge(json_encode($response));
     }
     $this->theme->set_template('login');
     $this->theme->get_template()->set('content', \view::forge('default/login', $this->_arrParam));
 }
 public function action_update()
 {
     // If not logged in redirect to home
     if (!\Auth::check()) {
         \Messages::info(__('user.login.not-logged'));
         \Response::redirect_back();
     }
     // was the login form posted?
     if (\Input::method() == 'POST') {
         // check the credentials.
         if (\Auth::instance()->validate_user(\Auth::get_email(), \Input::param('password'))) {
             if (\Input::param('new_password') === \Input::param('confirm_password')) {
                 \Auth::change_password(\Input::param('password'), \Input::param('new_password'));
                 // inform the user the password change was successful
                 \Messages::success(__('user.login.changed'));
                 \Response::redirect_back();
             }
             \Messages::warning(__('user.login.mismatch-password'));
         } else {
             // login failed, show an error message
             \Messages::error(__('user.login.bad-password'));
         }
         \Response::redirect_back('/backend/account/index/password');
     }
     // display the password reset page
     $this->template->content = View::forge('user/password/update');
 }
Exemple #5
0
 public function action_usercp()
 {
     if (!$this->current_user->logged_in()) {
         Session::set_flash('error', 'You need to be logged in to access is page');
         Session::set_flash('login_redirect', Uri::current());
         Response::redirect('login');
     }
     $this->title('UserCP');
     $this->view = $this->theme->view('users/usercp');
     if (Input::param() != array()) {
         // Set name and email
         $this->current_user->name = Input::param('name');
         $this->current_user->email = Input::param('email');
         // Set new password
         if (Input::param('new_password')) {
             $this->current_user->password = Input::param('new_password');
         }
         // Check if the current password is valid...
         $auth = Model_User::authenticate_login($this->current_user->username, Input::param('current_password'));
         if ($this->current_user->is_valid() and $auth) {
             $this->current_user->save();
             Session::set_flash('success', 'Details saved');
             Response::redirect('usercp');
         } else {
             $errors = $this->current_user->errors();
             if (!$auth) {
                 $errors = array('Current password is invalid.') + $errors;
             }
         }
         $this->view->set('errors', isset($errors) ? $errors : array());
     }
 }
 /**
  * User login
  * 
  * @access public
  * @return void
  */
 public function action_login()
 {
     if ($this->check_logged_type() == 'guest') {
         \Sentry::logout();
     }
     if (!(\Sentry::check() && !\Sentry::user()->is_admin())) {
         \View::set_global('title', 'Login');
         if (\Input::post('login')) {
             $val = \User\Controller_Validate::forge('login');
             if ($val->run()) {
                 try {
                     if (\Sentry::user_exists(\Input::param('identity')) && !\Sentry::user(\Input::param('identity'))->is_admin()) {
                         // check the credentials.
                         $valid_login = \Sentry::login(\Input::param('identity'), \Input::param('password'), true);
                         if ($valid_login) {
                             if ($this->check_logged_type() == 'guest') {
                                 \Messages::info('You cannot log on to with a guest account.');
                                 \Response::redirect(\Uri::front_create('user/account/login'));
                             }
                             \Messages::success('You have logged in successfully');
                             //								\Response::redirect(\Input::referrer(\Uri::front_create('user/account/dashboard')));
                             \Response::redirect(\Uri::front_create('user/account/dashboard'));
                         } else {
                             \Messages::error('Email and/or password is incorrect');
                         }
                     } else {
                         \Messages::error('Email and/or password is incorrect');
                     }
                 } catch (\Sentry\SentryAuthException $e) {
                     // show validation errors
                     //\Messages::error('<h4>There was an error while trying to login</h4>');
                     $errors = $e->getMessage();
                     \Messages::error($errors);
                 } catch (\Sentry\SentryException $e) {
                     // show validation errors
                     //\Messages::error('<h4>There was an error while trying to login</h4>');
                     $errors = $e->getMessage();
                     \Messages::error($errors);
                 }
             } else {
                 if ($val->error() != array()) {
                     // show validation errors
                     foreach ($val->error() as $e) {
                         \Messages::error($e->get_message());
                     }
                 }
             }
         }
         if (\Input::is_ajax()) {
             echo \Theme::instance()->view($this->view_dir . 'login');
         } else {
             \Theme::instance()->set_partial('content', $this->view_dir . 'single_login');
         }
     } else {
         //Keep existing messages
         \Messages::instance()->shutdown();
         \Response::redirect(\Uri::front_create('/'));
     }
 }
Exemple #7
0
 /**
  * Get image params for this request
  */
 protected function getImageParams($override)
 {
     $output = array('q' => \Config::get('image.quality', 80), 'bg' => \Input::param('bg', 'fff'));
     if ($format = \Input::param('fm', \Input::param('format'))) {
         $output['fm'] = $format;
     }
     $output = \Arr::merge($output, $override);
     return \Arr::merge($output, \Input::get());
 }
Exemple #8
0
 public function getData()
 {
     $data = \Input::param();
     $arrFile = $this->upload();
     if (count($arrFile) > 0) {
         $data = array_merge($data, $arrFile);
     }
     return $data;
 }
Exemple #9
0
 /**
  * Creates a new validation instance for customer update.
  *
  * @return Validation
  */
 public static function update()
 {
     $validator = Validation::forge('customer');
     $input = Input::param();
     if (array_key_exists('balance', $input)) {
         $validator->add('balance', 'Balance')->add_rule('trim');
     }
     return $validator;
 }
 /**
  * view method
  *
  * @access public
  * @return void
  * @author ida
  */
 public function view()
 {
     $this->fleamarket_id = \Input::param('fleamarket_id');
     $this->prefectures = \Config::get('master.prefectures');
     $this->entry_styles = \Config::get('master.entry_styles');
     $this->event_statuses = \Model_Fleamarket::getEventStatuses();
     $this->locations = \Model_Location::find('all');
     $this->link_from_list = $this->getLinkFromList();
 }
Exemple #11
0
 /**
  * Creates a new validation instance for product option update.
  *
  * @return Validation
  */
 public static function update()
 {
     $validator = Validation::forge('product_option');
     $input = Input::param();
     if (array_key_exists('name', $input)) {
         $validator->add('name', 'Name')->add_rule('trim')->add_rule('required');
     }
     return $validator;
 }
Exemple #12
0
 /**
  * Runs on 'controller_started' event
  */
 public static function start()
 {
     $controller = \Request::active()->controller_instance;
     $nocache = \Input::param('nocache', \Session::get_flash('nocache', false, true));
     $controller_nocache = !is_null($controller) && method_exists($controller, 'cache') && $controller->cache() === false;
     // Don't run if it's already started, if we have a POST or if the controller says not to
     if ($nocache !== false || strtolower(\Input::method()) == 'post' || $controller_nocache) {
         if (static::$started === true) {
             static::stop();
         }
         return false;
     }
     $config = \Config::get('cmf.cache');
     if ($config['enabled'] !== true) {
         return;
     }
     // Check for excluded URLS
     $uri = '/' . str_replace(array('?debug', '&debug'), '', trim($_SERVER['REQUEST_URI'], '/'));
     if ($uriPath = parse_url($uri, PHP_URL_PATH)) {
         $uri = $uriPath;
     }
     $jq = \Input::get('_', null);
     if ($jq !== null) {
         $uri = str_replace(array("?_={$jq}", "&_={$jq}"), '', $uri);
     }
     $excluded_urls = $config['excluded_urls'];
     foreach ($excluded_urls as $url) {
         $url = \Uri::create($url);
         if ($urlPath = parse_url($url, PHP_URL_PATH)) {
             $url = $urlPath;
         }
         if (strpos($url, '*') !== false && strpos($uri . '/', str_replace('*', '', $url)) === 0) {
             return;
         }
         if ($uri == $url) {
             return;
         }
     }
     // Create the driver and try to get cached content from it
     $driver = static::driver();
     static::$started = true;
     // Add any extra files to check
     $files = \Arr::get($config, 'check_files', array());
     foreach ($files as $file) {
         $driver->addFile($file);
     }
     // Try and get the cached content
     $content = $driver->get($uri);
     // Serve the cached content if found, or continue and add the finish listener
     if (static::$active = $content !== false) {
         $driver->serve($content, static::$modified);
     } else {
         \Event::register('request_finished', 'CMF\\Cache::finish');
     }
 }
Exemple #13
0
 /**
  * Creates a new validation instance for product meta option update.
  *
  * @return Validation
  */
 public static function update()
 {
     if (!($validator = Validation::instance('product_meta_option'))) {
         $validator = Validation::forge('product_meta_option');
     }
     $input = Input::param();
     if (array_key_exists('value', $input)) {
         $validator->add('value', 'Value')->add_rule('trim')->add_rule('required');
     }
     return $validator;
 }
Exemple #14
0
 /**
  * Initialise the wrapper and it's query builder instance
  * 
  * @param string $class The model class
  */
 public function __construct($class, $root, $rootOutput, $params = array(), $field = null)
 {
     $this->class = $class;
     $this->root = $root;
     $this->rootOutput = $rootOutput;
     $this->params = \Input::param();
     $this->field = $field;
     if (is_array($params)) {
         $this->params = \Arr::merge($this->params, $params);
     }
 }
Exemple #15
0
 public function post_commands()
 {
     $params = Input::param();
     require_once 'AWSSDKforPHP/sdk.class.php';
     $ddb = new AmazonDynamoDB();
     $ddb->set_region('dynamodb.ap-northeast-1.amazonaws.com');
     $body = $params['body'];
     $ret = $ddb->put_item(array('TableName' => 'watasync2b', 'Item' => array('id' => array(AmazonDynamoDB::TYPE_STRING => (string) uniqid()), 'command' => array(AmazonDynamoDB::TYPE_STRING => (string) $body), 'created_at' => array(AmazonDynamoDB::TYPE_NUMBER => (string) time()), 'updated_at' => array(AmazonDynamoDB::TYPE_NUMBER => (string) time()))));
     $responce = array("hoge" => "hoge");
     $this->response($responce, 200);
 }
 /**
  * Prepares vars for creating links
  *
  * @access public
  * @return array    The pagination variables
  */
 protected static function initialize()
 {
     static::$total_pages = ceil(static::$total_items / static::$per_page) ?: 1;
     static::$current_page = static::$total_items > 0 && static::$current_page > 1 ? static::$current_page : (int) \Input::param(static::$uri_parameter);
     if (static::$current_page > static::$total_pages) {
         static::$current_page = static::$total_pages;
     } elseif (static::$current_page < 1) {
         static::$current_page = 1;
     }
     // The current page must be zero based so that the offset for page 1 is 0.
     static::$offset = (static::$current_page - 1) * static::$per_page;
 }
Exemple #17
0
 public static function _validation_re_password($val, $password)
 {
     $password = Input::param($password);
     if (empty($password)) {
         return true;
     }
     Validation::active()->set_message('re_password', '新しいパスワードと再入力が異なります。');
     if ($val === $password) {
         return true;
     }
     return false;
 }
 public function before()
 {
     parent::before();
     if (!Auth::check()) {
         return $this->responseJson('nologin', true);
     }
     $this->fleamarket = Model_Fleamarket::find(Input::param('fleamarket_id'));
     if (!$this->fleamarket) {
         return $this->responseJson('nodata', true);
     }
     $this->input = array('user_id' => Auth::get_user_id(), 'fleamarket_id' => Input::param('fleamarket_id'));
     $this->favorite = Model_Favorite::query()->where($this->input)->get_one();
 }
Exemple #19
0
 /**
  * If no action is provided, use one of the BREAD ones
  */
 public function router($resource, $arguments)
 {
     $id = array_values(array_filter($this->expand(\Input::param('id', \Arr::get($arguments, 'id'))), 'is_numeric'));
     $this->unique = $single = count($id) == 1;
     $this->model = \Arr::get($arguments, 'model');
     $this->singular = \Arr::get($arguments, 'singular');
     $this->plural = \Arr::get($arguments, 'plural');
     if (count($id)) {
         $id_key = $single ? 'id' : 'ids';
         $this->params = array($id_key => $single ? $id[0] : $id);
         $this->id = $id[0];
     }
     if ($this->unique && !count($id)) {
         throw new \HttpException('A single item was requested, but no ID was specified', \HttpException::BAD_REQUEST);
     }
     // Check whether a relationship is being requested
     $class = $class = @$arguments['model'];
     if ($single && $resource && !method_exists($this, "action_{$resource}")) {
         if (!$class::metadata()->hasAssociation($resource)) {
             throw new \HttpException('You can only request relationships separately, not normal fields', \HttpException::BAD_REQUEST);
         }
         if (!in_array(strtolower(\Input::method()), array('get', 'patch'))) {
             throw new \HttpException('Only GET and PATCH operations are supported for relationships', \HttpException::BAD_REQUEST);
         }
         $this->field = $resource;
         $resource = null;
     }
     if (!$resource) {
         $method = strtolower(\Input::method());
         switch ($method) {
             case 'get':
                 $resource = $single ? 'read' : 'browse';
                 break;
             case 'post':
                 $resource = $single ? 'edit' : 'add';
                 break;
             case 'put':
             case 'patch':
                 $resource = $single ? 'edit' : null;
                 break;
             case 'delete':
                 $resource = 'delete';
                 break;
             case 'options':
             case 'head':
                 throw new \HttpException('HEAD and OPTIONS methods have not been implemented yet!', \HttpException::NOT_IMPLEMENTED);
                 break;
         }
     }
     return parent::router($resource, $arguments);
 }
Exemple #20
0
 public function __construct($metadata, $model, $prefix = '', $prepopulate = array(), $exclude = array(), $disable_groups = false, $disable_widgets = false, $extra_settings = null)
 {
     $class_name = $metadata->name;
     $model_id = $model->id;
     $this->table_name = $metadata->table['name'];
     $this->prepopulate = \Arr::merge(\Input::get(), $prepopulate);
     $this->exclude = $exclude;
     $this->disable_groups = $disable_groups;
     $this->disable_widgets = $disable_widgets;
     $this->title = $model_id && method_exists($model, 'getFormTitle') ? $model->getFormTitle() : $class_name::singular();
     if (\Input::param('alias', false) !== false) {
         $this->icon = 'link';
         $this->plural = 'Links';
         $this->singular = 'Link';
     } else {
         $this->icon = $class_name::icon();
         $this->plural = $class_name::plural();
         $this->singular = $class_name::singular();
     }
     // Tabs, Groups, Fields
     $this->tabs = $class_name::tabs();
     $this->groups = $class_name::groups();
     $this->default_tab = $class_name::defaultTab();
     $this->default_group = $class_name::defaultGroup();
     // Merge in extra field settings
     $this->fields = \Admin::getFieldSettings($class_name);
     if ($extra_settings !== null && is_array($extra_settings)) {
         $this->fields = \Arr::merge($this->fields, $extra_settings);
     }
     $this->validator_meta = \D::validator()->getMetadataFactory()->getMetadataFor($class_name);
     // Merge any DB settings into the mix...
     $model_settings = $model->settings;
     if (is_array($model_settings)) {
         $_model_settings = array();
         foreach ($model_settings as $key => $value) {
             if (is_array($value) && ($metadata->hasField($key) || $metadata->hasAssociation($key))) {
                 $_model_settings[$key] = $value;
             }
         }
         $this->fields = \Arr::merge($this->fields, $_model_settings);
     }
     // The field data
     $this->processFieldSettings($metadata, $model, $prefix);
     // The group data
     $this->processGroups();
     // The form structure
     $this->processFormStructure();
     $this->assets['js'] = array_unique($this->assets['js']);
     $this->assets['css'] = array_unique($this->assets['css']);
 }
Exemple #21
0
 /**
  * Creates a new validation instance for gateway update.
  *
  * @return Validation
  */
 public static function update()
 {
     $validator = Validation::forge('gateway');
     $input = Input::param();
     if (array_key_exists('type', $input)) {
         $validator->add('type', 'Type')->add_rule('trim')->add_rule('valid_value', Config::get('gateway.types'))->add_rule('required');
     }
     if (array_key_exists('processor', $input)) {
         $validator->add('processor', 'Processor')->add_rule('trim')->add_rule('valid_value', Config::get('gateway.processors'))->add_rule('required');
     }
     if (array_key_exists('meta', $input)) {
         $validator->add('meta', 'Meta Data');
     }
     return $validator;
 }
Exemple #22
0
 /**
  * Creates a new session and API key
  * @return array
  */
 public function action_add()
 {
     $user_type = \Input::param('user_type') ?: 'Admin\\Model_User';
     $scope = \Input::param('scope') ?: 'api';
     if (\CMF\Auth::authenticate(\Input::post('username'), \Input::post('password'), $user_type)) {
         // Purge old keys
         $this->removeOldKeys();
         // Find the logged in user and get an API key for it
         $user = \CMF\Auth::current_user();
         $key = $this->getKey($user, $user_type, $scope);
         $user_data = $user->toArray();
         unset($user_data['encrypted_password']);
         return array('user' => $user_data, 'api_key' => $key->toArray());
     }
     throw new \HttpException('Invalid Login', \HttpException::UNAUTHORIZED);
 }
Exemple #23
0
 public function before()
 {
     parent::before();
     $module = isset($this->request->module) ? $this->request->module : 'none';
     $controller = preg_match('#^(.*\\\\)?Controller_(.*)#', $this->request->controller, $matches);
     $controller = strtolower($matches[2]);
     $action = $this->request->action;
     $this->_arrParam = array('module' => $module, 'controller' => $controller, 'action' => $action);
     $this->_arrParam['named_params'] = $this->request->named_params;
     $this->_arrParam['post_params'] = \Input::param();
     $this->_arrParam['pagination'] = array('per_page' => 5, 'uri_segment' => 'page', 'num_links' => 5, 'name' => 'default');
     $lang_code = \Config::get('language');
     \Config::set('language', \Cookie::get('lang_code'));
     $this->_arrParam['default_lang_code'] = isset($lang_code) && !empty($lang_code) ? $lang_code : 'en';
     \Lang::load(APPPATH . DS . 'lang' . DS . $lang_code . DS . 'language.php');
     $this->theme = Theme::instance();
 }
Exemple #24
0
 public function action_edit($article_id)
 {
     $this->title('Edit');
     $this->view = $this->theme->view('admin/articles/edit');
     $article = Model_Article::find($article_id);
     $this->view->set('article', $article);
     if (Input::param() != array()) {
         $article->values(array('title' => Input::param('title'), 'body' => Input::param('body'), 'status' => Input::param('status'), 'user_id' => $this->current_user->id));
         if ($article->is_valid()) {
             $article->save();
             Session::set_flash('success', 'Article saved');
             Response::redirect('-admin/articles');
         } else {
             $this->view->set('errors', $article->errors());
         }
     }
 }
Exemple #25
0
 public function post_products()
 {
     Log::info(__METHOD__ . ": Start");
     $params = Input::param();
     $asin = $params['product_uid'];
     $obj = new Amazon_Product(Config::get('unique.amazon.public_key'), Config::get('unique.amazon.private_key'));
     $itemobj = $obj->getItemByAsin($asin);
     #Log::error(var_export($itemobj['Items'],true));
     $item = $itemobj['Items']['Item'];
     $responce = array("asin" => $item['ASIN'], "title" => $item['ItemAttributes']['Title'], "image_url" => $item['LargeImage']['URL'], "detail_url" => "", "is_adult" => isset($item['ItemAttributes']['IsAdultProduct']) ? $item['ItemAttributes']['IsAdultProduct'] : 0);
     #Log::error(var_export($responce,true));
     $ins_arr = array('id' => UUID::generate(UUID::UUID_RANDOM, UUID::FMT_STRING), 'product_uid' => $responce['asin'], 'product_type' => "amazon", 'title' => $responce['title'], 'image_url' => $responce['image_url'], 'detail_url' => $responce['detail_url'], 'is_adult' => $responce['is_adult']);
     $ins = new Model_Products($ins_arr);
     $_res = $ins->save();
     $responce = array();
     $this->response($responce, 200);
 }
Exemple #26
0
 public function action_index()
 {
     if (!$this->current_user->group->is_admin) {
         return $this->no_permission();
     }
     $this->title('Settings');
     $this->view = $this->theme->view('admin/settings/index');
     if (Input::param() != array()) {
         foreach (Input::param('settings') as $setting => $value) {
             $s = Model_Setting::find('first', array('where' => array('setting' => $setting)));
             $s->value = $value;
             $s->save();
         }
         Session::set_flash('success', 'Settings saved');
         Response::redirect(Uri::current());
     }
 }
 public function before()
 {
     parent::before();
     if (Input::param('fleamarket_id')) {
         $this->fleamarket = \Model_Fleamarket::find(Input::param('fleamarket_id'));
     }
     if ($this->fleamarket) {
         $fleamarket_abouts = $this->fleamarket->fleamarket_abouts;
         foreach ($fleamarket_abouts as $fleamarket_about) {
             $this->fleamarket_abouts[$fleamarket_about->about_id] = $fleamarket_about;
         }
         $fleamarket_entry_styles = $this->fleamarket->fleamarket_entry_styles;
         foreach ($fleamarket_entry_styles as $fleamarket_entry_style) {
             $this->fleamarket_entry_styles[$fleamarket_entry_style->entry_style_id] = $fleamarket_entry_style;
         }
     }
 }
Exemple #28
0
 /**
  * Loads a seller based on session.
  *
  * @return void
  */
 public static function load()
 {
     Config::load('api', true);
     $seller_id = Session::get(self::$namespace . '.id');
     if ($seller_id) {
         $seller = Service_Seller::find_one($seller_id);
     } elseif ($api_key = Input::param('api_key', Config::get('api.key'))) {
         $api_key = Service_Api_Key::find_one(array('key' => $api_key));
         $seller = $api_key->seller;
     } else {
         $seller = Service_Seller::find_one();
     }
     if (!$seller || !$seller->active()) {
         return false;
     }
     self::set($seller);
     return true;
 }
Exemple #29
0
 /**
  * Creates a new validation instance for seller callback update.
  *
  * @return Validation
  */
 public static function update()
 {
     $validator = Validation::forge('callback');
     $input = Input::param();
     if (array_key_exists('event', $input)) {
         $validator->add('event', 'Event Name')->add_rule('trim')->add_rule('required')->add_rule(array('invalid_event_name' => function ($event_name) {
             $event = Service_Event::find_one(array('name' => $event_name));
             if (!$event) {
                 return false;
             }
             return true;
         }));
     }
     if (array_key_exists('url', $input)) {
         $validator->add('url', 'Callback URL')->add_rule('trim')->add_rule('valid_url')->add_rule('required');
     }
     return $validator;
 }
 public function action_index($blog_id = null)
 {
     $result = false;
     $limit = min((int) \Input::param('limit', BLOG_DISPLAY_LIMIT), BLOG_DISPLAY_LIMIT);
     $offset = (int) \Input::param('offset', 0);
     $page = (int) \Input::param('page', 0);
     $user_id = \Input::param('user_id', null);
     if ($page > 0) {
         $limit = BLOG_DISPLAY_LIMIT;
         $offset = BLOG_DISPLAY_LIMIT * ($page - 1);
     }
     try {
         $result = array_merge(array('status' => 1), Model_Project::load($blog_id, $user_id, $offset ? false : true, $offset, $limit));
     } catch (Exception $e) {
         $result = array('status' => 0, 'error' => $e->getMessage());
     }
     return $this->response($result);
 }