[ Index ] |
PHP Cross Reference of Phabricator |
[Summary view] [Print] [Text view]
1 <?php 2 3 final class PhabricatorUserPreferences extends PhabricatorUserDAO { 4 5 const PREFERENCE_MONOSPACED = 'monospaced'; 6 const PREFERENCE_DARK_CONSOLE = 'dark_console'; 7 const PREFERENCE_EDITOR = 'editor'; 8 const PREFERENCE_MULTIEDIT = 'multiedit'; 9 const PREFERENCE_TITLES = 'titles'; 10 const PREFERENCE_MONOSPACED_TEXTAREAS = 'monospaced-textareas'; 11 const PREFERENCE_TIME_FORMAT = 'time-format'; 12 13 const PREFERENCE_RE_PREFIX = 're-prefix'; 14 const PREFERENCE_NO_SELF_MAIL = 'self-mail'; 15 const PREFERENCE_NO_MAIL = 'no-mail'; 16 const PREFERENCE_MAILTAGS = 'mailtags'; 17 const PREFERENCE_VARY_SUBJECT = 'vary-subject'; 18 const PREFERENCE_HTML_EMAILS = 'html-emails'; 19 20 const PREFERENCE_SEARCHBAR_JUMP = 'searchbar-jump'; 21 const PREFERENCE_SEARCH_SHORTCUT = 'search-shortcut'; 22 23 const PREFERENCE_DIFFUSION_BLAME = 'diffusion-blame'; 24 const PREFERENCE_DIFFUSION_COLOR = 'diffusion-color'; 25 26 const PREFERENCE_NAV_COLLAPSED = 'nav-collapsed'; 27 const PREFERENCE_NAV_WIDTH = 'nav-width'; 28 const PREFERENCE_APP_TILES = 'app-tiles'; 29 const PREFERENCE_APP_PINNED = 'app-pinned'; 30 31 const PREFERENCE_DIFF_FILETREE = 'diff-filetree'; 32 33 const PREFERENCE_CONPH_NOTIFICATIONS = 'conph-notifications'; 34 35 // These are in an unusual order for historic reasons. 36 const MAILTAG_PREFERENCE_NOTIFY = 0; 37 const MAILTAG_PREFERENCE_EMAIL = 1; 38 const MAILTAG_PREFERENCE_IGNORE = 2; 39 40 protected $userPHID; 41 protected $preferences = array(); 42 43 public function getConfiguration() { 44 return array( 45 self::CONFIG_SERIALIZATION => array( 46 'preferences' => self::SERIALIZATION_JSON, 47 ), 48 self::CONFIG_TIMESTAMPS => false, 49 self::CONFIG_KEY_SCHEMA => array( 50 'userPHID' => array( 51 'columns' => array('userPHID'), 52 'unique' => true, 53 ), 54 ), 55 ) + parent::getConfiguration(); 56 } 57 58 public function getPreference($key, $default = null) { 59 return idx($this->preferences, $key, $default); 60 } 61 62 public function setPreference($key, $value) { 63 $this->preferences[$key] = $value; 64 return $this; 65 } 66 67 public function unsetPreference($key) { 68 unset($this->preferences[$key]); 69 return $this; 70 } 71 72 public function getPinnedApplications(array $apps, PhabricatorUser $viewer) { 73 $pref_pinned = PhabricatorUserPreferences::PREFERENCE_APP_PINNED; 74 $pinned = $this->getPreference($pref_pinned); 75 76 if ($pinned) { 77 return $pinned; 78 } 79 80 $pref_tiles = PhabricatorUserPreferences::PREFERENCE_APP_TILES; 81 $tiles = $this->getPreference($pref_tiles, array()); 82 $full_tile = 'full'; 83 84 $large = array(); 85 foreach ($apps as $app) { 86 $show = $app->isPinnedByDefault($viewer); 87 88 // TODO: This is legacy stuff, clean it up eventually. This approximately 89 // retains the old "tiles" preference. 90 if (isset($tiles[get_class($app)])) { 91 $show = ($tiles[get_class($app)] == $full_tile); 92 } 93 94 if ($show) { 95 $large[] = get_class($app); 96 } 97 } 98 99 return $large; 100 } 101 102 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Sun Nov 30 09:20:46 2014 | Cross-referenced by PHPXref 0.7.1 |