/** * Uninstall file for PhatForm v2 * * Rewritten to work with phpwebsite 1.0 * @version $Id$ */ function phatform_uninstall(&$content) { $db = new PHPWS_DB('mod_phatform_forms'); $db->addColumn('id'); $db->addColumn('archiveTableName'); $db->addWhere('saved', 1); $result = $db->select(); if (!empty($result)) { foreach ($result as $form) { if (empty($form['archiveTableName'])) { $table = 'mod_phatform_form_' . $form['id']; if (PHPWS_DB::isTable($table)) { PHPWS_DB::dropTable($table); } } else { $table = $form['archiveTableName']; PHPWS_DB::dropTable($table); } } $content[] = dgettext('phatform', 'Removed all dynamic Form Generator tables.'); } PHPWS_DB::dropTable('mod_phatform_forms'); PHPWS_DB::dropTable('mod_phatform_options'); PHPWS_DB::dropTable('mod_phatform_textfield'); PHPWS_DB::dropTable('mod_phatform_textarea'); PHPWS_DB::dropTable('mod_phatform_dropbox'); PHPWS_DB::dropTable('mod_phatform_multiselect'); PHPWS_DB::dropTable('mod_phatform_radiobutton'); PHPWS_DB::dropTable('mod_phatform_checkbox'); $content[] = dgettext('phatform', 'All Form Generator static tables removed.'); return TRUE; }
/** * @author Matthew McNaney <mcnaney at gmail dot com> * @version $Id$ */ function calendar_uninstall(&$content) { PHPWS_Core::initModClass('calendar', 'Schedule.php'); // Need functions to remove old event tables $db = new PHPWS_DB('calendar_schedule'); $schedules = $db->getObjects('Calendar_Schedule'); if (PHPWS_Error::isError($schedules)) { return $schedules; } elseif (empty($schedules)) { $result = PHPWS_DB::dropTable('calendar_schedule'); if (PHPWS_Error::isError($result)) { return $result; } $result = PHPWS_DB::dropTable('calendar_notice'); if (PHPWS_Error::isError($result)) { return $result; } $result = PHPWS_DB::dropTable('calendar_suggestions'); if (PHPWS_Error::isError($result)) { return $result; } return true; } $error = false; foreach ($schedules as $sch) { $result = $sch->delete(); if (PHPWS_Error::isError($result)) { PHPWS_Error::log($result); $error = true; } } $result = PHPWS_DB::dropTable('calendar_schedule'); if (PHPWS_Error::isError($result)) { return $result; } $result = PHPWS_DB::dropTable('calendar_notice'); if (PHPWS_Error::isError($result)) { return $result; } $result = PHPWS_DB::dropTable('calendar_suggestions'); if (PHPWS_Error::isError($result)) { return $result; } if (PHPWS_DB::isTable('converted')) { $db2 = new PHPWS_DB('converted'); $db2->addWhere('convert_name', array('schedule', 'calendar')); $db2->delete(); $content[] = dgettext('calendar', 'Removed convert flag.'); } if (!$error) { $content[] = dgettext('calendar', 'Calendar tables removed.'); } else { $content[] = dgettext('calendar', 'Some errors occurred when uninstalling Calendar.'); } return true; }
function _confirmArchive() { if (isset($_REQUEST['PHAT_ArchiveConfirm'])) { include PHPWS_SOURCE_DIR . 'mod/phatform/inc/Archive.php'; $error = NULL; $error = archive($this->getId()); if (PHPWS_Error::isError($error)) { PHPWS_Error::log($error); javascript('alert', array('content' => dgettext('phatform', 'Failed to archive.'))); unset($_REQUEST['PHAT_ArchiveConfirm']); unset($error); $_REQUEST['PHAT_FORM_OP'] = 'ArchiveConfirm'; $this->action(); return; } $this->_saved = 0; $this->_position = 0; $sql = 'UPDATE mod_phatform_forms SET saved=\'' . $this->_saved . "' WHERE id='" . $this->getId() . "'"; PHPWS_DB::query($sql); $sql = 'DROP TABLE mod_phatform_form_' . $this->getId(); PHPWS_DB::query($sql); $table = 'mod_phatform_form_' . $this->getId() . '_seq'; if (PHPWS_DB::isTable($table)) { $sql = 'DROP TABLE ' . $table; PHPWS_DB::query($sql); } $_REQUEST['PHAT_FORM_OP'] = 'EditAction'; $_REQUEST['PHAT_Submit'] = 1; $this->action(); } else { if (isset($_REQUEST['PHAT_ArchiveCancel'])) { $_REQUEST['PHAT_MAN_OP'] = 'List'; $_SESSION['PHAT_FormManager']->action(); } else { $hiddens['module'] = 'phatform'; $hiddens['PHAT_FORM_OP'] = 'ArchiveConfirm'; foreach ($hiddens as $key => $value) { $eles[] = PHPWS_Form::formHidden($key, $value); } $elements[0] = implode("\n", $eles); $confirmTags['WARNING_TAG'] = dgettext('phatform', 'WARNING!'); $confirmTags['MESSAGE'] = dgettext('phatform', 'You have chosen to edit a saved form! All current data will be archived and cleared if you chose to continue! Make sure you export your data from your form before you continue!'); $confirmTags['CANCEL_BUTTON'] = PHPWS_Form::formSubmit(dgettext('phatform', 'Cancel'), 'PHAT_ArchiveCancel'); $confirmTags['CONFIRM_BUTTON'] = PHPWS_Form::formSubmit(dgettext('phatform', 'Confirm'), 'PHAT_ArchiveConfirm'); $elements[0] .= PHPWS_Template::processTemplate($confirmTags, 'phatform', 'form/archiveConfirm.tpl'); $content = PHPWS_Form::makeForm('PHAT_FormArchiveConfirm', 'index.php', $elements); $GLOBALS['CNT_phatform']['title'] = dgettext('phatform', 'Form') . ': ' . $this->getLabel(); $GLOBALS['CNT_phatform']['content'] .= $content; } } }
/** * Static call only * check_existence - of table * sequence_table - if true, drop sequence table as well */ public static function dropTable($table, $check_existence = true, $sequence_table = true) { PHPWS_DB::touchDB(); // was using IF EXISTS but not cross compatible if ($check_existence && !PHPWS_DB::isTable($table)) { return true; } $result = PHPWS_DB::query("DROP TABLE {$table}"); if (PHPWS_Error::isError($result)) { return $result; } if ($sequence_table && PHPWS_DB::isSequence($table)) { $result = $GLOBALS['PHPWS_DB']['lib']->dropSequence($table . '_seq'); if (PHPWS_Error::isError($result)) { return $result; } } return true; }
/** * Returns the core version. * * @param boolean get_file If true, uses the boost.php file, if false * uses the database version. */ public static function getVersionInfo($get_file = true) { $file = PHPWS_SOURCE_DIR . 'core/boost/boost.php'; include $file; if (!$get_file) { if (!PHPWS_DB::isTable('core_version')) { $version = '1.0.0'; } else { $db = new PHPWS_DB('core_version'); $db->addColumn('version'); $version = $db->select('one'); } } return array('proper_name' => $proper_name, 'version' => $version, 'version_http' => $version_http); }
/** * @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. + Fixed some error messages in File_Common. + Commented out ext variable in File_Common. Doesn\'t appear to be in use. + Created setDirectory function for File_Common. Assures trailing forward slash on directory name. + Removed itemname variable from Document_Manager + Added ability to classify uploaded files. + New folder class - Multimedia + Multimedia files can be clipped and pasted via SmartTags. </pre> '; case version_compare($version, '1.2.0', '<'): $content[] = '<pre>'; $files = array('img/no_image.png', 'conf/config.php', 'conf/video_types.php', 'conf/embedded.php', 'javascript/folder_contents/head.js', 'javascript/clear_image/head.js', 'javascript/clear_image/body.js', 'javascript/pick_image/head.js', 'templates/image_folders.tpl', 'templates/settings.tpl', 'templates/style.css', 'templates/image_view.tpl', 'templates/multimedia_view.tpl', 'templates/style.css', 'img/video_generic.png', 'templates/image_edit.tpl', 'conf/error.php'); fc_updatefiles($files, $content); if (!PHPWS_Boost::inBranch()) { $content[] = file_get_contents(PHPWS_SOURCE_DIR . 'mod/filecabinet/boost/changes/1_2_0.txt'); } $content[] = '</pre>'; case version_compare($version, '1.2.1', '<'): $content[] = '<pre>'; if (!PHPWS_DB::isTable('filecabinet_pins')) { $db = new PHPWS_DB('filecabinet_pins'); $db->addValue('key_id', 'int not null default 0'); $db->addValue('folder_id', 'int not null default 0'); if (PHPWS_Error::logIfError($db->createTable())) { $content[] = 'Failed to create filecabinet_pins table.</pre>'; return false; } $content[] = '--- Created filecabinet_pins table.'; } $files = array('templates/settings.tpl'); fc_updatefiles($files, $content); if (!PHPWS_Boost::inBranch()) { $content[] = file_get_contents(PHPWS_SOURCE_DIR . 'mod/filecabinet/boost/changes/1_2_1.txt'); } $content[] = '</pre>'; case version_compare($version, '1.2.2', '<'): $content[] = '<pre>'; $files = array('templates/image_edit.tpl'); fc_updatefiles($files, $content); if (!PHPWS_Boost::inBranch()) { $content[] = file_get_contents(PHPWS_SOURCE_DIR . 'mod/filecabinet/boost/changes/1_2_2.txt'); } $content[] = '</pre>'; case version_compare($version, '1.3.0', '<'): $content[] = '<pre>'; $db = new PHPWS_DB('folders'); if (!$db->isTableColumn('module_created')) { if (PHPWS_Error::logIfError($db->addTableColumn('module_created', 'varchar(40) default null'))) { $content[] = '--- Could not create column module_created on folders table.</pre>'; return false; } else { $content[] = '--- Created module_created column on folders table.'; } } $db = new PHPWS_DB('multimedia'); $result = $db->addTableColumn('thumbnail', 'varchar(255) not null'); if (PHPWS_Error::logIfError($result)) { $content[] = '--- Unable to add thumbnail column to multimedia table.</pre>'; return false; } else { $content[] = '--- Added thumbnail column to multimedia table.'; } $s1 = PHPWS_SOURCE_DIR . 'mod/filecabinet/templates/filters/flash/'; $d1 = $home_dir . 'templates/filecabinet/filters/flash/'; $s2 = PHPWS_SOURCE_DIR . 'mod/filecabinet/img/icons/'; $d2 = $home_dir . 'images/mod/filecabinet/icons/'; if (PHPWS_File::copy_directory($s1, $d1)) { $content[] = "--- Successfully copied {$s1} to {$d1}"; } else { $content[] = "--- Failed to copy {$s1} to {$d1}</pre>"; return false; } if (PHPWS_File::copy_directory($s2, $d2)) { $content[] = "--- Successfully copied {$s2} to {$d2}"; } else { $content[] = "--- Failed to copy {$s2} to {$d2}</pre>"; return false; } $content[] = ''; $files = array('conf/error.php', 'conf/config.php', 'templates/filters/flash.tpl', 'templates/file_list.tpl', 'templates/multimedia_edit.tpl', 'templates/settings.tpl', 'templates/style.css', 'templates/thumbnail.tpl', 'templates/image_edit.tpl', 'javascript/pick_image/head.js', 'templates/folder_list.tpl', 'templates/manager/pick.tpl', 'img/delete.png'); fc_updatefiles($files, $content); if (!PHPWS_Boost::inBranch()) { $content[] = file_get_contents(PHPWS_SOURCE_DIR . 'mod/filecabinet/boost/changes/1_3_0.txt'); } $content[] = '</pre>'; case version_compare($version, '1.4.0', '<'): $content[] = '<pre>'; $files = array('javascript/folder_contents/head.js', 'javascript/folder_contents/scripts.js', 'javascript/pick_image/head.js', 'javascript/pick_image/scripts.js', 'javascript/clear_image/body.js', 'javascript/clear_image/head.js', 'templates/style.css', 'templates/settings.tpl'); fc_updatefiles($files, $content); if (!PHPWS_Boost::inBranch()) { $content[] = file_get_contents(PHPWS_SOURCE_DIR . 'mod/filecabinet/boost/changes/1_4_0.txt'); } $content[] = '</pre>'; case version_compare($version, '1.4.1', '<'): $content[] = '<pre>'; $db = new PHPWS_DB('folders'); if (!$db->isTableColumn('module_created')) { if (PHPWS_Error::logIfError($db->addTableColumn('module_created', 'varchar(40) default null'))) { $content[] = '--- Could not create column module_created on folders table.</pre>'; return false; } else { $content[] = '--- Created module_created column on folders table.'; } } $content[] = '1.4.1 changes -------------- + module_created column missing from > 1.3.0 install. </pre>'; case version_compare($version, '1.4.2', '<'): $content[] = '<pre> 1.4.2 changes -------------- + Removed test echo 1 + moved all defines to one file. </pre>'; case version_compare($version, '2.0.0', '<'): $content[] = '<pre>'; if (PHPWS_File::copy_directory(PHPWS_SOURCE_DIR . 'mod/filecabinet/templates/', $home_dir . 'templates/filecabinet/')) { $content[] = '--- Copied complete templates directory.'; } else { $content[] = '--- Could not copy complete templates directory. Use revert or copy manually.'; } if (PHPWS_File::copy_directory(PHPWS_SOURCE_DIR . 'mod/filecabinet/img/', $home_dir . 'images/mod/filecabinet/')) { $content[] = '--- Copied complete images directory.'; } else { $content[] = '--- Could not copy complete images directory. Use revert or copy manually.'; } if (PHPWS_File::copy_directory(PHPWS_SOURCE_DIR . 'mod/filecabinet/conf/', $home_dir . 'config/filecabinet/')) { $content[] = '--- Copied complete configuration directory.'; } else { $content[] = '--- Could not copy complete configuration directory. Use revert or copy manually.'; } if (PHPWS_File::copy_directory(PHPWS_SOURCE_DIR . 'mod/filecabinet/javascript/', $home_dir . 'javascript/modules/filecabinet/')) { $content[] = '--- Copied complete javascript directory.'; } else { $content[] = '--- Could not copy complete javascript directory. Use revert or copy manually.'; } if (!PHPWS_DB::isTable('fc_convert')) { $result = PHPWS_DB::importFile(PHPWS_SOURCE_DIR . 'mod/filecabinet/boost/fc_convert.sql'); if (!PHPWS_Error::logIfError($result)) { $content[] = '--- File conversion table created successfully.'; } else { $content[] = '--- Failed to create File conversion table.</pre>'; return false; } } if (!PHPWS_DB::isTable('fc_file_assoc')) { $result = PHPWS_DB::importFile(PHPWS_SOURCE_DIR . 'mod/filecabinet/boost/file_assoc.sql'); if (!PHPWS_Error::logIfError($result)) { $content[] = '--- File assoc table created successfully.'; } else { $content[] = '--- Failed to create File assoc table.</pre>'; return false; } } $db = new PHPWS_DB('multimedia'); if (!$db->isTableColumn('duration')) { if (PHPWS_Error::logIfError($db->addTableColumn('duration', 'int not null default 0'))) { $content[] = '--- Failed to create duration column on multimedia table.</pre>'; return false; } else { $content[] = '--- Created duration column on multimedia table.'; } } if (!$db->isTableColumn('embedded')) { if (PHPWS_Error::logIfError($db->addTableColumn('embedded', 'smallint not null default 0'))) { $content[] = 'Failed to create embedded column on multimedia table.</pre>'; return false; } else { $content[] = '--- Created embedded column on multimedia table.'; } } PHPWS_Core::initModClass('filecabinet', 'Multimedia.php'); $result = $db->getObjects('PHPWS_Multimedia'); if ($result) { foreach ($result as $mm) { $mm->loadDimensions(); PHPWS_Error::logIfError($mm->save()); } } $content[] = '--- Durations added to multimedia files.'; fc_update_parent_links(); if (!checkMultimediaDir($content, $home_dir)) { return false; } if (!PHPWS_Boost::inBranch()) { $content[] = file_get_contents(PHPWS_SOURCE_DIR . 'mod/filecabinet/boost/changes/2_0_0.txt'); } $content[] = '</pre>'; case version_compare($version, '2.0.1', '<'): $content[] = '<pre>2.0.1 changes ------------- + Updated youTube import. + Removed unused code.</pre>'; case version_compare($version, '2.1.0', '<'): $content[] = '<pre>'; $files = array('templates/image_view.tpl', 'templates/settings.tpl', 'javascript/pick_file/head.js', 'javascript/pick_file/scripts.js', 'javascript/update_file/head.js', 'templates/file_manager/placeholder.tpl', 'templates/document_edit.tpl', 'templates/image_edit.tpl', 'templates/multimedia_edit.tpl', 'templates/edit_folder.tpl', 'templates/embed_edit.tpl', 'templates/style.css', 'templates/file_manager/folder_content_view.tpl', 'templates/file_manager/resize.tpl'); fc_updatefiles($files, $content); $db = new PHPWS_DB('folders'); $db->begin(); if (PHPWS_Error::logIfError($db->addTableColumn('max_image_dimension', 'smallint not null default 0'))) { $content[] = '--- Unable to add max_image_dimension column to folders table.'; $db->rollback(); return false; } else { $content[] = '--- Added max_image_dimension column to folders table.'; } $db = new PHPWS_DB('fc_file_assoc'); if (PHPWS_Error::logIfError($db->addTableColumn('width', 'smallint NOT NULL default 0'))) { $content[] = '--- Unable to add width column to fc_file_assoc.'; $db->rollback(); return false; } else { $content[] = '--- Added width column to fc_file_assoc table'; } if (PHPWS_Error::logIfError($db->addTableColumn('height', 'smallint NOT NULL default 0'))) { $content[] = '--- Unable to add height column to fc_file_assoc.'; $db->rollback(); return false; } else { $content[] = '--- Added height column to fc_file_assoc table'; } if (PHPWS_Error::logIfError($db->addTableColumn('cropped', 'smallint NOT NULL default 0'))) { $content[] = '--- Unable to add cropped column to fc_file_assoc.'; $db->rollback(); return false; } else { $content[] = '--- Added cropped column to fc_file_assoc table'; } $db->commit(); if (!PHPWS_Boost::inBranch()) { $content[] = file_get_contents(PHPWS_SOURCE_DIR . 'mod/filecabinet/boost/changes/2_1_0.txt'); } $content[] = '</pre>'; case version_compare($version, '2.2.0', '<'): $content[] = '<pre>'; $db = new PHPWS_DB('fc_file_assoc'); if (PHPWS_Error::logIfError($db->addTableColumn('vertical', 'smallint not null default 0'))) { $content[] = 'Unable to create vertical column in fc_file_assoc table.'; return false; } if (PHPWS_Error::logIfError($db->addTableColumn('num_visible', 'smallint not null default 3'))) { $content[] = 'Unable to create num_visible column in fc_file_assoc table.'; return false; } $db->dropTableColumn('cropped'); $db = new PHPWS_DB('modules'); $db->addWhere('title', 'filecabinet'); $db->addValue('unregister', 1); PHPWS_Error::logIfError($db->update()); $content[] = 'Unregister flag set in modules table.'; $files = array('javascript/jcaro_lite/', 'javascript/shutter/', 'javascript/pick_file/', 'javascript/update_file/head.js', 'javascript/update_file/default.php', 'javascript/clear_file/body.js', 'javascript/clear_file/head.js', 'javascript/clear_file/default.php', 'templates/image_view.tpl', 'templates/carousel_horz.tpl', 'templates/carousel_vert.tpl', 'templates/classify_list.tpl', 'templates/ss_box.tpl', 'templates/file_manager/carousel_pick.tpl', 'templates/file_manager/folder_content_view.tpl', 'templates/settings.tpl', 'templates/style.css', 'templates/file_list.tpl', 'templates/folder_list.tpl', 'templates/pinned.tpl', 'img/add.png', 'img/arrow_left.png', 'img/arrow_right.png', 'conf/icons.php', 'conf/config.php'); fc_updatefiles($files, $content); if (!PHPWS_Boost::inBranch()) { $content[] = file_get_contents(PHPWS_SOURCE_DIR . 'mod/filecabinet/boost/changes/2_2_0.txt'); } case version_compare($version, '2.2.1', '<'): $content[] = '<pre> 2.2.1 changes ----------------------- + Fixed folder deletion. + Clipped documents and images now have full pathing. + Fixed document smarttag</pre>'; case version_compare($version, '2.2.2', '<'): $content[] = '<pre>'; $files = array('img/mime_types/', 'templates/document_download.tpl', 'templates/file_view.css', 'templates/multi_doc_download.tpl'); fc_updatefiles($files, $content); $content[] = '2.2.2 changes ----------------------- + Fixed edit icon in document view. Needed to be salted. + Added error check to prevent possible divide by zero error. + Resized mime type icons + Changed the document download windows. Simplified. + Fixed image edit link. + Added pptm to known types. + Fixed permission checks on folders.</pre>'; case version_compare($version, '2.2.3', '<'): $content[] = '<pre>2.2.3 changes ----------------------- + Fixed document delete link</pre>'; case version_compare($version, '2.2.4', '<'): $content[] = '<pre>'; $files = array('templates/fckeditor.tpl', 'templates/fckdocuments.tpl', 'templates/fck.css', 'templates/fckimages.tpl', 'templates/fckfolders.tpl', 'templates/folder_list.tpl', 'templates/settings.tpl', 'img/folder.gif', 'javascript/fckeditor/'); fc_updatefiles($files, $content); $content[] = '2.2.4 changes ----------------------- + Error checking added to document upload. + Fixed multimedia folder pager. + Added method for fixing document directories. + Added file search to folder pager. + Added File Cabinet FCKeditor interaction. + Cleaned up so interface issues. </pre>'; case version_compare($version, '2.2.5', '<'): $content[] = '<pre>2.2.5 changes ----------------------- + Fixed bug that displayed error message on document upload. + Proper error message now on document uploaded to unwritable directory + Directory check on unwritable directory prevents upload link</pre>'; case version_compare($version, '2.2.6', '<'): $content[] = '<pre>'; $files = array('javascript/fckeditor/head.js', 'templates/fck.css'); fc_updatefiles($files, $content); $content[] = '2.2.6 changes ----------------------- + Fixed bug with editing Multimedia. + Fixed bug with File Cabinet in FCKeditor not loading folders properly. </pre>'; case version_compare($version, '2.2.7', '<'): $content[] = '<pre>'; $files = array('javascript/fckeditor/head.js', 'templates/filters/media/mediaplayer.swf', 'templates/filters/media/yt.swf'); fc_updatefiles($files, $content); $content[] = '2.2.7 changes ----------------------- + Added trim to ffmpeg file directory + Added description to search for files + Media player updated to latest version. + FCKeditor media insertion had problems with any media other than YouTube embeds. SmartTag for media is displayed instead.</pre>'; case version_compare($version, '2.3.0', '<'): $content[] = '<pre>2.3.0 changes --------------------- + Icon class implemented. + Video player changed to Flowplayer. + Lightbox option for public folders. + Image carousel switched to jcarousel with Lightbox usage. + Updated to work with core updates.</pre>'; case version_compare($version, '2.3.1', '<'): $content[] = '<pre>2.3.1 changes --------------------- + Setting added to allow direct links to documents + Fixed captioned image template</pre>'; case version_compare($version, '2.3.2', '<'): $content[] = '<pre>2.3.2 changes --------------------- + Changing public flag to private on document folders creates .htaccess file preventing world access + Added mp4/m4v to multimedia class. </pre>'; case version_compare($version, '2.4.0', '<'): $content[] = '<pre>2.4.0 changes --------------------- + Heavy ckeditor modifications. + rtmp support added. + Removed FCK code where found. + Minified some scripts. + Failed image upload will now display an error. + Can now add Access shortcut to a document. + Various bug fixes </pre>'; case version_compare($version, '2.4.1', '<'): $content[] = '<pre>2.4.1 changes ----------------------- + Fixed a possible XSS vulnerability discovered by Jakub Galczyk. + Users must have some File Cabinet permission to use the File Manager. </pre>'; case version_compare($version, '2.4.2', '<'): $content[] = '<pre>2.4.2 changes ----------------------- + Added error logging to image resize. </pre>'; case version_compare($version, '2.4.3', '<'): $content[] = '<pre>2.4.3 changes ----------------------- + Added checkbox in Settings to turn off autofloating of images in the ckeditor. </pre>'; case version_compare($version, '2.4.4', '<'): $content[] = '<pre>2.4.4 changes ----------------------- + Removed clipboard functionality. Confused users and was not + Bootstrap icons and styles added. </pre>'; case version_compare($version, '2.5.0', '<'): $content[] = '<pre>2.5.0 changes ----------------------- + img-responsive added to inserted images to work with Bootstrap + removed image widths and heights + Cropping and resizing removed from manager + Manager made larger. + Manager upload header fixed position </pre>'; case version_compare($version, '2.6.0', '<'): $content[] = <<<EOF <pre>2.6.0 changes ---------------- + Removed call to updateTag as it does not work. + Removed calls to Layout Cache (which was removed) + Updated filecabinet to work with ckeditor 4. + Updated ckeditor 4 filecabinet pop up layout. + Thumbnails of uploaded images are not shown. </pre> EOF; case version_compare($version, '2.7.0', '<'): $db = \Database::newDB(); $t1 = $db->addTable('folders'); $t1->addValue('module_created', null); $db->update(); $content[] = <<<EOF <pre>2.7.0 changes ---------------- + Javascript windows replaced with Bootstrap modal dropdowns. + Fixed thumbnail form. + Removed module_created for all folders. </pre> EOF; case version_compare($version, '2.8.0', '<'): $content[] = <<<EOF <pre>2.8.0 changes ---------------- + Rewrote CKEditor interaction with Filecabinet. Images and documents functional, multimedia uploads not complete. </pre> EOF; return true; } }
/** * @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()) { $content[] = file_get_contents(PHPWS_SOURCE_DIR . 'mod/users/boost/changes/2_4_3.txt'); } $content[] = '</pre>'; case version_compare($currentVersion, '2.4.4', '<'): $content[] = '<pre>'; $source_dir = PHPWS_SOURCE_DIR . 'mod/users/javascript/'; $dest_dir = $home_dir . 'javascript/modules/users/'; if (PHPWS_File::copy_directory($source_dir, $dest_dir, true)) { $content[] = "--- Successfully copied {$source_dir} to {$dest_dir}"; } else { $content[] = "--- Could not copy {$source_dir} to {$dest_dir}"; } $files = array('conf/error.php', 'templates/forms/permissions.tpl', 'templates/forms/permission_pop.tpl'); userUpdateFiles($files, $content); if (!PHPWS_Boost::inBranch()) { $content[] = file_get_contents(PHPWS_SOURCE_DIR . 'mod/users/boost/changes/2_4_4.txt'); } $content[] = '</pre>'; case version_compare($currentVersion, '2.4.5', '<'): $content[] = '<pre>'; $files = array('conf/error.php', 'conf/languages.php', 'templates/forms/settings.tpl', 'templates/manager/groups.tpl'); userUpdateFiles($files, $content); if (!PHPWS_Boost::inBranch()) { $content[] = file_get_contents(PHPWS_SOURCE_DIR . 'mod/users/boost/changes/2_4_5.txt'); } $content[] = '</pre>'; case version_compare($currentVersion, '2.4.6', '<'): $content[] = '<pre>'; $files = array('templates/forms/forgot.tpl'); userUpdateFiles($files, $content); if (!PHPWS_Boost::inBranch()) { $content[] = ' 2.4.6 changes ------------------- + Added error check to permission menu. + Error for missing user groups now reports user id. + Forgot password will work if CAPTCHA is disabled. + Using new savePermissions function instead of save. + Current_User was calling giveItemPermissions incorrectly.'; } $content[] = '</pre>'; case version_compare($currentVersion, '2.4.7', '<'): $content[] = '<pre> 2.4.7 changes ------------------- + Removed global authorization from change password check since it is not written yet. </pre>'; case version_compare($currentVersion, '2.4.9', '<'): $content[] = '<pre>'; if (PHPWS_Core::isBranch() || PHPWS_Boost::inBranch()) { $user_db = new PHPWS_DB('users'); $user_db->addWhere('deity', 1); $user_db->addColumn('id'); $user_db->addColumn('username'); $user_db->setIndexBy('id'); $user_ids = $user_db->select('col'); if (!empty($user_ids) && !PHPWS_Error::logIfError($user_ids)) { $group_db = new PHPWS_DB('users_groups'); foreach ($user_ids as $id => $username) { $group_db->addWhere('user_id', $id); $result = $group_db->select('row'); if (!$result) { $group_db->reset(); $group_db->addValue('active', 1); $group_db->addValue('name', $username); $group_db->addValue('user_id', $id); if (!PHPWS_Error::logIfError($group_db->insert())) { $content[] = '--- Created missing group for user: '******'2.4.9 changes ----------------- + Raised sql character limit in default username, display_name, and group name installs. + Fixed bug with forbidden usernames + Added a function to group to remove its permissions upon deletion. + Bookmark won\'t return a user to a authkey page if their session dies. + Fixed bug #1850815 : unknown function itemIsAllowed in Permission.php + My Pages are unregistered on module removal. + My Page tab stays fixed. </pre>'; case version_compare($currentVersion, '2.5.0', '<'): $content[] = '<pre>'; $files = array('templates/forms/memberlist.tpl', 'templates/forms/userForm.tpl', 'javascript/generate/head.js', 'templates/manager/groups.tpl', 'templates/manager/users.tpl'); userUpdateFiles($files, $content); $content[] = '2.5.0 changes ------------------- + Members\' names alphabetized + New user email notification added. + Fixed member listing dropping names past 10. + Added random password generator on user edit form. + Removed reference from Action.php causing php notice. + Changed redundant static method call in Permission. + Added dash to allowed display name characters. + Added \\pL to display name characters. + Users will now query modules should a user get deleted. + Added an error check to Permissions. + Users will now look for remove_user.php in all modules\' inc/ directory in order to run the remove_user function. + Using pager\'s addSortHeaders in user and group listing + Added display name to pager search. </pre>'; case version_compare($currentVersion, '2.6.0', '<'): $content[] = '<pre>'; Users_Permission::registerPermissions('users', $content); $db = new PHPWS_DB('users_auth_scripts'); $db->addWhere('filename', 'local.php'); $db->addColumn('id'); $auth_id = $db->select('one'); PHPWS_Settings::set('users', 'local_script', $auth_id); PHPWS_Settings::save('users'); $files = array('conf/languages.php', 'templates/my_page/user_setting.tpl', 'templates/usermenus/css.tpl', 'img/permission.png', 'templates/forms/userForm.tpl'); userUpdateFiles($files, $content); if (!PHPWS_Boost::inBranch()) { $content[] = file_get_contents(PHPWS_SOURCE_DIR . 'mod/users/boost/changes/2_6_0.txt'); } $content[] = '</pre>'; case version_compare($currentVersion, '2.6.1', '<'): $content[] = '<pre>2.6.1 changes ------------------ + requireLogin now reroutes dependant on the user authorization + If the user\'s group is missing when they are updated, a new one is properly created. Prior to the fix, a new group was created without an assigned user id. + Added error message to my page if update goes bad. </pre>'; case version_compare($currentVersion, '2.6.2', '<'): $content[] = '<pre>'; $files = array('templates/forms/settings.tpl'); userUpdateFiles($files, $content); $content[] = '2.6.2 changes ------------------ + Moved error file to inc/ + Blank passwords forbidden. + Error check added to cosign authorization. + php fiveasized the classes. + Added some needed error logging to user creation problems + Added ability for default user groups to be set for admin created and newly joined users. + Fixed testing on addMembers. Previous code was nonsensical. + _user_group id gets set upon a user object save. </pre>'; case version_compare($currentVersion, '2.6.3', '<'): $content[] = '<pre>'; $files = array('img/deity.gif', 'img/delete.png', 'img/edit.png', 'img/man.gif', 'img/key.png', 'img/members.png', 'templates/forms/authorization.tpl', 'templates/forms/settings.tpl', 'templates/manager/users.tpl'); userUpdateFiles($files, $content); $db = new PHPWS_DB('users_auth_scripts'); PHPWS_Error::logIfError($db->addTableColumn('default_group', 'int not null default 0')); $content[] = '2.6.3 changes ------------------ + Added icons for admin options under manage users and groups + Disabled active link in groups listing + Authorization scripts now have default group assignments. New members will assigned to a group based on their authorization method. + Removed default group by user or admin from settings. + Added ability to view users by whether or not they are in a particular group. + Added pager caching to group listing + Display name may now not be the same as another user\'s username + Extended user name error to include display name + Added empty password check to ldap script </pre>'; case version_compare($currentVersion, '2.6.4', '<'): $db = new PHPWS_DB('users_auth_scripts'); PHPWS_Error::logIfError($db->addTableColumn('default_group', 'int not null default 0')); $content[] = '<pre>2.6.4 changes ------------------------- + Added missing column to install.sql</pre>'; case version_compare($currentVersion, '2.6.5', '<'): $content[] = '<pre>'; userUpdateFiles(array('conf/languages.php'), $content); $content[] = '2.6.5 changes ------------------------- + Added missing column to install.sql</pre>'; case version_compare($currentVersion, '2.6.6', '<'): $content[] = '<pre>'; userUpdateFiles(array('templates/forms/userForm.tpl'), $content); $content[] = '2.6.6 changes ----------------------- + Graceful recovery from broken authentication scripts. + Authorization script made deity only + Fixed default groups on external authentication + Deleted auth scripts will update users under it to use local instead. + The user constructor was trying to load the authorization script on failed users. Thanks Verdon.</pre>'; case version_compare($currentVersion, '2.7.0', '<'): $content[] = '<pre>2.7.0 changes ------------------------- + Usernames and passwords can not be changed on non local users + Added switch to settings to prevent admins from making new users + Site admin can be set by non-deities again + Fixed bug with users able to change password on alternate auth. + Fixed some bugs with user creation and editing with alternate authentication. + Hiding permissions and members in create group form + Icon class implemented. + Strict PHP 5 changes made. </pre>'; case version_compare($currentVersion, '2.7.1', '<'): $content[] = '<pre>2.7.1 changes ------------------------- + Improved cosign script + Fixed errors getting dropped without logging. </pre>'; case version_compare($currentVersion, '2.7.2', '<'): $content[] = '<pre>2.7.2 changes ------------------------- + Fixed multiple group member bug. + Cleaned up cosign authentication. + Current_User requireLogin to use login_link instead of login_url + New User form now properly respects the "settings" permission for showing user authentication script option. + User constuction allow username parameter. + Trim whitespace from user email addresses. Don\'t modify the member variable unless all the sanity checks passed. </pre>'; case version_compare($currentVersion, '2.7.3', '<'): PHPWS_Core::initModClass('users', 'Action.php'); User_Action::checkPermissionTables(); $content[] = '<pre>2.7.3 changes ------------------------ + Update permissions </pre>'; case version_compare($currentVersion, '2.7.4', '<'): $content[] = '<pre>2.7.4 changes ------------------------ + Fixed 500 error on My Page </pre>'; case version_compare($currentVersion, '2.7.5', '<'): $content[] = '<pre>2.7.5 changes ------------------------ + Loosened group name restrictions + User edit page shows group membership </pre>'; case version_compare($currentVersion, '2.7.6', '<'): $content[] = '<pre>2.7.6 changes ------------------------ + Updated icons to Font Awesome + Email addresses may now be used as user names. + Static method call fixed. + Added exception error for missing authorization file. + My Page no longer is using tabs as other modules use of My Page have been removed. + css.tpl template rewritten. Login now works closer with authentication script. - drop down no longer contains Home or Control Panel. Account link added - takes user to their account page to change their password. </pre>'; case version_compare($currentVersion, '2.8.0', '<'): $content[] = <<<EOF <pre>2.8.0 changes ----------------- + Added suggested bootstrap classes from TRF + Removed call to nonexistent method. + Moved icons to left and set admin-icons class to column. + Added FA icon here for mini admin + Changed to ensure users_auth_scripts table was created properly + Session timeouts are now tracked. Warning to user given before failure. </pre> EOF; case version_compare($currentVersion, '2.8.1', '<'): \PHPWS_Settings::set('users', 'session_warning', 0); \PHPWS_Settings::save('users'); $content[] = <<<EOF <pre>2.8.1 changes ----------------- + Changing default on user session to false. If you want it enabled, do so in settings. </pre> EOF; case version_compare($currentVersion, '2.8.2', '<'): $content[] = <<<EOF <pre>2.8.2 changes ----------------- + Bug Fix: Unstyled permission pop up. </pre> EOF; } // End of switch statement return TRUE; }
public function getBackupTable($table) { if (!PHPWS_DB::isTable($table)) { return FALSE; } $backupTable = Backup::getBackupTableName($table); if (!PHPWS_DB::isTable($backupTable)) { $result = Backup::_buildBackupTable($table); if (PHPWS_Error::isError($result)) { return $result; } } return $backupTable; }
/** * Saves a schedule and creates a new event table if needed */ public function save() { $db = $this->getDB(); if (empty($this->id)) { $new_key = TRUE; } else { $new_key = FALSE; } $result = $db->saveObject($this); if (PHPWS_Error::isError($result)) { return false; } else { if (!PHPWS_DB::isTable($this->getEventTable())) { $result = $this->createEventTable(); if (PHPWS_Error::isError($result)) { $this->delete(); return $result; } } $result = $this->saveKey(); if (PHPWS_Error::isError($result)) { $this->delete(); return $result; } if ($new_key) { $db->saveObject($this); } return true; } }
public function dropPermissions() { $modules = PHPWS_Core::getModules(true, true); if (empty($modules)) { return false; } foreach ($modules as $mod) { $permTable = Users_Permission::getPermissionTableName($mod); $db = new PHPWS_DB($permTable); if (!$db->isTable($permTable)) { continue; } $db->addWhere('group_id', $this->id); PHPWS_Error::logIfError($db->delete()); $db = new PHPWS_DB('phpws_key_edit'); $db->addWhere('group_id', $this->id); PHPWS_Error::logIfError($db->delete()); $db = new PHPWS_DB('phpws_key_view'); $db->addWhere('group_id', $this->id); PHPWS_Error::logIfError($db->delete()); } return true; }
/** * Returns an associative list of all groups and their levels of permission * in reference to the key passed to it */ public static function getPermissionGroups($key, $edit_rights = false) { if (empty($key) || !is_a($key, 'Key') || $key->isHomeKey() || empty($key->module) || $edit_rights && empty($key->edit_permission)) { return NULL; } $permTable = Users_Permission::getPermissionTableName($key->module); if (!PHPWS_DB::isTable($permTable)) { return PHPWS_Error::get(USER_ERR_PERM_FILE, 'users', __CLASS__ . '::' . __FUNCTION__); } $db = new PHPWS_DB('users_groups'); $db->addColumn('users_groups.*'); $db->addColumn("{$permTable}.permission_level"); $db->addWhere('id', "{$permTable}.group_id"); $db->addWhere("{$permTable}.permission_level", 0, '>'); $test_db = new PHPWS_DB($permTable); if ($edit_rights) { if (!$test_db->isTableColumn($key->edit_permission)) { return PHPWS_Error::get(KEY_PERM_COLUMN_MISSING, 'core', 'Users_Permission::getRestrictedGroups', $key->edit_permission); } $db->addWhere($permTable . '.' . $key->edit_permission, 1); } $db->addOrder('name'); $result = $db->select(); if (empty($result) || PHPWS_Error::isError($result)) { return $result; } foreach ($result as $group) { if ($group['user_id']) { if ($group['permission_level'] == RESTRICTED_PERMISSION) { $glist['restricted']['all'][] = $glist['restricted']['users'][] = $group; } else { $glist['unrestricted']['users'][] = $glist['unrestricted']['all'][] = $group; } $glist['permitted']['users'][] = $group; } else { if ($group['permission_level'] == RESTRICTED_PERMISSION) { $glist['restricted']['groups'][] = $glist['restricted']['all'][] = $group; } else { $glist['unrestricted']['groups'][] = $glist['unrestricted']['all'][] = $group; } $glist['permitted']['groups'][] = $group; } $glist['permitted']['all'][] = $group; } return $glist; }
public function save() { PHPWS_Core::initModClass('search', 'Search.php'); $table = $this->_schedule->getEventTable(); if (!PHPWS_DB::isTable($table)) { return PHPWS_Error::get(CAL_EVENT_TABLE_MISSING, 'calendar', 'Calendar_Event::save'); } $db = new PHPWS_DB($table); $result = $db->saveObject($this); if (PHPWS_Error::isError($result)) { return $result; } elseif (!$this->pid) { // only save the key if the pid is 0 // ie source event not copy if (empty($this->key_id)) { $save_key = true; } else { $save_key = false; } $key = $this->saveKey(); if (PHPWS_Error::isError($key)) { PHPWS_Error::log($key); return false; } if ($save_key) { $db->saveObject($this); } /* save search settings */ $search = new Search($this->key_id); $search->addKeywords($this->summary); $search->addKeywords($this->location); $search->addKeywords($this->description); $search->save(); return true; } }