function Streams_0_8_6_Streams_mysql() { $app = Q_Config::expect('Q', 'app'); // access for managing communities $access = new Streams_Access(); $access->publisherId = $app; $access->streamName = 'Streams/community*'; $access->ofUserId = ''; $access->ofContactLabel = "{$app}/admins"; $access->readLevel = Streams::$READ_LEVEL['messages']; $access->writeLevel = Streams::$WRITE_LEVEL['edit']; $access->adminLevel = Streams::$ADMIN_LEVEL['manage']; $access->save(); // access for managing categories $access = new Streams_Access(); $access->publisherId = $app; $access->streamName = 'Streams/category/'; $access->ofUserId = ''; $access->ofContactLabel = "{$app}/admins"; $access->readLevel = Streams::$READ_LEVEL['messages']; $access->writeLevel = Streams::$WRITE_LEVEL['close']; $access->adminLevel = Streams::$ADMIN_LEVEL['manage']; $access->save(); // template to help users relate things to Streams/category streams Streams_Stream::insert(array('publisherId' => '', 'name' => 'Streams/category/', 'type' => 'Streams/template', 'title' => 'Untitled Category', 'icon' => 'Streams/category', 'content' => '', 'attributes' => null, 'readLevel' => Streams::$READ_LEVEL['messages'], 'writeLevel' => Streams::$WRITE_LEVEL['relate'], 'adminLevel' => Streams::$ADMIN_LEVEL['invite']))->execute(); // template to help users create subcategories for things Streams_RelatedTo::insert(array('toPublisherId' => '', 'toStreamName' => 'Streams/category/', 'type' => 'subcategories', 'fromPublisherId' => '', 'fromStreamName' => 'Streams/category/'))->execute(); }
function Websites_0_9_1_Streams_mysql() { $userId = Users::communityId(); $ofUserId = ''; $ofContactLabel = 'Websites/admins'; $grantedByUserId = null; $streams = array("Websites/presentation/" => array('type' => "Streams/template", "title" => "Untitled Presentation", "icon" => "{{baseUrl}}/plugins/Websites/img/icons/Websites/presentation", "content" => "", "deletable" => true), "Websites/slide/" => array('type' => "Streams/template", "title" => "Untitled Slide", "icon" => "{{baseUrl}}/plugins/Websites/img/icons/Websites/presentation", "content" => "", "deletable" => true)); $readLevel = Streams::$READ_LEVEL['messages']; $adminLevel = Streams::$ADMIN_LEVEL['own']; $rows = array(); foreach ($streams as $streamName => $stream) { $publisherId = substr($streamName, -1) == '/' ? '' : $userId; $level = !empty($stream['deletable']) ? 'close' : 'edit'; $writeLevel = Streams::$WRITE_LEVEL[!empty($stream['deletable']) ? 'close' : 'edit']; $rows[] = compact('publisherId', 'streamName', 'ofUserId', 'ofContactLabel', 'grantedByUserId', 'readLevel', 'writeLevel', 'adminLevel'); } Streams_Access::insertManyAndExecute($rows); $attributes = null; $closedTime = null; $readLevel = Streams::$READ_LEVEL['messages']; $writeLevel = Streams::$WRITE_LEVEL['join']; $adminLevel = Streams::$ADMIN_LEVEL['invite']; $inheritAccess = null; $rows = array(); foreach ($streams as $name => $s) { extract($s); $publisherId = substr($name, -1) == '/' ? '' : $userId; $rows[] = compact('publisherId', 'name', 'type', 'title', 'icon', 'content', 'attributes', 'readLevel', 'writeLevel', 'adminLevel', 'inheritAccess'); } Streams_Stream::insertManyAndExecute($rows); Streams_RelatedTo::insert(array('toPublisherId' => '', 'toStreamName' => 'Websites/presentation/', 'type' => 'slides', 'fromPublisherId' => '', 'fromStreamName' => 'Websites/slide/'))->execute(); }
function Websites_0_8_Streams_mysql() { $userId = Q_Config::get("Websites", "user", "id", null); if (!$userId) { throw new Q_Exception('Websites: Please fill in the config field "Websites"/"user"/"id"'); } // $now = Streams::db()->toDateTime(Streams::db()->getCurrentTimestamp()); $ofUserId = ''; $ofContactLabel = 'Websites/admins'; $grantedByUserId = null; $streams = array("Streams/images/" => array('type' => "Streams/template", "title" => "Images", "icon" => "default", "content" => "", "deletable" => true), "Streams/image/" => array('type' => "Streams/template", "title" => "Untitled Image", "icon" => "Streams/image", "content" => "", "deletable" => true), "Streams/file/" => array('type' => "Streams/template", "title" => "Untitled File", "icon" => "files/_blank", "content" => "", "deletable" => true), "Websites/article/" => array('type' => "Streams/template", "title" => "Untitled Article", "icon" => "default", "content" => "", "deletable" => true), "Websites/seo/" => array('type' => "Streams/template", "title" => "Website SEO", "icon" => Q_Html::themedUrl("plugins/Websites/img/seo"), "content" => "", "deletable" => true), "Websites/header" => array('type' => "Streams/image/icon", "title" => "Header image", "icon" => Q_Html::themedUrl("plugins/Websites/img/header"), "content" => ""), "Websites/slogan" => array('type' => "Streams/text/small", "title" => "Website slogan", "icon" => "default", "content" => "The coolest website"), "Websites/title" => array('type' => "Streams/text/small", "title" => "Website title", "icon" => "default", "content" => "Website Title"), "Websites/menu" => array('type' => "Streams/category", "title" => "Website Menu", "icon" => "default", "content" => ""), "Websites/articles" => array('type' => "Streams/category", "title" => "Articles", "icon" => "default", "content" => "Articles"), "Websites/images" => array('type' => "Streams/category", "title" => "Images", "icon" => "default", "content" => "Articles")); $readLevel = Streams::$READ_LEVEL['messages']; $writeLevel = Streams::$WRITE_LEVEL['edit']; $adminLevel = Streams::$ADMIN_LEVEL['own']; $rows = array(); foreach ($streams as $streamName => $stream) { $publisherId = substr($streamName, -1) == '/' ? '' : $userId; $writeLevel = !empty($stream['deletable']) ? 40 : 30; $rows[] = compact('publisherId', 'streamName', 'ofUserId', 'ofContactLabel', 'grantedByUserId', 'readLevel', 'writeLevel', 'adminLevel'); } Streams_Access::insertManyAndExecute($rows); $attributes = null; $closedTime = null; $readLevel = Streams::$READ_LEVEL['messages']; $writeLevel = Streams::$WRITE_LEVEL['join']; $adminLevel = Streams::$ADMIN_LEVEL['invite']; $inheritAccess = null; $rows = array(); foreach ($streams as $name => $s) { extract($s); if (substr($name, 0, 9) != 'Websites/') { continue; // this tempate was already added by Streams install script } $publisherId = substr($name, -1) == '/' ? '' : $userId; $rows[] = compact('publisherId', 'name', 'type', 'title', 'icon', 'content', 'attributes', 'readLevel', 'writeLevel', 'adminLevel', 'inheritAccess'); } Streams_Stream::insertManyAndExecute($rows); Streams_RelatedTo::insert(array('toPublisherId' => '', 'toStreamName' => 'Streams/images/', 'type' => 'images', 'fromPublisherId' => '', 'fromStreamName' => 'Streams/image/'))->execute(); Streams_RelatedTo::insert(array('toPublisherId' => '', 'toStreamName' => 'Streams/category/', 'type' => 'articles', 'fromPublisherId' => '', 'fromStreamName' => 'Websites/article/'))->execute(); Streams_RelatedTo::insert(array('toPublisherId' => '', 'toStreamName' => 'Streams/category/', 'type' => 'announcements', 'fromPublisherId' => '', 'fromStreamName' => 'Websites/article/'))->execute(); }