Example #1
0
 public static function hSet($key, $field, $value)
 {
     if (is_array($value) || is_Object($value)) {
         $value = json_encode($value);
     }
     return self::connection()->hset($key, $field, $value);
 }
Example #2
0
 public function hSet($key, $field, $value)
 {
     if (is_array($value) || is_Object($value)) {
         $value = json_encode($value);
     }
     return $this->connection->hset($key, $field, $value);
 }
Example #3
0
function print_ro($object, $alsoIgnore = array(), $tab = 0)
{
    // prints an object/array, but removes the $parent, and anything inside alsoIgnore
    $pad = "";
    if (!in_array('parent', $alsoIgnore)) {
        $alsoIgnore[] = "parent";
    }
    for ($c = 0; $c < $tab; $c++) {
        $pad .= "\t";
    }
    foreach ($object as $key => $value) {
        if (!is_numeric($key) && in_array($key, $alsoIgnore)) {
            echo $pad . $key . " => *HIDDEN*\n";
        } else {
            if (is_Array($value) || is_Object($value)) {
                if (is_Array($value)) {
                    echo "{$pad}{$key} => Array (\n";
                } else {
                    echo "{$pad}{$key} => Object (\n";
                }
                print_ro($value, $alsoIgnore, $tab + 1);
                echo $pad . ")\n";
            } else {
                echo $pad . $key . " => " . $value . "\n";
            }
        }
    }
}
Example #4
0
 public function getUserId($username = '')
 {
     if ($username == '') {
         $userRecord = UserRecord::finder()->find('user_username = ?', $this->Name);
     } else {
         $userRecord = UserRecord::finder()->find('user_username = ?', $username);
     }
     if (is_Object($userRecord)) {
         return $userRecord->idtm_user;
     } else {
         return 0;
     }
 }
 function debugObject($obj, $indent = 0)
 {
     if (is_Array($obj) || is_Object($obj)) {
         $return = '';
         while (list($k, $v) = each($obj)) {
             for ($i = 0; $i < $indent; $i++) {
                 $return .= '&nbsp;';
             }
             $return .= $k . "->{$v}\n";
             $return .= $this->debugObject($v, $indent + 1);
         }
         return $return;
     }
 }
 public static function register($ClassName)
 {
     $Obj = self::singleton();
     $ClassName = strtolower($ClassName);
     if ($Obj->getObject($ClassName) != NULL) {
         return $Obj->getObject($ClassName);
     }
     $Class = $ClassName;
     $Obj->setObject($ClassName, new $Class());
     $Object = $Obj->getObject($ClassName);
     if (is_Object($Object)) {
         return $Object;
     }
 }
Example #7
0
 /**
  * Populates the datagrid with user lists.
  * This method is invoked by the framework when initializing the page
  * @param mixed event parameter
  */
 public function onInit($param)
 {
     parent::onInit($param);
     if (!$this->IsPostBack) {
         // get the total number of posts available
         $criteria = new TActiveRecordCriteria();
         $criteria->Condition = 'idtm_user = :idtm_user';
         $criteria->Parameters[':idtm_user'] = $this->User->getUserId($this->User->Name);
         if (is_Object(ParteiRecord::finder()->find($criteria))) {
             $this->Repeater->VirtualItemCount = ParteiRecord::finder()->find($criteria)->count();
         }
         // populates post data into the repeater
         $this->populateData();
     }
 }
 public function onKernelRequest(GetResponseEvent $event)
 {
     $route = $event->getRequest()->attributes->get('_route');
     if ($route == 'livraison' || $route == 'validation') {
         if ($this->session->has('panier')) {
             if (count($this->session->get('panier')) == 0) {
                 $event->setResponse(new RedirectResponse($this->router->generate('panier')));
             }
         }
         if (!is_Object($this->securityContext->getToken()->getUser())) {
             $this->session->getFlashBag()->add('notification', 'Vous devez vous identifier');
             $event->setResponse(new RedirectResponse($this->router->generate('fos_user_security_login')));
         }
     }
 }
 public function setValue($request, $response)
 {
     $id = $request->id;
     $vars['type'] = $request->type;
     $vars['status'] = $request->status;
     $vars['comment'] = $request->getRequest('comment');
     $admin = UserClient::getInstance()->getCurrentUser();
     $id = UserClient::getInstance()->modifyUserAdvice($id, $vars, $admin);
     $userAdvice = DAL::get()->find('UserAdvice', $id);
     if (is_Object($userAdvice) && $userAdvice->source == '管理员发起的认证任务' && $vars['status'] == -1) {
         $predoctor = DAL::get()->find_by_userid('predoctor', $userAdvice->user->id);
         $inspector = DAL::get()->find_by_userid('inspector', $admin->id);
         if (false == $predoctor->isNull() && false == $inspector->isNull()) {
             PreDoctorClient::getInstance()->setResultNo($predoctor->id, $inspector->id);
         }
     }
     return self::DIRECT_OUTPUT;
 }
 public function saveStrukturBericht($sender, $param)
 {
     $mySession = "";
     $mySession = UserFelderRecord::finder()->findAllBy_user_id($this->User->getUserId($this->User->Name));
     foreach ($mySession as $myFieldRecord) {
         $arr_newValues = array();
         //very important!!! otherwise we have values which dont exist
         $arr_MyFields = array();
         $uniqueID = $myFieldRecord->tuf_feldname;
         //lets start the saving
         //$UniqueID = 'xxx'.$inp_per_year.'xxx'.$inp_per_month.'xxx'.$inp_idta_struktur_type.'xxx'.$inp_idta_feldfunktion.'xxx'.$inp_idtm_struktur.'xxx'.$inp_idta_variante.'xxx';
         //$SaveString = $jahr."xxx".$monat."xxx".$local_ff."xxx".$local_id; definition of the string to pass
         $arr_MyFields = preg_split("/xxx/", $uniqueID);
         $tt_per_year = $arr_MyFields[1];
         $tt_per_month = $arr_MyFields[2];
         $tt_idta_struktur_type = $arr_MyFields[3];
         $tt_idta_feldfunktion = $arr_MyFields[4];
         $tt_idtm_struktur = $arr_MyFields[5];
         $tt_idta_variante = $arr_MyFields[6];
         //abrufen des aktuellen DB-Wertes
         $ExistingValue = WerteRecord::finder()->findBySql("SELECT w_wert FROM tt_werte WHERE idtm_struktur = '" . $tt_idtm_struktur . "' AND idta_feldfunktion = '" . $tt_idta_feldfunktion . "' AND w_jahr = '" . $tt_per_year . "' AND w_monat = '" . $tt_per_month . "' AND w_id_variante = '" . $tt_idta_variante . "' LIMIT 1");
         //formatieren, damit es mit dem inhalt aus der zelle vergleichbar wird
         //CHECKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKK
         if (is_Object($ExistingValue)) {
             $CompareValue = number_format($ExistingValue->w_wert, 2, '.', '');
         } else {
             $CompareValue = "0.00";
         }
         //here I start the magic server calculation;)
         if ($CompareValue === $this->page->ACTPanel->FindControl($uniqueID)->Text) {
         } else {
             $ObjSaver = new PFBackCalculator();
             $ObjSaver->setVariante($tt_idta_variante);
             $ObjSaver->setStartPeriod($tt_per_month);
             $ObjSaver->setStartNode($tt_idtm_struktur);
             //$SaveString = $tt_per_year."xxx".$tt_per_month."xxx".$tt_idta_feldfunktion."xxx".$tt_idtm_struktur;
             //$NEWWerteRecord = WerteRecord::finder()->findBySql("SELECT * FROM tt_werte WHERE idtm_struktur = '".$tt_idtm_struktur."' AND idta_feldfunktion = '".$tt_idta_feldfunktion."' AND w_jahr = '".$tt_per_year."' AND w_monat = '".$tt_per_month."' AND w_id_variante = '".$tt_idta_variante."' LIMIT 1");
             $arr_newValues[$tt_idta_feldfunktion] = $this->page->ACTPanel->FindControl($uniqueID)->Text;
             $ObjSaver->setNewValues($arr_newValues);
             $ObjSaver->run();
             unset($ObjSaver);
         }
     }
     $sender->Text = "Saved";
 }
Example #11
0
 /**
  * Load article list of this product and store in private class variable
  *
  * @return array Article uids
  */
 public function loadArticles()
 {
     if ($this->articlesLoaded == FALSE) {
         $uidToLoadFrom = $this->uid;
         if ($this->getT3verOid() > 0 && $this->getT3verOid() != $this->uid && (is_Object($GLOBALS['TSFE']) && $GLOBALS['TSFE']->beUserLogin)) {
             $uidToLoadFrom = $this->getT3verOid();
         }
         if ($this->articles_uids = $this->databaseConnection->getArticles($uidToLoadFrom)) {
             foreach ($this->articles_uids as $articleUid) {
                 /**
                  * Article
                  *
                  * @var Tx_Commerce_Domain_Model_Article $article
                  */
                 $article = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('Tx_Commerce_Domain_Model_Article', $articleUid, $this->lang_uid);
                 $article->loadData();
                 $this->articles[$articleUid] = $article;
             }
             $this->articlesLoaded = TRUE;
             return $this->articles_uids;
         } else {
             return FALSE;
         }
     }
     return $this->articles_uids;
 }
Example #12
0
/**
 * 获取当前堆栈.
 */
function getBacktrace() {
	$traces = debug_backTrace ();
	$str = "\n\nback trace:";
	for($i = 1; $i < count ( $traces ); $i ++) {
		$trace = $traces [$i];
		$class = @$trace ['class'] ? @$trace ['class'] . @$trace ['type'] : '';
		$str .= "\n##$i " . @$trace ['file'] . " (" . @$trace ['line'] . "), call function $class" . @$trace ['function'] . "(";
		if ($i > 1) {
			foreach ( @$trace ['args'] as $arg ) {
				if (is_array ( $arg )) {
					$str .= "Array, ";
				} else if (is_Object ( $arg )) {
					$str .= "Object, ";
				} else if (is_bool ( $arg )) {
					$str .= $arg ? 'true, ' : 'false, ';
				} else {
					$str .= "$arg, ";
				}
			}
		}
		$str .= ");";
	}
	return $str;
}
Example #13
0
 /**
  * Load article list of this product and store in private class variable.
  *
  * @return array Article uids
  */
 public function loadArticles()
 {
     if (!is_array($this->articles)) {
         $uidToLoadFrom = $this->uid;
         if ($this->getT3verOid() > 0 && $this->getT3verOid() != $this->uid && (is_Object($this->getFrontendController()) && $this->getFrontendController()->beUserLogin)) {
             $uidToLoadFrom = $this->getT3verOid();
         }
         $this->articles = array();
         if ($this->articles_uids = $this->databaseConnection->getArticles($uidToLoadFrom)) {
             foreach ($this->articles_uids as $articleUid) {
                 /**
                  * Article.
                  *
                  * @var \CommerceTeam\Commerce\Domain\Model\Article $article
                  */
                 $article = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('CommerceTeam\\Commerce\\Domain\\Model\\Article', $articleUid, $this->lang_uid);
                 $article->loadData();
                 $this->articles[$articleUid] = $article;
             }
             return $this->articles_uids;
         } else {
             return false;
         }
     }
     return $this->articles_uids;
 }
Example #14
0
 /**
  *
  * @author Max Milbers
  * @param unknown_type $currency
  * @param unknown_type $price
  * @param unknown_type $shop
  */
 function convertCurrencyTo($currency, $price, $shop = true)
 {
     if (empty($currency)) {
         // 			vmdebug('empty  $currency ',$price);
         return $price;
     }
     // If both currency codes match, do nothing
     if (is_Object($currency) and $currency->_currency_id == $this->_vendorCurrency or !is_Object($currency) and $currency == $this->_vendorCurrency) {
         // 			vmdebug('  $currency == $this->_vendorCurrency ',$price);
         return $price;
     }
     /*		if($shop){
     			// TODO optimize this... the exchangeRate cant be cached, there are more than one currency possible
     		//			$exchangeRate = &$this->exchangeRateVendor;
     		$exchangeRate = 0;
     		} else {
     		//caches the exchangeRate between shopper and vendor
     		$exchangeRate = &$this->exchangeRateShopper;
     		}
     		*/
     //		if(empty($exchangeRate)){
     if (is_Object($currency)) {
         $exchangeRate = $currency->exchangeRateShopper;
         vmdebug('convertCurrencyTo OBJECT ' . $exchangeRate);
     } else {
         //				$this->_db = JFactory::getDBO();
         $q = 'SELECT `currency_exchange_rate` FROM `#__virtuemart_currencies` WHERE `virtuemart_currency_id` ="' . (int) $currency . '" ';
         $this->_db->setQuery($q);
         $exch = $this->_db->loadResult();
         // 				vmdebug('begin convertCurrencyTo '.$exch);
         if (!empty($exch) and $exch !== '0.00000') {
             $exchangeRate = $exch;
         } else {
             $exchangeRate = FALSE;
         }
     }
     //	}
     $this->exchangeRateShopper = $exchangeRate;
     // 		vmdebug('convertCurrencyTo my currency ',$exchangeRate,$currency);
     if (!empty($exchangeRate) && $exchangeRate != FALSE) {
         //vmdebug('convertCurrencyTo Use custom rate');
         if ($shop) {
             $price = $price / $exchangeRate;
         } else {
             $price = $price * $exchangeRate;
         }
         // 			vmdebug('!empty($exchangeRate) && $exchangeRate!=FALSE '.$price.' '.$exchangeRate);
     } else {
         $currencyCode = self::ensureUsingCurrencyCode($currency);
         $vendorCurrencyCode = self::ensureUsingCurrencyCode($this->_vendorCurrency);
         $globalCurrencyConverter = JRequest::getVar('globalCurrencyConverter');
         if ($shop) {
             //$oldprice = $price;
             $price = $this->_currencyConverter->convert($price, $currencyCode, $vendorCurrencyCode);
             //vmdebug('convertCurrencyTo Use dynamic rate in shop '.$oldprice .' => '.$price);
         } else {
             //vmdebug('convertCurrencyTo Use dynamic rate to shopper currency '.$price);
             $price = $this->_currencyConverter->convert($price, $vendorCurrencyCode, $currencyCode);
         }
         // 			vmdebug('convertCurrencyTo my currency ',$this->exchangeRateShopper);
     }
     return $price;
 }
Example #15
0
 /**
  * Synchronize the object with the UF Match entry. Can be called stand-alone from
  * the drupalUsers script
  *
  * @param Object  $user    the drupal user object
  * @param string  $userKey the id of the user from the uf object
  * @param string  $uniqId    the OpenID of the user
  * @param string  $uf      the name of the user framework
  * @param integer $status  returns the status if user created or already exits (used for CMS sync)
  *
  * @return the ufmatch object that was found or created
  * @access public
  * @static
  */
 static function &synchronizeUFMatch(&$user, $userKey, $uniqId, $uf, $status = null, $ctype = null)
 {
     // validate that uniqId is a valid url. it will either be
     // an OpenID (which should always be a valid url) or a
     // http://uf_username/ construction (so that it can
     // be used as an OpenID in the future)
     require_once 'CRM/Utils/Rule.php';
     if ($uf == 'Standalone') {
         if (!CRM_Utils_Rule::url($uniqId)) {
             return $status ? null : false;
         }
     } else {
         if (!CRM_Utils_Rule::email($uniqId)) {
             return $status ? null : false;
         }
     }
     $newContact = false;
     // make sure that a contact id exists for this user id
     $ufmatch =& new CRM_Core_DAO_UFMatch();
     if (CRM_Core_DAO::checkFieldExists('civicrm_uf_match', 'domain_id')) {
         // FIXME: if() condition check was required especially for upgrade cases (2.2.x -> 3.0.x),
         // where folks if happen to logout, would encounter a column not found fatal error
         $ufmatch->domain_id = CRM_Core_Config::domainID();
     }
     $ufmatch->uf_id = $userKey;
     if (!$ufmatch->find(true)) {
         require_once 'CRM/Core/Transaction.php';
         $transaction = new CRM_Core_Transaction();
         if (!empty($_POST)) {
             $params = $_POST;
             $params['email'] = $uniqId;
             require_once 'CRM/Dedupe/Finder.php';
             $dedupeParams = CRM_Dedupe_Finder::formatParams($params, 'Individual');
             $ids = CRM_Dedupe_Finder::dupesByParams($dedupeParams, 'Individual');
             if (!empty($ids)) {
                 $dao = new CRM_Core_DAO();
                 $dao->contact_id = $ids[0];
             }
         } else {
             require_once 'CRM/Contact/BAO/Contact.php';
             if ($uf == 'Standalone') {
                 $dao =& CRM_Contact_BAO_Contact::matchContactOnOpenId($uniqId, $ctype);
             } else {
                 $dao =& CRM_Contact_BAO_Contact::matchContactOnEmail($uniqId, $ctype);
             }
         }
         if ($dao) {
             //print "Found contact with uniqId $uniqId<br/>";
             $ufmatch->contact_id = $dao->contact_id;
             $ufmatch->uf_name = $uniqId;
         } else {
             if ($uf == 'Drupal') {
                 $mail = 'mail';
             } else {
                 $mail = 'email';
             }
             if (is_Object($user)) {
                 $params = array('email-Primary' => $user->{$mail});
             }
             if ($ctype == 'Organization') {
                 $params['organization_name'] = $uniqId;
             } else {
                 if ($ctype == 'Household') {
                     $params['household_name'] = $uniqId;
                 }
             }
             if (!$ctype) {
                 $ctype = "Individual";
             }
             $params['contact_type'] = $ctype;
             // extract first / middle / last name
             // for joomla
             if ($uf == 'Joomla' && $user->name) {
                 require_once 'CRM/Utils/String.php';
                 CRM_Utils_String::extractName($user->name, $params);
             }
             if ($uf == 'Standalone') {
                 $params['openid-Primary'] = $uniqId;
                 //need to delete below code once profile is
                 //exposed on signup page
                 if (!empty($user->first_name) || !empty($user->last_name)) {
                     $params['first_name'] = $user->first_name;
                     $params['last_name'] = $user->last_name;
                 } elseif (!empty($user->name)) {
                     require_once 'CRM/Utils/String.php';
                     CRM_Utils_String::extractName($user->name, $params);
                 }
             }
             $contactId = CRM_Contact_BAO_Contact::createProfileContact($params, CRM_Core_DAO::$_nullArray);
             $ufmatch->contact_id = $contactId;
             $ufmatch->uf_name = $uniqId;
         }
         $ufmatch->save();
         $ufmatch->free();
         $newContact = true;
         $transaction->commit();
     }
     if ($status) {
         return $newContact;
     } else {
         return $ufmatch;
     }
 }
Example #16
0
 public function view_Organisation($idtm_organisation)
 {
     $myitem = OrganisationRecord::finder()->findByPK($idtm_organisation);
     $tempus = 'RCed' . $this->RCprimarykey;
     $monus = $this->RCprimarykey;
     $this->{$tempus}->Text = $myitem->{$monus};
     $this->bindListAdress();
     $this->bindListKom();
     $this->viewMainAdress($idtm_organisation);
     //HIDDEN
     foreach ($this->RChiddenfields as $recordfield) {
         $edrecordfield = 'RCed' . $recordfield;
         $this->{$edrecordfield}->setText($myitem->{$recordfield});
     }
     //DATUM
     foreach ($this->RCdatfields as $recordfield) {
         $edrecordfield = 'RCed' . $recordfield;
         $this->{$edrecordfield}->setDate($myitem->{$recordfield});
     }
     //BOOL
     foreach ($this->RCboolfields as $recordfield) {
         $edrecordfield = 'RCed' . $recordfield;
         $this->{$edrecordfield}->setChecked($myitem->{$recordfield});
     }
     //TIME
     foreach ($this->RCtimefields as $recordfield) {
         $edrecordfield = 'RCed' . $recordfield;
         $my_time = explode(':', $myitem->{$recordfield});
         $my_time_text = $my_time[0] . ':' . $my_time[1];
         $this->{$edrecordfield}->Text = $my_time_text;
     }
     //NON DATUM
     foreach ($this->RCfields as $recordfield) {
         $edrecordfield = 'RCed' . $recordfield;
         $this->{$edrecordfield}->Text = $myitem->{$recordfield};
     }
     $this->RCedorganisation_edit_status->Text = 1;
     $ActualUser = UserRecord::finder()->findByidtm_user($this->RCedidtm_user->Text);
     if (is_Object($ActualUser)) {
         $this->suggest_idtm_user->Text = $ActualUser->user_username;
     } else {
         $this->suggest_idtm_user->Text = 0;
     }
     $this->loadBankkonto($this->{$tempus}->Text);
     $this->loadObjekt($this->{$tempus}->Text);
     $this->laborg_name->Text = $myitem->org_name;
     $ParentOrga = OrganisationRecord::finder()->findByidtm_organisation($myitem->parent_idtm_organisation);
     if (is_Object($ParentOrga)) {
         $this->labparentorg_name->Text = $ParentOrga->org_name . ', ' . $ParentOrga->org_vorname;
     }
     $this->labparentorg_name->CommandParameter = $myitem->parent_idtm_organisation;
     //Rechnungen
     //$this->Teddeb_id->Text = $myitem->$monus;
     //$this->Teddeb_tabelle->Text = 'tm_zeiterfassung';
     //$this->RechnungContainer->initParameters();
     $this->RechnungContainer->bindRechnungListe();
     //TASKPART
     $this->Tedsend_id->Text = $myitem->{$monus};
     $this->Tedauf_id->Text = $myitem->{$monus};
     $this->AufgabenContainerOrganisation->initParameters();
     $this->AufgabenContainerOrganisation->initYearPullDown();
     $this->AufgabenContainerOrganisation->bindListTAValue();
     $this->setPDFSteckbrief($myitem->{$monus});
     $this->bindListChildOrgListe();
 }
Example #17
0
 /**
  * Synchronize the object with the UF Match entry. Can be called stand-alone from
  * the drupalUsers script
  *
  * @param Object  $user    the drupal user object
  * @param string  $userKey the id of the user from the uf object
  * @param string  $uniqId    the OpenID of the user
  * @param string  $uf      the name of the user framework
  * @param integer $status  returns the status if user created or already exits (used for CMS sync)
  *
  * @return the ufmatch object that was found or created
  * @access public
  * @static
  */
 static function &synchronizeUFMatch(&$user, $userKey, $uniqId, $uf, $status = null, $ctype = null, $isLogin = false)
 {
     // validate that uniqId is a valid url. it will either be
     // an OpenID (which should always be a valid url) or a
     // http://uf_username/ construction (so that it can
     // be used as an OpenID in the future)
     require_once 'CRM/Utils/Rule.php';
     if ($uf == 'Standalone') {
         if (!CRM_Utils_Rule::url($uniqId)) {
             return $status ? null : false;
         }
     } else {
         if (!CRM_Utils_Rule::email($uniqId)) {
             return $status ? null : false;
         }
     }
     $newContact = false;
     // make sure that a contact id exists for this user id
     $ufmatch =& new CRM_Core_DAO_UFMatch();
     if (CRM_Core_DAO::checkFieldExists('civicrm_uf_match', 'domain_id')) {
         // FIXME: if() condition check was required especially for upgrade cases (2.2.x -> 3.0.x),
         // where folks if happen to logout, would encounter a column not found fatal error
         $ufmatch->domain_id = CRM_Core_Config::domainID();
     }
     $ufmatch->uf_id = $userKey;
     if (!$ufmatch->find(true)) {
         require_once 'CRM/Core/Transaction.php';
         $transaction = new CRM_Core_Transaction();
         if (!empty($_POST) && !$isLogin) {
             $params = $_POST;
             $params['email'] = $uniqId;
             require_once 'CRM/Dedupe/Finder.php';
             $dedupeParams = CRM_Dedupe_Finder::formatParams($params, 'Individual');
             $ids = CRM_Dedupe_Finder::dupesByParams($dedupeParams, 'Individual');
             if (!empty($ids) && defined('CIVICRM_UNIQ_EMAIL_PER_SITE') && CIVICRM_UNIQ_EMAIL_PER_SITE) {
                 // restrict dupeIds to ones that belong to current domain/site.
                 require_once 'CRM/Core/BAO/Domain.php';
                 $siteContacts = CRM_Core_BAO_Domain::getContactList();
                 foreach ($ids as $index => $dupeId) {
                     if (!in_array($dupeId, $siteContacts)) {
                         unset($ids[$index]);
                     }
                 }
                 $ids = array_values($ids);
                 //re-index the array
             }
             if (!empty($ids)) {
                 $dao = new CRM_Core_DAO();
                 $dao->contact_id = $ids[0];
             }
         } else {
             require_once 'CRM/Contact/BAO/Contact.php';
             if ($uf == 'Standalone') {
                 $dao =& CRM_Contact_BAO_Contact::matchContactOnOpenId($uniqId, $ctype);
             } else {
                 $dao =& CRM_Contact_BAO_Contact::matchContactOnEmail($uniqId, $ctype);
             }
         }
         if ($dao) {
             //print "Found contact with uniqId $uniqId<br/>";
             $ufmatch->contact_id = $dao->contact_id;
             $ufmatch->uf_name = $uniqId;
         } else {
             if ($uf == 'Drupal') {
                 $mail = 'mail';
             } else {
                 $mail = 'email';
             }
             if (is_Object($user)) {
                 $params = array('email-Primary' => $user->{$mail});
             }
             if ($ctype == 'Organization') {
                 $params['organization_name'] = $uniqId;
             } else {
                 if ($ctype == 'Household') {
                     $params['household_name'] = $uniqId;
                 }
             }
             if (!$ctype) {
                 $ctype = "Individual";
             }
             $params['contact_type'] = $ctype;
             // extract first / middle / last name
             // for joomla
             if ($uf == 'Joomla' && $user->name) {
                 require_once 'CRM/Utils/String.php';
                 CRM_Utils_String::extractName($user->name, $params);
             }
             if ($uf == 'Standalone') {
                 $params['openid-Primary'] = $uniqId;
                 //need to delete below code once profile is
                 //exposed on signup page
                 if (!empty($user->first_name) || !empty($user->last_name)) {
                     $params['first_name'] = $user->first_name;
                     $params['last_name'] = $user->last_name;
                 } elseif (!empty($user->name)) {
                     require_once 'CRM/Utils/String.php';
                     CRM_Utils_String::extractName($user->name, $params);
                 }
             }
             $contactId = CRM_Contact_BAO_Contact::createProfileContact($params, CRM_Core_DAO::$_nullArray);
             $ufmatch->contact_id = $contactId;
             $ufmatch->uf_name = $uniqId;
         }
         // check that there are not two CMS IDs matching the same CiviCRM contact - this happens when a civicrm
         // user has two e-mails and there is a cms match for each of them
         // the gets rid of the nasty fata error but still reports the error
         $sql = "\nSELECT uf_id\nFROM   civicrm_uf_match\nWHERE  ( contact_id = %1\nOR     uf_name      = %2\nOR     uf_id        = %3 )\nAND    domain_id    = %4\n";
         $params = array(1 => array($ufmatch->contact_id, 'Integer'), 2 => array($ufmatch->uf_name, 'String'), 3 => array($ufmatch->uf_id, 'Integer'), 4 => array($ufmatch->domain_id, 'Integer'));
         require_once 'CRM/Core/DAO.php';
         $conflict = CRM_Core_DAO::singleValueQuery($sql, $params);
         if (!$conflict) {
             $ufmatch->save();
             $ufmatch->free();
             $newContact = true;
             $transaction->commit();
         } else {
             $msg = ts("Contact ID %1 is a match for %2 user %3 but has already been matched to %4", array(1 => $ufmatch->contact_id, 2 => $uf, 3 => $ufmatch->uf_id, 4 => $conflict));
             unset($conflict);
         }
     }
     if ($status) {
         return $newContact;
     } else {
         return $ufmatch;
     }
 }
Example #18
0
 /**
  * Method to check needed tables columns
  *
  * @param    object $checkTable object of table, that must be installed
  *
  * @return    boolean        true if all is ok
  *
  * @since    1.0.1
  */
 public function checkTableColumns($checkTable)
 {
     if (!is_object($checkTable)) {
         return 0;
     }
     $_db = JFactory::getDbo();
     $neededColumns = array();
     $installedColumns = array();
     foreach ($checkTable->columns as $col) {
         if (is_Object($col)) {
             $neededColumns[] = JArrayHelper::fromObject($col, true);
         } else {
             $neededColumns[] = $col;
         }
     }
     foreach ($_db->getTableColumns($checkTable->name, false) as $col) {
         $installedColumns[] = JArrayHelper::fromObject($col, true);
     }
     // prepare check for col names
     $search_cols_1 = array();
     $search_cols_2 = array();
     foreach ($installedColumns as $col) {
         $search_cols_1[] = $col['Field'];
     }
     foreach ($neededColumns as $col) {
         $search_cols_2[] = $col['Column'];
     }
     // check for col names
     for ($i = 0; $i < count($neededColumns); $i++) {
         // check for needed col names
         if (array_search($neededColumns[$i]['Column'], $search_cols_1) === false) {
             $neededColumns[$i]['Null'] == 'NO' ? $null = ' NOT NULL' : ($null = '');
             isset($neededColumns[$i]['Default']) ? $default = ' DEFAULT ' . $_db->Quote($neededColumns[$i]['Default']) : ($default = '');
             echo '<p class="bw_tablecheck_warn">' . JText::sprintf('COM_BWPOSTMAN_MAINTENANCE_CHECK_TABLES_COMPARE_DIFF_COLS', $neededColumns[$i]['Column'], $checkTable->name) . '</p>';
             $query = "ALTER TABLE " . $_db->quoteName($checkTable->name) . " ADD " . $_db->quoteName($neededColumns[$i]['Column']) . ' ' . $neededColumns[$i]['Type'] . $null . $default . " AFTER " . $_db->quoteName($neededColumns[$i - 1]['Column']);
             $_db->setQuery($query);
             $insertCol = $_db->Execute($query);
             if (!$insertCol) {
                 echo '<p class="bw_tablecheck_error">' . JText::sprintf('COM_BWPOSTMAN_MAINTENANCE_CHECK_TABLES_COMPARE_DIFF_COL_CREATE_ERROR', $neededColumns[$i]['Column'], $checkTable->name) . '</p>';
                 return 0;
             } else {
                 echo str_pad('<p class="bw_tablecheck_ok">' . JText::sprintf('COM_BWPOSTMAN_MAINTENANCE_CHECK_TABLES_COMPARE_DIFF_COL_CREATE_SUCCESS', $neededColumns[$i]['Column'], $checkTable->name) . '</p>', 4096);
                 return 2;
                 // Durchlauf zurücksetzen
             }
         }
         // check for obsolete col names
         if (array_search($installedColumns[$i]['Field'], $search_cols_2) === false) {
             echo '<p class="bw_tablecheck_warn">' . JText::sprintf('COM_BWPOSTMAN_MAINTENANCE_CHECK_TABLES_COMPARE_DIFF2_COLS', $installedColumns[$i]['Field'], $checkTable->name) . '</p>';
             $query = "ALTER TABLE " . $_db->quoteName($checkTable->name) . " DROP " . $_db->quoteName($installedColumns[$i]['Field']);
             $_db->setQuery($query);
             $deleteCol = $_db->Execute($query);
             if (!$deleteCol) {
                 echo '<p class="bw_tablecheck_error">' . JText::sprintf('COM_BWPOSTMAN_MAINTENANCE_CHECK_TABLES_COMPARE_DIFF2_COL_CREATE_ERROR', $installedColumns[$i]['Field'], $checkTable->name) . '</p>';
                 return 0;
             } else {
                 echo str_pad('<p class="bw_tablecheck_ok">' . JText::sprintf('COM_BWPOSTMAN_MAINTENANCE_CHECK_TABLES_COMPARE_DIFF2_COL_CREATE_SUCCESS', $installedColumns[$i]['Field'], $checkTable->name) . '</p>', 4096);
                 return 2;
                 // Durchlauf zurücksetzen
             }
         }
     }
     echo str_pad('<p class="bw_tablecheck_ok">' . JText::sprintf('COM_BWPOSTMAN_MAINTENANCE_CHECK_TABLES_COMPARE_COLS_OK', $checkTable->name) . '</p>', 4096);
     for ($i = 0; $i < count($neededColumns); $i++) {
         $diff = array_udiff($neededColumns[$i], $installedColumns[$i], 'strcasecmp');
         if (!empty($diff)) {
             echo '<p class="bw_tablecheck_warn">' . JText::sprintf('COM_BWPOSTMAN_MAINTENANCE_CHECK_TABLES_COMPARE_DIFF_COL_ATTRIBUTES', implode(',', array_keys($diff)), $neededColumns[$i]['Column'], $checkTable->name) . '</p>';
             // install missing columns
             foreach (array_keys($diff) as $missingCol) {
                 $neededColumns[$i]['Null'] == 'NO' ? $null = ' NOT NULL' : ($null = '');
                 isset($neededColumns[$i]['Default']) ? $default = ' DEFAULT ' . $_db->Quote($neededColumns[$i]['Default']) : ($default = '');
                 $query = "ALTER TABLE " . $_db->quoteName($checkTable->name);
                 $query .= " MODIFY " . $_db->quoteName($neededColumns[$i]['Column']) . ' ' . $neededColumns[$i]['Type'] . $null . $default;
                 if (array_key_exists('Extra', $neededColumns[$i])) {
                     $query .= " " . $neededColumns[$i]['Extra'];
                 }
                 $_db->setQuery($query);
                 $alterCol = $_db->Execute($query);
                 if (!$alterCol) {
                     echo '<p class="bw_tablecheck_error">' . JText::sprintf('COM_BWPOSTMAN_MAINTENANCE_CHECK_TABLES_COMPARE_DIFF_COL_ATTRIBUTES_ERROR', $missingCol, $neededColumns[$i]['Column'], $checkTable->name) . '</p>';
                 } else {
                     echo str_pad('<p class="bw_tablecheck_ok">' . JText::sprintf('COM_BWPOSTMAN_MAINTENANCE_CHECK_TABLES_COMPARE_DIFF_COL_ATTRIBUTES_SUCCESS', $missingCol, $neededColumns[$i]['Column'], $checkTable->name) . '</p>', 4096);
                 }
             }
         }
     }
     echo str_pad('<p class="bw_tablecheck_ok">' . JText::sprintf('COM_BWPOSTMAN_MAINTENANCE_CHECK_TABLES_COMPARE_COLS_ATTRIBUTES_OK', $checkTable->name) . '</p>', 4096);
     return 1;
 }
Example #19
0
 function draw()
 {
     $r = new request();
     if ($r->cancel) {
         return "";
     }
     $object = new $this->callbackobject();
     if ($r->step == "") {
         $r->step = 1;
         $this->step = 1;
     } else {
         $step = $object->parsePage($r->step);
         // El proximo paso viene dado por el objeto
         $this->step = $step;
     }
     $out = "<form method=\"post\" action=\"" . $this->controller . "\">\n                                <input type=\"hidden\" name=\"step\" value=\"" . ($this->step + 1) . "\">";
     foreach ($r as $k => $v) {
         if (strpos($k, "__") === false && $k != "step" && $k != "next") {
             $out .= "<input type=\"hidden\" name=\"" . $k . "\" value=\"" . $v . "\">";
         }
     }
     if (is_Object($this->pages[$this->step])) {
         $out .= $this->pages[$this->step]->draw();
     }
     if ($this->pages[$r->step]->isfinish) {
         $object = new $this->callbackobject();
         $object->drop(new request());
     }
     return $out;
 }
Example #20
0
 public function __construct($template, $CSS_filename, $user_name, $course_title, $node_title = "", $meta_keywords = "", $author = "", $meta_refresh_time = "", $meta_refresh_url = "", $onload_func = "", $layoutObj = NULL)
 {
     $HTTP_USER_AGENT = $_SERVER['HTTP_USER_AGENT'];
     $root_dir = $GLOBALS['root_dir'];
     $http_root_dir = $GLOBALS['http_root_dir'];
     $keywords = "ADA, Lynx, ";
     $keywords .= ADA_METAKEYWORDS;
     // from config file
     $description = ADA_METADESCRIPTION;
     // from config file
     //$layoutObj = $GLOBALS['layoutObj'];
     if (!is_Object($layoutObj)) {
         // we use function parameters
         $this->template = $template;
         $this->CSS_filename = $CSS_filename;
         $this->JS_filename = $JS_filename;
         $this->family = "";
         $this->module_dir = "";
     } else {
         // we use data from LayOut object
         $this->template = $layoutObj->template;
         $this->CSS_filename = $layoutObj->CSS_filename;
         $this->family = $layoutObj->family;
         $this->JS_filename = $layoutObj->JS_filename;
         $this->module_dir = $layoutObj->module_dir;
         $this->external_module = $layoutObj->external_module;
     }
     $template_name = basename($template);
     $widget_filename = !is_null($layoutObj) ? basename($layoutObj->WIDGET_filename) : '';
     $family_name = $this->family;
     $module_dir = $this->module_dir;
     $static_filename = $this->static_filename;
     $this->htmlheader = "\n<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3.org/TR/html4/loose.dtd\">\n<html>\n<head>\n<meta http-equiv=\"Content-Type\" content=\"text/html; charset=" . ADA_CHARSET . "\">";
     //this is useful for all those html pages that need a refresh time
     // if the refresh time & url are set, this tag is added into the header part of the html page
     if (!empty($meta_refresh_time)) {
         $this->htmlheader .= "\n            <meta http-equiv=\"refresh\" content=\"{$meta_refresh_time}; url={$meta_refresh_url}\">";
     }
     $this->htmlheader .= "\n<meta name=\"powered_by\" content=\"ADA v." . ADA_VERSION . "\">\n        <meta name=\"address\" content=\"{$http_root_dir}\">\n        <meta name=\"author\" content=\"{$author}\">\n        <meta name=\"template\" content=\"{$template_name}\">\n        <meta name=\"family\" content=\"{$family_name}\">\n        <meta name=\"module\" content=\"{$module_dir}\">\n        <meta name=\"widgets\" content=\"{$widget_filename}\">";
     if (isset($layoutObj->menu)) {
         $this->htmlheader .= "\n        <meta name=\"menu\" content=\"" . $layoutObj->menu->getId() . "\"";
         if (!is_null($layoutObj->menu->getLinkedFromId())) {
             $this->htmlheader .= " linked-from=\"" . $layoutObj->menu->getLinkedFromId() . "\"";
         }
         $this->htmlheader .= ">";
     }
     $this->htmlheader .= "\n        <meta name=\"class\" content=\"HTML\">\n        <meta name=\"outputClasses\" content=\"NEW\">\n        <meta name=\"description\" content=\"{$description}\">\n        <meta name=\"keywords\" content=\"{$keywords},{$meta_keywords}\">\n        <meta name=\"cachefile\" content=\"{$static_filename}\">\n        <!-- Stile -->\n        <!-- Javascript -->\n";
     if (isset($course_title) && !empty($course_title) && isset($node_title) && !empty($node_title)) {
         $this->htmlheader .= "<title>" . PORTAL_NAME . " > {$course_title} > {$node_title}</title>\n\n";
     } else {
         $this->htmlheader .= "<title>" . PORTAL_NAME . "</title>\n\n";
     }
     $this->replace_field_code = $GLOBALS['replace_field_code'];
     $this->replace_microtemplate_field_code = $GLOBALS['replace_microtemplate_field_code'];
     $this->htmlheader .= "</head>\n";
     if (isset($onload_func) && !empty($onload_func)) {
         $this->htmlbody = "<body onload=\"{$onload_func}\">\n";
     } else {
         $this->htmlbody = "<body>\n";
     }
     $this->htmlfooter = "</body>\n</html>";
 }
<?php

$pathTpl = $modx->getOption('pathTpl', $scriptProperties, '');
$docid = $modx->getOption('docid', $scriptProperties, '');
$createfolder = $modx->getOption('creatFolder', $scriptProperties, false);
$createpath = false;
if (empty($docid) && $modx->getPlaceholder('docid')) {
    // placeholder was set by some script
    $docid = $modx->getPlaceholder('docid');
}
if (empty($docid)) {
    if (is_Object($modx->resource)) {
        //on frontend
        $docid = $modx->resource->get('id');
    } else {
        //on backend
        $createpath = $createfolder;
        $parsedUrl = parse_url($_SERVER['HTTP_REFERER']);
        parse_str($parsedUrl['query'], $parsedQuery);
        if (isset($parsedQuery['amp;id'])) {
            $docid = $parsedQuery['amp;id'];
        } elseif (isset($parsedQuery['id'])) {
            $docid = $parsedQuery['id'];
        }
    }
}
$path = str_replace('{id}', $docid, $pathTpl);
$fullpath = $modx->getOption('base_path') . $path;
if ($createpath && !file_exists($fullpath)) {
    mkdir($fullpath, 0755, true);
}
 /**
  *
  * @author Max Milbers
  * @param unknown_type $currency
  * @param unknown_type $price
  * @param unknown_type $shop
  */
 function convertCurrencyTo($currency, $price, $shop = true)
 {
     if (empty($currency)) {
         return $price;
     }
     // If both currency codes match, do nothing
     if (is_Object($currency) and $currency->_currency_id == $this->_vendorCurrency or !is_Object($currency) and $currency == $this->_vendorCurrency) {
         return $price;
     }
     if (is_Object($currency)) {
         $exchangeRate = (double) $currency->exchangeRateShopper;
     } else {
         static $currency_exchange_rate = array();
         if (!isset($currency_exchange_rate[$currency])) {
             $db = JFactory::getDBO();
             $q = 'SELECT `currency_exchange_rate` FROM `#__virtuemart_currencies` WHERE `virtuemart_currency_id` ="' . (int) $currency . '" ';
             $db->setQuery($q);
             $currency_exchange_rate[$currency] = (double) $db->loadResult();
         }
         if (!empty($currency_exchange_rate[$currency])) {
             $exchangeRate = $currency_exchange_rate[$currency];
         } else {
             $exchangeRate = 0;
         }
     }
     if (!empty($exchangeRate)) {
         if ($shop) {
             $price = $price / $exchangeRate;
         } else {
             $price = $price * $exchangeRate;
         }
     } else {
         $currencyCode = self::ensureUsingCurrencyCode($currency);
         $vendorCurrencyCode = self::ensureUsingCurrencyCode($this->_vendorCurrency);
         if ($shop) {
             $price = $this->_currencyConverter->convert($price, $currencyCode, $vendorCurrencyCode);
         } else {
             $price = $this->_currencyConverter->convert($price, $vendorCurrencyCode, $currencyCode);
         }
     }
     return $price;
 }
Example #23
0
 function loadConfigs($grid = true, $other = true, $properties = array(), $sender = '')
 {
     $winbuttons = array();
     $gridactionbuttons = array();
     $gridcolumnbuttons = array();
     $gridcontextmenus = array();
     $gridfunctions = array();
     $winfunctions = array();
     $renderer = array();
     $editors = array();
     $gridfilters = array();
     $configs = array('migx_default');
     //$configs = array();
     if (isset($properties['configs']) && !empty($properties['configs'])) {
         $configs = explode(',', $properties['configs']);
     } elseif (isset($this->config['configs']) && !empty($this->config['configs'])) {
         $configs = explode(',', $this->config['configs']);
     }
     if (!empty($configs)) {
         //$configs = (isset($this->config['configs'])) ? explode(',', $this->config['configs']) : array();
         //$configs = array_merge( array ('master'), $configs);
         if ($grid) {
             $configFile = $this->config['corePath'] . 'configs/grid/grid.config.inc.php';
             // [ file ]
             if (file_exists($configFile)) {
                 include $configFile;
             }
             //custom collection of grid-functions...... - deprecated
             $configFile = $this->config['corePath'] . 'configs/grid/grid.custom.config.inc.php';
             // [ file ]
             if (file_exists($configFile)) {
                 include $configFile;
             }
         }
         //get migxconfig-specific grid-configs
         $req_configs = $this->modx->getOption('configs', $_REQUEST, '');
         $preloadGridConfigs = false;
         if ($sender == 'mgr/fields' && ($req_configs == 'migxcolumns' || $req_configs == 'migxdbfilters')) {
             $preloadGridConfigs = true;
             $configs_id = $this->modx->getOption('co_id', $_REQUEST, '');
             $this->configsObject = $this->modx->getObject('migxConfig', $configs_id);
         }
         if ($sender == 'migxconfigs/fields') {
             $preloadGridConfigs = true;
         }
         if ($preloadGridConfigs && is_Object($this->configsObject)) {
             $config = $this->configsObject->get('name');
             $configFile = $this->config['corePath'] . 'configs/grid/grid.' . $config . '.config.inc.php';
             // [ file ]
             if (file_exists($configFile)) {
                 include $configFile;
             }
             //package-specific
             $extended = $this->configsObject->get('extended');
             $packageName = $this->modx->getOption('packageName', $extended, '');
             if (!empty($packageName)) {
                 $configFile = $this->modx->getOption('core_path') . 'components/' . $packageName . '/migxconfigs/grid/grid.' . $config . '.config.inc.php';
                 // [ file ]
                 if (file_exists($configFile)) {
                     include $configFile;
                 }
                 $configFile = $this->modx->getOption('core_path') . 'components/' . $packageName . '/migxconfigs/grid/grid.config.inc.php';
                 // [ file ]
                 if (file_exists($configFile)) {
                     include $configFile;
                 }
             }
         }
         foreach ($configs as $config) {
             $parts = explode(':', $config);
             $cfObject = false;
             if (isset($parts[1])) {
                 $config = $parts[0];
                 $packageName = $parts[1];
             } elseif ($cfObject = $this->modx->getObject('migxConfig', array('name' => $config, 'deleted' => '0'))) {
                 $extended = $cfObject->get('extended');
                 $packageName = $this->modx->getOption('packageName', $extended, '');
             }
             if (isset($packageName)) {
                 $packagepath = $this->modx->getOption('core_path') . 'components/' . $packageName . '/';
                 $configpath = $packagepath . 'migxconfigs/';
             }
             if ($grid) {
                 //first try to find custom-grid-configurations (buttons,context-menus,functions)
                 $configFile = $this->config['corePath'] . 'configs/grid/grid.' . $config . '.config.inc.php';
                 // [ file ]
                 if (file_exists($configFile)) {
                     include $configFile;
                 }
                 if (!empty($packageName)) {
                     $configFile = $configpath . 'grid/grid.' . $config . '.config.inc.php';
                     // [ file ]
                     if (file_exists($configFile)) {
                         include $configFile;
                     }
                     $configFile = $configpath . 'grid/grid.config.inc.php';
                     // [ file ]
                     if (file_exists($configFile)) {
                         include $configFile;
                     }
                 }
             }
             if ($other) {
                 //second try to find config-object
                 if (isset($configpath) && !$cfObject && file_exists($configpath . $config . '.config.js')) {
                     $filecontent = @file_get_contents($configpath . $config . '.config.js');
                     $objectarray = $this->importconfig($this->modx->fromJson($filecontent));
                     $this->prepareConfigsArray($objectarray, $gridactionbuttons, $gridcontextmenus, $gridcolumnbuttons, $winbuttons);
                 }
                 if ($cfObject) {
                     $objectarray = $cfObject->toArray();
                     $this->prepareConfigsArray($objectarray, $gridactionbuttons, $gridcontextmenus, $gridcolumnbuttons, $winbuttons);
                 }
                 //third add configs from file, if exists
                 $configFile = $this->config['corePath'] . 'configs/' . $config . '.config.inc.php';
                 // [ file ]
                 if (file_exists($configFile)) {
                     include $configFile;
                 }
                 if (!empty($packageName)) {
                     $configFile = $configpath . $config . '.config.inc.php';
                     // [ file ]
                     if (file_exists($configFile)) {
                         include $configFile;
                     }
                 }
             }
         }
     }
     if (isset($this->customconfigs['filters']) && is_array($this->customconfigs['filters']) && count($this->customconfigs['filters']) > 0) {
         foreach ($this->customconfigs['filters'] as $filter) {
             if (isset($gridfilters[$filter['type']]) && is_array($gridfilters[$filter['type']])) {
                 $this->customconfigs['gridfilters'][$filter['name']] = array_merge($filter, $gridfilters[$filter['type']]);
             }
         }
     }
     $this->customconfigs['gridactionbuttons'] = $gridactionbuttons;
     $this->customconfigs['gridcontextmenus'] = $gridcontextmenus;
     $this->customconfigs['gridcolumnbuttons'] = $gridcolumnbuttons;
     $this->customconfigs['gridfunctions'] = array_merge($gridfunctions, $renderer, $editors);
     $this->customconfigs['winfunctions'] = $winfunctions;
     $this->customconfigs['windowbuttons'] = $winbuttons;
     //$defaulttask = empty($this->customconfigs['join_alias']) ? 'default' : 'default_join';
     $defaulttask = 'default';
     $this->customconfigs['task'] = empty($this->customconfigs['task']) ? $defaulttask : $this->customconfigs['task'];
 }
Example #24
0
 public function getYearByMonth($periode_intern)
 {
     $Result = PeriodenRecord::finder()->findByper_Intern($periode_intern);
     if (is_Object($Result)) {
         if ($Result->parent_idta_perioden != 0) {
             $Result2 = PeriodenRecord::finder()->findByidta_perioden($Result->parent_idta_perioden);
             return $Result2->per_intern;
         } else {
             return $periode_intern;
         }
     } else {
         return $periode_intern;
     }
 }
Example #25
0
 function loadConfigs($grid = true, $other = true, $properties = array(), $sender = '')
 {
     $gridactionbuttons = array();
     $gridcolumnbuttons = array();
     $gridcontextmenus = array();
     $gridfunctions = array();
     $renderer = array();
     $gridfilters = array();
     $configs = array();
     if (isset($properties['configs'])) {
         $configs = explode(',', $properties['configs']);
     } elseif (isset($this->config['configs'])) {
         $configs = explode(',', $this->config['configs']);
     }
     if (!empty($configs)) {
         //$configs = (isset($this->config['configs'])) ? explode(',', $this->config['configs']) : array();
         //$configs = array_merge( array ('master'), $configs);
         if ($grid) {
             $configFile = $this->config['migxCorePath'] . 'configs/grid/grid.config.inc.php';
             // [ file ]
             if (file_exists($configFile)) {
                 include $configFile;
             }
             //custom collection of grid-functions...... - deprecated
             $configFile = $this->config['migxCorePath'] . 'configs/grid/grid.custom.config.inc.php';
             // [ file ]
             if (file_exists($configFile)) {
                 include $configFile;
             }
         }
         //get migxconfig-specific grid-configs
         $req_configs = $this->modx->getOption('configs', $_REQUEST, '');
         $preloadGridConfigs = false;
         if ($sender == 'mgr/fields' && $req_configs == 'migxcolumns') {
             $preloadGridConfigs = true;
             $configs_id = $this->modx->getOption('co_id', $_REQUEST, '');
             $this->configsObject = $this->modx->getObject('migxConfig', $configs_id);
         }
         if ($sender == 'migxconfigs/fields') {
             $preloadGridConfigs = true;
         }
         if ($preloadGridConfigs && is_Object($this->configsObject)) {
             $config = $this->configsObject->get('name');
             $configFile = $this->config['migxCorePath'] . 'configs/grid/grid.' . $config . '.config.inc.php';
             // [ file ]
             if (file_exists($configFile)) {
                 include $configFile;
             }
             //package-specific
             $extended = $this->configsObject->get('extended');
             $packageName = $this->modx->getOption('packageName', $extended, '');
             if (!empty($packageName)) {
                 $configFile = $this->modx->getOption('core_path') . 'components/' . $packageName . '/migxconfigs/grid/grid.' . $config . '.config.inc.php';
                 // [ file ]
                 if (file_exists($configFile)) {
                     include $configFile;
                 }
                 $configFile = $this->modx->getOption('core_path') . 'components/' . $packageName . '/migxconfigs/grid/grid.config.inc.php';
                 // [ file ]
                 if (file_exists($configFile)) {
                     include $configFile;
                 }
             }
         }
         foreach ($configs as $config) {
             if ($cfObject = $this->modx->getObject('migxConfig', array('name' => $config, 'deleted' => '0'))) {
                 $extended = $cfObject->get('extended');
                 $packageName = $this->modx->getOption('packageName', $extended, '');
             }
             if ($grid) {
                 //first try to find custom-grid-configurations (buttons,context-menus,functions)
                 $configFile = $this->config['migxCorePath'] . 'configs/grid/grid.' . $config . '.config.inc.php';
                 // [ file ]
                 if (file_exists($configFile)) {
                     include $configFile;
                 }
                 if (!empty($packageName)) {
                     $configFile = $this->modx->getOption('core_path') . 'components/' . $packageName . '/migxconfigs/grid/grid.' . $config . '.config.inc.php';
                     // [ file ]
                     if (file_exists($configFile)) {
                         include $configFile;
                     }
                     $configFile = $this->modx->getOption('core_path') . 'components/' . $packageName . '/migxconfigs/grid/grid.config.inc.php';
                     // [ file ]
                     if (file_exists($configFile)) {
                         include $configFile;
                     }
                 }
             }
             if ($other) {
                 //second try to find config-object
                 if ($cfObject) {
                     $objectarray = $cfObject->toArray();
                     if (is_array($objectarray['extended'])) {
                         foreach ($objectarray['extended'] as $key => $value) {
                             if (!empty($value)) {
                                 $this->customconfigs[$key] = $value;
                             }
                         }
                     }
                     unset($objectarray['extended']);
                     if (isset($this->customconfigs)) {
                         $this->customconfigs = is_array($this->customconfigs) ? array_merge($this->customconfigs, $objectarray) : $objectarray;
                         $this->customconfigs['tabs'] = $this->modx->fromJson($cfObject->get('formtabs'));
                         $this->customconfigs['filters'] = $this->modx->fromJson($cfObject->get('filters'));
                         //$this->customconfigs['tabs'] =  stripslashes($cfObject->get('formtabs'));
                         //$this->customconfigs['columns'] = $this->modx->fromJson(stripslashes($cfObject->get('columns')));
                         $this->customconfigs['columns'] = $this->modx->fromJson($cfObject->get('columns'));
                     }
                     $menus = $cfObject->get('contextmenus');
                     if (!empty($menus)) {
                         $menus = explode('||', $menus);
                         foreach ($menus as $menu) {
                             $gridcontextmenus[$menu]['active'] = 1;
                         }
                     }
                     $columnbuttons = $cfObject->get('columnbuttons');
                     if (!empty($columnbuttons)) {
                         $columnbuttons = explode('||', $columnbuttons);
                         foreach ($columnbuttons as $button) {
                             if (isset($gridcontextmenus[$button])) {
                                 $gridcolumnbuttons[$button] = $gridcontextmenus[$button];
                                 $gridcolumnbuttons[$button]['active'] = 1;
                             }
                         }
                     }
                     $actionbuttons = $cfObject->get('actionbuttons');
                     if (!empty($actionbuttons)) {
                         $actionbuttons = explode('||', $actionbuttons);
                         foreach ($actionbuttons as $button) {
                             $gridactionbuttons[$button]['active'] = 1;
                         }
                     }
                 }
                 //third add configs from file, if exists
                 $configFile = $this->config['migxCorePath'] . 'configs/' . $config . '.config.inc.php';
                 // [ file ]
                 if (file_exists($configFile)) {
                     include $configFile;
                 }
                 if (!empty($packageName)) {
                     $configFile = $this->modx->getOption('core_path') . 'components/' . $packageName . '/migxconfigs/' . $config . '.config.inc.php';
                     // [ file ]
                     if (file_exists($configFile)) {
                         include $configFile;
                     }
                 }
             }
         }
     }
     if (isset($this->customconfigs['filters']) && is_array($this->customconfigs['filters']) && count($this->customconfigs['filters']) > 0) {
         foreach ($this->customconfigs['filters'] as $filter) {
             if (isset($gridfilters[$filter['type']]) && is_array($gridfilters[$filter['type']])) {
                 $this->customconfigs['gridfilters'][$filter['name']] = array_merge($filter, $gridfilters[$filter['type']]);
             }
         }
     }
     $this->customconfigs['gridactionbuttons'] = $gridactionbuttons;
     $this->customconfigs['gridcontextmenus'] = $gridcontextmenus;
     $this->customconfigs['gridcolumnbuttons'] = $gridcolumnbuttons;
     $this->customconfigs['gridfunctions'] = array_merge($gridfunctions, $renderer);
     //$defaulttask = empty($this->customconfigs['join_alias']) ? 'default' : 'default_join';
     $defaulttask = 'default';
     $this->customconfigs['task'] = empty($this->customconfigs['task']) ? $defaulttask : $this->customconfigs['task'];
 }
 public function onPreInit($param)
 {
     //parent::onPreInit($param);
     if (isset($_GET['idta_stammdatensicht'])) {
         $openItem = $_GET['idta_stammdatensicht'];
     } else {
         $openItem = 1;
     }
     $this->setUserStartId($this->user->getStartNode($this->user->getUserId($this->user->Name), "tm_struktur", $openItem));
     $res = mysql_connect($this->Application->Parameters['Host'], $this->Application->getModule('db1')->database->getUsername(), $this->Application->getModule('db1')->database->getPassword());
     mysql_select_db($this->Application->Parameters['Database']);
     //$tree = new TreeConnector($this->DBConnection);
     $tree = new TreeConnector($res);
     $tree->set_encoding("UTF-8");
     $tree->enable_log("temp.log", false);
     $mySQL = "SELECT idtm_struktur,parent_idtm_struktur,struktur_name,idta_struktur_type,(struktur_rgt - struktur_lft) AS struktur_rgt FROM vv_struktur";
     $mySQLOrderBy = " ORDER BY idta_struktur_type, struktur_name";
     $mySQLcond1 = "";
     //the start ID
     $numberofstructureelements = StrukturRecord::finder()->count();
     if ($numberofstructureelements > 1) {
         $MaxRecord = StrukturRecord::finder()->findBySql('SELECT MAX(struktur_rgt) AS struktur_rgt FROM tm_struktur');
         if (is_Object($MaxRecord)) {
             $maxrgtvalue = $MaxRecord->struktur_rgt;
         } else {
             $maxrgtvalue = 0;
         }
         if ($numberofstructureelements * 2 <= $maxrgtvalue) {
             $StrStartRecord = StrukturRecord::finder()->findByidtm_struktur($this->UserStartId);
             $mySQLcond1 = "(struktur_lft BETWEEN " . $StrStartRecord->struktur_lft . " AND " . $StrStartRecord->struktur_rgt . ")";
             $mySQLcond1 .= " OR idtm_struktur IN ( " . $this->parentCategory_list_Nested($this->UserStartId) . ")";
         } else {
             $this->load_all_cats($mySQL . $mySQLOrderBy);
             $mySQLcond1 = "idtm_struktur IN (" . $this->subCategory_list($this->subcats, $this->UserStartId) . "," . $this->parentCategory_list($this->parentcats, $this->UserStartId) . ")";
         }
         $tmp_Strukturfilter = $this->user->getStartNode($this->user->getUserId($this->user->Name), "ta_stammdaten_group");
         if ($tmp_Strukturfilter > 0 and $tmp_Strukturfilter != StammdatenGroupRecord::finder()->findByparent_idta_stammdaten_group(0)->idta_stammdaten_group) {
             $tsgroup = "";
             $loopcounter = 0;
             while ($this->checkMyParent($tmp_Strukturfilter) > 0) {
                 if ($loopcounter == 0) {
                     $tsgroup .= $tmp_Strukturfilter;
                 } else {
                     $tsgroup .= "," . $tmp_Strukturfilter;
                 }
                 $loopcounter++;
                 $tmp_Strukturfilter = $this->checkMyParent($tmp_Strukturfilter);
             }
             $mySQLcond1 .= " AND idta_stammdaten_group IN (" . $tsgroup . ", " . StammdatenGroupRecord::finder()->findByparent_idta_stammdaten_group(0)->idta_stammdaten_group . ")";
         }
     }
     function custom_format($item)
     {
         $item->set_image("s" . $item->get_value("idta_struktur_type") . ".gif");
         if ($item->get_value("struktur_rgt") > 1) {
             $item->set_kids(true);
         } else {
             $item->set_kids(false);
         }
     }
     $tree->event->attach("beforeRender", 'custom_format');
     $SQLComp = $mySQL;
     if ($mySQLcond1 != '') {
         $SQLComp .= " WHERE (" . $mySQLcond1 . ") AND idta_stammdatensicht = " . $openItem;
         //.$mySQLOrderBy
     } else {
         $SQLComp .= " WHERE idta_stammdatensicht = " . $openItem;
     }
     $tree->dynamic_loading(true);
     //$tree->render_table("tm_struktur", "idtm_struktur", "struktur_name", "parent_idtm_struktur");
     $tree->render_sql($SQLComp, "idtm_struktur", "struktur_name,idta_struktur_type", "", "parent_idtm_struktur");
 }
Example #27
0
 /**
  *
  * @author Max Milbers
  * @param unknown_type $currency
  * @param unknown_type $price
  * @param unknown_type $shop
  */
 function convertCurrencyTo($currency, $price, $shop = true)
 {
     if (empty($currency)) {
         // 			vmdebug('empty  $currency ',$price);
         return $price;
     }
     // If both currency codes match, do nothing
     if (is_Object($currency) and $currency->_currency_id == $this->_vendorCurrency or !is_Object($currency) and $currency == $this->_vendorCurrency) {
         // 			vmdebug('  $currency == $this->_vendorCurrency ',$price);
         return $price;
     }
     if (is_Object($currency)) {
         $exchangeRate = (double) $currency->exchangeRateShopper;
         vmdebug('convertCurrencyTo OBJECT ' . $exchangeRate);
     } else {
         static $currency_exchange_rate = array();
         if (!isset($currency_exchange_rate[$currency])) {
             $q = 'SELECT `currency_exchange_rate` FROM `#__virtuemart_currencies` WHERE `virtuemart_currency_id` ="' . (int) $currency . '" ';
             $this->_db->setQuery($q);
             $currency_exchange_rate[$currency] = (double) $this->_db->loadResult();
         }
         if (!empty($currency_exchange_rate[$currency])) {
             $exchangeRate = $currency_exchange_rate[$currency];
         } else {
             $exchangeRate = 0;
         }
     }
     if (!empty($exchangeRate)) {
         if ($shop) {
             $price = $price / $exchangeRate;
         } else {
             $price = $price * $exchangeRate;
         }
     } else {
         $currencyCode = self::ensureUsingCurrencyCode($currency);
         $vendorCurrencyCode = self::ensureUsingCurrencyCode($this->_vendorCurrency);
         $globalCurrencyConverter = vRequest::getVar('globalCurrencyConverter');
         if ($shop) {
             $price = $this->_currencyConverter->convert($price, $currencyCode, $vendorCurrencyCode);
             //vmdebug('convertCurrencyTo Use dynamic rate in shop '.$oldprice .' => '.$price);
         } else {
             //vmdebug('convertCurrencyTo Use dynamic rate to shopper currency '.$price);
             $price = $this->_currencyConverter->convert($price, $vendorCurrencyCode, $currencyCode);
         }
         // 			vmdebug('convertCurrencyTo my currency ',$this->exchangeRateShopper);
     }
     return $price;
 }
Example #28
0
function ProcessTQ(){
	global $g_DBData, $sTable;
	
	$sRegistros = '';
	
	//establezco conección con la DB
	$oDB = ADONewConnection('oci8');
	$oDB->Connect( $g_DBData['Host'], $g_DBData['User'], $g_DBData['Pass'], $g_DBData['DB'] );
	$oDB->SetFetchMode(ADODB_FETCH_ASSOC);
	
	$oDB->debug=true;
	
	//*** Estructura de la Tabla
	$sSQL = "SELECT * FROM ALL_TAB_COLUMNS WHERE TABLE_NAME = '$sTable' ";
	$oRS=$oDB->Execute($sSQL);
	
	if ($oRS===false){
		echo "La instruccion SQL:<br><b>$sSQL</b><br>no se ejecuto correctamente.";
		
	}else{
		echo "Estructura de la Tabla: <b>$sTable</b>.";
		$sRegistros = '('. $oRS->RecordCount(). ' registros)';
		if (is_Object($oRS)){
			rs2html($oRS);
		}
		echo "La instruccion SQL:<br><b>$sSQL</b><br>se ejecuto correctamente. $sRegistros";
	}
	
	//*** Indices de la Tabla
	$sSQL = "SELECT * FROM ALL_IND_COLUMNS WHERE TABLE_NAME = '$sTable' ";
	$oRS=$oDB->Execute($sSQL);
	
	if ($oRS===false){
		echo "La instruccion SQL:<br><b>$sSQL</b><br>no se ejecuto correctamente.";
		
	}else{
		echo "Indices de la Tabla: <b>$sTable</b>.";
		$sRegistros = '('. $oRS->RecordCount(). ' registros)';
		if (is_Object($oRS)){
			rs2html($oRS);
		}
		echo "La instruccion SQL:<br><b>$sSQL</b><br>se ejecuto correctamente. $sRegistros";
	}
	
	//*** Constraints de la Tabla
	$sSQL = "SELECT * FROM ALL_CONSTRAINTS WHERE TABLE_NAME = '$sTable' ";
	$oRS=$oDB->Execute($sSQL);
	
	if ($oRS===false){
		echo "La instruccion SQL:<br><b>$sSQL</b><br>no se ejecuto correctamente.";
		
	}else{
		echo "Constraints de la Tabla: <b>$sTable</b>.";
		$sRegistros = '('. $oRS->RecordCount(). ' registros)';
		if (is_Object($oRS)){
			rs2html($oRS);
		}
		echo "La instruccion SQL:<br><b>$sSQL</b><br>se ejecuto correctamente. $sRegistros";
	}
	
	if (is_Object($oRS)){
		$oRS->Close();
	}
}
 public function testInstance()
 {
     $this->assertTrue(is_Object($this->obj));
 }
 public function buildFieldList($idta_stammdaten_group)
 {
     $Result = StammdatenGroupRecord::finder()->findBy_idta_stammdaten_group($idta_stammdaten_group);
     if (is_Object($Result)) {
         $this->RCTedidta_feldfunktion->DataSource = PFH::build_SQLPullDown(FeldfunktionRecord::finder(), "ta_feldfunktion", array("idta_feldfunktion", "ff_name"), "idta_struktur_type = '" . $Result->idta_struktur_type . "' AND ff_type = 1");
         $this->RCTedidta_feldfunktion->dataBind();
     }
 }