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


PHP Roles::assign_role_to_user方法代码示例

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


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

示例1: testAssign_role_to_user_empty_user

 /**
  * @todo Implement testAssign_tasks_to_role().
  */
 public function testAssign_role_to_user_empty_user()
 {
     //check for single tasks
     $role_id = 1;
     $user_id = NULL;
     $code = NULL;
     try {
         Roles::assign_role_to_user($role_id, $user_id);
     } catch (PAException $e) {
         $error = $e->message;
         $code = $e->code;
     }
     //this id should be equal to newly created id
     $this->assertEquals($code, REQUIRED_PARAMETERS_MISSING);
 }
开发者ID:Cyberspace-Networks,项目名称:PeopleAggregator,代码行数:18,代码来源:RolesTest.php

示例2: dirname

<?php

$login_required = TRUE;
include "../includes/page.php";
require_once dirname(__FILE__) . '/../../config.inc';
require_once "{$path_prefix}/api/Roles/Roles.php";
if ($_POST['uid']) {
    if (empty($_POST['rid'])) {
        //delete the admin role assigned to user
        Roles::delete_user_adminrole($_POST['uid']);
    } else {
        $role = new Roles();
        $role->assign_role_to_user($_POST['rid'], $_POST['uid']);
    }
    echo "save";
}
开发者ID:CivicCommons,项目名称:oldBellCaPA,代码行数:16,代码来源:save_adminrole.php

示例3: join

 /**
  * let the user join network
  * @access public
  * @param id of the network,uid of user
  * @return flag for joining request moderated or success message
  */
 static function join($network_id, $uid, $user_type = null, $by_admin = false)
 {
     // function modified just to have crude functionality for time being
     // TODO : when some one joins network do something
     global $default_sender;
     Logger::log("Enter: static function Network::join");
     if (Network::member_exists($network_id, $uid)) {
         //then make an entry for the network to be joined and user_id
         throw new PAException(OPERATION_NOT_PERMITTED, "Already a member of this network.");
     }
     $owner_id = self::get_network_owner($network_id);
     $roles = array();
     $roles[0] = array('role_id' => LOGINUSER_ROLE, 'extra' => serialize(array('user' => true, 'network' => true, 'groups' => array())));
     // assign LOGINUSER_ROLE to new member
     if ((int) $network_id == 1 && (int) $uid == 1 || $uid == $owner_id) {
         // user is mother network owner !
         $user_type = NETWORK_OWNER;
         $roles[0] = array('role_id' => ADMINISTRATOR_ROLE, 'extra' => serialize(array('user' => false, 'network' => true, 'groups' => array())));
         // ADMIN role to mother network owner !
     }
     $roles_obj = new Roles();
     $roles_obj->assign_role_to_user($roles, $uid);
     $user_created = Dal::query_first("SELECT created FROM users WHERE user_id=?", array($uid));
     // find type of the network
     // $type = Network::find_network_type($network_id);
     $res = Dal::query('SELECT type, extra FROM {networks} WHERE  network_id = ? ', array($network_id));
     $row = $res->fetchRow(DB_FETCHMODE_OBJECT);
     $type = $row->type;
     $extra = unserialize($row->extra);
     $email_val = false;
     if (!$by_admin) {
         if (isset($extra['email_validation']) && $extra['email_validation'] == 1) {
             $email_val = true;
         }
         if ($type == PRIVATE_NETWORK_TYPE) {
             $user_type = empty($user_type) ? NETWORK_WAITING_MEMBER : $user_type;
             // see if user has already applied for the network
             $res = Dal::query("SELECT * FROM {networks_users} WHERE network_id = ? AND user_id = ? AND user_type = ? ", array($network_id, $uid, $user_type));
             if ($res->numRows() > 0) {
                 throw new PAException(OPERATION_NOT_PERMITTED, "You have already requested to join this network.");
             }
         } else {
             $user_type = $email_val ? NETWORK_WAITING_MEMBER : NETWORK_MEMBER;
         }
     } else {
         // join the new user in all cases, this is an admin action!
         $user_type = NETWORK_MEMBER;
     }
     $res = Dal::query("INSERT INTO {networks_users} (network_id, user_id, user_type, created) VALUES (?, ?, ?, ?)", array($network_id, $uid, $user_type, $user_created));
     //getting Mother network informaton
     //    $network_data =  Network::get_mothership_info();//get the network_info of mother network such as network_id
     //    if (!Network::member_exists($network_data->network_id, $uid)) {//if not a member of mother network ie directly joining a network then make an entry for mother network_id and user_id
     //      $res = Dal::query("INSERT INTO {networks_users} (network_id, user_id, user_type, created) VALUES (?, ?, ?, ?)", array($network_data->network_id, $uid, NETWORK_MEMBER, $user_created));
     //    }
     // Update cached member count
     Network::update_network_member_count($network_id);
     return TRUE;
 }
开发者ID:Cyberspace-Networks,项目名称:PeopleAggregator,代码行数:64,代码来源:Network.php

示例4: array

                }
            }
            $extra['groups'] = $_groups;
        }
    }
    $user_roles = array();
    $role = new Roles();
    $_extra = serialize(array('user' => true, 'network' => true, 'groups' => array()));
    if (!empty($role_extra[$role_id])) {
        $_extra = serialize($role_extra[$role_id]);
    } else {
        if ($group_id) {
            $_extra = array('user' => false, 'network' => false, 'groups' => array($group_id));
            $_extra = serialize($_extra);
        }
    }
    $user_roles[] = array('role_id' => $role_id, 'extra' => $_extra);
    if ($_POST['roles_action'] == 'delete') {
        $role->delete_user_roles($uid, $user_roles, $group_id);
    } else {
        $role->assign_role_to_user($user_roles, $uid);
    }
    $names = array();
    $r_params = $group_id ? array('type' => 'group', 'gid' => $group_id) : null;
    $saved_roles = Roles::get_user_roles($uid, DB_FETCHMODE_OBJECT, $r_params);
    foreach ($saved_roles as $s_role) {
        $names[] = Roles::get_role_name($s_role->role_id);
    }
    $msg = implode("<br />", $names);
    echo $msg;
}
开发者ID:Cyberspace-Networks,项目名称:PeopleAggregator,代码行数:31,代码来源:assign_role.php


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