Campustream 1.0
A social network MQP for WPI
|
00001 <? 00002 00006 class Usertwitter_Model extends ActiveRecord { 00007 public $table_name = 'usertwitter'; 00008 public $columns = array('id', 'user_id', 'twitter_id', 'username', 'oauth_token', 'oauth_secret', 'name', 'website', 'bio', 'location', 'avatar_url', 'utc_offset', 'geo_enabled', 'profile_background_color', 'profile_text_color', 'profile_link_color', 'profile_sidebar_fill_color', 'profile_sidebar_border_color', 'profile_background_image_url', 'profile_background_tile', 'import_enabled', 'export_enabled', 'last_tweet_id'); 00009 public $cache_keys = array( 'usertwitter/#' => 'id', 'usertwitter/user:#' => 'user_id' ); 00010 public $has_one = array('user'); 00011 public $has_many = array(); 00012 public $public_columns = array(); 00013 00017 public function load_user() { 00018 if (!$this->user) { 00019 $user = ActiveCache::find('User_Model', $this->user_id, 43200)->sql( 00020 "SELECT * FROM users WHERE id = {$this->user_id} LIMIT 1" 00021 ); 00022 00023 if ($user->is_loaded()) { 00024 $this->add_relationship('user', $user); 00025 } 00026 } 00027 } 00028 00029 public function save() { 00030 ActiveCache::invalidate_keys_for($this); 00031 00032 return parent::save(); 00033 } 00034 00035 public function __get($key) { 00036 switch ($key) { 00037 case 'website_formatted' : 00038 if(mb_strlen($this->website) > 0) { 00039 $website = '<a class="nav-link" rel="nofollow" target="_blank" href="'.str_replace(array('"', "'"), "", $this->website).'">'; 00040 if(mb_strlen($this->website) > 30) { 00041 $website .= mb_substr($this->website, 0, 30)."..."; 00042 } else { 00043 $website .= $this->website; 00044 } 00045 $website .= "</a>"; 00046 return $website; 00047 } else { 00048 return ''; 00049 } 00050 } 00051 00052 return parent::__get($key); 00053 } 00054 }