// todo - delete... ensure that all contacts using the to-be-deleted profile are moved to the default.
-
-
if(($a->argc > 1) && ($a->argv[1] != "new") && intval($a->argv[1])) {
$r = q("SELECT * FROM `profile` WHERE `id` = %d AND `uid` = %d LIMIT 1",
intval($a->argv[1]),
$_SESSION['sysmsg'] .= "Profile not found." . EOL;
return;
}
+ $is_default = (($r[0]['is-default']) ? 1 : 0);
$profile_name = notags(trim($_POST['profile_name']));
if(! strlen($profile_name)) {
$marital = notags(trim(implode(', ',$_POST['marital'])));
$homepage = notags(trim($_POST['homepage']));
$about = str_replace(array('<','>','&'),array('<','>','&'),trim($_POST['about']));
-
+ if(x($_POST,'profile_in_directory'))
+ $publish = (($_POST['profile_in_directory'] == 1) ? 1: 0);
if(! in_array($gender,array('','Male','Female','Other')))
$gender = '';
if($r)
$_SESSION['sysmsg'] .= "Profile updated." . EOL;
+
+
+ if($is_default) {
+ $r = q("UPDATE `profile`
+ SET `publish` = %d
+ WHERE `id` = %d AND `uid` = %d LIMIT 1",
+ intval($publish),
+ intval($a->argv[1]),
+ intval($_SESSION['uid'])
+
+ );
+ }
+
+
}
goaway($a->get_baseurl() . '/profiles');
}
+ if(($a->argc > 2) && ($a->argv[1] == 'clone')) {
+
+ $r0 = q("SELECT `id` FROM `profile` WHERE `uid` = %d",
+ intval($_SESSION['uid']));
+ $num_profiles = count($r0);
+
+ $name = "Profile-" . ($num_profiles + 1);
+ $r1 = q("SELECT * FROM `profile` WHERE `uid` = %d AND `id` = %d LIMIT 1",
+ intval($_SESSION['uid']),
+ intval($a->argv[2])
+ );
+ if(! count($r1)) {
+ notice("Profile unavailable to clone." . EOL);
+ return;
+ }
+ unset($r1[0]['id']);
+ $r1[0]['is-default'] = 0;
+ $r1[0]['publish'] = 0;
+ $r1[0]['profile-name'] = dbesc($name);
+
+ dbesc_array($r1[0]);
+
+ $r2 = q("INSERT INTO `profile` (`"
+ . implode("`, `", array_keys($r1[0]))
+ . "`) VALUES ('"
+ . implode("', '", array_values($r1[0]))
+ . "')" );
+
+ $r3 = q("SELECT `id` FROM `profile` WHERE `uid` = %d AND `profile-name` = '%s' LIMIT 1",
+ intval($_SESSION['uid']),
+ dbesc($name)
+ );
+ $_SESSION['sysmsg'] .= "New profile created." . EOL;
+ if(count($r3) == 1)
+ goaway($a->get_baseurl() . '/profiles/' . $r3[0]['id']);
+ goaway($a->get_baseurl() . '/profiles');
+ return; // NOTREACHED
+ }
+
+
+
+
if(intval($a->argv[1])) {
$r = q("SELECT * FROM `profile` WHERE `id` = %d AND `uid` = %d LIMIT 1",
require_once('view/profile_selectors.php');
$tpl = file_get_contents('view/jot-header.tpl');
- $profile_in_dir = file_get_contents("view/profile-in-directory.tpl");
+ $opt_tpl = file_get_contents("view/profile-in-directory.tpl");
+ $profile_in_dir = replace_macros($opt_tpl,array(
+ '$yes_selected' => (($r[0]['publish']) ? " checked=\"checked\" " : ""),
+ '$no_selected' => (($r[0]['publish'] == 0) ? " checked=\"checked\" " : "")
+ ));
+
$a->page['htmlhead'] .= replace_macros($tpl, array('$baseurl' => $a->get_baseurl()));
+ $a->page['htmlhead'] .= "<script type=\"text/javascript\" src=\"include/country.js\" ></script>";
// $a->page['aside'] = file_get_contents('view/sidenote.tpl');
$is_default = (($r[0]['is-default']) ? 1 : 0);