conf = $extra['conf']; $this->project = $extra['project']; $ak = array('downloads_access_rights' => __('Downloads'), 'review_access_rights' => __('Code Review'), 'wiki_access_rights' => __('Documentation'), 'source_access_rights' => __('Source'), 'issues_access_rights' => __('Issues'),); foreach ($ak as $key=>$label) { $this->fields[$key] = new Pluf_Form_Field_Varchar( array('required' => true, 'label' => $label, 'initial' => $this->conf->getVal($key, 'all'), 'widget_attrs' => array('choices' => array( __('Open to all') => 'all', __('Signed in users') => 'login', __('Project members') => 'members', __('Project owners') => 'owners', __('Closed') => 'none', ) ), 'widget' => 'Pluf_Form_Widget_SelectInput', )); } $sections = array( 'downloads_notification', 'review_notification', 'wiki_notification', 'source_notification', 'issues_notification', ); foreach ($sections as $section) { $this->fields[$section.'_owners_enabled'] = new Pluf_Form_Field_Boolean( array('required' => false, 'label' => __('Project owners'), 'initial' => $this->conf->getVal($section.'_owners_enabled', false), 'widget' => 'Pluf_Form_Widget_CheckboxInput', )); $this->fields[$section.'_members_enabled'] = new Pluf_Form_Field_Boolean( array('required' => false, 'label' => __('Project members'), 'initial' => $this->conf->getVal($section.'_members_enabled', false), 'widget' => 'Pluf_Form_Widget_CheckboxInput', )); $this->fields[$section.'_email_enabled'] = new Pluf_Form_Field_Boolean( array('required' => false, 'label' => __('Others'), 'initial' => $this->conf->getVal($section.'_email_enabled', false), 'widget' => 'Pluf_Form_Widget_CheckboxInput', )); if ($this->conf->getVal($section.'_email_enabled', false)) { $attrs['readonly'] = 'readonly'; } $this->fields[$section.'_email'] = new IDF_Form_Field_EmailList( array('required' => false, 'label' => null, 'initial' => $this->conf->getVal($section.'_email', ''), 'widget_attrs' => array('size' => 20), )); } $this->fields['private_project'] = new Pluf_Form_Field_Boolean( array('required' => false, 'label' => __('Private project'), 'initial' => $this->project->private, 'widget' => 'Pluf_Form_Widget_CheckboxInput', )); $this->fields['authorized_users'] = new Pluf_Form_Field_Varchar( array('required' => false, 'label' => __('Extra authorized users'), 'widget_attrs' => array('rows' => 7, 'cols' => 40), 'widget' => 'Pluf_Form_Widget_TextareaInput', )); } public function clean_authorized_users() { return IDF_Form_MembersConf::checkBadLogins($this->cleaned_data['authorized_users']); } public function save($commit=true) { if (!$this->isValid()) { throw new Exception(__('Cannot save the model from an invalid form.')); } // remove all the permissions $perm = Pluf_Permission::getFromString('IDF.project-authorized-user'); $cm = $this->project->getMembershipData(); $guser = new Pluf_User(); foreach ($cm['authorized'] as $user) { Pluf_RowPermission::remove($user, $this->project, $perm); } if ($this->cleaned_data['private_project']) { foreach (preg_split("/\015\012|\015|\012|\,/", $this->cleaned_data['authorized_users'], -1, PREG_SPLIT_NO_EMPTY) as $login) { $sql = new Pluf_SQL('login=%s', array(trim($login))); $users = $guser->getList(array('filter'=>$sql->gen())); if ($users->count() == 1) { Pluf_RowPermission::add($users[0], $this->project, $perm); } } $this->project->private = 1; } else { $this->project->private = 0; } $this->project->update(); $this->project->membershipsUpdated(); } }