@Route("/{type}/{portfolioWidgetId}", name="icap_portfolio_internal_portfolio_widget_put", requirements={"portfolioWidgetId" = "\d+"})
@Method({"PUT"})

@ParamConverter("loggedUser", options={"authenticatedUser" = true})
436835
public function putAction(Request $request, User $loggedUser, Portfolio $portfolio, $type, $portfolioWidgetId)
    {
        $this->checkPortfolioToolAccess($loggedUser, $portfolio);

        /** @var \Icap\PortfolioBundle\Entity\PortfolioWidget $portfolioWidget */
        $portfolioWidget = $this->getDoctrine()->getRepository('IcapPortfolioBundle:PortfolioWidget')->findOneBy([
            'id' => $portfolioWidgetId,
            'widgetType' => $type,
            'portfolio' => $portfolio,
        ]);
        $oldWidget = $portfolioWidget->getWidget()->getId();
        $data = $this->getWidgetsManager()->handlePortfolioWidget($portfolioWidget, $request->request->all(), $this->get('kernel')->getEnvironment());
        if ($oldWidget !== $data['widget_id']) {
            $event = new PortfolioEditEvent($portfolio);
            $this->get('event_dispatcher')->dispatch('log', $event);
        }
        $response = new JsonResponse();
        $response->setData($data);

        return $response;
    }
601778
public function update(PortfolioRequest $request, Portfolio $portfolio)
    {
        try {
            $attributes = $request->all();

            $portfolio->update($attributes);
            return $this->response->message(trans('messages.success.updated', ['Module' => trans('portfolio::portfolio.name')]))
                ->code(204)
                ->status('success')
                ->url(guard_url('portfolio/portfolio/' . $portfolio->getRouteKey()))
                ->redirect();
        } catch (Exception $e) {
            return $this->response->message($e->getMessage())
                ->code(400)
                ->status('error')
                ->url(guard_url('portfolio/portfolio/' . $portfolio->getRouteKey()))
                ->redirect();
        }

    }
161627
public function setAccessToken($token, $clientId, $userId, $expiryTimestamp, $scope = null)
    {
        $authTokenDataMapper = $this->getTokenDataMapper(Entity\AccessToken::class);

        $client = $this->getClientDataMapper()->findByUuid($clientId);

        if (! $accessToken = $authTokenDataMapper->findByToken($token)) {
            $accessToken = new Entity\AccessToken(null, $token, $client);
        } else {
            $accessToken->setClient($client);
        }

        if ($userId) {
            $user = $this->getUserDataMapper()->findByUuid($userId);

            if ($user instanceof $this->userClass) {
                $accessToken->setUser($user);
            }
        }

        $expiryDate = is_int($expiryTimestamp) ? new DateTime('@' . $expiryTimestamp) : null;
        $accessToken->setExpiryDate($expiryDate);

        if ($scope) {
            $scopes = $this->getScopeDataMapper()->findScopes(explode(' ', $scope));
            $accessToken->setScopes($scopes);
        }

        $authTokenDataMapper->save($accessToken);
    }
456905
public void setIamUserArns(java.util.Collection<String> iamUserArns) {
        if (iamUserArns == null) {
            this.iamUserArns = null;
            return;
        }

        this.iamUserArns = new com.amazonaws.internal.SdkInternalList<String>(iamUserArns);
    }
495432
@Override
    protected void defineWidgets() {

        // initialize the user object to use for the dialog
        initUserObject();
        boolean webuserOu = false;
        try {
            webuserOu = OpenCms.getOrgUnitManager().readOrganizationalUnit(getCms(), getParamOufqn()).hasFlagWebuser();
        } catch (CmsException e) {
            webuserOu = m_user.isWebuser();
        }
        setKeyPrefix(KEY_PREFIX);

        // widgets to display
        if (isNewUser() && isEditable(m_user)) {
            addWidget(new CmsWidgetDialogParameter(this, "name", PAGES[0], new CmsInputWidget()));
        } else {
            addWidget(new CmsWidgetDialogParameter(this, "name", PAGES[0], new CmsDisplayWidget()));
        }
        if (isEditable(m_user)) {
            addWidget(new CmsWidgetDialogParameter(this, "description", "", PAGES[0], new CmsTextareaWidget(), 0, 1));
            addWidget(new CmsWidgetDialogParameter(m_user, "lastname", PAGES[0], new CmsInputWidget()));
            addWidget(new CmsWidgetDialogParameter(m_user, "firstname", PAGES[0], new CmsInputWidget()));
            addWidget(new CmsWidgetDialogParameter(m_user, "email", PAGES[0], new CmsInputWidget()));
            addWidget(new CmsWidgetDialogParameter(this, "assignedOu", PAGES[0], new CmsDisplayWidget()));
            addWidget(new CmsWidgetDialogParameter(m_user, "institution", "", PAGES[0], new CmsInputWidget(), 0, 1));
            addWidget(new CmsWidgetDialogParameter(m_user, "address", "", PAGES[0], new CmsInputWidget(), 0, 1));
            addWidget(new CmsWidgetDialogParameter(m_user, "zipcode", "", PAGES[0], new CmsInputWidget(), 0, 1));
            addWidget(new CmsWidgetDialogParameter(m_user, "city", "", PAGES[0], new CmsInputWidget(), 0, 1));
            addWidget(new CmsWidgetDialogParameter(m_user, "country", "", PAGES[0], new CmsInputWidget(), 0, 1));
            if (!webuserOu) {
                addWidget(
                    new CmsWidgetDialogParameter(this, "language", PAGES[0], new CmsSelectWidget(getLanguages())));
                if (!getSites().isEmpty()) {
                    addWidget(new CmsWidgetDialogParameter(this, "site", PAGES[0], new CmsSelectWidget(getSites())));
                }
                addWidget(
                    new CmsWidgetDialogParameter(this, "startProject", PAGES[0], new CmsSelectWidget(getProjects())));
                addWidget(
                    new CmsWidgetDialogParameter(
                        this,
                        "startFolder",
                        PAGES[0],
                        new CmsVfsFileWidget(true, null, false)));
                addWidget(new CmsWidgetDialogParameter(this, "startView", PAGES[0], new CmsSelectWidget(getViews())));
                if (isNewUser()) {
                    addWidget(
                        new CmsWidgetDialogParameter(
                            this,
                            "group",
                            PAGES[0],
                            new CmsGroupWidget(null, null, getParamOufqn())));
                    addWidget(new CmsWidgetDialogParameter(this, "role", PAGES[0], new CmsSelectWidget(getRoles())));
                }
            }
        } else {
            addWidget(new CmsWidgetDialogParameter(this, "description", PAGES[0], new CmsDisplayWidget()));
            addWidget(new CmsWidgetDialogParameter(m_user, "lastname", PAGES[0], new CmsDisplayWidget()));
            addWidget(new CmsWidgetDialogParameter(m_user, "firstname", PAGES[0], new CmsDisplayWidget()));
            addWidget(new CmsWidgetDialogParameter(m_user, "email", PAGES[0], new CmsDisplayWidget()));
            addWidget(new CmsWidgetDialogParameter(this, "assignedOu", PAGES[0], new CmsDisplayWidget()));
            addWidget(new CmsWidgetDialogParameter(m_user, "institution", PAGES[0], new CmsDisplayWidget()));
            addWidget(new CmsWidgetDialogParameter(m_user, "address", PAGES[0], new CmsDisplayWidget()));
            addWidget(new CmsWidgetDialogParameter(m_user, "zipcode", PAGES[0], new CmsDisplayWidget()));
            addWidget(new CmsWidgetDialogParameter(m_user, "city", PAGES[0], new CmsDisplayWidget()));
            addWidget(new CmsWidgetDialogParameter(m_user, "country", PAGES[0], new CmsDisplayWidget()));
            if (!webuserOu) {
                addWidget(new CmsWidgetDialogParameter(this, "language", PAGES[0], new CmsDisplayWidget()));
                if (!getSites().isEmpty()) {
                    addWidget(new CmsWidgetDialogParameter(this, "site", PAGES[0], new CmsDisplayWidget()));
                }
                addWidget(new CmsWidgetDialogParameter(this, "startProject", PAGES[0], new CmsDisplayWidget()));
                addWidget(new CmsWidgetDialogParameter(this, "startFolder", PAGES[0], new CmsDisplayWidget()));
                addWidget(new CmsWidgetDialogParameter(this, "startView", PAGES[0], new CmsDisplayWidget()));
            }
        }
        addWidget(new CmsWidgetDialogParameter(m_user, "enabled", PAGES[0], new CmsCheckboxWidget()));
        addWidget(new CmsWidgetDialogParameter(this, "selfManagement", PAGES[0], new CmsCheckboxWidget()));
        if (isPwdChangeAllowed(m_user)) {
            addWidget(new CmsWidgetDialogParameter(m_pwdInfo, "newPwd", PAGES[0], new CmsPasswordWidget()));
            addWidget(new CmsWidgetDialogParameter(m_pwdInfo, "confirmation", PAGES[0], new CmsPasswordWidget()));
        }
    }
1321160
def add_or_update(user_id, app_id, value):
        '''
        
        '''
        rec = MEvaluation.get_by_signature(user_id, app_id)
        if rec:
            entry = TabEvaluation.update(
                value=value,
            ).where(TabEvaluation.uid == rec.uid)
            entry.execute()
        else:
            TabEvaluation.create(
                uid=tools.get_uuid(),
                user_id=user_id,
                post_id=app_id,
                value=value,
            )
1198490
@Override
    public void setUserLayout(
            final IPerson person,
            final IUserProfile profile,
            final Document layoutXML,
            final boolean channelsAdded) {
        final long startTime = System.currentTimeMillis();
        final int userId = person.getID();
        final int profileId = profile.getProfileId();

        // don't try to save null layouts.
        if (layoutXML == null) {
            logger.error(
                    "Invalid attempt to save NULL user layout for user "
                            + person.getUserName()
                            + ". Skipping!");
            return;
        }

        transactionOperations.execute(
                status ->
                        jdbcOperations.execute(
                                (ConnectionCallback<Object>)
                                        con -> {
                                            int layoutId;
                                            ResultSet rs;

                                            // Eventually we want to be able to just get layoutId
                                            // from
                                            // the
                                            // profile, but because of the template user layouts we
                                            // have
                                            // to do this for now ...
                                            layoutId = getLayoutID(userId, profileId);

                                            boolean firstLayout = false;
                                            if (layoutId == 0) {
                                                // First personal layout for this user/profile
                                                layoutId = 1;
                                                firstLayout = true;
                                            }

                                            String sql =
                                                    "DELETE FROM UP_LAYOUT_PARAM WHERE USER_ID=? AND LAYOUT_ID=?";
                                            PreparedStatement pstmt = con.prepareStatement(sql);
                                            try {
                                                pstmt.clearParameters();
                                                pstmt.setInt(1, userId);
                                                pstmt.setInt(2, layoutId);
                                                logger.debug(sql);
                                                pstmt.executeUpdate();
                                            } finally {
                                                pstmt.close();
                                            }

                                            sql =
                                                    "DELETE FROM UP_LAYOUT_STRUCT WHERE USER_ID=? AND LAYOUT_ID=?";
                                            pstmt = con.prepareStatement(sql);
                                            try {
                                                pstmt.clearParameters();
                                                pstmt.setInt(1, userId);
                                                pstmt.setInt(2, layoutId);
                                                logger.debug(sql);
                                                pstmt.executeUpdate();
                                            } finally {
                                                pstmt.close();
                                            }

                                            int firstStructId;
                                            try (PreparedStatement structStmt =
                                                            con.prepareStatement(
                                                                    "INSERT INTO UP_LAYOUT_STRUCT "
                                                                            + "(USER_ID, LAYOUT_ID, STRUCT_ID, NEXT_STRUCT_ID, CHLD_STRUCT_ID,EXTERNAL_ID,CHAN_ID,NAME,TYPE,HIDDEN,IMMUTABLE,UNREMOVABLE) "
                                                                            + "VALUES ("
                                                                            + userId
                                                                            + ","
                                                                            + layoutId
                                                                            + ",?,?,?,?,?,?,?,?,?,?)");
                                                    PreparedStatement parmStmt =
                                                            con.prepareStatement(
                                                                    "INSERT INTO UP_LAYOUT_PARAM "
                                                                            + "(USER_ID, LAYOUT_ID, STRUCT_ID, STRUCT_PARM_NM, STRUCT_PARM_VAL) "
                                                                            + "VALUES ("
                                                                            + userId
                                                                            + ","
                                                                            + layoutId
                                                                            + ",?,?,?)")) {
                                                firstStructId =
                                                        saveStructure(
                                                                layoutXML
                                                                        .getFirstChild()
                                                                        .getFirstChild(),
                                                                structStmt,
                                                                parmStmt);
                                            }

                                            // Check to see if the user has a matching layout
                                            sql =
                                                    "SELECT * FROM UP_USER_LAYOUT WHERE USER_ID=? AND LAYOUT_ID=?";
                                            pstmt = con.prepareStatement(sql);
                                            try {
                                                pstmt.clearParameters();
                                                pstmt.setInt(1, userId);
                                                pstmt.setInt(2, layoutId);
                                                logger.debug(sql);
                                                rs = pstmt.executeQuery();

                                                try {
                                                    if (!rs.next()) {
                                                        /*
                                                         * In ancient times, uPortal had a notion of
                                                         * a "template user," and here we used to
                                                         * set up profiles based on the emplate
                                                         * user.  Now we use the 'system' user.
                                                         */
                                                        final int defaultUserId =
                                                                getSystemUser().getID();

                                                        // Add to UP_USER_LAYOUT
                                                        sql =
                                                                "SELECT USER_ID,LAYOUT_ID,LAYOUT_TITLE,INIT_STRUCT_ID FROM UP_USER_LAYOUT WHERE USER_ID=?";
                                                        try (PreparedStatement pstmt2 =
                                                                con.prepareStatement(sql)) {
                                                            pstmt2.clearParameters();
                                                            pstmt2.setInt(1, defaultUserId);
                                                            logger.debug(sql);
                                                            try (ResultSet rs2 =
                                                                    pstmt2.executeQuery()) {
                                                                if (rs2.next()) {
                                                                    // There is a row for this
                                                                    // user's
                                                                    // template user...
                                                                    sql =
                                                                            "INSERT INTO UP_USER_LAYOUT (USER_ID, LAYOUT_ID, LAYOUT_TITLE, INIT_STRUCT_ID) VALUES (?,?,?,?)";
                                                                    try (PreparedStatement pstmt3 =
                                                                            con.prepareStatement(
                                                                                    sql)) {
                                                                        pstmt3.clearParameters();
                                                                        pstmt3.setInt(1, userId);
                                                                        pstmt3.setInt(
                                                                                2,
                                                                                rs2.getInt(
                                                                                        "LAYOUT_ID"));
                                                                        pstmt3.setString(
                                                                                3,
                                                                                rs2.getString(
                                                                                        "LAYOUT_TITLE"));
                                                                        pstmt3.setInt(
                                                                                4,
                                                                                rs2.getInt(
                                                                                        "INIT_STRUCT_ID"));
                                                                        logger.debug(sql);
                                                                        pstmt3.executeUpdate();
                                                                    }
                                                                } else {
                                                                    // We can't rely on the template
                                                                    // user, but we still need a
                                                                    // row...
                                                                    sql =
                                                                            "INSERT INTO UP_USER_LAYOUT (USER_ID, LAYOUT_ID, LAYOUT_TITLE, INIT_STRUCT_ID) VALUES (?,?,?,?)";
                                                                    try (PreparedStatement pstmt3 =
                                                                            con.prepareStatement(
                                                                                    sql)) {
                                                                        pstmt3.clearParameters();
                                                                        pstmt3.setInt(1, userId);
                                                                        pstmt3.setInt(2, layoutId);
                                                                        pstmt3.setString(
                                                                                3,
                                                                                "default layout");
                                                                        pstmt3.setInt(4, 1);
                                                                        logger.debug(sql);
                                                                        pstmt3.executeUpdate();
                                                                    }
                                                                }
                                                            }
                                                        }
                                                    }
                                                } finally {
                                                    rs.close();
                                                }
                                            } finally {
                                                pstmt.close();
                                            }

                                            // Update the users layout with the correct inital
                                            // structure
                                            // ID
                                            sql =
                                                    "UPDATE UP_USER_LAYOUT SET INIT_STRUCT_ID=? WHERE USER_ID=? AND LAYOUT_ID=?";
                                            pstmt = con.prepareStatement(sql);
                                            try {
                                                pstmt.clearParameters();
                                                pstmt.setInt(1, firstStructId);
                                                pstmt.setInt(2, userId);
                                                pstmt.setInt(3, layoutId);
                                                logger.debug(sql);
                                                pstmt.executeUpdate();
                                            } finally {
                                                pstmt.close();
                                            }

                                            // Update the last time the user saw the list of
                                            // available
                                            // channels
                                            if (channelsAdded) {
                                                sql =
                                                        "UPDATE UP_USER SET LST_CHAN_UPDT_DT=? WHERE USER_ID=?";
                                                pstmt = con.prepareStatement(sql);
                                                try {
                                                    pstmt.clearParameters();
                                                    pstmt.setDate(
                                                            1,
                                                            new Date(System.currentTimeMillis()));
                                                    pstmt.setInt(2, userId);
                                                    logger.debug(sql);
                                                    pstmt.executeUpdate();
                                                } finally {
                                                    pstmt.close();
                                                }
                                            }

                                            if (firstLayout) {
                                                sql =
                                                        "UPDATE UP_USER_PROFILE SET LAYOUT_ID=1 WHERE USER_ID=? AND PROFILE_ID=?";
                                                pstmt = con.prepareStatement(sql);
                                                try {
                                                    pstmt.clearParameters();
                                                    pstmt.setInt(1, userId);
                                                    pstmt.setInt(2, profileId);
                                                    logger.debug(sql);
                                                    pstmt.executeUpdate();
                                                } finally {
                                                    pstmt.close();
                                                }
                                            }

                                            return null;
                                        }));
        if (logger.isDebugEnabled()) {
            long stopTime = System.currentTimeMillis();
            long timeTook = stopTime - startTime;
            logger.debug(
                    "setUserLayout(): Layout document for user {} took {} milliseconds to save",
                    userId,
                    timeTook);
        }
    }
140867
public function setPortfolioWidgets($portfolioWidgets)
    {
        foreach ($portfolioWidgets as $portfolioWidget) {
            $portfolioWidget->setPortfolio($this);
        }

        $this->portfolioWidgets = $portfolioWidgets;

        return $this;
    }
329624
public Widget insert(Widget w, int beforeIndex) {

        FlowPanel widgetWrapper = new FlowPanel();
        widgetWrapper.getElement().setId(Document.get().createUniqueId());
        widgetWrapper.add(w);

        flow.insert(w, beforeIndex);

        JQMContext.render(widgetWrapper.getElement().getId());
        rebase();

        return widgetWrapper;
    }
275166
def put(self, accountId):
        """"""
        self.reqparse.add_argument('accountName', type=str, required=True)
        self.reqparse.add_argument('accountType', type=str, required=True)
        self.reqparse.add_argument('contacts', type=dict, required=True, action='append')
        self.reqparse.add_argument('enabled', type=int, required=True, choices=(0, 1))
        self.reqparse.add_argument('requiredRoles', type=str, action='append', default=())
        self.reqparse.add_argument('properties', type=dict, required=True)
        args = self.reqparse.parse_args()

        account_class = get_plugin_by_name(PLUGIN_NAMESPACES['accounts'], args['accountType'])
        if not account_class:
            raise InquisitorError('Invalid account type: {}'.format(args['accountType']))

        validate_contacts(args['contacts'])

        if not args['accountName'].strip():
            raise Exception('You must provide an account name')

        if not args['contacts']:
            raise Exception('You must provide at least one contact')

        class_properties = {from_camelcase(key): value for key, value in args['properties'].items()}
        for prop in account_class.class_properties:
            if prop['key'] not in class_properties:
                raise InquisitorError('Missing required property {}'.format(prop))

        account = account_class.get(accountId)
        if account.account_type != args['accountType']:
            raise InquisitorError('You cannot change the type of an account')

        account.account_name = args['accountName']
        account.contacts = args['contacts']
        account.enabled = args['enabled']
        account.required_roles = args['requiredRoles']
        account.update(**args['properties'])
        account.save()

        auditlog(event='account.update', actor=session['user'].username, data=args)

        return self.make_response({'message': 'Object updated', 'account': account.to_json(is_admin=True)})
1271050
public function replaceUser(User $from, User $to)
    {
        $portfolioGuides = $this->entityManager->getRepository('IcapPortfolioBundle:PortfolioGuide')->findByUser($from);

        if (count($portfolioGuides) > 0) {
            foreach ($portfolioGuides as $portfolioGuide) {
                $portfolioGuide->setUser($to);
            }

            $this->entityManager->flush();
        }

        return count($portfolioGuides);
    }
256277
@PUT
  @Path("{user}")
  @Consumes(MediaType.TEXT_PLAIN)
  public Response addUser(@PathParam("user") String username, @HeaderParam("Authorization") @DefaultValue("no token") String auth, String message) throws Exception {
    if(!this.isAuth(auth)) {
      throw new Exception("Unauthorized!");
    }
    if( realm != null ){
      AuthenticationManagerRequest req = new AuthenticationManagerRequest();
      req.setAccountName(username);
      req.setPassword(message);
      req.setRequestType(RequestType.ADD);
      
      sendMessage(req);
      return Response.created(new URI("")).build();
    }
    return Response.status(Status.NOT_FOUND).build();
  }
363045
def add_account(self, account):
        ''
        if account.account_cookie not in self.account_list:
            if self.cash_available > account.init_cash:
                account.portfolio_cookie = self.portfolio_cookie
                account.user_cookie = self.user_cookie
                self.cash.append(self.cash_available - account.init_cash)
                self.account_list.append(account.account_cookie)
                account.save()
                return account
        else:
            pass
82459
public function setPortfolioUsers($portfolioUsers)
    {
        foreach ($portfolioUsers as $portfolioUser) {
            $portfolioUser->setPortfolio($this);
        }

        $this->portfolioUsers = $portfolioUsers;

        return $this;
    }
1291278
function(assetKey) {
        var oldEntry = oldAvailableLists[assetKey];
        if ( oldEntry === undefined || oldEntry.off === true ) { return; }
        var listURL = oldEntry.contentURL;
        if ( Array.isArray(listURL) ) {
            listURL = listURL[0];
        }
        var newEntry = {
            content: 'filters',
            contentURL: listURL,
            external: true,
            group: 'custom',
            submitter: 'user',
            title: oldEntry.title || ''
        };
        newAvailableLists[listURL] = newEntry;
        µb.assets.registerAssetSource(listURL, newEntry);
        importedListKeys.push(listURL);
        µb.userSettings.externalLists += '\n' + listURL;
        µb.userSettings.externalLists = µb.userSettings.externalLists.trim();
        vAPI.storage.set({ externalLists: µb.userSettings.externalLists });
        µb.saveSelectedFilterLists([ listURL ], true);
    }
705559
public function getViewAction(User $loggedUser, Portfolio $portfolio, $startDate, $endDate)
    {
        $this->checkPortfolioToolAccess($loggedUser, $portfolio);

        $startDate = new \DateTime($startDate);
        $endDate = new \DateTime($endDate);

        $chartData = $this->getAnalyticsManager()->getViewsForChart(
            $loggedUser,
            $portfolio,
            [$startDate->getTimestamp(), $endDate->getTimestamp()]
        );
        $response = new JsonResponse($chartData, Response::HTTP_OK);

        return $response;
    }
129959
protected final void attach(Attachable widget) {
		if (user != null) {
			widget.addTo(user);
		} else {
			if (waitingForUser == null) waitingForUser = new LinkedList<Attachable>();
			waitingForUser.add(widget);
		}
	}