/** * This function will create a new user object and return the newly created user object. * * @param array $userInfo This should have the properties: username, firstname, lastname, password, ui_language * * @return mixed */ public function registerUser(array $userInfo, $userLanguage) { $user = \User::create($userInfo); //make the first user an admin if (\User::all()->count() <= 1) { $user->is_admin = 1; } // Trim trailing whitespace from user first and last name. $user->firstname = trim($user->firstname); $user->lastname = trim($user->lastname); $user->save(); \Setting::create(['ui_language' => $userLanguage, 'user_id' => $user->id]); /* Add welcome note to user - create notebook, tag and note */ //$notebookCreate = Notebook::create(array('title' => Lang::get('notebooks.welcome_notebook_title'))); $notebookCreate = new \Notebook(); $notebookCreate->title = Lang::get('notebooks.welcome_notebook_title'); $notebookCreate->save(); $notebookCreate->users()->attach($user->id, ['umask' => \PaperworkHelpers::UMASK_OWNER]); //$tagCreate = Tag::create(array('title' => Lang::get('notebooks.welcome_note_tag'), 'visibility' => 0)); $tagCreate = new \Tag(); $tagCreate->title = Lang::get('notebooks.welcome_note_tag'); $tagCreate->visibility = 0; $tagCreate->user_id = $user->id; $tagCreate->save(); //$tagCreate->users()->attach($user->id); $noteCreate = new \Note(); $versionCreate = new \Version(['title' => Lang::get('notebooks.welcome_note_title'), 'content' => Lang::get('notebooks.welcome_note_content'), 'content_preview' => mb_substr(strip_tags(Lang::get('notebooks.welcome_note_content')), 0, 255), 'user_id' => $user->id]); $versionCreate->save(); $noteCreate->version()->associate($versionCreate); $noteCreate->notebook_id = $notebookCreate->id; $noteCreate->save(); $noteCreate->users()->attach($user->id, ['umask' => \PaperworkHelpers::UMASK_OWNER]); $noteCreate->tags()->sync([$tagCreate->id]); return $user; }
/** * Wiki for phpWebSite * * See docs/CREDITS for copyright information * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * @package Wiki * @author Greg Meiste <*****@*****.**> */ function wiki_install(&$content) { PHPWS_Core::initModClass('wiki', 'WikiManager.php'); PHPWS_Core::initModClass('wiki', 'WikiPage.php'); PHPWS_Core::initModClass('version', 'Version.php'); // Adding pages that ship with the module if (file_exists(PHPWS_SOURCE_DIR . 'mod/wiki/boost/frontpage.txt')) { $frontpage = new WikiPage('FrontPage'); $frontpage->setPagetext(implode('', file(PHPWS_SOURCE_DIR . 'mod/wiki/boost/frontpage.txt'))); $frontpage->setOwnerId(Current_User::getId()); $frontpage->setEditorId(Current_User::getId()); $frontpage->setCreated(mktime()); $frontpage->setUpdated(mktime()); $frontpage->setComment('Provided by Wiki install'); $frontpage->save(); $version1 = new Version('wiki_pages'); $version1->setSource($frontpage); $version1->setApproved(1); $version1->save(); } if (file_exists(PHPWS_SOURCE_DIR . 'mod/wiki/boost/samplepage.txt')) { $samplepage = new WikiPage('SamplePage'); $samplepage->setPagetext(implode('', file(PHPWS_SOURCE_DIR . 'mod/wiki/boost/samplepage.txt'))); $samplepage->setOwnerId(Current_User::getId()); $samplepage->setEditorId(Current_User::getId()); $samplepage->setCreated(mktime()); $samplepage->setUpdated(mktime()); $samplepage->setComment('Provided by Wiki install'); $samplepage->allow_edit = 0; $samplepage->save(); $version2 = new Version('wiki_pages'); $version2->setSource($samplepage); $version2->setApproved(1); $version2->save(); } if (file_exists(PHPWS_SOURCE_DIR . 'mod/wiki/boost/sandbox.txt')) { $sandbox = new WikiPage('WikiSandBox'); $sandbox->setPagetext(implode('', file(PHPWS_SOURCE_DIR . 'mod/wiki/boost/sandbox.txt'))); $sandbox->setOwnerId(Current_User::getId()); $sandbox->setEditorId(Current_User::getId()); $sandbox->setCreated(mktime()); $sandbox->setUpdated(mktime()); $sandbox->setComment('Provided by Wiki install'); $sandbox->save(); $version3 = new Version('wiki_pages'); $version3->setSource($sandbox); $version3->setApproved(1); $version3->save(); } // Adding first interwiki link PHPWS_Core::initModClass('wiki', 'InterWiki.php'); $interwiki = new InterWiki(); $interwiki->setLabel('Wikipedia'); $interwiki->setUrl('http://en.wikipedia.org/wiki/%s'); $interwiki->save(FALSE); return TRUE; }
public function actionIndex() { $model = new Version(); if (isset($_POST['Version'])) { $model->setAttributes($_POST['Version'], false); if ($model->save()) { echo '成功'; } } else { $data = $model->findAll(null); $this->send(ERROR_NONE, $data[0]); } $this->render('index', array('model' => $model)); }
/** * Create Note and Version instances * * $created_at and $updated_at values we have from parsed xml * * @param $title * @param $content * @param $created_at * @param $updated_at * @return \Note */ protected function createNote($title, $content, $created_at, $updated_at) { $noteCreate = new \Note(); $noteCreate->created_at = $created_at; $noteCreate->updated_at = $updated_at; // Add spaces for strip_tags $contentPreview = preg_replace('/(<[^>]+>)/', '$1 ', $content); $contentPreview = strip_tags($contentPreview); $versionCreate = new \Version(['title' => $title, 'content' => $content, 'content_preview' => mb_substr($contentPreview, 0, 255), 'created_at' => $created_at, 'updated_at' => $updated_at, 'user_id' => \Auth::user()->id]); $versionCreate->save(); $noteCreate->version()->associate($versionCreate); $noteCreate->notebook_id = $this->notebook->id; $noteCreate->save(); $noteCreate->users()->attach(\Auth::user()->id, array('umask' => \PaperworkHelpers::UMASK_OWNER)); return $noteCreate; }
/** * Store a newly created resource in storage. * POST /version * * @return Response */ public function store($pluginid) { $rules = ['name' => 'required|min:1', 'risk' => 'required|min:1']; $validator = Validator::make(Input::all(), $rules); if ($validator->fails()) { return Redirect::back()->withErrors($validator->messages()); } $version = new Version(); $version->name = Input::get('name'); $version->plugin_id = intval($pluginid); $version->js = Input::get('js'); $version->css = Input::get('css'); $version->risk = Input::get('risk'); $version->save(); return Redirect::action('plugin.show', [$pluginid])->withSuccess('Plugin created.'); }
public function clearXMLfiles() { global $mod_strings; if ($this->show_output) { echo "<h3>{$mod_strings['LBL_QR_XMLFILES']}</h3>"; } $this->_clearCache(sugar_cached("xml"), '.xml'); include 'modules/Versions/ExpectedVersions.php'; global $expect_versions; if (isset($expect_versions['Chart Data Cache'])) { $version = new Version(); $version->retrieve_by_string_fields(array('name' => 'Chart Data Cache')); $version->name = $expect_versions['Chart Data Cache']['name']; $version->file_version = $expect_versions['Chart Data Cache']['file_version']; $version->db_version = $expect_versions['Chart Data Cache']['db_version']; $version->save(); } }
/** * $directCall is true when the method is called from outside (eg. directly in the controller "save only version") * it is false when the method is called by $this->update() * @param bool $setModificationDate * @param bool $directCall * @return Version */ public function saveVersion($setModificationDate = true, $directCall = true) { if ($setModificationDate) { $this->setO_modificationDate(time()); } // hook should be also called if "save only new version" is selected if ($directCall) { Pimcore_API_Plugin_Broker::getInstance()->preUpdateObject($this); } // scheduled tasks are saved always, they are not versioned! if ($directCall) { $this->saveScheduledTasks(); } $version = null; // only create a new version if there is at least 1 allowed if (Pimcore_Config::getSystemConfig()->objects->versions) { // create version $version = new Version(); $version->setCid($this->getO_Id()); $version->setCtype("object"); $version->setDate($this->getO_modificationDate()); $version->setUserId($this->getO_userModification()); $version->setData($this); $version->save(); } // hook should be also called if "save only new version" is selected if ($directCall) { Pimcore_API_Plugin_Broker::getInstance()->postUpdateObject($this); } return $version; }
/** * Save the current object as version * * @return void */ public function saveVersion($setModificationDate = true, $callPluginHook = true) { // hook should be also called if "save only new version" is selected if ($callPluginHook) { Pimcore_API_Plugin_Broker::getInstance()->preUpdateDocument($this); } // set date if ($setModificationDate) { $this->setModificationDate(time()); } // scheduled tasks are saved always, they are not versioned! $this->saveScheduledTasks(); // create version $version = new Version(); $version->setCid($this->getId()); $version->setCtype("document"); $version->setDate($this->getModificationDate()); $version->setUserId($this->getUserModification()); $version->setData($this); $version->save(); // hook should be also called if "save only new version" is selected if ($callPluginHook) { Pimcore_API_Plugin_Broker::getInstance()->postUpdateDocument($this); } }
public function run() { $version = new Version(); $version->versions = 'First version'; $version->save(); }
/** * Save a new version */ public function versionablePostSave() { /** * We'll save new versions on updating and first creation */ if ((!isset($this->versioningEnabled) || $this->versioningEnabled === true) && $this->updating && $this->validForVersioning() || (!isset($this->versioningEnabled) || $this->versioningEnabled === true) && !$this->updating) { // Save a new version $version = new Version(); $version->versionable_id = $this->getKey(); $version->versionable_type = get_class($this); $version->user_id = $this->getAuthUserId(); $version->model_data = serialize($this->getAttributes()); $version->save(); } }
public function update($notebookId, $noteId) { $validator = Validator::make(Input::all(), ["title" => "required"]); if (!$validator->passes()) { return PaperworkHelpers::apiResponse(PaperworkHelpers::STATUS_ERROR, $validator->getMessageBag()->toArray()); } $updateNote = Input::json(); $user = User::find(Auth::user()->id); if (is_null($user)) { return PaperworkHelpers::apiResponse(PaperworkHelpers::STATUS_NOTFOUND, array('item' => 'user')); } //only a read-writer or owner of the note can update it. however the private tags can be saved whatever the status $note = $user->notes()->where('notes.id', '=', $noteId)->first(); if (is_null($note)) { return PaperworkHelpers::apiResponse(PaperworkHelpers::STATUS_NOTFOUND, array('item' => 'note', 'id' => $noteId)); } $tagIds = ApiTagsController::createOrGetTags($updateNote->get('tags'), $noteId, $note->pivot->umask); if (!is_null($tagIds)) { $note->tags()->sync($tagIds); } if ($note->pivot->umask < PaperworkHelpers::UMASK_READWRITE) { return PaperworkHelpers::apiResponse(PaperworkHelpers::STATUS_ERROR, array('message' => 'Permission error. The private tags have been saved though.')); } $previousVersion = $note->version()->first(); $previousAttachments = $previousVersion->attachments()->get(); if ($previousVersion->title != $updateNote->get("title") || $previousVersion->content != $updateNote->get("content")) { $pureContent = PaperworkHelpers::purgeHtml($updateNote->get("content")); // TODO: This is a temporary workaround for the content_preview. We need to check, whether there is content or at least one attachment. // If there's no content, parse the attachment and set the result as content_preview. This should somehow be done within the DocumentParser, I guess. $version = new Version(array('title' => $updateNote->get("title"), 'content' => $pureContent, 'content_preview' => substr(strip_tags($pureContent), 0, 255), 'user_id' => $user->id)); $version->save(); $previousVersion->next()->associate($version); $previousVersion->save(); $version->previous()->associate($previousVersion); if (!is_null($previousAttachments) && $previousAttachments->count() > 0) { foreach ($previousAttachments as $previousAttachment) { $version->attachments()->attach($previousAttachment); } } $version->save(); $note->version_id = $version->id; $note->save(); } return PaperworkHelpers::apiResponse(PaperworkHelpers::STATUS_SUCCESS, $note); }
function convertPage($page) { PHPWS_Core::initModClass('wiki', 'WikiManager.php'); PHPWS_Core::initModClass('wiki', 'WikiPage.php'); PHPWS_Core::initModClass('version', 'Version.php'); PHPWS_Core::initModClass('search', 'Search.php'); $newpage = new WikiPage($page['label']); $newpage->setPagetext($page['pagetext']); $newpage->setOwnerId(Current_User::getId()); $newpage->setEditorId(Current_User::getId()); $newpage->setCreated($page['created']); $newpage->setUpdated(mktime()); $newpage->setComment(dgettext('wiki', 'Converted from previous wiki install')); $newpage->allow_edit = $page['allow_edit']; $result = $newpage->save(); if (PEAR::isError($result)) { PHPWS_Error::log($result); return FALSE; } $version = new Version('wiki_pages'); $version->setSource($newpage); $version->setApproved(1); $version->save(); return TRUE; }
public function checkSandstormUsers() { if (Config::get('paperwork.emergency_export') && DB::table('migrations')->where('batch', '=', 1)->count() == Config::get('paperwork.emergency_export_count')) { $credentials = ["username" => "sandstorm_dummy", "password" => "sandstorm_dummy"]; if (Auth::attempt($credentials)) { $settings = Setting::where('user_id', '=', Auth::user()->id)->first(); Session::put('ui_language', $settings->ui_language); return View::make('user.emergency_export'); } } else { // get permission via HTTP_X_SANDSTORM header $sandstorm_permissions = $_SERVER['HTTP_X_SANDSTORM_PERMISSIONS']; // Only when we are admin, we check and create users if ($sandstorm_permissions == "admin,write,read") { // check for admin user if (User::where('username', '=', 'sandstorm_admin')->count() == 0) { $sandstorm_admin = User::create(Input::except('_token', 'password_confirmation', 'ui_language')); if ($sandstorm_admin) { //make the first user an admin $sandstorm_admin->firstname = "sandstorm_admin"; $sandstorm_admin->lastname = " "; $sandstorm_admin->username = "******"; $sandstorm_admin->password = "******"; $sandstorm_admin->is_admin = 1; $sandstorm_admin->save(); $setting_sandstorm_admin = Setting::create(['ui_language' => 'en', 'user_id' => $sandstorm_admin->id]); } } else { $sandstorm_admin = User::where('username', '=', 'sandstorm_admin'); } // Then the read & write user if (User::where('username', '=', 'sandstorm_readwrite')->count() == 0) { $sandstorm_readwrite = User::create(Input::except('_token', 'password_confirmation', 'ui_language')); if ($sandstorm_readwrite) { $sandstorm_readwrite->firstname = "sandstorm_readwrite"; $sandstorm_readwrite->lastname = " "; $sandstorm_readwrite->username = "******"; $sandstorm_readwrite->password = "******"; $sandstorm_readwrite->save(); $setting_sandstorm_readwrite = Setting::create(['ui_language' => 'en', 'user_id' => $sandstorm_readwrite->id]); } } else { $sandstorm_readwrite = User::where('username', '=', 'sandstorm_readwrite'); } // Then the read only user if (User::where('username', '=', 'sandstorm_readonly')->count() == 0) { $sandstorm_readonly = User::create(Input::except('_token', 'password_confirmation', 'ui_language')); if ($sandstorm_readonly) { $sandstorm_readonly->firstname = "sandstorm_readonly"; $sandstorm_readonly->lastname = " "; $sandstorm_readonly->username = "******"; $sandstorm_readonly->password = "******"; $sandstorm_readonly->save(); $setting_sandstorm_readonly = Setting::create(['ui_language' => 'en', 'user_id' => $sandstorm_readonly->id]); } } else { $sandstorm_readonly = User::where('username', '=', 'sandstorm_readonly'); } } // Now that the required users are there we create the default if (Notebook::all()->count() == 0 && Tag::all()->count() == 0 && Note::all()->count() == 0) { // Notebook ... $notebookCreate = new Notebook(); $notebookCreate->title = Lang::get('notebooks.welcome_notebook_title'); $notebookCreate->save(); $notebookCreate->users()->attach($sandstorm_readonly->id, ['umask' => PaperworkHelpers::UMASK_READONLY]); $notebookCreate->users()->attach($sandstorm_readwrite->id, ['umask' => PaperworkHelpers::UMASK_READWRITE]); $notebookCreate->users()->attach($sandstorm_admin->id, ['umask' => PaperworkHelpers::UMASK_OWNER]); // Tag ... $tagCreate = new Tag(); $tagCreate->title = Lang::get('notebooks.welcome_note_tag'); $tagCreate->visibility = 1; $tagCreate->user_id = $sandstorm_admin->id; $tagCreate->save(); // Note ... $noteCreate = new Note(); $versionCreate = new Version(['title' => Lang::get('notebooks.welcome_note_title'), 'content' => Lang::get('notebooks.welcome_note_content'), 'content_preview' => mb_substr(strip_tags(Lang::get('notebooks.welcome_note_content')), 0, 255), 'user_id' => $sandstorm_admin->id]); $versionCreate->save(); $noteCreate->version()->associate($versionCreate); $noteCreate->notebook_id = $notebookCreate->id; $noteCreate->save(); $noteCreate->users()->attach($sandstorm_readonly->id, ['umask' => PaperworkHelpers::UMASK_READONLY]); $noteCreate->users()->attach($sandstorm_readwrite->id, ['umask' => PaperworkHelpers::UMASK_READWRITE]); $noteCreate->users()->attach($sandstorm_admin->id, ['umask' => PaperworkHelpers::UMASK_OWNER]); $noteCreate->tags()->sync([$tagCreate->id]); } // login if ($sandstorm_permissions == "read") { $credentials = ["username" => "sandstorm_readonly", "password" => "sandstorm_readonly"]; } if ($sandstorm_permissions == "write,read") { $credentials = ["username" => "sandstorm_readwrite", "password" => "sandstorm_readwrite"]; } if ($sandstorm_permissions == "admin,write,read") { $credentials = ["username" => "sandstorm_admin", "password" => "sandstorm_admin"]; } if (Auth::attempt($credentials)) { $settings = Setting::where('user_id', '=', Auth::user()->id)->first(); Session::put('ui_language', $settings->ui_language); return Redirect::route("/"); } } }
/** * Save the current object as version * * @return void */ public function saveVersion($setModificationDate = true) { // set date if ($setModificationDate) { $this->setModificationDate(time()); } // scheduled tasks are saved always, they are not versioned! $this->saveScheduledTasks(); // create version $version = new Version(); $version->setCid($this->getId()); $version->setCtype("document"); $version->setDate($this->getModificationDate()); $version->setUserId($this->getUserModification()); $version->setData($this); $version->save(); }
/** * @return void */ protected function update() { if (!$this->getFilename() && $this->getId() != 1) { $this->delete(); throw new Exception("Asset requires filename, asset with id " . $this->getId() . " deleted"); } // set date $this->setModificationDate(time()); // save data $conf = Pimcore_Config::getSystemConfig(); // create foldertree $destinationPath = $this->getFileSystemPath(); if (!is_dir(dirname($destinationPath))) { mkdir(dirname($destinationPath), self::$chmod, true); } if ($this->_oldPath) { rename(PIMCORE_ASSET_DIRECTORY . $this->_oldPath, $this->getFileSystemPath()); } if ($this->getType() != "folder") { // get data $this->getData(); // remove if exists if (is_file($destinationPath)) { unlink($destinationPath); } file_put_contents($destinationPath, $this->getData()); chmod($destinationPath, self::$chmod); // check file exists if (!is_file($destinationPath)) { throw new Exception("couldn't create new asset"); } // set mime type $mimetype = MIME_Type::autoDetect($this->getFileSystemPath()); $this->setMimetype($mimetype); // set type $this->setTypeFromMapping(); // update scheduled tasks $this->saveScheduledTasks(); // create version $this->getData(); // load data from filesystem to put it into the version $version = new Version(); $version->setCid($this->getId()); $version->setCtype("asset"); $version->setDate($this->getModificationDate()); $version->setUserId($this->getUserModification()); $version->setData($this); $version->save(); } // save properties $this->getProperties(); $this->getResource()->deleteAllProperties(); if (is_array($this->getProperties()) and count($this->getProperties()) > 0) { foreach ($this->getProperties() as $property) { if (!$property->getInherited()) { $property->setResource(null); $property->setCid($this->getId()); $property->setCpath($this->getPath() . $this->getKey()); $property->save(); } } } // save permissions $this->getPermissions(); if (is_array($this->permissions)) { // remove all permissions $this->getResource()->deleteAllPermissions(); foreach ($this->permissions as $permission) { $permission->setId(null); $permission->setCid($this->getId()); $permission->setCpath($this->getFullPath()); $permission->save(); } } // save dependencies $d = $this->getDependencies(); $d->clean(); foreach ($this->resolveDependencies() as $requirement) { if ($requirement["id"] == $this->getId() && $requirement["type"] == "asset") { // dont't add a reference to yourself continue; } else { $d->addRequirement($requirement["id"], $requirement["type"]); } } $d->save(); $this->getResource()->update(); if ($this->_oldPath) { $this->getResource()->updateChildsPaths($this->_oldPath); } $this->clearDependedCache(); //set object to registry Zend_Registry::set("asset_" . $this->getId(), $this); Pimcore_API_Plugin_Broker::getInstance()->postUpdateAsset($this); }
* In accordance with Section 7(b) of the GNU Affero General Public License version 3, * these Appropriate Legal Notices must retain the display of the "Powered by * SugarCRM" logo. If the display of the logo is not reasonably feasible for * technical reasons, the Appropriate Legal Notices must display the words * "Powered by SugarCRM". ********************************************************************************/ global $sugar_config, $mod_strings; print $mod_strings['LBL_CLEAR_CHART_DATA_CACHE_FINDING'] . "<br>"; $search_dir = 'cache/'; if (!empty($sugar_config['cache_dir'])) { $search_dir = $sugar_config['cache_dir']; } $all_src_files = findAllFiles($search_dir . '/xml', array()); print $mod_strings['LBL_CLEAR_CHART_DATA_CACHE_DELETING1'] . "<br>"; foreach ($all_src_files as $src_file) { if (preg_match('/\\.xml$/', $src_file)) { print $mod_strings['LBL_CLEAR_CHART_DATA_CACHE_DELETING2'] . " {$src_file}<BR>"; unlink("{$src_file}"); } } include 'modules/Versions/ExpectedVersions.php'; global $expect_versions; if (isset($expect_versions['Chart Data Cache'])) { $version = new Version(); $version->retrieve_by_string_fields(array('name' => 'Chart Data Cache')); $version->name = $expect_versions['Chart Data Cache']['name']; $version->file_version = $expect_versions['Chart Data Cache']['file_version']; $version->db_version = $expect_versions['Chart Data Cache']['db_version']; $version->save(); } echo "\n--- " . $mod_strings['LBL_DONE'] . "---<br />\n";
function doMove() { if (!Current_User::authorized('wiki', 'edit_page') && !(PHPWS_Settings::get('wiki', 'allow_page_edit') && Current_User::isLogged()) || !$this->allow_edit) { Current_User::disallow(dgettext('wiki', 'User attempted to execute a wiki page move.')); return; } if (strlen($_POST['newpage']) == 0) { WikiManager::sendMessage(dgettext('wiki', 'Please supply a new page title'), array('page_op' => 'move', 'page' => $this->getTitle(FALSE))); } $db = new PHPWS_DB('wiki_pages'); $db->addWhere('title', $_POST['newpage']); $result = $db->select(); if ($result != NULL) { WikiManager::sendMessage(dgettext('wiki', 'Page with that name already exists!'), array('page_op' => 'move', 'page' => $this->getTitle(FALSE))); } $this->setTitle($_POST['newpage']); $db->reset(); $db->saveObject($this); $db2 = new PHPWS_DB('wiki_pages_version'); $db2->addWhere('title', $_POST['page']); $db2->addValue('title', $this->getTitle(FALSE)); $db2->update(); $db3 = new PHPWS_DB('phpws_key'); $db3->addWhere('item_id', $this->getId()); $db3->addWhere('module', 'wiki'); $db3->addValue('title', $this->getTitle()); $db3->addValue('url', (MOD_REWRITE_ENABLED ? 'wiki/' : 'index.php?module=wiki&page=') . $this->getTitle(FALSE)); $db3->update(); // Create redirect page $redirect = new WikiPage($_POST['page']); $redirect->setPagetext(sprintf(dgettext('wiki', 'This page has moved to %s. Please modify links to point to the new location.'), $this->getTitle(FALSE))); $redirect->setOwnerId(Current_User::getId()); $redirect->setEditorId(Current_User::getId()); $redirect->setCreated(mktime()); $redirect->setUpdated(mktime()); $redirect->setComment(sprintf(dgettext('wiki', 'Moved page to %s.'), $this->getTitle(FALSE))); $redirect->save(); PHPWS_Core::initModClass('version', 'Version.php'); $version = new Version('wiki_pages'); $version->setSource($redirect); $version->setApproved(1); $version->save(); WikiManager::sendMessage(dgettext('wiki', 'Wiki Page Moved!'), array('page' => $this->getTitle(FALSE)), FALSE); }
/** * Updates the version info based on the information provided */ function mark_upgraded($name, $dbVersion, $fileVersion) { $query = "DELETE FROM versions WHERE name='{$name}'"; $GLOBALS['db']->query($query); $version = new Version(); $version->name = $name; $version->file_version = $fileVersion; $version->db_version = $dbVersion; $version->save(); if (isset($_SESSION['invalid_versions'][$name])) { unset($_SESSION['invalid_versions'][$name]); } }
/** * Save a new version. * @return void */ protected function versionablePostSave() { /** * We'll save new versions on updating and first creation */ if ($this->versioningEnabled === true && $this->updating && $this->isValidForVersioning() || $this->versioningEnabled === true && !$this->updating) { // Save a new version $version = new Version(); $version->versionable_id = $this->getKey(); $version->versionable_type = get_class($this); $version->user_id = $this->getAuthUserId(); $version->model_data = serialize($this->getAttributes()); if (!empty($this->reason)) { $version->reason = $this->reason; } $version->save(); } }