Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Subscriptions can't be added if user has zero subscriptions existing, can't see random or all in blab list #2

Open
jonathanvaughn opened this issue May 8, 2014 · 0 comments

Comments

@jonathanvaughn
Copy link

Figured out why I was having the problem, sort of. TL;DR: The add blab logic was inserting at the start of the list, but that didn't work if there wasn't any list ...

Here's my fix for that, plus removing the minimum of 3 blabs restriction (not sure why that was there, but I only had 3 I was testing with so that was annoying), and fixing the all and random blab links to work even if user has zero subs (when logged in and no subs, wouldn't even get the random and all options).

# diff -Bb repo/application/controllers/BlabsController.php application/controllers/BlabsController.php
371,375d370
<                                                                       if (count($results) < 4) {
<                                                                               $msg = "You must maintain at least 3 items on your front page. Please add some more first.";
<                                                                               return $this->_redirect("/index/notfound?m=".urlencode($msg));
<                                                                       }
<
429,438d423
<                                                                       $oldFirstItem = array();
<                                                                       $i = 0;
<
<                                                                       if (isset($results[0]["id"])) {
<
<                                                                               $oldFirstItem["id"] = $results[0]["id"];
<                                                                               $oldFirstItem["user_id"] = $results[0]["user_id"];
<                                                                               $oldFirstItem["blab_id"] = $results[0]["blab_id"];
<                                                                               $oldFirstItem["display_order"] = $results[0]["display_order"];
<                                                                               // Update first row with new blab id
440c425,427
<                                                                       'blab_id'      => $blabId

---
>                                                         'blab_id'      => $blabId,
>                                                         'user_id'      => $loggedInId,
>                                                         'display_order' => $count++,
442,446c429,430
<                                                                               $update = $db->update("subscriptions", $data, "id = ".$oldFirstItem["id"]);
<
<                                                                               // shift all the other subscriptions down one row
<                                                                               $shifter = $this->moveBlabsDown($count, $oldFirstItem);
<                                                                       }

---
>                                                         // Add blab as next available display order
>                                                         $insert = $db->insert("subscriptions", $data);
453,455d436
<                                                 }
<
<
458a440
>     }

# diff -Bb repo/application/views/helpers/BuildBlabCategories.php application/views/helpers/BuildBlabCategories.php
55,57d54
<                       foreach ($results as $row) {
<                               $class = ($row['title'] == $category) ? 'class="activeBlab"' : 'class=""';
<                               if ($i == 0) {
62a60,62
>                       foreach ($results as $row) {
>                               $class = ($row['title'] == $category) ? 'class="activeBlab"' : 'class=""';
>                               if ($i == 0) {
64,65d63
<                                       $blabs .= '<a '.$class.' href="/b/'.$row['title'].'">'.$row['title'].'</a>';
<                                       $blabs .= " - ";
67,69c65,67
<                               else {
<                               $blabs .= '<a '.$class.' href="/b/'.$row['title'].'">'.$row['title'].'</a>';
<                               $blabs .= " - ";

---
>                 else
>                 {
>                     $blabs .= ' - ';
70a69
>                               $blabs .= '<a '.$class.' href="/b/'.$row['title'].'">'.$row['title'].'</a>';
74,75d72
<                       $blabs = substr($blabs,0,-1);
<                       $blabs = substr($blabs,0,-1);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant