Exemplo n.º 1
0
 public function removeSampleData()
 {
     $sampleIds = unserialize(ConfigHelper::getConfigValue('import_sample'));
     $db = $this->container->resolve('db');
     $query = $db->getQuery(true);
     foreach ($sampleIds as $table => $ids) {
         $query->clear()->delete("#__" . $table)->where("id IN(" . implode(',', $ids) . ")");
         $db->setQuery($query);
         $db->query();
     }
     $data = array('import_sample' => "0");
     $configModel = new ConfigModel();
     $configModel->store($data);
     $msg = TextHelper::_('COBALT_SAMPLE_DATA_REMOVED');
     $this->getApplication()->redirect('index.php?view=import', $msg);
 }
Exemplo n.º 2
0
 public static function getMenuModules()
 {
     $modules = array();
     $app = \Cobalt\Container::fetch('app');
     /** Side menu links **/
     $menu_links = MenuHelper::getMenuLinks();
     $menu = ViewHelper::getView('cobalt', 'menu', 'phtml');
     $menu->menu_links = $menu_links;
     $modules['menu'] = $menu;
     /** Quick Menu Links **/
     $quick_menu_links = MenuHelper::getQuickMenuLinks();
     $quick_menu = ViewHelper::getView('cobalt', 'quick_menu', 'phtml');
     $quick_menu->quick_menu_links = $quick_menu_links;
     $modules['quick_menu'] = $quick_menu;
     /** Determine help type on page **/
     $help_type_1 = $app->input->get('view') != '' || !is_null($app->input->get('view')) ? $app->input->get('view') : $app->input->get('controller');
     $help_type_2 = $app->input->get('layout') != '' || !is_null($app->input->get('layout')) ? $app->input->get('layout') : $app->input->get('task');
     $help_type_1 = $help_type_1 == "" || is_null($help_type_1) ? "" : $help_type_1;
     $help_type_2 = $help_type_2 == "" || is_null($help_type_2) ? "" : '_' . $help_type_2;
     $help_type = str_replace(".", "_", $help_type_1 . $help_type_2);
     $help_types = self::getHelpTypes();
     $show_help = ConfigHelper::getConfigValue('show_help');
     $launch_default = ConfigHelper::getConfigValue('launch_default');
     $step_completed = ConfigHelper::getConfigValue($help_type);
     $show_update_buttons = in_array($help_type, $help_types);
     /** Help Menu Links **/
     $help_menu_links = MenuHelper::getHelpMenuLinks();
     $help_menu = ViewHelper::getView('cobalt', 'help_menu', 'phtml');
     $help_menu->help_menu_links = $help_menu_links;
     $help_menu->help_type = $help_type;
     $help_menu->show_help = $show_help;
     $help_menu->launch_default = $launch_default;
     $help_menu->step_completed = $step_completed;
     $help_menu->show_update_buttons = $show_update_buttons;
     $modules['help_menu'] = $help_menu;
     $count = count($help_menu_links) - 1;
     $completed = 0;
     foreach ($help_menu_links as $link) {
         if ($link['completed_status'] == 1) {
             $completed++;
         }
     }
     $modules['percentage'] = number_format($completed / $count * 100, 0);
     return $modules;
 }
Exemplo n.º 3
0
 public function store()
 {
     //Load Tables
     $row = new UserTable();
     $data = $this->app->input->post->getArray();
     //$this->app->triggerEvent('onBeforeCRMUserSave', array(&$data));
     //date generation
     $date = date('Y-m-d H:i:s');
     if (!array_key_exists('id', $data)) {
         $data['created'] = $date;
         $data['time_zone'] = ConfigHelper::getConfigValue('timezone');
         $data['time_format'] = ConfigHelper::getConfigValue('time_format');
         $data['block'] = 0;
         $data['registerDate'] = $date;
         $data['activation'] = 0;
         $data['params'] = "";
     }
     if (array_key_exists('password', $data) && $data['password'] != "") {
         $data['password'] = UsersHelper::hashPassword($data['password']);
     } else {
         unset($data['password']);
     }
     //generate team data
     $model = new Teams();
     if (array_key_exists('id', $data) && $data['id'] > 0) {
         $teamId = $this->getTeamId($data['id']);
     }
     //assign user priviliges
     $data['modified'] = $date;
     $data['admin'] = array_key_exists('admin', $data) && $data['admin'] == '1' ? 1 : 0;
     $data['exports'] = array_key_exists('exports', $data) && $data['exports'] == 'on' ? 1 : 0;
     $data['can_delete'] = array_key_exists('can_delete', $data) && $data['can_delete'] == 'on' ? 1 : 0;
     //republish / register users
     if (array_key_exists('id', $data) && $data['id'] != "") {
         $query = $this->db->getQuery(true);
         $query->clear()->select("id")->from("#__users")->where("id=" . $data['id']);
         $this->db->setQuery($query);
         $id = $this->db->loadResult();
         if ($id) {
             $data['id'] = $id;
             $data['published'] = 1;
         }
     }
     if (array_key_exists('team_id', $data) && $data['team_id'] == "") {
         unset($data['team_id']);
     }
     // Bind the form fields to the table
     if (!$row->bind($data)) {
         $this->setError($this->db->getErrorMsg());
         return false;
     }
     // Make sure the record is valid
     if (!$row->check()) {
         $this->setError($this->db->getErrorMsg());
         return false;
     }
     // Store the web link table to the database
     if (!$row->store()) {
         $this->setError($this->db->getErrorMsg());
         return false;
     }
     if (array_key_exists('role_type', $data) && $data['role_type'] == "manager") {
         $teamModel = new Teams();
         $teamName = array_key_exists('team_name', $data) ? $data['team_name'] : "";
         $teamModel->createTeam($row->id, $teamName);
     }
     //if we are downgrading a users priviliges
     if (array_key_exists('manager_assignment', $data) && $data['manager_assignment'] != null && $data['manager_assignment'] != "") {
         $newTeamId = $this->getTeamId($data['manager_assignment']);
         $model->updateTeam($teamId, $newTeamId);
     }
     $row->id = array_key_exists('id', $data) && $data['id'] > 0 ? $data['id'] : $this->db->insertId();
     $this->updateUserMap($row);
     //$this->app->triggerEvent('onAfterCRMUserSave', array(&$data));
     return true;
 }