Пример #1
0
 public function render()
 {
     //authenticate the current user to make sure they are an admin
     UsersHelper::authenticateAdmin();
     //load model
     $layout = $this->getLayout();
     $model = new FormWizardModel();
     $model->set("_layout", $layout);
     //document
     $document = JFactory::getDocument();
     // Create the toolbar object
     $this->toolbar = new Toolbar();
     //add toolbar buttons to manage users
     if ($layout == 'default') {
         //buttons
         $this->toolbar->addNew();
         $this->toolbar->addDeleteRow();
         ToolbarHelper::addNew('edit');
         ToolbarHelper::editList('edit');
         ToolbarHelper::deleteList(TextHelper::_('COBALT_CONFIRMATION'), 'remove');
         // Initialise variables.
         $this->state = $model->getState();
         $this->forms = $model->getForms();
         $this->listOrder = $this->state->get('Formwizard.filter_order');
         $this->listDirn = $this->state->get('Formwizard.filter_order_Dir');
     } elseif ($layout == 'edit') {
         //buttons
         $this->toolbar->save();
         $this->toolbar->cancel();
         //form
         $form_id = $model->getTempFormId();
         $this->form_id = $form_id;
         $this->form = $model->getForm();
         //form types
         $this->form_types = DropdownHelper::getFormTypes($this->form['type']);
         $fields = array('lead' => DropdownHelper::getFormFields('people'), 'contact' => DropdownHelper::getFormFields('people'), 'deal' => DropdownHelper::getFormFields('deal'), 'company' => DropdownHelper::getFormFields('company'));
         $this->fields = $fields;
         $document->addScriptDeclaration('var fields=' . json_encode($fields));
         //get joomla users to add
         $model = new UsersModel();
         $user_list = $model->getUsers();
         $document->addScriptDeclaration('var user_list=' . json_encode($user_list) . ';');
     }
     //javascripts
     $document->addScript(JURI::base() . 'src/Cobalt/media/js/jquery.base64.js');
     $document->addScript(JURI::base() . 'src/Cobalt/media/js/formwizard.js');
     $document->addScript(JURI::base() . 'src/Cobalt/media/js/cobalt-admin.js');
     /** Menu Links **/
     $menu = MenuHelper::getMenuModules();
     $this->menu = $menu;
     //display
     return parent::render();
 }
Пример #2
0
 public function render($tpl = null)
 {
     //authenticate the current user to make sure they are an admin
     UsersHelper::authenticateAdmin();
     //application
     $app = \Cobalt\Container::fetch('app');
     //display title
     $document = JFactory::getDocument();
     //load model
     $layout = $this->getLayout();
     $model = new UsersModel();
     $model->set("_layout", $layout);
     //add toolbar buttons to manage users
     if ($layout == 'default') {
         $this->toolbar = new Toolbar();
         $this->toolbar->addNew();
         $this->toolbar->addDeleteRow();
         //get users
         $users = $model->getUsers();
         // Initialise variables.
         $this->state = $model->getState();
         //assign refs
         $this->users = $users;
         $this->listOrder = $this->state->get('Users.filter_order');
         $this->listDirn = $this->state->get('Users.filter_order_Dir');
     } elseif ($this->getLayout() == 'edit') {
         $model = new UserModel();
         $model->set("_layout", $layout);
         $this->toolbar = new Toolbar();
         $this->toolbar->save();
         $this->toolbar->cancel();
         //get id
         $id = $app->input->getInt('id', null);
         //plugins
         //$app->triggerEvent('onBeforeCRMUserEdit', array(&$id));
         //get user
         $this->user = $model->getUser($id);
         //view data
         $roles = DropdownHelper::getMemberRoles();
         $teamId = UsersHelper::getTeamId($id);
         $teams = UsersHelper::getTeams($teamId);
         $managers = DropdownHelper::getManagers($id);
         $this->member_roles = $roles;
         $this->teams = $teams;
         $this->managers = $managers;
     }
     /** Menu Links **/
     $menu = MenuHelper::getMenuModules();
     $this->menu = $menu;
     //display
     return parent::render();
 }