00001 <?php
00002
00016
00017
00018
00019 import('form.Form');
00020 import('group.Group');
00021
00022 class GroupForm extends Form {
00024 var $group;
00025
00030 function GroupForm($group = null) {
00031 $journal = &Request::getJournal();
00032
00033 parent::Form('manager/groups/groupForm.tpl');
00034
00035
00036 $this->addCheck(new FormValidatorLocale($this, 'title', 'required', 'manager.groups.form.groupTitleRequired'));
00037
00038 $this->addCheck(new FormValidatorPost($this));
00039
00040 $this->group =& $group;
00041 }
00042
00047 function getLocaleFieldNames() {
00048 $groupDao =& DAORegistry::getDAO('GroupDAO');
00049 return $groupDao->getLocaleFieldNames();
00050 }
00051
00055 function display() {
00056 $templateMgr = &TemplateManager::getManager();
00057 $templateMgr->assign_by_ref('group', $this->group);
00058 $templateMgr->assign('helpTopicId', 'journal.managementPages.groups');
00059 $templateMgr->assign('groupContextOptions', array(
00060 GROUP_CONTEXT_EDITORIAL_TEAM => 'manager.groups.context.editorialTeam',
00061 GROUP_CONTEXT_PEOPLE => 'manager.groups.context.people'
00062 ));
00063 parent::display();
00064 }
00065
00069 function initData() {
00070 if ($this->group != null) {
00071 $this->_data = array(
00072 'title' => $this->group->getTitle(null),
00073 'context' => $this->group->getContext()
00074 );
00075 } else {
00076 $this->_data = array(
00077 'context' => GROUP_CONTEXT_EDITORIAL_TEAM
00078 );
00079 }
00080 }
00081
00085 function readInputData() {
00086 $this->readUserVars(array('title', 'context'));
00087 }
00088
00092 function execute() {
00093 $groupDao = &DAORegistry::getDAO('GroupDAO');
00094 $journal = &Request::getJournal();
00095
00096 if (!isset($this->group)) {
00097 $this->group = &new Group();
00098 }
00099
00100 $this->group->setJournalId($journal->getJournalId());
00101 $this->group->setTitle($this->getData('title'), null);
00102 $this->group->setContext($this->getData('context'));
00103
00104
00105
00106 $this->group->setAboutDisplayed(true);
00107
00108
00109 if ($this->group->getGroupId() != null) {
00110 $groupDao->updateGroup($this->group);
00111 } else {
00112 $this->group->setSequence(REALLY_BIG_NUMBER);
00113 $groupDao->insertGroup($this->group);
00114
00115
00116 $groupDao->resequenceGroups($this->group->getJournalId());
00117 }
00118 }
00119 }
00120
00121 ?>