Пример #1
0
<?php

// Get arguments
$objParameters = new QCliParameterProcessor('populate', 'Populate Email List Script');
$objParameters->AddDefaultParameter('file', QCliParameterType::String, 'The csv file that contains the email addresses to import to the email list');
$objParameters->AddDefaultParameter('token', QCliParameterType::String, 'The token identifying the list to import the email addresses to');
$objParameters->Run();
$txtSrcFile = $objParameters->GetDefaultValue('file');
$groupList = $objParameters->GetDefaultValue('token');
// read file
if (is_file($txtSrcFile)) {
    $lineArray = file($txtSrcFile, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
    $isFirst = true;
    foreach ($lineArray as $line) {
        if ($isFirst) {
            $isFirst = false;
        } else {
            $strTokens = explode(',', trim($line));
            $firstName = $strTokens[0];
            $lastName = $strTokens[1];
            $email = $strTokens[2];
            $objCommunicationListEntry = CommunicationListEntry::LoadByEmail($email);
            if (!$objCommunicationListEntry) {
                // If not found then create new entry and add to the communications list
                $objCommunicationListEntry = new CommunicationListEntry();
                $objCommunicationListEntry->Email = $email;
                $objCommunicationListEntry->FirstName = $firstName;
                $objCommunicationListEntry->LastName = $lastName;
                $objCommunicationListEntry->Save();
            }
            $objList = CommunicationList::LoadByToken($groupList);
Пример #2
0
<?php

/**
 * Codegen Qcodo CLI file
 * Part of the Qcodo Development Framework
 * Copyright (c) 2005-2011, Quasidea Development, LLC
 */
// Setup the Parameters for qpm-download
$objParameters = new QCliParameterProcessor('qpm-download', 'Qcodo Package Manager (QPM) Download and Install Tool v' . QCODO_VERSION);
// Package Name is always required
$objParameters->AddDefaultParameter('username/package_name', QCliParameterType::String, 'the username/package name pair of the QPM package you are wanting to download and install');
// Optional Parameters include Username, Password, "Live" mode, and "Force" upload
$objParameters->AddFlagParameter('l', 'live', 'actually perform the live download and install; by default, calling qpm-download will only *report* to you files that will be downloaded and installed; specify the "live" flag to actually perform the download and install');
$objParameters->AddFlagParameter('f', 'force', 'force the download, even if the version of Qcodo used by the QPM author is different than what is currently installed here');
$objParameters->Run();
// Pull the Parameter Values
$strPackageName = $objParameters->GetDefaultValue('username/package_name');
$strUsername = null;
if (($intPosition = strpos($strPackageName, '/')) !== false) {
    $strUsername = substr($strPackageName, 0, $intPosition);
    $strPackageName = substr($strPackageName, $intPosition + 1);
}
$blnLive = $objParameters->GetValue('l');
$blnForce = $objParameters->GetValue('f');
try {
    $objQpm = new QPackageManagerDownload($strPackageName, $strUsername, $blnLive, $blnForce);
    $objQpm->PerformDownload();
} catch (Exception $objExc) {
    print 'error: ' . trim($objExc->getMessage()) . "\r\n";
    exit(1);
}
Пример #3
0
<?php

// Get arguments
$objParameters = new QCliParameterProcessor('bounceback', 'Checking for Bounceback emails');
$objParameters->AddDefaultParameter('file', QCliParameterType::String, 'The csv file that contains the email addresses that bounced');
$objParameters->Run();
$txtSrcFile = $objParameters->GetDefaultValue('file');
// read file
if (is_file($txtSrcFile)) {
    $lineArray = file($txtSrcFile, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
    $isFirst = true;
    foreach ($lineArray as $line) {
        $objEmailArray = Email::LoadArrayByAddress(trim($line));
        if ($objEmailArray) {
            printf("Found email: %s\n", trim($line));
            foreach ($objEmailArray as $objEmail) {
                $objPerson = Person::LoadByPrimaryEmailId($objEmail->Id);
                if ($objPerson) {
                    printf("Deleting email: %s from %s %s\n", trim($line), $objPerson->FirstName, $objPerson->LastName);
                    $objPerson->PrimaryEmail->Delete();
                    // If there's a secondary email associated with the user set it as primary
                    $objSecondaryEmailArray = Email::LoadArrayByPersonId($objPerson->Id);
                    if (count($objSecondaryEmailArray) >= 1) {
                        foreach ($objSecondaryEmailArray as $objSecondEmail) {
                            printf("    Found secondary email object...%s\n", $objSecondEmail->Address);
                            if ($objSecondEmail->Address != trim($line)) {
                                $objPerson->PrimaryEmail = $objSecondEmail;
                                $objPerson->PrimaryEmail->SetAsPrimary();
                                printf("    Set email: %s as the new primary email.\n", $objSecondEmail->Address);
                                break;
                            }
Пример #4
0
<?php

$objParameters = new QCliParameterProcessor('ldap', 'ALCF LDAP-to-ChMS Sync Script');
$objParameters->AddDefaultParameter('username', QCliParameterType::String, 'Domain\\Username of the LDAP user that is authorized to download credentials');
$objParameters->AddDefaultParameter('password', QCliParameterType::String, 'Password of the LDAP user that is authorized to download credentials');
$objParameters->Run();
$objLdap = new AlcfLdap(LDAP_PATH, $objParameters->GetDefaultValue('username'), $objParameters->GetDefaultValue('password'));
print "Pulling data from LDAP... ";
$objLdap->PullDataFromLdap();
print "Done.\r\n";
// Group Sync
print "Syncing Groups... ";
$objLdap->UpdateLocalGroups();
print "Done.\r\n";
// People Sync
print "Syncing People... ";
$objLdap->UpdateLocalPeople();
print "Done.\r\n";
// Disable "admin" account
$objLogin = Login::LoadByUsername('admin');
if ($objLogin) {
    $objLogin->LoginActiveFlag = false;
    $objLogin->Save();
}
// TODO: Delete Old Records (?)
// Disconnect
$objLdap->Unbind();
Пример #5
0
<?php

$objParameters = new QCliParameterProcessor('zipcode-locater', 'Zipcode locater Script');
$objParameters->AddDefaultParameter('zipcode', QCliParameterType::String, 'Zipcode to search for');
$objParameters->Run();
$zipcode = $objParameters->GetDefaultValue('zipcode');
$objPersonCursor = Person::QueryCursor(QQ::All());
QDataGen::DisplayForEachTaskStart('Checking for Persons in  zipcode', Person::CountAll());
print "\n";
while ($objPerson = Person::InstantiateCursor($objPersonCursor)) {
    QDataGen::DisplayForEachTaskNext('Checking for Persons in  zipcode');
    if ($objPerson->MembershipStatusTypeId == MembershipStatusType::Member) {
        $objAddressArray = $objPerson->GetAllAssociatedAddressArray();
        foreach ($objAddressArray as $objAddress) {
            if (strstr($objAddress->ZipCode, $zipcode) != false) {
                print $objPerson->FirstName . " " . $objPerson->LastName . ": " . $objAddress->Address1 . ", " . $objAddress->City . ", " . $objAddress->ZipCode . "\n";
            }
        }
    }
}
//$test = new Address();
//$test->City
QDataGen::DisplayForEachTaskEnd('Checking for Persons in  zipcode');
Пример #6
0
<?php

$objParameters = new QCliParameterProcessor('growth-group-import', 'ALCF Growth Group Importer Script');
$objParameters->AddDefaultParameter('server', QCliParameterType::String, 'Server/Host of the MySQL Database');
$objParameters->AddDefaultParameter('dbname', QCliParameterType::String, 'Database Name of the MySQL Database');
$objParameters->AddDefaultParameter('username', QCliParameterType::String, 'Username of the MySQL user');
$objParameters->Run();
$objMySqli = new mysqli($objParameters->GetDefaultValue('server'), $objParameters->GetDefaultValue('username'), null, $objParameters->GetDefaultValue('dbname'));
$objMinistry = Ministry::LoadByToken('growth');
if (!$objMinistry) {
    exit('No GG Ministry Found');
}
$objResult = $objMySqli->Query('SELECT * FROM growth_group_structure order by id;');
while ($objRow = $objResult->fetch_array()) {
    $objStructure = new GrowthGroupStructure();
    $objStructure->Name = $objRow['name'];
    $objStructure->Save();
}
$objResult = $objMySqli->Query('SELECT * FROM growth_group_location order by id;');
$objParentGroupArray = array();
while ($objRow = $objResult->fetch_array()) {
    $objGrowthGroupLocation = new GrowthGroupLocation();
    $objGrowthGroupLocation->Location = $objRow['location'];
    $objGrowthGroupLocation->Longitude = $objRow['longitude'];
    $objGrowthGroupLocation->Latitude = $objRow['latitude'];
    $objGrowthGroupLocation->Zoom = $objRow['zoom'];
    $objGrowthGroupLocation->Save();
    $strTokens = explode('(', $objGrowthGroupLocation->Location);
    $objParentGroup = Group::CreateGroupForMinistry($objMinistry, GroupType::GroupCategory, trim($strTokens[0]), 'Growth Groups in ' . $objGrowthGroupLocation->Location);
    $objGroupCategory = new GroupCategory();
    $objGroupCategory->Group = $objParentGroup;
Пример #7
0
<?php

$objParameters = new QCliParameterProcessor('get-data', 'ALCF Parent Pager sync script');
$objParameters->AddDefaultParameter('connection', QCliParameterType::String, 'Connection Name (per freetds.conf file) containing the Parent Pager DB server information');
$objParameters->AddDefaultParameter('username', QCliParameterType::String, 'Username of the MS SQL User that is authorized to access the Parent Pager DB');
$objParameters->AddDefaultParameter('password', QCliParameterType::String, 'Password of the MS SQL User that is authorized to access the Parent Pager DB');
$objParameters->AddDefaultParameter('dbname', QCliParameterType::String, 'Database Name within the MS SQL Server that is the Parent Pager DB');
$objParameters->Run();
// Get the Fields
$strConnectionName = $objParameters->GetDefaultValue('connection');
$strUsername = $objParameters->GetDefaultValue('username');
$strPassword = $objParameters->GetDefaultValue('password');
$strDbName = $objParameters->GetDefaultValue('dbname');
// Shared Functions
function GetRowCount($strTableName)
{
    global $objMsSql;
    $objRow = mssql_fetch_assoc(mssql_query('SELECT COUNT(*) AS row_count FROM ' . $strTableName . ';', $objMsSql));
    return $objRow['row_count'];
}
function GetPkResultForTableColumn($strTableName, $strPkColumnName)
{
    global $objMsSql;
    return mssql_query('SELECT ' . $strPkColumnName . ' FROM ' . $strTableName . ';', $objMsSql);
}
function GetRowForTableColumnRow($strTableName, $strPkColumnName, $objRow)
{
    global $objMsSql;
    return mssql_fetch_assoc(mssql_query(sprintf('SELECT * FROM %s WHERE %s=%s;', $strTableName, $strPkColumnName, $objRow[$strPkColumnName]), $objMsSql));
}
// Attempt to Connect
Пример #8
0
<?php

function EscapeCsv($strString)
{
    return '"' . str_replace('"', '""', $strString) . '"';
}
$objParameters = new QCliParameterProcessor('export-stewardship-roster', 'ALCF Export Stewardship Roster to CSV');
$objParameters->AddDefaultParameter('year', QCliParameterType::Integer, 'The year of giving data to use');
$objParameters->AddDefaultParameter('export_path', QCliParameterType::Path, 'The folder to export to');
$objParameters->Run();
$intYear = $objParameters->GetDefaultValue('year');
$strFolder = $objParameters->GetDefaultValue('export_path');
$fltMinimumAmount = 0;
$objFile = fopen($strFolder . '/contributors.csv', 'w');
fwrite($objFile, 'Salutation,MailingName,CompanyFacilityEtc,Address1,Address2,City,State,ZipCode' . "\r\n");
$objConditions = QQ::All();
//	$objConditions = QQ::AndCondition($objConditions,QQ::Equal(QQN::Household()->HeadPerson->CanMailFlag, true));
$objHouseholdCursor = Household::QueryCursor($objConditions, QQ::OrderBy(QQN::Household()->HeadPerson->LastName));
QDataGen::DisplayForEachTaskStart('Generating CSV Row(s) for Household', Household::CountAll());
while ($objHousehold = Household::InstantiateCursor($objHouseholdCursor)) {
    QDataGen::DisplayForEachTaskNext('Generating CSV Row(s) for Household');
    // Generate for the whole household
    if ($objHousehold->CombinedStewardshipFlag) {
        if ($objAddress = $objHousehold->GetStewardshipAddress()) {
            $intPersonIdArray = StewardshipContribution::GetPersonIdArrayForPersonOrHousehold($objHousehold);
            $objContributionAmountArray = StewardshipContribution::GetContributionAmountArrayForPersonArray($intPersonIdArray, $intYear);
            $fltAmount = StewardshipContribution::GetContributionAmountTotalForContributionAmountArray($objContributionAmountArray, false);
            if ($fltAmount > $fltMinimumAmount) {
                $objSpouse = $objHousehold->SpousePerson;
                if ($objSpouse) {
                    // Head person says do not mail, but spouse says mail
Пример #9
0
<?php

// Get arguments
$objParameters = new QCliParameterProcessor('email', 'Email to check against');
$objParameters->AddDefaultParameter('email', QCliParameterType::String, 'The email address to check for in group and email lists');
$objParameters->Run();
$txtEmail = $objParameters->GetDefaultValue('email');
$objEmailArray = Email::LoadArrayByAddress($txtEmail);
if (count($objEmailArray) > 0) {
    print "Found email objects\n";
    print "\n";
    $intPersonIdArray = array();
    foreach ($objEmailArray as $objEmail) {
        $objPerson = Person::LoadByPrimaryEmailId($objEmail->Id);
        if ($objPerson) {
            $intPersonIdArray[] = $objPerson->Id;
        }
    }
    print "GROUPS\n";
    $objGroupCursor = Group::QueryCursor(QQ::All());
    QDataGen::DisplayForEachTaskStart('Checking for email in Group Lists', Group::CountAll());
    while ($objGroup = Group::InstantiateCursor($objGroupCursor)) {
        QDataGen::DisplayForEachTaskNext('Checking for email in Group Lists');
        $objGroupParticipationArr = $objGroup->GetGroupParticipationArray();
        foreach ($objGroupParticipationArr as $objGroupParticipant) {
            if (in_array($objGroupParticipant->PersonId, $intPersonIdArray)) {
                printf("\n%s is in %s: %s\n", $txtEmail, $objGroup->Ministry->Name, $objGroup->Name);
                break;
            }
        }
    }
Пример #10
0
        $strSql .= sprintf("    `%s%s` %s,\r\n", $strPrefix, $strFieldName, $strType);
    }
    $strSql .= "    PRIMARY KEY (pkid)\r\n);\r\n\r\n";
    return $strSql;
}
$objOdbc = odbc_connect(ACS_ODBC, null, null);
$objDirectory = opendir(ACS_DATA_PATH);
$strSql = null;
while ($strFile = readdir($objDirectory)) {
    $strFile = strtolower($strFile);
    if (substr($strFile, strlen($strFile) - 7) == '.acsdat') {
        $strTableName = substr($strFile, 0, strlen($strFile) - 7);
        $strSql .= GetTableScript($objOdbc, $strTableName, $strTableName, null);
    }
}
if (trim(strtolower($objParameters->GetDefaultValue('output_path'))) == 'run') {
    $strConnectionArray = unserialize(DB_CONNECTION_3);
    $objMySql = new MySqli($strConnectionArray['server'], $strConnectionArray['username']);
    $objMySql->select_db('mysql');
    $objMySql->query('DROP DATABASE IF EXISTS `' . $strConnectionArray['database'] . '`;');
    $objMySql->query('CREATE DATABASE `' . $strConnectionArray['database'] . '`;');
    $objMySql->select_db($strConnectionArray['database']);
    foreach (explode(';', $strSql) as $strSqlStatement) {
        $objMySql->query(trim($strSqlStatement . ';'));
        if ($strError = $objMySql->error) {
            print $strError . "\r\n";
        }
    }
    $objMySql->close();
} else {
    file_put_contents($objParameters->GetDefaultValue('output_path'), $strSql);