public function get_ngo_network_data($ngo_id) { $user_model = new UsersModel(); $event_model = new EventsModel(); $ngo_id = intval($ngo_id); //defense against exploit //select the events of the user $events_of_user = $event_model->field('id,longitude,latitude')->where(array('user_id' => $ngo_id))->select(); $user = $user_model->find($ngo_id); //select the related ngo of the user $fields = explode(',', $user['work_field']); $sql = "select id,longitude,latitude, 0"; foreach ($fields as $field) { $sql .= "-10*if(work_field like '%{$field}%',1,0)"; } $sql .= " score from users where type='ngo' and is_checked=1 order by score limit 5"; $ngo_of_user = $this->query($sql); //select the related csr with the same work field with the user $sql = "select id,longitude,latitude, 0"; foreach ($fields as $field) { $sql .= "-10*if(item_field like '%{$field}%',1,0)"; } $sql .= " score from events where type='csr' and is_checked=1 order by score limit 5"; $csr_of_user = $this->query($sql); return array('events' => $events_of_user, 'related_user' => $ngo_of_user, 'related_csr' => $csr_of_user); }
public function edit($id) { $local_map_model = new LocalMapModel(); $local_map = $local_map_model->find($id); $user_model = new UsersModel(); $user = $user_model->find($local_map['admin_id']); $local_map['user_name'] = $user['name']; $this->assign('local_map', $local_map); $this->assign('action', 'save'); $this->display('add_map'); }
public function edit($id) { $news_model = new NewsModel(); $news = $news_model->find($id); $user_model = new UsersModel(); $user = $user_model->find($news['user_id']); $news['user_name'] = $user['name']; $this->assign('news', $news); $this->assign('action', 'save'); $this->display('add'); }
public function view($id) { $user_model = new UsersModel(); $event_model = new EventsModel(); $recommend_model = new RecommendModel(); $weibo_model = new WeiboModel(); $user = $user_model->find($id); $recommended_users = $recommend_model->users_by_user($id); $events = $event_model->select_by_user($id); $weibo = $weibo_model->select_weibo_by_user($id); $related_ngo_model = new RelatedNgosModel(); $this->assign('user', $user); $this->assign('events', $events); $this->assign('rec_users', $recommended_users); $this->assign('related_ngos', $related_ngo_model->select_by_user_id($id)); $this->assign('weibo', $weibo); $this->display(); }
public function view($id) { $event_model = new EventsModel(); $user_model = new UsersModel(); $recommend_model = new RecommendModel(); $media_model = new MediaModel(); $event = $event_model->find($id); $user = $user_model->find($event['user_id']); $recommended_users = $recommend_model->users_by_event($id); $recommended_events = $recommend_model->events_by_event($id); $images = $media_model->select_images_by_event($id); $this->assign('images', $images); $this->assign('event', $event); $this->assign('user', $user); $this->assign('rec_users', $recommended_users); $this->assign('rec_events', $recommended_events); $this->display(); }
public function users_by_user($id, $type = 'ngo', $count = 6, $has_image = true) { $user_model = new UsersModel(); $user = $user_model->find($id); return $this->recommend_users($user, $type, $count, $has_image); }