Jump to content


jack

Member Since 18 Oct 2018
Offline Last Active Today, 11:04 AM
-----

Topics I've Started

Fix for "Add to list" and "Remove from List"

16 April 2019 - 03:34 PM

Here is code for a fix for the workflow actions, it will be included in next update.

 

in both X2FlowRecordListAdd.php and X2FlowRecordListRemove.php change 

 

'linkSource' => Yii::app()->controller->createUrl(
                           CActiveRecord::model('X2List')->autoCompleteSource, array(
 
 
to 
 
'linkSource' => Yii::app()->controller->createUrl(
                       "/contacts/contacts/getAllLists", array(
 
and add to ContactsController.php
 
                'actions' => array('getItems', 'getLists', 'ignoreDuplicates', 'discardNew',
 
to
                'actions' => array('getItems', 'getLists', 'getAllLists', 'ignoreDuplicates', 'discardNew',

 

Also add this function 

 

    /**

     * Return a JSON encoded list of all the lists
     */
    public function actionGetAllLists() {
        if (!Yii::app()->user->checkAccess('ContactsAdminAccess')) {
            $condition = ' AND (visibility="1" OR assignedTo="Anyone"  OR assignedTo="' . Yii::app()->user->getName() . '"';
            /* x2temp */
            $groupLinks = Yii::app()->db->createCommand()->select('groupId')->from('x2_group_to_user')->where('userId=' . Yii::app()->user->getId())->queryColumn();
            if (!empty($groupLinks)) {
                $condition .= ' OR assignedTo IN (' . implode(',', $groupLinks) . ')';
            }
 
            $condition .= ' OR (visibility=2 AND assignedTo IN
                (SELECT username FROM x2_group_to_user WHERE groupId IN
                (SELECT groupId FROM x2_group_to_user WHERE userId=' . Yii::app()->user->getId() . '))))';
        } else {
            $condition = '';
        }
        // Optional search parameter for autocomplete
        $qterm = isset($_GET['term']) ? $_GET['term'] . '%' : '';
        $static = isset($_GET['static']) && $_GET['static'];
        $weblist = isset($_GET['weblist']) && $_GET['weblist'];
        $result = Yii::app()->db->createCommand()
                ->select('id,name as value')
                ->from('x2_lists')
                ->where(
                        ($static ? 'type="static" AND ' : '') .
                        ($weblist ? 'type="weblist" AND ' : '') .
                        'type!="campaign" 
                    AND name LIKE :qterm' . $condition, array(':qterm' => $qterm))
                ->order('name ASC')
                ->queryAll();
        echo CJSON::encode($result);
    }