public static function setDefaultDB($db) { return Handy::setDB($db); }
/** * An action for promoting new content * * @access public * @param string $id * @param string $redirect_url * */ public function promote($id, $redirect_url = 'users/social_media') { if (!$this->Session->check('Auth.User.sm_list')) { $sm_list = $this->Oauth->find('list', array('conditions' => array('Oauth.person_id' => $this->Session->read('Auth.User.id')), 'fields' => array('Oauth.oauth_id', 'Oauth.service'))); $this->Session->write('Auth.User.sm_list', $sm_list); } foreach ($this->Session->read('Auth.User.sm_list') as $key => $val) { switch ($val) { case 'facebook': $this->Oauths->check_session_for_token('facebook', $redirect_url); break; case 'linked_in': $this->Oauths->check_session_for_token('linked_in', $redirect_url); break; case 'twitter': $this->Oauths->check_session_for_token('twitter', $redirect_url); break; } } $content = $this->Content->findById($id); $this->set('content', $content); $objectType = strtolower($content['Content']['object_type']); $shorty = " " . Configure::read("Shorty.{$objectType}") . $content['Content']['short_cut']; $twitter = Handy::truncate($content['Content']['body'], 140 - strlen($shorty)) . $shorty; $other = $content['Content']['body'] . " " . Configure::read('Domain.url') . $content['Content']['url']; $promo = array('twitter' => $twitter, 'other' => $other); $this->set('promo', $promo); $this->set('title_for_layout', "Promote {$content['Content']['name']}"); }