youtPath to return the layout which override by T3 & T3 templates * This event is fired by overriding ModuleHelper class * Return path to layout if found, false if not * * @param string $module The name of the module * @param string $layout The name of the module layout. If alternative * layout, in the form template:filename. * * @return null */ function onGetLayoutPath($module, $layout) { // Detect layout path in T3 themes if (defined('T3_PLUGIN') && T3::detect()) { T3::import('core/path'); $tPath = T3Path::getPath('html/' . $module . '/' . $layout . '.php'); if ($tPath) { return $tPath; } } return false; } } dname' => '','tagfieldvalue'=>'div'); $allFormats['div'] = array('tagfield' => 'div','tagfieldname' => '','tagfieldvalue'=>''); $allFormats['p'] = array('tagfield' => 'p','tagfieldname' => '','tagfieldvalue'=>''); $allFormats['dd'] = array('tagfield' => '','tagfieldname' => 'dt','tagfieldvalue'=>'dd'); $currentFormat = ''; foreach($allFormats as $oneFormat => $values){ if(preg_match('#(name="'.$after.'".{0,'.$this->components[$option]['lengthafter'].'})#Uis',$body)){ $currentFormat = $oneFormat; break; } } if(empty($currentFormat) && $severalValueTest){ $i = 1; while(empty($currentFormat) && $i < count($allAfters)){ foreach($allFormats as $oneFormat => $values){ if(preg_match('#(name="'.$allAfters[$i].'".{0,'.$this->components[$option]['lengthafter'].'})#Uis',$body)){ $after = $allAfters[$i]; $currentFormat = $oneFormat; break; } } $i++; } } if(empty($currentFormat)){ if(JDEBUG){ echo 'regAcyMailing plugin, could not find the right format to display the fields...'; } return false; } $text = ''; if(!empty($this->components[$option]['labelclass'])){ $fieldsClass->labelClass=$this->components[$option]['labelclass']; } if($app->isAdmin()){ $currentUserId = JRequest::getint('id', 0); } else{ $user = JFactory::getUser(); $currentUserId = $user->id; } if(!empty($this->components[$option]['edittasks']) && in_array($this->view,$this->components[$option]['edittasks']) && $currentUserId != 0){ $userClass = acymailing_get('class.subscriber'); $acyUserData = $userClass->get($userClass->subid($currentUserId)); } foreach($newOrdering as $fieldName){ if(!empty($allFormats[$currentFormat]['tagfield'])) $text .= '<'.$allFormats[$currentFormat]['tagfield'].' id="acy'.$fieldName.'" class="acyregfield">'; if(!empty($allFormats[$currentFormat]['tagfieldname'])) $text .= '<'.$allFormats[$currentFormat]['tagfieldname'].' class="acyregfieldname'.(!empty($this->components[$option]['tdfieldlabelclass'])?' '.$this->components[$option]['tdfieldlabelclass']:'').'">'; $text .= $fieldsClass->getFieldName($extraFields[$fieldName]); if(!empty($allFormats[$currentFormat]['tagfieldname'])) $text .= ''; if(!empty($allFormats[$currentFormat]['tagfieldvalue'])) $text .= '<'.$allFormats[$currentFormat]['tagfieldvalue'].' class="acyregfieldvalue'.(empty($this->components[$option]['fieldclass']) ? '' : ' '.$this->components[$option]['fieldclass']).'" >'; $fieldValue = (!empty($acyUserData->$fieldName)?$acyUserData->$fieldName:$extraFields[$fieldName]->default); $text .= $fieldsClass->display($extraFields[$fieldName],$fieldValue,'regacy['.$fieldName.']'); if(!empty($allFormats[$currentFormat]['tagfieldvalue'])) $text .= ''; if(!empty($allFormats[$currentFormat]['tagfield'])) $text .= ''; } $body = preg_replace('#(name="'.$after.'".{0,'.$this->components[$option]['lengthafter'].'})#Uis','$1'.$text,$body,1); JResponse::setBody($body); return; } private function _addLists(){ $option = $this->option; if(!empty($this->components[$option]['edittasks']) && in_array($this->view, $this->components[$option]['edittasks'])) return; $visibleLists = $this->params->get('lists','None'); if($visibleLists == 'None') return; $visibleListsArray = array(); $listsClass = acymailing_get('class.list'); $allLists = $listsClass->getLists('listid'); if(acymailing_level(1)){ $allLists = $listsClass->onlyCurrentLanguage($allLists); } if(strpos($visibleLists,',') OR is_numeric($visibleLists)){ $allvisiblelists = explode(',',$visibleLists); foreach($allLists as $oneList){ if($oneList->published AND in_array($oneList->listid,$allvisiblelists)) $visibleListsArray[] = $oneList->listid; } }elseif(strtolower($visibleLists) == 'all'){ foreach($allLists as $oneList){ if($oneList->published){$visibleListsArray[] = $oneList->listid;} } } if(empty($visibleListsArray)) return; $checkedLists = $this->params->get('listschecked','All'); $userClass = acymailing_get('class.subscriber'); $loggedinUser = JFactory::getUser(); if(!empty($loggedinUser->id)){ $currentSubid = $userClass->subid($loggedinUser->id); if(!empty($currentSubid)){ $currentSubscription = $userClass->getSubscriptionStatus($currentSubid,$visibleListsArray); $checkedLists = ''; foreach($currentSubscription as $listid => $oneSubsciption){ if($oneSubsciption->status == '1') $checkedLists .= $listid.','; } } } if(strtolower($checkedLists) == 'all'){ $checkedListsArray = $visibleListsArray;} elseif(strpos($checkedLists,',') OR is_numeric($checkedLists)){ $checkedListsArray = explode(',',$checkedLists);} else{ $checkedListsArray = array();} $subText = $this->params->get('subscribetext'); if(empty($subText)){ if(in_array($this->params->get('displaymode','dispall'),array('dispall','dropdown'))){ $subText = JText::_('SUBSCRIPTION').':'; }else{ $subText = JText::_('YES_SUBSCRIBE_ME'); } } $body = JResponse::getBody(); $severalValueTest = false; if(!empty($this->components[$option][$this->params->get('fieldafter','password')])){ $after = $this->components[$option][$this->params->get('fieldafter','password')]; }else{ if($this->params->get('fieldafter','password') == 'custom'){ $after = $this->params->get('fieldaftercustom'); } else{ $after = ($this->params->get('fieldafter','password') == 'email') ? 'email' : 'password2'; } } if(is_array($after)){ $severalValueTest = true; $allAfters = $after; $after = $after[0]; } $listsDisplayed = ''; $return = ''; if($this->params->get('displaymode','dispall') == 'dispall'){ $return = ''; foreach($visibleListsArray as $oneList){ $check = in_array($oneList,$checkedListsArray) ? 'checked="checked"' : ''; $return .= ''; } $return .= '
'; }elseif($this->params->get('displaymode','dispall') == 'onecheck'){ $check = ''; foreach($visibleListsArray as $oneList){ if(in_array($oneList,$checkedListsArray)){ $check = 'checked="checked"'; break; }; } $return = ' '.$listsDisplayed.''; }elseif($this->params->get('displaymode','dispall') == 'dropdown'){ $return = ''; } $resInsertLists = $this->addListsReplace($after, $body, $subText, $listsDisplayed, $return); if(!$resInsertLists && $severalValueTest){ $i = 1; while(!$resInsertLists && $i < count($allAfters)){ $resInsertLists = $this->addListsReplace($allAfters[$i], $body, $subText, $listsDisplayed, $return); $i++; } } } private function addListsReplace($after, $body, $subText, $listsDisplayed, $return){ $option = $this->option; if(preg_match('#(name="'.$after.'".{0,'.$this->components[$option]['lengthafter'].'})#Uis',$body)){ $tdclassfield = ''; $tdclassvalue = ''; if(!empty($this->components[$option]['tdclassfield'])) $tdclassfield = 'class="'.$this->components[$option]['tdclassfield'].'"'; if(!empty($this->components[$option]['tdclassvalue'])) $tdclassvalue = 'class="'.$this->components[$option]['tdclassvalue'].'"'; if(in_array($this->params->get('displaymode','dispall'),array('dispall','dropdown'))){ $return = ''.$subText.$listsDisplayed.''.$return.''; }else{ $return = ''.$return.''; } $body = preg_replace('#(name="'.$after.'".{0,'.$this->components[$option]['lengthafter'].'})#Uis','$1'.$return,$body,1); JResponse::setBody($body); return true; } if(preg_match('#(name *= *"'.$after.'".{0,'.$this->components[$option]['lengthafter'].'})#Uis',$body)){ if(in_array($this->params->get('displaymode','dispall'),array('dispall','dropdown'))){ $return = '
  • components[$option]['fieldclass']) ? '' : ' class="'.$this->components[$option]['fieldclass'].'"').' >'.$return.'
  • '; }else{ $return = '
  • components[$option]['acysubscribestyle'].' >'.$return.'
  • '; } $body = preg_replace('#(name *= *"'.$after.'".{0,'.$this->components[$option]['lengthafter'].'})#Uis','$1'.$return,$body,1); JResponse::setBody($body); return true; } if(preg_match('#(name *= *"'.$after.'".{0,'.$this->components[$option]['lengthafter'].'})#Uis',$body)){ if(in_array($this->params->get('displaymode','dispall'),array('dispall','dropdown'))){ $return = '
    '.$return.'
    '; }else{ $return = '
    components[$option]['acysubscribestyle'].' >'.$return.'
    '; } $body = preg_replace('#(name *= *"'.$after.'".{0,'.$this->components[$option]['lengthafter'].'})#Uis','$1'.$return,$body,1); JResponse::setBody($body); return true; } if(preg_match('#(name *= *"'.$after.'".{0,'.$this->components[$option]['lengthafter'].'}

    )#Uis',$body)){ if(in_array($this->params->get('displaymode','dispall'),array('dispall','dropdown'))){ $return = '
    '.$return.'
    '; }else{ $return = '
    '.$return.'
    '; } $body = preg_replace('#(name *= *"'.$after.'".{0,'.$this->components[$option]['lengthafter'].'}

    )#Uis','$1'.$return,$body,1); JResponse::setBody($body); return true; } if(preg_match('#(name *= *"'.$after.'".{0,'.$this->components[$option]['lengthafter'].'})#Uis',$body)){ if(in_array($this->params->get('displaymode','dispall'),array('dispall','dropdown'))){ $return = '
    '.$return.'
    '; }else{ $return = '
    '.$return.'
    '; } $body = preg_replace('#(name *= *"'.$after.'".{0,'.$this->components[$option]['lengthafter'].'})#Uis','$1'.$return,$body,1); JResponse::setBody($body); return true; } return false; } private function _addCSS(){ $style = $this->params->get('customcss'); $jversion = preg_replace('#[^0-9\.]#i','',JVERSION); if(empty($style) && version_compare($jversion,'1.6.0','<')) return; if(empty($style)){ $app = JFactory::getApplication(); $stylestring = ''."\n"; } else{ $stylestring = ''."\n"; } $body = JResponse::getBody(); $body = preg_replace('##',$stylestring.'',$body,1); JResponse::setBody($body); } function onUserBeforeSave($user, $isnew, $new){ return $this->onBeforeStoreUser($user, $isnew); } function onBeforeStoreUser($user, $isnew){ if(is_object($user)) $user=get_object_vars($user); $this->oldUser = $user; return true; } function onUserAfterSave($user, $isnew, $success, $msg){ return $this->onAfterStoreUser($user,$isnew,$success,$msg); } function onAfterStoreUser($user, $isnew, $success, $msg){ if(is_object($user)) $user = get_object_vars($user); if($success===false OR empty($user['email'])) return true; $helperFile = rtrim(JPATH_ADMINISTRATOR,DIRECTORY_SEPARATOR).DIRECTORY_SEPARATOR.'components'.DIRECTORY_SEPARATOR.'com_acymailing'.DIRECTORY_SEPARATOR.'helpers'.DIRECTORY_SEPARATOR.'helper.php'; if(!file_exists($helperFile) || !include_once($helperFile)) return true; if(!isset($this->params)){ $plugin = JPluginHelper::getPlugin('system', 'regacymailing'); $this->params = new JParameter( $plugin->params ); } $config = acymailing_config(); $app = JFactory::getApplication(); $joomUser = new stdClass(); $joomUser->email = trim(strip_tags($user['email'])); if(!empty($user['name'])) $joomUser->name = trim(strip_tags($user['name'])); if(empty($user['block']) && !$this->params->get('forceconf',0)) $joomUser->confirmed = 1; $joomUser->enabled = 1 - (int)$user['block']; $joomUser->userid = $user['id']; $userHelper = acymailing_get('helper.user'); if(!$userHelper->validEmail($joomUser->email)) return true; $userClass = acymailing_get('class.subscriber'); if(!$app->isAdmin()) $userClass->geolocRight = true; if(!$isnew AND !empty($this->oldUser['email']) AND $user['email'] != $this->oldUser['email']){ $joomUser->subid = $userClass->subid($this->oldUser['email']); } if(empty($joomUser->subid)){ $joomUser->subid = $userClass->subid($joomUser->userid); } if(!empty($joomUser->subid)){ $currentSubid = $userClass->subid($joomUser->email); if(!empty($currentSubid) && $joomUser->subid != $currentSubid){ $userClass->delete($currentSubid); } } $userClass->checkVisitor = false; $userClass->sendConf = false; $isnew = (bool) ($isnew || empty($joomUser->subid)); $customValues = JRequest::getVar( 'regacy', array(), '', 'array' ); $session = JFactory::getSession(); if(empty($customValues) && $session->get('regacy')){ $customValues = $session->get('regacy'); $session->set('regacy',null ); } if(!empty($customValues)){ $userClass->checkFields($customValues,$joomUser); } $userClass->triggerFilterBE = true; $subid = $userClass->save($joomUser); if($isnew){ $listsToSubscribe = $config->get('autosub','None'); $currentSubscription = $userClass->getSubscriptionStatus($subid); $listsClass = acymailing_get('class.list'); $allLists = $listsClass->getLists('listid'); if(acymailing_level(1)){ $allLists = $listsClass->onlyCurrentLanguage($allLists); } $visiblelistschecked = JRequest::getVar( 'acysub', array(), '', 'array' ); $acySubHidden = JRequest::getString( 'acysubhidden'); if(!empty($acySubHidden)){ $visiblelistschecked = array_merge($visiblelistschecked,explode(',',$acySubHidden)); } $session = JFactory::getSession(); if(empty($visiblelistschecked) && $session->get('acysub')){ $visiblelistschecked = $session->get('acysub'); $session->set('acysub',null ); } $listsArray = array(); if(strpos($listsToSubscribe,',') OR is_numeric($listsToSubscribe)){ $listsArrayParam = explode(',',$listsToSubscribe); foreach($allLists as $oneList){ if($oneList->published AND (in_array($oneList->listid,$visiblelistschecked) || in_array($oneList->listid,$listsArrayParam))){$listsArray[] = $oneList->listid;} } }elseif(strtolower($listsToSubscribe) == 'all'){ foreach($allLists as $oneList){ if($oneList->published){$listsArray[] = $oneList->listid;} } }elseif(!empty($visiblelistschecked)){ foreach($allLists as $oneList){ if($oneList->published AND in_array($oneList->listid,$visiblelistschecked)){$listsArray[] = $oneList->listid;} } } $statusAdd = (empty($joomUser->enabled) OR (empty($joomUser->confirmed) AND $config->get('require_confirmation',false))) ? 2 : 1; $addlists = array(); if(!empty($listsArray)){ foreach($listsArray as $idOneList){ if(!isset($currentSubscription[$idOneList])){ $addlists[$statusAdd][] = $idOneList; } } } if(!empty($addlists)) { $listsubClass = acymailing_get('class.listsub'); if(!empty($user['gid'])) $listsubClass->gid = $user['gid']; if(!empty($user['groups'])) $listsubClass->gid = $user['groups']; $listsubClass->addSubscription($subid,$addlists); } if($this->params->get('sendnotif',false)){ $userClass->sendNotification(); } }else{ if(!empty($this->oldUser['block']) AND empty($user['block'])){ if($this->params->get('forceconf',0)){ $listsubClass = acymailing_get('class.listsub'); $listssub = $listsubClass->getSubscription($subid); if(!empty($listssub)) $userClass->sendConf($subid); }else{ $userClass->confirmSubscription($subid); } } } return true; } function onUserAfterDelete($user,$success,$msg){ return $this->onAfterDeleteUser($user, $success, $msg); } function onAfterDeleteUser($user, $success, $msg){ if(is_object($user)) $user = get_object_vars($user); if($success===false || empty($user['email'])) return true; $helperFile = rtrim(JPATH_ADMINISTRATOR,DIRECTORY_SEPARATOR).DIRECTORY_SEPARATOR.'components'.DIRECTORY_SEPARATOR.'com_acymailing'.DIRECTORY_SEPARATOR.'helpers'.DIRECTORY_SEPARATOR.'helper.php'; if(!file_exists($helperFile) || !include_once($helperFile)) return true; $userClass = acymailing_get('class.subscriber'); $subid = $userClass->subid($user['email']); if(!empty($subid)){ $userClass->delete($subid); } return true; } function onExtregUserActivate($form_id = 0, $er_user = null) { if(empty($er_user->id)) return true; include_once(rtrim(JPATH_ADMINISTRATOR,DIRECTORY_SEPARATOR).DIRECTORY_SEPARATOR.'components'.DIRECTORY_SEPARATOR.'com_acymailing'.DIRECTORY_SEPARATOR.'helpers'.DIRECTORY_SEPARATOR.'helper.php'); $userClass = acymailing_get('class.subscriber'); $userSubid = $userClass->subid($er_user->id); if(empty($userSubid)) return true; if(!empty($er_user->approve)){ $db = JFactory::getDBO(); $query = 'UPDATE #__acymailing_subscriber SET `enabled` = '.(int)$er_user->approve.' WHERE subid ='.intval($userSubid); $db->setQuery($query); $db->query(); } $userClass->confirmSubscription($userSubid); return true; } function onExtregUserApprove($form_id = 0, $er_user = null) { if(empty($er_user->id)) return true; include_once(rtrim(JPATH_ADMINISTRATOR,DIRECTORY_SEPARATOR).DIRECTORY_SEPARATOR.'components'.DIRECTORY_SEPARATOR.'com_acymailing'.DIRECTORY_SEPARATOR.'helpers'.DIRECTORY_SEPARATOR.'helper.php'); $userClass = acymailing_get('class.subscriber'); $userSubid = $userClass->subid($er_user->id); if(empty($userSubid)) return true; $db = JFactory::getDBO(); $query = 'UPDATE #__acymailing_subscriber SET `enabled` = "1" WHERE subid ='.intval($userSubid); $db->setQuery($query); $db->query(); return true; } }//endclass