function hasAssignPrivilege($webserviceId)
 {
     global $adb;
     // administrator's have assign privilege
     if (is_admin($this->user)) {
         return true;
     }
     $idComponents = vtws_getIdComponents($webserviceId);
     $userId = $idComponents[1];
     $ownerTypeId = $idComponents[0];
     if ($userId == null || $userId == '' || $ownerTypeId == null || $ownerTypeId == '') {
         return false;
     }
     $webserviceObject = VtigerWebserviceObject::fromId($adb, $ownerTypeId);
     if (strcasecmp($webserviceObject->getEntityName(), "Users") === 0) {
         if ($userId == $this->user->id) {
             return true;
         }
         if (!$this->assign) {
             $this->retrieveUserHierarchy();
         }
         if (in_array($userId, array_keys($this->assignUsers))) {
             return true;
         } else {
             return false;
         }
     } elseif (strcasecmp($webserviceObject->getEntityName(), "Groups") === 0) {
         $tabId = $this->getTabId();
         $groups = vtws_getUserAccessibleGroups($tabId, $this->user);
         foreach ($groups as $group) {
             if ($group['id'] == $userId) {
                 return true;
             }
         }
         return false;
     }
 }
Пример #2
0
function vtws_getUserWebservicesGroups($tabId, $user)
{
    $groups = vtws_getUserAccessibleGroups($tabId, $user);
    return vtws_getWebserviceGroupFromGroups($groups);
}
Пример #3
0
 static function getassignedtoValues($userObj, $assigned_user_id = '')
 {
     //get users info
     $recordprefix = self::getEntityModuleWSId('Users');
     if ($assigned_user_id == '') {
         $assigned_user_id = $recordprefix . 'x' . $userObj->id;
     }
     if ($userObj->is_admin == false) {
         $resultuser = get_user_array(FALSE, "Active", $assigned_user_id, 'private');
     } else {
         $resultuser = get_user_array(FALSE, "Active", $assigned_user_id);
     }
     //add prefix to key
     $data = array_flip($resultuser);
     foreach ($data as $key => &$val) {
         $val = $recordprefix . 'x' . $val;
     }
     $resultuser = array_flip($data);
     $users_combo = get_select_options_array($resultuser, $assigned_user_id);
     //handle groups
     $resultgroups = array();
     if ($userObj->is_admin == false) {
         $resultgroups = vtws_getUserAccessibleGroups($module, $userObj);
     } else {
         $resultgroups = vtws_getUserAccessibleGroups($module, $userObj);
     }
     //add prefix to key for groups
     $groups_combo = array();
     if (count($resultgroups) > 0) {
         $newgrouporder = array();
         foreach ($resultgroups as $key => &$val) {
             $newid = $recordprefix . 'x' . $val['id'];
             $newgrouporder[$newid] = $val['name'];
         }
         $groups_combo = get_select_options_array($newgrouporder, $assigned_user_id);
     }
     $fieldvalue = array();
     $fieldvalue[] = $users_combo;
     $fieldvalue[] = $groups_combo;
     return $fieldvalue;
 }