Squiz Matrix  4.12.2
 All Data Structures Namespaces Functions Variables Pages
site_prefs.inc
1 <?php
18 require_once SQ_LIB_PATH.'/config/prefs.inc';
19 
31 class Site_Prefs extends Prefs
32 {
33 
34  var $pref_vars = Array (
35  'SQ_CHILD_CREATE_LINK_TYPE_2_RESTRICT' => Array(
36  'name' => 'child_creation_type_2_restriction',
37  'description' => 'Link type options prior to asset creation will be restricted to a TYPE 2 link for any asset to be located anywhere under the specified Site Asset IDs. Link type can still be changed after creation e.g. via Linking Screen',
38  'default' => Array(),
39  'protected' => FALSE,
40  ),
41  );
42 
43 
48  function __construct($pref_file='')
49  {
50  parent::__construct($pref_file);
51 
52  }//end constructor
53 
54 
65  function paintBackend(&$o, $have_lock, $pref=NULL)
66  {
67  $is_root = $GLOBALS['SQ_SYSTEM']->userRoot();
68  $is_admin = ($is_root || $GLOBALS['SQ_SYSTEM']->userSystemAdmin());
69 
70  if (is_null($pref) || $pref == 'SQ_CHILD_CREATE_LINK_TYPE_2_RESTRICT') {
71  if (is_null($pref)) {
72  $o->openField(translate($this->pref_vars['SQ_CHILD_CREATE_LINK_TYPE_2_RESTRICT']['name']));
73  }
74 
75  if ($have_lock && $is_admin) {
76  multiple_asset_finder('prefs[SQ_CHILD_CREATE_LINK_TYPE_2_RESTRICT]', $this->pref_vars['SQ_CHILD_CREATE_LINK_TYPE_2_RESTRICT']['default'], Array ('site' => 'I'));
77  } else {
78  echo '<ul>';
79  foreach ($this->pref_vars['SQ_CHILD_CREATE_LINK_TYPE_2_RESTRICT']['default'] as $index => $assetid) {
80  echo '<li>'.get_asset_tag_line($assetid).'</li>';
81  }
82  echo '</ul>';
83  }
84  echo '<div class="sq-backend-note">'.$this->pref_vars['SQ_CHILD_CREATE_LINK_TYPE_2_RESTRICT']['description'].'</div>';
85  if (is_null($pref)) $o->closeField();
86  }//end if
87 
88  return TRUE;
89 
90  }//end paintBackend()
91 
92 
103  function processBackend($o, $have_lock, $pref=NULL)
104  {
105  $is_root = $GLOBALS['SQ_SYSTEM']->userRoot();
106  $is_admin = ($is_root || $GLOBALS['SQ_SYSTEM']->userSystemAdmin());
107  if (!$is_admin || !$have_lock) return FALSE;
108 
109  if (is_null($pref) || $pref == 'SQ_CHILD_CREATE_LINK_TYPE_2_RESTRICT') {
110  if (isset($_POST['prefs']['SQ_CHILD_CREATE_LINK_TYPE_2_RESTRICT'])) {
111  $site_assets = $_POST['prefs']['SQ_CHILD_CREATE_LINK_TYPE_2_RESTRICT'];
112  $save_assets = Array();
113  foreach ($site_assets as $index => $asset_info) {
114  if (!empty($asset_info['assetid'])) {
115  $type_info = $GLOBALS['SQ_SYSTEM']->am->getAssetInfo($asset_info['assetid'], 'site');
116  if (!empty($type_info)) $save_assets[] = $asset_info['assetid'];
117  }//end if
118  }//end foreach
119  $this->pref_vars['SQ_CHILD_CREATE_LINK_TYPE_2_RESTRICT']['default'] = $save_assets;
120  }
121  }
122 
123  return TRUE;
124 
125  }//end processBackend()
126 
127 
128 }//end class
129 
130 ?>