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


PHP FormResponse::status_messsage方法代码示例

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


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

示例1: addtogroup

 /**
  * Add existing member to group rather than creating a new member
  */
 function addtogroup()
 {
     // Protect against CSRF on destructive action
     $token = $this->getForm()->getSecurityToken();
     if (!$token->checkRequest($this->controller->getRequest())) {
         return $this->httpError(400);
     }
     $data = $_REQUEST;
     $groupID = isset($data['ctf']['ID']) ? $data['ctf']['ID'] : null;
     if (!is_numeric($groupID)) {
         FormResponse::status_messsage(_t('MemberTableField.ADDINGFIELD', 'Adding failed'), 'bad');
         return;
     }
     // Get existing record either by ID or unique identifier.
     $identifierField = Member::get_unique_identifier_field();
     $className = self::$data_class;
     $record = null;
     if (isset($data[$identifierField])) {
         $record = DataObject::get_one($className, sprintf('"%s" = \'%s\'', $identifierField, $data[$identifierField]));
         if ($record && !$record->canEdit()) {
             return $this->httpError('401');
         }
     }
     // Fall back to creating a new record
     if (!$record) {
         $record = new $className();
     }
     // Update an existing record, or populate a new one.
     // If values on an existing (autocompleted) record have been changed,
     // they will overwrite current data. We need to unset 'ID'
     // record as it points to the group rather than the member record, and would
     // cause the member to be written to a potentially existing record.
     unset($data['ID']);
     $record->update($data);
     // Validate record, mainly password restrictions.
     // Note: Doesn't use Member_Validator
     $valid = $record->validate();
     if ($valid->valid()) {
         $record->write();
         $record->Groups()->add($groupID);
         $this->sourceItems();
         // TODO add javascript to highlight added row (problem: might not show up due to sorting/filtering)
         FormResponse::update_dom_id($this->id(), $this->renderWith($this->template), true);
         FormResponse::status_message(_t('MemberTableField.ADDEDTOGROUP', 'Added member to group'), 'good');
     } else {
         $message = sprintf(_t('MemberTableField.ERRORADDINGUSER', 'There was an error adding the user to the group: %s'), Convert::raw2xml($valid->starredList()));
         FormResponse::status_message($message, 'bad');
     }
     return FormResponse::respond();
 }
开发者ID:comperio,项目名称:silverstripe-cms,代码行数:53,代码来源:MemberTableField.php

示例2: addtogroup

	/**
	 * Add existing member to group rather than creating a new member
	 */
	function addtogroup() {
		$data = $_REQUEST;
		unset($data['ID']);
		$ctfID = isset($data['ctf']) ? $data['ctf']['ID'] : null;

		if(!is_numeric($ctfID)) {
			FormResponse::status_messsage(_t('MemberTableField.ADDINGFIELD', 'Adding failed'), 'bad');
		}

		$className = Object::getCustomClass($this->stat('data_class'));
		$record = new $className();

		$record->update($data);
		
		$valid = $record->validate();

		if($valid->valid()) {
			$record->write();
			$record->Groups()->add($ctfID);

			$this->sourceItems();

			// TODO add javascript to highlight added row (problem: might not show up due to sorting/filtering)
			FormResponse::update_dom_id($this->id(), $this->renderWith($this->template), true);
			FormResponse::status_message(_t('MemberTableField.ADDEDTOGROUP','Added member to group'), 'good');
		
		} else {
			FormResponse::status_message(Convert::raw2xml("I couldn't add that user to this group:\n\n" . $valid->starredlist()), 'bad');
		}

		return FormResponse::respond();
	}
开发者ID:neopba,项目名称:silverstripe-book,代码行数:35,代码来源:MemberTableField.php

示例3: addtogroup

 /**
  * Add existing member to group rather than creating a new member
  */
 function addtogroup()
 {
     $data = $_REQUEST;
     unset($data['ID']);
     if (!is_numeric($data['ctf']['ID'])) {
         FormResponse::status_messsage(_t('MemberTableField.ADDINGFIELD', 'Adding failed'), 'bad');
     }
     $className = $this->stat('data_class');
     $record = new $className();
     $record->update($data);
     $record->write();
     // To Avoid duplication in the Group_Members table if the ComponentSet.php is not modified just uncomment le line below
     //if( ! $record->isInGroup( $data['ctf']['ID'] ) )
     $record->Groups()->add($data['ctf']['ID']);
     $this->sourceItems();
     // TODO add javascript to highlight added row (problem: might not show up due to sorting/filtering)
     FormResponse::update_dom_id($this->id(), $this->renderWith($this->template), true);
     FormResponse::status_message(_t('MemberTableField.ADDEDTOGROUP', 'Added member to group'), 'good');
     return FormResponse::respond();
 }
开发者ID:ramziammar,项目名称:websites,代码行数:23,代码来源:MemberTableField.php


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