当前位置: 首页>>代码示例>>PHP>>正文


PHP YumUser::model方法代码示例

本文整理汇总了PHP中YumUser::model方法的典型用法代码示例。如果您正苦于以下问题:PHP YumUser::model方法的具体用法?PHP YumUser::model怎么用?PHP YumUser::model使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在YumUser的用法示例。


在下文中一共展示了YumUser::model方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: actionEditAvatar

 public function actionEditAvatar()
 {
     $model = YumUser::model()->findByPk(Yii::app()->user->id);
     if (isset($_POST['YumUser'])) {
         $model->attributes = $_POST['YumUser'];
         $model->setScenario('avatarUpload');
         if (Yum::module('avatar')->avatarMaxWidth != 0) {
             $model->setScenario('avatarSizeCheck');
         }
         $model->avatar = CUploadedFile::getInstanceByName('YumUser[avatar]');
         if ($model->validate()) {
             if ($model->avatar instanceof CUploadedFile) {
                 // Prepend the id of the user to avoid filename conflicts
                 $filename = Yum::module('avatar')->avatarPath . '/' . $model->id . '_' . $_FILES['YumUser']['name']['avatar'];
                 $model->avatar->saveAs($filename);
                 $model->avatar = $filename;
                 if ($model->save()) {
                     Yum::setFlash(Yum::t('The image was uploaded successfully'));
                     Yum::log(Yum::t('User {username} uploaded avatar image {filename}', array('{username}' => $model->username, '{filename}' => $model->avatar)));
                     $this->redirect(array('//profile/profile/view'));
                 }
             }
         }
     }
     $this->render('edit_avatar', array('model' => $model));
 }
开发者ID:Canyian,项目名称:yii-user-management-facebook,代码行数:26,代码来源:YumAvatarController.php

示例2: renderContent

 protected function renderContent()
 {
     parent::renderContent();
     if (Yii::app()->user->isGuest) {
         return false;
     }
     $user = YumUser::model()->findByPk(Yii::app()->user->id);
     $this->render('profile_comments', array('comments' => Yii::app()->user->data()->profile->recentComments()));
 }
开发者ID:kumarsivarajan,项目名称:yii-user-management,代码行数:9,代码来源:ProfileCommentsWidget.php

示例3: checkexists

 public function checkexists($attribute, $params)
 {
     $user = null;
     // we only want to authenticate when there are no input errors so far
     if (!$this->hasErrors()) {
         if (strpos($this->login_or_email, "@")) {
             $profile = YumProfile::model()->findByAttributes(array('email' => $this->login_or_email));
             $this->user = $profile && $profile->user && $profile->user instanceof YumUser ? $profile->user : null;
         } else {
             $this->user = YumUser::model()->findByAttributes(array('username' => $this->login_or_email));
         }
     }
 }
开发者ID:kumarsivarajan,项目名称:yii-user-management,代码行数:13,代码来源:YumPasswordRecoveryForm.php

示例4: loadModel

 public function loadModel($id = null)
 {
     if (!$id) {
         $id = Yii::app()->user->id;
     }
     if (is_numeric($id)) {
         return $this->_model = YumUser::model()->findByPk($id);
     } else {
         if (is_string($id)) {
             return $this->_model = YumUser::model()->find("username = '{$id}'");
         }
     }
 }
开发者ID:kumarsivarajan,项目名称:yii-user-management,代码行数:13,代码来源:YumProfileController.php

示例5: isPublic

	public function isPublic($user = null) {
		if($user == null)
			$user = Yii::app()->user->id;

		if(!$this->visible)
			return false;

		if($privacy = YumUser::model()->findByPk($user)->privacy) {
			if($privacy->public_profile_fields & pow(2, $this->id))
				return true;
		}

		return false;
	}
开发者ID:neam,项目名称:yii-user-management,代码行数:14,代码来源:YumProfileField.php

示例6: getPublicFields

 public function getPublicFields()
 {
     if (!Yum::module('profile')->enablePrivacySetting) {
         return false;
     }
     $fields = array();
     if ($privacy = @YumUser::model()->cache(500)->with('privacy')->findByPk($this->user_id)->privacy->public_profile_fields) {
         $i = 1;
         foreach (YumProfileField::model()->cache(500)->findAll() as $field) {
             if ($i & $privacy && $field->visible != 0) {
                 $fields[] = $field;
             }
             $i *= 2;
         }
     }
     return $fields;
 }
开发者ID:bhaveshsoni,项目名称:yii-user-management,代码行数:17,代码来源:YumProfile.php

示例7: actionCreate

 public function actionCreate()
 {
     $this->layout = Yum::module()->adminLayout;
     $model = new YumRole();
     $this->performAjaxValidation($model, 'yum-role-form');
     if (isset($_POST['YumRole'])) {
         $model->attributes = $_POST['YumRole'];
         if ($model->save()) {
             if (Yum::module()->enableLogging == true) {
                 $user = YumUser::model()->findbyPK(Yii::app()->user->id);
                 Yum::log(Yum::t('The role {role} has been created by {username}', array('{role}' => $model->title, '{username}' => Yii::app()->user->data()->username)));
             }
             $this->redirect(array('admin'));
         }
     }
     $this->render('create', array('model' => $model));
 }
开发者ID:kumarsivarajan,项目名称:yii-user-management,代码行数:17,代码来源:YumRoleController.php

示例8: actionCompose

 public function actionCompose($to_user_id = null, $answer_to = 0)
 {
     $model = new YumMessage();
     $this->performAjaxValidation('YumMessage', 'yum-message-form');
     if (isset($_POST['YumMessage'])) {
         $model->attributes = $_POST['YumMessage'];
         $model->from_user_id = Yii::app()->user->id;
         $model->validate();
         if (!$model->hasErrors()) {
             $model->save();
             Yum::setFlash(Yum::t('Message "{message}" has been sent to {to}', array('{message}' => $model->title, '{to}' => YumUser::model()->findByPk($model->to_user_id)->username)));
             $this->redirect(Yum::module('message')->inboxRoute);
         }
     }
     $fct = 'render';
     if (Yii::app()->request->isAjaxRequest) {
         $fct = 'renderPartial';
     }
     $this->{$fct}('compose', array('model' => $model, 'to_user_id' => $to_user_id, 'answer_to' => $answer_to));
 }
开发者ID:Canyian,项目名称:yii-user-management-facebook,代码行数:20,代码来源:YumMessageController.php

示例9: 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;
 }
开发者ID:kumarsivarajan,项目名称:yii-user-management,代码行数:37,代码来源:YumUserIdentity.php

示例10: write

 public static function write($to, $from, $subject, $body, $mail = true)
 {
     $message = new YumMessage();
     if (!$mail) {
         $message->omit_mail = true;
     }
     if (is_object($from)) {
         $message->from_user_id = (int) $from->id;
     } else {
         if (is_numeric($from)) {
             $message->from_user_id = $from;
         } else {
             if (is_string($from) && ($user = YumUser::model()->find("username = '{$from}'"))) {
                 $message->from_user_id = $user->id;
             } else {
                 return false;
             }
         }
     }
     if (is_object($to)) {
         $message->to_user_id = (int) $to->id;
     } else {
         if (is_numeric($to)) {
             $message->to_user_id = $to;
         } else {
             if (is_string($to) && ($user = YumUser::model()->find("username = '{$to}'"))) {
                 $message->to_user_id = $user->id;
             } else {
                 return false;
             }
         }
     }
     $message->title = $subject;
     $message->message = $body;
     return $message->save();
 }
开发者ID:Canyian,项目名称:yii-user-management-facebook,代码行数:36,代码来源:YumMessage.php

示例11: beforeSave

 public function beforeSave()
 {
     $this->updatetime = time();
     // If the user has activated email receiving, send a email
     if ($this->isNewRecord) {
         if ($user = YumUser::model()->findByPk($this->friend_id)) {
             if (Yum::hasModule('messages') && $user->privacy && $user->privacy->message_new_friendship) {
                 Yii::import('application.modules.messages.models.YumMessage');
                 YumMessage::write($user, $this->inviter, Yum::t('New friendship request from {username}', array('{username}' => $this->inviter->username)), YumTextSettings::getText('text_friendship_new', array('{username}' => $this->inviter->username, '{link_friends}' => Yii::app()->controller->createUrl('//friendship/friendship/index'), '{link_profile}' => Yii::app()->controller->createUrl('//profile/profile/view'), '{message}' => $this->message)));
             }
         }
     }
     return parent::beforeSave();
 }
开发者ID:bhaveshsoni,项目名称:yii-user-management,代码行数:14,代码来源:YumFriendship.php

示例12: _checkAuth

 private function _checkAuth()
 {
     foreach (array('HTTP_X_USERNAME', 'PHP_AUTH_USER') as $var) {
         if (isset($_SERVER[$var]) && $_SERVER[$var] != '') {
             $username = $_SERVER[$var];
         }
     }
     foreach (array('HTTP_X_PASSWORD', 'PHP_AUTH_PW') as $var) {
         if (isset($_SERVER[$var]) && $_SERVER[$var] != '') {
             $password = $_SERVER[$var];
         }
     }
     if ($username && $password) {
         $user = YumUser::model()->find('LOWER(username)=?', array(strtolower($username)));
         if (Yum::module()->RESTfulCleartextPasswords && $user !== null && $user->superuser && md5($password) == $user->password) {
             return true;
         }
         if (!Yum::module()->RESTfulCleartextPasswords && $user !== null && $user->superuser && $password == $user->password) {
             return true;
         }
     }
     $this->_sendResponse(401, 'Error: Username or password is invalid');
 }
开发者ID:bhaveshsoni,项目名称:yii-user-management,代码行数:23,代码来源:YumRestController.php

示例13: loginsToday

 public function loginsToday()
 {
     $day = $this->getStartOfDay(time());
     return YumUser::model()->count('lastvisit > :begin and lastvisit < :end', array(':begin' => $day, ':end' => $day + 86400));
 }
开发者ID:Canyian,项目名称:yii-user-management-facebook,代码行数:5,代码来源:YumStatisticsController.php

示例14: getAdmins

 /**
  * Return admins.
  * @return array syperusers names
  */
 public static function getAdmins()
 {
     $admins = YumUser::model()->active()->superuser()->findAll();
     $returnarray = array();
     foreach ($admins as $admin) {
         array_push($returnarray, $admin->username);
     }
     return $returnarray;
 }
开发者ID:Canyian,项目名称:yii-user-management-facebook,代码行数:13,代码来源:YumUser.php

示例15: actionLogout

 public function actionLogout()
 {
     // If the user is already logged out send them to returnLogoutUrl
     if (Yii::app()->user->isGuest) {
         $this->redirect(Yum::module()->returnLogoutUrl);
     }
     // let's delete the login_type cookie
     $cookie = Yii::app()->request->cookies['login_type'];
     if ($cookie) {
         $cookie->expire = time() - Yum::module()->cookieDuration;
         Yii::app()->request->cookies['login_type'] = $cookie;
     }
     if ($user = YumUser::model()->findByPk(Yii::app()->user->id)) {
         $user->logout();
         Yum::log(Yum::t('User {username} logged off', array('{username}' => $user->username)));
         Yii::app()->user->logout();
     }
     $this->redirect(Yum::module()->returnLogoutUrl);
 }
开发者ID:kumarsivarajan,项目名称:yii-user-management,代码行数:19,代码来源:YumAuthController.php


注:本文中的YumUser::model方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。