Example #1
0
 public static function display()
 {
     $messages = "";
     if ($_POST['cc_form'] === 'add-group') {
         $group = $_POST['group'];
         $rows = Database::select('users', 'name', array('name = ? AND type = ?', $group, 'group'), null, 1)->fetch(PDO::FETCH_ASSOC);
         if (!empty($rows)) {
             $messages .= Message::error(__('admin', 'group-in-use'));
         } else {
             $row = DB::select('users', array('data'), array('users_id = ?', $_GET['parent']))->fetch(PDO::FETCH_ASSOC);
             $inheritance = unserialize($row['data']);
             $inheritance = $inheritance['permissions'];
             $result = Database::insert('users', array('name' => filter('admin_add_group_name', $group), 'type' => 'group', 'group' => '-1', 'data' => serialize(filter('admin_add_group_data', array('permissions' => $inheritance)))));
             if ($result === 1) {
                 $messages .= Message::success(__('admin', 'group-added'));
             }
         }
     }
     $form = new Form('self', 'post', 'add-group');
     $form->startFieldset(__("admin", 'group-information'));
     $form->addInput(__('admin', 'group-name'), 'text', 'group', self::get('group'));
     $groups = Users::allGroups();
     foreach ($groups as $key => $value) {
         $groups[$value->getId()] = $value->getName();
     }
     $form->addSelectList(__('admin', 'inherit-permissions'), 'parent', $groups);
     plugin('admin_add_group_custom_fields', array(&$form));
     $form->addSubmit('', 'add-group', __('admin', 'add-group'));
     $form->endFieldset();
     plugin('admin_add_group_custom_fieldset', array(&$form));
     $form = $form->endAndGetHTML();
     return array(__('admin', 'add-group'), $messages . $form);
 }
Example #2
0
 public static function display()
 {
     $messages = "";
     if ($_POST['cc_form'] === 'add-user') {
         $username = $_POST['username'];
         $password = $_POST['password'];
         $cpassword = $_POST['confirm-password'];
         $group = $_POST['group'];
         if ($password != $cpassword) {
             $messages .= Message::error(__('admin', 'passwords-dont-match'));
         } else {
             $rows = Database::select('users', 'name', array('name = ? AND type = ?', $username, 'user'), null, 1)->fetch(PDO::FETCH_ASSOC);
             if (!empty($rows)) {
                 $messages .= Message::error(__('admin', 'username-in-use'));
             } else {
                 $hash = hash('whirlpool', $password);
                 $result = Database::insert('users', array('name' => filter('admin_add_user_username', $username), 'value' => $hash, 'type' => 'user', 'group' => filter('admin_add_group', $group), 'data' => serialize(filter('admin_add_user_data', array()))));
                 if ($result === 1) {
                     $messages .= Message::success(__('admin', 'user-added'));
                 }
             }
         }
     }
     $form = new Form('self', 'post', 'add-user');
     $groups = Users::allGroups();
     foreach ($groups as $key => $value) {
         $groups[$value->getId()] = $value->getName();
     }
     $form->startFieldset(__("admin", 'user-information'));
     $form->addInput(__('admin', 'username'), 'text', 'username', self::get('username'));
     $form->addInput(__('admin', 'password'), 'password', 'password');
     $form->addInput(__('admin', 'confirm-password'), 'password', 'confirm-password');
     $form->addSelectList(__('admin', 'group'), 'group', $groups, true, self::get('group'));
     plugin('admin_add_user_custom_fields', array(&$form));
     $form->addSubmit('', 'add-user', __('admin', 'add-user'));
     $form->endFieldset();
     plugin('admin_add_user_custom_fieldset', array(&$form));
     $form = $form->endAndGetHTML();
     return array(__('admin', 'add-user'), $messages . $form);
 }
Example #3
0
 public static function display()
 {
     $type = $_GET['type'];
     $types = Content::contentTypes();
     if (array_key_exists($type, $types) === false && array_key_exists($_POST['type'], $types) === false) {
         $opt_list = array();
         foreach ($types as $single_type => $class) {
             $opt_list[$single_type] = call_user_func($class . '::name');
         }
         $form = new Form('self', 'post', 'add_node_1');
         $form->addSelectList(__('admin', 'content-type'), 'type', $opt_list, true, 'page');
         $form->addSubmit('', 'continue', __('admin', 'continue'));
         return array(__('admin', 'add-page'), $form->endAndGetHTML());
     }
     if (!$type && $_POST['type']) {
         if (array_key_exists('continue', $_POST)) {
             cc_redirect(Admin::link($_GET['page'], array('type' => $_POST['type'])));
         } else {
             return;
         }
     }
     AdminSidebar::registerForPage('content/create-page', 'EditPage::fileUploadBlock');
     return Content::nodeDisplay('create_display', $type, array());
 }
Example #4
0
 public static function create_display()
 {
     i18n::set('admin');
     if ($_POST['cc_form'] == 'create_page') {
         plugin('admin_create_post_pre_proccessing');
         $id = $_GET['id'];
         $title = filter('admin_create_post_title', self::get('title'));
         $content = filter('admin_create_post_content', self::get('content_area'));
         $last_modified = filter('admin_create_post_last_modified', time());
         $settings = filter('admin_create_post_settings', self::get('settings'));
         $weight = filter('admin_create_post_weight', self::get('weight'));
         $menutitle = filter('admin_create_post_menutitle', self::get('menutitle'));
         $parent_id = filter('admin_create_post_parent_id', self::get('parent_id'));
         $slug = filter('admin_create_post_slug', self::get('slug'));
         if (empty($menutitle) || empty($slug)) {
             $message = Message::error(__('blank-error'));
             plugin('admin_create_post_blank_error');
         } else {
             plugin('admin_create_post_post_proccessing');
             $values = array('title' => $title, 'content' => $content, 'settings' => unserialize($settings), 'weight' => $weight, 'menutitle' => $menutitle, 'parent_id' => $parent_id, 'slug' => $slug);
             $values = filter('admin_create_post_posted_values', $values);
             $values['settings'] = serialize($values['settings']);
             $res = Content::createNode($_GET['type'], $values);
             if ($res) {
                 $message = Message::success(sprintf(__('page-creation-successful') . ' (<a href="%s">%s</a>)', Admin::link('content'), __('view-all-pages')));
             } else {
                 $message = Message::error(__('page-creation-failed'));
             }
         }
         //Hooks::bind('post_edit_page', 'EditPage::handlePost');
     }
     $r = $message;
     $themeList = array_subkeys(Themes::getThemeList(), 'name');
     $themeList['-1'] = 'Default Theme';
     ksort($themeList);
     $form = new Form('self', 'post', 'create_page');
     $form->addHidden('settings', 'a:0:{}');
     $form->startFieldset(__('page-info'), array('id' => 'page_info_f'));
     $form->addInput(__('page-title'), 'text', 'title', self::get('title'), array('class' => 'large'));
     $form->addHidden('content_type', self::get('type'));
     $form->addSelectList(__('theme-override'), 'theme', $themeList);
     $form->addSelectList(__('parent'), 'parent_id', self::buildParentOptions(), true, $_POST['parent_id'] ? $_POST['parent_id'] : '0');
     $form->endFieldset();
     plugin('admin_create_custom_fields', array(&$form));
     $form->startFieldset(__('menu-settings'), array('id' => 'menu_settings_f'));
     $form->addInput(__('menu-title'), 'text', 'menutitle', self::get('menutitle'));
     $form->addInput(__('slug'), 'text', 'slug', self::get('slug'));
     $form->addInput(__('weight'), 'text', 'weight', $_POST['weight'] ? $_POST['weight'] : '0');
     $form->endFieldset();
     plugin('admin_create_custom_fields2', array(&$form));
     $form->startFieldset(__('content'));
     $content = self::get('content_area');
     $form->addEditor('<p></p>', 'content_area', empty($content) ? "<p></p>" : $content);
     $form->endFieldset();
     plugin('admin_create_custom_fields3', array(&$form));
     $form->addSubmit('', 'save', __('save'));
     i18n::restore();
     return array(__('admin', 'add-page'), $r . $form->endAndGetHTML());
 }
Example #5
0
 public static function display()
 {
     $r = "";
     if ($_POST['cc_form'] == 'settings') {
         $name_lookup = array();
         Database::beginTransaction();
         foreach ($_POST as $key => $value) {
             if ($key == 'cc_form') {
                 continue;
             }
             if (substr($key, 0, 12) == 'cc_settings_') {
                 $name_lookup[substr($key, 12)] = explode('|', $value);
                 continue;
             }
             $setting_name = $key;
             //var_dump(array_key_exists($key, $name_lookup),$name_lookup);
             if (!array_key_exists($setting_name, $name_lookup)) {
                 continue;
             }
             if ($key == 'clean-urls') {
                 $value = (bool) $value;
             }
             Database::update('settings', array('data'), array(serialize($value)), array('package = ? AND name = ?', $name_lookup[$setting_name][1], $name_lookup[$setting_name][0]));
         }
         $r .= Message::success(__('admin', 'settings-saved'));
         Database::endTransaction();
     }
     $settings = Database::select('settings', '*', array('package = ? OR package = ? OR package = ? OR package = ?', 'core', 'admin', 'site', 'gui'), array('package', 'ASC', 'name', 'ASC'));
     $settings = $settings->fetchAll(PDO::FETCH_ASSOC);
     $rows = array();
     foreach ($settings as $row) {
         if (!array_key_exists($row['package'], $rows)) {
             $rows[$row['package']] = array();
         }
         $rows[$row['package']][] = $row;
     }
     ksort($rows);
     $form = new Form('self', 'POST', 'settings');
     foreach ($rows as $cat => $catRows) {
         $form->startFieldset(__('settings', $cat));
         foreach ($catRows as $row) {
             $data = unserialize($row['data']);
             $form->addHidden('cc_settings_' . UTF8::slugify($row['name']), $row['name'] . '|' . $row['package']);
             if ($row['name'] == 'clean urls') {
                 $form->addSelectList(__('settings', $row['name']), UTF8::slugify($row['name']), array(1 => __('admin', 'yes'), 0 => __('admin', 'no')), true, $data);
             } else {
                 if ($row['name'] == 'theme') {
                     $themes = Themes::getThemeList();
                     $options = array();
                     foreach ($themes as $slug => $ini) {
                         $options[$slug] = $ini['name'];
                     }
                     $form->addSelectList(__('settings', $row['name']), UTF8::slugify($row['name']), $options, true, $data);
                 } else {
                     if ($row['name'] == 'locale') {
                         $locales = i18n::getLocales();
                         $form->addSelectList(__('settings', $row['name']), UTF8::slugify($row['name']), $locales, false, $data);
                     } else {
                         if ($row['name'] == 'homepage id') {
                             $form->addSelectList(__('settings', $row['name']), UTF8::slugify($row['name']), Content::optionListArrayFromArray(Content::parseNavigation()), true, $data);
                         } else {
                             if ($row['name'] == 'site name') {
                                 $form->addInput(__('settings', $row['name']), 'text', UTF8::slugify($row['name']), $data);
                             } else {
                                 if ($row['name'] == 'editor') {
                                     $editors = Editors::getNamesOfRegistered();
                                     $form->addSelectList(__('settings', $row['name']), UTF8::slugify($row['name']), $editors, false, $data);
                                 } else {
                                     if ($row['name'] == 'homepage') {
                                         $form->addSelectList(__('settings', $row['name']), UTF8::slugify($row['name']), Admin::getAdminPageOptions(), true, $data);
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
         }
         $form->endFieldset();
     }
     $form->startFieldset('');
     $form->addSubmit('', 'save-settings', __('admin', 'save'));
     $form->endFieldset();
     return array(__('admin', 'settings'), $r . $form->endAndGetHTML());
 }
Example #6
0
 public static function display()
 {
     $id = $_GET['id'];
     if (!is_numeric($id)) {
         i18n::restore();
         cc_redirect(Admin::link('users'));
         return 'redirected.';
     }
     $messages = "";
     if ($_POST['cc_form'] === 'edit-user') {
         $username = $_POST['name'];
         $password = $_POST['password'];
         $cpassword = $_POST['confirm-password'];
         $group = $_POST['group'];
         if ($password != $cpassword) {
             $messages .= Message::error(__('admin', 'passwords-dont-match'));
         } else {
             $result = Database::select('users', '*', array('users_id = ?', $id));
             $row = $result->fetch(PDO::FETCH_ASSOC);
             $result = Database::select('users', '*', array('name = ?', $username));
             if (!empty($result)) {
                 $userRow = $result->fetch(PDO::FETCH_ASSOC);
             } else {
                 $result = false;
             }
             if ($result && $userRow['name'] == $username && $id != $userRow['id']) {
                 $messages .= Message::error(__('admin', 'username-in-use'));
             } else {
                 if (!empty($password) && !empty($cpassword) && $password == $cpassword) {
                     $hash = hash('whirlpool', $password);
                 } else {
                     $hash = $row['value'];
                 }
                 $data = unserialize($row['data']);
                 $result = Database::update('users', array('name' => filter('admin_edit_user_username', $username), 'value' => $hash, 'type' => 'user', 'group' => filter('admin_edit_group', $group), 'data' => serialize(filter('admin_edit_user_data', $data))), null, array('id = ?', $id));
                 if ($result === 1) {
                     $messages .= Message::success(__('admin', 'user-updated'));
                 }
             }
         }
     }
     $result = Database::select('users', '*', array('users_id = ?', $id));
     if (empty($result)) {
         i18n::restore();
         cc_redirect(Admin::link('users'));
     }
     self::$row = $result->fetch(PDO::FETCH_ASSOC);
     $form = new Form('self', 'post', 'edit-user');
     $groups = Users::allGroups();
     foreach ($groups as $key => $value) {
         $groups[$value->getId()] = $value->getName();
     }
     $form->startFieldset(__("admin", 'user-information'));
     $form->addInput(__('admin', 'username'), 'text', 'name', self::get('name'));
     $form->addInput(__('admin', 'password'), 'password', 'password');
     $form->addInput(__('admin', 'confirm-password'), 'password', 'confirm-password');
     $form->addSelectList(__('admin', 'group'), 'group', $groups, true, self::get('group'));
     plugin('admin_edit_user_custom_fields', array(&$form));
     $form->addSubmit('', 'edit-user', __('admin', 'edit-user'));
     $form->endFieldset();
     plugin('admin_edit_user_custom_fieldset', array(&$form));
     $form = $form->endAndGetHTML();
     return array(sprintf("%s: %s", __('admin', 'edit-user'), self::get('name')), $messages . $form);
 }
Example #7
0
 $total = $cart->getFormattedTotal();
 $content = "<h3>Purchase for <strong>{$total}</strong></h3>";
 $content .= '<p>Shipping Address: </p>';
 //get address from DB or show address fields
 //get customer addresses
 $addresses = new AddressCollection($customer_id);
 $address_options = array();
 //make empty default option
 $address_options[] = array(0, 'Choose an address');
 if (!empty($addresses)) {
     foreach ($addresses as $a) {
         $address_options[] = array($a->id, $a->address1);
     }
 }
 $form = new Form();
 $form->addSelectList('address_id', 'Ship to', $address_options);
 $form->addText('Or ship to a different address');
 //token
 $token_str = '';
 //make a string from the cart ids converted to hex
 foreach ($_SESSION['cart'] as $id) {
     $token_str .= dechex($id);
 }
 $token = md5($customer_id . time() . $token_str);
 //also add a salt? from file or db
 $_SESSION['form_token'] = $token;
 $form->addInput('token', '', $token, 'hidden');
 $form->addInput('address1', 'Address Line 1');
 $form->addInput('address2', 'Address Line 2');
 $form->addInput('city', 'City');
 $form->addInput('state', 'State');
Example #8
0
 public static function create_display()
 {
     i18n::set('external-link-nodetype');
     $message = "";
     if ($_POST['cc_form'] == 'create_external_link') {
         $id = $_GET['id'];
         $weight = self::get('weight');
         $menutitle = self::get('menutitle');
         $parent_id = self::get('parent_id');
         $slug = self::get('slug');
         if (empty($url) || empty($text)) {
             $message = Message::error(__('blank-error'));
         } else {
             if (empty($weight)) {
                 $weight = '0';
             }
             $values = array('title' => '', 'content' => '', 'settings' => 'a:0:{}', 'weight' => $weight, 'menutitle' => $menutitle, 'parent_id' => $parent_id, 'slug' => $slug);
             $res = Content::createNode($_GET['type'], $values);
             if ($res) {
                 $message = Message::success(sprintf(__('link-creation-successful') . ' (<a href="%s">%s</a>)', Admin::link('content'), __('admin', 'view-all-pages')));
             } else {
                 $message = Message::error(__('link-creation-failed'));
             }
         }
     }
     $r = $message;
     $form = new Form('self', 'post', 'create_external_link');
     $form->addInput(__('url'), 'text', 'slug', self::get('slug'));
     $form->addInput(__('display-text'), 'text', 'menutitle', self::get('menutitle'));
     $form->addSelectList(__('parent'), 'parent_id', PageNode::buildParentOptions(), true, $_POST['parent_id'] ? $_POST['parent_id'] : '0');
     $form->addInput(__('weight'), 'text', 'weight', self::get('weight'));
     $form->addSubmit('', 'create', 'Create');
     i18n::restore();
     return array(__('external-link-nodetype', 'create-external-link'), $form->endAndGetHTML());
 }