How to hide suggestions of other customers' 'send groups' when I type the name of my own 'send group' when setting up a campaign

Groundarker

Member
Hello guys,
Christmas is coming and first of all I want to wish all your Team and anyone who will read us a wonderful Christmas!

As for me, however, before getting totally into the Christmas mood, I would like to try to solve a small thing.

In the "Details" tab of a campaign configuration, if I try to fill in the "send group" field, I am suggested send groups defined by other customers.
Is it possible to show only your own "sending groups" as suggestions when filling in the "sending group" field without displaying those of other customers?

Is there any way to achieve this?

A thousand thanks!
 

twisted1919

Administrator
Staff member
Thanks for catching this, we fixed it and will be available in the next release.
Meanwhile, you can open the file /apps/customer/controllers/Campaign_send_groupsController.php and look for:
PHP:
public function actionAutocomplete($term)
    {
        if (!request()->getIsAjaxRequest()) {
            $this->redirect(['campaign_send_groups/index']);
        }

        $criteria = new CDbCriteria();
        $criteria->compare('name', $term, true, 'OR');
        $criteria->limit = 20;

        $this->renderJson(CampaignSendGroupCollection::findAll($criteria)->map(function (CampaignSendGroup $model) {
            return [
                'group_id'  => $model->group_id,
                'label'     => t('campaigns', '{name} ({campaignsCount} campaigns)', [
                    '{name}'            => $model->name,
                    '{campaignsCount}'  => $model->campaignsCount,
                ]),
                'value' => $model->name,
            ];
        })->all());
    }
And make it:
PHP:
public function actionAutocomplete($term)
    {
        if (!request()->getIsAjaxRequest()) {
            $this->redirect(['campaign_send_groups/index']);
        }

        $criteria = new CDbCriteria();
        $criteria->compare('name', $term, true, 'OR');
        $criteria->compare('customer_id', (int)customer()->getId()); // this has been added
        $criteria->limit = 20;

        $this->renderJson(CampaignSendGroupCollection::findAll($criteria)->map(function (CampaignSendGroup $model) {
            return [
                'group_id'  => $model->group_id,
                'label'     => t('campaigns', '{name} ({campaignsCount} campaigns)', [
                    '{name}'            => $model->name,
                    '{campaignsCount}'  => $model->campaignsCount,
                ]),
                'value' => $model->name,
            ];
        })->all());
    }
And save the file, it should fix the problem for now.
 

twisted1919

Administrator
Staff member
Please see updated:

PHP:
public function actionAutocomplete($term)
    {
        if (!request()->getIsAjaxRequest()) {
            $this->redirect(['campaign_send_groups/index']);
        }

        $criteria = new CDbCriteria();
        $criteria->compare('name', $term, true);
        $criteria->compare('customer_id', (int)customer()->getId()); 
        $criteria->limit = 20;

        $this->renderJson(CampaignSendGroupCollection::findAll($criteria)->map(function (CampaignSendGroup $model) {
            return [
                'group_id'  => $model->group_id,
                'label'     => t('campaigns', '{name} ({campaignsCount} campaigns)', [
                    '{name}'            => $model->name,
                    '{campaignsCount}'  => $model->campaignsCount,
                ]),
                'value' => $model->name,
            ];
        })->all());
    }
 
Top