コード例 #1
0
 public function questionSubscribe(Request $request, $id)
 {
     $question = Question::find($id);
     $message = [];
     if ($currentUser = \Auth::user()) {
         if ($question->subscribers->contains($currentUser)) {
             // $this->dispatch(new RemoveLikeFromAnswer($tag, \Auth::user()));
             $question->subscribers()->detach($currentUser);
             $message['type'] = 'unsubscribe';
         } else {
             $question->subscribers()->attach($currentUser);
             $message['type'] = 'subscribe';
             // $this->dispatch(new AddLikeToAnswer($tag, \Auth::user()));
         }
     }
     if ($request->ajax()) {
         $message['count'] = $question->subscribersCount;
         $message['title'] = count_subscribers($message['count']);
         return $message;
     }
     return back();
 }
コード例 #2
0
ファイル: admin-core.php プロジェクト: bulini/sendit
function ManageLists()
{
    global $_POST;
    global $wpdb;
    //nome tabella LISTE
    $table_liste = $wpdb->prefix . "nl_liste";
    if ($_POST['newsletteremail'] != "" and $_POST['com'] != "EDIT") {
        $liste_count = $wpdb->get_var("SELECT COUNT(*) FROM {$table_liste} where email_lista ='{$_POST['newsletteremail']}';");
        $wpdb->query("INSERT INTO {$table_liste} (email_lista, nomelista) VALUES ('{$_POST['newsletteremail']}', '{$_POST['newslettername']}')");
        echo '<div id="message" class="updated fade"><p><strong>' . __('Mailing list created succesfully!', 'sendit') . '</strong></p></div>';
    }
    if ($_POST['com'] == "EDIT") {
        $header = $_POST['header'];
        $footer = $_POST['footer'];
        $aggiorno = $wpdb->query("UPDATE {$table_liste} set email_lista = '{$_POST['newsletteremail']}', nomelista = '{$_POST['newslettername']}', header='{$header}', footer='{$footer}' where id_lista = '{$_POST['id_lista']}'");
        $msg = '<div id="message" class="updated fade"><p><strong>' . __('Mailing list updated', 'sendit') . '</strong></p></div>';
    } elseif ($_POST['com'] == "ADD") {
        $newemail = __('email@here', 'sendit');
        $newname = __('New mailing list', 'sendit');
        $ins = $wpdb->query("insert into {$table_liste} (email_lista, nomelista) values('{$newemail}', '{$newname}')");
        $msg = '<div id="message" class="updated fade"><p><strong>' . __('Mailing created successfully!', 'sendit') . '</strong></p></div>';
    } elseif ($_POST['com'] == "DEL") {
        $ins = $wpdb->query("delete from {$table_liste} where id_lista = {$_POST['id_lista']}");
        $msg = '<div id="message" class="updated fade"><p><strong>' . __('Mailing deleted successfully!', 'sendit') . '</strong></p></div>';
    }
    if ($_GET['update'] == 1 && !isset($_POST['com'])) {
        $listacorrente = $wpdb->get_row("select * from {$table_liste} where id_lista = '{$_GET['id_lista']}'");
        $com = "EDIT";
    }
    if ($_GET['delete'] == 1) {
        //div che avvisa prima della cancellazione con form
        $msg = "<div class=\"error\"class=\"wrap\"><p>" . sprintf(__('Are You sure to delete %d list? it will delete all mailing list and subscribers data ', 'sendit'), $_GET['id_lista']) . " " . $listacorrente->nomelista . "</p>\n                <form action=\"admin.php?page=lists-management\" method=\"post\" name=\"delml\">\n                    <input type=\"hidden\" name=\"id_lista\" value = \"" . $_GET['id_lista'] . "\">\n                    <input type=\"submit\" name=\"com\" value = \"DEL\">\n                </form>\n                </div>";
    }
    echo "<div class=\"wrap\"class=\"wrap\"><h2>" . __('Lists Management', 'sendit') . " " . $listacorrente->nomelista . "</h2>";
    //esco il messaggio
    echo $msg;
    $table_liste = $wpdb->prefix . "nl_liste";
    $liste = $wpdb->get_results("select * from {$table_liste}");
    echo "\n                    <form action='{$_SERVER['REQUEST_URI']}' method='post' name='addml'>\n                    <input type='submit' class='button-primary sendit_actionbuttons' name='go' value='" . __('Create new list', 'sendit') . "'>\n                    <input type='hidden' name='com' value='ADD' />\n                    </form>\n                         <table class=\"wp-list-table widefat fixed posts\">\n                            <thead>\n                            <tr>\n                            <th>" . __('Available lists', 'sendit') . "</th>\n                            <th>" . __('from', 'sendit') . "</th>\n                            <th style=\"width:100px;\">" . __('Subscribers', 'sendit') . "</th>\n                            <th>" . __('actions', 'sendit') . "</th>\n                            </tr>\n                            </thead>\n                            <tbody>\n                            ";
    foreach ($liste as $lista) {
        echo "<tr>\n                            <td>" . $lista->id_lista . " - " . $lista->nomelista . "</td>\n                            <td>" . $lista->email_lista . " </td>\n                            <td><b>" . count_subscribers($lista->id_lista) . "</b></td>\n                            <td><a class=\"button-secondary\" href=\"admin.php?page=lists-management&update=1&id_lista=" . $lista->id_lista . "\"><i class=\"dashicons-before dashicons-admin-tools\"></i> " . __('Edit', 'sendit') . "</a> <a class=\"button-secondary\" href=\"admin.php?page=lista-iscritti&lista=" . $lista->id_lista . "\"><i class=\"dashicons-before dashicons-admin-users\"></i> " . __('Manage subscribers', 'sendit') . "</a> <a class=\"button-secondary\" href=\"admin.php?page=lists-management&delete=1&id_lista=" . $lista->id_lista . "\">" . __('Delete', 'sendit') . "</a></td></p></tr>";
    }
    echo "</tbody></table>";
    if ($_GET['id_lista'] and !$_GET['delete']) {
        echo "<form action='{$_SERVER['REQUEST_URI']}' method='post' >\n            <p>" . __('Newsletter options', 'sendit') . "</p>\n            <table>\n\n                    <tr>\n                        <th scope=\"row\" width=\"200\"><label for=\"newsletteremail\">" . __('from email', 'sendit') . "</label><th>\n                        <td><input type=\"text\" name=\"newsletteremail\" value=\"" . $listacorrente->email_lista . "\" ></td>\n                    </tr>\n                    <tr>\n                    <th scope=\"row\" ><label for=\"newslettername\">" . __('Newsletter name', 'sendit') . "</label><th>\n                    <td><input type=\"text\" name=\"newslettername\"  value=\"" . $listacorrente->nomelista . "\"><input type=\"hidden\" name=\"com\" value=\"" . $com . "\">\n                    <input type=\"hidden\" name=\"id_lista\" value=\"" . $_GET[id_lista] . "\">\n                    </td></tr>\n                    <tr>\n                    <th scope=\"row\"><label for=\"template_id\">Select Template</label></th><td></td>\n\n                    </tr>\n                    <tr><th scope=\"row\" ><label for=\"header\">" . __('Header', 'sendit') . "</label><th>\n                    <td><textarea name=\"header\" rows=\"5\" cols=\"50\">" . $listacorrente->header . "</textarea></td></tr>\n                        <tr><th scope=\"row\" ><label for=\"footer\">" . __('Footer', 'sendit') . "</label><th>\n                    <td><textarea name=\"footer\" rows=\"5\" cols=\"50\">" . $listacorrente->footer . "</textarea></td></tr>\n                    <tr><th scope=\"row\" ><th>\n                    <td><p class=\"submit\"><input type=\"submit\" class=\"button-primary\" name=\"salva\" value=\"" . __('Save', 'sendit') . "\"></p></td>\n                    </tr>\n                 </table>\n                    </form>";
    }
    echo "</div>";
}
コード例 #3
0
ファイル: subscribers-list.php プロジェクト: bulini/sendit
/** *************************** RENDER TEST PAGE ********************************
 *******************************************************************************
 * This function renders the admin page and the example list table. Although it's
 * possible to call prepare_items() and display() from the constructor, there
 * are often times where you may need to include logic here between those steps,
 * so we've instead called those methods explicitly. It keeps things flexible, and
 * it's the way the list tables are used in the WordPress core.
 */
function sendit_render_list_page()
{
    //Create an instance of our package class...
    $SenditListTable = new Sendit_List_Table();
    //Fetch, prepare, sort, and filter our data...
    $liste = $SenditListTable->get_sendit_lists();
    $SenditListTable->prepare_items();
    ?>
    <div class="wrap">

        <div id="icon-users" class="icon32"><br/></div>
        <h1>Sendit <a href="<?php 
    echo get_bloginfo('siteurl');
    ?>
/wp-admin/admin-ajax.php?action=add_contacts&width=500&height=400&page=lista-iscritti" class="page-title-action thickbox">Add Subscribers</a></h1>



        <?php 
    add_thickbox();
    ?>
        <div id="my-content-id" style="display:none;">
			<p>
          id <?php 
    echo $_GET['id'];
    ?>
		  	</p>
	 	</div>


        <div>
           <h3>Contact management</h3>
          <p><i>sono le ore <?php 
    echo date("Y-m-d H:i:s");
    ?>
</i></p>

        <ul class="subsubsub">
        <?php 
    $allcss = !isset($_GET['lista']) ? ' current' : '';
    foreach ($liste as $lista) {
        $css = $_GET['lista'] == $lista['id_lista'] ? ' current' : '';
        $subscribers = count_subscribers($lista['id_lista']);
        ?>
            <li><a class="<?php 
        echo $css;
        ?>
"href="<?php 
        echo admin_url('admin.php?page=lista-iscritti&lista=' . $lista['id_lista']);
        ?>
"><?php 
        echo $lista['nomelista'];
        ?>
 (<?php 
        echo $subscribers;
        ?>
)</a>
            </li>
        <?php 
        $tot_subscribers += $subscribers;
    }
    ?>
        <li><a class="<?php 
    echo $allcss;
    ?>
" href="<?php 
    echo admin_url('admin.php?page=lista-iscritti');
    ?>
">All contact (<?php 
    echo $tot_subscribers;
    ?>
)</a></li>
        </ul>


        </div>

        <br />



        <form  method="get" id="searchcontact">
            <input type="hidden" name="page" value="<?php 
    echo $_REQUEST['page'];
    ?>
" />
            <?php 
    $SenditListTable->search_box('search', 'search_id');
    ?>
        </form>

        <br />
        <!-- Forms are NOT created automatically, so you need to wrap the table in one to use features like bulk actions -->
        <form id="subscribers-filter" method="get">
            <!-- For plugins, we also need to ensure that the form posts back to our current page -->
            <input type="hidden" name="page" value="<?php 
    echo $_REQUEST['page'];
    ?>
" />
            <!-- Now we can render the completed list table -->
            <?php 
    $SenditListTable->display();
    ?>
        </form>

    </div>
    <?php 
}