Example #1
0
/**
 * @version $Id$
 * @author Adam Morton
 * @author Steven Levin
 */
function archive($formId = NULL)
{
    if (!isset($formId)) {
        $message = dgettext('phatform', 'No form ID was passed');
        return new PHPWS_Error('phatform', 'archive()', $message, 'continue', PHAT_DEBUG_MODE);
    }
    $archiveDir = PHPWS_HOME_DIR . 'files/phatform/archive/';
    $path = $archiveDir;
    clearstatcache();
    if (!is_dir($path)) {
        if (is_writeable($archiveDir)) {
            PHPWS_File::makeDir($path);
        } else {
            return PHPWS_Error::get(PHATFORM_ARCHIVE_PATH, 'phatform', 'Archive.php::archive', $path);
        }
    } else {
        if (!is_writeable($path)) {
            return PHPWS_Error::get(PHATFORM_ARCHIVE_PATH, 'phatform', 'Archive.php::archive()');
        }
    }
    $table = array();
    $time = time();
    $table[] = 'mod_phatform_forms';
    $table[] = 'mod_phatform_forms_seq';
    $table[] = 'mod_phatform_form_' . $formId;
    $table[] = 'mod_phatform_form_' . $formId . '_seq';
    $table[] = 'mod_phatform_multiselect';
    $table[] = 'mod_phatform_multiselect_seq';
    $table[] = 'mod_phatform_checkbox';
    $table[] = 'mod_phatform_checkbox_seq';
    $table[] = 'mod_phatform_dropbox';
    $table[] = 'mod_phatform_dropbox_seq';
    $table[] = 'mod_phatform_options';
    $table[] = 'mod_phatform_options_seq';
    $table[] = 'mod_phatform_radiobutton';
    $table[] = 'mod_phatform_radiobutton_seq';
    $table[] = 'mod_phatform_textarea';
    $table[] = 'mod_phatform_textarea_seq';
    $table[] = 'mod_phatform_textfield';
    $table[] = 'mod_phatform_textfield_seq';
    $step1 = explode('//', PHPWS_DSN);
    $step2 = explode('@', $step1[1]);
    $step3 = explode(':', $step2[0]);
    $step4 = explode('/', $step2[1]);
    $dbuser = $step3[0];
    $dbpass = $step3[1];
    $dbhost = $step4[0];
    $dbname = $step4[1];
    for ($i = 0; $i < sizeof($table); $i++) {
        $pipe = ' >> ';
        if ($i == 0) {
            $pipe = ' > ';
        }
        $goCode = 'mysqldump -h' . $dbhost . ' -u' . $dbuser . ' -p' . $dbpass . ' ' . $dbname . ' ' . $table[$i] . $pipe . $path . $formId . '.' . $time . '.phat';
        system($goCode);
    }
}
Example #2
0
 public function printFile($id)
 {
     $db = \Database::newDB();
     $t = $db->addTable('multimedia');
     $t->addFieldConditional('id', (int) $id);
     $row = $db->selectOneRow();
     if (empty($row)) {
         return null;
     }
     $ext = \PHPWS_File::getFileExtension($row['file_name']);
     if ($ext == 'mp3') {
         $template = 'filters/audio.tpl';
     } else {
         $template = 'filters/media.tpl';
     }
     return \PHPWS_Template::process(array('FILE_PATH' => $row['file_directory'] . $row['file_name']), 'filecabinet', $template);
 }
Example #3
0
 public function loadTemplates()
 {
     PHPWS_Core::initModClass('pagesmith', 'PS_Template.php');
     if (!empty($this->tpl_list)) {
         return true;
     }
     $tpl_dir = $this->ps->pageTplDir();
     $templates = PHPWS_File::listDirectories($tpl_dir);
     if (empty($templates)) {
         PHPWS_Error::log(PS_TPL_DIR, 'pagesmith', 'PS_Forms::loadTemplates', $tpl_dir);
         return false;
     }
     foreach ($templates as $tpl) {
         $pg_tpl = new PS_Template($tpl);
         if ($pg_tpl->data) {
             $this->tpl_list[$tpl] = $pg_tpl;
         }
     }
     return true;
 }
Example #4
0
 public function delete()
 {
     if (!$this->id) {
         throw new \Exception('Missing contact id');
     }
     $c_db = new \PHPWS_DB('prop_contacts');
     $c_db->addWhere('id', $this->id);
     $result = $c_db->delete();
     if (\PEAR::isError($result)) {
         \PHPWS_Error::log($result);
         throw new \Exception('Could not delete contact from database.');
     }
     $p_db = new \PHPWS_DB('properties');
     $p_db->addWhere('contact_id', $this->id);
     $result = $p_db->delete();
     if (\PEAR::isError($result)) {
         \PHPWS_Error::log($result);
         throw new \Exception('Could not delete contact properties from database.');
     }
     $i_db = new \PHPWS_DB('prop_photo');
     $i_db->addWhere('cid', $this->id);
     $result = $i_db->delete();
     if (\PEAR::isError($result)) {
         \PHPWS_Error::log($result);
         throw new \Exception('Could not delete contact photos from database.');
     }
     $dir = 'images/properties/c' . $this->id;
     \PHPWS_File::rmdir($dir);
     return true;
 }
 public static function getThemeList()
 {
     PHPWS_Core::initCoreClass('File.php');
     return PHPWS_File::readDirectory(Layout::getThemeDirRoot(), 1);
 }
        if ($GLOBALS['core']->query("ALTER TABLE mod_xwysiwyg_areas_seq RENAME {$GLOBALS['core']->tbl_prefix}mod_xw_areas_seq", TRUE)) {
            $update = $update + 8;
        }
    } else {
        $update = $update + 8;
    }
    if ($GLOBALS['core']->query("DROP TABLE mod_xwysiwyg_conf", TRUE)) {
        $update = $update + 16;
    }
    /* Create files/xwysiwyg directory */
    if (!is_dir("{$GLOBALS['core']->home_dir}files/xwysiwyg/")) {
        PHPWS_File::makeDir($GLOBALS['core']->home_dir . "files/xwysiwyg/");
    }
    /* Create files/xwysiwyg/editors directory */
    if (!is_dir("{$GLOBALS['core']->home_dir}files/xwysiwyg/editors/")) {
        PHPWS_File::makeDir($GLOBALS['core']->home_dir . "files/xwysiwyg/editors/");
    }
    if ($update >= 31) {
        $content .= "Altered database-scheme.<br />";
        $content .= "New module-layout.<br />";
        $content .= "More Settings.<br /><br />";
    } else {
        $content .= "Boost failed to update or alter tables. <br /><br />";
        $status = 0;
    }
}
if (version_compare($currentVersion, "0.4.1") < 0) {
    @unlink(PHPWS_HOME_DIR . "files/xwysiwyg/editors/list.txt");
    $content .= "Xwysiwyg Updates (Version 0.4.1)<br />";
    $content .= "+ Bugfix in manager<br /><br />";
}
Example #7
0
 public function post_basic()
 {
     PHPWS_Core::initCoreClass('File.php');
     $result = true;
     if (empty($this->branch->dbname) && isset($this->dbname)) {
         $this->branch->dbname = $this->dbname;
     }
     $this->branch->directory = $_POST['directory'];
     if (!preg_match('/\\/$/', $this->branch->directory)) {
         $this->branch->directory .= '/';
     }
     if (!is_dir($this->branch->directory)) {
         $this->message[] = dgettext('branch', 'Branch directory does not exist.');
         $directory = explode('/', $this->branch->directory);
         // removes item after the /
         array_pop($directory);
         // removes the last directory
         array_pop($directory);
         $write_dir = implode('/', $directory);
         // only writes directory on new branches
         if (!$this->branch->id) {
             if (is_writable($write_dir)) {
                 if (mkdir($this->branch->directory)) {
                     $this->message[] = dgettext('branch', 'Directory creation successful.');
                 } else {
                     $this->message[] = dgettext('branch', 'Unable to create the directory. You will need to create it manually.');
                     return false;
                 }
             } else {
                 $this->message[] = dgettext('branch', 'Unable to create the directory. You will need to create it manually.');
                 $result = false;
             }
         }
     } elseif (!is_writable($this->branch->directory)) {
         $this->message[] = dgettext('branch', 'Directory exists but is not writable.');
         $result = false;
     } elseif (!$this->branch->id && PHPWS_File::listDirectories($this->branch->directory)) {
         $this->message[] = dgettext('branch', 'Directory exists but already contains files.');
         $result = false;
     }
     if (empty($_POST['branch_name'])) {
         $this->message[] = dgettext('branch', 'You must name your branch.');
         $result = false;
     } elseif (!$this->branch->setBranchName($_POST['branch_name'])) {
         $this->message[] = dgettext('branch', 'You may not use that branch name.');
         $result = false;
     }
     if (empty($_POST['url'])) {
         $this->message[] = dgettext('branch', 'Enter your site\'s url address.');
         $result = false;
     } else {
         $this->branch->url = $_POST['url'];
     }
     if (empty($_POST['site_hash'])) {
         $this->message[] = dgettext('branch', 'Your branch site must have a site_hash.');
         $result = false;
     } else {
         $this->branch->site_hash = $_POST['site_hash'];
     }
     return $result;
 }
 function tarEditor()
 {
     if ($_SESSION["OBJ_user"]->allow_access("xwysiwyg", "settings")) {
         //Administrativ condition
         if (isset($_GET['tarEditor'])) {
             $package = PHPWS_Text::parseInput($_GET['tarEditor']);
         } else {
             return FALSE;
         }
         $file_loc = PHPWS_HOME_DIR . "files/xwysiwyg/editors/" . $package;
         $file_onl = "http://www.firebird.ch/xwysiwyg/editors/" . $package;
         //Last check, if the target is writeable
         if (!is_writeable(PHPWS_HOME_DIR . "files/xwysiwyg/editors")) {
             $this->content .= $_SESSION['translate']->it("[var1] does NOT exist or is NOT server writable!", "files/xwysiwyg/editors") . "<br />";
             $this->content .= $_SESSION['translate']->it("Try to create it manually (This may be a SafeMode problem)") . "<br />";
             return FALSE;
         }
         if (!isset($_GET['local'])) {
             //if not local, copy first
             PHPWS_File::fileCopy($file_onl, PHPWS_HOME_DIR . "files/xwysiwyg/editors/", "{$package}", TRUE, TRUE);
         }
         //Now we try to extract the files
         $tar = new Archive_Tar($file_loc);
         $result = $tar->extract(PHPWS_HOME_DIR . "files/xwysiwyg/editors/");
         if (!$result) {
             $this->content .= $_SESSION['translate']->it("Direct install failed!") . "<br />";
         }
     } else {
         $this->content .= $_SESSION['translate']->it("Access was denied due to lack of proper permissions.");
     }
     // End of ADMINISTRATOR condition
 }
Example #9
0
 public function getTemplateList()
 {
     $tpl_list = PHPWS_File::listDirectories(PHPWS_SOURCE_DIR . 'mod/pagesmith/templates/page_templates/');
     foreach ($tpl_list as $name) {
         $tpl = new PS_Template($name);
         $flist[$name] = $tpl->title;
     }
     return $flist;
 }
Example #10
0
 public function getTemplateList()
 {
     $included_result = PHPWS_File::listDirectories(PHPWS_Template::getTemplateDirectory('menu') . 'menu_layout/');
     $theme_result = PHPWS_File::listDirectories(PHPWS_SOURCE_DIR . Layout::getThemeDir() . 'templates/menu/menu_layout/');
     if (PHPWS_Error::logIfError($included_result) || PHPWS_Error::logIfError($theme_result)) {
         return null;
     }
     if ($theme_result) {
         $result = array_unique(array_merge($included_result, $theme_result));
     } else {
         $result = $included_result;
     }
     $result = array_combine($result, $result);
     if (empty($result)) {
         return null;
     }
     foreach ($result as $dir) {
         $directories[$dir] = $dir;
     }
     return $directories;
 }
Example #11
0
/**
 * @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;
}
Example #12
0
 public function updateResizes($image)
 {
     $dir = $image->getResizePath();
     if (!is_dir($dir)) {
         return;
     }
     $images = PHPWS_File::readDirectory($dir, false, true);
     if (empty($images)) {
         return;
     }
     foreach ($images as $file_name) {
         if (!preg_match('/\\d+x\\d+\\.\\w{1,4}$/', $file_name)) {
             continue;
         }
         $last_dot = strrpos($file_name, '.');
         $base = substr($file_name, 0, $last_dot);
         $dimensions = explode('x', $base);
         $image->resize($dir . $file_name, $dimensions[0], $dimensions[1]);
     }
 }
Example #13
0
 public function fileTypes()
 {
     $known_images = null;
     $known_media = null;
     $known_documents = null;
     include PHPWS_SOURCE_DIR . 'mod/filecabinet/inc/known_types.php';
     $image_types = explode(',', PHPWS_Settings::get('filecabinet', 'image_files'));
     $media_types = explode(',', PHPWS_Settings::get('filecabinet', 'media_files'));
     $doc_types = explode(',', PHPWS_Settings::get('filecabinet', 'document_files'));
     $all_file_types = PHPWS_File::getAllFileTypes();
     $form = new PHPWS_Form('allowed-file-types');
     $form->addHidden('module', 'filecabinet');
     $form->addHidden('aop', 'post_allowed_files');
     $img_checks = $this->sortType($known_images, $all_file_types);
     if (!empty($img_checks)) {
         $form->addCheckAssoc('allowed_images', $img_checks);
         $form->setMatch('allowed_images', $image_types);
     }
     $media_checks = $this->sortType($known_media, $all_file_types);
     if (isset($media_checks)) {
         $form->addCheckAssoc('allowed_media', $media_checks);
         $form->setMatch('allowed_media', $media_types);
     }
     $doc_checks = $this->sortType($known_documents, $all_file_types);
     if (isset($doc_checks)) {
         $form->addCheckAssoc('allowed_documents', $doc_checks);
         $form->setMatch('allowed_documents', $doc_types);
     }
     $form->useRowRepeat();
     $form->addSubmit(dgettext('filecabinet', 'Save allowed files'));
     $tpl = $form->getTemplate();
     $tpl['CHECK_IMAGES'] = javascript('check_all', array('checkbox_name' => 'allowed_images'));
     $tpl['CHECK_MEDIA'] = javascript('check_all', array('checkbox_name' => 'allowed_media'));
     $tpl['CHECK_DOCUMENTS'] = javascript('check_all', array('checkbox_name' => 'allowed_documents'));
     return PHPWS_Template::process($tpl, 'filecabinet', 'Forms/allowed_types.tpl');
 }
    return;
}
/* Import installation database and dump result into status variable */
if ($status = $GLOBALS["core"]->sqlImport(PHPWS_SOURCE_DIR . "mod/xwysiwyg/boost/install.sql", TRUE)) {
    $content .= "All xwysiwyg tables successfully written.<br /><br />";
    $status = 1;
} else {
    $content .= "There was a problem writing to the database!<br /><br />";
    return;
}
/* Create images directory */
if (!is_dir("{$GLOBALS['core']->home_dir}images/javascript/wysiwyg/")) {
    PHPWS_File::makeDir($GLOBALS['core']->home_dir . "images/javascript/wysiwyg/");
}
/* Create files/xwysiwyg directory */
if (!is_dir("{$GLOBALS['core']->home_dir}files/xwysiwyg/")) {
    PHPWS_File::makeDir($GLOBALS['core']->home_dir . "files/xwysiwyg/");
}
/* Create files/xwysiwyg/editors directory */
if (!is_dir("{$GLOBALS['core']->home_dir}files/xwysiwyg/editors/")) {
    PHPWS_File::makeDir($GLOBALS['core']->home_dir . "files/xwysiwyg/editors/");
}
if (is_dir("{$GLOBALS['core']->home_dir}images/javascript/wysiwyg/")) {
    PHPWS_File::fileCopy(PHPWS_SOURCE_DIR . "mod/xwysiwyg/img/xw.gif", $GLOBALS['core']->home_dir . "images/javascript/wysiwyg/", "xw.gif", false, false);
    $status = 1;
} else {
    $content .= "There was a problem copying the icons!<br /><br />";
    return;
}
$status = 1;
//instead
Example #15
0
 public function resize($orig, $dst, $max_width, $max_height)
 {
     if (!$this->width || !$this->height) {
         return false;
     }
     $src_proportion = $this->width / $this->height;
     $new_width = $this->width;
     $new_height = $this->height;
     if ($max_width > $this->width) {
         $crop_width = $new_width;
         $crop_height = $max_height;
     } elseif ($max_height > $this->height) {
         $crop_width = $max_width;
         $crop_height = $new_height;
     } elseif ($max_width <= $max_height) {
         $new_height = $max_height;
         $new_width = round($new_height * $src_proportion);
         $crop_width = $max_width;
         $crop_height = $new_height;
         if ($crop_width > $new_width) {
             $new_width = $max_width;
             $new_height = round($new_width / $src_proportion);
         }
     } else {
         $new_width = $max_width;
         $new_height = round($new_width * $src_proportion);
         $crop_width = $new_width;
         $crop_height = $max_height;
     }
     \PHPWS_File::scaleImage($orig, $dst, $new_width, $new_height);
     return \PHPWS_File::cropImage($dst, $dst, $crop_width, $crop_height);
 }
Example #16
0
/**
 * @version $Id$
 * @author Adam Morton
 * @author Steven Levin
 */
function export($formId = NULL)
{
    if (!isset($formId)) {
        $message = dgettext('phatform', 'No form ID was passed');
        return new PHPWS_Error('phatform', 'export()', $message, 'continue', PHAT_DEBUG_MODE);
    }
    $exportDir = PHPWS_HOME_DIR . 'files/phatform/export/';
    $path = $exportDir;
    clearstatcache();
    if (!is_dir($path)) {
        if (is_writeable($exportDir)) {
            PHPWS_File::makeDir($path);
        } else {
            return PHPWS_Error::get(PHATFORM_EXPORT_PATH, 'phatform', 'Export.php::export()');
        }
    } elseif (!is_writeable($path)) {
        return PHPWS_Error::get(PHATFORM_EXPORT_PATH, 'phatform', 'Export.php::export()');
    }
    $sql = 'SELECT * FROM mod_phatform_form_' . $formId;
    $result = PHPWS_DB::getAll($sql);
    if (sizeof($result) > 0) {
        $data = '';
        foreach ($result[0] as $key => $value) {
            if ($key != 'position') {
                $data .= $key . "\t";
            }
        }
        foreach ($result as $entry) {
            $data .= "\n";
            foreach ($entry as $key => $value) {
                if ($key != 'position') {
                    if ($key == 'updated') {
                        $value = date(PHPWS_DATE_FORMAT . ' ' . PHPWS_TIME_FORMAT, $value);
                    } else {
                        $value = str_replace("\t", " ", $value);
                        $value = str_replace("\r\n", '', $value);
                        $value = str_replace("\n", '', $value);
                        $temp = $value;
                        if (is_array($temp)) {
                            $value = implode(',', $temp);
                        } else {
                            if (preg_match('/^[ao]:\\d+:/', $temp)) {
                                // unserialize data
                                $unsTemp = unserialize($temp);
                                if (is_array($unsTemp)) {
                                    $value = implode(',', $unsTemp);
                                } else {
                                    $value = $unsTemp;
                                }
                            }
                        }
                    }
                    $data .= "{$value}\t";
                }
            }
        }
    }
    $filename = 'form_' . $formId . '_export.' . time() . '.csv';
    $file = fopen($path . $filename, 'w');
    fwrite($file, $data);
    fclose($file);
    $goCode = 'zip -qmj ' . $path . $filename . '.zip ' . $path . $filename;
    system($goCode);
    $filename = $filename . '.zip';
    $filepath = 'files/phatform/export/' . $filename;
    header('Pragma: public');
    header('Expires: 0');
    header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
    header('Last-Modified: ' . gmdate('D, d M Y H:i:s', filemtime($filepath)) . ' GMT');
    header('Cache-Control: private', false);
    header('Content-Type: application/zip');
    header('Content-Disposition: attachment; filename="' . $filename . '"');
    header('Content-Transfer-Encoding: binary');
    header('Content-Length: ' . filesize($filepath));
    header('Connection: close');
    readfile($filepath);
    exit;
}
Example #17
0
 public static function settings()
 {
     $content = array();
     $form = new PHPWS_Form('user_settings');
     $form->addHidden('module', 'users');
     $form->addHidden('action', 'admin');
     $form->addHidden('command', 'update_settings');
     $form->addSubmit('submit', dgettext('users', 'Update Settings'));
     $form->addText('site_contact', PHPWS_User::getUserSetting('site_contact'));
     $form->setLabel('site_contact', dgettext('users', 'Site contact email'));
     $form->setSize('site_contact', 40);
     if (Current_User::isDeity()) {
         $signup_modes = array(0, AUTO_SIGNUP, CONFIRM_SIGNUP);
         $signup_labels = array(dgettext('users', 'Not allowed'), dgettext('users', 'Immediate'), dgettext('users', 'Email Verification'));
         $form->addRadio('user_signup', $signup_modes);
         $form->setLabel('user_signup', $signup_labels);
         $form->addTplTag('USER_SIGNUP_LABEL', dgettext('users', 'User Signup Mode'));
         $form->setMatch('user_signup', PHPWS_User::getUserSetting('new_user_method'));
         if (extension_loaded('gd')) {
             $form->addCheckbox('graphic_confirm');
             $form->setLabel('graphic_confirm', dgettext('users', 'New user CAPTCHA confirmation'));
             $form->setMatch('graphic_confirm', PHPWS_User::getUserSetting('graphic_confirm'));
         }
         $included_usermenu = PHPWS_File::readDirectory(PHPWS_SOURCE_DIR . 'mod/users/templates/usermenus/', FALSE, TRUE, FALSE, array('tpl'));
         $theme_usermenu = PHPWS_File::readDirectory(PHPWS_SOURCE_DIR . Layout::getThemeDir() . 'templates/users/usermenus/', FALSE, TRUE, FALSE, array('tpl'));
         if ($theme_usermenu) {
             $options = array_unique(array_merge($included_usermenu, $theme_usermenu));
         } else {
             $options = $included_usermenu;
         }
         $menu_options = array_combine($options, $options);
         // Replace below with a directory read
         $menu_options['none'] = dgettext('users', 'None');
         $menu_options['css.tpl'] = 'css.tpl';
         $menu_options['Default.tpl'] = 'Default.tpl';
         $menu_options['top.tpl'] = 'top.tpl';
         $form->addSelect('user_menu', $menu_options);
         $form->setMatch('user_menu', PHPWS_User::getUserSetting('user_menu'));
         $form->setLabel('user_menu', dgettext('users', 'User Menu'));
         $form->addCheckBox('show_login', 1);
         $form->setMatch('show_login', PHPWS_Settings::get('users', 'show_login'));
         $form->setLabel('show_login', dgettext('users', 'Show login box'));
         $form->addTplTag('AFFIRM', dgettext('users', 'Yes'));
         $form->addCheckBox('allow_remember', 1);
         $form->setMatch('allow_remember', PHPWS_Settings::get('users', 'allow_remember'));
         $form->setLabel('allow_remember', dgettext('users', 'Allow Remember Me'));
         $form->addRadioAssoc('allow_new_users', array(1 => 'Yes', 0 => 'No'));
         $form->setMatch('allow_new_users', PHPWS_Settings::get('users', 'allow_new_users'));
         $form->addTplTag('ALLOW_NEW_USERS_LABEL', dgettext('users', 'Allow new user creation?'));
     }
     $form->addTextArea('forbidden_usernames', PHPWS_Settings::get('users', 'forbidden_usernames'));
     $form->setLabel('forbidden_usernames', dgettext('users', 'Forbidden usernames (one per line)'));
     $form->addCheckbox('session_warning', 1);
     $form->setMatch('session_warning', PHPWS_Settings::get('users', 'session_warning'));
     $form->setlabel('session_warning', 'Show session warning');
     $template = $form->getTemplate();
     if (Current_User::isDeity()) {
         $vars['action'] = 'admin';
         $vars['command'] = 'check_permission_tables';
         $template['VERIFY_PERMISSIONS'] = PHPWS_Text::secureLink(dgettext('users', 'Register user permissions'), 'users', $vars);
         $template['VERIFY_EXPLAIN'] = dgettext('users', 'Users module will re-register each module\'s permissions.');
     }
     return PHPWS_Template::process($template, 'users', 'forms/settings.tpl');
 }
Example #18
0
 public static function getEditorList()
 {
     return PHPWS_File::readDirectory(PHPWS_SOURCE_DIR . 'javascript/editors/', true);
 }
Example #19
0
 public static function getAllMods()
 {
     $all_mods = PHPWS_File::readDirectory(PHPWS_SOURCE_DIR . 'mod/', TRUE);
     foreach ($all_mods as $key => $module) {
         if (is_file(PHPWS_SOURCE_DIR . 'mod/' . $module . '/boost/boost.php')) {
             $dir_mods[] = $module;
         } elseif (is_file(PHPWS_SOURCE_DIR . 'mod/' . $module . '/conf/boost.php')) {
             $GLOBALS['Boost_Old_Mods'][] = $module;
         }
     }
     return $dir_mods;
 }
Example #20
0
 public function getVbType($ext)
 {
     $ext = trim(strtolower($ext));
     if (strpos($ext, '.')) {
         $ext = PHPWS_File::getFileExtension($ext);
     }
     $all_types = PHPWS_File::getAllFileTypes();
     if (!isset($all_types[$ext])) {
         return _('Unknown type');
     } else {
         return $all_types[$ext]['vb'];
     }
 }
Example #21
0
/**
 * @version $Id$
 * @author Matthew McNaney <mcnaney at gmail dot com>
 */
function pagesmith_update(&$content, $currentVersion)
{
    $home_dir = PHPWS_Boost::getHomeDir();
    switch ($currentVersion) {
        case version_compare($currentVersion, '1.0.1', '<'):
            $content[] = '<pre>';
            $db = new PHPWS_DB('ps_page');
            $result = $db->addTableColumn('front_page', 'smallint NOT NULL default 0');
            if (PHPWS_Error::logIfError($result)) {
                $content[] = "--- Unable to create table column 'front_page' on ps_page table.</pre>";
                return false;
            } else {
                $content[] = "--- Created 'front_page' column on ps_page table.";
            }
            $files = array('templates/page_list.tpl', 'javascript/update/head.js', 'conf/error.php', 'templates/page_templates/simple/page.tpl', 'templates/page_templates/twocolumns/page.tpl');
            pagesmithUpdateFiles($files, $content);
            if (!PHPWS_Boost::inBranch()) {
                $content[] = file_get_contents(PHPWS_SOURCE_DIR . 'mod/pagesmith/boost/changes/1_0_1.txt');
            }
            $content[] = '</pre>';
        case version_compare($currentVersion, '1.0.2', '<'):
            $content[] = '<pre>';
            $dest_dir = $home_dir . 'javascript/modules/pagesmith/passinfo/';
            if (!is_dir($dest_dir)) {
                if (is_writable($home_dir . 'javascript/modules/pagesmith/') && @mkdir($dest_dir)) {
                    $content[] = '--- SUCCEEDED creating "javascript/modules/passinfo/" directory.';
                } else {
                    $content[] = 'PageSmith 1.0.2 requires the javascript/modules/pagesmith/ directory be writable.</pre>';
                    return false;
                }
            } elseif (!is_writable($dest_dir)) {
                $content[] = 'PageSmith 1.0.2 requires the javascript/modules/pagesmith/passinfo/ directory be writable.</pre>';
                return false;
            }
            $source_dir = PHPWS_SOURCE_DIR . 'mod/pagesmith/javascript/passinfo/';
            if (!PHPWS_File::copy_directory($source_dir, $dest_dir)) {
                $content[] = "--- FAILED copying to {$dest_dir}.</pre>";
                return false;
            } else {
                $content[] = "--- SUCCEEDED copying to {$dest_dir} directory.";
            }
            if (!PHPWS_Boost::inBranch()) {
                $content[] = file_get_contents(PHPWS_SOURCE_DIR . 'mod/pagesmith/boost/changes/1_0_2.txt');
            }
            $content[] = '</pre>';
        case version_compare($currentVersion, '1.0.3', '<'):
            $content[] = '<pre>';
            $source_dir = PHPWS_SOURCE_DIR . 'mod/pagesmith/templates/page_templates/text_only/';
            $dest_dir = $home_dir . 'templates/pagesmith/page_templates/text_only/';
            if (PHPWS_File::copy_directory($source_dir, $dest_dir)) {
                $content[] = "--- Successfully copied {$source_dir}\n    to {$dest_dir}\n";
            } else {
                $content[] = "--- Failed to copy {$source_dir} to {$dest_dir}</pre>";
                return false;
            }
            $files = array('conf/config.php');
            pagesmithUpdateFiles($files, $content);
            if (!PHPWS_Boost::inBranch()) {
                $content[] = file_get_contents(PHPWS_SOURCE_DIR . 'mod/pagesmith/boost/changes/1_0_3.txt');
            }
            $content[] = '</pre>';
        case version_compare($currentVersion, '1.0.4', '<'):
            $content[] = '<pre>';
            $db = new PHPWS_DB('phpws_key');
            $db->addWhere('module', 'pagesmith');
            $db->addValue('edit_permission', 'edit_page');
            if (PHPWS_Error::logIfError($db->update())) {
                $content[] = 'Unable to update phpws_key table.</pre>';
                return false;
            } else {
                $content[] = 'Updated phpws_key table.';
            }
            $content[] = '1.0.4 changes
------------------
+ Fixed pagesmith edit permission.
+ PageSmith home pages were missing edit link.</pre>';
        case version_compare($currentVersion, '1.0.5', '<'):
            $content[] = '<pre>';
            pagesmithUpdateFiles(array('templates/page_templates/text_only/page.tpl'), $content);
            $content[] = '1.0.5 changes
----------------
+ Changed wording on move to front functionality
+ Added move to front to miniadmin
+ Fixed text_only template. Missing closing div tag.
</pre>';
        case version_compare($currentVersion, '1.0.6', '<'):
            $content[] = '<pre>
1.0.6 changes
-------------
+ Small fix to allow linkable images on cached pages.
</pre>';
        case version_compare($currentVersion, '1.0.7', '<'):
            $content[] = '<pre>';
            pagesmithUpdateFiles(array('templates/settings.tpl'), $content);
            $content[] = '1.0.7 changes
-------------
+ PageSmith can be set to automatically create a link when a new page
  is created.
+ Changing a page title now updates the menu link.
</pre>';
        case version_compare($currentVersion, '1.1.0', '<'):
            PHPWS_Core::initModClass('filecabinet', 'Cabinet.php');
            $content[] = '<pre>';
            Cabinet::convertImagesToFileAssoc('ps_block', 'type_id');
            $content[] = '--- Images converted for File Cabinet 2.0.0.';
            pagesmithUpdateFiles(array('javascript/passinfo/head.js', 'templates/page_templates/threesec/page.css', 'templates/page_templates/threesec/page.tpl', 'templates/page_templates/threesec/structure.xml', 'templates/page_templates/threesec/threesec.png'), $content);
            $content[] = '1.1.0 changes (unreleased)
-------------
+ PageSmith conforms to new File Cabinet update.
+ Added url parser to passinfo script to allow images to work with fck better.
</pre>';
        case version_compare($currentVersion, '1.2.1', '<'):
            $content[] = '<pre>';
            $source_tpl = PHPWS_SOURCE_DIR . 'mod/pagesmith/templates/page_templates/';
            $local_tpl = $home_dir . 'templates/pagesmith/page_templates/';
            $backup = $home_dir . 'templates/pagesmith/_page_templates/';
            $source_img = PHPWS_SOURCE_DIR . 'mod/pagesmith/img/folder_icons/';
            $local_img = $home_dir . 'images/mod/pagesmith/folder_icons/';
            if (is_dir($backup) || @PHPWS_File::copy_directory($local_tpl, $backup)) {
                $content[] = '--- Local page templates backed up to: ' . $backup;
            } else {
                $content[] = sprintf('--- Could not backup directory "%s" to "%s"</pre>', $local_tpl, $backup);
                return false;
            }
            if (PHPWS_File::copy_directory($source_tpl, $local_tpl)) {
                $content[] = '--- Local page templates updated.';
            } else {
                $content[] = sprintf('--- Could not copy directory "%s" to "%s"</pre>', $source_tpl, $local_tpl);
                return false;
            }
            if (PHPWS_File::copy_directory($source_img, $local_img)) {
                $content[] = '--- New page template icons copied locally.';
            } else {
                $content[] = sprintf('--- Could not copy directory "%s" to "%s"</pre>', $source_img, $local_img);
                return false;
            }
            if (!pagesmithSearchIndex()) {
                $content[] = '--- Unable to index pages in search. Check your error log.</pre>';
                return false;
            } else {
                $content[] = '--- Pages added to search';
            }
            $files = array('templates/pick_folder.tpl', 'templates/pick_template.tpl', 'templates/style.css', 'conf/folder_icons.php');
            pagesmithUpdateFiles($files, $content);
            $content[] = '1.2.1 changes
----------------
+ PageSmith now allows the sorting of templates
+ Page titles now added to search.
+ Wrong page ids don\'t 404. Send to message page.
+ Search indexing added to update and version raised.
+ Added search to pagesmith.
+ Changed to new url rewriting method.</pre>';
        case version_compare($currentVersion, '1.2.2', '<'):
            $content[] = '<pre>';
            $files = array('templates/page_list.tpl');
            pagesmithUpdateFiles($files, $content);
            $content[] = '
1.2.2 changes
---------------
+ Updated pagers to addSortHeaders.
+ Fixed direct access to page allowing view.
+ Front page does not alter page title.
+ Fixed some notices and a caching bug.
+ Changed wording on edit text windows.</pre>';
        case version_compare($currentVersion, '1.3.0', '<'):
            $db = new PHPWS_DB('ps_block');
            $db->dropTableColumn('btype');
            $db = new PHPWS_DB('ps_page');
            if (PHPWS_Error::logIfError($db->addTableColumn('parent_page', 'int NOT NULL default 0'))) {
                $content[] = 'Could not create ps_page.parent_page column.';
                return false;
            }
            if (PHPWS_Error::logIfError($db->addTableColumn('page_order', 'smallint NOT NULL default 0'))) {
                $content[] = 'Could not create ps_page.page_order column.';
                return false;
            }
            $db = new PHPWS_DB('ps_text');
            if (PHPWS_DB::getDBType() == 'mysql' || PHPWS_DB::getDBType() == 'mysqli') {
                if (PHPWS_Error::logIfError($db->alterColumnType('content', 'longtext NOT NULL'))) {
                    $content[] = 'Could not alter ps_text.content column.';
                }
            }
            $content[] = '<pre>';
            $files = array('javascript/passinfo/head.js', 'templates/page_form.tpl', 'javascript/delete_orphan/', 'javascript/confirm_delete/', 'javascript/update/head.js', 'templates/page_templates/threesec-tbl/', 'templates/orphans.tpl', 'templates/page_form.tpl', 'templates/page_frame.tpl', 'templates/page_list.tpl', 'templates/style.css', 'templates/sublist.tpl', 'templates/upload_template.tpl', 'img/add.png', 'img/delete.png', 'img/back.png', 'img/front.png');
            pagesmithUpdateFiles($files, $content);
            if (!PHPWS_Boost::inBranch()) {
                $content[] = file_get_contents(PHPWS_SOURCE_DIR . 'mod/pagesmith/boost/changes/1_3_0.txt');
            }
            $content[] = '</pre>';
        case version_compare($currentVersion, '1.3.1', '<'):
            $content[] = '<pre>';
            $files = array('templates/page_templates/threesec/page.tpl', 'templates/page_templates/threesec-tbl/page.tpl', 'templates/settings.tpl');
            pagesmithUpdateFiles($files, $content);
            $content[] = '1.3.1 changes
---------------
+ Page cache refreshed on page save.
+ Updated threesec templates to conform with norm box-title,
  box-content layout
+ Added ability to lengthen or shorten pagesmith links.
+ Added fix so edit mode does not parse smarttags.</pre>';
        case version_compare($currentVersion, '1.3.2', '<'):
            $content[] = '<pre>';
            Users_Permission::registerPermissions('pagesmith', $content);
            pagesmithUpdateFiles(array('templates/page_templates/'), $content);
            $content[] = '1.3.2 changes
----------------
+ Update was missing a permission update
+ Wrong permission getting called on settings
+ All page templates now have a class called pagesmith-page
+ Removed padding from page templates</pre>';
        case version_compare($currentVersion, '1.3.3', '<'):
            $db = new PHPWS_DB('ps_text');
            if (PHPWS_Error::logIfError($db->alterColumnType('content', 'longtext'))) {
                $content[] = 'Could not alter ps_text.content column.';
                return false;
            } else {
                $content[] = 'Updated ps_text.content column';
            }
            $content[] = '<pre>';
            pagesmithUpdateFiles(array('javascript/disable_links/', 'javascript/update/head.js'), $content);
            $content[] = 'Version 1.3.3
--------------------------------------------------------------------
+ Made ps_text.content null instead of not null
+ Made a change in page editing. Text spaces receive text without
  formatting. Prior to this change the parseOutput was run before
  sending the data to the editor. This stripped data that may need
  editing.
  Now the text is sent to the editor without processing. After post
  the text IS processed. This fixed the filters. Anchors will be
  busted AFTER the edit post but I don\'t think they really need to
  work in edit mode.
+ Added javascript to prevent accidental link clicks in edit mode.
+ change_link was an id, changed to a class since there were several
  on a page.</pre>';
        case version_compare($currentVersion, '1.3.4', '<'):
            $content[] = '<pre>1.3.4 changes
-------------
+ Fixed link shortening
+ Restored missing placeholder width and height
+ Fixed lost text bug.
</pre>';
        case version_compare($currentVersion, '1.4.0', '<'):
            $content[] = '<pre>1.4.0 changes
-------------
+ Icon class implemented.
+ Fixed on disableLinks script.
+ Added black page check on saving. Prohibits empty content from being saved to the database.
+ Added option to turn off "Back to top" links.
+ Added default installation page.
+ PHP 5 strict fixes.</pre>';
        case version_compare($currentVersion, '1.4.1', '<'):
            $content[] = '<pre>1.4.1 changes
-------------
Fixed bug causing blank editors on edit.</pre>';
        case version_compare($currentVersion, '1.4.2', '<'):
            $content[] = '<pre>1.4.2 changes
-------------
+ Added conditionals to try and prevent blank page posting.
+ Updated javascript to jquery code.
+ Added some new templates.
.</pre>';
        case version_compare($currentVersion, '1.5.0', '<'):
            $content[] = '<pre>1.5.0 changes
---------------
+ New method of editing text. Click on text instead of edit image.
+ Javascript window replaced with Jquery dialog.
</pre>';
        case version_compare($currentVersion, '1.5.1', '<'):
            $content[] = '<pre>1.5.1 changes
---------------
+ Mouseover edit behavior changed.
+ Publish on date added.
</pre>';
        case version_compare($currentVersion, '1.5.2', '<'):
            $content[] = '<pre>1.5.2 changes
---------------
- Fixed error message
- Empty orphans are removed automatically.
- Dialog editor made modal.
</pre>';
        case version_compare($currentVersion, '1.5.3', '<'):
            $content[] = '<pre>1.5.3 changes
---------------
+ Edit hinting changed to Boostrap standard
+ Removed upload template tab and code
+ Font Awesome used in icons
+ Tweaked page listing.
+ Removed default background color from page template.
+ Fixed bug with pages saving untitled.
</pre>';
        case version_compare($currentVersion, '1.5.4', '<'):
            $content[] = '<pre>1.5.4 changes
---------------
+ Added titles to admin icons
+ Removed @ to prevent PHP warning message
+ Style changes to pager listing
+ Pop up width is relative to browser
</pre>';
        case version_compare($currentVersion, '1.6.0', '<'):
            $db = \Database::newDB();
            $table = $db->addTable('ps_page');
            $table->addFieldConditional('template', 'art');
            $table->addValue('template', 'banner');
            $db->update();
            $db->clearConditional();
            $table->reset();
            $c1 = $table->getFieldConditional('template', 'vtour');
            $c2 = $table->getFieldConditional('template', 'VTOUR');
            $db->addConditional($db->createConditional($c1, $c2, 'OR'));
            $table->addValue('template', 'threesec');
            $db->update();
            $content[] = '<pre>1.6.0 changes
---------------
+ Rewrote page templates to be Bootstrap compatible.
+ Removed art and vtour template.
</pre>';
        case version_compare($currentVersion, '1.6.1', '<'):
            $content[] = '<pre>1.6.1 changes
---------------
+ changed content editor pop up to use bootstrap modal instead of jquery dialog
+ Bootstrap styling to some UI elements
+ Back to top link pulled right with new icon
</pre>';
        case version_compare($currentVersion, '1.7.0', '<'):
            $content[] = <<<EOF
<pre>1.7.0 changes
------------------
+ Removed hardcoded h2 styles on some templates
+ Back to top default setting added
+ Clicking off edit window saves content
</pre>
EOF;
        case version_compare($currentVersion, '1.8.0', '<'):
            $db = \Database::newDB();
            $lb = $db->addTable('layout_box');
            $lb->addFieldConditional('module', 'pagesmith');
            $db->delete();
            $content[] = <<<EOF
<pre>1.8.0 changes
------------------
+ Removed all PageSmith pages from layout_box table. Was kept only for multiple front pages which no one used.
</pre>
EOF;
        case version_compare($currentVersion, '1.9.0', '<'):
            $db = \Database::newDB();
            $pp = $db->addTable('ps_page');
            $st = $pp->addDataType('show_title', 'smallint');
            $st->add();
            $content[] = <<<EOF
<pre>1.9.0 changes
------------------
+ Added: Ability to hide title
+ Changed: Pagesmith editing works within Bootstrap modals.
+ Changed: Adapted to work with CKEditor 4.
+ Changed: Front page is now Highlander style.
</pre>
EOF;
        case version_compare($currentVersion, '1.9.1', '<'):
            $db = \Database::newDB();
            $pp = $db->addTable('ps_page');
            if (!$pp->columnExists('hide_title') && $pp->columnExists('show_title')) {
                $dt = $pp->getDatatype('show_title');
                $dt->change('hide_title');
            }
            $content[] = <<<EOF
<pre>1.9.1 changes
------------------
+ Fixed: Code uses hide_title. Column name was show_title.
</pre>
EOF;
        case version_compare($currentVersion, '1.9.2', '<'):
            $content[] = <<<EOF
<pre>1.9.2 changes
------------------
+ Fixed: hide_title was not properly formated in install.sql
+ Fixed: Reduced edit popup window height.
+ Feature: Added save button to CKEditor that works in maximize.
+ Feature: Added page update check to page submission.
+ Change: Save button is styled and larger.
+ Change: New page defaults to Text Only template.
</pre>
EOF;
        case version_compare($currentVersion, '1.10.0', '<'):
            $db = \Database::newDB();
            $t1 = $db->addTable('ps_page');
            $dt = $t1->addDatatype('deleted', 'smallint');
            $dt->setDefault(0);
            $dt->add();
            $content[] = <<<EOF
<pre>
1.10.0 Changes
---------------
+ Deleted pages are kept in database
</pre>
EOF;
    }
    // end switch
    return true;
}
Example #22
0
/**
 * @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;
    }
}
Example #23
0
/**
 * @version $Id$
 * @author Matthew McNaney <mcnaney at gmail dot com>
 */
function core_update(&$content, $version)
{
    $content[] = '';
    // Versions previous to 1.9.8 removed 2 May, 2013.
    switch (1) {
        case version_compare($version, '1.9.8', '<'):
            $content[] = '<h2>Sorry</h2>
<p>Your version of phpWebSite is too old to update using 1.8.0. Please update to
1.7.3 and return.</p>';
        case version_compare($version, '2.0.0', '<'):
            if (PHPWS_Core::isBranch()) {
                $content[] = 'This update can only be performed on the hub.';
                return false;
            }
            if (!PHPWS_Boost::inBranch()) {
                $config_dir = PHPWS_SOURCE_DIR . 'config/core/';
                if (!is_writable($config_dir)) {
                    $content[] = '<p>Core update can not continue until your hub installation\'s <strong>config/core/</strong> directory is writable.</p>';
                    return false;
                }
                $source_http = sprintf("<?php\ndefine('PHPWS_SOURCE_HTTP', '%s');\n?>", PHPWS_CORE::getHomeHttp());
                if (!file_put_contents($config_dir . 'source.php', $source_http)) {
                    $content[] = '<p>Could not create config/core/source.php file.</p>';
                    return false;
                }
                $content[] = <<<EOT
                <pre>2.0.0 changes
-----------------
+ Hub/Branch overhaul. Branches pull config, templates, javascript,
  and theme files from hub instead of locally.
+ Added Icon class. Standardizes icons and prevents overlap.
+ Added Tag class: extendable class used with Image and Form2.
+ Added tag_implode function.
+ Created Form2 class.
+ Added CKeditor.
+ Added Lightbox.
+ getConfigFile does not throw error now.
+ Dutch translation updated.
+ Added autoload function for core classes.
+ Source dir derived from file path and not simply "./"
+ Added Image class.
+ Critical functions changed to throw exceptions.
+ Setup steamlined.</pre>

<p><strong>Note:</strong> this update creates a backup of your config/core/config.php file named<br />
config-prior170.php.<br />
If your installation is working, this file may be safely deleted.</p>
<p>IMPORTANT! Many settings in the old config.php have been moved to core/conf/defines.php in the hub.
You can delete all settings <strong>except</strong> the following:</p>
<ul><li>PHPWS_SOURCE_DIR</li>
<li>PHPWS_HOME_DIR</li>
<li>PHPWS_SOURCE_HTTP</li>
<li>SITE_HASH</li>
<li>PHPWS_DSN</li>
<li>PHPWS_TABLE_PREFIX</li></ul>
</pre>
EOT;
            }
            if ($branch = PHPWS_Boost::inBranch(true)) {
                if (!PHPWS_File::copy_directory(PHPWS_SOURCE_DIR . 'javascript/editors/fckeditor/', $branch->directory . 'javascript/editors/fckeditor', true)) {
                    mkdir($branch->directory . 'images/ckeditor/');
                    $this->content[] = dgettext('branch', 'Failed to copy FCKeditor to branch.');
                } else {
                    $content[] = 'FCKeditor not copied to branch. Check directory permissions.';
                }
            } else {
                mkdir(PHPWS_SOURCE_DIR . 'images/ckeditor/');
            }
        case version_compare($version, '2.0.1', '<'):
            $content[] = <<<UPDATES
            <pre>2.0.1 changes
----------------------
+ Fixed captcha trying to pull from branch directory.
+ Fixed templates ignoring use_hub_themes setting.
+ Image class will accept tilde in source directory.
+ Database fix for insert and update on multiple tables.
+ Powerpoint types added to file check.
+ Background mode added to index (allows for selective loading on Ajax calls)
+ Freecap ereg_replace updated to preg_replace
+ Fix for js_calendar
+ Fix for javascript alert script
+ Fixes for Fckeditor and Tinymce
+ Inclusion of ngBackup
</pre>
UPDATES;
        case version_compare($version, '2.0.2', '<'):
            $content[] = <<<UPDATES
<pre>2.0.2 changes
----------------------
+ Added To top icon
+ Fixed table bug where names used in foreign key constrains (in CREATE TABLE statements) were not prefixed correctly
+ Removed HTML from some translations.
+ Fixed bug causing a table name to be repeated in a JOIN statement
+ Fixed some PHP notice errors.
+ Fixed some hub icon directory problems (Thanks Eloi).
+ Image resizing reworked to correct problems with irregular images.
+ ngBackup updates.
+ Fixed some templating issues (Thanks Tommy, Eloi).
+ URL validity checking in Text was made more robust.
+ Fixed some label id issues in form.
+ Fixed a loadDimensions error in Image (Thanks Eloi)
+ Fixed DBPager duplicating table insertions (Thanks Eloi)
+ Fixed some PEAR PHP 5 warnings.
+ Changed URL forwarding - if first value after the module is numeric, it is cast as an id.
+ Removed deny-all .htaccess file from file directory.
</pre>
UPDATES;
        case version_compare($version, '2.1.0', '<'):
            $content[] = <<<UPDATES
<pre>2.1.0 changes
----------------------
 + Another Powerpoint file mimetype added to file_types.php
 + Turned off collapse_urls as a default condition.
 + Added cosign configuration example in defines.dist.php
 + More static warnings silenced.

Classes
----------------
 + Form.php
    - Fixed bug with addCheckAssoc
    - Added onbeforeclose protection to forms
    - Fixed array handling in PHPWS_Form::grab(). If the array of elements isn't
      indexed by integers, it will return the entire array instead of trying to
      return element 0.
 + Error.php
    - Pear method call was called all lowercase. Probably a hold over
      from when function name case was irrelevant.
 + Cookie.php
    - Cookie assumes a cookie is set before deletion. Changed function
      call to check prior to operation.
 + File.php
    - Fix to file extension checking.
 + Core.php
    - Moved some logic for finding the site Base URL out of Layout and
      into Core, as the getBaseURL() function
 + Text.php
    - Missing variable added to parameter list.
    - Faulty parse_url is being silenced on failure and getGetValues returns null.
    - Filtering out high ascii using parseOutput
 + Init.php
    - Fixed overwrite problem with defines.php on updating.
 + Database.php
    - Removed restrictive join check
    - Database substitutes table "as" if it exists on column call and/or set order
    - Allow parenthesis and commas in addOrder, so we can order by function,
      like "order by coalesce(...)"
    - Fixed splat usage with count in addColumn and getColumn
+ DBPager.php
    - Rewrote CSV parser to use fputcsv
    - Fixed bug with csv reporting

Javascript
------------------
+ captcha/recaptcha - added recycle instructions
+ required_input - file inputs can now be required fields
+ protect_form - new javascript to prevent user leaving fields blank
+ jquery - updated
+ flowplayer - updated version
+ editors
    + ckeditor - added File Cabinet functionality
    + cleditor - added Cleditor by Hilmar
</pre>
UPDATES;
        case version_compare($version, '2.1.1', '<'):
            $content[] = <<<UPDATES
<pre>
2.1.1 changes
-----------------

Core Classes
-----------------
+ Fixed bugs with Key and Database. Registered users (not deities) were having problems
  with editing and view restricted items. PHPWS_DB::groupIn rewritten.
+ Core now has better error messages for Branches problems.
+ Image - removed px from width and height for xhtml compatibility.
+ Static notice fixes
+ Removed clone function call in Icon.

Javascript
----------------
+ jquery_ui and jquery updated
</pre>
UPDATES;
        case version_compare($version, '2.2.0', '<'):
            $changes = file_get_contents(PHPWS_SOURCE_DIR . 'core/boost/changes/2_2_0.txt');
            $content[] = "<pre>{$changes}</pre>";
        case version_compare($version, '2.3.0', '<'):
            try {
                include_once PHPWS_SOURCE_DIR . 'core/boost/updates/2_3_0.php';
                update_core_2_3_0();
            } catch (\Exception $e) {
                $content[] = 'Error: ' . $e->getMessage();
                return false;
            }
            $changes = file_get_contents(PHPWS_SOURCE_DIR . 'core/boost/changes/2_3_0.txt');
            $content[] = "<pre>{$changes}</pre>";
        case version_compare($version, '2.3.1', '<'):
            $db = \Database::newDB();
            $db->setConditional($db->addTable('modules')->getFieldConditional('title', 'comments'));
            $db->delete();
            $db = \Database::newDB();
            $db->setConditional($db->addTable('controlpanel_link')->getFieldConditional('itemname', 'comments'));
            $db->delete();
            $db = \Database::newDB();
            if ($db->tableExists('comments_items')) {
                $db->buildTable('comments_items')->drop();
            }
            if ($db->tableExists('comments_items_seq')) {
                $db->buildTable('comments_items_seq')->drop();
            }
            if ($db->tableExists('comments_monitors')) {
                $db->buildTable('comments_monitors')->drop();
            }
            if ($db->tableExists('comments_permissions')) {
                $db->buildTable('comments_permissions')->drop();
            }
            if ($db->tableExists('comments_ranks')) {
                $db->buildTable('comments_ranks')->drop();
            }
            if ($db->tableExists('comments_ranks_seq')) {
                $db->buildTable('comments_ranks_seq')->drop();
            }
            if ($db->tableExists('comments_threads')) {
                $db->buildTable('comments_threads')->drop();
            }
            if ($db->tableExists('comments_threads_seq')) {
                $db->buildTable('comments_threads_seq')->drop();
            }
            if ($db->tableExists('comments_users')) {
                $db->buildTable('comments_users')->drop();
            }
            if ($db->tableExists('comments_user_ranks')) {
                $db->buildTable('comments_user_ranks')->drop();
            }
            if ($db->tableExists('comments_user_ranks_seq')) {
                $db->buildTable('comments_user_ranks_seq')->drop();
            }
            $db = \Database::newDB();
            if ($db->tableExists('categories')) {
                $db->buildTable('categories')->drop();
            }
            if ($db->tableExists('categories_seq')) {
                $db->buildTable('categories_seq')->drop();
            }
            if ($db->tableExists('categories_permissions')) {
                $db->buildTable('categories_permissions')->drop();
            }
            if ($db->tableExists('category_items')) {
                $db->buildTable('category_items')->drop();
            }
            if ($db->tableExists('category_items_seq')) {
                $db->buildTable('category_items_seq')->drop();
            }
            $db = \Database::newDB();
            $db->setConditional($db->addTable('modules')->getFieldConditional('title', 'categories'));
            $db->delete();
            $db = \Database::newDB();
            $db->setConditional($db->addTable('controlpanel_link')->getFieldConditional('itemname', 'categories'));
            $db->delete();
            $content[] = '<pre>Core 2.3.1 Changes
-------------------
+ Removed Comments module
+ Removed Categories module
</pre>';
        case version_compare($version, '2.3.2', '<'):
            $content[] = '<pre>Core 2.3.2 Changes
-------------------
+ Bootstrap
    - Updated Bootstrap theme to Bootstrap 3.0.1
    - Added Bootstrap table styles to several modules.
    - Removed class name "label" from several templates as it is a reserved class name
        in Bootstrap. Leaving it caused white text.
+ Font Awesome
    - Font Awesome replaced several module icons.
    - Updated Icon class to use Font Awesome 4
+ Changed phpDSNLoader to accept the table prefix as a parameter instead of relying on a define.
+ added loadPDO to exec method should it get unset.
+ Removed remnants of category calls.
+ xml2php changed to catch an exception.
+ Added Dutch translation from Han Velthuis.
+ Rewrote some Global error messages to be more descriptive.
+ Removed "simple" theme.
+ Fixed define bug casuing setup errors.
+ Pear deprecated when possible.
+ Filter code (BB and pear) removed from Text parsing.
+ Removed firebug code, ngboost and ngcom.
+ A theme can now define default classes for inputs, labels, and element groups.
+ date_default_timezone_set added to index.php to conform with new PHP standards.
+ Error check on PHPWS_Form class added.
+ Removed setup/manager.php
+ Fixed GD version detection. Was causing resampled images to be downgraded.
+ Swiftmail library added. Not in use yet but will replace other mail functions.
+ Added abbr tag to allowed_tags.
+ Global\\Server
    - fixed getCurrentUrl adding extra slashes
+ Global\\Variable
    - setRange and setIncrement return $this to allow method chaining.
    - setText will change a bool to a 0 or 1 for display.
    - Integer creates a ranged select if setInputType is set to select.
    - Unlimited String will create a text column in the database and no longer a varchar.
    - Text input is no longer the default type for a Variable object
    - Fixed: String validity check would fail on empty or null values.
    - String-type variable limits raised to reflect higher varchar limits
    - Added unlink method to File class.
    - Boolean now shows up in a Debug call
+ Global\\Form
    - Form can now define groupings for use with Bootstrap
    - Form Labels are now a class instead of a string.
    - addInputClass will plug a css class to every input in the Global\\Form.
    - Placeholders can now be added to input objects.
    - Required check works with onblur instead of change allowing blanks to be detected.
    - Submit button will be disabled if form set to use required inputs.
    - Choice\\Select now allows first choice to be blank
    - Input\\Text now allow apostrophes.
    - Added to ability to theme buttons
    - Added return to Text to allow method chaining.
    - Removed code that automatically copied the options of integer keyed arrays
        over the key. Instead added a copyOptionToValue method.
+ Global\\Database
    - Added addFieldConditional method to Table class.
    - Text added as datatype.
    - Added joinResources method to replace join method
    - Large update to allow multiple conditionals to join statements
    - Update to subselects and tables to work properly with fields.
    - Added Exists class which is an extension of Conditional. Works with subselects.
    - DB quote changed to static method.
    - Conditionals were missing proper quoting methods.
    - Added stringAsField method to Expression.
    - Conditional checks for alias on getLeft
+ Global\\Resource returns the id of the resource as a hidden input.
    - createTable returns a table object
+ Global\\Request added methods for returning FILES information
    - Added new functions to Request to assist with command branching.
    - Added lastCommand method
+ Global\\ResourceFactory selectInto fixed as private and protected variables would not work
+ Global\\Pager
    - Added addJsonData and json_data variable. Allows entering a key=>value pair
        that will be included in the JSON return.
    - Fixed search box display
    - Fixed search clear
    - Added page count to JSON result. Not in UI yet.
    - Added method to set the data url to the pager template.
    - Added undefined check to prevent javascript error.
+ Global\\DatabasePager
    - added showQuery function and show_query variable. If variable is true, the
        select query will be inserted into the JSON return for evaluation
    - Total row calculation moved up in process so current page count is correct.
</pre>';
        case version_compare($version, '2.4.0', '<'):
            $db = \Database::newDB();
            $tbl = $db->addTable('modules');
            $tbl->addFieldConditional('title', 'clipboard');
            $db->delete();
            $db->clearConditional();
            $tbl->addFieldConditional('title', 'demographics');
            $db->delete();
            $db->clearTables();
            if ($db->tableExists('demographics')) {
                $tbl = $db->addTable('demographics');
                $tbl->drop();
            }
            $content[] = <<<EOF
<pre>Core 2.4.0 Changes
--------------------------------
+ Dropping clipboard module.
+ Dropping demographics module.
</pre>
EOF;
        case version_compare($version, '2.4.1', '<'):
            $db = \Database::newDB();
            $db->addTable('modules')->addFieldConditional('title', 'version');
            $db->delete();
            $content[] = <<<EOF
<pre>Core 2.4.1 Changes
--------------------------------
+ Removed Version module from Core modules
+ Pear DB changed to MDB2.
+ MDB2 using mysqli class instead of mysql class to prevent MySQL deprecation warnings.
+ Fixed GD library identification.
+ DTTIME format now includes hour, minute, and seconds set to zero as "all day" is interpreted differently by ical.
+ ResourceFactory returns True on successful load and false otherwise. Previously returned void.
+ Added aspell plugin for CKEditor. Written by Christian Boisjoli.
+ CKeditor
    - altered to have smoother button transitions when width is changed.
    - removed Style button
    - default width is 100% instead of hard coded pixel
    - imports images with img-responsive class added
+ Javascript added to avoid image loading on small screens
+ Fixed createConfig function in setup script
EOF;
        case version_compare($version, '2.4.2', '<'):
            $db = \Database::newDB();
            $t1 = $db->addTable('settings');
            $indexes = $t1->getIndexes();
            if (empty($indexes)) {
                $t1->createPrimaryIndexId();
            }
            $content[] = <<<EOF
<pre>
Core 2.4.2 Changes
--------------------
+ Index added to the Settings table
+ dropIndex and createPrimaryIndexId methods added to Database Table
+ Update autoloader to allow modules classes to be in their own top-level namespace
+ Global/Module: Unnecessary ampersand removed from afterRun
+ Global/Form: setAction missing https check.
+ Global/Form/Input/Date: Added min, max, and step parameters to conform with HTML5
+ Global/Form/Input/Date: setValue parses integer values
+ Global/Form/Label: required parameter made private. It was breaking the required tag.
+ Global/Modal: new class that allows for easier insertion of a bootstrap modal window.
+ Global/Variable/Integer: fixed typo with class name Exception
+ Global/Form: Added removeInput method
+ core/class/PHPWS_DB: Previously, Pear's DB class would return two column results
  as an array with the key as the first column and the value as the second. This
  behavior was inconsistent with the expected functionality. We had code programmed
  expecting this behavior. MDB2 did not replicate it, so two column results were
  broken. New code brings the result back to the expected action.
+ core/class/Link: addClass method added. setClass accepts an array
+ CKeditor: Allows i tags for use with Font Awesome and to not strip spans.
+ CKeditor: Shortened max height on autogrow. Previously, 600px frequently pushed
            it outside the monitor bounds.
</pre>
EOF;
        case version_compare($version, '2.5.0', '<'):
            $content[] = <<<EOF
<pre>
Core 2.5.0 Changes
------------------
+ Added selectAsCSV to Global Database class.
</pre>
EOF;
        case version_compare($version, '2.6.0', '<'):
            $content[] = <<<EOF
<pre>
Core 2.6.0 Changes
------------------
+ Improved DBPager Search bar and pagination
+ Updated CKEditor from 3 to 4.
+ Removed Editor class.
+ Added PHPWS_File stub file to work with autoload.
+ Added method to set width and height on Modal.
+ Added method to pull hidden variables.
+ Removed Simple and Tinymce editors
+ Updated datetimepicker script
</pre>
EOF;
        case version_compare($version, '2.7.0', '<'):
            $content[] = <<<EOF
<pre>
+ Bug Fix: CKEditor images folder returned.
+ Bug Fix: Database - Blank schema error check added to mysql Table class.
+ Bug Fix: Database - Mislabeled return on getDateType.
+ Change: datepicker - script tags put into head.js
+ Update: Bootstrap and Font Awesome version
+ Feature: Database - added "using" ability. Helps with multi-table deletions.
+ Update: Flowplayer version upped. Captioning ability added.
+ Removed: javascript/editor/ directory and all wysiwyg editors outside of ckeditor
+ Removed: Unsupported modules: phpwsbb, podcaster, and profiler
+ Bug Fix: core/class/DBPager - setDefaultOrder was ignored
+ Bug Fix: Removed @ error suppressors throughout code. Should be fun right?
+ Feature: Added exception messages to JsonErrorView.
           Previously info had to be dug out of an html encoded exception object.
+ Bug Fix: Global/Pager Search icon with bad class name
+ Feature: Global/Pager Search columns can now be set manually instead of depending on the headers.
+ Feature: Global/Tag - removeClass method - removes a class previously added to the class variable stack
+ Feature: Added authkey javascript for insertion of the authkey value for use in other js scripts.
+ Added:  &lt;s&gt; as allowed tag.
+ Feature: CKEditor Save button added for use with some modules.
</pre>
EOF;
        case version_compare($version, '2.8.0', '<'):
            $db = \Database::newDB();
            $t = $db->addTable('settings');
            $dt_old = $t->getDataType('setting');
            $dt_update = new \Database\Datatype\Text($t, 'setting');
            $dt_update->setIsNull(true);
            $t->alter($dt_old, $dt_update);
            $content[] = <<<EOF
<pre>2.8.0 changes
--------------------
+ Settings table setting column is now TEXT not VARCHAR.
</pre>               
EOF;
        case version_compare($version, '2.8.1', '<'):
            $db = \Database::newDB();
            $t = $db->addTable('settings');
            $dt_old = $t->getDataType('setting');
            $t->buildDatatype('mediumtext', 'setting');
            $dt_update = new \Database\Datatype\Text($t, 'setting');
            $dt_update->setIsNull(true);
            $t->alter($dt_old, $dt_update);
            $content[] = <<<EOF
<pre>2.8.1 changes
--------------------
+ Settings table setting column is now MEDIUMTEXT not TEXT.
</pre>               
EOF;
    }
    return true;
}
Example #24
0
 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;
 }
<?php

/**
 * This is the xwysiwyg-version of an uninstall file for boost. Edit it to
 * be used with your module.
 *
 * $Id: uninstall.php,v 1.3 2005/11/06 18:48:47 ykuendig Exp $
 */
/* Make sure the user is a deity before running this script */
if (!$_SESSION["OBJ_user"]->isDeity()) {
    header("location:index.php");
    exit;
}
/* Import the uninstall database file and dump the result into the status variable */
if ($status = $GLOBALS["core"]->sqlImport(PHPWS_SOURCE_DIR . "mod/xwysiwyg/boost/uninstall.sql", 1, 1)) {
    $content .= "All xwysiwyg tables successfully removed!<br />";
    if (is_dir("{$GLOBALS['core']->home_dir}files/xwysiwyg/")) {
        if (PHPWS_File::rmdir(PHPWS_HOME_DIR . "files/xwysiwyg")) {
            $content .= "All Files in /files/xwysiwyg removed!<br /><br />";
        } else {
            $content .= "Directory /files/xwysiwyg could NOT be deleted!<br />";
            $content .= "Please delete it manually.<br /><br />";
        }
    }
} else {
    $content .= "There was a problem accessing the database.<br /><br />";
}
$status = 1;
// instead
Example #26
0
 private function checkMimeType($source_directory, $filename, $ftype)
 {
     switch ($ftype) {
         case DOCUMENT_FOLDER:
             $type_list = \PHPWS_Settings::get('filecabinet', 'document_files');
             break;
         case IMAGE_FOLDER:
             $type_list = \PHPWS_Settings::get('filecabinet', 'image_files');
             break;
         case MULTIMEDIA_FOLDER:
             $type_list = \PHPWS_Settings::get('filecabinet', 'media_files');
             break;
     }
     $ext = PHPWS_File::getFileExtension($filename);
     // First check if the extension is allowed for the current folder type.
     $type_array = explode(',', str_replace(' ', '', $type_list));
     if (!in_array($ext, $type_array)) {
         $this->sendErrorHeader('File type not allowed in folder');
     }
     // second check that file is the type it claims to be
     if (!PHPWS_File::checkMimeType($source_directory, $ext)) {
         $this->sendErrorHeader('Unknown file type');
     }
 }
Example #27
0
 public function classifyIntoFolder($folder_id, $files)
 {
     if (empty($files)) {
         return;
     }
     $folder = new Folder($folder_id);
     if (!$folder->id) {
         return;
     }
     $classify_dir = $this->getClassifyDir();
     if (empty($classify_dir)) {
         return;
     }
     switch ($folder->ftype) {
         case IMAGE_FOLDER:
             $type = 'image';
             PHPWS_Core::initModClass('filecabinet', 'Image.php');
             $class_name = 'PHPWS_Image';
             break;
         case DOCUMENT_FOLDER:
             $type = 'document';
             PHPWS_Core::initModClass('filecabinet', 'Document.php');
             $class_name = 'PHPWS_Document';
             break;
         case MULTIMEDIA_FOLDER:
             $type = 'media';
             PHPWS_Core::initModClass('filecabinet', 'Multimedia.php');
             $class_name = 'PHPWS_Multimedia';
             break;
     }
     $allowed_types = $this->getAllowedTypes($type);
     foreach ($files as $filename) {
         $path = $classify_dir . $filename;
         $ext = PHPWS_File::getFileExtension($filename);
         if ($this->fileTypeAllowed($path, $type) && PHPWS_File::checkMimeType($path) && in_array($ext, $allowed_types)) {
             $file_obj = new $class_name();
             $file_obj->folder_id = $folder->id;
             $file_obj->setFilename($filename);
             $file_obj->setTitle(str_replace(".{$ext}", '', $filename));
             $file_obj->setDirectory($folder->getFullDirectory());
             $folder_directory = $file_obj->getPath();
             if (!@rename($path, $folder_directory)) {
                 PHPWS_Error::log(FC_FILE_MOVE, 'filecabinet', 'Cabinet::classifyIntoFolder', $folder_directory);
                 continue;
             }
             $file_obj->file_type = PHPWS_File::getMimeType($file_obj->getPath());
             $file_obj->loadFileSize();
             if ($folder->ftype == IMAGE_FOLDER) {
                 $file_obj->loadDimensions();
                 $file_obj->save(true, false);
             } else {
                 $file_obj->save(false);
             }
         }
     }
 }
Example #28
0
 public function prewriteRotate()
 {
     $degrees = $this->_getDegrees();
     if (!$degrees) {
         return true;
     }
     $tmp_file = $this->_upload->upload['tmp_name'];
     $cpy_file = $tmp_file . '.rs';
     $result = PHPWS_File::rotateImage($tmp_file, $cpy_file, $degrees);
     if (!PHPWS_Error::logIfError($result) && !$result) {
         return PHPWS_Error::get(FC_IMAGE_DIMENSION, 'filecabinet', 'PHPWS_Image::prewriteRotate', array($this->width, $this->height, $this->_max_width, $this->_max_height));
     } else {
         if (!@copy($cpy_file, $tmp_file)) {
             return PHPWS_Error::get(FC_IMAGE_DIMENSION, 'filecabinet', 'PHPWS_Image::prewriteRotate', array($this->width, $this->height, $this->_max_width, $this->_max_height));
         } else {
             list($this->width, $this->height, $image_type, $image_attr) = getimagesize($tmp_file);
             return true;
         }
     }
     return true;
 }
Example #29
0
 public function view()
 {
     if (empty($this->id)) {
         \Layout::add('<h1>Sorry</h1><p>This property is not in our system. Please return to the <a href="./">property listing page</a> to try again.</p>');
         return;
     }
     $tpl = $this->getBaseTpl();
     $refund = '<span style="font-size : 90%">(Refundable)</span>';
     \PHPWS_Core::initModClass('properties', 'Contact.php');
     $max_width = PANEL_WIDTH;
     $max_height = PANEL_HEIGHT;
     \Layout::addStyle('properties', 'view.css');
     $tpl['NAME'] = $this->viewLink($this->name);
     $photos = $this->getPhotos();
     if ($photos) {
         javascriptMod('properties', 'galleryview', array('panel_width' => $max_width, 'panel_height' => $max_height));
         foreach ($photos as $p) {
             if (is_file($p['path'])) {
                 $dim = getimagesize($p['path']);
                 $width =& $dim[0];
                 $height =& $dim[1];
                 $diff = \PHPWS_File::getDiff($width, $max_width, $height, $max_height);
                 $new_width = round($width * $diff);
                 $new_height = round($height * $diff);
                 if ($new_width > $max_width || $new_height > $max_height) {
                     $diff = \PHPWS_File::getDiff($new_width, $max_width, $new_height, $max_height);
                     $new_width = round($width * $diff);
                     $new_height = round($height * $diff);
                 }
             } else {
                 $p['path'] = PHPWS_SOURCE_HTTP . 'mod/properties/img/no_photo.gif';
                 $p['title'] = 'Photo not found';
                 $new_width = '150px';
                 $new_height = '113px';
             }
             $all[] = sprintf('<li><img src="%s" title="%s" />
         <div class="panel-content lightbox">
         <a class="lightbox" href="%s"><img src="%s" width="%s" height="%s" /></a>
         </div></li>', Photo::thumbnailPath($p['path']), $p['title'], $p['path'], $p['path'], $new_width, $new_height);
         }
         $tpl['PHOTOS'] = implode("\n", $all);
     } else {
         $tpl['NO_PHOTO'] = '<img src="' . PHPWS_SOURCE_HTTP . 'mod/properties/img/no_photo.gif" alt="No photo" title="No photos available" />';
     }
     $contact = new Contact($this->contact_id);
     if (!empty($contact->company_address)) {
         $tpl['COMPANY_ADDRESS'] = $contact->getCompanyAddress();
         $tpl['GOOGLE_COMPANY'] = sprintf('<a target="_blank" href="http://maps.google.com/maps?q=%s">
     <img class="google-map" src="%smod/properties/img/google-pin-red.gif" title="Google maps" target="_blank" /></a>', Property::googleMapUrl($contact->company_address), PHPWS_SOURCE_HTTP);
     }
     $tpl['COMPANY_NAME'] = $contact->getCompanyUrl();
     $tpl['EMAIL'] = $contact->getEmailAddress(true);
     $tpl['PHONE'] = $contact->getPhone();
     $tpl['TIMES_AVAILABLE'] = $contact->getTimesAvailable();
     $tpl['ADDRESS'] = $this->getAddress();
     $tpl['GOOGLE_MAP'] = sprintf('<a target="_blank" href="http://maps.google.com/maps?q=%s">
     <img src="%smod/properties/img/google-pin-red.gif" title="Google maps" target="_blank" /></a>', Property::googleMapUrl($this->address), PHPWS_SOURCE_HTTP);
     $tpl['LEASE_TYPE'] = $this->getLeaseType();
     if ($this->efficiency) {
         $tpl['BEDROOMS'] = 'One room efficiency';
     } else {
         $tpl['BEDROOMS'] = $this->bedroom_no;
     }
     $tpl['BATHROOMS'] = $this->getBathroomNo();
     if ($this->window_number) {
         $tpl['WINDOWS'] = 'Yes';
     } else {
         $tpl['WINDOWS'] = 'No';
     }
     if (!empty($this->admin_fee_amt)) {
         $tpl['ADMIN_FEE'] = '$' . $this->getAdminFeeAmt();
         $tpl['ADMIN_FEE_REFUND'] = $this->admin_fee_refund ? $refund : null;
     }
     if (!empty($this->parking_fee)) {
         $tpl['PARKING_FEE'] = '$' . $this->getParkingFee();
     }
     if (!empty($this->security_amt)) {
         $tpl['SECURITY_AMT'] = '$' . $this->getSecurityAmt();
         $tpl['SECURITY_REFUND'] = $this->security_refund ? $refund : null;
     }
     if (!empty($this->other_fees)) {
         $tpl['OTHER_FEES'] = $this->getOtherFees();
     }
     if (!empty($this->clean_fee_amt)) {
         $tpl['CLEAN_FEE_AMT'] = '$' . $this->getCleanFeeAmt();
         $tpl['CLEAN_FEE_REFUND'] = $this->clean_fee_refund ? $refund : null;
     }
     $tpl['PARKING_PER_UNIT'] = $this->getParkingPerUnit();
     if ($this->pets_allowed) {
         $tpl['PETS_ALLOWED'] = 'Yes';
         $tpl['PET_TYPES'] = $this->getPetType();
         if ($this->pet_deposit) {
             $tpl['PET_DEPOSIT'] = '$' . $this->getPetDeposit() . ' <span style="font-size : 90%">(refundable)</span>';
         } else {
             $tpl['PET_DEPOSIT'] = 'None';
         }
         if ($this->pet_fee) {
             $tpl['PET_FEE'] = '$' . $this->getPetFee() . ' <span style="font-size : 90%">(nonrefundable)</span>';
         } else {
             $tpl['PET_FEE'] = 'None';
         }
     } else {
         $tpl['PETS_ALLOWED'] = 'No';
     }
     $utility_allowance = false;
     $tpl['STUDENT_TYPE'] = $this->getStudentType();
     if ($this->util_water) {
         $utility_allowance = true;
         $tpl['UTIL_WATER'] = $this->getUtilWater();
     }
     if ($this->util_trash) {
         $utility_allowance = true;
         $tpl['UTIL_TRASH'] = $this->getUtilTrash();
     }
     if ($this->util_power) {
         $utility_allowance = true;
         $tpl['UTIL_POWER'] = $this->getUtilPower();
     }
     if ($this->util_fuel) {
         $utility_allowance = true;
         $tpl['UTIL_FUEL'] = $this->getUtilFuel();
     }
     if ($this->util_cable) {
         $utility_allowance = true;
         $tpl['UTIL_CABLE'] = $this->getUtilCable();
     }
     if ($this->util_internet) {
         $utility_allowance = true;
         $tpl['UTIL_INTERNET'] = $this->getUtilInternet();
     }
     if ($this->util_phone) {
         $utility_allowance = true;
         $tpl['UTIL_PHONE'] = $this->getUtilPhone();
     }
     $photo = new Photo();
     $photo->setPropertyId($this->id);
     if (isset($_GET['photo'])) {
         $data['pid'] = $this->id;
     }
     $data['view'] = 1;
     if (\Current_User::allow('properties')) {
         javascriptMod('properties', 'photo_upload', $data);
         $tpl['ADD_PHOTO'] = $photo->uploadNew(false);
         $tpl['EDIT'] = \PHPWS_Text::secureLink('<i class="fa fa-edit"></i> Edit', 'properties', array('aop' => 'edit_property', 'pid' => $this->id), null, null, 'btn btn-default');
         if (!$this->active) {
             $tpl['ACTIVE'] = '<div id="not-active">This property is currently NOT ACTIVE</div>';
         }
     } elseif (isset($_SESSION['Contact_User']->id) && $_SESSION['Contact_User']->id == $this->contact_id) {
         if (!$this->active) {
             $tpl['ACTIVE'] = '<div id="not-active">This property is currently NOT ACTIVE</div>';
         }
         $data['is_contact'] = 1;
         javascriptMod('properties', 'photo_upload', $data);
         $tpl['ADD_PHOTO'] = $photo->uploadNew(false);
         $tpl['EDIT'] = \PHPWS_Text::moduleLink('Edit property', 'properties', array('cop' => 'edit_property', 'pid' => $this->id, 'k' => $_SESSION['Contact_User']->getKey()));
     } elseif (!$this->active) {
         \Layout::add('This property is currently not available');
         return;
     }
     $heat_type = $this->getHeatType();
     if ($heat_type) {
         $tpl['HEAT_TYPE'] = implode(', ', $this->getHeatType());
     }
     $content = \PHPWS_Template::process($tpl, 'properties', 'view.tpl');
     \Layout::add($content);
 }
Example #30
0
 public static function writeIni($switch = 0)
 {
     PHPWS_Core::initCoreClass('File.php');
     $info = "cache = {$switch}\n";
     return PHPWS_File::writeFile(CACHE_DIRECTORY . 'phpws_cache.ini', $info, TRUE);
 }