public function get_pic_detail() { $pic_id = intval($_GET['pic_id']); $pic_item = MeiuiPic::find('id = ' . $pic_id); if (count($pic_item)) { foreach ($pic_item as $value) { $user = MeiuiUser::findFirst('id=' . $value->create_user); $tags = MeiuiPicLinkTag::find('pic_id=' . $value->id); $sys_tag = []; $user_tag = []; if (count($tags) > 0) { foreach ($tags as $v) { if (in_array($v->pic_id, $this->user_tag_array['del_flag'][$v->tag_id])) { $user_tag[] = $v->tag_name; if ($v->tag_type == 2) { $sys_tag[] = $v->tag_name; } } else { if ($v->tag_type == 2) { $sys_tag[] = $v->tag_name; } } } } $this->main['data']['items'][] = array('pic_id' => $value->id, 'pic' => $value->pic_url, 'pic_h' => $value->pic_h, 'pic_w' => $value->pic_w, 'app_id' => $value->app_id, 'user_id' => $value->create_user, 'user_name' => $user->username, 'user_pic' => $user->user_pic, 'app_name' => $value->app_name, 'brief' => $value->brief, 'sys_tag' => $sys_tag, 'user_tag' => $user_tag); } $this->main['alert']['msg'] = $this->lang['request_success']; } else { $this->main['alert']['msg'] = '不存在图片'; } die(json_encode($this->main)); }
public function search() { $data = $this->main; $page = 1; if (isset($_GET['page'])) { $page = intval($_GET['page']); } $this->set_search_history(); $keyword = $_GET['keyword']; $conditions = " tag_name LIKE :tag_name: group by pic_id"; $parameters = array("tag_name" => '%' . $keyword . '%'); $all_pic = MeiuiPicLinkTag::find(array($conditions, "bind" => $parameters)); $paginator = new Paginator(array("data" => $all_pic, "limit" => 10, "page" => $page)); $all_pic = $paginator->getPaginate(); $data['status'] = '200200'; $data['data']['page'] = $all_pic->current . '/' . $all_pic->total_pages; $login_user_id = intval($_GET['user_id']); $login_user_collect = MeiuiUserTag::find('user_id = ' . $login_user_id . ' and del_flag = 1 '); $login_collect_tag = []; if (count($login_user_collect) > 0) { foreach ($login_user_collect as $collect) { $login_collect_tag[] = $collect->tag_id; } } foreach ($all_pic->items as $pic_value) { $pic = MeiuiPic::findFirst('id=' . $pic_value->pic_id); if ($pic) { $user = MeiuiUser::findFirst('id=' . $pic->create_user); $tags = MeiuiPicLinkTag::find('pic_id=' . $pic->id); $sys_tag = []; $user_tag = []; if (count($tags) > 0) { foreach ($tags as $v) { if (in_array($v->pic_id, $this->user_tag_array['del_flag'][$v->tag_id])) { $user_tag[] = $v->tag_name; if ($v->tag_type == 2) { $sys_tag[] = $v->tag_name; } } else { if ($v->tag_type == 2) { $sys_tag[] = $v->tag_name; } } } } $data['data']['items'][] = array('pic_id' => $pic->id, 'pic' => $pic->pic_url, 'pic_h' => $pic->pic_h, 'pic_w' => $pic->pic_w, 'app_id' => $pic->app_id, 'user_id' => $pic->create_user, 'user_name' => $user->username, 'user_pic' => $user->user_pic, 'app_name' => $pic->app_name, 'brief' => $pic->brief, 'sys_tag' => $sys_tag, 'user_tag' => $user_tag); } } $data['alert']['msg'] = $this->lang['request_success']; die(json_encode($data)); }
/** * This action authenticate and logs an user into the application * */ public function startAction() { if ($this->request->isPost()) { $email = $this->request->getPost('email'); $password = $this->request->getPost('password'); $user = MeiuiUser::findFirst(array("(email = :email: OR username = :email:) AND password = :password: AND del_flag = '1'", 'bind' => array('email' => $email, 'password' => sha1($password)))); if ($user != false) { $this->_registerSession($user); $this->flash->success('Welcome ' . $user->name); return $this->forward('user/list'); } $this->flash->error('Wrong email/password'); } return $this->forward('session/index'); }
public function center() { $data = $this->main; $data['status'] = '400200'; $conditions = " id = :id: "; $parameters = array("id" => intval($_GET['user_id'])); $user = MeiuiUser::findFirst(array($conditions, "bind" => $parameters)); if ($user) { $data['data']['user_pic'] = $user->user_pic; $data['data']['user_name'] = $user->nickname; $data['data']['user_id'] = $user->id; } else { $data['alert']['msg'] = $this->lang['lack_user_info']; die(json_encode($data)); } $conditions = " user_id = :user_id: and del_flag = 1"; $parameters = array("user_id" => intval($_GET['user_id'])); $user_tag = MeiuiUserTag::find(array($conditions, "bind" => $parameters)); $tag_tree = []; $login_collect_tag = []; foreach ($user_tag as $tag) { $tag_tree[$tag->tag_id][] = $tag; $login_collect_tag[] = $tag->tag_id; } krsort($tag_tree); // 遍历用户标签 foreach ($tag_tree as $tag_key => $tag_value) { $tag_arr = array(); foreach ($tag_value as $one_pic) { $pic = MeiuiPic::findFirst('id=' . $one_pic->pic_id); $user = MeiuiUser::findFirst('id=' . $pic->create_user); $tags = MeiuiPicLinkTag::find('pic_id=' . $pic->id); $sys_tag = []; $user_tag = []; $tag_name = ''; if (count($tags) > 0) { foreach ($tags as $v) { if ($v->tag_id == $tag_key) { $tag_name = $v->tag_name; } if (in_array($v->pic_id, $this->user_tag_array['del_flag'][$v->tag_id])) { $user_tag[] = $v->tag_name; if ($v->tag_type == 2) { $sys_tag[] = $v->tag_name; } } else { if ($v->tag_type == 2) { $sys_tag[] = $v->tag_name; } } } } $tag_arr['tag_name'] = $tag_name; $tag_arr['items'][] = array('pic_id' => $pic->id, 'pic' => $pic->pic_url, 'pic_h' => $pic->pic_h, 'pic_w' => $pic->pic_w, 'app_id' => $pic->app_id, 'user_id' => $pic->create_user, 'user_name' => $user->username, 'user_pic' => $user->user_pic, 'app_name' => $pic->app_name, 'brief' => $pic->brief, 'sys_tag' => $sys_tag, 'user_tag' => $user_tag); } $data['data']['tags'][] = $tag_arr; } $data['alert']['msg'] = $this->lang['request_success']; die(json_encode($data)); }
public function edit_user() { $data = $this->main; $conditions = " id = :user_id:"; $parameters = array("user_id" => $_GET['user_id']); $user = MeiuiUser::findFirst(array($conditions, "bind" => $parameters)); if (!$user) { $data['status'] = $this->status['save_user_error']; $data['data'] = array(); $data['alert']['msg'] = $this->lang['save_user_error']; die(json_encode($data)); } else { if ($_GET['nickname']) { $user->nickname = addslashes($_GET['nickname']); } if ($_GET['user_pic']) { // $user->user_pic = $this->inner_upload_pic(); $user->user_pic = addslashes($_GET['user_pic']); } if ($user->save()) { $data['status'] = '500200'; // $data['data'] = array( // 'user_id' => $user->id, // 'user_name' => $user->nickname, // 'user_pic' => $user->user_pic, // ); $data['alert']['msg'] = $this->lang['request_success']; } else { $data['status'] = $this->status['save_user_error']; $data['data'] = array(); $data['alert']['msg'] = $this->lang['save_user_error']; } die(json_encode($data)); } }
private function getUser($id) { // 用 phalcon 的方式查找该用户 $conditions = " id = :id: AND del_flag != :del_flag:"; $parameters = array("id" => "{$id}", "del_flag" => '2'); $changeUser = MeiuiUser::findFirst(array($conditions, "bind" => $parameters)); return $changeUser; }