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


PHP Yum类代码示例

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


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

示例1: actionCreate

 public function actionCreate()
 {
     $this->layout = Yum::module()->adminLayout;
     $model = new YumPermission();
     $this->performAjaxValidation($model, 'permission-create-form');
     if (isset($_POST['YumPermission'])) {
         $model->attributes = $_POST['YumPermission'];
         if ($model->validate()) {
             if ($_POST['YumPermission']['type'] == 'user') {
                 $model->subordinate = $_POST['YumPermission']['subordinate_id'];
                 $model->principal = $_POST['YumPermission']['principal_id'];
             } else {
                 if ($_POST['YumPermission']['type'] == 'role') {
                     $model->subordinate_role = $_POST['YumPermission']['subordinate_id'];
                     $model->principal_role = $_POST['YumPermission']['principal_id'];
                 }
             }
             if ($model->save()) {
                 $this->redirect(array('admin'));
             }
             return;
         }
     }
     $model->type = 'user';
     // preselect 'user'
     $this->render('create', array('model' => $model));
 }
开发者ID:Canyian,项目名称:yii-user-management-facebook,代码行数:27,代码来源:YumPermissionController.php

示例2: rules

	public function rules() 
	{
		$rules = parent::rules();

		/* FIXME: As soon as i grasp how i can dynamically add variables to a 
			 class in PHP, i will enable this code snippet for flexibility:

			 $profile = new YumProfile;
			 $profile_rules = $profile->rules();
			 foreach($profile_rules as $rule) 
			 if(isset($rule[0]) && is_string($rule[0]))
			 $this->${$rule[0]} = ''; 

			 $rules = array_merge($rules, $profile->rules());	 */

		$rules[] = array('username', 'required');
		$rules[] = array('password, verifyPassword', 'required');
		$rules[] = array('password', 'compare',
				'compareAttribute'=>'verifyPassword',
				'message' => Yum::t("Retype password is incorrect."));
		if(Yum::module('registration')->enableCaptcha)
			$rules[] = array('verifyCode', 'captcha',
					'allowEmpty'=>CCaptcha::checkRequirements()); 

		return $rules;
	}
开发者ID:neam,项目名称:yii-user-management,代码行数:26,代码来源:YumRegistrationForm.php

示例3: 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

示例4: actionLeave

 public function actionLeave($id = null)
 {
     if ($id !== null) {
         $p = YumUsergroup::model()->findByPk($id);
         $participants = $p->participants;
         if (!in_array(Yii::app()->user->id, $participants)) {
             Yum::setFlash(Yum::t('You are not participating in this group'));
         } else {
             $participants = $p->participants;
             foreach ($participants as $key => $participant) {
                 if ($participant == Yii::app()->user->id) {
                     unset($participants[$key]);
                 }
             }
             $p->participants = $participants;
             if ($p->save(array('participants'))) {
                 Yum::setFlash(Yum::t('You have left this group'));
                 Yum::log(Yum::t('User {username} left group id {id}', array('{username}' => Yii::app()->user->data()->username, '{id}' => $id)));
             }
         }
         $this->redirect(array('//usergroup/groups/index'));
     } else {
         throw new CHttpException(404);
     }
 }
开发者ID:usmansaleem10,项目名称:youthpowered,代码行数:25,代码来源:YumUsergroupController.php

示例5: beforeAction

 public function beforeAction($action)
 {
     if (Yum::module()->enableOnlineStatus && !Yii::app()->user->isGuest) {
         Yii::app()->user->data()->setLastAction();
     }
     return parent::beforeAction($action);
 }
开发者ID:bhaveshsoni,项目名称:yii-user-management,代码行数:7,代码来源:YumController.php

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

示例7: init

 public function init()
 {
     if ($this->title === NULL) {
         $this->title = Yum::t('Login');
     }
     parent::init();
 }
开发者ID:kumarsivarajan,项目名称:yii-user-management,代码行数:7,代码来源:LoginWidget.php

示例8: itemAlias

	public static function itemAlias($type,$code=NULL) {
		$_items = array(
				'field_type' => array(
					'INTEGER' => Yum::t('INTEGER'),
					'VARCHAR' => Yum::t( 'VARCHAR'),
					'TEXT'=> Yum::t( 'TEXT'),
					'DATE'=> Yum::t( 'DATE'),
					'DROPDOWNLIST' => Yum::t('DROPDOWNLIST'),
					'FLOAT'=> Yum::t('FLOAT'),
					'BOOL'=> Yum::t('BOOL'),
					'BLOB'=> Yum::t('BLOB'),
					'BINARY'=> Yum::t('BINARY'),
					'FILE'=> 'FILE',
					),
				'required' => array(
					'0' => Yum::t('No'),
					'1' => Yum::t('Yes'),
					),
				'visible' => array(
					self::VISIBLE_USER_DECISION => Yum::t('Let the user choose in privacy settings'),
					self::VISIBLE_PUBLIC => Yum::t('For all'),
					self::VISIBLE_REGISTER_USER => Yum::t('Registered users'),
					self::VISIBLE_ONLY_OWNER => Yum::t('Only owner'),
					self::VISIBLE_HIDDEN => Yum::t('Hidden'),
					),
				);
		if (isset($code))
			return isset($_items[$type][$code]) ? $_items[$type][$code] : false;
		else
			return isset($_items[$type]) ? $_items[$type] : false;
	}
开发者ID:neam,项目名称:yii-user-management,代码行数:31,代码来源:YumProfileField.php

示例9: behaviors

 /**
  * Adds the CAdvancedArBehavior and, if enabled, the LoggableBehavior to
  * every YUM Active Record model
  * @return array
  */
 public function behaviors()
 {
     $behaviors = array('CAdvancedArBehavior');
     if (Yum::module()->enableAuditTrail) {
         $behaviors = array_merge($behaviors, array('LoggableBehavior' => 'application.modules.auditTrail.behaviors.LoggableBehavior'));
     }
     return $behaviors;
 }
开发者ID:snapfrozen,项目名称:boxomatic,代码行数:13,代码来源:YumActiveRecord.php

示例10: init

 public function init()
 {
     $this->title = Yum::t('Profile Comments');
     if (Yii::app()->user->isGuest) {
         return false;
     }
     parent::init();
 }
开发者ID:kumarsivarajan,项目名称:yii-user-management,代码行数:8,代码来源:ProfileCommentsWidget.php

示例11: createRandomPassword

	public function createRandomPassword() {

		$lowercase = Yum::module()->passwordRequirements['minLowerCase'];
		$uppercase = Yum::module()->passwordRequirements['minUpperCase'];
		$minnumbers = Yum::module()->passwordRequirements['minDigits'];
		$max = Yum::module()->passwordRequirements['maxLen'];

		$chars = "abcdefghijkmnopqrstuvwxyz";
		$numbers = "1023456789";
		srand((double) microtime() * 1000000);
		$i = 0;
		$current_lc = 0;
		$current_uc = 0;
		$current_dd = 0;
		$password = '';
		while ($i <= $max) {
			if ($current_lc < $lowercase) {
				$charnum = rand() % 22;
				$tmpchar = substr($chars, $charnum, 1);
				$password = $password . $tmpchar;
				$i++;
			}

			if ($current_uc < $uppercase) {
				$charnum = rand() % 22;
				$tmpchar = substr($chars, $charnum, 1);
				$password = $password . strtoupper($tmpchar);
				$i++;
			}

			if ($current_dd < $minnumbers) {
				$charnum = rand() % 9;
				$tmpchar = substr($numbers, $charnum, 1);
				$password = $password . $tmpchar;
				$i++;
			}

			if ($current_lc == $lowercase && $current_uc == $uppercase && $current_dd == $numbers && $i < $max) {
				$charnum = rand() % 22;
				$tmpchar = substr($chars, $charnum, 1);
				$password = $password . $tmpchar;
				$i++;
				if ($i < $max) {
					$charnum = rand() % 9;
					$tmpchar = substr($numbers, $charnum, 1);
					$password = $password . $tmpchar;
					$i++;
				}
				if ($i < $max) {
					$charnum = rand() % 22;
					$tmpchar = substr($chars, $charnum, 1);
					$password = $password . strtoupper($tmpchar);
					$i++;
				}
			}
		}
		return $password;
	}
开发者ID:neam,项目名称:yii-user-management,代码行数:58,代码来源:YumUserChangePassword.php

示例12: beforeAction

 public function beforeAction($event)
 {
     if (Yii::app()->user->isAdmin()) {
         $this->layout = Yum::module('userproject')->adminLayout;
     } else {
         $this->layout = Yum::module('userproject')->layout;
     }
     return parent::beforeAction($event);
 }
开发者ID:usmansaleem10,项目名称:youthpowered,代码行数:9,代码来源:YumUserProjectController.php

示例13: attributeLabels

	public function attributeLabels()
	{
		return array(
			'id' => Yum::t('ID'),
			'user_id' => Yum::t('Written from'),
			'profile_id' => Yum::t('Profile'),
			'comment' => Yum::t('Comment'),
			'createtime' => Yum::t('Written at'),
		);
	}
开发者ID:richardh68,项目名称:yii-user-management,代码行数:10,代码来源:YumProfileComment.php

示例14: renderContent

 protected function renderContent()
 {
     if (Yum::module('message')->messageSystem === false) {
         return false;
     }
     if (!Yii::app()->user->isGuest) {
         $messages = YumMessage::model()->unread()->limit(10)->findAll();
         $this->render('messages', array('messages' => $messages));
     }
 }
开发者ID:kumarsivarajan,项目名称:yii-user-management,代码行数:10,代码来源:MessageWidget.php

示例15: actionDelete

 public function actionDelete($id)
 {
     $comment = YumProfileComment::model()->findByPk($id);
     if ($comment->user_id == Yii::app()->user->id || $comment->profile_id == Yii::app()->user->id) {
         $comment->delete();
         $this->redirect(array(Yum::module('profile')->profileView, 'id' => $comment->profile->user_id));
     } else {
         throw new CHttpException(403, Yum::t('You are not the owner of this Comment or this Profile!'));
     }
 }
开发者ID:kumarsivarajan,项目名称:yii-user-management,代码行数:10,代码来源:YumProfileCommentController.php


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