/** * Api.post('user-meta', {key: 'test', value:'hello world2'}, function(r){console.log(r)}); */ public function rest_post() { $key = $this->param('key', NULL, TRUE); $value = $this->param('value', NULL, TRUE); $user_id = $this->param('uid', NULL); $this->response(Model_User_Meta::set($key, $value, $user_id)); }
/** * * @param string $id * @param string $column * @return boolean */ public static function move_widget($id, $column, $user_id = NULL) { $widgets = Model_User_Meta::get(self::WIDGET_BLOCKS_KEY, array(), $user_id); $found = FALSE; foreach ($widgets as $data) { foreach ($ids as $i => $_id) { if ($_id = $id and $_column != $column) { $found = TRUE; unset($blocks[$_column][$i]); break; } } } if ($found === TRUE) { $blocks[$column][] = $id; Model_User_Meta::set(self::WIDGET_BLOCKS_KEY, $blocks, $user_id); return TRUE; } return FALSE; }
<?php defined('SYSPATH') or die('No direct script access.'); $config = Kohana::$config->load('installer'); $data = $config->get('user_meta', array()); foreach ($data as $key => $value) { Model_User_Meta::set($key, $value, 0); }