本文整理汇总了PHP中Yum::hasModule方法的典型用法代码示例。如果您正苦于以下问题:PHP Yum::hasModule方法的具体用法?PHP Yum::hasModule怎么用?PHP Yum::hasModule使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Yum
的用法示例。
在下文中一共展示了Yum::hasModule方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: beforeControllerAction
public function beforeControllerAction($controller, $action)
{
if (!Yum::hasModule('role')) {
throw new Exception('Using the membership submodule requires the role module activated');
}
return parent::beforeControllerAction($controller, $action);
}
示例2: beforeAction
public function beforeAction($action)
{
if (!Yum::hasModule('friendship')) {
return false;
}
return parent::beforeAction($action);
}
示例3: beforeAction
public function beforeAction($action) {
if(!Yum::hasModule('registration'))
throw new CHttpException(401, 'Please activate the registration submodule in your config/main.php. See the installation instructions or registration/RegistrationModule.php for details');
if(!Yii::app()->user->isGuest)
$this->redirect(Yii::app()->user->returnUrl);
$this->layout = Yum::module('registration')->layout;
return parent::beforeAction($action);
}
示例4: afterSave
public function afterSave()
{
// If the user has activated email receiving, send a email
if ($user = $this->profile->user) {
if (Yum::hasModule('messages') && $user->privacy && $user->privacy->message_new_profilecomment) {
Yii::import('application.modules.messages.models.YumMessage');
YumMessage::write($user, $this->user_id, Yum::t('New profile comment from {username}', array('{username}' => $this->user->username)), YumTextSettings::getText('text_profilecomment_new', array('{username}' => $this->user->username, '{message}' => $this->comment, '{link_profile}' => Yii::app()->controller->createUrl('//profile/profile/view'))));
}
}
return parent::afterSave();
}
示例5: afterSave
public function afterSave()
{
// If the user has activated email receiving, send a email
if ($user = $this->profile->user) {
if (Yum::hasModule('messages') && $user->privacy && $user->privacy->message_new_profilecomment) {
Yii::import('application.modules.messages.models.YumMessage');
YumMessage::write($user, $this->user_id, Yum::t('New profile comment from {username}', array('{username}' => $this->user->username)), strtr('A new profile comment has been made from {username}: {message} <br /> <a href="{link_profile}">to my profile</a>', array('{username}' => $this->user->username, '{message}' => $this->comment, '{link_profile}' => Yii::app()->controller->createUrl('//profile/profile/view'))));
}
}
return parent::afterSave();
}
示例6: loginByHybridAuth
public function loginByHybridAuth($provider)
{
if (!Yum::module()->loginType & UserModule::LOGIN_BY_HYBRIDAUTH) {
throw new CException(400, 'Hybrid authentification is not allowed');
}
if (!Yum::hasModule('profile')) {
throw new CException(400, 'Hybrid auth needs the profile submodule to be enabled');
}
Yii::import('user.vendors.hybridauth.Hybrid.Auth', true);
Yii::import('user.profile.models.*');
require_once Yum::module()->hybridAuthConfigFile;
try {
$hybridauth = new Hybrid_Auth(Yum::module()->hybridAuthConfigFile);
$providers = Yum::module()->hybridAuthProviders;
if (count($providers) == 0) {
throw new CException('No Hybrid auth providers enabled in configuration file');
}
if (!in_array($provider, $providers)) {
throw new CException('Requested provider is not enabled in configuration file');
}
$success = $hybridauth->authenticate($provider);
if ($success && $success->isUserConnected()) {
// User found and authenticated at foreign party. Is he already
// registered at our application?
$hybridAuthProfile = $success->getUserProfile();
$user = $this->getUserByEmail($hybridAuthProfile->email);
if (!$user && !YumProfile::model()->findByAttributes(array('email' => $hybridAuthProfile->email))) {
// No, he is not, so we register the user and sync the profile fields
$user = new YumUser();
if (!$user->registerByHybridAuth($hybridAuthProfile)) {
Yum::setFlash(Yum::t('Registration by external provider failed'));
$this->redirect(Yum::module()->returnUrl);
} else {
Yum::setFlash('Registration successful');
}
}
$identity = new YumUserIdentity($user->username, null);
if ($identity->authenticate(true)) {
Yum::log(Yum::t('User {username} logged in by hybrid {provider}', array('{username}' => $hybridAuthProfile->displayName, '{email}' => $hybridAuthProfile->displayName, '{provider}' => $provider)));
Yii::app()->user->login($identity, Yum::module()->cookieDuration);
} else {
Yum::setFlash(Yum::t('Login by external provider failed'));
}
$this->redirect(Yum::module()->returnUrl);
}
} catch (Exception $e) {
if (Yum::module()->debug) {
throw new CException($e->getMessage());
} else {
throw new CHttpException(403, Yum::t('Permission denied'));
}
}
}
示例7: actionView
public function actionView()
{
$this->layout = Yum::module()->adminLayout;
$model = $this->loadModel();
$assignedUsers = new CActiveDataProvider('YumUser', array('criteria' => array('condition' => "role_id = {$model->id}", 'join' => 'left join ' . Yum::module('role')->userRoleTable . ' on t.id = user_id')));
$activeMemberships = false;
if (Yum::hasModule('membership')) {
Yii::import('application.modules.membership.models.*');
$activeMemberships = new CActiveDataProvider('YumMembership', array('criteria' => array('condition' => "membership_id = {$model->id}")));
}
$this->render('view', array('assignedUsers' => $assignedUsers, 'activeMemberships' => $activeMemberships, 'model' => $model));
}
示例8: beforeAction
public function beforeAction($action)
{
if (!Yum::hasModule('registration')) {
throw new CHttpException(401, 'Please activate the registration submodule in your config/main.php. See the installation instructions or registration/RegistrationModule.php for details');
}
if (!Yum::hasModule('profile')) {
throw new CHttpException(401, 'The Registration submodule depends on the profile submodule. Please see the installation instructions or registration/RegistrationModule.php for details');
}
Yii::import('profile.models.*');
Yii::import('registration.models.*');
if (!Yii::app()->user->isGuest) {
$this->redirect(Yii::app()->user->returnUrl);
}
$this->layout = Yum::module('registration')->layout;
return parent::beforeAction($action);
}
示例9: rules
public function rules()
{
$rules = parent::rules();
if (!(Yum::hasModule('registration') && Yum::module('registration')->registration_by_email)) {
$rules[] = array('username', 'required');
}
$rules[] = array('newsletter, terms,type_id', 'safe');
// password requirement is already checked in YumUser model, its sufficient
// to check for verifyPassword here
$rules[] = array('verifyPassword', 'required');
$rules[] = array('password', 'compare', 'compareAttribute' => 'verifyPassword', 'message' => Yum::t("Retype password is incorrect."));
if (Yum::module('registration')->enableCaptcha && !Yum::module()->debug) {
$rules[] = array('verifyCode', 'captcha', 'allowEmpty' => CCaptcha::checkRequirements());
}
return $rules;
}
示例10: authenticate
public function authenticate($without_password = false)
{
$user = YumUser::model()->find('username = :username', array(':username' => $this->username));
// try to authenticate via email
if (Yum::hasModule('profile') && Yum::module()->loginType & UserModule::LOGIN_BY_EMAIL && !$user) {
if ($profile = YumProfile::model()->find('email = :email', array(':email' => $this->username))) {
if ($profile->user) {
$user = $profile->user;
}
}
}
if (!$user) {
return self::ERROR_STATUS_USER_DOES_NOT_EXIST;
}
if ($user->status == YumUser::STATUS_INACTIVE) {
$this->errorCode = self::ERROR_STATUS_INACTIVE;
} else {
if ($user->status == YumUser::STATUS_BANNED) {
$this->errorCode = self::ERROR_STATUS_BANNED;
} else {
if ($user->status == YumUser::STATUS_REMOVED) {
$this->errorCode = self::ERROR_STATUS_REMOVED;
} else {
if ($without_password) {
$this->credentialsConfirmed($user);
} else {
if (!CPasswordHelper::verifyPassword($this->password, $user->password)) {
$this->errorCode = self::ERROR_PASSWORD_INVALID;
} else {
$this->credentialsConfirmed($user);
}
}
}
}
}
return !$this->errorCode;
}
示例11: array
}
?>
<div class="row-fluid">
<div class="span12">
<p class="hint">
<?php
if (Yum::hasModule('registration') && Yum::module('registration')->enableRegistration) {
echo CHtml::link(Yum::t("Registration"), Yum::module('registration')->registrationUrl);
}
if (Yum::hasModule('registration') && Yum::module('registration')->enableRegistration && Yum::module('registration')->enableRecovery) {
echo ' | ';
}
if (Yum::hasModule('registration') && Yum::module('registration')->enableRecovery) {
echo CHtml::link(Yum::t("Lost password?"), Yum::module('registration')->recoveryUrl);
}
?>
</p>
</div>
</div>
<div class="row-fluid">
<div class="span3">
<div class="buttons">
<p><?php
echo CHtml::submitButton(Yum::t('Login'), array('class' => 'btn'));
?>
</p>
示例12: loginByEmail
public function loginByEmail()
{
if (Yum::hasModule('profile')) {
Yii::import('application.modules.profile.models.*');
$profile = YumProfile::model()->find('email = :email', array(':email' => $this->loginForm->username));
if ($profile && $profile->user) {
return $this->authenticate($profile->user);
}
} else {
throw new CException(Yum::t('The profile submodule must be enabled to allow login by Email'));
}
}
示例13: array
<?php
$this->breadcrumbs = array(Yum::t('Data Generation'));
if (isset($_POST['user_amount'])) {
echo '<h2> Success </h2>';
printf('<p> <strong> %d </strong> %s been generated. The associated password is <em>%s</em> </p>', $_POST['user_amount'], $_POST['user_amount'] == 1 ? 'User has' : 'Users have', $_POST['password']);
echo '<br />';
}
echo CHtml::beginForm();
echo '<h2> Random user Generator </h2>';
printf('Generate %s %s users <br />
belonging to role %s <br />
with associated password %s', CHtml::textField('user_amount', '1', array('size' => 2)), CHtml::dropDownList('status', 1, array('-1' => Yum::t('banned'), '0' => Yum::t('inactive'), '1' => Yum::t('active'))), Yum::hasModule('role') ? CHtml::dropDownList('role', '', CHtml::listData(YumRole::model()->findAll(), 'id', 'title')) : ' - ', CHtml::textField('password', 'Demopassword123'));
echo '<br />';
echo CHtml::submitButton(Yum::t('Generate'));
echo CHtml::endForm();
示例14: authenticate
public function authenticate($without_password = false)
{
$user = YumUser::model()->find('username = :username', array(
':username' => $this->username));
// try to authenticate via email
if(!$user && (Yum::module()->loginType & 2) && Yum::hasModule('profile')) {
if($profile = YumProfile::model()->find('email = :email', array(
':email' => $this->username)))
if($profile->user)
$user = $profile->user;
}
if(!$user)
return self::ERROR_STATUS_USER_DOES_NOT_EXIST;
if($without_password)
$this->credentialsConfirmed($user);
else if(YumUser::encrypt($this->password)!==$user->password)
$this->errorCode=self::ERROR_PASSWORD_INVALID;
else if($user->status == YumUser::STATUS_INACTIVE)
$this->errorCode=self::ERROR_STATUS_INACTIVE;
else if($user->status == YumUser::STATUS_BANNED)
$this->errorCode=self::ERROR_STATUS_BANNED;
else if($user->status == YumUser::STATUS_REMOVED)
$this->errorCode=self::ERROR_STATUS_REMOVED;
else
$this->credentialsConfirmed($user);
return !$this->errorCode;
}
示例15: exit
exit('YUMPROFILEHEREE');
//Yii::app()->clientScript->registerCssFile(
// Yii::app()->getAssetManager()->publish(
// Yii::getPathOfAlias('YumAssets').'/css/yum.css'));
//$module = Yii::app()->getModule('user');
//$this->beginContent($module->baseLayout);
?>
<div id="usermenu">
<?php
Yum::renderFlash();
if (Yum::hasModule('message')) {
Yii::import('user.message.components.*');
$this->widget('MessageWidget');
}
if (Yum::hasModule('profile') && Yum::module('profile')->enableProfileVisitLogging) {
Yii::import('user.profile.components.*');
$this->widget('ProfileVisitWidget');
}
$this->renderMenu();
?>
</div>
<div id="usercontent">
<?php
echo $content;
?>
</div>
<?php