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


PHP get_role_id函数代码示例

本文整理汇总了PHP中get_role_id函数的典型用法代码示例。如果您正苦于以下问题:PHP get_role_id函数的具体用法?PHP get_role_id怎么用?PHP get_role_id使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: getAvatar

 public function getAvatar($uid = 0, $size = 256)
 {
     $avatar = D('avatar')->where(array('uid' => $uid, 'status' => 1, 'is_temp' => 0))->find();
     if ($avatar) {
         if ($avatar['driver'] == 'local') {
             $avatar_path = "/Uploads/Avatar" . $avatar['path'];
             return $this->getImageUrlByPath($avatar_path, $size);
         } else {
             $new_img = $avatar['path'];
             $name = get_addon_class($avatar['driver']);
             if (class_exists($name)) {
                 $class = new $name();
                 if (method_exists($class, 'thumb')) {
                     $new_img = $class->thumb($avatar['path'], $size, $size);
                 }
             }
             return $new_img;
         }
     } else {
         //如果没有头像,返回默认头像
         if ($uid == session('temp_login_uid') || $uid == is_login()) {
             $role_id = session('temp_login_role_id') ? session('temp_login_role_id') : get_role_id();
         } else {
             $role_id = query_user('show_role', $uid);
         }
         return $this->getImageUrlByRoleId($role_id, $size);
     }
 }
开发者ID:terrydeng,项目名称:beimeibang1205,代码行数:28,代码来源:UploadAvatarWidget.class.php

示例2: getUserConfigMap

/**
 * 构造用户配置表 D('UserConfig')查询条件
 * @param string $name 表中name字段的值(配置标识)
 * @param string $model 表中model字段的值(模块标识)
 * @param int $uid 用户uid
 * @param int $role_id 登录的角色id
 * @return array 查询条件 $map
 * @author 郑钟良<zzl@ourstu.com>
 */
function getUserConfigMap($name = '', $model = '', $uid = 0, $role_id = 0)
{
    $uid = $uid ? $uid : is_login();
    $role_id = $role_id ? $role_id : get_role_id($uid);
    $map = array();
    //构造查询条件
    $map['uid'] = $uid;
    $map['name'] = $name;
    $map['role_id'] = $role_id;
    $map['model'] = $model;
    return $map;
}
开发者ID:suhanyujie,项目名称:digitalOceanVps,代码行数:21,代码来源:function.php

示例3: getAvatar

 public function getAvatar($uid = 0, $size = 256)
 {
     $avatar = M('avatar')->where(array('uid' => $uid, 'status' => 1, 'is_temp' => 0))->getField('path');
     if ($avatar) {
         if (is_sae()) {
             $avatar_path = $avatar;
         } else {
             if (!is_bool(strpos($avatar, 'http://'))) {
                 return $avatar . '/thumbnail/' . $size . 'x' . $size . '!';
             } else {
                 $avatar_path = "/Uploads/Avatar{$avatar}";
             }
         }
         return $this->getImageUrlByPath($avatar_path, $size);
     } else {
         //如果没有头像,返回默认头像
         $role_id = session('temp_login_role_id') ? session('temp_login_role_id') : get_role_id();
         return $this->getImageUrlByRoleId($role_id, $size);
     }
 }
开发者ID:suhanyujie,项目名称:digitalOceanVps,代码行数:20,代码来源:UploadAvatarWidget.class.php

示例4: getRoleFieldIds

 private function getRoleFieldIds($uid = null)
 {
     $role_id = get_role_id($uid);
     $fields_list = S('Role_Expend_Info_' . $role_id);
     if (!$fields_list) {
         $map_role_config = getRoleConfigMap('expend_field', $role_id);
         $fields_list = D('RoleConfig')->where($map_role_config)->getField('value');
         if ($fields_list) {
             $fields_list = explode(',', $fields_list);
             S('Role_Expend_Info_' . $role_id, $fields_list, 600);
         }
     }
     return $fields_list;
 }
开发者ID:smartymoon,项目名称:e-anjia,代码行数:14,代码来源:ConfigController.class.php

示例5: edit_expandinfo

 public function edit_expandinfo()
 {
     $field_list = $this->getRoleFieldIds();
     if ($field_list) {
         $map_field['id'] = array('in', $field_list);
     } else {
         $this->error(L('_ERROR_INFO_SAVE_NONE_') . L('_EXCLAMATION_'));
     }
     $map_field['status'] = 1;
     $field_setting_list = D('field_setting')->where($map_field)->order('sort asc')->select();
     if (!$field_setting_list) {
         $this->error(L('_ERROR_INFO_MODIFY_NONE_') . L('_EXCLAMATION_'));
     }
     $data = null;
     foreach ($field_setting_list as $key => $val) {
         $data[$key]['uid'] = session('temp_login_uid') ? session('temp_login_uid') : is_login();
         $data[$key]['field_id'] = $val['id'];
         switch ($val['form_type']) {
             case 'input':
                 $val['value'] = op_t($_POST['expand_' . $val['id']]);
                 if (!$val['value'] || $val['value'] == '') {
                     if ($val['required'] == 1) {
                         $this->error($val['field_name'] . L('_ERROR_CONTENT_CANNOT_EMPTY_') . L('_EXCLAMATION_'));
                     }
                 } else {
                     $val['submit'] = $this->_checkInput($val);
                     if ($val['submit'] != null && $val['submit']['succ'] == 0) {
                         $this->error($val['submit']['msg']);
                     }
                 }
                 $data[$key]['field_data'] = $val['value'];
                 break;
             case 'radio':
                 $val['value'] = op_t($_POST['expand_' . $val['id']]);
                 $data[$key]['field_data'] = $val['value'];
                 break;
             case 'checkbox':
                 $val['value'] = $_POST['expand_' . $val['id']];
                 if (!is_array($val['value']) && $val['required'] == 1) {
                     $this->error(L('_ERROR_AT_LEAST_ONE_') . L('_COLON_') . $val['field_name']);
                 }
                 $data[$key]['field_data'] = is_array($val['value']) ? implode('|', $val['value']) : '';
                 break;
             case 'select':
                 $val['value'] = op_t($_POST['expand_' . $val['id']]);
                 $data[$key]['field_data'] = $val['value'];
                 break;
             case 'time':
                 $val['value'] = op_t($_POST['expand_' . $val['id']]);
                 $val['value'] = strtotime($val['value']);
                 $data[$key]['field_data'] = $val['value'];
                 break;
             case 'textarea':
                 $val['value'] = op_t($_POST['expand_' . $val['id']]);
                 if (!$val['value'] || $val['value'] == '') {
                     if ($val['required'] == 1) {
                         $this->error($val['field_name'] . L('_ERROR_CONTENT_CANNOT_EMPTY_') . L('_EXCLAMATION_'));
                     }
                 } else {
                     $val['submit'] = $this->_checkInput($val);
                     if ($val['submit'] != null && $val['submit']['succ'] == 0) {
                         $this->error($val['submit']['msg']);
                     }
                 }
                 $val['submit'] = $this->_checkInput($val);
                 if ($val['submit'] != null && $val['submit']['succ'] == 0) {
                     $this->error($val['submit']['msg']);
                 }
                 $data[$key]['field_data'] = $val['value'];
                 break;
         }
     }
     $map['uid'] = session('temp_login_uid') ? session('temp_login_uid') : is_login();
     $map['role_id'] = session('temp_login_role_id') ? session('temp_login_role_id') : get_role_id($map['uid']);
     $result['status'] = 1;
     foreach ($data as $dl) {
         $dl['role_id'] = $map['role_id'];
         $map['field_id'] = $dl['field_id'];
         $res = D('field')->where($map)->find();
         if (!$res) {
             if ($dl['field_data'] != '' && $dl['field_data'] != null) {
                 $dl['createTime'] = $dl['changeTime'] = time();
                 if (!D('field')->add($dl)) {
                     $result['info'] = L('_ERROR_INFO_ADD_') . L('_EXCLAMATION_');
                     $result['status'] = 0;
                 }
             }
         } else {
             $dl['changeTime'] = time();
             if (!D('field')->where('id=' . $res['id'])->save($dl)) {
                 $result['info'] = L('_ERROR_INFO_MODIFY_') . L('_EXCLAMATION_');
                 $result['status'] = 0;
             }
         }
         unset($map['field_id']);
     }
     return $result;
 }
开发者ID:naliduo,项目名称:Lightweight-social-platform,代码行数:98,代码来源:RegStepWidget.class.php

示例6: edit_expandinfo

 public function edit_expandinfo()
 {
     $field_list = $this->getRoleFieldIds();
     if ($field_list) {
         $map_field['id'] = array('in', $field_list);
     } else {
         $this->error('没有要保存的信息!');
     }
     $map_field['status'] = 1;
     $field_setting_list = D('field_setting')->where($map_field)->order('sort asc')->select();
     if (!$field_setting_list) {
         $this->error('没有要修改的信息!');
     }
     $data = null;
     foreach ($field_setting_list as $key => $val) {
         $data[$key]['uid'] = session('temp_login_uid') ? session('temp_login_uid') : is_login();
         $data[$key]['field_id'] = $val['id'];
         switch ($val['form_type']) {
             case 'input':
                 $val['value'] = op_t($_POST['expand_' . $val['id']]);
                 if (!$val['value'] || $val['value'] == '') {
                     if ($val['required'] == 1) {
                         $this->error($val['field_name'] . '内容不能为空!');
                     }
                 } else {
                     $val['submit'] = $this->_checkInput($val);
                     if ($val['submit'] != null && $val['submit']['succ'] == 0) {
                         $this->error($val['submit']['msg']);
                     }
                 }
                 $data[$key]['field_data'] = $val['value'];
                 break;
             case 'radio':
                 $val['value'] = op_t($_POST['expand_' . $val['id']]);
                 $data[$key]['field_data'] = $val['value'];
                 break;
             case 'checkbox':
                 $val['value'] = $_POST['expand_' . $val['id']];
                 if (!is_array($val['value']) && $val['required'] == 1) {
                     $this->error('请至少选择一个:' . $val['field_name']);
                 }
                 $data[$key]['field_data'] = is_array($val['value']) ? implode('|', $val['value']) : '';
                 break;
             case 'select':
                 $val['value'] = op_t($_POST['expand_' . $val['id']]);
                 $data[$key]['field_data'] = $val['value'];
                 break;
             case 'time':
                 $val['value'] = op_t($_POST['expand_' . $val['id']]);
                 $val['value'] = strtotime($val['value']);
                 $data[$key]['field_data'] = $val['value'];
                 break;
             case 'textarea':
                 $val['value'] = op_t($_POST['expand_' . $val['id']]);
                 if (!$val['value'] || $val['value'] == '') {
                     if ($val['required'] == 1) {
                         $this->error($val['field_name'] . '内容不能为空!');
                     }
                 } else {
                     $val['submit'] = $this->_checkInput($val);
                     if ($val['submit'] != null && $val['submit']['succ'] == 0) {
                         $this->error($val['submit']['msg']);
                     }
                 }
                 $val['submit'] = $this->_checkInput($val);
                 if ($val['submit'] != null && $val['submit']['succ'] == 0) {
                     $this->error($val['submit']['msg']);
                 }
                 $data[$key]['field_data'] = $val['value'];
                 break;
         }
     }
     $map['uid'] = session('temp_login_uid') ? session('temp_login_uid') : is_login();
     $map['role_id'] = session('temp_login_role_id') ? session('temp_login_role_id') : get_role_id($map['uid']);
     $result['status'] = 1;
     foreach ($data as $dl) {
         $dl['role_id'] = $map['role_id'];
         $map['field_id'] = $dl['field_id'];
         $res = D('field')->where($map)->find();
         if (!$res) {
             if ($dl['field_data'] != '' && $dl['field_data'] != null) {
                 $dl['createTime'] = $dl['changeTime'] = time();
                 if (!D('field')->add($dl)) {
                     $result['info'] = '信息添加时出错!';
                     $result['status'] = 0;
                 }
             }
         } else {
             $dl['changeTime'] = time();
             if (!D('field')->where('id=' . $res['id'])->save($dl)) {
                 $result['info'] = '信息修改时出错!';
                 $result['status'] = 0;
             }
         }
         unset($map['field_id']);
     }
     return $result;
 }
开发者ID:fishling,项目名称:chatPro,代码行数:98,代码来源:RegStepWidget.class.php


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