openrat-cms

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README

GroupPropAction.class.php (1058B)


      1 <?php
      2 namespace cms\action\group;
      3 use cms\action\GroupAction;
      4 use cms\action\Method;
      5 use cms\model\Group;
      6 use language\Messages;
      7 use util\exception\ValidationException;
      8 
      9 
     10 class GroupPropAction extends GroupAction implements Method {
     11 
     12 	/**
     13 	 * Reads the properties of this group.
     14 	 */
     15     public function view() {
     16 
     17 		$this->setTemplateVars( $this->group->getProperties() );
     18 
     19 		$otherGroups = Group::getAll();
     20 
     21 		unset( $otherGroups[$this->group->groupid] );
     22 
     23 		foreach ( $this->group->getAllDescendantsIds() as $descendantGroupId )
     24 			unset( $otherGroups[ $descendantGroupId ] );
     25 
     26 		$this->setTemplateVar('groups',$otherGroups );
     27     }
     28 
     29 
     30 	/**
     31 	 * Store the group properties.
     32 	 *
     33 	 * @throws ValidationException
     34 	 */
     35     public function post() {
     36 
     37         $this->group->name     = $this->request->getRequiredText('name');
     38 		$this->group->parentid = $this->request->getNumber('parentid');
     39 
     40 		if   ( ! $this->group->parentid )
     41 			$this->group->parentid = null;
     42 
     43         $this->group->persist();
     44 
     45         $this->addNoticeFor($this->group,Messages::SAVED);
     46     }
     47 }