本文整理匯總了PHP中Group::validate方法的典型用法代碼示例。如果您正苦於以下問題:PHP Group::validate方法的具體用法?PHP Group::validate怎麽用?PHP Group::validate使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Group
的用法示例。
在下文中一共展示了Group::validate方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: store
public static function store()
{
$p = $_POST;
$group = new Group($p);
if (count($group->validate()) > 0) {
die("errors");
$errors = $group->validate();
View::make("group/new.html", array("errors" => $errors, 'name' => $_POST['name']));
} else {
$group->store();
Redirect::to("/group", array('message' => "New Group has been saved."));
}
}
示例2: doValidate
/**
* This function performs the validation work for complex object models.
*
* In addition to checking the current object, all related objects will
* also be validated. If all pass then <code>true</code> is returned; otherwise
* an aggreagated array of ValidationFailed objects will be returned.
*
* @param array $columns Array of column names to validate.
* @return mixed <code>true</code> if all validations pass; array of <code>ValidationFailed</code> objets otherwise.
*/
protected function doValidate($columns = null)
{
if (!$this->alreadyInValidation) {
$this->alreadyInValidation = true;
$retval = null;
$failureMap = array();
// We call the validate method on the following object(s) if they
// were passed to this object by their coresponding set
// method. This object relates to these object(s) by a
// foreign key reference.
if ($this->aGroup !== null) {
if (!$this->aGroup->validate($columns)) {
$failureMap = array_merge($failureMap, $this->aGroup->getValidationFailures());
}
}
if ($this->aUser !== null) {
if (!$this->aUser->validate($columns)) {
$failureMap = array_merge($failureMap, $this->aUser->getValidationFailures());
}
}
if (($retval = DirectoryPermissionPeer::doValidate($this, $columns)) !== true) {
$failureMap = array_merge($failureMap, $retval);
}
$this->alreadyInValidation = false;
}
return !empty($failureMap) ? $failureMap : true;
}
示例3: postGroup
public function postGroup($id = null)
{
if (Input::has('id')) {
$group = Group::find(Input::get('id'));
if (!$group->isGroupOwner(Auth::user()->id)) {
return Response::json($this->growlMessage('You cannot modify a group you do not own.', 'error'));
}
$message = "Your group has been updated!";
} else {
$group = new Group();
$group->status = Group::STATUS_PENDING;
$message = "Your group has been created! It must be approved before you can invite others to join or create documents.";
}
$postData = array('name', 'display_name', 'address1', 'address2', 'city', 'state', 'postal_code', 'phone_number');
foreach ($postData as $field) {
$group->{$field} = Input::get($field);
}
if ($group->validate()) {
$group->save();
$group->addMember(Auth::user()->id, Group::ROLE_OWNER);
if ($group->status === Group::STATUS_PENDING) {
Event::fire(MadisonEvent::VERIFY_REQUEST_GROUP, $group);
}
return Response::json($this->growlMessage($message, 'success'));
} else {
return Response::json($this->growlMessage($group->getErrors()->all(), 'error'), 400);
}
}
示例4: actionEdit
/**
* Edits or Creates a user group
*/
public function actionEdit()
{
// Create Group Edit Form
$group = Group::model()->findByPk(Yii::app()->request->getQuery('id'));
if ($group === null) {
$group = new Group();
}
$group->scenario = 'edit';
$group->populateDefaultSpaceGuid();
$group->populateAdminGuids();
// uncomment the following code to enable ajax-based validation
if (isset($_POST['ajax']) && $_POST['ajax'] === 'admin-group-form') {
echo CActiveForm::validate($model);
Yii::app()->end();
}
if (isset($_POST['Group'])) {
$_POST = Yii::app()->input->stripClean($_POST);
$group->attributes = $_POST['Group'];
if ($group->validate()) {
$group->save();
// Redirect to admin groups overview
$this->redirect(Yii::app()->createUrl('//admin/group'));
}
}
$this->render('edit', array('group' => $group));
}
示例5: edit
public function edit($name)
{
$group = Group::where('group_name', $name)->firstOrFail();
self::checkOwner(self::userFp(), $name);
if (Request::isMethod('GET')) {
return View::make('group.edit', ['group' => $group]);
} else {
$input = Input::only('group_name', 'group_title', 'description', 'submit_text', 'is_private');
Group::validate($input);
Group::editGroup($group, $input);
return Redirect::to("group/edit/{$name}");
}
}
示例6: actionCreateGroup
public function actionCreateGroup()
{
/* validate all query string param */
$model = new Group('create');
$fileModel = new FileUploadFormModel();
$fileModel->setScenario(FileUploadFormModel::FILE_UPLOAD_MODE_SINGLE);
/*define the required variable for the controller base on the query string param */
if (isset($_POST['Group'])) {
$model->setAttributes($_POST['Group']);
//$fileHandler->LoadUploadedeImageToModel();
//$model->photos = $fileHandler->photos;
//$model->photos = CUploadedFile::getInstancesByName(BSMultiFileUploadWidget::fieldName);
if ($model->validate()) {
$fileModel->LoadUploadedeImage();
if ($fileModel->isUploadedFile()) {
if ($fileModel->validate()) {
$SavedFileRelativePaths = $fileModel->processImage(get_class($model), $model->group_name, md5(DateTimeHelper::now()));
$model->apply_img = ArrayHelper::array2string($SavedFileRelativePaths);
if ($model->save()) {
$model->addOwnerUser(Yii::app()->user->id);
Yii::app()->user->setFlash(FlashMsg::SUCCESS, "已提交組織申請");
$this->redirect(array('index'));
} else {
Yii::app()->user->setFlash(FlashMsg::ERROR, "提交組織申請失敗");
}
}
} else {
if ($model->save()) {
$model->addOwnerUser(Yii::app()->user->id);
Yii::app()->user->setFlash(FlashMsg::SUCCESS, "已提交組織申請");
$this->redirect(array('index'));
} else {
Yii::app()->user->setFlash(FlashMsg::ERROR, "提交組織申請失敗");
}
}
}
}
$this->render('createGroup', array('model' => $model, 'fileModel' => $fileModel));
}
示例7: _createGroup
protected function _createGroup($opts = array())
{
$group = new Group(array("name" => $opts["name"], "users" => $opts["users"]));
if ($group->validate()) {
$group->save();
return $group;
}
return false;
}
示例8: actionCreate
/**
* 創建小組
*/
public function actionCreate()
{
$uid = Yii::app()->user->id;
$model = new Group();
$model->scenario = 'create';
$category_list = $model->getGroupCategory();
$category_list = CHtml::listData($category_list, 'id', 'title');
if (!empty($_POST['Group'])) {
$attributes = $_POST['Group'];
$model->attributes = $attributes;
$model->validate();
}
$data = array('owner' => $owner, 'is_me' => $is_me, 'group' => $group, 'category_list' => $category_list);
$this->render('create', $data);
}