<?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; }
<?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);
<?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');
<?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); }
<?php /** * Codegen Qcodo CLI file * Part of the Qcodo Development Framework * Copyright (c) 2005-2010, Quasidea Development, LLC */ //execution timer $intStartTime = microtime(); $intStartTime = explode(' ', $intStartTime); $intStartTime = $intStartTime[1] + $intStartTime[0]; // Setup the Parameters for codegen $objParameters = new QCliParameterProcessor('codegen', 'Qcodo Code Generator v' . QCODO_VERSION); // Optional Parameters for Path to Codegen Settings $strDefaultPath = __DEVTOOLS_CLI__ . '/settings/codegen.xml'; // Small cleanup on the text $strDefaultPath = str_replace('/html/../', '/', $strDefaultPath); $strDefaultPath = str_replace('/docroot/../', '/', $strDefaultPath); $strDefaultPath = str_replace('/wwwroot/../', '/', $strDefaultPath); $strDefaultPath = str_replace('/www/../', '/', $strDefaultPath); $objParameters->AddNamedParameter('s', 'settings-path', QCliParameterType::Path, $strDefaultPath, 'path to the Codegen Settings XML file; defaults to ' . $strDefaultPath); $objParameters->Run(); // Pull the Parameter Values $strSettingsXmlPath = $objParameters->GetValue('s'); try { ///////////////////// // Run Code Gen QCodeGen::Run($strSettingsXmlPath); ///////////////////// if ($strErrors = QCodeGen::$RootErrors) { printf("The following ROOT ERRORS were reported:\r\n%s\r\n\r\n", $strErrors);
<?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();
<?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;
<?php /** * Codegen Qcodo CLI file * Part of the Qcodo Development Framework * Copyright (c) 2005-2010, Quasidea Development, LLC */ // Setup the Parameters for qpm-upload $objParameters = new QCliParameterProcessor('qpm-upload', 'Qcodo Package Manager (QPM) Uploader Tool v' . QCODO_VERSION); // Package Name is always required $objParameters->AddDefaultParameter('username/package_name', QCliParameterType::String, 'your username and the name of the QPM package you are wanting to upload'); // Optional Parameters include Username, Password, "Live" mode, and "Force" upload $objParameters->AddNamedParameter('p', 'password', QCliParameterType::String, null, 'the qcodo.com password to use, or if not specified, it will use the information stored in the QPM Settings file'); $objParameters->AddFlagParameter('l', 'live', 'actually perform the live upload; by default, calling qpm-upload will only *report* to you files that will be uploaded; specify the "live" flag to actually perform the upload'); $objParameters->AddFlagParameter('f', 'force', 'force the upload, even if the most recent Qcodo version is more recent than what is currently installed here'); $objParameters->AddNamedParameter('s', 'settings-path', QCliParameterType::Path, null, 'path to the QPM Settings XML file; defaults to ' . __DEVTOOLS_CLI__ . '/settings_qpm.xml'); $objParameters->AddNamedParameter('n', 'notes', QCliParameterType::String, null, 'text of any notes to include with this QPM package'); $objParameters->AddNamedParameter('N', 'notes-path', QCliParameterType::Path, null, 'path to textfile containing any notes to include with this QPM package; if both notes and notes-path are set, only the contents from notes-path will be included in the QPM package'); $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'); $strPassword = $objParameters->GetValue('p'); $strSettingsFilePath = $objParameters->GetValue('s'); $strNotes = $objParameters->GetValue('n');
<?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
<?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
<?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; } } }
/** * Adds a default parameter for this CLI call. DefaultIdentifier will be alphanumeric with underscores in all caps. * Because default parameters are required, there is no default value to specify. * Note that since defualt parameters MUST be passed in, there is no short or long (-x or --xxx) identifiers associated with them. * The identifier specified is simply for internal use. Processing of default identifiers are done in the order they are added * to the class. So for example, if default identifiers are added in the following way: * $this->AddDefaultParameter('USERNAME', QCliParameterType::String, 'Your Username'); * $this->AddDefaultParameter('PASSWORD', QCliParameterType::String, 'Your Possword'); * $this->AddDefaultParameter('PATH_TO_FILE', QCliParameterType::Path, 'Path to the given file'); * then the call to the CLI must follow with USERNAME PASSWORD PATH_TO_FILE. * @param string $strDefaultIdentifier * @param QCliParameterType $intCliParameterType * @param string $strHelpText * @return void */ public function AddDefaultParameter($strDefaultIdentifier, $intCliParameterType, $strHelpText) { // Cleanup the Identifier, and throw in invalid try { $strDefaultIdentifier = QCliParameterProcessor::CleanDefaultIdentifier($strDefaultIdentifier); } catch (QInvalidCastException $objExc) { $objExc->IncrementOffset(); throw $objExc; } // Ensure DefaultIdentifier is not already in use if ($strDefaultIdentifier && array_key_exists($strDefaultIdentifier, $this->strDefaultIdentifierArray)) { throw new QCallerException('DefaultIdentifier already in use: ' . $strDefaultIdentifier); } // Get the ValueIndex for this flag, and set the value to false $intIndex = count($this->mixDefaultValueArray); $this->mixDefaultValueArray[$intIndex] = null; $this->intDefaultParameterTypeArray[$intIndex] = $intCliParameterType; $this->strDefaultHelpTextArray[$intIndex] = $strHelpText; $this->strDefaultIdentifierArray[$intIndex] = $strDefaultIdentifier; }
<?php $objParameters = new QCliParameterProcessor('acs-make-mysql', 'Make MySQL Create Script for ACS'); // Package Name is always required $objParameters->AddDefaultParameter('output_path', QCliParameterType::String, 'the path of the script output'); $objParameters->Run(); function GetTableScript($objOdbc, $strTablePath, $strTableName, $strPrefix) { $objResult = odbc_exec($objOdbc, "SELECT * FROM " . $strTablePath . ";"); $intNumFields = odbc_num_fields($objResult); $strSql = 'CREATE TABLE `' . strtolower($strTableName) . "` (\r\n"; $strSql .= " pkid INTEGER UNSIGNED NOT NULL AUTO_INCREMENT,\r\n"; for ($intFieldNumber = 1; $intFieldNumber <= $intNumFields; $intFieldNumber++) { $strType = odbc_field_type($objResult, $intFieldNumber); switch ($strType) { case 'LONGVARCHAR': case 'LONGVARBINARY': $strType = 'TEXT'; break; case 'VARCHAR': case 'WORD': $strType = 'VARCHAR(255)'; break; case 'LARGEINT': case 'SMALLINT': case 'AUTOINC': $strType = 'INT'; break; case 'Long': $strType = 'INT'; break;