本文整理汇总了PHP中PHPWS_DB::reset方法的典型用法代码示例。如果您正苦于以下问题:PHP PHPWS_DB::reset方法的具体用法?PHP PHPWS_DB::reset怎么用?PHP PHPWS_DB::reset使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PHPWS_DB
的用法示例。
在下文中一共展示了PHPWS_DB::reset方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: diff
/**
* Diff
*
* Main function: Calls the diff and render, then outputs to layout
*
* @author Greg Meiste <greg.meiste+github@gmail.com>
*/
function diff($oVer, $nVer)
{
PHPWS_Core::initModClass('wiki', 'OldWikiPage.php');
$olderpage = new OldWikiPage();
$newerpage = new OldWikiPage();
$db = new PHPWS_DB('wiki_pages_version');
$db->addWhere('title', $_REQUEST['page']);
$db->addWhere('vr_number', $oVer);
$db->loadObject($olderpage);
$db->reset();
$db->addWhere('title', $_REQUEST['page']);
$db->addWhere('vr_number', $nVer);
$db->loadObject($newerpage);
// Need to parse the text, but we can't call parseOutput or this module's
// transform function. They both do too much parsing and can't be used
// for a diff. So, we call what is needed directly:
$oPagetext = htmlspecialchars(str_replace("'", "'", $olderpage->getPagetext(FALSE)));
$nPagetext = htmlspecialchars(str_replace("'", "'", $newerpage->getPagetext(FALSE)));
if (!ALLOW_PROFANITY) {
$oPagetext = PHPWS_Text::profanityFilter($oPagetext);
$nPagetext = PHPWS_Text::profanityFilter($nPagetext);
}
// End diff text parsing
$oPagetext = explode("\n", $oPagetext);
$nPageText = explode("\n", $nPagetext);
$diff = new Text_Diff($oPagetext, $nPageText);
$this->render($diff);
$tags = array();
$tags['TITLE'] = dgettext('wiki', 'Difference between revisions');
$tags['BACK_PAGE'] = PHPWS_Text::moduleLink(dgettext('wiki', 'Back to Page'), 'wiki', array('page' => $_REQUEST['page']));
$tags['BACK_HISTORY'] = PHPWS_Text::moduleLink(dgettext('wiki', 'Back to History'), 'wiki', array('page_op' => 'history', 'page_id' => $newerpage->getSourceId()));
$tags['DIFF'] = $this->_output;
$tags['OLDER_VERSION'] = $olderpage->getVrNumber();
$tags['NEWER_VERSION'] = $newerpage->getVrNumber();
$tags['OLDER_UPDATED'] = $olderpage->getUpdated();
$tags['NEWER_UPDATED'] = $newerpage->getUpdated();
$tags['VERSION_LABEL'] = dgettext('wiki', 'Version');
return PHPWS_Template::process($tags, 'wiki', 'diff/' . $this->_format . '/diff.tpl');
}
示例2: saveParams
/**
* Saves the parameters from this report to the database.
*
* @throws DatabaseException
*/
public function saveParams()
{
$params = $this->getParams();
if (empty($params)) {
return;
}
$db = new PHPWS_DB('hms_report_param');
foreach ($params as $key => $value) {
$db->reset();
$db->addValue('report_id', $this->report->getId());
$db->addValue('param_name', $key);
$db->addValue('param_value', $value);
$result = $db->insert();
if (PHPWS_Error::logIfError($result)) {
throw new DatabaseException($result->toString());
}
}
}
示例3: add
/**
* Grant user access to search and manage Department.
*/
public static function add($username, $departmentId)
{
if (empty($username)) {
return \NQ::simple('intern', NotifyUI::WARNING, 'No username entered.');
}
if ($departmentId == -1) {
return \NQ::simple('intern', NotifyUI::WARNING, 'No department selected.');
}
// First check that the username passed in is a registered user.
$db = new \PHPWS_DB('users');
$db->addWhere('username', $username);
$db->addColumn('id', $count = true);
if (sizeof($db->select()) == 0) {
// No user exists with that name.
return \NQ::simple('intern', NotifyUI::ERROR, "No user exists with the name <i>{$username}</i>. Please choose a valid username.");
}
// Deity users automatically see every department. No need to add them to table.
$db->reset();
$db->addWhere('username', $username);
$db->addWhere('deity', true);
$db->addColumn('id', $count = true);
if (sizeof($db->select()) >= 1) {
// Is a deity.
return \NQ::simple('intern', NotifyUI::WARNING, "<i>{$username}</i> can view all internships in all departments.");
}
$d = new Department($departmentId);
// Check if user already has permission.
if (self::allowed($username, $departmentId)) {
// User permission has already been added.
return \NQ::simple('intern', NotifyUI::WARNING, "<i>{$username}</i> can already view internships in <i>{$d->name}</i>.");
}
$ia = new Admin();
$ia->username = $username;
$ia->department_id = $departmentId;
$ia->save();
\NQ::simple('intern', NotifyUI::SUCCESS, "<i>{$username}</i> can now view internships for <i>{$d->name}</i>.");
}
示例4: checkin_update
/**
* @version $Id$
* @author Matthew McNaney <mcnaney at gmail dot com>
*/
function checkin_update(&$content, $current_version)
{
switch (1) {
case version_compare($current_version, '1.0.1', '<'):
$content[] = '<pre>';
$db = new PHPWS_DB('checkin_staff');
if (PHPWS_Error::logIfError($db->addTableColumn('view_order', 'smallint not null default 0'))) {
$content[] = 'Unable to create checkin_staff.view_order column.</pre>';
return false;
} else {
$content[] = 'Created checkin_staff.view_order column.';
}
$db->addColumn('id');
$staff_list = $db->select('col');
if (!empty($staff_list)) {
$count = 1;
foreach ($staff_list as $staff_id) {
$db->reset();
$db->addWhere('id', $staff_id);
$db->addValue('view_order', $count);
PHPWS_Error::logIfError($db->update());
$count++;
}
}
checkinUpdateFiles(array('templates/visitors.tpl', 'templates/waiting.tpl', 'templates/queue.tpl', 'templates/settings.tpl'), $content);
$content[] = '1.0.1 changes
------------------
+ Fixed bug with pulling current staff member
+ Added refresh link to waiting and assignment page
+ Fixed report
</pre>';
case version_compare($current_version, '1.0.2', '<'):
$content[] = '<pre>';
checkinUpdateFiles(array('templates/visitors.tpl', 'templates/waiting.tpl', 'templates/style.css'), $content);
$content[] = '1.0.2 changes
--------------------
+ Fixed translation typo.
+ Added "Send back" condition</pre>';
case version_compare($current_version, '1.0.3', '<'):
$content[] = '<pre>';
checkinUpdateFiles(array('templates/report.tpl'), $content);
$content[] = '1.0.3 changes
--------------------
+ Removed error message from report if no reasons created
+ Added the time of arrival to the report
+ Changed report date entry interface
+ Upper cased names.
</pre>';
case version_compare($current_version, '1.0.4', '<'):
$content[] = '<pre>1.0.4 changes
---------------------
+ Fixed waiting time setting</pre>';
case version_compare($current_version, '1.1.0', '<'):
$content[] = '<pre>1.1.0 changes
---------------------
+ Added code to prevent refreshed duplicates
+ Fixed possible error in admin view
+ Added monthly and student reports
+ Added report for number of times a visitor has visited within 30 days.
+ PHP 5 Strict changes</pre>';
case version_compare($current_version, '1.1.1', '<'):
$content[] = '<pre>1.1.1 changes
---------------------
+ Reports limited to admins</pre>';
case version_compare($current_version, '1.2', '<'):
$db = new PHPWS_DB('checkin_staff');
$db->addTableColumn('active', 'smallint not null default 1');
$content[] = '<pre>1.2 changes
--------------
+ Fixed blue button on admin menu
+ Staff can now be deactivated so they appear on reports but do not receive visitors</pre>';
case version_compare($current_version, '1.3', '<'):
$db = new PHPWS_DB('checkin_visitor');
$db->addTableColumn('email', 'varchar(255) NULL');
$content[] = '<pre>1.3 changes
---------------
+ Option to collect visitor email addresses.</pre>';
case version_compare($current_version, '1.4.0', '<'):
$content[] = '<pre>1.4.0 changes
---------------
+ May now report by visitor name.</pre>';
case version_compare($current_version, '1.5.0', '<'):
$content[] = '<pre>';
// Make changes to checkin_visitor table
$db = new PHPWS_DB('checkin_visitor');
if (PHPWS_Error::logIfError($db->addTableColumn('gender', 'varchar(20) default NULL'))) {
$content[] = 'Unable to create checkin_visitor.gender column.</pre>';
return false;
} else {
$content[] = 'Created checkin_visitor.gender column.';
}
if (PHPWS_Error::logIfError($db->addTableColumn('birthdate', 'varchar(20) default NULL'))) {
$content[] = 'Unable to create checkin_visitor.birthdate column.</pre>';
return false;
} else {
$content[] = 'Created checkin_visitor.birthdate column.';
//.........这里部分代码省略.........
示例5: users_install
/**
* boost install file for users
*
* @author Matthew McNaney <mcnaney at gmail dot com>
* @version $Id$
*/
function users_install(&$content)
{
PHPWS_Core::initModClass('users', 'Users.php');
PHPWS_Core::initModClass('users', 'Action.php');
PHPWS_Core::configRequireOnce('users', 'config.php');
if (isset($_REQUEST['module']) && $_REQUEST['module'] == 'branch') {
$db = new PHPWS_DB();
PHPWS_Settings::clear();
if (!createLocalAuthScript()) {
$content[] = 'Could not create authorization script.';
return false;
}
Branch::loadHubDB();
$db = new PHPWS_DB('mod_settings');
$db->addWhere('module', 'users');
$db->addWhere('setting_name', 'site_contact');
$db->addColumn('small_char');
$site_contact = $db->select('one');
$db = new PHPWS_DB('users');
$sql = 'select a.password, b.* from user_authorization as a, users as b where b.deity = 1 and a.username = b.username';
$deities = $db->getAll($sql);
if (PHPWS_Error::isError($deities)) {
PHPWS_Error::log($deities);
$content[] = dgettext('users', 'Could not access hub database.');
Branch::restoreBranchDB();
return FALSE;
} elseif (empty($deities)) {
$content[] = dgettext('users', 'Could not find any hub deities.');
Branch::restoreBranchDB();
return FALSE;
} else {
Branch::restoreBranchDB();
PHPWS_Settings::set('users', 'site_contact', $site_contact);
PHPWS_Settings::save('users');
$auth_db = new PHPWS_DB('user_authorization');
$user_db = new PHPWS_DB('users');
$group_db = new PHPWS_DB('users_groups');
foreach ($deities as $deity) {
$auth_db->addValue('username', $deity['username']);
$auth_db->addValue('password', $deity['password']);
$result = $auth_db->insert();
if (PHPWS_Error::isError($result)) {
PHPWS_Error::log($result);
$content[] = dgettext('users', 'Unable to copy deity login to branch.');
continue;
}
unset($deity['password']);
$user_db->addValue($deity);
$result = $user_db->insert();
if (PHPWS_Error::isError($result)) {
PHPWS_Error::log($result);
$content[] = dgettext('users', 'Unable to copy deity users to branch.');
Branch::loadBranchDB();
return FALSE;
}
$group_db->addValue('active', 1);
$group_db->addValue('name', $deity['username']);
$group_db->addValue('user_id', $result);
if (PHPWS_Error::logIfError($group_db->insert())) {
$content[] = dgettext('users', 'Unable to copy deity user group to branch.');
Branch::loadBranchDB();
return FALSE;
}
$group_db->reset();
$auth_db->reset();
$user_db->reset();
}
$content[] = dgettext('users', 'Deity users copied to branch.');
}
return TRUE;
}
if (!createLocalAuthScript()) {
$content[] = 'Could not create local authorization script.';
return false;
}
$authorize_id = PHPWS_Settings::get('users', 'local_script');
$user = new PHPWS_User();
$content[] = '<hr />';
return TRUE;
}
示例6: postMeta
public static function postMeta()
{
$values['page_title'] = strip_tags($_POST['page_title']);
$values['meta_keywords'] = strip_tags($_POST['meta_keywords']);
$values['meta_description'] = strip_tags($_POST['meta_description']);
if (isset($_POST['index'])) {
$index = 1;
} else {
$index = 0;
}
if (isset($_POST['follow'])) {
$follow = 1;
} else {
$follow = 0;
}
PHPWS_Settings::set('layout', 'use_key_summaries', (int) isset($_POST['use_key_summaries']));
PHPWS_Settings::save('layout');
$values['meta_robots'] = $index . $follow;
if (isset($_POST['key_id'])) {
$key_id = (int) $_POST['key_id'];
}
if (isset($key_id)) {
$values['key_id'] = $key_id;
$db = new PHPWS_DB('layout_metatags');
$db->addWhere('key_id', $key_id);
$db->delete();
if (isset($_POST['reset'])) {
return true;
}
$db->reset();
$db->addValue($values);
return $db->insert();
} else {
$db = new PHPWS_DB('layout_config');
$db->addValue($values);
return $db->update();
}
}
示例7: save
/**
* updates the settings table
*/
public static function save($module)
{
if (!PHPWS_Settings::is_set($module)) {
return false;
}
$db = new PHPWS_DB('mod_settings');
$db->addWhere('module', $module);
$db->addWhere('setting_name', array_keys($GLOBALS['PHPWS_Settings'][$module]));
$db->delete();
$db->reset();
foreach ($GLOBALS['PHPWS_Settings'][$module] as $key => $value) {
if (empty($key)) {
continue;
}
$type = PHPWS_Settings::getType($value);
$db->addValue('module', $module);
$db->addValue('setting_name', $key);
$db->addValue('setting_type', $type);
switch ($type) {
case 1:
$db->addValue('small_num', (int) $value);
break;
case 2:
$db->addValue('large_num', (int) $value);
break;
case 3:
$db->addValue('small_char', $value);
break;
case 4:
$db->addValue('large_char', $value);
break;
}
$result = $db->insert();
if (PHPWS_Error::isError($result)) {
unset($GLOBALS['PHPWS_Settings'][$module]);
PHPWS_Settings::load($module);
return $result;
}
$db->reset();
}
unset($GLOBALS['PHPWS_Settings'][$module]);
PHPWS_Settings::load($module);
}
示例8: save
public function save()
{
if (empty($this->key_id) || empty($this->keywords)) {
return FALSE;
}
$db = new PHPWS_DB('search');
$db->addWhere('key_id', $this->key_id);
$db->delete();
$db->reset();
$key = new Key($this->key_id);
$db->addValue('key_id', $key->id);
$db->addValue('module', $key->module);
$db->addValue('created', $key->create_date);
if (is_array($this->keywords)) {
$keywords = implode(' ', $this->keywords);
} else {
$keywords = $this->keywords;
}
$db->addValue('keywords', $keywords);
return $db->insert();
}
示例9: delete
public function delete()
{
if ($this->ftype == IMAGE_FOLDER) {
$table = 'images';
} elseif ($this->ftype == DOCUMENT_FOLDER) {
$table = 'documents';
} elseif ($this->ftype == MULTIMEDIA_FOLDER) {
$table = 'multimedia';
} else {
return false;
}
/**
* Delete file associations inside folder
*/
$db = new PHPWS_DB('fc_file_assoc');
$db->addWhere($table . '.folder_id', $this->id);
$db->addWhere($table . '.id', 'fc_file_assoc.file_id');
PHPWS_Error::logIfError($db->delete());
/**
* Delete the special folder associations to this folder
*/
$db->reset();
$db->addWhere('file_type', FC_IMAGE_FOLDER, '=', 'or', 1);
$db->addWhere('file_type', FC_IMAGE_LIGHTBOX, '=', 'or', 1);
$db->addWhere('file_type', FC_IMAGE_RANDOM, '=', 'or', 1);
$db->addWhere('file_type', FC_DOCUMENT_FOLDER, '=', 'or', 1);
$db->addWhere('file_id', $this->id);
PHPWS_Error::logIfError($db->delete());
/**
* Delete the files in the folder from the db
*/
unset($db);
$db = new PHPWS_DB($table);
$db->addWhere('folder_id', $this->id);
PHPWS_Error::logIfError($db->delete());
/**
* Delete the folder from the database
*/
$db = new PHPWS_DB('folders');
$db->addWhere('id', $this->id);
PHPWS_Error::logIfError($db->delete());
/**
* Delete the key
*/
$key = new Key($this->key_id);
$key->delete();
/**
* Delete the physical directory the folder occupies
*/
$directory = $this->getFullDirectory();
if (is_dir($directory)) {
PHPWS_File::rmdir($directory);
}
return true;
}
示例10: filecabinet_update
/**
* @author Matthew McNaney
* @version $Id$
*/
function filecabinet_update(&$content, $version)
{
$home_dir = PHPWS_Boost::getHomeDir();
switch ($version) {
case version_compare($version, '1.0.1', '<'):
$content[] = '<pre>File Cabinet versions prior to 1.0.1 are not supported.
Please download version 1.0.2.</pre>';
break;
case version_compare($version, '1.0.2', '<'):
$content[] = '<pre>';
$db = new PHPWS_DB('folders');
if (!$db->isTableColumn('key_id')) {
if (PHPWS_Error::logIfError($db->addTableColumn('key_id', 'int NOT NULL default 0'))) {
$content[] = '--- An error occurred when trying to add key_id as a column to the folders table.</pre>';
return false;
}
$content[] = '--- Successfully added key_id column to folders table.';
$db2 = new PHPWS_DB('phpws_key');
$db2->addWhere('module', 'filecabinet');
$db2->delete();
$content[] = '--- Deleted false folder keys.';
$db->reset();
PHPWS_Core::initModClass('filecabinet', 'Folder.php');
$result = $db->getObjects('Folder');
if (!empty($result)) {
foreach ($result as $folder) {
$folder->saveKey(true);
}
}
}
$content[] = '
1.0.2 changes
--------------
+ 1.0.0 update was missing key_id column addition to folders table.
</pre>';
case version_compare($version, '1.1.0', '<'):
$content[] = '<pre>';
if (!checkMultimediaDir($content, $home_dir)) {
return false;
}
if (!is_dir($home_dir . 'files/filecabinet/incoming')) {
if (is_writable($home_dir . 'files/filecabinet') && @mkdir($home_dir . 'files/filecabinet/incoming')) {
$content[] = '--- "files/filecabinet/incoming" directory created.';
} else {
$content[] = 'File Cabinet 1.1.0 is unable to create a "filecabinet/incoming" directory.
It is not required but if you want to classify files you will need to create it yourself.
Example: mkdir phpwebsite/files/filecabinet/incoming/</pre>';
return false;
}
}
$source_dir = PHPWS_SOURCE_DIR . 'mod/filecabinet/templates/filters/';
$dest_dir = $home_dir . 'templates/filecabinet/filters/';
if (!is_dir($dest_dir)) {
if (!PHPWS_File::copy_directory($source_dir, $dest_dir)) {
$content[] = '--- FAILED copying templates/filters/ directory locally.</pre>';
return false;
}
}
$files = array('templates/manager/pick.tpl', 'templates/classify_file.tpl', 'templates/classify_list.tpl', 'templates/image_edit.tpl', 'templates/multimedia_edit.tpl', 'templates/multimedia_grid.tpl', 'templates/style.css', 'templates/settings.tpl', 'conf/config.php');
if (PHPWS_Boost::updateFiles($files, 'filecabinet')) {
$content[] = '--- Copied the following files:';
} else {
$content[] = '--- FAILED copying the following files:';
}
$content[] = " " . implode("\n ", $files);
$db = new PHPWS_DB('images');
if (!$db->isTableColumn('parent_id')) {
if (PHPWS_Error::logIfError($db->addTableColumn('parent_id', 'int NOT NULL default 0'))) {
$content[] = 'Could not create parent_id column in images table.</pre>';
return false;
}
}
if (!$db->isTableColumn('url')) {
if (PHPWS_Error::logIfError($db->addTableColumn('url', 'varchar(255) NULL'))) {
$content[] = 'Could not create url column in images table.</pre>';
return false;
}
}
if (!PHPWS_DB::isTable('multimedia')) {
$result = PHPWS_DB::importFile(PHPWS_SOURCE_DIR . 'mod/filecabinet/boost/multimedia.sql');
if (!PHPWS_Error::logIfError($result)) {
$content[] = '--- Multimedia table created successfully.';
} else {
$content[] = '--- Failed to create multimedia table.</pre>';
return false;
}
}
$content[] = '
1.1.0 changes
--------------
+ Fixed authorized check when unpinning folders
+ Images can now be linked to other pages.
+ Resized images can now be linked to their parent image.
+ Clip option moved outside edit_folder permissions when viewing images.
+ Added writable directory check before allowing new folders to be
created.
//.........这里部分代码省略.........
示例11: hms_update
//.........这里部分代码省略.........
$db->addColumn('term_classification');
$db->addColumn('student_status');
$db->addColumn('preferred_bedtime');
$db->addColumn('room_condition');
$result = $db->select();
if (PEAR::isError($result)) {
return $result;
}
/*
* The following is weird, and I just wanted to take a few minutes
* to explain exactly what the hell is going on here. Any students
* in the database at this point have filled out an application but
* do not have the aggregate number that is used to autoassign
* roommates. What follows generates the appropriate aggregate
* number for each student. The aggregate number is a bitmask that
* will end up looking like this:
*
* Bits Meaning
* 43 term_classification
* 2 student_status
* 1 preferred_bedtime
* 0 room_condition
*
* Unfortunately, this code is duplicated in HMS_Application.
* Fortunately, this code should only be needed once.
*/
$i = 0;
foreach ($result as $row) {
$aggregate = 0;
$aggregate |= $row['term_classification'] - 1 << 3;
$aggregate |= $row['student_status'] - 1 << 2;
$aggregate |= $row['preferred_bedtime'] - 1 << 1;
$aggregate |= $row['room_condition'] - 1;
$db->reset();
$db->addWhere('id', $row['id']);
$db->addValue('aggregate', $aggregate);
$result = $db->update();
if (PEAR::isError($result)) {
return $result;
}
$i++;
}
$content[] = "+ Calculated {$i} aggregates.";
case version_compare($currentVersion, '0.1.22', '<'):
$db = new PHPWS_DB();
$result = $db->importFile(PHPWS_SOURCE_DIR . 'mod/hms/boost/updates/0_1_22.sql');
if (PEAR::isError($result)) {
return $result;
}
$files[] = 'templates/admin/display_room_data.tpl';
$files[] = 'templates/student/profile_search_pager.tpl';
PHPWS_Boost::updateFiles($files, 'hms');
$content[] = "* Fixed bug in pagination of student profile results";
$content[] = '** Bug still exists where search values need to be set in $_SESSION';
$content[] = "+ Added 'displayed room number' to room editing";
$content[] = "+ Added 'displayed room number' to the assign by floor/mass assignment page";
$content[] = "+ Fixed bug in assigned RLC members page where address/telephone number were displaying incorrectly or not at all";
case version_compare($currentVersion, '0.1.23', '<'):
$db = new PHPWS_DB();
$result = $db->importFile(PHPWS_SOURCE_DIR . 'mod/hms/boost/updates/0_1_23.sql');
if (PEAR::isError($result)) {
return $result;
}
$content[] = '+ Increased length of the asu_username field for RLC assignments';
$content[] = '+ Added stateful pagination when assigning people to RLCs';
$content[] = '+ Corrected count when viewing the Learning Community Assignments';
示例12: lengthenLinks
private function lengthenLinks()
{
$db = new PHPWS_DB('menu_links');
$db->addColumn('id');
$db->addColumn('url');
$db->addColumn('key_id');
$db->addWhere('url', 'pagesmith/[0-9]+$', 'regexp');
$result = $db->select();
if (empty($result)) {
return true;
} elseif (PHPWS_Error::logIfError($result)) {
return false;
}
$db->reset();
$db2 = new PHPWS_DB('phpws_key');
foreach ($result as $link) {
$link['url'] = preg_replace('@pagesmith/(\\d+)$@', 'index.php?module=pagesmith&uop=view_page&id=\\1', $link['url']);
$db->addValue($link);
$db->addWhere('id', $link['id']);
if (!PHPWS_Error::logIfError($db->update()) && $link['key_id']) {
$db2->addValue('url', $link['url']);
$db2->addWhere('id', $link['key_id']);
PHPWS_Error::logIfError($db2->update());
$db2->reset();
}
$db->reset();
}
}
示例13: doMove
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);
}
示例14: reorderLinks
public function reorderLinks()
{
if (!$this->id) {
return false;
}
$db = new PHPWS_DB('menu_links');
$db->addWhere('menu_id', $this->id);
$db->addColumn('id');
$db->addColumn('parent');
$db->addColumn('link_order');
$db->addOrder('link_order');
$db->setIndexBy('parent');
$result = $db->select();
if (empty($result)) {
return;
}
foreach ($result as $parent_id => $links) {
if (empty($links)) {
continue;
}
$count = 1;
if (isset($links[0])) {
foreach ($links as $link) {
$db->reset();
$db->addWhere('id', $link['id']);
$db->addValue('link_order', $count);
PHPWS_Error::logIfError($db->update());
$count++;
}
} else {
$db->reset();
$db->addWhere('id', $links['id']);
$db->addValue('link_order', $count);
PHPWS_Error::logIfError($db->update());
}
}
return true;
}
示例15: users_update
/**
* @author Matthew McNaney <mcnaney at gmail dot com>
* @version $Id$
*/
function users_update(&$content, $currentVersion)
{
$home_dir = PHPWS_Boost::getHomeDir();
switch ($currentVersion) {
case version_compare($currentVersion, '2.2.0', '<'):
$content[] = 'This package does not update versions under 2.2.0';
return false;
case version_compare($currentVersion, '2.2.1', '<'):
$content[] = '+ Fixed a bug causing conflicts between user and group permissions.';
case version_compare($currentVersion, '2.2.2', '<'):
$content[] = '+ Set username to the same character size in both users table and user_authorization.';
$content[] = '+ Fixed typo causing branch installation failure on Postgresql.';
case version_compare($currentVersion, '2.3.0', '<'):
$content[] = '<pre>
2.3.0 changes
------------------------
+ Added translate function calls in classes and my_page.php
+ my_page hides translation option if language defines disable selection
+ Added a unrestricted only parameter to Current_User\'s allow and
authorize functions
+ Dropped references from some constructors
+ Added error check to setPermissions function: won\'t accept empty
group id
+ Changed id default to zero.
+ Removed unneeded function parameter on getGroups
</pre>
';
case version_compare($currentVersion, '2.3.1', '<'):
$content[] = '<pre>';
$files = array('templates/my_page/user_setting.tpl');
userUpdateFiles($files, $content);
$content[] = '
2.3.1 changes
------------------------
+ Added ability for user to set editor preferences
</pre>
';
case version_compare($currentVersion, '2.3.2', '<'):
$content[] = '<pre>2.3.2 changes';
$files = array('img/users.png', 'templates/user_main.tpl');
userUpdateFiles($files, $content);
$content[] = '+ Added error check to login.
+ Changed user control panel icon.
+ Fixed template typo that broke IE login.
+ Removed fake French translation (delete mod/users/locale/fr_FR/ directory
+ Permissions are now ordered alphabetically.
+ isUser will now always return false if passed a zero id.
+ Added new function requireLogin that forwards a user to the login
screen
</pre>';
case version_compare($currentVersion, '2.4.0', '<'):
if (!PHPWS_DB::isTable('users_pw_reset')) {
$new_table = 'CREATE TABLE users_pw_reset (
user_id INT NOT NULL default 0,
authhash CHAR( 32 ) NOT NULL default 0,
timeout INT NOT NULL default 0,
);';
if (!PHPWS_DB::import($new_table)) {
$content[] = 'Unable to create users_pw_reset table.';
return false;
} else {
$content[] = 'Created new table: users_pw_reset';
}
}
$files = array('templates/forms/reset_password.tpl', 'templates/forms/forgot.tpl', 'conf/config.php', 'templates/usermenus/top.tpl', 'templates/forms/settings.tpl', 'templates/my_page/user_setting.tpl');
$content[] = '<pre>';
userUpdatefiles($files, $content);
if (!PHPWS_Boost::inBranch()) {
$content[] = file_get_contents(PHPWS_SOURCE_DIR . 'mod/users/boost/changes/2_4_0.txt');
}
$content[] = '</pre>';
case version_compare($currentVersion, '2.4.1', '<'):
$content[] = '<pre>';
$files = array('conf/languages.php');
userUpdateFiles($files, $content);
$content[] = '
2.4.1 changes
------------------------
+ Default item id on permission check functions is now zero instead of
null. This will make checking permissions a little easier on new items.
+ Bug #1690657 - Changed group select js property to onclick instead
of onchange. Thanks singletrack.
+ Changed the language abbreviation for Danish
</pre>
';
case version_compare($currentVersion, '2.4.2', '<'):
$content[] = '<pre>';
$files = array('templates/usermenus/Default.tpl');
userUpdateFiles($files, $content);
if (!PHPWS_Boost::inBranch()) {
$content[] = file_get_contents(PHPWS_SOURCE_DIR . 'mod/users/boost/changes/2_4_2.txt');
}
$content[] = '</pre>';
case version_compare($currentVersion, '2.4.3', '<'):
$content[] = '<pre>';
if (!PHPWS_Boost::inBranch()) {
//.........这里部分代码省略.........