当前位置: 首页>>代码示例>>PHP>>正文


PHP Utils::isTest方法代码示例

本文整理汇总了PHP中Utils::isTest方法的典型用法代码示例。如果您正苦于以下问题:PHP Utils::isTest方法的具体用法?PHP Utils::isTest怎么用?PHP Utils::isTest使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Utils的用法示例。


在下文中一共展示了Utils::isTest方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: reportVersion

 /**
  * Report installation version back to thinkup.com. If usage reporting is enabled, include instance username
  * and network.
  * @param Instance $instance
  * @return array ($report_back_url, $referer_url, $status, $contents)
  */
 public static function reportVersion(Instance $instance)
 {
     //Build URLs with appropriate parameters
     $config = Config::getInstance();
     $report_back_url = 'http://thinkup.com/version.php?v=' . $config->getValue('THINKUP_VERSION');
     //Explicity set referer for when this is called by a command line script
     $referer_url = Utils::getApplicationURL();
     //If user hasn't opted out, report back username and network
     if ($config->getValue('is_opted_out_usage_stats') === true) {
         $report_back_url .= '&usage=n';
     } else {
         $referer_url .= "?u=" . urlencode($instance->network_username) . "&n=" . urlencode($instance->network);
     }
     if (!Utils::isTest()) {
         //only make live request if we're not running the test suite
         //Make the cURL request
         $c = curl_init();
         curl_setopt($c, CURLOPT_URL, $report_back_url);
         curl_setopt($c, CURLOPT_REFERER, $referer_url);
         curl_setopt($c, CURLOPT_RETURNTRANSFER, 1);
         $contents = curl_exec($c);
         $status = curl_getinfo($c, CURLINFO_HTTP_CODE);
         curl_close($c);
     } else {
         $contents = '';
         $status = 200;
     }
     return array($report_back_url, $referer_url, $status, $contents);
 }
开发者ID:dgw,项目名称:ThinkUp,代码行数:35,代码来源:class.Reporter.php

示例2: doesTextMatchImage

 /**
  * Check the $_POST'ed CAPTCHA inputs match the contents of the CAPTCHA.
  * @return bool
  */
 public function doesTextMatchImage()
 {
     //if in test mode, assume check is good if user_code is set to 123456
     if (Utils::isTest()) {
         if (isset($_POST['user_code']) && $_POST['user_code'] == '123456') {
             return true;
         } else {
             return false;
         }
     }
     switch ($this->type) {
         case self::RECAPTCHA_CAPTCHA:
             $config = Config::getInstance();
             $priv_key = $config->getValue('recaptcha_private_key');
             $resp = recaptcha_check_answer($priv_key, $_SERVER["REMOTE_ADDR"], $_POST["recaptcha_challenge_field"], $_POST["recaptcha_response_field"]);
             if (!$resp->is_valid) {
                 return false;
             } else {
                 return true;
             }
             break;
         default:
             if (strcmp(md5($_POST['user_code']), SessionCache::get('ckey'))) {
                 return false;
             } else {
                 return true;
             }
             break;
     }
 }
开发者ID:prabhatse,项目名称:olx_hack,代码行数:34,代码来源:class.Captcha.php

示例3: generateInsight

 public function generateInsight(Instance $instance, User $user, $last_week_of_posts, $number_days)
 {
     parent::generateInsight($instance, $user, $last_week_of_posts, $number_days);
     $this->logger->logInfo("Begin generating insight", __METHOD__ . ',' . __LINE__);
     $baseline_dao = DAOFactory::getDAO('InsightBaselineDAO');
     foreach ($this->getSchedule() as $baseline_slug => $data) {
         $now = TimeHelper::getTime();
         if ($now >= strtotime($data['start']) && $now <= strtotime($data['end'])) {
             $this->logger->logInfo("{$now} is in-schedule", __METHOD__ . ',' . __LINE__);
             $baseline = $baseline_dao->getMostRecentInsightBaseline($baseline_slug, $instance->id);
             if (!$baseline) {
                 if ($instance->network == 'facebook' && date('w') == 4 || $instance->network == 'twitter' && date('w') == 1 || Utils::isTest()) {
                     $found = $this->runInsightForConfig($data, $instance);
                     $baseline_dao->insertInsightBaseline($baseline_slug, $instance->id, $found);
                 } else {
                     $this->logger->logInfo("Not today", __METHOD__ . ',' . __LINE__);
                 }
             } else {
                 $this->logger->logInfo("Already exists", __METHOD__ . ',' . __LINE__);
             }
         } else {
             $this->logger->logInfo("Not in-schedule", __METHOD__ . ',' . __LINE__);
         }
     }
     $this->logger->logInfo("Done generating insight", __METHOD__ . ',' . __LINE__);
 }
开发者ID:ngugijames,项目名称:ThinkUp,代码行数:26,代码来源:newdictionarywords.php

示例4: shouldGenerateInsight

 /**
  * Determine whether an insight should be generated or not.
  * @param str $slug slug of the insight to be generated
  * @param Instance $instance user and network details for which the insight has to be generated
  * @param date $insight_date date for which the insight has to be generated
  * @param bool $regenerate_existing_insight whether the insight should be regenerated over a day
  * @param int $day_of_week the day of week (0 for Sunday through 6 for Saturday) on which the insight should run
  * @param int $count_last_week_of_posts if set, wouldn't run insight if there are no posts from last week
  * @param arr $excluded_networks array of networks for which the insight shouldn't be run
  * @param bool $alternate_day whether today is an alternate day or not
  * @return bool $run whether the insight should be generated or not
  */
 public function shouldGenerateInsight($slug, Instance $instance, $insight_date = null, $regenerate_existing_insight = false, $day_of_week = null, $count_last_week_of_posts = null, $excluded_networks = null, $alternate_day = true)
 {
     if (Utils::isTest()) {
         return true;
     } else {
         return $alternate_day && parent::shouldGenerateInsight($slug, $instance, $insight_date, $regenerate_existing_insight, $day_of_week, $count_last_week_of_posts, $excluded_networks);
     }
 }
开发者ID:dgw,项目名称:ThinkUp,代码行数:20,代码来源:linkprompt.php

示例5: authControl

 public function authControl()
 {
     $config = Config::getInstance();
     Loader::definePathConstants();
     $this->setViewTemplate(THINKUP_WEBAPP_PATH . 'plugins/twitter/view/twitter.account.index.tpl');
     $this->view_mgr->addHelp('twitter', 'userguide/settings/plugins/twitter/index');
     $instance_dao = DAOFactory::getDAO('InstanceDAO');
     // get plugin option values if defined...
     $plugin_options = $this->getPluginOptions();
     $oauth_consumer_key = $this->getPluginOption('oauth_consumer_key');
     $oauth_consumer_secret = $this->getPluginOption('oauth_consumer_secret');
     $archive_limit = $this->getPluginOption('archive_limit');
     $num_twitter_errors = $this->getPluginOption('num_twitter_errors');
     $this->addToView('twitter_app_name', "ThinkUp " . $_SERVER['SERVER_NAME']);
     $this->addToView('thinkup_site_url', Utils::getApplicationURL(true));
     $plugin = new TwitterPlugin();
     if ($plugin->isConfigured()) {
         $this->addToView('is_configured', true);
         $owner_instances = $instance_dao->getByOwnerAndNetwork($this->owner, 'twitter');
         $this->addToView('owner_instances', $owner_instances);
         if (isset($this->owner) && $this->owner->isMemberAtAnyLevel()) {
             if ($this->owner->isMemberLevel()) {
                 if (sizeof($owner_instances) > 0) {
                     $this->do_show_add_button = false;
                     $this->addInfoMessage("To connect another Twitter account to ThinkUp, upgrade your membership.", 'membership_cap');
                 }
             }
         }
         if (isset($_GET['oauth_token']) || $this->do_show_add_button) {
             $twitter_oauth = new TwitterOAuth($oauth_consumer_key, $oauth_consumer_secret);
             /* Request tokens from twitter */
             $token_array = $twitter_oauth->getRequestToken(Utils::getApplicationURL(true) . "account/?p=twitter");
             if (isset($token_array['oauth_token']) || Utils::isTest()) {
                 $token = $token_array['oauth_token'];
                 SessionCache::put('oauth_request_token_secret', $token_array['oauth_token_secret']);
                 if (isset($_GET['oauth_token'])) {
                     self::addAuthorizedUser($oauth_consumer_key, $oauth_consumer_secret, $num_twitter_errors);
                 }
                 if ($this->do_show_add_button) {
                     /* Build the authorization URL */
                     $oauthorize_link = $twitter_oauth->getAuthorizeURL($token);
                     $this->addToView('oauthorize_link', $oauthorize_link);
                 }
             } else {
                 //set error message here
                 $this->addErrorMessage("Unable to obtain OAuth tokens from Twitter. Please double-check the consumer key and secret " . "are correct.", "setup");
                 $oauthorize_link = '';
                 $this->addToView('is_configured', false);
             }
         }
     } else {
         $this->addInfoMessage('Please complete plugin setup to start using it.', 'setup');
         $this->addToView('is_configured', false);
     }
     // add plugin options from
     $this->addOptionForm();
     return $this->generateView();
 }
开发者ID:dgw,项目名称:ThinkUp,代码行数:58,代码来源:class.TwitterPluginConfigurationController.php

示例6: generateInsight

 public function generateInsight(Instance $instance, User $user, $last_week_of_posts, $number_days)
 {
     if (Utils::isTest() || date("Y-m-d") == '2015-02-23') {
         parent::generateInsight($instance, $user, $last_week_of_posts, $number_days);
         $this->logger->logInfo("Begin generating insight", __METHOD__ . ',' . __LINE__);
         $hero_image = array('url' => 'https://www.thinkup.com/assets/images/insights/2015-02/oscars2015.jpg', 'alt_text' => 'Oprah got a Lego Oscar!', 'credit' => 'Photo: Disney | ABC Television Group', 'img_link' => 'https://www.flickr.com/photos/disneyabc/16620198142');
         $post_dao = DAOFactory::getDAO('PostDAO');
         $last_month_of_posts = $post_dao->getAllPostsByUsernameOrderedBy($instance->network_username, $network = $instance->network, $count = 0, $order_by = "pub_date", $in_last_x_days = 30, $iterator = false, $is_public = false);
         if (self::shouldGenerateWeeklyInsight('oscars_2015', $instance, $insight_date = 'today', $regenerate_existing_insight = false, $day_of_week = 1, count($last_month_of_posts))) {
             foreach ($last_month_of_posts as $post) {
                 $this->logger->logInfo("Post text is: " . $post->post_text, __METHOD__ . ',' . __LINE__);
                 //  see if $post date is before the awards aired
                 if ($post->pub_date < "2015-02-22 18:00:00") {
                     $mentioned_oscar_winner = self::detectOscarWinnerReferences($post->post_text);
                     $mentioned_oscar_loser = self::detectOscarLoserReferences($post->post_text);
                     $oscar_mention_count = self::countOscarMentions($post->post_text);
                     if ($mentioned_oscar_winner) {
                         $this->logger->logInfo("Winner mention: {$mentioned_oscar_winner}", __METHOD__ . ',' . __LINE__);
                         $insight_body = "{$this->username} was talking about {$mentioned_oscar_winner} before the " . "Academy Award winners were even announced!";
                     } else {
                         $this->logger->logInfo("No winners mentioned, skipping insight. ", __METHOD__ . ',' . __LINE__);
                     }
                     if ($mentioned_oscar_loser) {
                         $this->logger->logInfo("Loser mention: {$mentioned_oscar_loser}", __METHOD__ . ',' . __LINE__);
                         $insight_body_suffix = " Looks like the Academy voters might have missed " . "{$this->username}'s " . $this->terms->getNoun('post', InsightTerms::PLURAL) . " about " . $mentioned_oscar_loser . ", though.";
                     }
                 }
             }
             if ($insight_body_suffix) {
                 $insight_text = $insight_body . $insight_body_suffix;
             } else {
                 $insight_text = $insight_body;
             }
             if ($insight_body) {
                 $headline = "Somebody was ready for the Oscars party!";
                 $my_insight = new Insight();
                 $my_insight->slug = 'oscars_2015';
                 //slug to label this insight's content
                 $my_insight->instance_id = $instance->id;
                 $my_insight->date = $this->insight_date;
                 //date is often this or $simplified_post_date
                 $my_insight->headline = $headline;
                 // or just set a string like 'Ohai';
                 $my_insight->text = $insight_text;
                 // or just set a strong like "Greetings humans";
                 $my_insight->filename = basename(__FILE__, ".php");
                 //Same for every insight, must be set this way
                 $my_insight->emphasis = Insight::EMPHASIS_HIGH;
                 //Optional emphasis, default Insight::EMPHASIS_LOW
                 $my_insight->setHeroImage($hero_image);
                 $this->insight_dao->insertInsight($my_insight);
             }
         }
         $this->logger->logInfo("Done generating insight", __METHOD__ . ',' . __LINE__);
     }
 }
开发者ID:pepeleproso,项目名称:ThinkUp,代码行数:56,代码来源:oscars2015.php

示例7: generateInsight

 public function generateInsight(Instance $instance, User $user, $last_week_of_posts, $number_days)
 {
     parent::generateInsight($instance, $user, $last_week_of_posts, $number_days);
     $this->logger->logInfo("Begin generating insight", __METHOD__ . ',' . __LINE__);
     $has_never_run = !$this->insight_dao->doesInsightExist($this->slug, $instance->id);
     if (Utils::isTest() || $has_never_run && (date("Y-m-d") == '2015-06-27' || date("Y-m-d") == '2015-06-28')) {
         $this->logger->logInfo("Should generate insight", __METHOD__ . ',' . __LINE__);
         $hero_image = array('url' => 'https://www.thinkup.com/assets/images/insights/2015-06/white-house-rainbow.jpg', 'alt_text' => '1600 Pennsylvania Avenue', 'credit' => 'Photo: Jason Goldman', 'img_link' => 'https://twitter.com/Goldman44/status/614599247959322624');
         $topics = array('lovewins' => array("LoveWins", "marriage equality", "scotus", "gay marriage", "pride"));
         $matches = array();
         $matched_posts = array();
         $matched = false;
         foreach ($last_week_of_posts as $post) {
             foreach ($topics as $key => $strings) {
                 foreach ($strings as $string) {
                     if (preg_match_all('/\\b' . strtolower($string) . '\\b/i', strtolower($post->post_text), $matches)) {
                         $matched = true;
                         $this->logger->logInfo("FOUND " . $string . " in " . $post->post_text, __METHOD__ . ',' . __LINE__);
                     } else {
                         $this->logger->logInfo("Didn't find " . $string . " in " . $post->post_text, __METHOD__ . ',' . __LINE__);
                     }
                 }
             }
             if ($matched) {
                 $this->logger->logInfo("Matched post " . $post->post_text, __METHOD__ . ',' . __LINE__);
                 $matched_posts[] = $post;
             }
             $matched = false;
         }
         if (count($matched_posts) > 0) {
             if ($instance->network == 'facebook') {
                 $headline = $this->username . " had enough pride for all 50 states";
                 $insight_text = $this->username . ' joined the <a href="https://facebook.com/celebratepride">marriage equality celebration</a> ' . 'this week!';
             } else {
                 $headline = $this->username . " joined the #LoveWins celebration";
                 $insight_text = $this->username . ' was all about <a href="https://twitter.com/hashtag/LoveWins">marriage equality</a> ' . 'this week.';
             }
             $insight = new Insight();
             $insight->instance_id = $instance->id;
             $insight->slug = $this->slug;
             $insight->date = date("Y-m-d");
             $insight->headline = $headline;
             $insight->text = $insight_text;
             $insight->filename = basename(__FILE__, ".php");
             $insight->emphasis = Insight::EMPHASIS_HIGH;
             $insight->setHeroImage($hero_image);
             $matched_posts_sliced = array_slice($matched_posts, 0, 5);
             $insight->setPosts($matched_posts_sliced);
             $this->insight_dao->insertInsight($insight);
         }
     }
     $this->logger->logInfo("Done generating insight", __METHOD__ . ',' . __LINE__);
 }
开发者ID:ngugijames,项目名称:ThinkUp,代码行数:53,代码来源:lovewins.php

示例8: generateInsight

 public function generateInsight(Instance $instance, User $user, $last_week_of_posts, $number_days)
 {
     parent::generateInsight($instance, $user, $last_week_of_posts, $number_days);
     $this->logger->logInfo("Begin generating insight", __METHOD__ . ',' . __LINE__);
     if (Utils::isTest() || date("Y-m-d") == $this->run_date) {
         $this->logger->logInfo("Should generate insight", __METHOD__ . ',' . __LINE__);
         $hero_image = array('url' => 'https://www.thinkup.com/assets/images/insights/2015-05/starwars.jpg', 'alt_text' => 'RockTrooper', 'credit' => 'Photo: JD Hancock', 'img_link' => 'https://www.flickr.com/photos/jdhancock/4932301604');
         $post_dao = DAOFactory::getDAO('PostDAO');
         $last_year_of_posts = $post_dao->getPostsByUserInRange($author_id = $instance->network_user_id, $network = $instance->network, $from = date('Y-m-d', strtotime('-1 year')), $until = date('Y-m-d'), $order_by = 'pub_date', $direction = 'DESC', $iterator = true, $is_public = false);
         $topics = array('force' => array("star wars", "force awakens", "bb-8", "darth vader", "bb8", "StarWars", "StarWarsDay"));
         $matches = array();
         $matched_posts = array();
         $matched = false;
         //print_r($last_year_of_posts);
         foreach ($last_year_of_posts as $post) {
             foreach ($topics as $key => $strings) {
                 foreach ($strings as $string) {
                     if (preg_match_all('/\\b' . strtolower($string) . '\\b/i', strtolower($post->post_text), $matches)) {
                         $matched = true;
                     }
                     //DEBUG
                     // else {
                     //     $this->logger->logInfo("Didn't find ".$string." in ".$post->post_text,
                     //         __METHOD__.','.__LINE__);
                     // }
                 }
             }
             if ($matched) {
                 $this->logger->logInfo("Matched post " . $post->post_text, __METHOD__ . ',' . __LINE__);
                 $matched_posts[] = $post;
             }
             $matched = false;
         }
         if (count($matched_posts) > 0) {
             $headline = "The Force is strong with " . $this->username . " on #StarWarsDay";
             $insight_text = $this->username . " was ready for Star Wars Day. May the fourth be with you... always.";
             $insight = new Insight();
             $insight->instance_id = $instance->id;
             $insight->slug = $this->slug;
             $insight->date = $this->run_date;
             $insight->headline = $headline;
             $insight->text = $insight_text;
             $insight->filename = basename(__FILE__, ".php");
             $insight->emphasis = Insight::EMPHASIS_HIGH;
             $insight->setHeroImage($hero_image);
             $matched_posts_sliced = array_slice($matched_posts, 0, 20);
             $insight->setPosts($matched_posts_sliced);
             $this->insight_dao->insertInsight($insight);
         }
     }
     $this->logger->logInfo("Done generating insight", __METHOD__ . ',' . __LINE__);
 }
开发者ID:ngugijames,项目名称:ThinkUp,代码行数:52,代码来源:maythefourth.php

示例9: generateInsight

 public function generateInsight(Instance $instance, User $user, $last_week_of_posts, $number_days)
 {
     if (Utils::isTest() || date("Y-m-d") == '2014-02-23') {
         parent::generateInsight($instance, $user, $last_week_of_posts, $number_days);
         $this->logger->logInfo("Begin generating insight", __METHOD__ . ',' . __LINE__);
         $hero_image = array('url' => 'https://www.thinkup.com/assets/images/insights/2014-02/olympics2014.jpg', 'alt_text' => 'The Olympic rings in Sochi', 'credit' => 'Photo: Atos International', 'img_link' => 'http://www.flickr.com/photos/atosorigin/12568057033/');
         $post_dao = DAOFactory::getDAO('PostDAO');
         $last_month_of_posts = $post_dao->getAllPostsByUsernameOrderedBy($instance->network_username, $network = $instance->network, $count = 0, $order_by = "pub_date", $in_last_x_days = 30, $iterator = false, $is_public = false);
         if (self::shouldGenerateWeeklyInsight('olympics_2014', $instance, $insight_date = 'today', $regenerate_existing_insight = true, $day_of_week = 0, count($last_month_of_posts))) {
             $event_count = 0;
             foreach ($last_month_of_posts as $post) {
                 $event_count += self::countOlympicReferences($post->post_text);
             }
             $this->logger->logInfo("There are {$event_count} Olympic-related mentions", __METHOD__ . ',' . __LINE__);
             if ($event_count > 0) {
                 $headline = "Do they give out medals for " . $this->terms->getNoun('post', InsightTerms::PLURAL) . "?";
                 $insight_text = "{$this->username} mentioned ";
                 if ($event_count > 0) {
                     $this->logger->logInfo("There are event mentions", __METHOD__ . ',' . __LINE__);
                     $insight_text .= "the Olympics ";
                     if ($event_count > 1) {
                         $this->logger->logInfo("there is more than one event mention", __METHOD__ . ',' . __LINE__);
                         $insight_text .= "{$event_count} times since they started.";
                         $insight_text .= " That's kind of like winning {$event_count} gold medals in " . ucfirst($instance->network) . ", right?";
                     } else {
                         $insight_text .= "just as the whole world's attention was focused on the Games.";
                         $insight_text .= " That's a pretty great way to join a global conversation.";
                     }
                 }
                 $my_insight = new Insight();
                 $my_insight->slug = 'olympics_2014';
                 //slug to label this insight's content
                 $my_insight->instance_id = $instance->id;
                 $my_insight->date = $this->insight_date;
                 //date is often this or $simplified_post_date
                 $my_insight->headline = $headline;
                 // or just set a string like 'Ohai';
                 $my_insight->text = $insight_text;
                 // or just set a strong like "Greetings humans";
                 $my_insight->filename = basename(__FILE__, ".php");
                 //Same for every insight, must be set this way
                 $my_insight->emphasis = Insight::EMPHASIS_HIGH;
                 //Optional emphasis, default is Insight::EMPHASIS_LOW
                 $my_insight->setHeroImage($hero_image);
                 $this->insight_dao->insertInsight($my_insight);
             }
         }
         $this->logger->logInfo("Done generating insight", __METHOD__ . ',' . __LINE__);
     }
 }
开发者ID:ngugijames,项目名称:ThinkUp,代码行数:50,代码来源:olympics2014.php

示例10: generateInsight

 public function generateInsight(Instance $instance, User $user, $last_week_of_posts, $number_days)
 {
     if (Utils::isTest() || date("Y-m-d") == $this->run_date) {
         parent::generateInsight($instance, $user, $last_week_of_posts, $number_days);
         $this->logger->logInfo("Begin generating insight", __METHOD__ . ',' . __LINE__);
         $hero_image = array('url' => 'https://www.thinkup.com/assets/images/insights/2015-02/llama.jpg', 'alt_text' => 'Llama', 'credit' => 'Photo: Eric Kilby', 'img_link' => 'https://www.flickr.com/photos/ekilby/8564867495/');
         $should_generate_insight = self::shouldGenerateWeeklyInsight($this->slug, $instance, $insight_date = $this->run_date, $regenerate_existing_insight = false, $day_of_week = 5, count($last_week_of_posts));
         if ($should_generate_insight) {
             $this->logger->logInfo("Should generate", __METHOD__ . ',' . __LINE__);
             $post_dao = DAOFactory::getDAO('PostDAO');
             $topics = array('llama' => array("llama", "llamas"));
             $matches = array();
             foreach ($last_week_of_posts as $post) {
                 foreach ($topics as $key => $strings) {
                     foreach ($strings as $string) {
                         if (preg_match_all('/\\b' . $string . '\\b/i', $post->post_text) > 0) {
                             $matches[$key] = array('term' => $string, 'post' => $post);
                             unset($topics[$key]);
                             break;
                         }
                     }
                 }
             }
             if (count($matches) == 0) {
                 $headline = $this->username . ' managed to avoid llamageddon!';
                 $insight_text = "It seems like half the internet was " . "<a href='http://www.theverge.com/2015/2/26/8116693/live-the-internet-is-going-bananas-" . "for-this-llama-chase'>talking about runaway llamas</a> " . 'yesterday. Kudos to ' . $this->username . ' for showing a llama restraint.';
             } else {
                 $headline = $this->username . " showed a whole llama love";
                 $insight_text = "Two runaway llamas <a href='http://www.theverge.com/2015/2/26/8116693/live-" . "the-internet-is-going-bananas-for-this-llama-chase'>took over Twitter yesterday</a>" . ", and like a llama people, " . $this->username . " couldn't resist.";
             }
             $insight = new Insight();
             $insight->instance_id = $instance->id;
             $insight->slug = $this->slug;
             $insight->date = $this->run_date;
             $insight->headline = $headline;
             $insight->text = $insight_text;
             $insight->filename = basename(__FILE__, ".php");
             $insight->emphasis = Insight::EMPHASIS_HIGH;
             $insight->setHeroImage($hero_image);
             $this->insight_dao->insertInsight($insight);
         }
         $this->logger->logInfo("Done generating insight", __METHOD__ . ',' . __LINE__);
     }
 }
开发者ID:pepeleproso,项目名称:ThinkUp,代码行数:44,代码来源:llamas.php

示例11: shouldGenerateInsight

 /**
  * Determine whether an insight should be generated or not.
  * @param str $slug slug of the insight to be generated
  * @param Instance $instance user and network details for which the insight has to be generated
  * @param date $insight_date date for which the insight has to be generated
  * @param bool $regenerate_existing_insight whether the insight should be regenerated over a day
  * @param int $day_of_week the day of week (0 for Sunday through 6 for Saturday) on which the insight should run
  * @param int $count_last_week_of_posts if set, wouldn't run insight if there are no posts from last week
  * @param arr $excluded_networks array of networks for which the insight shouldn't be run
  * @return bool $run whether the insight should be generated or not
  */
 public function shouldGenerateInsight($slug, Instance $instance, $insight_date = null, $regenerate_existing_insight = false, $day_of_week = null, $count_last_week_of_posts = null, $excluded_networks = null)
 {
     $run = true;
     // Check the number of posts from last week
     if (isset($count_last_week_of_posts)) {
         $run = $run && $count_last_week_of_posts;
     }
     // Check whether testing
     if (Utils::isTest()) {
         return $run && Utils::isTest();
     }
     // Check the day of the week (0 for Sunday through 6 for Saturday) on which the insight should run
     if (isset($day_of_week)) {
         if (date('w') == $day_of_week) {
             $run = $run && true;
         } else {
             $run = $run && false;
         }
     }
     // Check boolean whether insight should be regenerated over a day
     if (!$regenerate_existing_insight) {
         $insight_date = isset($insight_date) ? $insight_date : 'today';
         $existing_insight = $this->insight_dao->getInsight($slug, $instance->id, date('Y-m-d', strtotime($insight_date)));
         if (isset($existing_insight)) {
             $run = $run && false;
         } else {
             $run = $run && true;
         }
     }
     // Check array of networks for which the insight should run
     if (isset($excluded_networks)) {
         if (in_array($instance->network, $excluded_networks)) {
             $run = $run && false;
         } else {
             $run = $run && true;
         }
     }
     return $run;
 }
开发者ID:dgw,项目名称:ThinkUp,代码行数:50,代码来源:class.InsightPluginParent.php

示例12: mailViaMandrill

 /**
  * Send email from ThinkUp installation via Mandrill's API.
  * If you're running tests, just write the message headers and contents to the file system in the data directory.
  * @param str $to A valid email address
  * @param str $subject
  * @param str $message
  */
 public static function mailViaMandrill($to, $subject, $message)
 {
     $config = Config::getInstance();
     $app_title = $config->getValue('app_title_prefix') . "ThinkUp";
     $host = self::getHost();
     $mandrill_api_key = $config->getValue('mandrill_api_key');
     try {
         require_once THINKUP_WEBAPP_PATH . '_lib/extlib/mandrill/Mandrill.php';
         $mandrill = new Mandrill($mandrill_api_key);
         $message = array('text' => $message, 'subject' => $subject, 'from_email' => "notifications@{$host}", 'from_name' => $app_title, 'to' => array(array('email' => $to, 'name' => $to)));
         //don't send email when running tests, just write it to the filesystem for assertions
         if (Utils::isTest()) {
             self::setLastMail(json_encode($message));
         } else {
             $result = $mandrill->messages->send($message, $async, $ip_pool);
             //DEBUG
             //print_r($result);
         }
     } catch (Mandrill_Error $e) {
         throw new Exception('An error occurred while sending email via Mandrill. ' . get_class($e) . ': ' . $e->getMessage());
     }
 }
开发者ID:jkuehl-carecloud,项目名称:ThinkUp,代码行数:29,代码来源:class.Mailer.php

示例13: mailViaMandrill

 /**
  * Send email from ThinkUp installation via Mandrill's API.
  * If you're running tests, just write the message headers and contents to the file system in the data directory.
  * @param str $to A valid email address
  * @param str $subject
  * @param str $message
  */
 public static function mailViaMandrill($to, $subject, $message)
 {
     $config = Config::getInstance();
     $app_title = $config->getValue('app_title_prefix') . "Empoddy Labs";
     $host = Utils::getApplicationHostName();
     $mandrill_api_key = $config->getValue('mandrill_api_key');
     if (Utils::isEmpoddyLabs()) {
         $from_email = 'empoddy@gmail.com';
     } else {
         $from_email = "notifications@{$host}";
     }
     try {
         require_once EFC_WEBAPP_PATH . '_lib/extlib/mandrill/Mandrill.php';
         $mandrill = new Mandrill($mandrill_api_key);
         $tos = array();
         foreach ($to as $key => $value) {
             $tos[] = array('email' => $value, 'name' => $value);
         }
         //$message = array( 'text' => $message, 'subject' => $subject, 'from_email' => $from_email,
         //'from_name' => $app_title, 'to' => array( array( 'email' => $to, 'name' => $to ) ) );
         $message = array('text' => $message, 'subject' => $subject, 'from_email' => $from_email, 'from_name' => $app_title, 'to' => $tos);
         //don't send email when running tests, just write it to the filesystem for assertions
         if (Utils::isTest()) {
             self::setLastMail(json_encode($message));
         } else {
             $async = true;
             $ip_pool = "Main pool";
             $result = $mandrill->messages->send($message, $async, $ip_pool);
             //DEBUG
             //print_r($result);
         }
     } catch (Mandrill_Error $e) {
         throw new Exception('An error occurred while sending email via Mandrill. ' . get_class($e) . ': ' . $e->getMessage());
     }
 }
开发者ID:prabhatse,项目名称:olx_hack,代码行数:42,代码来源:class.Mailer.php

示例14: isThinkUpInstalled

 /**
  * Check if ThinkUp is already installed, that is, that:
  *  all system requirements are met;
  *  the ThinkUp config.inc.php file exists;
  *  all ThinkUp tables exist
  *  all tables report a status ok "Okay"
  *
  * @param array $config
  * @return bool true when ThinkUp is already installed
  */
 public function isThinkUpInstalled($config)
 {
     // check if file config present
     $config_file_exists = false;
     $config_file = THINKUP_WEBAPP_PATH . 'config.inc.php';
     // check if we have made config.inc.php
     if (file_exists($config_file)) {
         $config_file_exists = true;
     } else {
         self::$error_messages['config_file'] = "Config file doesn't exist.";
         return false;
     }
     // check version is met
     $version_met = self::checkStep1();
     // when testing
     if (Utils::isTest() && !empty($pass)) {
         $version_met = $pass;
     }
     if (!$version_met) {
         self::$error_messages['requirements'] = "Requirements are not met. " . "Make sure your PHP version >= " . self::$required_version['php'] . ", " . "you have cURL and GD extension installed, and template and log directories are writable";
         return false;
     }
     // database is okay
     $db_check = self::checkDb($config);
     // table present
     $table_present = true;
     if (!self::doThinkUpTablesExist($config)) {
         self::$error_messages['table'] = 'ThinkUp\'s database tables are not fully installed.';
         $table_present = false;
     }
     return $version_met && $db_check === true && $table_present;
 }
开发者ID:pepeleproso,项目名称:ThinkUp,代码行数:42,代码来源:class.Installer.php

示例15: control

 public function control()
 {
     $config = Config::getInstance();
     $this->setViewTemplate($this->tpl_name);
     $this->addToView('enable_bootstrap', true);
     $this->addToView('developer_log', $config->getValue('is_log_verbose'));
     $this->addToView('thinkup_application_url', Utils::getApplicationURL());
     if ($this->shouldRefreshCache()) {
         if (isset($_GET['u']) && isset($_GET['n']) && isset($_GET['d']) && isset($_GET['s'])) {
             $this->displayIndividualInsight();
             if (isset($_GET['share'])) {
                 $this->addToView('share_mode', true);
             }
         } else {
             if (!$this->displayPageOfInsights()) {
                 $controller = new LoginController(true);
                 return $controller->go();
             }
         }
         if ($this->isLoggedIn()) {
             //Populate search dropdown with service users and add thinkup_api_key for desktop notifications.
             $owner_dao = DAOFactory::getDAO('OwnerDAO');
             $owner = $owner_dao->getByEmail($this->getLoggedInUser());
             $this->addToView('thinkup_api_key', $owner->api_key);
             $this->addHeaderJavaScript('assets/js/notify-insights.js');
             $instance_dao = DAOFactory::getDAO('InstanceDAO');
             $instances = $instance_dao->getByOwnerWithStatus($owner);
             $this->addToView('instances', $instances);
             $saved_searches = array();
             if (sizeof($instances) > 0) {
                 $instancehashtag_dao = DAOFactory::getDAO('InstanceHashtagDAO');
                 $saved_searches = $instancehashtag_dao->getHashtagsByInstances($instances);
             }
             $this->addToView('saved_searches', $saved_searches);
             //Start off assuming connection doesn't exist
             $connection_status = array('facebook' => 'inactive', 'twitter' => 'inactive', 'instagram' => 'inactive');
             foreach ($instances as $instance) {
                 if ($instance->auth_error != '') {
                     $connection_status[$instance->network] = 'error';
                 } else {
                     //connection exists, so it's active
                     $connection_status[$instance->network] = 'active';
                 }
             }
             $this->addToView('facebook_connection_status', $connection_status['facebook']);
             $this->addToView('twitter_connection_status', $connection_status['twitter']);
             $this->addToView('instagram_connection_status', $connection_status['instagram']);
         }
     }
     if (Utils::isTest() || date("Y-m-d") == '2015-11-26') {
         $this->addInfoMessage("Happy Thanksgiving! We're thankful you're using ThinkUp.");
     }
     $this->addToView('tpl_path', THINKUP_WEBAPP_PATH . 'plugins/insightsgenerator/view/');
     if ($config->getValue('image_proxy_enabled') == true) {
         $this->addToView('image_proxy_sig', $config->getValue('image_proxy_sig'));
     }
     return $this->generateView();
 }
开发者ID:ChowSinWon,项目名称:ThinkUp,代码行数:58,代码来源:class.InsightStreamController.php


注:本文中的Utils::isTest方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。