public function changeActive() { if ($this->template->is_ajax()) { $post = $this->input->post(); $social_groups = $this->c_user->social_group->get(); $result = array('success' => true); foreach ($social_groups as $social_group) { $social_group->is_active = false; $social_group->save(); } $social_group = new Social_group($post['id']); if ($social_group->exists()) { $social_group->is_active = true; if ($social_group->save()) { $result['message'] = lang('profile_updated_successfully'); } else { $result['success'] = false; $result['message'] = lang('profile_saving_error'); } } else { $result['success'] = false; $result['message'] = lang('profile_saving_error'); } echo json_encode($result); } }
/** * @param integer $user_id * @param null $group_id * @param array $exclude types * * @return array */ public static function getTokensArrayForGroup($user_id, $group_id = null, $exclude = array()) { $access = new Access_token(); $tokens = array(); $group = new Social_group($group_id); foreach (self::$types as $type) { if (in_array($type, $exclude)) { continue; } $tokens_array = $access->get_array_by_type($type, $user_id); if (!empty($tokens_array)) { if ($group->exists()) { foreach ($tokens_array as &$token) { if ($group->access_token->where('id', $token['id'])->get()->exists()) { $token['in_group'] = true; } else { $token['in_group'] = false; } } } $tokens[$type] = $tokens_array; } else { $tokens[$type] = array(); } } return $tokens; }