18 require_once SQ_CORE_PACKAGE_PATH.
'/page/page.inc';
19 require_once SQ_LIB_PATH.
'/html_form/html_form.inc';
36 var $bodycopies = Array(
37 'logged_in' =>
'Logged In Layout',
38 'not_logged_in' =>
'Not Logged In Layout',
41 var $keywords = Array(
43 'error_messages_list',
44 'success_messages_list',
51 'not_logged_in' => Array(
69 $this->_ser_attrs = TRUE;
70 parent::__construct($assetid);
87 if (!parent::_createAdditional($link))
return FALSE;
90 $GLOBALS[
'SQ_SYSTEM']->am->includeAsset(
'bodycopy');
92 foreach ($this->bodycopies as $value => $name) {
95 'link_type' => SQ_LINK_TYPE_2,
102 $bodycopy->setAttrValue(
'name', $name);
104 if (!$bodycopy->create($copy_link, $args)) {
125 return '<h2>'.translate(
'cms_user_group_manager_title',
'%user_name%').
'</h2>'.
"\n".
126 '%error_messages_list%%success_messages_list%'.
"\n".
127 '<p>%location_picker%%commit_button%</p>';
128 case 'not_logged_in':
129 return translate(
'cms_user_group_manager_must_be_logged_in');
148 if (isset($_REQUEST[
'submitted'])) {
149 $GLOBALS[
'SQ_SYSTEM']->changeDatabaseConnection(
'db2');
155 <form
id=
"<?php echo $this->getPrefix(); ?>" action=
"<?php echo current_url(); ?>" method=
"post">
156 <input
type=
"hidden" name=
"submitted" value=
"1" />
162 if (isset($_REQUEST[
'submitted'])) {
163 $GLOBALS[
'SQ_SYSTEM']->restoreDatabaseConnection();
177 $user_groups = Array();
178 $link_type = $this->
attr(
'link_type');
180 $current_links = $GLOBALS[
'SQ_SYSTEM']->am->getLinks($GLOBALS[
'SQ_SYSTEM']->currentUserId(), $link_type,
'', FALSE,
'minor');
182 $valid_nodes = array_keys($GLOBALS[
'SQ_SYSTEM']->am->getChildren($this->attr(
'root_node'),
'user_group', FALSE, NULL, NULL, SQ_PERMISSION_WRITE));
184 $current_groups = Array();
185 foreach ($current_links as $id => $link) {
186 if (in_array($link[
'majorid'], $valid_nodes)) {
187 $current_groups[] = $link[
'majorid'];
191 if (isset($_REQUEST[
'submitted'])) {
192 if (isset($_REQUEST[$this->
getPrefix().
'_location_selection'])) {
193 $user_groups = $_REQUEST[$this->
getPrefix().
'_location_selection'];
195 if ($this->
attr(
'allow_multiple') == FALSE) {
197 $user_groups = !empty($user_groups) ? Array($user_groups) : Array();
200 $this->_tmp[
'selected'] = $user_groups;
201 $GLOBALS[
'SQ_SYSTEM']->setRunLevel(SQ_RUN_LEVEL_FORCED);
202 $done = $this->
processMinorLinks($GLOBALS[
'SQ_SYSTEM']->currentUserId(), $current_groups, $user_groups, $link_type);
203 $GLOBALS[
'SQ_SYSTEM']->restoreRunLevel();
226 function processMinorLinks($minor_id, $old_links=Array(), $new_links=Array(), $link_type, $link_value=NULL)
228 $cannot_create = Array();
229 $cannot_delete = Array();
230 $to_delete = array_diff($old_links, $new_links);
231 $to_create = array_diff($new_links, $old_links);
232 $minor = $GLOBALS[
'SQ_SYSTEM']->am->getAsset($minor_id);
237 foreach ($to_create as $majorid) {
238 $major = $GLOBALS[
'SQ_SYSTEM']->am->getAsset($majorid);
239 if (!$GLOBALS[
'SQ_SYSTEM']->am->createAssetLink($major, $minor, $link_type)) {
240 $done[
'add_fail'][] = $major->id;
242 $done[
'add_success'][] = $major->id;
245 $GLOBALS[
'SQ_SYSTEM']->am->forgetAsset($major);
249 foreach ($to_delete as $majorid) {
250 $curr_link = $GLOBALS[
'SQ_SYSTEM']->am->getLinkByAsset($majorid, $minor_id, $link_type, $link_value);
251 if (!empty($curr_link)) {
252 $link_id = $curr_link[
'linkid'];
254 if (!$GLOBALS[
'SQ_SYSTEM']->am->deleteAssetLink($link_id)) {
255 $done[
'delete_fail'][] = $majorid;
257 $done[
'delete_success'][] = $majorid;
263 $GLOBALS[
'SQ_SYSTEM']->am->forgetAsset($minor);
281 foreach ($fail_success as $message_type => $assetids) {
282 switch ($message_type) {
284 $this->errors[] =
'Unable to add this user to the following groups: '.$this->_getCommaSeparatedNamesByAssetid($assetids);
287 $this->messages[] =
'Successfully added this user to the following groups: '.$this->_getCommaSeparatedNamesByAssetid($assetids);
290 $this->errors[] =
'Unable to remove this user from the following groups: '.$this->_getCommaSeparatedNamesByAssetid($assetids);
292 case 'delete_success':
293 $this->messages[] =
'Successfully removed this user from the following groups: '.$this->_getCommaSeparatedNamesByAssetid($assetids);
312 $type_codes = Array(
'user_group' =>
'1');
313 $full_types = Array();
314 foreach ($type_codes as $type => $inherit) {
315 $full_types[] = $type;
316 if ($inherit ==
'1') {
317 $full_types += $GLOBALS[
'SQ_SYSTEM']->am->getTypeDescendants($type);
322 $root_node = $this->
attr(
'root_node');
323 $default = array_get_index($this->_tmp,
'selected', Array());
326 $current_user = $GLOBALS[
'SQ_SYSTEM']->user;
328 $_permission = SQ_PERMISSION_READ;
330 $_permission = SQ_PERMISSION_WRITE;
332 structured_drop_down($prefix.$suffix, $root_node, $full_types, $default, $this->attr(
'structured_width'), $this->
attr(
'structured_height'), $this->
attr(
'max_depth'), $this->
attr(
'allow_multiple'), $this->
attr(
'seperator'), $this->
attr(
'include_root_node'),
'', $this->
attr(
'structured_style'), $this->
attr(
'statuses'), TRUE, Array(), FALSE, $_permission);
333 $selector = ob_get_contents();
349 return Array(SQ_LINK_TYPE_2 => Array(
'bodycopy' => Array(
'card' =>
'M',
'exclusive' => FALSE)));
369 if (is_null($bodycopy))
return '';
371 $bodycopy->setKeywordReplacements($replacements);
374 $bodycopy->printBody();
375 $html = ob_get_contents();
395 if (array_key_exists($name, $this->bodycopies)) {
396 $am = $GLOBALS[
'SQ_SYSTEM']->am;
397 $link = $am->getLink($this->
id, SQ_LINK_TYPE_2,
'bodycopy', TRUE, $name,
'major',
'1');
398 $bodycopy = $am->getAsset($link[
'minorid'], $link[
'minor_type_code']);
419 $vars[
'keywords'] = isset($vars[
'keywords']) ? $vars[
'keywords'] : Array();
422 $parents = $GLOBALS[
'SQ_SYSTEM']->am->getParents($broadcaster->id,
'bodycopy', TRUE);
423 $bodycopy_links = $GLOBALS[
'SQ_SYSTEM']->am->getLinks($this->
id, SQ_LINK_TYPE_2,
'bodycopy');
424 $chosen_bodycopy =
'';
425 foreach ($bodycopy_links as $id => $link) {
426 if (in_array($link[
'minorid'], array_keys($parents))) {
427 $chosen_bodycopy = $link[
'value'];
432 if (!empty($chosen_bodycopy)) {
433 foreach ($this->keywords[$chosen_bodycopy] as $key_word) {
434 $keys[$key_word] = ucwords(str_replace(
'_',
' ', $key_word));
437 $vars[
'keywords'] = array_merge($vars[
'keywords'], $keys);
451 $public_user = $GLOBALS[
'SQ_SYSTEM']->getPublicUser();
452 if ($GLOBALS[
'SQ_SYSTEM']->currentUser($public_user)) {
458 $keywords = $bodycopy->getKeywords();
459 $replacements = Array();
460 foreach ($keywords as $name) {
463 $bodycopy->setKeywordReplacements($replacements);
466 $bodycopy->printBody();
467 $html = ob_get_contents();
488 foreach ($assetids as $assetid) {
489 $asset = $GLOBALS[
'SQ_SYSTEM']->am->getAsset($assetid);
490 $names[] = $asset->name;
491 $GLOBALS[
'SQ_SYSTEM']->am->forgetAsset($asset);
493 $string .= implode(
', ', $names);
521 $user = $GLOBALS[
'SQ_SYSTEM']->am->getAssetInfo(Array($GLOBALS[
'SQ_SYSTEM']->currentUserId()));
522 return $user[$GLOBALS[
'SQ_SYSTEM']->currentUserId()][
'name'];
535 $user = $GLOBALS[
'SQ_SYSTEM']->am->getAssetInfo(Array($GLOBALS[
'SQ_SYSTEM']->currentUserId()));
536 return $user[$GLOBALS[
'SQ_SYSTEM']->currentUserId()][
'short_name'];
549 $current_user = $GLOBALS[
'SQ_SYSTEM']->user;
550 $current_user_email = $current_user->attr(
'email');
551 return $current_user_email;
565 return $GLOBALS[
'SQ_SYSTEM']->currentUserId();
580 submit_button($this->
getPrefix().
'_submit_button', $this->
attr(
'submit-button'));
581 $button = ob_get_contents();
626 if (!empty($messages)) {
628 foreach ($messages as $message) {
629 $string .=
'<li class="'.$this->getPrefix().
'_'.$suffix.
'">'.$message.
'</li>';
648 <input
type=
"hidden" name=
"SQ_LOGIN_KEY" value=
"<?php echo $GLOBALS['SQ_SYSTEM']->generateLoginKey(); ?>" />
649 <input type=
"hidden" name=
"SQ_LOGIN_REFERER" value=
"" />
653 <td valign=
"top"><?php echo translate(
'username'); ?></td>
654 <td valign=
"top"><?php echo text_box(
'SQ_LOGIN_USERNAME', (isset($_POST[
'SQ_LOGIN_USERNAME'])) ? $_POST[
'SQ_LOGIN_USERNAME'] :
'Enter your username here', 25, 0, (isset($_POST[
'SQ_LOGIN_USERNAME'])) ? FALSE : TRUE,
'title="Username"'); ?></td>
657 <td valign=
"top"><?php echo translate(
'password'); ?></td>
658 <td valign=
"top"><?php echo password_box(
'SQ_LOGIN_PASSWORD',
'', 25, 0,
'title="Password"'); ?></td>
661 <td valign=
"top"> </td>
663 <input type=
"hidden" name=
"SQ_ACTION" value=
"" id=
"SQ_ACTION" />
664 <?php echo submit_button(
'SQ_LOGIN_SUBMIT',
'Login',
'document.getElementById(\'SQ_ACTION\').value = \'login\'; document.getElementById(\''.$this->
id.
'ASSET_BUILDER_ACTION\').value = \'login\';'); ?>
670 $login_form = ob_get_contents();