/** * 执行指定的动作 * * @return mixed */ function execute($action_name, array $args = array()) { $action_method = "action{$action_name}"; // 执行指定的动作方法 $this->_before_execute(); #IFDEF DBEUG QLog::log('EXECUTE ACTION: ' . get_class($this) . '::' . $action_method . '()', QLog::DEBUG); #ENDIF $this->_view['_MSG'] = $this->_app->getFlashMessage(); Q::replaceIni('OrderAvailable', true); Q::replaceIni('isAdmin', false); #dump(Q::ini('appini/managers')); if ($this->_user) { if (in_array($this->_user->user_mail, Q::ini('appini/managers'))) { Q::replaceIni('isAdmin', true); } } $this->_view['_UDI'] = QContext::instance()->requestUDI(false); $response = call_user_func_array(array($this, $action_method), $args); $this->_after_execute($response); if (is_null($response) && is_array($this->_view)) { // 如果动作没有返回值,并且 $this->view 不为 null, // 则假定动作要通过 $this->view 输出数据 $config = array('view_dir' => $this->_getViewDir()); $response = new $this->_view_class($config); $response->setViewname($this->_getViewName())->assign($this->_view); #dump($response); $this->_before_render($response); } elseif ($response instanceof $this->_view_class) { $response->assign($this->_view); $this->_before_render($response); } #dump($response); return $response; }
public static function queryKeywordWithPrefix($prefix = '', $limit = 10) { global $db; $keyword_quoted = $db->quote($prefix . "%"); $sql = "SELECT `keyword` as itemName FROM `keyword` \n\t\t\tWHERE `keyword` like {$keyword_quoted}\n\t\t\tORDER BY keyword\n\t\t\tLIMIT " . intval($limit); $keyword_list = $db->getAll($sql); QLog::log("KeywordModel::queryKeywordWithPrefix({$prefix},{$limit})->sql: " . $sql . " -> list: " . json_encode($keyword_list)); return $keyword_list; }
public static function queryYamaiWithTypeAndPrefix($which, $prefix = '', $limit = 10) { global $db; if (!in_array($which, array('yamai_type', 'yamai_system', 'yamai_name'))) { return false; } $keyword_quoted = $db->quote($prefix . "%"); $sql = "SELECT distinct `{$which}` as itemName FROM yamai \n\t\t\tWHERE `{$which}` like {$keyword_quoted} \n\t\t\tLIMIT " . intval($limit); $list = $db->getAll($sql); QLog::log("YamaiModel::queryYamaiWithTypeAndPrefix({$which},{$prefix},{$limit})->sql: " . $sql . " -> list: " . json_encode($list)); return $list; }
/** * 执行指定的动作 * * @return mixed */ function execute($action_name, array $args = array()) { $action_method = "action{$action_name}"; // 执行指定的动作方法 $this->_before_execute(); #IFDEF DBEUG QLog::log('EXECUTE ACTION: ' . get_class($this) . '::' . $action_method . '()', QLog::DEBUG); #ENDIF $response = call_user_func_array(array($this, $action_method), $args); $this->_after_execute($response); if (is_null($response) && is_array($this->_view)) { // 如果动作没有返回值,并且 $this->view 不为 null, // 则假定动作要通过 $this->view 输出数据 $config = array('view_dir' => $this->_getViewDir()); $response = new $this->_view_class($config); $response->setViewname($this->_getViewName())->assign($this->_view); } return $response; }
function actionMigrationOut() { $this->_pathway->addStep('数据迁出'); QLog::log('开始数据迁出!'); try { $db = QDB::getConn(); $db->startTrans(); $db->completeTrans(); } catch (QException $ex) { QLog::log($ex->getMessage(), QLog::ERR); } echo '正在迁移,请稍后...<br/>'; for ($i = 0; $i < 100; $i++) { QLog::log('正在迁出数据:' . $i); echo $i . '<br/>'; } QLog::log('数据迁出完成!'); return '迁出成功'; }
public function Send() { if (!$this->blnErrorFlag) { $this->blnErrorFlag = true; $this->Save(); $objEmailMessage = new QEmailMessage($this->strFromAddress, $this->strToAddress, $this->strSubject, $this->strBody); $objEmailMessage->Cc = $this->strCcAddress; $objEmailMessage->Bcc = $this->strBccAddress; try { QEmailServer::Send($objEmailMessage); } catch (QCallerException $objExc) { QLog::Log('Email Failed to Send #' . $this->intId); QLog::Log($objExc->getMessage()); $this->strErrorMessage = $objExc->getMessage(); $this->Save(); } $this->Delete(); } }
public function getOne($sql) { //FETCH_BOTH $stmt = $this->pdo->query($sql); if ($stmt === false) { QLog::log("STMT GET FALSE FOR SQL: " . $sql); throw new Exception("STMT GET FALSE FOR SQL: " . $sql, -1); } $rows = $stmt->fetchAll(PDO::FETCH_BOTH); if ($rows) { $row = $rows[0]; if ($row) { return $row[0]; } else { return false; } } else { return false; } }
public function execute($sql, $inputarr = null) { if (!$this->isConnected()) { $this->connect(); } $sth = $this->_conn->prepare($sql); if ($this->_log_enabled) { QLog::log($sql, QLog::DEBUG); } $result = $sth->execute((array) $inputarr); if (false === $result) { $error = $sth->errorInfo(); $this->_last_err = $error[2]; $this->_last_err_code = $error[1]; $this->_has_failed_query = true; throw new QDB_Exception($sql, $this->_last_err, $this->_last_err_code); } $this->_lastrs = $sth; if ('select' == strtolower(substr($sql, 0, 6))) { return new QDB_Result_Pdo($this->_lastrs, $this->_fetch_mode); } else { return $this->affectedRows(); } }
public static function searchKeywords($keywords = array()) { global $db; if (empty($keywords)) { return false; } $keywords_in_sql = "'" . implode("','", $keywords) . "'"; $sql = "SELECT keyword_id FROM keyword WHERE keyword in ({$keywords_in_sql})"; $keyword_id_list = $db->getColumn($sql); QLog::log("KYStoreModel::searchKeywords(" . implode(',', $keywords) . ") -> sql: " . $sql . " -> " . implode(',', $keyword_id_list)); if (empty($keyword_id_list) || count($keyword_id_list) != count($keywords)) { return false; } $yamai_list = null; foreach ($keyword_id_list as $keyword_id) { $sql = "SELECT yamai_id FROM yamai_keyword yk \n\t\t\t\tWHERE yk.keyword_id={$keyword_id} and yk.relation_score>0\n\t\t\t"; if ($yamai_list !== null) { $sql .= " and yk.yamai_id in (" . implode(",", $yamai_list) . ") "; } $yamai_list_once = $db->getColumn($sql); QLog::log("KYStoreModel::searchKeywords once for {$keyword_id} -> sql: " . $sql . " -> list: " . implode(',', $yamai_list_once)); if ($yamai_list === null) { $yamai_list = $yamai_list_once; } else { $yamai_list = array_intersect($yamai_list, $yamai_list_once); } QLog::log("KYStoreModel::searchKeywords intersect list: " . implode(',', $yamai_list)); if (empty($yamai_list)) { return false; } } $sql = "SELECT y.*,group_concat('',k.keyword) keyword_list FROM yamai y\n\t\t\tLEFT JOIN yamai_keyword yk ON y.yamai_id=yk.yamai_id\n\t\t\tLEFT JOIN keyword k ON k.keyword_id=yk.keyword_id\n\t\t\tWHERE y.yamai_id in (" . implode(',', $yamai_list) . ") \n\t\t\tGROUP BY y.yamai_id\n\t\t"; $list = $db->getAll($sql); QLog::log("KYStoreModel::searchKeywords find details -> sql: " . $sql . " -> " . implode(',', $keyword_id_list)); return $list; }
/** * 执行一个查询,返回一个查询对象或者 boolean 值,出错时抛出异常 * * $sql 是要执行的 SQL 语句字符串,而 $inputarr 则是提供给 SQL 语句中参数占位符需要的值。 * * 如果执行的查询是诸如 INSERT、DELETE、UPDATE 等不会返回结果集的操作, * 则 execute() 执行成功后会返回 true,失败时将抛出异常。 * * 如果执行的查询是 SELECT 等会返回结果集的操作, * 则 execute() 执行成功后会返回一个 DBO_Result 对象,失败时将抛出异常。 * * QDB_Result_Abstract 对象封装了查询结果句柄,而不是结果集。 * * @param string $sql * @param array $inputarr * * @return QDB_Result_Abstract */ function execute($sql, $inputarr = null) { if (is_array($inputarr)) { $sql = $this->_fakebind($sql, $inputarr); } if (!$this->_conn) { $this->connect(); } //print_R($sql); $this->_lastrs = @pg_query($this->_conn, $sql); if ($this->_log_enabled) { QLog::log($sql, QLog::DEBUG); } if (is_resource($this->_lastrs)) { Q::loadClass('Qdb_Result_Pgsql'); return new QDB_Result_Pgsql($this->_lastrs, $this->_fetch_mode); } elseif ($this->_lastrs) { $this->_last_err = null; $this->_last_err_code = null; return $this->_lastrs; } else { $this->_last_err = pg_errormessage($this->_conn); $this->_last_err_code = null; $this->_has_failed_query = true; throw new QDB_Exception($sql, $this->_last_err, $this->_last_err_code); } }
/** * 追加日志到日志缓存 * * @param string $msg * @param int $type */ static function log($msg, $type = self::DEBUG) { // 如果是command,则用echo 替换 ljzhou 2015-1-28 if (!isset($_SERVER['SERVER_NAME'])) { echo date('c') . " " . $msg . "\n"; return; } static $instance; if (is_null($instance)) { $instance = new QLog(); # 对象属性设置 $instance->_log_writer_dir = QLog::$log_dir; //$log_dir;//ROOT_PATH. 'admin/filelock'; $instance->_log_cache_chunk_size = 64; $instance->_log_writer_filename = 'devel-' . date('ymd') . '.log'; $instance->_log_priorities = 'EMERG, ALERT, CRIT, ERR, WARN, NOTICE, INFO, DEBUG'; } $instance->append($msg, $type); }
/* * All Hail Sinri Edogawa * ========================================= * Weishop 的初始化文件 * 反正就是初始化,搞搞数据库啊日志啊啥的 * 绝命:2015年4月8日 * ========================================= * 针对新项目的修正处以【TODO】标记 */ require_once __DIR__ . "/../toolkit/lib_log.php"; date_default_timezone_set("Asia/Shanghai"); require_once __DIR__ . "/../toolkit/config.php"; // Set up the logger. // URL: such as http://XXX.com/weishop/toolkit/log/ws_20150408.log QLog::setLogDir($log_file_path); require __DIR__ . "/../toolkit/SinriPDO.php"; global $db; $db = new SinriPDO($deploy_level, $username, $password, $host, $port, $database, $charset); function getRequest($name, $default = null) { if (isset($_REQUEST[$name])) { return $_REQUEST[$name]; } else { return $default; } } function maskValue($mono, $default = '') { if ($isset($mono)) { return $mono;
/** * 创建对象时,保存 many_to_many 关联 */ function testCreateWithManyToMany() { QLog::log(__METHOD__, QLog::DEBUG); $tags = array('PHP', 'C++', 'Java'); $content = new Content(array('title' => 'title - ' . mt_rand(), 'author_id' => 0)); foreach ($tags as $tag_name) { $content->tags[] = new Tag(array('name' => $tag_name)); } $content->save(); $this->assertNotNull($content->id()); $row = $this->_queryContent($content->id()); $this->_checkContent($row, $content); foreach ($tags as $offset => $tag_name) { $row = $this->_queryTag($tag_name); $this->assertType('array', $row); $this->_checkTag($row, $content->tags[$offset]); } $mid_table_name = $content->getMeta()->associations['tags']->mid_table->qtable_name; $sql = "SELECT * FROM {$mid_table_name} WHERE content_id = ?"; $rowset = $this->_conn->getAll($sql, array($content->id())); $this->assertEquals(count($tags), count($rowset)); $tags = array_flip($tags); foreach ($rowset as $row) { $this->assertTrue(isset($tags[$row['tag_name']])); unset($tags[$row['tag_name']]); } }
/** * 构造函数 * * @param int $type * @param array $config * @param QDB_ActiveRecord_Meta $source_meta * * @return QDB_ActiveRecord_Association_Abstract */ protected function __construct($type, array $config, QDB_ActiveRecord_Meta $source_meta) { $this->type = $type; #IFDEF DEBUG QLog::log(__METHOD__ . "({$config['mapping_name']})", QLog::DEBUG); #ENDIF foreach (self::$_init_config_keys as $key) { if (!empty($config[$key])) { $this->{$key} = $config[$key]; } } $this->_init_config = $config; $this->source_meta = $source_meta; }
keyword_id ~ keyword yamai_id ~ yamai_name yamai_type yamai_system yamai_id keyword_id ~ relation_score */ $act = getRequest('act'); if ($act == 'update') { $yamai_name = getRequest('yamai_name', ''); $yamai_type = getRequest('yamai_type', null); $yamai_system = getRequest('yamai_system', null); $keyword = getRequest('keyword', ''); $score = getRequest('score', 3); QLog::log("COMMON UPDATE: [{$yamai_name}][{$yamai_type}][{$yamai_system}]+[{$keyword}]={$score}"); $yamai_id = YamaiModel::getYamaiId($yamai_name, $yamai_type, $yamai_system); $keyword_id = KeywordModel::getKeywordId($keyword); $afx = KYStoreModel::updateKYScore($keyword_id, $yamai_id, $score); QLog::log("DB RESULT: Y[{$yamai_id}]+K[{$keyword_id}]=" . ($afx === false ? 'FALSE' : $afx)); echo json_encode(array('updated' => $afx === false ? '0' : '1')); exit; } elseif ($act == "list_yamai") { $yamai_name = getRequest('yamai_name', ''); $yamai_type = getRequest('yamai_type', null); $yamai_system = getRequest('yamai_system', null); $limit = 0; $offset = 0; $list_of_yamai = YamaiModel::listYamai($yamai_name, $yamai_type, $yamai_system, $limit, $offset); echo json_encode(array('list' => $list_of_yamai === false ? array() : $list_of_yamai)); exit; } elseif ($act == "search") { $keywords = getRequest('keywords', array()); $keywords = preg_split("/[\\s,]+/", $keywords); $list_of_yamai = KYStoreModel::searchKeywords($keywords);
protected function btnSave_Click($strFormId, $strControlId, $strParameter) { // Create address record(s) $objHomeAddress = $this->objHomeAddressValidator->CreateAddressRecord(); if ($this->objMailingAddressValidator) { $objMailingAddress = $this->objMailingAddressValidator->CreateAddressRecord(); } else { $objMailingAddress = null; } if (trim($this->dtxDateOfBirth->Text)) { $dttDateOfBirth = $this->dtxDateOfBirth->DateTime; } else { $dttDateOfBirth = null; } $objPerson = QApplication::$PublicLogin->ProvisionalPublicLogin->Reconcile(trim(strtolower($this->txtPassword->Text)), $this->lstQuestion->SelectedValue ? $this->lstQuestion->SelectedValue : trim($this->txtQuestion->Text), trim(strtolower($this->txtAnswer->Text)), trim($this->txtHomePhone->Text), trim($this->txtMobilePhone->Text), $objHomeAddress, $objMailingAddress, $dttDateOfBirth, $this->rblGender->SelectedValue); if ($objPerson->PublicLogin->Id != QApplication::$PublicLogin->Id) { QLog::Log(sprintf('Provisioned PublicLogin::Reconcile() matched against a Person with an existing PublicLogin: PublicLogin(%s) and Person(%s)', QApplication::$PublicLogin->Id, $objPerson->Id)); QApplication::DisplayAlert('It appears that another registration exists with the same name and home address. Before we can proceed, please contact ALCF Online Member Support at 650-625-1500 or records@alcf.net for more information. Please reference PLID ' . QApplication::$PublicLogin->Id . ' when calling.'); } else { // OptOut Email Flag if (!$this->chkBulkEmail->Checked) { $objPerson->CanEmailFlag = false; $objPerson->Save(); } else { //Upon confirmation, add them to the newletter list $objList = CommunicationList::LoadByToken('alcfweekly'); if ($objList) { if (!$objList->IsPersonAssociated($objPerson)) { $objList->AssociatePerson($objPerson); } $objPerson->Save(); } } QApplication::RedirectOnPublicLogin('/register/thankyou.php'); } }
/** * Returns an string array of check information indexed by: * 0: Routing Number * 1: Checking Account Number * 2: Check Number * 3: Amount (optional) * @param string $strCheckInfo * @return string[] */ public static function ParseCheckingInformation($strCheckInfo) { $strCheckInfo = trim(strtoupper($strCheckInfo)); if (strpos($strCheckInfo, '?') !== false) { QLog::Log('Cannot Read Check Info: ' . $strCheckInfo); return null; } $strTokens = explode(',', $strCheckInfo); if (count($strTokens) == 3 || count($strTokens) == 4) { if (strlen($strTokens[0]) == 9 && strlen($strTokens[1]) > 4) { return $strTokens; } } QLog::Log('Cannot Read Check Info: ' . $strCheckInfo); return null; }
/** * 执行指定的 Action 方法 * * @param QContext $context * @param array $args * * @return mixed */ protected function _executeAction(QContext $context, array $args = array()) { // 检查是否有权限访问 $controller_name = $context->controller_name; $action_name = $context->action_name; $namespace = $context->namespace; $module = $context->module_name; QLog::log(sprintf('Execute controller action: "%s".', $context->getRequestUDI())); if (!$this->checkAuthorized($controller_name, $action_name, $namespace, $module)) { $response = call_user_func($context->getIni('dispatcher_on_access_denied'), $context); } else { // 尝试载入控制器 $class_name = $context->getIni('controller_class_prefix') . 'Controller_'; if ($namespace) { $class_name .= ucfirst($namespace) . '_'; } $class_name .= ucfirst(str_replace('_', '', $controller_name)); $app_config = self::getAppConfig($this->_appid); if ($module) { $dir = $app_config['ROOT_DIR'] . "/modules/{$module}/controller"; } else { $dir = $app_config['ROOT_DIR'] . "/app/controller"; } if ($namespace) { $dir .= DS . $namespace; } // 构造控制器对象 try { $filename = $controller_name . '_controller.php'; Q::loadClassFile($filename, array($dir), $class_name); } catch (QException $ex) { $response = call_user_func($this->context->getIni('dispatcher_on_action_not_found'), $context); if (is_null($response)) { $response = ''; } } if (!isset($response)) { $controller = new $class_name($this, $context); /* @var $controller QController_Abstract */ if ($context->isAJAX()) { $controller->view = null; } $response = $controller->_execute($args); } } if (is_object($response) && method_exists($response, 'execute')) { $response = $response->execute(); } elseif ($response instanceof QController_Forward) { // 更新 flash message $key = $this->context->getIni('app_flash_message_key'); unset($_SESSION[$key]); $response = $this->_executeAction($response->context, $response->args); } return $response; }
function execute($sql, $inputarr = null) { if (is_array($inputarr)) { $sql = $this->_fakebind($sql, $inputarr); } if ($this->_log_enabled) { QLog::log('[DB EXECUTE] ' . str_replace("\n", ' ', $sql), QLog::DEBUG); } if (!$this->_conn) { $this->connect(); } $result = mysql_query($sql, $this->_conn); if (is_resource($result)) { return new QDB_Result_Mysql($result, $this->_fetch_mode); } elseif ($result) { $this->_last_err = null; $this->_last_err_code = null; return $result; } else { $this->_last_err = mysql_error($this->_conn); $this->_last_err_code = mysql_errno($this->_conn); $this->_has_failed_query = true; if ($this->_last_err_code == 1062) { throw new QDB_Exception_DuplicateKey($sql, $this->_last_err, $this->_last_err_code); } else { throw new QDB_Exception($sql, $this->_last_err, $this->_last_err_code); } } }
/** * Merges two records together. * @param Person $objPersonMergeWith * @param boolean $blnUseThisDetails boolean on whether to use this person's Person object details, or if false, use the PersonMergeWith's */ public function MergeWith(Person $objPersonMergeWith, $blnUseThisDetails) { QLog::Log(sprintf('Merging %s (ID %s) with %s (ID %s) - %s', $this->Name, $this->Id, $objPersonMergeWith->Name, $objPersonMergeWith->Id, $blnUseThisDetails ? 'left' : 'right')); Person::GetDatabase()->TransactionBegin(); // Household Participation Records if ($this->HouseholdAsHead && $objPersonMergeWith->HouseholdAsHead) { $this->HouseholdAsHead->MergeHousehold($objPersonMergeWith->HouseholdAsHead, $this); } else { if ($this->HouseholdAsHead) { // Go through each MergeWith HouseholdParticipation -- Throw if it's another household, Delete if it's this Household-as-Head foreach ($objPersonMergeWith->GetHouseholdParticipationArray() as $objHouseholdParticipation) { if ($objHouseholdParticipation->HouseholdId != $this->HouseholdAsHead->Id) { throw new QCallerException('Cannot merge this head of household with a person record that exists in other households'); } else { $objHouseholdParticipation->Delete(); } } } else { if ($objHousehold = $objPersonMergeWith->HouseholdAsHead) { // Go through each of this's HouseholdParticipation -- Throw if it's another household, Delete if it's MergeWith's Household-as-Head foreach ($this->GetHouseholdParticipationArray() as $objHouseholdParticipation) { if ($objHouseholdParticipation->HouseholdId != $objPersonMergeWith->HouseholdAsHead->Id) { throw new QCallerException('Cannot merge MergeWith head of household with this person record which exists in other households'); } else { $objHouseholdParticipation->Delete(); } } $objHousehold->HeadPerson = $this; $objHousehold->Save(); $objParticipation = HouseholdParticipation::LoadByPersonIdHouseholdId($objPersonMergeWith->Id, $objHousehold->Id); $objParticipation->PersonId = $this->Id; $objParticipation->Save(); } else { // Otherwise: members of multiple households! but head of none foreach ($objPersonMergeWith->GetHouseholdParticipationArray() as $objHouseholdParticipation) { if (HouseholdParticipation::LoadByPersonIdHouseholdId($this->Id, $objHouseholdParticipation->HouseholdId)) { $objHouseholdParticipation->Delete(); } else { $objHouseholdParticipation->PersonId = $this->Id; $objHouseholdParticipation->Save(); } } } } } if (!$blnUseThisDetails) { $this->FirstName = $objPersonMergeWith->FirstName; $this->MiddleName = $objPersonMergeWith->MiddleName; $this->LastName = $objPersonMergeWith->LastName; $this->MailingLabel = $objPersonMergeWith->MailingLabel; $this->PriorLastNames = $objPersonMergeWith->PriorLastNames; $this->Nickname = $objPersonMergeWith->Nickname; $this->Title = $objPersonMergeWith->Title; $this->Suffix = $objPersonMergeWith->Suffix; $this->Gender = $objPersonMergeWith->Gender; $this->DateOfBirth = $objPersonMergeWith->DateOfBirth; $this->DobYearApproximateFlag = $objPersonMergeWith->DobYearApproximateFlag; $this->DobGuessedFlag = $objPersonMergeWith->DobGuessedFlag; $this->Age = $objPersonMergeWith->Age; $this->DeceasedFlag = $objPersonMergeWith->DeceasedFlag; $this->DateDeceased = $objPersonMergeWith->DateDeceased; } // Attributes foreach ($objPersonMergeWith->GetAttributeValueArray() as $objAttributeValue) { // Check for double-defined attributes if ($objDoubleDefinedAttribute = AttributeValue::LoadByAttributeIdPersonId($objAttributeValue->AttributeId, $this->Id)) { if ($blnUseThisDetails) { $objAttributeValue->Delete(); } else { $objDoubleDefinedAttribute->Delete(); $objAttributeValue->PersonId = $this->Id; $objAttributeValue->Save(); } // Nothing double-defined -- just move it over! } else { $objAttributeValue->PersonId = $this->Id; $objAttributeValue->Save(); } } // Comments foreach ($objPersonMergeWith->GetCommentArray() as $objComment) { $objComment->PersonId = $this->Id; $objComment->Save(); } // Memberships foreach ($objPersonMergeWith->GetMembershipArray() as $objMembership) { $objMembership->PersonId = $this->Id; $objMembership->Save(); } // Communication Lists foreach ($objPersonMergeWith->GetCommunicationListArray() as $objCommList) { $objPersonMergeWith->UnassociateCommunicationList($objCommList); if (!$this->IsCommunicationListAssociated($objCommList)) { $this->AssociateCommunicationList($objCommList); } } // Head Shots foreach ($objPersonMergeWith->GetHeadShotArray() as $objHeadShot) { $objHeadShot->PersonId = $this->Id; $objHeadShot->Save(); } // Group Participation foreach ($objPersonMergeWith->GetGroupParticipationArray() as $objGroupParticipation) { $objGroupParticipation->PersonId = $this->Id; $objGroupParticipation->Save(); } // NameItemAssn $objPersonMergeWith->UnassociateAllNameItems(); // Marrriage Records foreach ($objPersonMergeWith->GetMarriageArray() as $objMarriage) { $this->CreateMarriageWith($objMarriage->MarriedToPerson, $objMarriage->DateStart, $objMarriage->DateEnd, $objMarriage->MarriageStatusTypeId); $objMarriage->DeleteThisAndLinked(); } foreach ($objPersonMergeWith->GetMarriageAsMarriedToArray() as $objMarriage) { $this->CreateMarriageWith($objMarriage->Person, $objMarriage->DateStart, $objMarriage->DateEnd, $objMarriage->MarriageStatusTypeId); $objMarriage->DeleteThisAndLinked(); } // Family Relationships foreach ($objPersonMergeWith->GetRelationshipArray() as $objRelationship) { if (!Relationship::LoadByPersonIdRelatedToPersonId($this->Id, $objRelationship->RelatedToPersonId)) { $this->AddRelationship($objRelationship->RelatedToPerson, $objRelationship->RelationshipTypeId); } $objRelationship->DeleteThisAndLinked(); } foreach ($objPersonMergeWith->GetRelationshipAsRelatedToArray() as $objRelationship) { if (!Relationship::LoadByPersonIdRelatedToPersonId($this->Id, $objRelationship->PersonId)) { $this->AddRelationship($objRelationship->Person, $objRelationship->RelationshipTypeId); } $objRelationship->DeleteThisAndLinked(); } // Phones foreach ($objPersonMergeWith->GetPhoneArray() as $objContact) { $objContact->PersonId = $this->Id; $objContact->Save(); } // Addresses foreach ($objPersonMergeWith->GetAddressArray() as $objContact) { $objContact->PersonId = $this->Id; $objContact->Save(); } // Email foreach ($objPersonMergeWith->GetEmailArray() as $objContact) { $objContact->PersonId = $this->Id; $objContact->Save(); } // Other Contact Info foreach ($objPersonMergeWith->GetOtherContactInfoArray() as $objContact) { $objContact->PersonId = $this->Id; $objContact->Save(); } // Checking Account Lookups foreach ($objPersonMergeWith->GetCheckingAccountLookupArray() as $objCheckingAccount) { $objPersonMergeWith->UnassociateCheckingAccountLookup($objCheckingAccount); if (!$this->IsCheckingAccountLookupAssociated($objCheckingAccount)) { $this->AssociateCheckingAccountLookup($objCheckingAccount); } } // Stewardship Contributions foreach ($objPersonMergeWith->GetStewardshipContributionArray() as $objStewardship) { $objStewardship->PersonId = $this->Id; $objStewardship->Save(); } // Stewardship Pledges foreach ($objPersonMergeWith->GetStewardshipPledgeArray() as $objPledge) { // Check for double-defined pledge if ($objDoubleDefinedPledge = StewardshipPledge::LoadByPersonIdStewardshipFundId($this->Id, $objPledge->StewardshipFundId)) { if ($blnUseThisDetails) { $objPledge->Delete(); } else { $objDoubleDefinedPledge->Delete(); $objPledge->PersonId = $this->Id; $objPledge->Save(); } // Nope, just move it over like normal } else { $objPledge->PersonId = $this->Id; $objPledge->Save(); } } // Online Donations foreach ($objPersonMergeWith->GetOnlineDonationArray() as $objOnlineDonation) { $objOnlineDonation->PersonId = $this->Id; $objOnlineDonation->Save(); } // Public Login if ($objPublicLogin = $objPersonMergeWith->PublicLogin) { $objPublicLogin->PersonId = $this->Id; $objPublicLogin->Save(); } // Events and Classes foreach ($objPersonMergeWith->GetSignupEntryArray() as $objSignupEntry) { $objSignupEntry->PersonId = $this->Id; $objSignupEntry->Save(); } foreach ($objPersonMergeWith->GetSignupEntryAsSignupByArray() as $objSignupEntry) { $objSignupEntry->SignupByPersonId = $this->Id; $objSignupEntry->Save(); } foreach ($objPersonMergeWith->GetClassRegistrationArray() as $objClassRegistration) { $objClassRegistration->PersonId = $this->Id; $objClassRegistration->Save(); } // Stewardship Post Line Items foreach ($objPersonMergeWith->GetStewardshipPostLineItemArray() as $objStewardship) { $objStewardship->PersonId = $this->Id; $objStewardship->Save(); } // Email Message Route foreach ($objPersonMergeWith->GetEmailMessageRouteArray() as $objEmailMessageRoute) { $objEmailMessageRoute->PersonId = $this->Id; $objEmailMessageRoute->Save(); } // Search Query foreach ($objPersonMergeWith->GetSearchQueryArray() as $objSearchQuery) { $objSearchQuery->PersonId = $this->Id; $objSearchQuery->Save(); } // Final Refresh/Cleanup $this->RefreshAge(false); $this->RefreshMaritalStatusTypeId(false); $this->RefreshMembershipStatusTypeId(false); $this->RefreshPrimaryContactInfo(false); $this->Save(); $this->RefreshNameItemAssociations(); $objPersonMergeWith->Delete(); Person::GetDatabase()->TransactionCommit(); }
/** * 初始化应用程序设置 */ protected function _initConfig() { #IFDEF DEBUG QLog::log(__METHOD__, QLog::DEBUG); #ENDIF // 载入配置文件 if ($this->_app_config['CONFIG_CACHED']) { /** * 从缓存载入配置文件内容 */ // 构造缓存服务对象 $backend = $this->_app_config['CONFIG_CACHE_BACKEND']; $settings = isset($this->_app_config['CONFIG_CACHE_SETTINGS'][$backend]) ? $this->_app_config['CONFIG_CACHE_SETTINGS'][$backend] : null; $cache = new $backend($settings); // 载入缓存内容 $cache_id = $this->_app_config['APPID'] . '_app_config'; $config = $cache->get($cache_id); if (!empty($config)) { Q::replaceIni($config); return; } } // 没有使用缓存,或缓存数据失效 $config = self::loadConfigFiles($this->_app_config); if ($this->_app_config['CONFIG_CACHED']) { $cache->set($cache_id, $config); } Q::replaceIni($config); }
/** * This will submit a NVP Request to paypal and return the repsonse * or NULL if there was a connection error. * * @param string[] $strNvpRequestArray a structured array containing the NVP Request * @return string[] a structured array based on the NVP Response, or NULL if there was a connection error */ protected static function PaymentGatewaySubmitRequest($strNvpRequestArray) { $strLogFile = 'paypal_' . QDateTime::NowToString('YYYY-MM-DD'); $strLogHash = substr(md5(microtime()), 0, 8); $objCurl = curl_init(); curl_setopt($objCurl, CURLOPT_URL, PAYPAL_ENDPOINT); curl_setopt($objCurl, CURLOPT_VERBOSE, false); // Turning off the server and peer verification (TrustManager Concept) curl_setopt($objCurl, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($objCurl, CURLOPT_SSL_VERIFYHOST, false); curl_setopt($objCurl, CURLOPT_RETURNTRANSFER, true); curl_setopt($objCurl, CURLOPT_POST, true); // Add Credentials to NVP-based Request for submitting to server $strNvpRequestArray['PARTNER'] = PAYPAL_PARTNER; $strNvpRequestArray['USER'] = PAYPAL_USER; $strNvpRequestArray['VENDOR'] = PAYPAL_VENDOR; $strNvpRequestArray['PWD'] = PAYPAL_PASSWORD; $strNvpRequest = self::FormatNvp($strNvpRequestArray); // First, we Sanitize NVP Request for Logging and then log it $strNvpRequestToLog = $strNvpRequestArray; $strNvpRequestToLog['PARTNER'] = 'xxxxx'; $strNvpRequestToLog['USER'] = '******'; $strNvpRequestToLog['VENDOR'] = 'xxxxx'; $strNvpRequestToLog['PWD'] = 'xxxxx'; if (array_key_exists('ACCT', $strNvpRequestToLog)) { $intLength = strlen($strNvpRequestToLog['ACCT']); $strNvpRequestToLog['ACCT'] = str_repeat('x', $intLength - 4) . substr($strNvpRequestToLog['ACCT'], $intLength - 4); } QLog::Log($strLogHash . ' - ' . self::FormatNvp($strNvpRequestToLog), QLogLevel::Normal, $strLogFile); // Setting the entire NvpRequest as POST FIELD to curl curl_setopt($objCurl, CURLOPT_POSTFIELDS, $strNvpRequest); // Getting response from server $strResponse = @curl_exec($objCurl); curl_close($objCurl); if ($strResponse) { $arrToReturn = self::DeformatNvp($strResponse); QLog::Log($strLogHash . ' - ' . var_export($arrToReturn, true), QLogLevel::Normal, $strLogFile); return $arrToReturn; } else { QLog::Log($strLogHash . ' - ' . 'ERROR', QLogLevel::Normal, $strLogFile); return null; } }