本文整理汇总了PHP中ActiveRecord::randString方法的典型用法代码示例。如果您正苦于以下问题:PHP ActiveRecord::randString方法的具体用法?PHP ActiveRecord::randString怎么用?PHP ActiveRecord::randString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ActiveRecord
的用法示例。
在下文中一共展示了ActiveRecord::randString方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: saveFile
/**
* Jun 07, 2014 - ANH DUNG
* To do: save file
* @param: $model is model ProGlobalEnquiry
* @param: $fieldName file_name
* @return: name of image upload/global_enquiry
*/
public static function saveFile($model, $fieldName)
{
if (is_null($model->{$fieldName})) {
return '';
}
$aDate = explode('-', $model->date_only);
$pathUpload = ProGlobalEnquiry::$folderUpload . "/{$aDate['0']}/{$aDate['1']}/{$aDate['2']}";
$ext = $model->{$fieldName}->getExtensionName();
$file_name_slug = strtolower(MyFunctionCustom::slugify($model->{$fieldName}->getName()));
$file_name_slug = str_replace(strtolower($ext), '', $file_name_slug);
$model->file_name_slug = $file_name_slug;
$fileName = date('Y-m-d');
$fileName = time() . '-' . ActiveRecord::randString() . '.' . $ext;
$imageProcessing = new ImageProcessing();
$imageProcessing->createDirectoryByPath($pathUpload);
$model->{$fieldName}->saveAs($pathUpload . '/' . $fileName);
$model->{$fieldName} = $fileName;
return $fileName;
}
示例2: actionResetPassword
public function actionResetPassword()
{
$id = Yii::app()->request->getParam('id');
$key = Yii::app()->request->getParam('key');
$model = Users::model()->findByPk((int) $id);
if ($model !== null && $key == ForgotPasswordForm::generateKey($model)) {
$pass = ActiveRecord::randString(6);
$model->password_hash = md5($pass);
$model->temp_password = $pass;
$model->update();
$name = $model->first_name . ' ' . $model->last_name;
$login_link = '<a href="' . Yii::app()->createAbsoluteUrl("admin/site/login") . '">' . Yii::app()->createAbsoluteUrl("admin/site/login") . '</a>';
$aBody = array('{NAME}' => $name, '{PASSWORD}' => $model->temp_password, '{LINK_LOGIN}' => $login_link);
if (CmsEmail::sendmail(2, array(), $aBody, $model->email)) {
Yii::app()->user->setFlash("success", "An email has sent to: {$model->email}. Please check email to get new password.");
} else {
$model->addError('email', 'Can not send email to: ' . $model->email);
}
} else {
Yii::log('Invalid request. Please do not repeat this request again.');
throw new CHttpException(400, 'Invalid request. Please do not repeat this request again.');
}
$this->render('ResetPassword', array('model' => $model));
}
示例3: SavePhotoListing
/**
* @Author: ANH DUNG Aug 12, 2014
* @Todo: save photo listing upload
* @Param: $model model
*/
public static function SavePhotoListing($model)
{
$uid = Yii::app()->user->id;
if (isset($_FILES['Listing']['name']['photo_listing_anhdung']) && count($_FILES['Listing']['name']['photo_listing_anhdung'])) {
$cMaxDisplay = ProListingPhotos::GetMaxDisplayOrder($model->id);
foreach ($_FILES['Listing']['name']['photo_listing_anhdung'] as $key => $item) {
if (Listing::CountPhotoListing($model->id) >= Listing::GetLimitPhotoUpload()) {
return;
}
$mFile = new ProListingPhotos();
$mFile->FileValidate = CUploadedFile::getInstanceByName('Listing[photo_listing_anhdung][' . $key . ']');
$mFile->validate();
if (!$mFile->hasErrors()) {
$ext = $mFile->FileValidate->getExtensionName();
$mFile->image = $uid . "-" . time() . ActiveRecord::randString() . $key . '.' . $ext;
// file name
$mFile->listing_id = $model->id;
$mFile->default = 0;
$mFile->display_order = ++$cMaxDisplay;
$mFile->save();
Listing::saveFile($mFile, 'FileValidate', $mFile->image);
Listing::ResizePhotoListing($mFile);
Listing::PutWarterMarkPhotoListing($mFile);
Listing::ResizePhotoListingSmall($mFile);
}
}
Listing::AutoSetCoverPhotoListing($model->id);
}
}
示例4: saveFile
/**
* Jun 07, 2014 - ANH DUNG
* To do: save file
* @param: $model is model ProGlobalEnquiry
* @param: $fieldName file_name
* @return: name of image upload/global_enquiry
*/
public static function saveFile($model, $fieldName)
{
if (is_null($model->{$fieldName})) {
return '';
}
$pathUpload = ProInventoryPhoto::$folderUpload;
$ext = $model->{$fieldName}->getExtensionName();
$file_name_slug = strtolower(MyFunctionCustom::slugify($model->{$fieldName}->getName()));
$file_name_slug = str_replace(strtolower($ext), '', $file_name_slug);
$model->file_name_slug = $file_name_slug;
$fileName = date('Y-m-d');
$uid = isset(Yii::app()->user->id) ? Yii::app()->user->id : 999999;
$fileName = $uid . '-' . time() . '-' . ActiveRecord::randString() . '.' . $ext;
$imageProcessing = new ImageProcessing();
$imageProcessing->createDirectoryByPath($pathUpload);
$model->{$fieldName}->saveAs($pathUpload . '/' . $fileName);
$model->{$fieldName} = $fileName;
return $fileName;
}
示例5: saveFile
/**
* Jul 08, 2014 - ANH DUNG
* To do: save file
* @param: $model model ProAirconService:
* @param: $nameField ex: file_name
* @param: $pathUpload ex: 'upload/aircon_service:'
* @return: name of image
*/
public static function saveFile($model, $nameField, $pathUpload, $count)
{
if (is_null($model->{$nameField})) {
return '';
}
$ext = $model->{$nameField}->getExtensionName();
$fileName = MyFunctionCustom::slugify($model->{$nameField}->getName());
$fileName = str_replace(strtolower($ext), '', $fileName);
$fileName = trim($fileName, '-');
$fileName = trim($fileName);
$fileName = $fileName . '-' . time() . ActiveRecord::randString() . '.' . $ext;
$imageProcessing = new ImageProcessing();
$imageProcessing->createDirectoryByPath($pathUpload);
// $imageProcessing->createDirectoryByPath($pathUpload.'/'.$model->id);
// $model->$nameField->saveAs($pathUpload.'/'.$model->id.'/'.$fileName);
$model->{$nameField}->saveAs($pathUpload . '/' . $fileName);
return $fileName;
}
示例6: loadItems
return;
}
if (!empty($name)) {
$result = Users::model()->findByPk($id)->{$name};
} else {
$result = Users::model()->findByPk($id);
}
return $result;
}
public static function loadItems($emptyOption = false)
{
$_items = array();
if ($emptyOption) {
$_items[""] = "";
}
$model = self::model()->findByPk(Yii::app()->user->getId());
//foreach($models as $model)
$_items[$model->id] = $model->email;
return $_items;
}
public static function generateKey($user)