Example #1
0
 /**
  * 將使用者資訊轉換成JSON
  * @param User $user
  * @param Boolean $embed_login
  * @return Array
  */
 private function _parse_user_output($user, $embed_login)
 {
     $webpage = get_context_webpage();
     $this->load->library("kals_actor/User_statistic", "user_statistic");
     $this->load->library("kals_actor/User_statistic", "user_statistic");
     $this->user_statistic = new User_statistic();
     $output = array();
     //$output["webpage_id"] = get_context_webpage()->get_id();
     $output['login'] = TRUE;
     $output['embed_login'] = $embed_login;
     $output['user'] = array('email' => $user->get_field('email'), 'name' => $user->get_field('name'), 'id' => $user->get_id(), 'has_photo' => $user->has_photo(), 'locale' => $user->get_locale(), 'sex' => $user->get_sex());
     $user_params = $this->user_statistic->get_init_user_params($user, $webpage);
     foreach ($user_params as $key => $value) {
         $output['user'][$key] = $value;
     }
     $user_params = $this->user_statistic->get_user_params($user, $webpage);
     foreach ($user_params as $key => $value) {
         $output['user'][$key] = $value;
     }
     //將使用者寫入Context當中
     set_context_user($user);
     $output = $this->_get_login_policy_output($output);
     require_once 'annotation_getter.php';
     $annotation_getter = new annotation_getter();
     $my_annotation = $annotation_getter->my();
     if (count($my_annotation['basic']) > 0) {
         $output['policy']['my_basic'] = $my_annotation['basic'];
     }
     if (count($my_annotation['custom']) > 0) {
         $output['policy']['my_custom'] = $my_annotation['custom'];
     }
     // 設定的位置是在 KALS_CONFIG.js 喔
     $nav_type = $GLOBALS['context']->get_anchor_navigation_type();
     //$nav_type = "original";
     if ($nav_type === "original") {
         $other_annotation = $annotation_getter->other();
         if (count($other_annotation['basic']) > 0) {
             $output['policy']['other_basic'] = $other_annotation['basic'];
         }
         if (count($other_annotation['custom']) > 0) {
             $output['policy']['other_custom'] = $other_annotation['custom'];
         }
     }
     //$mobile_redirect = $this->session->flashdata("mobile_redirect");
     $mobile_redirect = $this->session->userdata("mobile_redirect");
     //$mobile_redirect = "http://localhost/kals/mobile_apps/annotation_thread/topic_id/15651#annotation_15661";
     //test_msg("mobile_redirect", $mobile_redirect);
     if ($mobile_redirect !== FALSE) {
         $output['mobile_redirect'] = $mobile_redirect;
         $this->session->unset_userdata("mobile_redirect");
         //context_complete();
     }
     return $output;
 }
Example #2
0
 /**
  * @desc Update user
  * @param User $user 
  * @param string $condition the SQL condition update user
  * @param array $parameters 
  */
 public static function update(User $user, $extended_fields = null)
 {
     $condition = 'WHERE user_id=:user_id';
     $parameters = array('user_id' => $user->get_id());
     self::$querier->update(DB_TABLE_MEMBER, array('display_name' => TextHelper::htmlspecialchars($user->get_display_name()), 'level' => $user->get_level(), 'groups' => implode('|', $user->get_groups()), 'email' => $user->get_email(), 'show_email' => (int) $user->get_show_email(), 'locale' => $user->get_locale(), 'timezone' => $user->get_timezone(), 'theme' => $user->get_theme(), 'editor' => $user->get_editor()), $condition, $parameters);
     if ($extended_fields !== null) {
         if ($extended_fields instanceof MemberExtendedFieldsService) {
             $fields_data = $extended_fields->get_data($user->get_id());
         } elseif (is_array($extended_fields)) {
             $fields_data = $extended_fields;
         } else {
             $fields_data = array();
         }
         self::$querier->update(DB_TABLE_MEMBER_EXTENDED_FIELDS, $fields_data, $condition, $parameters);
     }
     SessionData::recheck_cached_data_from_user_id($user->get_id());
     self::regenerate_cache();
 }