/** * Register new user * * @access public * @return string Returns "OK" string upon succession and error message otherwise */ public function register() { $xml = apiler::get_xml(); try { $user = new User_Model($xml->login, $xml->password, $xml->email, $xml->description); $this->store_avatar($user->get_id($xml->login)); echo "OK"; } catch (Exception $e) { echo $e->getMessage() . "\n"; die; } }
public function insert($category, $username, $value) { $cat = new Category_Model(); $category = $cat->get_id($category); $user = new User_Model(); $username = $user->get_id($username); $results = $this->db->query("INSERT INTO results SET cat_id = ?, user_id = ?, value = ?, result_date = NOW()", $category, $username, $value); if ($results) { return true; } else { return false; } }
/** * Change user profile * @param array post data * @param string user id */ public function change_data($post, $email) { $user = new User_Model(); $id = $user->get_id($email); if (self::profile_exists($email)) { //update data $data = array('customer_street' => $post['customer_street'], 'customer_city' => $post['customer_city'], 'customer_postal_code' => $post['customer_postal_code'], 'customer_phone' => $post['customer_phone'], 'billing_name' => $post['billing_name'], 'billing_street' => $post['billing_street'], 'billing_city' => $post['billing_city'], 'billing_postal_code' => $post['billing_postal_code'], 'billing_identity_number' => $post['billing_identity_number'], 'billing_vat_number' => $post['billing_vat_number']); $this->db->update(self::TN_EXTEND, $data, array('user' => $id)); } else { //create data $data['user'] = $id; $this->db->insert(self::TN_EXTEND, $data); } }
/** * Return ID of current user * @return integer ID of user */ public function user_id() { $user = new User_Model(); return $user->get_id(self::user_email()); }