Exemplo n.º 1
0
    def share(self, user_principal_name,
              shareOption=ExternalSharingSiteOption.View,
              sendEmail=True, emailSubject=None, emailBody=None):
        """
        Share a Web with user

        :param str user_principal_name: User identifier
        :param ExternalSharingSiteOption shareOption: The sharing type of permission to grant on the object.
        :param bool sendEmail: A flag to determine if an email notification SHOULD be sent (if email is configured).
        :param str emailSubject: The email subject.
        :param str emailBody: The email subject.
        :return: SharingResult
        """

        picker_result = ClientResult(str)
        sharing_result = ClientResult(SharingResult(self.context))

        def _picker_value_resolved(picker_value):
            picker_result.value = picker_value

        def _grp_resolved(role_value):
            def _web_loaded():
                sharing_result.value = Web.share_object(self.context, self.url, picker_result.value, role_value,
                                                        0,
                                                        False, sendEmail, False, emailSubject, emailBody)

            self.ensure_property("Url", _web_loaded)

        params = ClientPeoplePickerQueryParameters(user_principal_name)
        ClientPeoplePickerWebServiceInterface.client_people_picker_resolve_user(self.context, params,
                                                                                _picker_value_resolved)
        Web._resolve_group_value(self.context, shareOption, _grp_resolved)
        return sharing_result.value
Exemplo n.º 2
0
    def unshare(self):
        """
        Unshare a Web

        :return: SharingResult
        """
        sharing_result = ClientResult(SharingResult(self.context))

        def _web_initialized():
            sharing_result.value = Web.unshare_object(self.context, self.url)
        self.ensure_property("Url", _web_initialized)
        return sharing_result.value
    def unshare(self):
        """
                Share a ListItem (file or folder facet)
        """
        result = ClientResult(SharingResult(self.context))

        def _property_resolved():
            abs_url = self.get_property("EncodedAbsUrl")
            from office365.sharepoint.webs.web import Web
            result.value = Web.unshare_object(self.context, abs_url)

        self.ensure_property("EncodedAbsUrl", _property_resolved)
        return result.value
Exemplo n.º 4
0
    def share_object(context,
                     url,
                     peoplePickerInput,
                     roleValue=None,
                     groupId=0,
                     propagateAcl=False,
                     sendEmail=True,
                     includeAnonymousLinkInEmail=False,
                     emailSubject=None,
                     emailBody=None,
                     useSimplifiedRoles=True):
        """
        This method shares an object in SharePoint such as a list item or site. It returns a SharingResult object
        which contains the completion script and a page to redirect to if desired.


        :param office365.sharepoint.client_context.ClientContext context: SharePoint context
        :param str url: The URL of the website with the path of an object in SharePoint query string parameters.
        :param str roleValue: The sharing role value for the type of permission to grant on the object.
        :param str peoplePickerInput: A string of JSON representing users in people picker format.
        :param int groupId: The ID of the group to be added. Zero if not adding to a permissions group.
        :param bool propagateAcl:  A flag to determine if permissions SHOULD be pushed to items with unique permissions.
        :param bool sendEmail: A flag to determine if an email notification SHOULD be sent (if email is configured).
        :param bool includeAnonymousLinkInEmail: If an email is being sent, this determines if an anonymous link
        SHOULD be added to the message.
        :param str emailSubject: The email subject.
        :param str emailBody: The email subject.
        :param bool useSimplifiedRoles: A Boolean value indicating whether to use the SharePoint simplified roles
        (Edit, View) or not.

        """
        result = SharingResult(context)
        payload = {
            "url": url,
            "groupId": groupId,
            "peoplePickerInput": peoplePickerInput,
            "roleValue": roleValue,
            "includeAnonymousLinkInEmail": includeAnonymousLinkInEmail,
            "propagateAcl": propagateAcl,
            "sendEmail": sendEmail,
            "emailSubject": emailSubject,
            "emailBody": emailBody,
            "useSimplifiedRoles": useSimplifiedRoles
        }
        qry = ServiceOperationQuery(context.web, "ShareObject", None, payload,
                                    None, result)
        qry.static = True
        context.add_query(qry)
        return result
Exemplo n.º 5
0
    def unshare_object(context, url):
        """
        Removes Sharing permissions on an object.

        :param office365.sharepoint.client_context.ClientContext context: SharePoint context
        :param str url: A SharingResult object which contains status codes pertaining to the completion of the operation.
        :return: SharingResult
        """
        result = SharingResult(context)
        payload = {"url": url}
        qry = ServiceOperationQuery(context.web, "UnshareObject", None,
                                    payload, None, result)
        qry.static = True
        context.add_query(qry)
        return result
    def share(self,
              user_principal_name,
              shareOption=ExternalSharingSiteOption.View,
              sendEmail=True,
              emailSubject=None,
              emailBody=None):
        """
        Share a ListItem (file or folder facet)

        :param str user_principal_name: User identifier
        :param ExternalSharingSiteOption shareOption: The sharing type of permission to grant on the object.
        :param bool sendEmail: A flag to determine if an email notification SHOULD be sent (if email is configured).
        :param str emailSubject: The email subject.
        :param str emailBody: The email subject.
        :return: SharingResult
        """

        result = ClientResult(SharingResult(self.context))
        file_result = ClientResult(str)

        role_values = {
            ExternalSharingSiteOption.View: "role:1073741826",
            ExternalSharingSiteOption.Edit: "role:1073741827",
        }

        def _property_resolved():
            file_result.value = self.get_property("EncodedAbsUrl")

        def _picker_value_resolved(picker_value):
            from office365.sharepoint.webs.web import Web
            result.value = Web.share_object(self.context, file_result.value,
                                            picker_value,
                                            role_values[shareOption], 0, False,
                                            sendEmail, False, emailSubject,
                                            emailBody)

        self.ensure_property("EncodedAbsUrl", _property_resolved)
        params = ClientPeoplePickerQueryParameters(user_principal_name)
        ClientPeoplePickerWebServiceInterface.client_people_picker_resolve_user(
            self.context, params, _picker_value_resolved)
        return result.value