当前位置: 首页>>代码示例>>PHP>>正文


PHP VBX_User::setting方法代码示例

本文整理汇总了PHP中VBX_User::setting方法的典型用法代码示例。如果您正苦于以下问题:PHP VBX_User::setting方法的具体用法?PHP VBX_User::setting怎么用?PHP VBX_User::setting使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在VBX_User的用法示例。


在下文中一共展示了VBX_User::setting方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: save_user

 private function save_user()
 {
     $errors = array();
     $user = false;
     $id = intval($this->input->post('id'));
     $auth_type = $this->input->post('auth_type');
     $error = false;
     $message = "Failed to save user for unknown reason.";
     $shouldGenerateNewPassword = false;
     $device_id_str = trim($this->input->post('device_id'));
     $device_number = trim($this->input->post('device_number'));
     $shouldSendWelcome = false;
     try {
         PhoneNumber::validatePhoneNumber($device_number);
     } catch (PhoneNumberException $e) {
         $data['json'] = array('error' => true, 'message' => $e->getMessage());
         return $this->respond('', 'accounts', $data);
     }
     if (!empty($auth_type)) {
         $auth_type = $this->vbx_user->get_auth_type($auth_type);
     }
     if ($id > 0) {
         $user = VBX_User::get($id);
     } else {
         $user = VBX_User::get(array('email' => $this->input->post('email')));
         if (!empty($user) && $user->is_active == 1) {
             $error = true;
             $message = 'Email address is already in use.';
         } elseif (!empty($user) && $user->is_active == 0) {
             // It's an old account that was made inactive.  By re-adding it, we're
             // assuming the user wants to re-instate the old account.
             $shouldSendWelcome = true;
         } else {
             // It's a new user
             $user = new VBX_User();
             $shouldSendWelcome = true;
         }
     }
     if (!$error) {
         $fields = array('first_name', 'last_name', 'email', 'is_admin');
         foreach ($fields as $field) {
             $user->{$field} = $this->input->post($field);
         }
         $user->is_active = TRUE;
         $user->auth_type = isset($auth_type->id) ? $auth_type->id : 1;
         try {
             $user->save();
             if ($shouldSendWelcome) {
                 $user->setting_set('online', 9);
                 $user->send_new_user_notification();
             }
         } catch (VBX_UserException $e) {
             $error = true;
             $message = $e->getMessage();
             log_message('error', 'Unable to send new user notification: ' . $message);
         }
         if (!$error) {
             if (strlen($device_number) > 0) {
                 // We're adding or modifying an existing device
                 if (strlen($device_id_str) > 0) {
                     // We're updating an existing record
                     $device_id = intval($device_id_str);
                     $device = VBX_Device::get($device_id);
                     $device->value = normalize_phone_to_E164($device_number);
                     try {
                         $device->save();
                     } catch (VBX_DeviceException $e) {
                         $error = true;
                         $message = 'Failed to update device: ' . $e->getMessage();
                     }
                 } else {
                     // We're creating a new device record
                     $number = array("name" => "Primary Device", "value" => normalize_phone_to_E164($device_number), "user_id" => $user->id, "sms" => 1);
                     try {
                         $new_device_id = $this->vbx_device->add($number);
                     } catch (VBX_DeviceException $e) {
                         $error = true;
                         $message = "Failed to add device: " . $e->getMessage();
                     }
                 }
             } else {
                 if (strlen($device_number) == 0 && strlen($device_id_str) > 0) {
                     // We're deleting a device
                     try {
                         $this->vbx_device->delete(intval($device_id_str), $user->id);
                     } catch (VBX_DeviceException $e) {
                         $error = true;
                         $message = "Unable to delete device entry: " . $e->getMessage();
                     }
                 }
             }
         }
     }
     if ($error) {
         $json = array('error' => $error, 'message' => $message);
     } else {
         $json = array('id' => $user->id, 'first_name' => $user->first_name, 'last_name' => $user->last_name, 'is_active' => $user->is_active, 'is_admin' => $user->is_admin, 'notification' => $user->notification, 'auth_type' => isset($auth_type->description) ? $auth_type->description : 'openvbx', 'email' => $user->email, 'error' => false, 'message' => '', 'online' => $user->setting('online'));
     }
     $data['json'] = $json;
     $this->respond('', 'accounts', $data);
//.........这里部分代码省略.........
开发者ID:wiserweb,项目名称:OpenVBX,代码行数:101,代码来源:accounts.php


注:本文中的VBX_User::setting方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。