/** * Define the menu based on user profile */ public function configureMenu() { if ($this->scroll->get_child()) { $this->scroll->remove($this->scroll->get_child()); } TTransaction::open('library'); $member = User::newFromLogin(TSession::getValue('login')); if ($member->role->mnemonic == 'LIBRARIAN') { $buttons = array(); $buttons[] = array('<b>' . _t('Cataloging') . '</b>'); $buttons[] = array(_t('Books'), 'BookList'); $buttons[] = array(_t('Collections'), 'CollectionFormList'); $buttons[] = array(_t('Classifications'), 'ClassificationFormList'); $buttons[] = array(_t('Subjects'), 'SubjectList'); $buttons[] = array(_t('Authors'), 'AuthorList'); $buttons[] = array(_t('Publishers'), 'PublisherList'); $buttons[] = array(_t('Status'), 'StatusFormList'); $buttons[] = array('<b>' . _t('Members') . '</b>'); $buttons[] = array(_t('Members'), 'MemberList'); $buttons[] = array(_t('Categories'), 'CategoryFormList'); $buttons[] = array(_t('Cities'), 'CityList'); $buttons[] = array('<b>' . _t('Circulation') . '</b>'); $buttons[] = array(_t('Check in'), 'CheckInForm'); $buttons[] = array(_t('Check out'), 'CheckOutForm'); $buttons[] = array('<b>' . _t('Reports') . '</b>'); $buttons[] = array(_t('Loans'), 'LoanReport'); $buttons[] = array(_t('Member'), 'MemberReport'); $buttons[] = array(_t('Books'), 'BookReport'); $buttons[] = array('Logout', array('LoginForm', 'onLogout')); } else { if ($member->role->mnemonic == 'OPERATOR') { $buttons = array(); $buttons[] = array('<b>' . _t('Members') . '</b>'); $buttons[] = array(_t('Members'), 'MemberList'); $buttons[] = array(_t('Categories'), 'CategoryFormList'); $buttons[] = array(_t('Cities'), 'CityList'); $buttons[] = array('<b>' . _t('Circulation') . '</b>'); $buttons[] = array(_t('Check in'), 'CheckInForm'); $buttons[] = array(_t('Check out'), 'CheckOutForm'); $buttons[] = array('<b>' . _t('Reports') . '</b>'); $buttons[] = array(_t('Loans'), 'LoanReport'); $buttons[] = array(_t('Member'), 'MemberReport'); $buttons[] = array(_t('Books'), 'BookReport'); $buttons[] = array('Logout', array('LoginForm', 'onLogout')); } else { if ($member->role->mnemonic == 'ADMINISTRATOR') { $buttons = array(); $buttons[] = array('<b>' . 'Admin' . '</b>'); $buttons[] = array(_t('Users'), 'UserList'); $buttons[] = array(_t('Roles'), 'RoleList'); $buttons[] = array('Logout', array('LoginForm', 'onLogout')); } } } TTransaction::close(); $vbox_buttons = new GtkVBox(FALSE, 0); $this->scroll->add_with_viewport($vbox_buttons); $this->scroll->get_child()->modify_bg(Gtk::STATE_NORMAL, GdkColor::parse('#EFEFEF')); foreach ($buttons as $button_info) { if (!isset($button_info[1])) { $button = new GtkEventBox(); $button->add($label = new GtkLabel($button_info[0])); $button->set_size_request(-1, 20); $label->set_use_markup(TRUE); $button->modify_bg(Gtk::STATE_NORMAL, GdkColor::parse('#C0C0C0')); } else { $button = new GtkButton($button_info[0]); $button->get_child()->set_alignment(0, 0); $button->set_property('can-focus', FALSE); $button->set_relief(Gtk::RELIEF_NONE); $button->modify_bg(Gtk::STATE_PRELIGHT, GdkColor::parse('#CFCFCF')); $button->modify_bg(Gtk::STATE_ACTIVE, GdkColor::parse('#CFCFCF')); $button->set_size_request(-1, 24); $button->connect_simple('clicked', array($this, 'run'), $button_info[1]); } $vbox_buttons->pack_start($button, FALSE, FALSE, 0); } $this->scroll->show_all(); }