/** * Deletes * * @param string $id */ public function deleteAction($id) { $this->view->disable(); $status = "NG"; $categorie = Words::findFirstByid($id); if ($categorie->delete()) { $status = "OK"; } echo json_encode(array("status" => $status)); }
/** * Create a new Words Instance * * @param mixed Optional words to set */ public function __construct($words = null) { if ($words) { if (!is_array($words)) { $words = array($words); } $this->setWords($words); } else { $words = Words::getDefault(); $this->setWords($words); } }
static function store($formData) { Words::addWord($formData); }
private function displayLoginOptions() { $output = ''; $ui = new ViewIntroduction(); if (isset($this->targetUser)) { // Get the details of the introducer $introducerDetailsQ = $this->db->prepare('SELECT p.name FROM person p, introduction i WHERE p.id=i.introducer_id AND i.id = :id'); $introducerDetailsQ->execute(array(':id' => $this->id)); $introducerDetails = $introducerDetailsQ->fetch(PDO::FETCH_ASSOC); $introducerName = $introducerDetails['name']; // Get the details of the target user $targetUserDetailsQ = $this->db->prepare('SELECT p.name, f.id as facebook_id, l.id as linkedin_id, t.id as twitter_id FROM person p LEFT JOIN facebook f ON p.id = f.person_id LEFT JOIN linkedin l ON p.id = l.person_id LEFT JOIN twitter t ON p.id = t.person_id WHERE p.id = :id'); $targetUserDetailsQ->execute(array(':id' => $this->targetUser)); $targetUserDetails = $targetUserDetailsQ->fetch(PDO::FETCH_ASSOC); $targetUserName = $targetUserDetails['name']; $acceptedLoginServices = array(); if (!empty($targetUserDetails['facebook_id'])) { $acceptedLoginServices[] = 'Facebook'; } if (!empty($targetUserDetails['linkedin_id'])) { $acceptedLoginServices[] = 'LinkedIn'; } if (!empty($targetUserDetails['twitter_id'])) { $acceptedLoginServices[] = 'Twitter'; } // Get the details of the other introducee $otherIntroduceeDetailsQ = $this->db->prepare('SELECT p.name, f.id as facebook_id, l.id as linkedin_id, t.id as twitter_id FROM introduction i, person p LEFT JOIN facebook f ON p.id = f.person_id LEFT JOIN linkedin l ON p.id = l.person_id LEFT JOIN twitter t ON p.id = t.person_id WHERE i.id = :introd_id AND ((i.introducee2_id = :id AND p.id = i.introducee1_id) OR (i.introducee1_id = :id AND p.id = i.introducee2_id))'); $otherIntroduceeDetailsQ->execute(array(':introd_id' => $this->id, ':id' => $this->targetUser)); $otherIntroduceeDetails = $otherIntroduceeDetailsQ->fetch(PDO::FETCH_ASSOC); $otherIntroduceeName = $otherIntroduceeDetails['name']; $picture = ''; if (!empty($otherIntroduceeDetails['facebook_id'])) { $picture = '<img src="https://graph.facebook.com/' . $otherIntroduceeDetails['facebook_id'] . '/picture?type=normal" alt="' . $otherIntroduceeName . '" />'; } if (empty($picture) && !empty($otherIntroduceeDetails['linkedin_id'])) { $linkedInPicQ = $this->db->prepare('SELECT picture_url FROM temp_linkedin WHERE linkedin_id = :linkedin_id'); $linkedInPicQ->execute(array(':linkedin_id' => $otherIntroduceeDetails['linkedin_id'])); $linkedInPic = $linkedInPicQ->fetch(PDO::FETCH_ASSOC); if (!empty($linkedInPic['picture_url'])) { $picture = '<img src="' . $linkedInPic['picture_url'] . '" alt="' . $otherIntroduceeName . '" />'; } } if (empty($picture) && !empty($otherIntroduceeDetails['twitter_id'])) { $twitterPicQ = $this->db->prepare('SELECT picture_url FROM temp_twitter WHERE twitter_id = :twitter_id'); $twitterPicQ->execute(array(':twitter_id' => $otherIntroduceeDetails['twitter_id'])); $twitterPic = $twitterPicQ->fetch(PDO::FETCH_ASSOC); if (!empty($twitterPic["picture_url"])) { $picture = '<img src="' . $twitterPic['picture_url'] . '" alt="' . $otherIntroduceeName . '" />'; } } $title = str_replace('OTHER_NAME', $otherIntroduceeName, str_replace('INTRODUCEE_NAME', $targetUserName, str_replace('INTRODUCER_NAME', $introducerName, Content::c()->view->login->title_targeted))); } else { // No target user. Generic login page with all login options. $title = Content::c()->view->login->title; $picture = ''; $acceptedLoginServices = array('Facebook', 'LinkedIn', 'Twitter'); } $output .= $ui->top(); $pleaseLogin = str_replace('SOCIAL_NETWORK_NAME', Words::arrayToList($acceptedLoginServices, Content::c()->or), Content::c()->view->login->login); $output .= '<div class="login clearfix">' . $picture . '<h1>' . $title . '</h1>' . '<p class="pleaseLogin">' . $pleaseLogin . '</p>' . '<div class="loginIcons">'; if (!empty($_GET['base62LinkId'])) { $nextPage = 'B' . $_GET['base62LinkId']; } else { $nextPage = 'A' . $_GET['base62IntroductionId']; } if (in_array('Facebook', $acceptedLoginServices)) { $facebookLoginUrl = SessionManager::getInstance()->getFacebook()->getLoginUrl(array('redirect_uri' => APP_URL . '/' . Content::l() . '/login/facebookcallback/' . $nextPage)); $output .= '<a id="loginFacebook" class="ir" href="' . $facebookLoginUrl . '">Facebook</a>'; } if (in_array('LinkedIn', $acceptedLoginServices)) { $output .= '<a id="loginLinkedIn" class="ir" href="/' . Content::l() . '/login/linkedin/' . $nextPage . '">LinkedIn</a>'; } if (in_array('Twitter', $acceptedLoginServices)) { $output .= '<a id="loginTwitter" class="ir" href="/' . Content::l() . '/login/twitter/' . $nextPage . '">Twitter</a>'; } $output .= '</div>'; if (!empty($this->targetUser)) { $output .= '<div class="faqsContainer">' . '<p id="btnFaqs"><a href="#">' . Content::c()->view->login->help . '</a></p>' . '<div id="faqs"><h2>' . Content::c()->view->login->faqs->what->title . '</h2>' . '<p>' . Content::c()->view->login->faqs->what->body . '</p>'; if (count($acceptedLoginServices) == 1) { $output .= '<h2>' . str_replace('SOCIAL_NETWORK_NAME', $acceptedLoginServices[0], Content::c()->view->login->faqs->why->title) . '</h2>' . '<p>' . str_replace('SOCIAL_NETWORK_NAME', $acceptedLoginServices[0], str_replace('TARGET_NAME', $targetUserName, str_replace('INTRODUCER_NAME', $introducerName, str_replace('INTRODUCEE_NAME', $otherIntroduceeName, Content::c()->view->login->faqs->why->body)))) . '</p>'; } $output .= '<h2>' . Content::c()->view->login->faqs->spam->title . '</h2>' . '<p>' . str_replace('INTRODUCER_NAME', $introducerName, str_replace('INTRODUCEE_NAME', $otherIntroduceeName, Content::c()->view->login->faqs->spam->body)) . '</p>'; $output .= '</div></div>'; } $output .= '</div>'; $script = '<script>' . '$(document).ready(function() {' . '_gaq.push(["_trackPageview", "/view-introduction/not-logged-in"]);' . '});' . '</script>'; $bottom = new Bottom($script); $output .= $bottom->getOutput(); return $output; }