本文整理汇总了PHP中Participant::gen_uuid方法的典型用法代码示例。如果您正苦于以下问题:PHP Participant::gen_uuid方法的具体用法?PHP Participant::gen_uuid怎么用?PHP Participant::gen_uuid使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Participant
的用法示例。
在下文中一共展示了Participant::gen_uuid方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: uploadCSV
//.........这里部分代码省略.........
//saving in this import
foreach ($mappedarray as $attid => $attname) {
if (!empty($attname)) {
$bData = array('participant_id' => $aData, 'attribute_id' => $attid, 'value' => $writearray[strtolower($attname)]);
ParticipantAttribute::model()->updateParticipantAttributeValue($bData);
} else {
//If the value is empty, don't write the value
}
}
$overwritten++;
}
}
}
if ($thisduplicate == 1) {
$dupfound = true;
$duplicatelist[] = $writearray['firstname'] . " " . $writearray['lastname'] . " (" . $writearray['email'] . ")";
}
//Checking the email address is in a valid format
$invalidemail = false;
$writearray['email'] = trim($writearray['email']);
if ($writearray['email'] != '') {
$aEmailAddresses = explode(';', $writearray['email']);
// Ignore additional email addresses
$sEmailaddress = $aEmailAddresses[0];
if (!validateEmailAddress($sEmailaddress)) {
$invalidemail = true;
$invalidemaillist[] = $line[0] . " " . $line[1] . " (" . $line[2] . ")";
}
}
if (!$dupfound && !$invalidemail) {
//If it isn't a duplicate value or an invalid email, process the entry as a new participant
//First, process the known fields
if (!isset($writearray['participant_id']) || $writearray['participant_id'] == "") {
$uuid = Participant::gen_uuid();
//Generate a UUID for the new participant
$writearray['participant_id'] = $uuid;
}
if (isset($writearray['emailstatus']) && trim($writearray['emailstatus'] == '')) {
unset($writearray['emailstatus']);
}
if (!isset($writearray['language']) || $writearray['language'] == "") {
$writearray['language'] = "en";
}
if (!isset($writearray['blacklisted']) || $writearray['blacklisted'] == "") {
$writearray['blacklisted'] = "N";
}
$writearray['owner_uid'] = Yii::app()->session['loginID'];
if (isset($writearray['validfrom']) && trim($writearray['validfrom'] == '')) {
unset($writearray['validfrom']);
}
if (isset($writearray['validuntil']) && trim($writearray['validuntil'] == '')) {
unset($writearray['validuntil']);
}
$dontimport = false;
if ($filterblankemails == "accept" && $writearray['email'] == "") {
//The mandatory fields of email, firstname and lastname
//must be filled, but one or more are empty
$mandatory++;
$dontimport = true;
} else {
foreach ($writearray as $key => $value) {
if (!empty($mappedarray)) {
//The mapped array contains the attributes we are
//saving in this import
if (in_array($key, $allowedfieldnames)) {
foreach ($mappedarray as $attid => $attname) {
示例2: cpd_importParticipants
/**
* This function import a participant to the LimeSurvey cpd. It stores attributes as well, if they are registered before within ui
*
* Call the function with $response = $myJSONRPCClient->cpd_importParticipants( $sessionKey, $aParticipants);
*
* @param int $sSessionKey
* @param array $aParticipants
* [[0] => ["email"=>"dummy-02222@limesurvey.com","firstname"=>"max","lastname"=>"mustermann"]]
* @return array with status
*/
public function cpd_importParticipants($sSessionKey, $aParticipants)
{
if (!$this->_checkSessionKey($sSessionKey)) {
return array('status' => 'Invalid session key');
}
$aResponse = array();
$aAttributeData = array();
$aAttributes = array();
$aDefaultFields = array('participant_id', 'firstname', 'lastname', 'email', 'language', 'blacklisted');
$bIsValidEmail = true;
$bDoImport = true;
$sMandatory = 0;
$sAttribCount = 0;
$aResponse = array();
$aResponse['ImportCount'] = 0;
// get all attributes for mapping
$oFindCriteria = new CDbCriteria();
$oFindCriteria->offset = -1;
$oFindCriteria->limit = -1;
$aAttributeRecords = ParticipantAttributeName::model()->with('participant_attribute_names_lang')->findAll($oFindCriteria);
foreach ($aParticipants as $sKey => $aParticipantData) {
$aData = array('firstname' => $aParticipantData['firstname'], 'lastname' => $aParticipantData['lastname'], 'email' => $aParticipantData['email'], 'owner_uid' => Yii::app()->session['loginID']);
//Check for duplicate participants
$arRecordExists = Participant::model()->exists('firstname = :firstname AND lastname = :lastname AND email = :email AND owner_uid = :owner_uid', array(':firstname' => $aData['firstname'], ':lastname' => $aData['lastname'], ':email' => $aData['email'], ':owner_uid' => $aData['owner_uid']));
// check if email is valid
$this->_checkEmailFormat($aData['email']);
if ($bIsValidEmail == true) {
//First, process the known fields
if (!isset($aData['participant_id']) || $aData['participant_id'] == "") {
// $arParticipantModel = new Participant();
$aData['participant_id'] = Participant::gen_uuid();
}
if (isset($aData['emailstatus']) && trim($aData['emailstatus'] == '')) {
unset($aData['emailstatus']);
}
if (!isset($aData['language']) || $aData['language'] == "") {
$aData['language'] = "en";
}
if (!isset($aData['blacklisted']) || $aData['blacklisted'] == "") {
$aData['blacklisted'] = "N";
}
$aData['owner_uid'] = Yii::app()->session['loginID'];
if (isset($aData['validfrom']) && trim($aData['validfrom'] == '')) {
unset($aData['validfrom']);
}
if (isset($aData['validuntil']) && trim($aData['validuntil'] == '')) {
unset($aData['validuntil']);
}
if (!empty($aData['email'])) {
//The mandatory fields of email, firstname and lastname
$sMandatory++;
$bDoImport = false;
}
// Write to database if record not exists
if (empty($arRecordExists)) {
// save participant to database
Participant::model()->insertParticipantCSV($aData);
// Prepare atrribute values to store in db . Iterate through our values
foreach ($aParticipantData as $sLabel => $sAttributeValue) {
// skip default fields
if (!in_array($sLabel, $aDefaultFields)) {
foreach ($aAttributeRecords as $sKey => $arValue) {
$aAttributes = $arValue->getAttributes();
if ($aAttributes['defaultname'] == $sLabel) {
$aAttributeData['participant_id'] = $aData['participant_id'];
$aAttributeData['attribute_id'] = $aAttributes['attribute_id'];
$aAttributeData['value'] = $sAttributeValue;
$sAttribCount++;
// save attributes values for participant
ParticipantAttributeName::model()->saveParticipantAttributeValue($aAttributeData);
}
}
}
}
$aResponse['ImportCount']++;
}
}
}
return $aResponse;
}