function createSlideshow($main = false, $settings = false, $elements = false) { $retval = 0; if (!empty($main['USER_ID']) && $settings !== false && $elements !== false) { include_once PATH_INCLUDE . '/functions.php'; // needed for tagwalk include_once PATH_CLASS . '/CFlix.php'; include_once PATH_CLASS . '/CUser.php'; include_once PATH_CLASS . '/CUserManage.php'; include_once PATH_CLASS . '/CSubscriptionManage.php'; $f =& CFlix::getInstance(); $u =& CUser::getInstance(); $um =& CUserManage::getInstance(); $sm =& CSubscriptionManage::getInstance(); $us_u_id = $this->dbh->sql_safe($main['USER_ID']); $us_key = substr(randomString(32) . NOW, -32); $us_key_safe = $this->dbh->sql_safe($us_key); $us_name = $this->dbh->sql_safe($main['NAME']); $us_fotoCount = intval($main['FOTOCOUNT']); $settingsArr = jsonDecode($settings); $settingsArr[0]['title_str'] = $main['NAME']; $settings = jsonEncode($settingsArr); $us_settings = $this->dbh->sql_safe($settings); // reset keys $elementsArr = jsonDecode($elements); $i = 0; $tmp = array(); foreach ($elementsArr as $v) { if (count($v) > 0) { array_push($tmp, $v); } } $elements = jsonEncode($tmp); $us_elements = $this->dbh->sql_safe($elements); $us_type = $settingsArr[0]['siteBuilder_bool'] == 1 ? "'site'" : "'slideshow'"; $us_privacy = intval($main['PRIVACY']); $views = intval($main['VIEWS']); $viewsComplete = intval($main['VIEWSCOMPLETE']); $order = 0; // always on top intval($main['ORDER']); // increment order for all public slideshows $sql = 'UPDATE user_slideshows SET us_order=us_order+1 WHERE us_privacy & ' . PERM_SLIDESHOW_DEFUALT . ' = ' . PERM_SLIDESHOW_DEFUALT . ' AND us_u_id = ' . $us_u_id; $this->dbh->execute($sql); // add slideshow $sql = 'INSERT INTO user_slideshows( us_u_id, us_key, us_name, us_settings, us_elements, us_type, us_fotoCount, us_privacy, us_views, us_viewsComplete, us_order, us_dateModified, us_dateCreated) ' . "VALUES({$us_u_id}, {$us_key_safe}, {$us_name}, {$us_settings}, {$us_elements}, {$us_type}, {$us_fotoCount}, {$us_privacy}, {$views}, {$viewsComplete}, {$order}, NOW(), NOW())"; $this->dbh->execute($sql); $us_id = $this->dbh->insert_id(); $firstPhoto = ''; $insertPhotos = false; $tags = array(); $sql = 'INSERT INTO foto_slideshow_map (up_id, us_id) VALUES'; foreach ($elementsArr as $k => $v) { if (array_key_exists('photoId_int', $v)) { if ($firstPhoto == '') { $firstPhoto = $v['thumbnailPath_str']; } $tags = array_merge($tags, (array) explode(',', $v['tags_str'])); $sql .= '(' . intval($v['photoId_int']) . ', ' . $us_id . '), '; $insertPhotos = true; } } if ($insertPhotos === true) { $sql = substr($sql, 0, -2); $this->dbh->execute($sql); } if (count($tags) > 0) { $tags = array_filter(array_unique($tags), 'tagtrim'); array_walk($tags, 'tagwalk'); $tags = ',' . implode(',', $tags) . ','; $tags = $this->dbh->sql_safe($tags); $this->dbh->execute("UPDATE user_slideshows SET us_tags = {$tags} WHERE us_id = {$us_id}"); } $retval = $us_key; //intval($this->dbh->insert_id()); $userData = $u->find($main['USER_ID']); // add subscription data $sm->addData(array('sd_u_id' => $main['USER_ID'], 'sd_elementType' => 'Slideshow_Public', 'sd_element_id' => $us_key, 'sd_thumbnail' => $firstPhoto)); // set preference $um->setPrefs($main['USER_ID'], array('HAS_SLIDESHOW' => 1)); // add activity $um->addActivity($main['USER_ID'], $us_id, 'newSlideshow', $userData['U_USERNAME'], $firstPhoto, $us_key); } return $retval; }
<?php $sm =& CSubscriptionManage::getInstance(); if (strlen($_GET['key']) == 32) { $sm->deleteSubscriptions(array('s_key' => $_GET['key'])); } $url = '/?action=confirm.main&type=subscription_removed';