Invite other users to access the virtual folder.

    \b
    NAME: Name of a virtual folder.
    EMAIL: Emails to invite.
347436
def invite(name, emails, perm):
    
    with Session() as session:
        try:
            assert perm in ['rw', 'ro'], \
                   'Invalid permission: {}'.format(perm)
            result = session.VFolder(name).invite(perm, emails)
            invited_ids = result.get('invited_ids', [])
            if len(invited_ids) > 0:
                print('Invitation sent to:')
                for invitee in invited_ids:
                    print('\t- ' + invitee)
            else:
                print('No users found. Invitation was not sent.')
        except Exception as e:
            print_error(e)
            sys.exit(1)
1067030
public Team inviteTeamMember(String idOrEmail) throws HelloSignException {
        String key = (idOrEmail != null && idOrEmail.contains("@")) ? Account.ACCOUNT_EMAIL_ADDRESS
                : Account.ACCOUNT_ID;
        return new Team(
                httpClient.withAuth(auth).withPostField(key, idOrEmail).post(BASE_URI + TEAM_ADD_MEMBER_URI).asJson());
    }
83425
def attach_virtual_server(self, ticket_id=None, virtual_id=None):
        
        return self.ticket.addAttachedVirtualGuest(virtual_id, id=ticket_id)
139528
def send_email(recipients, subject, message, attachments=None):
    
    if not attachments:
        attachments = []

    if os.path.exists(EMAIL_SETTINGS_FILE):
        email_settings = json.load(open(EMAIL_SETTINGS_FILE))
        sender = email_settings.get('sender', 'ambry@localhost')
        use_tls = email_settings.get('use_tls')
        username = email_settings['username']
        password = email_settings['password']
        server = email_settings['server']
    else:
        # use local smtp
        server = 'localhost'
        username = None
        password = None
        sender = 'ambry@localhost'

    # Create the container (outer) email message.
    msg = MIMEMultipart()
    msg['Subject'] = subject
    msg['From'] = sender
    msg['To'] = ','.join(recipients)
    msg.attach(MIMEText(message, 'plain'))

    # Add attachments.
    for file_name in attachments:
        if os.path.exists(file_name):
            with open(file_name, 'r') as fp:
                attachment = MIMEBase('application', 'text')
                attachment.set_payload(fp.read())
                attachment.add_header(
                    'Content-Disposition',
                    'attachment; filename="{}"'.format(os.path.basename(file_name)))
                msg.attach(attachment)

    # The actual mail send.
    srv = smtplib.SMTP(server)
    if use_tls:
        srv.starttls()
    if username:
        srv.login(username, password)

    srv.sendmail(sender, ','.join(recipients), msg.as_string())
    srv.quit()
168201
def _invite(self, name, method, email, uuid, event, password=""):
        """"""

        props = {
            'uuid': std_uuid(),
            'status': 'Open',
            'name': name,
            'method': method,
            'email': email,
            'password': password,
            'timestamp': std_now()
        }
        enrollment = objectmodels['enrollment'](props)
        enrollment.save()

        self.log('Enrollment stored', lvl=debug)

        self._send_invitation(enrollment, event)

        packet = {
            'component': 'hfos.enrol.enrolmanager',
            'action': 'invite',
            'data': [True, email]
        }
        self.fireEvent(send(uuid, packet))
311765
def invitations():
    
    with Session() as session:
        try:
            result = session.VFolder.invitations()
            invitations = result.get('invitations', [])
            if len(invitations) < 1:
                print('No invitations.')
                return
            print('List of invitations (inviter, vfolder id, permission):')
            for cnt, inv in enumerate(invitations):
                if inv['perm'] == 'rw':
                    perm = 'read-write'
                elif inv['perm'] == 'ro':
                    perm = 'read-only'
                else:
                    perm = inv['perm']
                print('[{}] {}, {}, {}'.format(cnt + 1, inv['inviter'],
                                               inv['vfolder_id'], perm))

            selection = input('Choose invitation number to manage: ')
            if selection.isdigit():
                selection = int(selection) - 1
            else:
                return
            if 0 <= selection < len(invitations):
                while True:
                    action = input('Choose action. (a)ccept, (r)eject, (c)ancel: ')
                    if action.lower() == 'a':
                        # TODO: Let user can select access_key among many.
                        #       Currently, the config objects holds only one key.
                        config = get_config()
                        result = session.VFolder.accept_invitation(
                            invitations[selection]['id'], config.access_key)
                        print(result['msg'])
                        break
                    elif action.lower() == 'r':
                        result = session.VFolder.delete_invitation(
                            invitations[selection]['id'])
                        print(result['msg'])
                        break
                    elif action.lower() == 'c':
                        break
        except Exception as e:
            print_error(e)
            sys.exit(1)
552012
@Override
    public SendInvitation invitees(ApiBaseUser... users) {
        this.invitees.addAll(Arrays.asList(users));
        return this;
    }
609847
def invitations(self):
        """"""
        url = "%s/invitations" % self.root
        return Invitations(url=url,
                           securityHandler=self._securityHandler,
                           proxy_url=self._proxy_url,
                           proxy_port=self._proxy_port)
541048
def receive_invite(opts = {})
      recv(opts.merge(request: 'INVITE', rrs: true)) do |recv|
        action = doc.create_element('action') do |action|
          action << doc.create_element('ereg') do |ereg|
            ereg['regexp'] = '<sip:(.*)>.*;tag=([^;]*)'
            ereg['search_in'] = 'hdr'
            ereg['header'] = 'From:'
            ereg['assign_to'] = 'dummy,remote_addr,remote_tag'
          end
          action << doc.create_element('ereg') do |ereg|
            ereg['regexp'] = '<sip:(.*)>'
            ereg['search_in'] = 'hdr'
            ereg['header'] = 'To:'
            ereg['assign_to'] = 'dummy,local_addr'
          end
          action << doc.create_element('assignstr') do |assignstr|
            assignstr['assign_to'] = "call_addr"
            assignstr['value']     = "[$local_addr]"
          end
        end
        recv << action
      end
      # These variables (except dummy) will only be used if we initiate a hangup
      @reference_variables += %w(dummy remote_addr remote_tag local_addr call_addr)
    end
386204
def user_update_email(self, username, email):
        
        data = {'name': username, 'emailAddress': email}
        return self.user_update(username, data=data)
482541
def visit_folder(self, item, parent):
        
        if item.sent_to_remote:
            self._add_report_item(item.path, item.remote_id)
673959
def _attach_files(filepaths, email_):
    
    for filepath in filepaths:
        base = os.path.basename(filepath)
        with open(filepath, "rb") as file:
            part = MIMEApplication(file.read(), Name=base)
            part["Content-Disposition"] = 'attachment; filename="%s"' % base
            email_.attach(part)
928173
def do_invite(invite)
      if invite.existing_user?
        deliver_email(InviteMailer.existing_user(invite))
        after_invite_existing_user(invite)
        invite.save
      else
        deliver_email(InviteMailer.new_user(invite))
        after_invite_new_user(invite)
      end
    end
1200246
def inbox_folder(self):
        
        return self.folder_constructor(parent=self, name='Inbox',
                                       folder_id=OutlookWellKnowFolderNames
                                       .INBOX.value)
260972
def add_member_email(self, email, permissions=None):
        
        data = {'email': email}

        if isinstance(permissions, dict):
            data.update({
                'permissions': permissions
            })

        extra = {
            'resource': self.__class__.__name__,
            'query': {
                'id': self.id,
                'data': data,
            }
        }
        logger.info('Adding member using email', extra=extra)
        response = self._api.post(
            url=self._URL['members_query'].format(id=self.id), data=data)
        member_data = response.json()
        return Member(api=self._api, **member_data)
1287011
protected function _actionInvite($context)
    {
        $data = $context->data;
        $viewer = get_viewer();
        $emails = $data->email;

        foreach ($emails as $email) {

            if ($this->getService('anahita:filter.email')->validate($email)) {

                $person = $this->getService('repos:people.person')->find(array('email' => $email));

                if (!$person) {

                    $token = $this->getService('repos:invites.token')->getEntity(array(
                        'data' => array(
                            'inviter' => $viewer,
                            'serviceName' => 'email',
                        ),
                    ));

                    $token->save();

                    $settings = $this->getService('com:settings.setting');

                    $mails[] = array(
                        'subject' => AnTranslator::sprintf('COM-INVITES-MESSAGE-SUBJECT', $settings->sitename),
                        'to' => $email,
                        'layout' => false,
                        'template' => 'invite',
                        'data' => array(
                            'invite_url' => $token->getURL(),
                            'site_name' => $settings->sitename,
                            'sender' => $viewer,
                        ),
                    );

                    $this->mail($mails);
                }
            }
        }
    }
1355577
public function sendInvitation()
    {
        $data = [
            'name' => $this->full_name,
            'login' => $this->login,
            'password' => $this->getOriginalHashValue('password'),
            'link' => Backend::url('backend'),
        ];

        Mail::send('backend::mail.invite', $data, function ($message) {
            $message->to($this->email, $this->full_name);
        });
    }