/** * Can load default profile or J! profile in addition to standard behavior * * @param type $data */ public function load($data) { if (!parent::load($data)) { if (!is_numeric($data) || $data != self::DEFAULT_SMTP_ID && $data != self::JOOMLA_SMTP_ID) { return false; } // If user wants to load DEFAULT SMTPP then determine it. if ($data == self::DEFAULT_SMTP_ID) { $data = $this->getDefaultSmtpId(); } // If we determine that need to load J! SMTPP // then change filter to load it. if ($data == self::JOOMLA_SMTP_ID) { $data = array('is_joomla' => 1); $isJoomla = true; } if (!parent::load($data)) { if (empty($isJoomla)) { return false; } if (!$this->save((array) $this->_getJoomlaProfile())) { return false; } } } // If loaded profile is J! profile // then fill it with J! SMTP settings if ($this->isJoomlaProfile()) { $this->addFromArray($this->_getJoomlaProfile()); } if (empty($this->_data->params)) { $this->_data->params = (object) $this->_defaults['params']; $this->save(); } return true; }
protected function _checkOnTheFly($data) { if (empty($data)) { return false; } // If not then load J! user and create row in subscribers for it $dbo = JFactory::getDbo(); $query = $dbo->getQuery(true); $query->select('*')->from('#__users'); if (is_numeric($data)) { $query->where('id = ' . abs((int) $data)); } else { foreach ($data as $name => $item) { $query->where($name . '=' . $dbo->quote($item)); } } $dbo->setQuery($query); $user = $dbo->loadAssoc(); if (empty($user['id'])) { return false; } if (parent::load(array('user_id' => $user['id']))) { return true; } $data = array(); $data['user_id'] = $user['id']; $data['created_on'] = date('Y-m-d H:i:s'); $data['created_by'] = JFactory::getUser()->id; $data['modified_on'] = 0; $data['modified_by'] = 0; $data['locked_on'] = 0; $data['locked_by'] = 0; if (!parent::save($data)) { return false; } $this->_createSubscriptionKey(); $this->_data->confirmed = empty($table->activation) ? 1 : $this->_data->subscription_key; return parent::save(); }
/** * Load default Mailbox profile * * @param type $data */ public function loadDefault() { return parent::load($this->getDefaultId()); }