/** * Delete a plugin * * @access private */ private function delete() { if (VPost::delete(false) && VPost::plg_id() && $this->_user['delete_content']) { try { $plg = new Setting(VPost::plg_id()); $plg->_data = json_decode($plg->_data, true); foreach ($plg->_data['admin'] as $file) { File::delete('includes/' . $plg->_data['namespace'] . '/' . $file); } foreach ($plg->_data['site'] as $file) { File::delete(PATH . 'includes/' . $file); } foreach ($plg->_data['library'] as $file) { File::delete('library/' . $plg->_data['namespace'] . '/' . $file); } foreach ($plg->_data['uninstall'] as $query) { $this->_db->query(str_replace('{{prefix}}', DB_PREFIX, $query)); } File::delete(PATH . 'css/' . $plg->_data['namespace'] . '.css', false); $plg->delete(); $result = true; } catch (Exception $e) { $result = $e->getMessage(); } $this->_action_msg = ActionMessages::deleted($result); } elseif (VPost::delete(false) && !$this->_user['delete_content']) { $this->_action_msg = ActionMessages::action_no_perm(); } }
/** * Delete a template * * Current and main template will raise an error * * @access private */ private function delete() { if (VPost::delete(false) && VPost::tpl_id() && $this->_user['delete_content']) { try { $tpl = new Setting(VPost::tpl_id()); $tpl->_data = json_decode($tpl->_data, true); if ($tpl->_data['namespace'] == $this->_setting->_data) { throw new Exception('Template currently used, action aborted'); } if ($tpl->_data['namespace'] == 'main' || $tpl->_data['namespace'] == 'bobcat') { throw new Exception('Default template can\'t be deleted, action aborted'); } foreach ($tpl->_data['files'] as $file) { File::delete(PATH . 'includes/templates/' . $tpl->_data['namespace'] . '/' . $file); } $tpl->delete(); $result = true; } catch (Exception $e) { $result = $e->getMessage(); } $this->_action_msg = ActionMessages::template_deleted($result); } elseif (VPost::delete(false) && !$this->_user['delete_content']) { $this->_action_msg = ActionMessages::action_no_perm(); } }
/** * Delete a role * * @access private */ private function delete() { if (VGet::action(false) == 'delete' && !in_array(VGet::role(), array('administrator', 'editor', 'author')) && $this->_user['delete_content']) { try { $to_read['table'] = 'user'; $to_read['columns'] = array('USER_ID'); $to_read['condition_columns'][':r'] = 'user_role'; $to_read['condition_select_types'][':r'] = '='; $to_read['condition_values'][':r'] = VGet::role(); $to_read['value_types'][':r'] = 'str'; $users = $this->_db->read($to_read); if (!empty($users)) { throw new Exception('Can\'t delete the role "' . ucfirst(VGet::role()) . '" because a user is using it!'); } $to_read = null; $to_read['table'] = 'setting'; $to_read['columns'] = array('SETTING_ID'); $to_read['condition_columns'][':t'] = 'setting_type'; $to_read['condition_select_types'][':t'] = '='; $to_read['condition_values'][':t'] = 'role'; $to_read['value_types'][':t'] = 'str'; $to_read['condition_types'][':n'] = 'AND'; $to_read['condition_columns'][':n'] = 'setting_name'; $to_read['condition_select_types'][':n'] = '='; $to_read['condition_values'][':n'] = VGet::role(); $to_read['value_types'][':n'] = 'str'; $role = $this->_db->read($to_read); $role = new Setting($role[0]['SETTING_ID']); $role->delete(); $to_read = null; $to_read['table'] = 'setting'; $to_read['columns'] = array('SETTING_ID'); $to_read['condition_columns'][':t'] = 'setting_type'; $to_read['condition_select_types'][':t'] = '='; $to_read['condition_values'][':t'] = 'all_roles'; $to_read['value_types'][':t'] = 'str'; $roles = $this->_db->read($to_read); $roles = new Setting($roles[0]['SETTING_ID']); $array = json_decode($roles->_data, true); foreach ($array as $key => $value) { if ($value == VGet::role()) { unset($array[$key]); } } $roles->_data = json_encode($array); $roles->update('_data', 'str'); $result = true; } catch (Exception $e) { $result = $e->getMessage(); } $this->_action_msg = ActionMessages::deleted($result); } elseif (VGet::action(false) == 'delete' && !$this->_user['delete_content']) { $this->_action_msg = ActionMessages::action_no_perm(); } }