/**
*  Make sure all active tables have the right sized token field
*
*  During a small period in the 2.0 cycle some survey tables got no
*  token field or a token field that was too small. This patch makes
*  sure all surveys that are not anonymous have a token field with the
*  right size
*
* @return void
*/
function upgradeSurveyTables164()
{
    $sQuery = "SELECT sid FROM {{surveys}} WHERE active='Y' and anonymized='N'";
    $aResult = Yii::app()->getDb()->createCommand($sQuery)->queryAll();
    if (!$aResult) {
        return "Database Error";
    } else {
        foreach ($aResult as $sv) {
            $token = SurveyDynamic::model($sv['sid'])->getTableSchema()->getColumn('token');
            if (is_null($token)) {
                addColumn('{{survey_' . $sv['sid'] . '}}', 'token', 'string(36)');
            } elseif ($token->size < 36) {
                alterColumn('{{survey_' . $sv['sid'] . '}}', 'token', 'string(36)');
            }
        }
    }
}
Esempio n. 2
0
    echo "</table>\r\n";
}
function synchronizeComments()
{
    global $xoopsDB, $xoopsModule, $mydirname;
    $sql = sprintf('SELECT bl.blog_id, COUNT(cm.com_id) FROM %s AS bl LEFT JOIN %s AS cm ON bl.blog_id=cm.com_itemid AND cm.com_modid=%d GROUP BY bl.blog_id', $xoopsDB->prefix($mydirname), $xoopsDB->prefix('xoopscomments'), $xoopsModule->getVar('mid'));
    $result = $xoopsDB->query($sql) or exit($xoopsDB->error());
    $handler =& xoops_getmodulehandler('entry');
    while (list($blog_id, $comments) = $xoopsDB->fetchRow($result)) {
        $handler->updateComments($blog_id, intval($comments));
    }
    redirect_header('dbmanager.php', 2, _AM_WEBLOG_DBUPDATED);
    exit;
}
switch ($action) {
    case "comments":
        synchronizeComments();
        break;
    case "checktable":
        checkTables();
        break;
    case "addcolumn":
        addColumn($_POST);
        break;
    case "addtable":
        addtable($_POST);
        break;
    default:
        dbManager();
        break;
}
Esempio n. 3
0
 function copyCPBDAttributesToTokens($surveyid, $mapped, $newcreate, $participantid, $overwriteauto = false, $overwriteman = false, $overwritest = false, $createautomap = true)
 {
     Yii::app()->loadHelper('common');
     $duplicate = 0;
     $sucessfull = 0;
     $iBlacklistSkipped = 0;
     $participantid = explode(",", $participantid);
     //List of participant ids to add to tokens table
     if ($participantid[0] == "") {
         $participantid = array_slice($participantid, 1);
     }
     $number2add = sanitize_int(count($newcreate));
     //Number of tokens being created
     $tokenattributefieldnames = array();
     //Will contain descriptions of existing token attribute fields
     $tokenfieldnames = array();
     //Will contain the actual field names of existing token attribute fields
     $attributesadded = array();
     //Will contain the actual field name of any new token attribute fields
     $attributeidadded = array();
     //Will contain the description of any new token attribute fields
     $fieldcontents = array();
     //Will contain serialised info for the surveys.attributedescriptions field
     $surveyinfo = getSurveyInfo($surveyid);
     $defaultsurveylang = $surveyinfo['surveyls_language'];
     $arr = Yii::app()->db->createCommand()->select('*')->from("{{tokens_{$surveyid}}}")->queryRow();
     if (is_array($arr)) {
         $tokenfieldnames = array_keys($arr);
         $tokenattributefieldnames = array_filter($tokenfieldnames, 'filterForAttributes');
     }
     // If automapping is enabled then update the token field properties with the mapped CPDB field ID
     if ($createautomap == "true") {
         foreach ($mapped as $key => $iIDAttributeCPDB) {
             if (is_numeric($iIDAttributeCPDB)) {
                 /* Update the attributedescriptions info */
                 $aTokenAttributes = Survey::model()->findByPk($surveyid)->tokenattributes;
                 $aTokenAttributes[$key]['cpdbmap'] = $iIDAttributeCPDB;
                 Yii::app()->db->createCommand()->update('{{surveys}}', array("attributedescriptions" => json_encode($aAttributes)), 'sid = ' . $surveyid);
             }
         }
     }
     foreach ($tokenattributefieldnames as $key => $value) {
         $mapped[$key] = $value;
         // $value can be 'attribute_1', which will clash with postgres
     }
     if (!empty($newcreate)) {
         foreach ($newcreate as $key => $value) {
             $newfieldname = 'attribute_' . $value;
             $fields[$newfieldname] = array('type' => 'string');
             $attname = Yii::app()->db->createCommand()->select('{{participant_attribute_names_lang}}.attribute_name, {{participant_attribute_names_lang}}.lang')->from('{{participant_attribute_names}}')->join('{{participant_attribute_names_lang}}', '{{participant_attribute_names}}.attribute_id = {{participant_attribute_names_lang}}.attribute_id')->where('{{participant_attribute_names}}.attribute_id = :attrid ')->bindParam(":attrid", $value, PDO::PARAM_INT);
             $attributename = $attname->queryAll();
             foreach ($attributename as $att) {
                 $languages[$att['lang']] = $att['attribute_name'];
             }
             //Check first for the default survey language
             if (isset($languages[$defaultsurveylang])) {
                 $newname = $languages[$defaultsurveylang];
             } elseif (isset($language[Yii::app()->session['adminlang']])) {
                 $newname = $languages[Yii::app()->session['adminlang']];
             } else {
                 $newname = $attributename[0]['attribute_name'];
                 //Choose the first item in the list
             }
             $tokenattributefieldnames[] = $newfieldname;
             $fieldcontents[$newfieldname] = array("description" => $newname, "mandatory" => "N", "show_register" => "N");
             array_push($attributeidadded, 'attribute_' . $value);
             array_push($attributesadded, $value);
         }
         //Update the attributedescriptions in the survey table to include the newly created attributes
         $previousatt = Yii::app()->db->createCommand()->select('attributedescriptions')->where("sid = :sid")->from('{{surveys}}')->bindParam(":sid", $surveyid, PDO::PARAM_INT);
         $aTokenAttributes = $previousatt->queryRow();
         $aTokenAttributes = decodeTokenAttributes($aTokenAttributes['attributedescriptions']);
         foreach ($fieldcontents as $key => $iIDAttributeCPDB) {
             $aTokenAttributes[$key] = $iIDAttributeCPDB;
         }
         $aTokenAttributes = serialize($aTokenAttributes);
         Yii::app()->db->createCommand()->update('{{surveys}}', array("attributedescriptions" => $aTokenAttributes), 'sid = ' . intval($surveyid));
         // load description in the surveys table
         //Actually create the fields in the tokens table
         Yii::app()->loadHelper('update/updatedb');
         foreach ($fields as $key => $value) {
             addColumn("{{tokens_{$surveyid}}}", $key, $value['type']);
         }
         Yii::app()->db->schema->getTable("{{tokens_{$surveyid}}}", true);
         // Refresh schema cache just
     }
     //Write each participant to the survey token table
     foreach ($participantid as $key => $sParticipantUID) {
         $writearray = array();
         $participantdata = Yii::app()->db->createCommand()->select('firstname,lastname,email,language,blacklisted')->where('participant_id = :pid')->from('{{participants}}')->bindParam(":pid", $sParticipantUID, PDO::PARAM_INT);
         $tobeinserted = $participantdata->queryRow();
         if (Yii::app()->getConfig('blockaddingtosurveys') == 'Y' && $tobeinserted == 'Y') {
             $iBlacklistSkipped++;
             continue;
         }
         /* Search for matching participant name/email in the survey token table */
         $sQuery = Yii::app()->db->createCommand()->select('*')->from('{{tokens_' . $surveyid . '}}')->where('firstname = :firstname AND lastname = :lastname AND email = :email AND participant_id = :participant_id')->bindParam(":firstname", $tobeinserted['firstname'], PDO::PARAM_STR)->bindParam(":lastname", $tobeinserted['lastname'], PDO::PARAM_STR)->bindParam(":email", $tobeinserted['email'], PDO::PARAM_STR)->bindParam(":participant_id", $sParticipantUID, PDO::PARAM_STR)->queryAll();
         if (count($sQuery) > 0) {
             //Participant already exists in token table - don't copy
             $duplicate++;
             // Here is where we can put code for overwriting the attribute data if so required
             if ($overwriteauto == "true") {
                 //If there are new attributes created, add those values to the token entry for this participant
                 if (!empty($newcreate)) {
                     $numberofattributes = count($attributesadded);
                     for ($a = 0; $a < $numberofattributes; $a++) {
                         Participant::model()->updateTokenAttributeValue($surveyid, $sParticipantUID, $attributesadded[$a], $attributeidadded[$a]);
                     }
                 }
                 //If there are automapped attributes, add those values to the token entry for this participant
                 if (!empty($mapped)) {
                     foreach ($mapped as $key => $value) {
                         if ($key[10] == 'c') {
                             //We know it's automapped because the 11th letter is 'c'
                             Participant::model()->updateTokenAttributeValue($surveyid, $sParticipantUID, $value, $key);
                         }
                     }
                 }
             }
             if ($overwriteman == "true") {
                 //If there are any manually mapped attributes, add those values to the token entry for this participant
                 if (!empty($mapped)) {
                     foreach ($mapped as $key => $value) {
                         if ($key[10] != 'c' && $key[9] == '_') {
                             //It's not an auto field because it's 11th character isn't 'c'
                             Participant::model()->updateTokenAttributeValue($surveyid, $sParticipantUID, $value, $key);
                         }
                     }
                 }
             }
             if ($overwritest == "true") {
                 if (!empty($mapped)) {
                     foreach ($mapped as $key => $value) {
                         if (strlen($key) > 8 && $key[10] != 'c' && $key[9] != '_' || strlen($key) < 9) {
                             Participant::model()->updateTokenAttributeValue($surveyid, $sParticipantUID, $value, $key);
                         }
                     }
                 }
             }
         } else {
             //Create a new token entry for this participant
             $writearray = array('participant_id' => $sParticipantUID, 'firstname' => $tobeinserted['firstname'], 'lastname' => $tobeinserted['lastname'], 'email' => $tobeinserted['email'], 'emailstatus' => 'OK', 'language' => $tobeinserted['language']);
             Yii::app()->db->createCommand()->insert('{{tokens_' . $surveyid . '}}', $writearray);
             $insertedtokenid = getLastInsertID('{{tokens_' . $surveyid . '}}');
             $time = time();
             //Create a survey link for the new token entry
             $data = array('participant_id' => $sParticipantUID, 'token_id' => $insertedtokenid, 'survey_id' => $surveyid, 'date_created' => date('Y-m-d H:i:s', $time));
             Yii::app()->db->createCommand()->insert('{{survey_links}}', $data);
             //If there are new attributes created, add those values to the token entry for this participant
             if (!empty($newcreate)) {
                 $numberofattributes = count($attributesadded);
                 for ($a = 0; $a < $numberofattributes; $a++) {
                     try {
                         Participant::model()->updateTokenAttributeValue($surveyid, $sParticipantUID, $attributesadded[$a], $attributeidadded[$a]);
                     } catch (Exception $e) {
                         throw new Exception(gT("Could not update token attribute value"));
                     }
                 }
             }
             //If there are any automatically mapped attributes, add those values to the token entry for this participant
             if (!empty($mapped)) {
                 foreach ($mapped as $key => $value) {
                     try {
                         Participant::model()->updateTokenAttributeValue($surveyid, $sParticipantUID, $value, $key);
                     } catch (Exception $e) {
                         throw new Exception(gT("Could not update token attribute value"));
                     }
                 }
             }
             $sucessfull++;
         }
     }
     $returndata = array('success' => $sucessfull, 'duplicate' => $duplicate, 'blacklistskipped' => $iBlacklistSkipped, 'overwriteauto' => $overwriteauto, 'overwriteman' => $overwriteman);
     return $returndata;
 }
Esempio n. 4
0
 /**
  * Create new "fields"? in which table?
  *
  * @param int $surveyId
  * @param array $newAttributes
  * @return array [addedAttributes, addedAttributeIds]
  */
 private function createColumnsInTokenTable($surveyId, array $newAttributes)
 {
     // Get default language
     $surveyInfo = getSurveyInfo($surveyId);
     $defaultsurveylang = $surveyInfo['surveyls_language'];
     //Will contain serialised info for the surveys.attributedescriptions field
     $fieldcontents = array();
     // ??
     $fields = array();
     //Will contain the actual field name of any new token attribute fields
     $addedAttributes = array();
     //Will contain the description of any new token attribute fields
     $addedAttributeIds = array();
     foreach ($newAttributes as $value) {
         $newfieldname = 'attribute_' . $value;
         $fields[$newfieldname] = array('type' => 'string');
         // TODO: Always string??
         $attname = Yii::app()->db->createCommand()->select('{{participant_attribute_names_lang}}.attribute_name, {{participant_attribute_names_lang}}.lang')->from('{{participant_attribute_names}}')->join('{{participant_attribute_names_lang}}', '{{participant_attribute_names}}.attribute_id = {{participant_attribute_names_lang}}.attribute_id')->where('{{participant_attribute_names}}.attribute_id = :attrid ')->bindParam(":attrid", $value, PDO::PARAM_INT);
         $attributename = $attname->queryAll();
         foreach ($attributename as $att) {
             $languages[$att['lang']] = $att['attribute_name'];
         }
         //Check first for the default survey language
         if (isset($languages[$defaultsurveylang])) {
             $newname = $languages[$defaultsurveylang];
         } elseif (isset($language[Yii::app()->session['adminlang']])) {
             $newname = $languages[Yii::app()->session['adminlang']];
         } else {
             $newname = $attributename[0]['attribute_name'];
             //Choose the first item in the list
         }
         $tokenAttributeFieldNames[] = $newfieldname;
         $fieldcontents[$newfieldname] = array("description" => $newname, "mandatory" => "N", "show_register" => "N");
         array_push($addedAttributeIds, 'attribute_' . $value);
         array_push($addedAttributes, $value);
     }
     //Update the attributedescriptions in the survey table to include the newly created attributes
     $previousatt = Yii::app()->db->createCommand()->select('attributedescriptions')->where("sid = :sid")->from('{{surveys}}')->bindParam(":sid", $surveyId, PDO::PARAM_INT);
     $aTokenAttributes = $previousatt->queryRow();
     $aTokenAttributes = decodeTokenAttributes($aTokenAttributes['attributedescriptions']);
     foreach ($fieldcontents as $key => $iIDAttributeCPDB) {
         $aTokenAttributes[$key] = $iIDAttributeCPDB;
     }
     $aTokenAttributes = serialize($aTokenAttributes);
     Yii::app()->db->createCommand()->update('{{surveys}}', array("attributedescriptions" => $aTokenAttributes), 'sid = ' . intval($surveyId));
     // load description in the surveys table
     //Actually create the fields in the tokens table
     Yii::app()->loadHelper('update/updatedb');
     foreach ($fields as $key => $value) {
         addColumn("{{tokens_{$surveyId}}}", $key, $value['type']);
     }
     Yii::app()->db->schema->getTable("{{tokens_{$surveyId}}}", true);
     // Refresh schema cache just
     return array($addedAttributes, $addedAttributeIds);
 }
Esempio n. 5
0
 /**
  * Checks to make sure that all required columns exist in this tokens table
  * (some older tokens tables dont' get udated properly)
  *
  */
 public function checkColumns()
 {
     $sid = self::$sid;
     $surveytable = '{{tokens_' . $sid . '}}';
     $columncheck = array("tid", "participant_id", "firstname", "lastname", "email", "emailstatus", "token", "language", "blacklisted", "sent", "remindersent", "completed", "usesleft", "validfrom", "validuntil");
     $columns = Yii::app()->db->schema->getTable($surveytable)->getColumnNames();
     $missingcolumns = array_diff($columncheck, $columns);
     if (count($missingcolumns) > 0) {
         Yii::app()->loadHelper('update/updatedb');
         //Load the admin helper to allow column creation
         setVarchar();
         //Set the appropriate varchar settings according to the database
         $sVarchar = Yii::app()->getConfig('varchar');
         //Retrieve the db specific varchar setting
         $columninfo = array('validfrom' => 'datetime', 'validuntil' => 'datetime', 'blacklisted' => $sVarchar . '(17) NOT NULL', 'participant_id' => $sVarchar . '(50) NOT NULL', 'remindercount' => "integer DEFAULT '0'", 'usesleft' => 'integer NOT NULL default 1');
         //Not sure if any other fields would ever turn up here - please add if you can think of any others
         foreach ($missingcolumns as $columnname) {
             addColumn($surveytable, $columnname, $columninfo[$columnname]);
         }
     }
 }
Esempio n. 6
0
 addColumn("users", 'level', "ENUM('free', 'user', 'admin' )", "default 'free'");
 addColumn("users", 'email', "varchar(65)", "default NULL");
 // Add the options table columns
 addColumn("options", '`type`', "ENUM('input', 'date', 'checkbox', 'hidden', 'textarea')", "default 'input'");
 addColumn("options", '`group`', "varchar(65)", "default 'Miscellaneous'");
 // This table will be where the settings are kept
 createTable("options_groups", "`group` varchar(65) NOT NULL", True, False);
 addColumn("options_groups", '`desc`', "varchar(65)", "default NULL");
 // This table will be where the settings are kept
 createTable("settings", "setting varchar(65) NOT NULL", True, False);
 addColumn("settings", '`desc`', "varchar(65)", "default NULL");
 addColumn("settings", 'type', "ENUM('input', 'date', 'checkbox', 'hidden', 'textarea')", "default 'input'");
 // This is where we will add the clien'ts ability to add values to the settings.
 createTable("repositry", "user_id int(11) NOT NULL", false, false);
 addColumn("repositry", '`key`', "varchar(65)", "default NULL");
 addColumn("repositry", 'value', "varchar(65)", "default NULL");
 // Create the default system user
 // Username: demo
 // Password: demo
 Auth::createNewUser('admin', 'password', '*****@*****.**');
 // Add a user, when the username does not exist
 Auth::changeGroup('admin', 'admin');
 // Promote the user to administrator by running the following snippet*/
 $getId = Auth::userId('admin');
 Activation::generate($getId, 20);
 Activation::activate($getId);
 // Set the timestamp and filesize
 Options::add('installModified', $lastEdit, 'input');
 // Do not modify these, they need to be static
 Options::add('installFilesize', $fileSize, 'input');
 // Do not modify these, they need to be static*/
Esempio n. 7
0
		if(!$result){
			$addcolRes['dbset']=$db->lastErrorMsg();
		}
		else{
			$addcolRes['dbset']=$db->changes().' Record updated successfully.';
		}
		
		$db->close();
		return $addcolRes;
	}
}
$addcolRes = addColumn($settingRes,'tasubgroupopt','for_all_group');
$addcolRes = addColumn($settingRes,'tasubgroup','1');
$addcolRes = addColumn($settingRes,'critsPlugin','0');
$addcolRes = addColumn($settingRes,'critsPage','https://192.168.1.131/api/v1/');
$addcolRes = addColumn($settingRes,'critsLogin','username=<username>&api_key=<apikey>');


if(isset($_GET['update'])){
	$command[]="cd /var/www/";
	$command[]="mkdir /var/www/tmpupdatebackup";
	$command[]="cd /var/www/tmpupdatebackup/";
	#Backup DB's
	$command[]="cp /var/www/admin/admin.db /var/www/tmpupdatebackup";
	$command[]="cp /var/www/urls/urls.db /var/www/tmpupdatebackup";
	$command[]="cp /var/www/autopb/autopb.db /var/www/tmpupdatebackup";
	$command[]="cp /var/www/malwr/malwr.db /var/www/tmpupdatebackup";
	$command[]="cp /var/www/mastiff/mastiff.db /var/www/tmpupdatebackup";
	$command[]="cp /var/www/twitter/twitter.db /var/www/tmpupdatebackup";
	$command[]="cp /var/www/ticketgen.php /var/www/tmpupdatebackup";
	#Get new WIPSTER files
Esempio n. 8
0
 /**
  * Checks to make sure that all required columns exist in this tokens table
  * (some older tokens tables dont' get udated properly)
  *
  * This method should be moved to db update for 2.05 version so it runs only 
  * once per token table / backup token table
  */
 public function checkColumns()
 {
     $sid = self::$sid;
     $sTableName = '{{tokens_' . $sid . '}}';
     $columncheck = array("tid", "participant_id", "firstname", "lastname", "email", "emailstatus", "token", "language", "blacklisted", "sent", "remindersent", "completed", "usesleft", "validfrom", "validuntil");
     $tableSchema = Yii::app()->db->schema->getTable($sTableName);
     $columns = $tableSchema->getColumnNames();
     $missingcolumns = array_diff($columncheck, $columns);
     if (count($missingcolumns) > 0) {
         Yii::app()->loadHelper('update/updatedb');
         //Load the admin helper to allow column creation
         setVarchar();
         //Set the appropriate varchar settings according to the database
         $sVarchar = Yii::app()->getConfig('varchar');
         //Retrieve the db specific varchar setting
         $columninfo = array('validfrom' => 'datetime', 'validuntil' => 'datetime', 'blacklisted' => $sVarchar . '(17)', 'participant_id' => $sVarchar . '(50)', 'remindercount' => "integer DEFAULT '0'", 'usesleft' => 'integer NOT NULL default 1');
         //Not sure if any other fields would ever turn up here - please add if you can think of any others
         foreach ($missingcolumns as $columnname) {
             addColumn($sTableName, $columnname, $columninfo[$columnname]);
         }
         Yii::app()->db->schema->getTable($sTableName, true);
         // Refresh schema cache just in case the table existed in the past
     } else {
         // On some installs we have created not null for participant_id and blacklisted fix this
         $columns = array('blacklisted', 'participant_id');
         foreach ($columns as $columnname) {
             $definition = $tableSchema->getColumn($columnname);
             if ($definition->allowNull != true) {
                 Yii::app()->loadHelper('update/updatedb');
                 //Load the admin helper to allow column creation
                 setVarchar();
                 //Set the appropriate varchar settings according to the database
                 $sVarchar = Yii::app()->getConfig('varchar');
                 //Retrieve the db specific varchar setting
                 Yii::app()->db->createCommand()->alterColumn($sTableName, $columnname, sprintf('%s(%s)', Yii::app()->getConfig('varchar'), $definition->size));
                 Yii::app()->db->schema->getTable($sTableName, true);
                 // Refresh schema cache just in case the table existed in the past
             }
         }
     }
 }
Esempio n. 9
0
$countDisplayedColumns = 0;
foreach ($prefs as $property => $propertyValue) {
    if ($property != 'id_user' && $property != '_id') {
        if ($propertyValue) {
            $visibility = "table_cell";
            $countDisplayedColumns++;
        } else {
            $visibility = 'display:none';
        }
        if ($property == 'notes') {
            $columns[] = addColumn($property, $model->getAttributeLabel($property), '$data->getShortNotes()', $visibility);
        } elseif ($property == 'biobank_id') {
            $columns[] = addColumn('biobank_id', $model->getAttributeLabel('biobank_id'), '$data->getBiobankName()', $visibility);
        } elseif ($property == 'collection_name') {
            $columns[] = addColumn('collection_name', Biobank::model()->getAttributeLabel('collection_name'), '$data->biobank->collection_name', $visibility);
        } elseif ($property == 'collection_id') {
            $columns[] = addColumn('collection_id', Biobank::model()->getAttributeLabel('collection_id'), '$data->biobank->collection_id', $visibility);
        } elseif ($property == 'collect_date') {
            $columns[] = addColumn('collect_date', $model->getAttributeLabel('collect_date'), '$data->collect_date', $visibility);
            //TODO normaliser les dates de collecte avant d activer cette feature
            // $columns [] = getArrayColumn('collect_date', $model->getAttributeLabel('collect_date'), 'CommonTools::toShortDateFR($data->collect_date)', $visibility);
        } elseif ($property == 'storage_conditions') {
            $columns[] = addColumn('storage_conditions', $model->getAttributeLabel('storage_conditions'), '$data->getLiteralStorageCondition()', $visibility);
        } else {
            $columns[] = addColumn($property, $model->getAttributeLabel($property), '$data->' . $property, $visibility);
        }
    }
}
//popup de choix des colonnes à afficher
$columns[] = array('class' => 'CButtonColumn', 'header' => CHtml::link($imageSelect, '#', array('onclick' => '$("#selectPopup").dialog("open");return false;')), 'template' => '{view}', 'buttons' => array('view' => array('url' => 'Yii::app()->createUrl("site/view",array("id"=>"$data->_id", "asDialog"=>1))', 'click' => 'function(){window.open(this.href,"_blank","left=100,top=100,width=760,height=650,toolbar=0,resizable=1, location=no");return false;}')));
$this->widget('zii.widgets.grid.CGridView', array('id' => 'sample-grid', 'dataProvider' => $model->searchWithNotes(), 'columns' => $columns));
Esempio n. 10
0
function upgradeTokenTables126()
{
    global $modifyoutput;
    $sVarchar = Yii::app()->getConfig('varchar');
    $surveyidresult = dbGetTablesLike("tokens%");
    if (!$surveyidresult) {
        return "Database Error";
    } else {
        foreach ($surveyidresult as $sv) {
            Yii::app()->db->createCommand()->alterColumn(reset($sv), 'token', "{$sVarchar}(15)");
            addColumn(reset($sv), 'emailstatus', "{$sVarchar}(300) NOT NULL DEFAULT 'OK'");
        }
    }
}
function update_db($newinstall)
{
    $database =& JFactory::getDBO();
    $error = false;
    // we create the new columns for 2.7
    $error = addColumn($database, 'preview_textfile_extensions', '', $error);
    $error = addColumn($database, 'edit_textfile_extensions', '', $error);
    $error = addColumn($database, 'js_create_folder', '', $error);
    $error = addColumn($database, 'js_rename_folder', '', $error);
    $error = addColumn($database, 'js_delete_folder', '', $error);
    $error = addColumn($database, 'js_copymove', '', $error);
    // new 2.8
    $error = addColumn($database, 'language_dropdown', 'de,en,es,br,cn,ct,da,fr,it,jp,nl,no,pl,pt,se,sk,tw', $error);
    $error = addColumn($database, 'use_image_magic', 'false', $error);
    $error = addColumn($database, 'image_magic_path', 'convert', $error);
    $error = addColumn($database, 'exclude_directories', 'data.pxp,_vti_cnf,.svn,CVS,thumbs', $error);
    $error = addColumn($database, 'normalise_file_names', 'false', $error);
    $error = addColumn($database, 'download_multiple_files_as_zip', 'false', $error);
    $error = addColumn($database, 'allowed_view_file_extensions', 'all', $error);
    $error = addColumn($database, 'forbidden_view_file_extensions', '', $error);
    $error = addColumn($database, 'description_mode', 'false', $error);
    $error = addColumn($database, 'description_mode_show_default', 'true', $error);
    $error = addColumn($database, 'description_mode_store', 'email', $error);
    $error = addColumn($database, 'master_profile', 'false', $error);
    $error = addColumn($database, 'master_profile_mode', 'login', $error);
    $error = addColumn($database, 'master_profile_lowercase', 'true', $error);
    // new 2.8.3
    $error = addColumn($database, 'normalise_directory_names', 'false', $error);
    $error = addColumn($database, 'direct_download', 'false', $error);
    $error = addColumn($database, 'fix_utf8', '', $error);
    // new 2.9
    if (!testEntry('use_js_include')) {
        $database->setQuery("INSERT INTO #__joomla_flash_uploader_conf (key_id, value) values ('use_js_include','true')");
        if (!$database->query()) {
            $error = true;
            echo $database->getErrorMsg() . '<br />';
        }
    }
    if (!testEntry('backend_access_upload')) {
        $database->setQuery("INSERT INTO #__joomla_flash_uploader_conf (key_id, value) values ('backend_access_upload','Manager')");
        if (!$database->query()) {
            $error = true;
            echo $database->getErrorMsg() . '<br />';
        }
    }
    if (!testEntry('backend_access_config')) {
        $database->setQuery("INSERT INTO #__joomla_flash_uploader_conf (key_id, value) values ('backend_access_config','Manager')");
        if (!$database->query()) {
            $error = true;
            echo $database->getErrorMsg() . '<br />';
        }
    }
    if (!testEntry('file_chmod')) {
        $database->setQuery("INSERT INTO #__joomla_flash_uploader_conf (key_id, value) values ('file_chmod','')");
        if (!$database->query()) {
            $error = true;
            echo $database->getErrorMsg() . '<br />';
        }
    }
    $error = addColumn($database, 'overwrite_files', 'true', $error);
    $error = addColumn($database, 'description_mode_mandatory', 'false', $error);
    $error = addColumn($database, 'show_full_url_for_selected_file', 'false', $error);
    $error = addColumn($database, 'normalize_spaces', 'false', $error);
    if (!testEntry('dir_chmod')) {
        $database->setQuery("INSERT INTO #__joomla_flash_uploader_conf (key_id, value) values ('dir_chmod','')");
        if (!$database->query()) {
            $error = true;
            echo $database->getErrorMsg() . '<br />';
        }
    }
    if ($error) {
        echo "<p class='error'>";
        echo JText::_('I_UPDATE_ERROR');
        return true;
        echo "</p>";
    } else {
        if (!$newinstall) {
            echo JText::_('I_UPDATE_OK');
        }
        return false;
    }
}
Esempio n. 12
0
 createTable("users", "id int(11) NOT NULL", True, True);
 addColumn("users", 'nid', "varchar(32)", "default NULL");
 addColumn("users", 'username', "varchar(65)", "default NULL");
 addColumn("users", 'password', "varchar(65)", "default NULL");
 addColumn("users", 'level', "ENUM('free', 'user', 'admin', 'moderator')", "default 'user'");
 addColumn("users", 'email', "varchar(65)", "default NULL");
 // Add the options table columns
 addColumn("options", '`type`', "ENUM('input', 'date', 'bool', 'hidden', 'textarea')", "default 'input'");
 addColumn("options", '`group`', "varchar(65)", "default 'Miscellaneous'");
 // This table will be where the settings are kept
 createTable("options_groups", "`group` varchar(65) NOT NULL", True, False);
 addColumn("options_groups", '`desc`', "varchar(65)", "default NULL");
 // This is where we will add the clien'ts ability to add values to the settings.
 createTable("options_users", "user_id int(11) NOT NULL", false, false);
 addColumn("options_users", '`key`', "varchar(65)", "default NULL");
 addColumn("options_users", 'value', "varchar(65)", "default NULL");
 $defaultUser = '******';
 $defaultPass = '******';
 $adminEmail = '*****@*****.**';
 // Create the default system user
 Auth::createNewUser($defaultUser, $defaultPass, $adminEmail);
 // Add a user, when the username does not exist
 Auth::changeGroup($defaultUser, 'admin');
 // Promote the user to administrator by running the following snippet*/
 $getId = Auth::userId($defaultUser);
 Activation::generate($getId, 20);
 Activation::activate($getId);
 // Set the timestamp and filesize
 Options::add('installModified', $lastEdit, 'hidden', 'Miscellaneous');
 // Do not modify these, they need to be static
 Options::add('installFilesize', $fileSize, 'hidden', 'Miscellaneous');
Esempio n. 13
0
 function addColumn($table, $column_name, $column_info = '', $after = '')
 {
     if (addColumn($table, $column_name, $column_info, $after)) {
         $this->updated = true;
     }
 }
Esempio n. 14
0
            $visibility = "table_cell";
        } else {
            $visibility = 'display:none';
        }
        if ($property == 'notes') {
            $columns[] = array('class' => 'DataColumn', 'name' => $property, 'id' => 'col_' . $property, 'header' => Sample::model()->getAttributeLabel($property), 'value' => '$data->getShortNotes()', 'htmlOptions' => array('class' => "col_{$property}", 'style' => $visibility), 'headerHtmlOptions' => array('class' => "col_{$property}", 'style' => $visibility));
        } elseif ($property == 'biobank_id') {
            $columns[] = array('class' => 'DataColumn', 'name' => Yii::t('sample', 'biobank_id'), 'id' => 'col_' . $property, 'header' => Sample::model()->getAttributeLabel($property), 'value' => 'Biobank::model()->findByPk(new MongoId($data->biobank_id))->name', 'htmlOptions' => array('class' => "col_{$property}", 'style' => $visibility), 'headerHtmlOptions' => array('class' => "col_{$property}", 'style' => $visibility));
        } elseif ($property == 'collect_date') {
            $columns[] = array('class' => 'DataColumn', 'name' => $property, 'id' => 'col_' . $property, 'header' => Sample::model()->getAttributeLabel($property), 'value' => 'CommonTools::toShortDateFR($data->collect_date)', 'htmlOptions' => array('class' => "col_{$property}", 'style' => $visibility), 'headerHtmlOptions' => array('class' => "col_{$property}", 'style' => $visibility));
        } elseif ($property == 'storage_conditions') {
            $columns[] = array('class' => 'DataColumn', 'name' => $property, 'id' => 'col_' . $property, 'header' => Sample::model()->getAttributeLabel($property), 'value' => '$data->getLiteralStorageCondition()', 'htmlOptions' => array('class' => "col_{$property}", 'style' => $visibility), 'headerHtmlOptions' => array('class' => "col_{$property}", 'style' => $visibility));
        } elseif ($property == 'collection_name') {
            $columns[] = addColumn('collection_name', Biobank::model()->getAttributeLabel('collection_name'), '$data->biobank->collection_name', $visibility);
        } elseif ($property == 'collection_id') {
            $columns[] = addColumn('collection_id', Biobank::model()->getAttributeLabel('collection_id'), '$data->biobank->collection_id', $visibility);
        } else {
            $columns[] = array('class' => 'DataColumn', 'name' => $property, 'id' => 'col_' . $property, 'value' => '$data->' . $property, 'header' => Sample::model()->getAttributeLabel($property), 'htmlOptions' => array('class' => "col_{$property}", 'style' => $visibility), 'headerHtmlOptions' => array('class' => "col_{$property}", 'style' => $visibility));
        }
    }
}
//
$columns[] = array('header' => Yii::t('demande', 'sampleDetail'), 'class' => 'CLinkColumn', 'labelExpression' => '$data->_id', 'urlExpression' => 'Yii::app()->createUrl("site/view",array("id"=>"$data->_id"))', 'linkHtmlOptions' => array('onclick' => 'window.open(this.href,"SampleDetail","left=100,top=100,width=760,height=650,toolbar=0,resizable=0, location=no");return false;'), 'htmlOptions' => array('style' => 'text-align:center'), 'imageUrl' => $imageSampleDetail);
?>

<h1><?php 
echo Yii::t('common', 'demande') . ' ' . $model->titre;
?>
</h1>

<?php 
Esempio n. 15
0
function XMLImportTokens($sFullFilePath, $iSurveyID, $sCreateMissingAttributeFields = true)
{
    Yii::app()->loadHelper('database');
    $clang = Yii::app()->lang;
    $sXMLdata = file_get_contents($sFullFilePath);
    $xml = simplexml_load_string($sXMLdata, 'SimpleXMLElement', LIBXML_NONET);
    $results['warnings'] = array();
    if ($xml->LimeSurveyDocType != 'Tokens') {
        $results['error'] = $clang->gT("This is not a valid token data XML file.");
        return $results;
    }
    if (!isset($xml->tokens->fields)) {
        $results['tokens'] = 0;
        return $results;
    }
    $results['tokens'] = 0;
    $results['tokenfieldscreated'] = 0;
    if ($sCreateMissingAttributeFields) {
        // Get a list with all fieldnames in the XML
        $aXLMFieldNames = array();
        foreach ($xml->tokens->fields->fieldname as $sFieldName) {
            $aXLMFieldNames[] = (string) $sFieldName;
        }
        // Get a list of all fieldnames in the token table
        $aTokenFieldNames = Yii::app()->db->getSchema()->getTable("{{tokens_{$iSurveyID}}}", true);
        $aTokenFieldNames = array_keys($aTokenFieldNames->columns);
        $aFieldsToCreate = array_diff($aXLMFieldNames, $aTokenFieldNames);
        Yii::app()->loadHelper('update/updatedb');
        foreach ($aFieldsToCreate as $sField) {
            if (strpos($sField, 'attribute') !== false) {
                addColumn('{{tokens_' . $iSurveyID . '}}', $sField, 'string');
            }
        }
    }
    switchMSSQLIdentityInsert('tokens_' . $iSurveyID, true);
    foreach ($xml->tokens->rows->row as $row) {
        $insertdata = array();
        foreach ($row as $key => $value) {
            $insertdata[(string) $key] = (string) $value;
        }
        $token = Token::create($iSurveyID);
        $token->setAttributes($insertdata, false);
        if (!$token->save()) {
            $results['warnings'][] = $clang->gT("Skipped tokens entry:") . ' ' . implode('. ', $token->errors['token']);
        }
        $results['tokens']++;
    }
    switchMSSQLIdentityInsert('tokens_' . $iSurveyID, false);
    if (Yii::app()->db->getDriverName() == 'pgsql') {
        try {
            Yii::app()->db->createCommand("SELECT pg_catalog.setval(pg_get_serial_sequence('{{tokens_" . $iSurveyID . "}}', 'tid'), (SELECT MAX(tid) FROM {{tokens_" . $iSurveyID . "}}))")->execute();
        } catch (Exception $oException) {
        }
    }
    return $results;
}
Esempio n. 16
0
$stimuli = multiLevelShuffle($cleanStimuli);
$stimuli = shuffle2dArray($stimuli, $_CONFIG->stop_at_login);
$_SESSION['Stimuli'] = $stimuli;
// load and block shuffle procedure for this condition
$cleanProcedure = GetFromFile($_FILES->proc_files . '/' . $_SESSION['Condition']['Procedure']);
$addColumns = array('Text');
foreach ($addColumns as $add) {
    foreach ($trialTypeColumns as $number => $colName) {
        // check all trial type levels we found
        if ($number == 0) {
            $prefix = '';
        } else {
            $prefix = 'Post' . ' ' . $number . ' ';
        }
        $column = $prefix . $add;
        addColumn($cleanProcedure, $column);
        // this will only add columns if they don't already exist; nothing is overwritten
    }
}
$procedure = multiLevelShuffle($cleanProcedure);
$procedure = shuffle2dArray($procedure, $_CONFIG->stop_at_login);
$_SESSION['Procedure'] = $procedure;
// Load entire experiment into $Trials[1-X] where X is the number of trials
$Trials = array(0 => 0);
$procedureLength = count($procedure);
for ($count = 2; $count < $procedureLength; $count++) {
    // $Trials[$count-1] = makeTrial($procedure[$count]['Item']);
    $items = rangeToArray($procedure[$count]['Item']);
    $stim = array();
    foreach ($items as $item) {
        if (isset($stimuli[$item]) and is_array($stimuli[$item])) {
Esempio n. 17
0
function XMLImportTokens($sFullFilepath, $iSurveyID, $sCreateMissingAttributeFields = true)
{
    Yii::app()->loadHelper('database');
    $clang = Yii::app()->lang;
    $xml = simplexml_load_file($sFullFilepath);
    if ($xml->LimeSurveyDocType != 'Tokens') {
        $results['error'] = $clang->gT("This is not a valid token data XML file.");
        return $results;
    }
    $results['tokens'] = 0;
    $results['tokenfieldscreated'] = 0;
    $aLanguagesSupported = array();
    foreach ($xml->languages->language as $language) {
        $aLanguagesSupported[] = (string) $language;
    }
    $results['languages'] = count($aLanguagesSupported);
    if ($sCreateMissingAttributeFields) {
        // Get a list with all fieldnames in the XML
        $aXLMFieldNames = array();
        foreach ($xml->tokens->fields->fieldname as $sFieldName) {
            $aXLMFieldNames[] = (string) $sFieldName;
        }
        // Get a list of all fieldnames in the token table
        $aTokenFieldNames = Yii::app()->db->getSchema()->getTable("{{tokens_{$iSurveyID}}}", true);
        $aTokenFieldNames = array_keys($aTokenFieldNames->columns);
        $aFieldsToCreate = array_diff($aXLMFieldNames, $aTokenFieldNames);
        Yii::app()->loadHelper('update/updatedb');
        foreach ($aFieldsToCreate as $sField) {
            if (strpos($sField, 'attribute') !== false) {
                addColumn('{{tokens_' . $iSurveyID . '}}', $sField, 'string');
            }
        }
    }
    switchMSSQLIdentityInsert('tokens_' . $iSurveyID, true);
    foreach ($xml->tokens->rows->row as $row) {
        $insertdata = array();
        foreach ($row as $key => $value) {
            $insertdata[(string) $key] = (string) $value;
        }
        $result = Tokens_dynamic::model($iSurveyID)->insertToken($iSurveyID, $insertdata) or safeDie($clang->gT("Error") . ": Failed to insert data<br />");
        $results['tokens']++;
    }
    switchMSSQLIdentityInsert('tokens_' . $iSurveyID, false);
    return $results;
}
Esempio n. 18
0
function migrate($options)
{
    if (!isset($options['action'])) {
        die("Usage: php zombie.php migrate action=<action>\n" . "Actions:\n" . "\tadd-column\n" . "\tadd-table\n" . "\tapply\n" . "\tnew\n" . "\trun\n");
    }
    if ($options['action'] == "apply") {
        applyMigration($options['name']);
    } else {
        if ($options['action'] == "run") {
            runMigrations();
        } else {
            if ($options['action'] == "new") {
                if (!isset($options['name'])) {
                    die("Usage: php zombie.php migrate action=new name=<name>\n");
                }
                newMigration($options['name']);
            } else {
                if ($options['action'] == "add-table") {
                    if (!isset($options['name']) || !isset($options['table'])) {
                        die("Usage: php zombie.php migrate action=add-table name=<name> table=<table>\n");
                    }
                    addTable($options['name'], $options['table']);
                } else {
                    if ($options['action'] == "add-column") {
                        if (!isset($options['name']) || !isset($options['table']) || !isset($options['column']) || !isset($options['type'])) {
                            die("Usage: php zombie.php migrate action=add-column name=<name> " . "table=<table> column=<column> type=<type> [extra=<extra>]\n");
                        }
                        if (!isset($options['extra'])) {
                            $options['extra'] = '';
                        }
                        addColumn($options['name'], $options['table'], $options['column'], $options['type'], $options['extra']);
                    } else {
                        die("Error: Unkown action '" . $options['action'] . "'.\n");
                    }
                }
            }
        }
    }
}