Example #1
0
 public static function display()
 {
     if (!is_numeric($_GET['id'])) {
         cc_redirect(Admin::link('users'));
     }
     if ($_POST['cc_form'] == 'edit-group') {
         $id = $_GET['id'];
         $previous = (array) unserialize(urldecode($_POST['previous']));
         $group = $_POST['group'];
         $permissions = (array) $_POST['permissions'];
         $new = array_merge($previous, $permissions);
         foreach ($new as $k => $v) {
             if ($v == "1") {
                 $new[$k] = true;
             }
             if (!array_key_exists($k, $permissions)) {
                 $new[$k] = false;
             }
         }
         if (DB::update('users', array('name', 'data'), array($group, serialize(filter('admin_edit_group_data', array('permissions' => $new)))), array('users_id = ?', $id))) {
             $message = Message::success(__('admin', 'group-information-updated'));
         } else {
             $message = Message::error(__('admin', 'database-error'));
         }
     }
     $p = Permissions::getAll();
     $g = new Group((int) $_GET['id']);
     $p_form = new Form('');
     $p_form->setCC_Form('edit-group');
     $p_form->startFieldset(__('admin', 'group-information'));
     $p_form->addInput(__('admin', 'group-name'), 'text', 'group', $g->getName());
     $p_form->endFieldset();
     $p_form->addHTML(sprintf("<h3>%s</h3>", __('admin', 'permissions')));
     $p_table = new Table('permissions');
     $p_table->addHeader(array('Name', 'Allowed'));
     foreach ($p as $k => $v) {
         $previous[$v['name']] = $g->isAllowed($v['name']);
         $p_table->addRow(array(__('permissions', $v['name']), sprintf('<input type="checkbox" name="permissions[%s]"%svalue="1"/>', $v['name'], $g->isAllowed($v['name']) ? ' checked="checked"' : '')));
     }
     $p_form->addHidden('previous', urlencode(serialize($previous)));
     $p_form->addHTML($p_table->html());
     $p_form->addSubmit('', 'save-permissions', __('admin', 'save-changes'));
     return array(sprintf('%s: %s', __('admin', 'edit-group'), $g->getName()), $message . $p_form->html());
 }
 function general_action()
 {
     $this->pageTitle = 'Ustawienia ogólne';
     $form = new Form('wmelon.options.general', 'options/general_save', 'options/general');
     // input values
     $config = Watermelon::$config;
     $siteName = $config->siteName;
     $footer = $config->footer;
     $head = $config->headTags;
     $tail = $config->tailTags;
     $userData = Users::userData();
     $login = $userData->login;
     $nick = $userData->nick;
     $email = $userData->email;
     $sblamKey = Config::get('wmelon.sblam.apiKey');
     // label notes
     $footer_label = 'Możesz używać HTML<br>oraz <em>$/</em> dla linków na stronie';
     $head_label = '"sekcja &lt;head&gt;"; skrypty, arkusze stylów itp.';
     $tail_label = 'Skrypty, dodane na końcu strony';
     $login_label = 'Nazwa użyta podczas logowania. Uważaj, żeby przypadkiem nie zmienić.';
     $nick_label = 'Nazwa pokazywana przy Twoich komentarzach itp.';
     $email_label = 'Zostanie użyty obok Twoich komentarzy do pokazania <a href="http://gravatar.com/" target="_blank">gravatara</a>';
     if (!empty($email)) {
         $email_label .= '<br>Podgląd: ';
         $email_label .= '<img src="http://gravatar.com/avatar/' . md5($email) . '?s=64&amp;d=mm" style="vertical-align:middle" />';
     }
     $sblamKey_label = '';
     // input args
     $siteName = array('value' => $siteName);
     $footer = array('value' => $footer, 'labelNote' => $footer_label);
     $head = array('value' => $head, 'labelNote' => $head_label);
     $tail = array('value' => $tail, 'labelNote' => $tail_label);
     $login = array('value' => $login, 'labelNote' => $login_label);
     $nick = array('value' => $nick, 'labelNote' => $nick_label);
     $email = array('value' => $email, 'labelNote' => $email_label);
     $sblamKey = array('value' => $sblamKey, 'labelNote' => $sblamKey_label);
     // adding inputs
     $form->addHTML('<fieldset id="siteOptions"><legend>Strona</legend>');
     $form->addInput('text', 'siteName', 'Nazwa strony', true, $siteName);
     $form->addInput('textarea', 'footer', 'Stopka', false, $footer);
     $form->addInput('textarea', 'head', 'Własne tagi na początek strony', false, $head);
     $form->addInput('textarea', 'tail', 'Własne tagi na koniec strony', false, $tail);
     $form->addHTML('</fieldset>');
     $form->addHTML('<fieldset id="adminOptions"><legend>Ty</legend>');
     $form->addInput('text', 'login', 'Twój login', true, $login);
     $form->addInput('text', 'nick', 'Twój nick', false, $nick);
     $form->addInput('password', 'pass', 'Twoje hasło', false);
     $form->addInput('password', 'pass2', 'Twoje hasło (powtórz)', false);
     $form->addHTML('</fieldset>');
     $form->addHTML('<fieldset id="sblamOptions"><legend>Sblam!</legend>');
     $form->addHTML('<p>Sblam! to filtr antyspamowy użyty w Watermelonie. Aby działał poprawnie należy ustalić dla niego <em>klucz API</em>. Własny klucz możesz <a href="http://sblam.com/key.html">wygenerować na stronie Sblam!</a></p>');
     $form->addInput('text', 'sblamKey', 'Klucz API', false, $sblamKey);
     $form->addHTML('</fieldset>');
     // rendering
     echo $form->generate();
 }
Example #3
0
 function edit_action($id)
 {
     $id = (int) $id;
     // getting data
     $data = $this->model->postData_id($id);
     if (!$data) {
         SiteRedirect('blog');
     }
     // back to link
     $backTo = isset($this->params->backTo) ? '?backTo=' . $this->params->backTo : '';
     $postURL = '#/' . date('Y/m', $data->published) . '/' . $data->name;
     switch ($this->params->backTo) {
         case 'post':
             $backToLabel = ' lub <a href="' . $postURL . '">powróć do wpisu</a>';
             break;
         case 'site':
             $backToLabel = ' lub <a href="#/#blogpost-' . $data->id . '">powróć do strony</a>';
             // TODO: and what if the post is not on first page?
             break;
         default:
             $backToLabel = ', <a href="$/blog/">powróć do listy wpisów</a> albo <a href="' . $postURL . '">obejrzyj wpis</a>';
             break;
     }
     // options
     $this->pageTitle = 'Edytuj wpis';
     $form = new Form('wmelon.blog.editPost', 'blog/editSubmit/' . $id . $backTo, 'blog/edit/' . $id . $backTo);
     $form->displaySubmitButton = false;
     // label notes
     $summary_note = 'Jeśli chcesz, napisz krótko wstęp lub streszczenie wpisu - zostanie ono pokazane na stronie głównej i w czytnikach kanałów';
     // inputs args
     $titleArgs = array('value' => $data->title);
     $contentArgs = array('value' => $data->content, 'style' => 'width: 100%; height:30em');
     $summaryArgs = array('value' => $data->summary, 'labelNote' => $summary_note);
     $allowCommentsArgs = array('value' => $data->allowComments);
     // adding inputs
     $form->addInput('text', 'title', 'Tytuł', true, $titleArgs);
     $form->addInput('textarea', 'content', 'Treść', true, $contentArgs);
     $form->addInput('textarea', 'summary', 'Streszczenie', false, $summaryArgs);
     $form->addInput('checkbox', 'allowComments', 'Pozwól na komentarze', false, $allowCommentsArgs);
     // submit buttons
     $form->addHTML('<br><label><span></span>');
     $form->addHTML('<input type="submit" name="submit_save" value="Zapisz">');
     if ($data->status == 'draft') {
         $form->addHTML('<input type="submit" name="submit_publish" value="Opublikuj">');
     }
     $form->addHTML($backToLabel);
     $form->addHTML('</label>');
     echo $form->generate();
 }
 function edit_action($id)
 {
     $id = (int) $id;
     // getting data
     $data = $this->model->pageData_id($id);
     if (!$data) {
         SiteRedirect('pages');
     }
     // back to link
     if ($this->params->backTo == 'site') {
         $backTo = '?backTo=site';
         $backToLabel = ' lub <a href="#/' . $data->name . '">powróć do strony</a>';
     } else {
         $backToLabel = ', <a href="$/pages/">powróć do listy stron</a> lub <a href="#/' . $data->name . '">obejrzyj stronę</a>';
     }
     // form options
     $this->pageTitle = 'Edytuj stronę';
     $form = new Form('wmelon.pages.editPage', 'pages/editSubmit/' . $id . $backTo, 'pages/edit/' . $id . $backTo);
     $form->displaySubmitButton = false;
     // inputs labels
     $nameLabel = 'Nie zmieniaj, jeśli <em>naprawdę</em> nie wiesz co robisz';
     // inputs args
     $titleArgs = array('value' => $data->title);
     $contentArgs = array('value' => $data->content, 'style' => 'width: 100%; height:30em');
     $nameArgs = array('value' => $data->name, 'labelNote' => $nameLabel);
     // adding inputs
     $form->addInput('text', 'title', 'Tytuł', true, $titleArgs);
     $form->addInput('textarea', 'content', 'Treść', true, $contentArgs);
     $form->addInput('text', 'name', 'Nazwa', true, $nameArgs);
     $form->addHTML('<label><span></span><input type="submit" value="Zapisz">' . $backToLabel . '</label>');
     echo $form->generate();
 }