本文整理汇总了PHP中AMA_DataHandler::instance方法的典型用法代码示例。如果您正苦于以下问题:PHP AMA_DataHandler::instance方法的具体用法?PHP AMA_DataHandler::instance怎么用?PHP AMA_DataHandler::instance使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AMA_DataHandler
的用法示例。
在下文中一共展示了AMA_DataHandler::instance方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: today_dateFN
* INCLUSIONE SPECIFICA PER PAYPAL
*/
if (file_exists(ROOT_DIR . '/browsing/paypal/paypal_conf.inc.php')) {
require_once ROOT_DIR . '/browsing/paypal/paypal_conf.inc.php';
$paypal_allowed = TRUE;
}
$today_date = today_dateFN();
$providerId = DataValidator::is_uinteger($_GET['provider']);
$courseId = DataValidator::is_uinteger($_GET['course']);
$instanceId = DataValidator::is_uinteger($_GET['instance']);
$studentId = DataValidator::is_uinteger($_GET['student']);
$testerInfoAr = $common_dh->get_tester_info_from_id($providerId, 'AMA_FETCH_ASSOC');
if (!AMA_Common_DataHandler::isError($testerInfoAr)) {
$provider_name = $testerInfoAr[1];
$tester = $testerInfoAr[10];
$tester_dh = AMA_DataHandler::instance(MultiPort::getDSN($tester));
$currentTesterId = $newTesterId;
$GLOBALS['dh'] = $tester_dh;
$dh = $tester_dh;
/*
* GESTIONE LOG
*/
$logStr = "";
$log_file = ROOT_DIR . '/browsing/paypal/' . PAYPAL_IPN_LOG;
$logFd = fopen($log_file, "a");
$fpx = fopen($log_file, 'a');
$debug = 1;
if ($debug == 1) {
fwrite($fpx, "INIZIO processo Confirm \n");
fwrite($fpx, "Student: {$studentId} \n");
}
示例2: whoami
require_once ROOT_DIR . '/include/module_init.inc.php';
$self = whoami();
require_once 'include/browsing_functions.inc.php';
$courseInstances = array();
$serviceProviders = $userObj->getTesters();
/**
* change the two below call to active to let the closed
* instances completely disappear from the HTML table
*/
if (count($serviceProviders) == 1) {
$provider_dh = AMA_DataHandler::instance(MultiPort::getDSN($serviceProviders[0]));
// $courseInstances = $provider_dh->get_course_instances_active_for_this_student($userObj->getId());
$courseInstances = $provider_dh->get_course_instances_for_this_student($userObj->getId(), true);
} else {
foreach ($serviceProviders as $Provider) {
$provider_dh = AMA_DataHandler::instance(MultiPort::getDSN($Provider));
// $courseInstances_provider = $provider_dh->get_course_instances_active_for_this_student($userObj->getId());
$courseInstances_provider = $provider_dh->get_course_instances_for_this_student($userObj->getId(), true);
$courseInstances = array_merge($courseInstances, $courseInstances_provider);
}
}
if (!AMA_DataHandler::isError($courseInstances)) {
/**
* @author giorgio 23/apr/2015
*
* filter course instance that are associated to a level of service having nonzero
* value in isPublic, so that all instances of public courses will not be shown here
*/
$courseInstances = array_filter($courseInstances, function ($courseInstance) {
if (is_null($courseInstance['tipo_servizio'])) {
$courseInstance['tipo_servizio'] = DEFAULT_SERVICE_TYPE;
示例3: fillAddressBook
protected static function fillAddressBook(ADALoggableUser $userObj, $user_types_Ar = array())
{
$user_type = $userObj->getType();
$common_dh = $GLOBALS['common_dh'];
$dh = $GLOBALS['dh'];
// this tells get_users_by_type method to get nome, cognome....
$retrieve_extended_data = true;
if (!is_array($user_types_Ar[$user_type]) || empty($user_types_Ar[$user_type])) {
return FALSE;
}
switch ($user_type) {
case AMA_TYPE_ADMIN:
/*
* Ottieni tutti i practitioner, gli autori e gli switcher da tutti i
* tester
*/
// FIXME: differisce dagli altri casi !!!
$users[] = $common_dh->get_users_by_type($user_types_Ar[AMA_TYPE_ADMIN], $retrieve_extended_data);
if (AMA_Common_DataHandler::isError($users)) {
// Gestione errore
}
break;
case AMA_TYPE_SWITCHER:
/*
* Ottieni tutti i practitioner e gli utenti dal suo tester
*/
$tester = $userObj->getDefaultTester();
$tester_dh = AMA_DataHandler::instance(MultiPort::getDSN($tester));
$tester_info_Ar = $common_dh->get_tester_info_from_pointer($tester);
$tester_name = $tester_info_Ar[1];
$users[$tester_name] = $tester_dh->get_users_by_type($user_types_Ar[AMA_TYPE_SWITCHER], $retrieve_extended_data);
if (AMA_Common_DataHandler::isError($users)) {
$users[$tester_name] = array();
}
/*
* Ottiene tutti i practitioner presenti sul tester
*/
// $practitioners_Ar = $tester_dh->get_users_by_type(array(AMA_TYPE_TUTOR), $retrieve_extended_data);
// if(AMA_DataHandler::isError($practitioners_Ar) || !is_array($practitioners_Ar)) {
// $practitioners_Ar = array();
// }
/*
* Ottiene tutti gli utenti che hanno richiesto un servizio sul tester
* e che sono in attesa di assegnamento ad un practitioner
*/
// $users_Ar = $tester_dh->get_registered_students_without_tutor();
// if(AMA_DataHandler::isError($users_Ar) || !is_array($users_Ar)) {
// $users_Ar = array();
// }
// $users[$tester_name] = array_merge($practitioners_Ar, $users_Ar);
break;
case AMA_TYPE_TUTOR:
/*
* Ottieni lo switcher del suo tester, gli utenti con i quali è in relazione,
* eventualmente gli altri practitioner sul suo tester
*/
$tester = $userObj->getDefaultTester();
$tester_dh = AMA_DataHandler::instance(MultiPort::getDSN($tester));
$tester_info_Ar = $common_dh->get_tester_info_from_pointer($tester);
$tester_name = $tester_info_Ar[1];
if (in_array(AMA_TYPE_STUDENT, $user_types_Ar[$user_type])) {
/*
* STUDENTS
*/
// $users[$tester_name] = $tester_dh->get_list_of_tutored_users($userObj->id_user);
if (!$userObj->isSuper()) {
$students_Ar = $tester_dh->get_list_of_tutored_unique_users($userObj->id_user);
} else {
$students_Ar = $tester_dh->get_users_by_type(array(AMA_TYPE_STUDENT), $retrieve_extended_data);
}
// $users[$tester_name] = $tester_dh->get_users_by_type($user_types_Ar[AMA_TYPE_TUTOR], $retrieve_extended_data);
if (AMA_DataHandler::isError($students_Ar) || !is_array($students_Ar)) {
$students_Ar = array();
}
} else {
$students_Ar = array();
}
if (in_array(AMA_TYPE_TUTOR, $user_types_Ar[$user_type])) {
/*
* TUTORS
*/
$tutors_Ar = $tester_dh->get_users_by_type(array(AMA_TYPE_TUTOR), $retrieve_extended_data);
if (AMA_DataHandler::isError($tutors_Ar) || !is_array($tutors_Ar)) {
$tutors_Ar = array();
}
} else {
$tutors_Ar = array();
}
if (in_array(AMA_TYPE_SWITCHER, $user_types_Ar[$user_type])) {
/*
* SWITCHERS
*/
$switchers_Ar = $tester_dh->get_users_by_type(array(AMA_TYPE_SWITCHER), $retrieve_extended_data);
if (AMA_DataHandler::isError($switchers_Ar) || !is_array($switchers_Ar)) {
$switchers_Ar = array();
}
} else {
$switchers_Ar = array();
}
$users[$tester_name] = array_merge($tutors_Ar, $students_Ar, $switchers_Ar);
//.........这里部分代码省略.........
示例4: instance
/**
* calls and sets the parent instance method, and if !MULTIPROVIDER
* checks if module_login_providers table is in the provider db.
*
* If found, use the provider DB else use the common
*
* @param string $dsn
*/
static function instance($dsn = null)
{
if (!MULTIPROVIDER && is_null($dsn)) {
$dsn = MultiPort::getDSN($GLOBALS['user_provider']);
}
$theInstance = parent::instance($dsn);
if (is_null(self::$dbToUse)) {
self::$dbToUse = AMA_Common_DataHandler::instance();
if (!MULTIPROVIDER && !is_null($dsn)) {
// must check if passed $dsn has the module login tables
// execute this dummy query, if result is not an error table is there
$sql = 'SELECT NULL FROM `' . self::$PREFIX . 'providers`';
// must use AMA_DataHandler because we are not able to
// query AMALoginDataHandelr in this method!
$ok = AMA_DataHandler::instance($dsn)->getOnePrepared($sql);
if (!AMA_DB::isError($ok)) {
self::$dbToUse = $theInstance;
}
}
}
return $theInstance;
}
示例5: get_subscription
function get_subscription($id_user)
{
/*
* troppo lenta....
*/
// versione che cicla sulle iscrizioni ad un servizio
$common_dh = $GLOBALS['common_dh'];
// servizio
$service_courseAr = $common_dh->get_service_implementors();
// corso
foreach ($service_courseAr as $service_implementor) {
$id_service = $service_implementor['id_servizio'];
$id_course = $service_implementor['id_corso'];
//tester
$providerId = get_tester_for_service($id_service);
$provider_dataHa = $common_dh->get_tester_info_from_id($id_tester);
$provider_pointer = $provider_dataHa[11];
$provider_dsn = Multiport::getDSN($provider_pointer);
if ($provider_dsn != null) {
$provider_dh = AMA_DataHandler::instance($provider_dsn);
// istanze per corso
$all_instance = $provider_dh->get_course_instance_for_this_student_and_course_model($id_user, $id_course);
//...
}
}
}
示例6: findImplementor
public static function findImplementor($implementorId)
{
$common_dh = $GLOBALS['common_dh'];
//$provider_dataHa = $common_dh->get_tester_info_from_id($id_provider);
$provider_dataHa = $common_dh->get_tester_info_from_id_course($implementorId);
if (AMA_DataHandler::isError($provider_dataHa)) {
// ?
} else {
$provider_dsn = Multiport::getDSN($provider_dataHa['puntatore']);
if ($provider_dsn != null) {
$provider_dh = AMA_DataHandler::instance($provider_dsn);
if (AMA_DataHandler::isError($provider_dh)) {
return $provider_dh;
} else {
$courseAr = $provider_dh->get_course($implementorId);
if (AMA_DataHandler::isError($courseAr)) {
// continue
$courseAr = array();
$courseAr['id_course'] = $implementorId;
} else {
if (!isset($courseAr['id_nodo_iniziale'])) {
$courseAr['id_nodo_iniziale'] = 0;
}
$id_start_node = $courseAr['id_nodo_iniziale'];
$id_desc = $implementorId . "_" . $id_start_node;
$user_level = "999";
$nodeHa = $provider_dh->get_node_info($id_desc);
if (AMA_DataHandler::isError($nodeHa)) {
// continue
$nodeHa = array();
$nodeHa['text'] = NULL;
}
}
}
}
}
$serviceImplementorObj = new Service_implementor($provider_dataHa, $courseAr, $nodeHa);
return $serviceImplementorObj;
}
示例7: ADA_Error
if (AMA_Common_DataHandler::isError($tester_infoAr)) {
$errObj = new ADA_Error($tester_infoAr);
} else {
$testersAr = array();
$tester_dataAr = array(array(translateFN('id'), $tester_infoAr[0]), array(translateFN('Nome'), $tester_infoAr[1]), array(translateFN('Ragione Sociale'), $tester_infoAr[2]), array(translateFN('Indirizzo'), $tester_infoAr[3]), array(translateFN('Città'), $tester_infoAr[4]), array(translateFN('Provincia'), $tester_infoAr[5]), array(translateFN('Nazione'), $tester_infoAr[6]), array(translateFN('Telefono'), $tester_infoAr[7]), array(translateFN('E-mail'), $tester_infoAr[8]), array(translateFN('Descrizione'), $tester_infoAr[11]), array(translateFN('Responsabile'), $tester_infoAr[9]), array(translateFN('Puntatore al database'), $tester_infoAr[10]));
//$tester_data = BaseHtmlLib::tableElement('',array(),$tester_dataAr);
$tester_data = AdminModuleHtmlLib::displayTesterInfo($id_tester, $tester_dataAr);
$services_dataAr = $common_dh->get_info_for_tester_services($id_tester);
if (AMA_Common_DataHandler::isError($services_dataAr)) {
$errObj = new ADA_Error($services_dataAr);
} else {
$tester_services = AdminModuleHtmlLib::displayServicesOnThisTester($id_tester, $services_dataAr);
}
$tester_dsn = MultiPort::getDSN($tester_infoAr[10]);
if ($tester_dsn != NULL) {
$tester_dh = AMA_DataHandler::instance($tester_dsn);
$users_on_this_tester = $tester_dh->count_users_by_type(array(AMA_TYPE_STUDENT, AMA_TYPE_AUTHOR, AMA_TYPE_TUTOR, AMA_TYPE_SWITCHER, AMA_TYPE_ADMIN));
if (AMA_DataHandler::isError($users_on_this_tester)) {
$errObj = new ADA_Error($users_on_this_tester);
} else {
$users_list_link = CDOMElement::create('div', 'id:tester_users');
$users_list_link->addChild(new CText(translateFN('Numero di utenti presenti sul tester: ') . $users_on_this_tester));
$link = CDOMElement::create('a', 'href:list_users.php?id_tester=' . $id_tester);
$link->addChild(new CText(translateFN('Lista utenti')));
$users_list_link->addChild($link);
}
}
}
} else {
/*
* non e' stato passato id_tester
示例8: _get_last_accessFN
/**
*
* @param $id_course_instance
* @return array
*/
private function _get_last_accessFN($id_course_instance = "", $provider_dh, $return_dateonly = true)
{
// if used by student before entering a course, we must pass the DataHandler
if ($provider_dh == NULL) {
$provider_dh = $GLOBALS['dh'];
}
//$error = $GLOBALS['error'];
// $debug = $GLOBALS['debug'];
$sess_id_user = $_SESSION['sess_id_user'];
if (!isset($this->id_user)) {
$id_user = $sess_id_user;
} else {
$id_user = $this->id_user;
}
if ($id_course_instance) {
$last_visited_node = $provider_dh->get_last_visited_nodes($id_user, $id_course_instance, 10);
/*
* vito, 10 ottobre 2008: $last_visited_node è Array([0]=>Array([id_nodo], ...))
*/
if (!AMA_DB::isError($last_visited_node) && is_array($last_visited_node) && isset($last_visited_node[0])) {
$last_visited_time = $return_dateonly ? AMA_DataHandler::ts_to_date($last_visited_node[0]['data_uscita']) : $last_visited_node[0]['data_uscita'];
return array($last_visited_node[0]['id_nodo'], $last_visited_time);
} else {
return "-";
}
} else {
/*
* Sara, 2/07/2014
* return the last access between all instances course
*/
$serviceProviders = $this->getTesters();
if (!empty($serviceProviders) && is_array($serviceProviders)) {
$i = 0;
foreach ($serviceProviders as $Provider) {
$provider_dh = AMA_DataHandler::instance(MultiPort::getDSN($Provider));
$courseInstances_provider = $provider_dh->get_course_instances_for_this_student($this->getId());
if (AMA_DataHandler::isError($courseInstances_provider)) {
$courseInstances_provider = new ADA_Error($courseInstances_provider);
} else {
$istance_testerAr[$i] = array('istances' => $courseInstances_provider, 'provider' => $Provider);
}
$i++;
}
}
if (!empty($istance_testerAr)) {
$Max = 0;
$id_nodo = null;
foreach ($istance_testerAr as $istanceTs) {
$courseInstancesAr = $istanceTs['istances'];
$pointer = $istanceTs['provider'];
$tester = AMA_DataHandler::instance(MultiPort::getDSN($pointer));
foreach ($courseInstancesAr as $courseInstance) {
$id_instance = $courseInstance['id_istanza_corso'];
$last_access = $tester->get_last_visited_nodes($id_user, $id_instance, 10);
if (!AMA_DB::isError($last_access) && is_array($last_access) && count($last_access)) {
$last_accessAr = array($last_access[0]['id_nodo'], $last_access[0]['data_uscita']);
if ($last_accessAr[1] > $Max) {
$id_nodo = $last_accessAr[0];
$Max = $last_accessAr[1];
}
}
}
}
$Last_accessAr = array(0 => $id_nodo, 1 => $Max);
return $Last_accessAr;
} else {
return "-";
}
}
}
示例9: disconnect
public function disconnect()
{
parent::disconnect();
self::$instance = NULL;
}
示例10: checkAndSetPublicTester
/**
* checks if the passed object type and id are coming from the public tester.
* If true sets the needed GLOBALS['dh'] session variables accordingly.
*
* @param string $objType either 'course' or 'node'
* @param string $objID object id to be checked and loaded if need be
*
* return true if invalid has to be set to true on the caller
*/
function checkAndSetPublicTester($objType, $objID)
{
$common_dh = $GLOBALS['common_dh'];
if ($objType !== 'course' || is_null($objID)) {
$tmp_id_course = isset($_REQUEST['id_course']) ? DataValidator::is_uinteger($_REQUEST['id_course']) : false;
if ($tmp_id_course === false) {
$tmp_id_course = isset($_REQUEST['id_node']) ? substr($_REQUEST['id_node'], 0, strpos($_REQUEST['id_node'], '_')) : false;
}
if ($tmp_id_course === false) {
$tmp_id_course = isset($_SESSION['sess_id_course']) ? DataValidator::is_uinteger($_SESSION['sess_id_course']) : false;
}
if ($tmp_id_course === false) {
$tmp_id_course = isset($_SESSION['sess_id_node']) ? substr($_SESSION['sess_id_node'], 0, strpos($_SESSION['sess_id_node'], '_')) : false;
}
} else {
$tmp_id_course = $objID;
}
if ($tmp_id_course !== false) {
// get the tester for the passed id_course
$tester_infoAr = $common_dh->get_tester_info_from_id_course($tmp_id_course);
// get the service info for the passed id_course
$service_inforAr = $common_dh->get_service_type_info_from_course($tmp_id_course);
// check that the tester is valid and is the public one and
// check that the service is valid and is a public one
if (!AMA_DB::isError($tester_infoAr) && is_array($tester_infoAr) && isset($tester_infoAr['puntatore']) && $tester_infoAr['puntatore'] == ADA_PUBLIC_TESTER && !AMA_DB::isError($service_inforAr) && is_array($service_inforAr) && isset($service_inforAr['isPublic']) && intval($service_inforAr['isPublic']) !== 0) {
// save the dh, if a restrore is needed afterwards
$olddh = $GLOBALS['dh'];
// load the dh
$dh = AMA_DataHandler::instance(MultiPort::getDSN($tester_infoAr['puntatore']));
if (!AMA_DB::isError($dh)) {
// check the object
if ($objType == 'node') {
$dataHa = $dh->get_node_info($objID);
if (AMA_DB::isError($dataHa) || !is_array($dataHa)) {
$retval = true;
// restore the saved datahandler
$GLOBALS['dh'] = $olddh;
} else {
$retval = false;
// set the datahandler
$GLOBALS['dh'] = $dh;
$_SESSION['sess_id_node'] = $objID;
$_SESSION['sess_id_course'] = $tmp_id_course;
}
} else {
if ($objType == 'course') {
// set the datahandler
$GLOBALS['dh'] = $dh;
$sess_courseObj = read_course($objID);
if (AMA_DB::isError($sess_courseObj) || !$sess_courseObj instanceof Course) {
$retval = true;
// restore the saved datahandler
$GLOBALS['dh'] = $olddh;
} else {
$retval = false;
$_SESSION['sess_courseObj'] = $sess_courseObj;
$_SESSION['sess_id_course'] = $objID;
}
}
}
}
}
}
return isset($retval) ? $retval : true;
}
示例11: log_report
public static function log_report($pointer = NULL, $Services_Type = NULL)
{
$log_dataAr = array();
$common_dh = $GLOBALS['common_dh'];
$filedArray = array('nome', 'ragione_sociale');
if (isset($pointer)) {
$testers_list = $common_dh->get_tester_info_from_pointer($pointer);
if (!AMA_DB::isError($testers_list)) {
$tester_name = $testers_list[1];
$tester = $pointer;
$tester_dsn = self::getDSN($tester);
if ($tester_dsn != null) {
$tester_dh = AMA_DataHandler::instance($tester_dsn);
$result = $tester_dh->tester_log_report($tester_name, null);
if (!AMA_DB::isError($result)) {
$result['provider'] = $tester_name;
$log_dataAr[$tester] = $result;
}
}
}
} else {
$testers_list = $common_dh->get_all_testers($filedArray);
if (!AMA_DB::isError($testers_list)) {
foreach ($testers_list as $testerAr) {
$tester_name = $testerAr['nome'];
$tester = $testerAr['puntatore'];
$tester_dsn = self::getDSN($tester);
if ($tester_dsn != null) {
$tester_dh = AMA_DataHandler::instance($tester_dsn);
$result = $tester_dh->tester_log_report($tester_name, $Services_Type);
if (!AMA_DB::isError($result)) {
$result['provider'] = $tester_name;
$log_dataAr[$tester] = $result;
}
}
}
}
}
return $log_dataAr;
}
示例12: setTerminatedStatusForInstance
/**
* Sets the terminated status for the passed courseId and courseInstanceId
* It is usually called from user.php when the user has a subscried status
* and the subscription_date + duration_subscription is in the past.
*
* @param number $courseId
* @param number $courseInstanceId
*
* @return AMA_Error on error or true on success
*
* @access public
*
* @author giorgio 03/apr/2015
*/
public function setTerminatedStatusForInstance($courseId, $courseInstanceId)
{
$common_dh = $GLOBALS['common_dh'];
require_once ROOT_DIR . '/switcher/include/Subscription.inc.php';
$s = new Subscription($this->getId(), $courseInstanceId);
$s->setSubscriptionStatus(ADA_STATUS_TERMINATED);
$s->setStartStudentLevel(null);
// null means no level update
// search the provider of the current iteration course
$courseProv = $common_dh->get_tester_info_from_id_course($courseId);
if (!AMA_DB::isError($courseProv) && is_array($courseProv) && isset($courseProv['puntatore'])) {
// save the datahandler
$savedDH = $GLOBALS['dh'];
// set the datahandler to be used
$GLOBALS['dh'] = AMA_DataHandler::instance(MultiPort::getDSN($courseProv['puntatore']));
// update the subscription
$retval = Subscription::updateSubscription($s);
// restore the datahandler
$GLOBALS['dh'] = $savedDH;
$GLOBALS['dh']->disconnect();
}
return isset($retval) ? $retval : null;
}