Commit d70918d3 authored by Chenu Denis's avatar Chenu Denis
Browse files

[feature] Allow to construct specific list for contact

parent 68c948f8
......@@ -5,7 +5,7 @@
* @author Denis Chenu <denis@sondages.pro>
* @copyright 2020-2022 Denis Chenu <http://www.sondages.pro>
* @license AGPL v3
* @version 0.23.0
* @version 0.24.0
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
......@@ -941,45 +941,58 @@ class TokenUsersManager
}
$now = dateShift(date("Y-m-d H:i:s"), "Y-m-d H:i:s", Yii::app()->getConfig("timeadjust"));
if(!empty($aGroupTokens)) {
foreach ($aGroupTokens as $selecttoken) {
$criteria = new CDBCriteria();
$criteria->order = "lastname,firstname,tid";
$criteria->addInCondition('token',$aGroupTokens);
$oContactTokens = TokenManaged::model($surveyId)->findAll($criteria);
foreach($oContactTokens as $oContactToken) {
/* check validity when search (using editable) */
$oToken = TokenManaged::model($surveyId)->findByToken($selecttoken);
if(!$oToken->getActive()) {
if(!$oContactToken->getActive()) {
continue;
}
$haveAccess = true;
if ($oToken->getIsRestricted() && Utilities::getSetting($this->originalSurveyId, 'useAttributeRestricted')) {
if (Utilities::getSetting($this->originalSurveyId, 'useAttributeRestricted') && $oContactToken->getIsRestricted()) {
$oTokenSridAccess = models\TokenSridAccess::model()->findByPk(array(
'sid' => $this->originalSurveyId,
'token' => $selecttoken,
'token' => $oContactToken->token,
'srid' => $srid,
));
if(empty($oTokenSridAccess) && !$this->getHaveAllAccess($surveyId, $selecttoken)) {
if(empty($oTokenSridAccess) && !$this->getHaveAllAccess($surveyId, $oContactToken->token)) {
$haveAccess = false;
}
}
$description = implode(" ", array($oToken->firstname,$oToken->lastname));
$aAllTokens[$oContactToken->token] = $oContactToken->getAttributes();
$tokenListData[$oContactToken->token] = array();
$tokenListOption[$oContactToken->token] = array();
$description = implode(" ", array($oContactToken->firstname,$oContactToken->lastname));
if (empty($description)) {
$description = $oToken->token;
$description = $oContactToken->token;
}
$aAllTokens[$oContactToken->token]['description'] = $description;
if ($haveAccess) {
$tokenListData[$selecttoken] = $description;
$tokenListData[$oContactToken->token] = $description;
}
if ($oToken->getIsManager()) {
$tokenListDataByCategories[$managerTitle][$selecttoken] = $description;
} elseif ($oToken->getIsRestricted()) {
$tokenListDataByCategories[$restrictedTitle][$selecttoken] = $description;
if ($oContactToken->getIsManager()) {
$aAllTokens[$oContactToken->token]['status'] = 'manager';
$aAllTokens[$oContactToken->token]['i18nstatus'] = $managerTitle;
$tokenListDataByCategories[$managerTitle][$oContactToken->token] = $description;
} elseif ($oContactToken->getIsRestricted()) {
$aAllTokens[$oContactToken->token]['status'] = 'restricted';
$aAllTokens[$oContactToken->token]['i18nstatus'] = $restrictedTitle;
$tokenListDataByCategories[$restrictedTitle][$oContactToken->token] = $description;
} else {
$tokenListDataByCategories[$userTitle][$selecttoken] = $description;
$aAllTokens[$oContactToken->token]['status'] = 'user';
$aAllTokens[$oContactToken->token]['i18nstatus'] = $userTitle;
$tokenListDataByCategories[$userTitle][$oContactToken->token] = $description;
}
if (empty($oToken->email) || $oToken->emailstatus != "OK" || !$haveAccess) {
$tokenListOption[$selecttoken] = array('disabled' => 'disabled');
if (empty($oContactToken->email) || $oContactToken->emailstatus != "OK" || !$haveAccess) {
$tokenListOption[$oContactToken->token] = array('disabled' => 'disabled');
if (!$haveAccess) {
$tokenListOption[$selecttoken]['title'] = self::translate("No access");
} elseif (empty($oToken->email)) {
$tokenListOption[$selecttoken]['title'] = self::translate("No email");
$tokenListOption[$oContactToken->token]['title'] = self::translate("No access");
} elseif (empty($oContactToken->email)) {
$tokenListOption[$oContactToken->token]['title'] = self::translate("No email");
} else {
$tokenListOption[$selecttoken]['title'] = sprintf(self::translate("Invalid email (%s)"), $oToken->emailstatus);
$tokenListOption[$oContactToken->token]['title'] = sprintf(self::translate("Invalid email (%s)"), $oContactToken->emailstatus);
}
}
}
......@@ -994,6 +1007,7 @@ class TokenUsersManager
'listData' => $tokenListData,
'listDataByCategories' => $tokenListDataByCategories,
'listOption' => $tokenListOption,
'aAllTokens' => $aAllTokens,
'selected' => ''
);
......
......@@ -8,7 +8,7 @@
<author>Denis Chenu</author>
<authorUrl>https://www.sondages.pro/</authorUrl>
<supportUrl>https://support.sondages.pro/</supportUrl>
<version>0.23.1-beta1</version>
<version>0.24.0</version>
<license>GNU Affero General Public License v3.0</license>
<description><![CDATA[Token Users List And Manage.]]></description>
</metadata>
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment