public function save()
 {
     $result = parent::save();
     if (PHPWS_Error::isError($result)) {
         return $result;
     }
     $db = new PHPWS_DB('analytics_tracker_owa');
     $db->addWhere('id', $this->id);
     $result = $db->select();
     if (PHPWS_Error::logIfError($result)) {
         return $result;
     }
     $db = new PHPWS_DB('analytics_tracker_owa');
     $db->addValue('id', $this->id);
     $db->addValue('owa_url', $this->owa_url);
     $db->addValue('owa_site_id', $this->owa_site_id);
     $db->addValue('owa_track_page_view', $this->owa_track_page_view);
     $db->addValue('owa_track_clicks', $this->owa_track_clicks);
     $db->addValue('owa_track_domstream', $this->owa_track_domstream);
     if (count($result) < 1) {
         $result = $db->insert(false);
     } else {
         $result = $db->update();
     }
     if (PHPWS_Error::logIfError($result)) {
         return $result;
     }
 }
Example #2
0
 public function save()
 {
     $result = parent::save();
     if (PHPWS_Error::isError($result)) {
         return $result;
     }
     $db = new PHPWS_DB('analytics_tracker_piwik');
     $db->addWhere('id', $this->id);
     $result = $db->select();
     if (PHPWS_Error::logIfError($result)) {
         return $result;
     }
     $db = new PHPWS_DB('analytics_tracker_piwik');
     $db->addValue('id', $this->id);
     $db->addValue('piwik_url', $this->piwik_url);
     $db->addValue('piwik_id', $this->piwik_id);
     if (count($result) < 1) {
         $result = $db->insert(false);
     } else {
         $result = $db->update();
     }
     if (PHPWS_Error::logIfError($result)) {
         return $result;
     }
 }
 public static function saveObject(DbStorable $o)
 {
     $vars = $o->extractVars();
     $tableName = $o::getTableName();
     // Check if the key already exists
     $query = "SELECT * FROM {$tableName} WHERE id = {$vars['id']}";
     $result = \PHPWS_DB::getAll($query);
     if (count($result) > 0) {
         $exists = true;
     } else {
         $exists = false;
     }
     $db = new \PHPWS_DB($o->getTableName());
     foreach ($vars as $key => $value) {
         $db->addValue($key, $value);
     }
     if ($exists) {
         $db->addWhere('id', $vars['id']);
         $result = $db->update();
     } else {
         $result = $db->insert(false);
     }
     if (\PHPWS_Error::logIfError($result)) {
         throw new \Exception($result->toString());
     }
 }
Example #4
0
 /**
  * Saves the current activity log object to the db.
  * Returns TRUE upon succes or a PEAR error object otherwise.
  */
 public function save()
 {
     if ($this->id != 0) {
         return FALSE;
     }
     $db = new PHPWS_DB('hms_activity_log');
     $db->addValue('user_id', $this->get_user_id());
     $db->addValue('timestamp', $this->get_timestamp());
     $db->addValue('activity', $this->get_activity());
     $db->addValue('actor', $this->get_actor());
     $db->addValue('notes', $this->get_notes());
     $result = $db->insert();
     if (PHPWS_Error::logIfError($result)) {
         throw new DatabaseException($result->toString());
     } else {
         return TRUE;
     }
 }
Example #5
0
 public function addUser($username, $classname, $instance = null)
 {
     $db = new PHPWS_DB('users');
     $db->addWhere('username', $username);
     $result = $db->select('row');
     if (PHPWS_Error::logIfError($result)) {
         throw new DatabaseException($result->toString());
     }
     if (is_null($result['id'])) {
         throw new InvalidArgumentException('User name "' . $username . '" does not exist.');
     }
     $user_id = $result['id'];
     $db = new PHPWS_DB('hms_user_role');
     $db->addValue('user_id', $user_id);
     $db->addValue('role', $this->id);
     $db->addValue('class', strtolower($classname));
     $db->addValue('instance', $instance);
     $result = $db->insert();
     if (PHPWS_Error::logIfError($result)) {
         throw new DatabaseException($result->toString());
     }
     return true;
 }
Example #6
0
 public static function registerModule($module)
 {
     $db = new PHPWS_DB('phpws_key_register');
     $db->addValue('module', $module);
     return $db->insert();
 }
Example #7
0
 /**
  * updates the settings table
  */
 public static function save($module)
 {
     if (!PHPWS_Settings::is_set($module)) {
         return false;
     }
     $db = new PHPWS_DB('mod_settings');
     $db->addWhere('module', $module);
     $db->addWhere('setting_name', array_keys($GLOBALS['PHPWS_Settings'][$module]));
     $db->delete();
     $db->reset();
     foreach ($GLOBALS['PHPWS_Settings'][$module] as $key => $value) {
         if (empty($key)) {
             continue;
         }
         $type = PHPWS_Settings::getType($value);
         $db->addValue('module', $module);
         $db->addValue('setting_name', $key);
         $db->addValue('setting_type', $type);
         switch ($type) {
             case 1:
                 $db->addValue('small_num', (int) $value);
                 break;
             case 2:
                 $db->addValue('large_num', (int) $value);
                 break;
             case 3:
                 $db->addValue('small_char', $value);
                 break;
             case 4:
                 $db->addValue('large_char', $value);
                 break;
         }
         $result = $db->insert();
         if (PHPWS_Error::isError($result)) {
             unset($GLOBALS['PHPWS_Settings'][$module]);
             PHPWS_Settings::load($module);
             return $result;
         }
         $db->reset();
     }
     unset($GLOBALS['PHPWS_Settings'][$module]);
     PHPWS_Settings::load($module);
 }
Example #8
0
 function viewArchive()
 {
     $content = $_SESSION['PHAT_FormManager']->menu();
     $filename = PHPWS_HOME_DIR . 'files/phatform/archive/' . $_REQUEST['ARCHIVE_filename'];
     if (is_file($filename)) {
         $fileContent = file($filename);
     } else {
         $content .= dgettext('phatform', 'Archive file was not found.');
         $content .= $this->viewArchives();
         return $content;
     }
     if (empty($fileContent)) {
         $content .= dgettext('phatform', 'File contained no content.');
         $content .= $this->viewArchives();
         return $content;
     }
     if (isset($_REQUEST['ARCHIVE_filename'])) {
         $this->filename = $_REQUEST['ARCHIVE_filename'];
     }
     $buildingSQL = FALSE;
     $endCreateSmnt = 0;
     $formNum = NULL;
     $sql = '';
     // extract out table containing report data
     for ($i = 0; $i < count($fileContent); $i++) {
         $line = $fileContent[$i];
         if (stristr($line, 'CREATE TABLE mod_phatform_form_') && ($line[0] != '#' && ($line[0] != '-' && $line[1] != '-'))) {
             $buildingSQL = TRUE;
             ereg('form_([0-9]+)', $line, $formNumArr);
             $formNum = $formNumArr[1];
         }
         if ($buildingSQL == TRUE) {
             $sql .= $line;
         }
         if ($buildingSQL == TRUE && stristr($line, ';')) {
             $endCreateSmnt = $i + 6;
             break;
         }
     }
     if (empty($sql)) {
         $content .= dgettext('phatform', 'File contained no archive to view.');
         $content .= $this->viewArchives();
         return $content;
     }
     $orgnTableName = 'mod_phatform_form_' . $formNum;
     $newTableName = time() . $orgnTableName;
     $sql = str_replace($orgnTableName, $newTableName, $sql);
     $db = new PHPWS_DB('mod_phatform_forms');
     $db->addWhere('archiveTableName', '%' . $orgnTableName . '%', 'LIKE');
     $result = $db->select();
     if ($result) {
         foreach ($result as $form) {
             if ($form['archiveFileName'] == $this->filename) {
                 return $this->readyViewArchive($form['id'], $form['archiveTableName']);
             }
         }
     }
     if (isset($_REQUEST['yes'])) {
         // create main report table
         PHPWS_DB::query(trim($sql));
         $inserts = FALSE;
         for ($j = $endCreateSmnt; $j < count($fileContent); $j++) {
             $line = $fileContent[$j];
             // check if finished inserting report data
             if (stristr($line, 'CREATE TABLE')) {
                 break;
             }
             // check to see if finished with comments and spaces before insert commands
             if (stristr($line, 'INSERT INTO ')) {
                 $inserts = TRUE;
             }
             // line is insertion data so put in database
             if ($inserts) {
                 $sql = trim($line);
                 if (!empty($sql) && stristr($sql, $orgnTableName)) {
                     $sql = str_replace($orgnTableName, $newTableName, $sql);
                     PHPWS_DB::query(trim($sql));
                 } else {
                     break;
                 }
             }
         }
         // create special archive form so keep track of archived forms
         $data['owner'] = $_SESSION['OBJ_user']->username;
         $data['editor'] = $_SESSION['OBJ_user']->username;
         $data['ip'] = $_SERVER['REMOTE_ADDR'];
         $data['label'] = dgettext('phatform', 'Archived Form');
         $data['groups'] = NULL;
         $data['created'] = time();
         $data['updated'] = time();
         $data['hidden'] = 1;
         $data['approved'] = 1;
         $data['saved'] = 1;
         $data['archiveTableName'] = $newTableName;
         $data['archiveFileName'] = $_REQUEST['ARCHIVE_filename'];
         $db = new PHPWS_DB('mod_phatforms_forms');
         $db->addValue($data);
         $formId = $db->insert();
         return $this->readyViewArchive($formId, $newTableName);
     } else {
         if (isset($_REQUEST['no'])) {
             $content .= dgettext('phatform', 'Viewing of archive has been canceled.');
             $content .= $this->viewArchives();
             return $content;
         } else {
             $elements[0] = PHPWS_Form::formHidden('module', 'phatform');
             $elements[0] .= PHPWS_Form::formHidden('ARCHIVE_OP', 'viewArchive');
             $elements[0] .= PHPWS_Form::formHidden('ARCHIVE_filename', $_REQUEST['ARCHIVE_filename']);
             $elements[0] .= PHPWS_Form::formSubmit(dgettext('phatform', 'Yes'), 'yes');
             $elements[0] .= PHPWS_Form::formSubmit(dgettext('phatform', 'No'), 'no');
             $content .= dgettext('phatform', 'In order to view this archive a new table will need to added to your database.') . '<br /><br />';
             $content .= '<b>' . dgettext('phatform', 'Are you sure you wish to view this archive?') . '</b><br /><br />';
             $content .= PHPWS_Form::makeForm('archive_view', 'index.php', $elements);
             return $content;
         }
     }
 }
Example #9
0
 public function save()
 {
     if (empty($this->key_id) || empty($this->keywords)) {
         return FALSE;
     }
     $db = new PHPWS_DB('search');
     $db->addWhere('key_id', $this->key_id);
     $db->delete();
     $db->reset();
     $key = new Key($this->key_id);
     $db->addValue('key_id', $key->id);
     $db->addValue('module', $key->module);
     $db->addValue('created', $key->create_date);
     if (is_array($this->keywords)) {
         $keywords = implode(' ', $this->keywords);
     } else {
         $keywords = $this->keywords;
     }
     $db->addValue('keywords', $keywords);
     return $db->insert();
 }
Example #10
0
 public function convertToFileAssoc($table, $column, $type)
 {
     $db = new PHPWS_DB('fc_convert');
     $db->addWhere('table_name', $table);
     $db->addWhere('column_name', $column);
     $result = $db->select();
     if (PHPWS_Error::logIfError($result)) {
         return false;
     } elseif ($result) {
         return true;
     }
     PHPWS_Core::initModClass('filecabinet', 'File_Assoc.php');
     $db = new PHPWS_DB($table);
     $db->addColumn('id');
     $db->addColumn($column);
     $db->setIndexBy('id');
     $item = $db->select('col');
     if (empty($item)) {
         return true;
     }
     foreach ($item as $id => $item_id) {
         $db->reset();
         if (isset($item_converted[$item_id])) {
             $file_assoc_id = $item_converted[$item_id];
             $db->addValue($column, $file_assoc_id);
             $db->addWhere('id', $id);
             PHPWS_Error::logIfError($db->update());
         } else {
             $file_assoc = new FC_File_Assoc();
             $file_assoc->file_type = $type;
             $file_assoc->file_id = $item_id;
             if (!PHPWS_Error::logIfError($file_assoc->save())) {
                 $db->addValue($column, $file_assoc->id);
                 $db->addWhere('id', $id);
                 if (PHPWS_Error::logIfError($db->update())) {
                     continue;
                 }
             }
             $item_converted[$item_id] = $file_assoc->id;
         }
     }
     $db->reset();
     $db->addValue('table_name', $table);
     $db->addValue('column_name', $column);
     PHPWS_Error::logIfError($db->insert());
     return true;
 }
Example #11
0
 public static function lockBlock($block_id, $key_id)
 {
     $block_id = (int) $block_id;
     $key_id = (int) $key_id;
     unset($_SESSION['Pinned_Blocks'][$block_id]);
     $values['block_id'] = $block_id;
     $values['key_id'] = $key_id;
     $db = new PHPWS_DB('block_pinned');
     $db->addWhere($values);
     $result = $db->delete();
     $db->addValue($values);
     return $db->insert();
 }
Example #12
0
 public function saveReasons()
 {
     // Save reason assignments
     $db = new PHPWS_DB('checkin_rtos');
     $db->addWhere('staff_id', $this->id);
     $db->delete();
     if ($this->filter_type & REASON_BITMASK) {
         foreach ($this->_reasons as $rid) {
             $db->reset();
             $db->addValue('staff_id', $this->id);
             $db->addValue('reason_id', $rid);
             PHPWS_Error::logIfError($db->insert());
         }
     }
 }
Example #13
0
 public function lottery_reserve($username, $requestor, $timestamp)
 {
     if ($this->is_lottery_reserved()) {
         return FALSE;
     }
     $db = new PHPWS_DB('hms_lottery_reservation');
     $db->addValue('asu_username', $username);
     $db->addValue('requestor', $requestor);
     $db->addValue('term', $this->term);
     $db->addValue('bed_id', $this->id);
     $db->addValue('expires_on', $timestamp);
     $result = $db->insert();
     if (PHPWS_Error::logIfError($result)) {
         throw new DatabaseException($result->toString());
     } else {
         return TRUE;
     }
 }
Example #14
0
 /**
  * Saves the parameters from this report to the database.
  *
  * @throws DatabaseException
  */
 public function saveParams()
 {
     $params = $this->getParams();
     if (empty($params)) {
         return;
     }
     $db = new PHPWS_DB('hms_report_param');
     foreach ($params as $key => $value) {
         $db->reset();
         $db->addValue('report_id', $this->report->getId());
         $db->addValue('param_name', $key);
         $db->addValue('param_value', $value);
         $result = $db->insert();
         if (PHPWS_Error::logIfError($result)) {
             throw new DatabaseException($result->toString());
         }
     }
 }
Example #15
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 #16
0
 public function save($item_id, $table, $total_backups = 5)
 {
     if (!PHPWS_DB::isTable($table)) {
         return FALSE;
     }
     $backupTable = Backup::getBackupTable($table);
     if (PHPWS_Error::isError($backupTable)) {
         return $backupTable;
     }
     $db = new PHPWS_DB($table);
     $db->addWhere('id', $item_id);
     $source_row = $db->select('row');
     $db2 = new PHPWS_DB($backupTable);
     $db2->addWhere('backup_id', $source_row['id']);
     $db2->addOrder('backup_order');
     $past_rows = $db2->select();
     $past_row_count = count($past_rows);
     if (empty($past_rows) || $past_row_count < $total_backups) {
         $db2->reset();
         $source_row['backup_id'] = $source_row['id'];
         unset($source_row['id']);
         $source_row['backup_order'] = $past_row_count + 1;
         $db2->addValue($source_row);
         $result = $db2->insert();
     } else {
         $db2->delete();
         $db2->reset();
         unset($past_rows[0]);
         $source_row['backup_id'] = $source_row['id'];
         unset($source_row['id']);
         $past_rows[] = $source_row;
         foreach ($past_rows as $key => $row) {
             $row['backup_order'] = $key;
             $db2->addValue($row);
             $db2->insert();
             $db2->resetValues();
         }
     }
 }
Example #17
0
 /**
  * Save the options for this PHAT_Element
  *
  * @return mixed  Content if the editing is to continue, PHPWS_Error on failure, or message on success
  * @access public
  */
 function saveOptions()
 {
     $className = get_class($this);
     $properName = ucfirst(str_ireplace('phat_', '', $className));
     if (is_array($_REQUEST['PHAT_ElementOptions']) && is_array($_REQUEST['PHAT_ElementValues'])) {
         $saveText = TRUE;
         $returnText = NULL;
         $saveValues = TRUE;
         $atLeastOne = FALSE;
         if (isset($_REQUEST['PHAT_ElementUseText'])) {
             $_REQUEST['PHAT_ElementValues'] = $_REQUEST['PHAT_ElementOptions'];
             $this->setOptionSet();
         }
         for ($i = 0; $i < sizeof($_REQUEST['PHAT_ElementOptions']); $i++) {
             if ($_REQUEST['PHAT_ElementOptions'][$i] != NULL) {
                 $this->_optionText[$i] = PHPWS_Text::parseInput($_REQUEST['PHAT_ElementOptions'][$i]);
             } else {
                 $this->_optionText[$i] = NULL;
                 $saveText = FALSE;
             }
             if ($_REQUEST['PHAT_ElementValues'][$i] != NULL) {
                 $this->_optionValues[$i] = PHPWS_Text::parseInput($_REQUEST['PHAT_ElementValues'][$i]);
                 $atLeastOne = TRUE;
             } else {
                 $this->_optionValues[$i] = NULL;
                 $saveValues = FALSE;
             }
         }
         if ($className == 'PHAT_Checkbox' || $className == 'PHAT_Multiselect') {
             for ($i = 0; $i < sizeof($_REQUEST['PHAT_ElementOptions']); $i++) {
                 if (isset($_REQUEST['PHAT_ElementDefault']) && isset($_REQUEST['PHAT_ElementDefault'][$i])) {
                     $this->_value[$i] = $_REQUEST['PHAT_ElementValues'][$_REQUEST['PHAT_ElementDefault'][$i]];
                 }
             }
         } else {
             if (isset($_REQUEST['PHAT_ElementDefault'])) {
                 $this->_value = $_REQUEST['PHAT_ElementValues'][$_REQUEST['PHAT_ElementDefault']];
             } else {
                 $this->_value = NULL;
             }
         }
         if ($saveText && $saveValues) {
             if ($_REQUEST['PHAT_SaveOptionSet']) {
                 $label = PHPWS_Text::parseInput($_REQUEST['PHAT_SaveOptionSet']);
                 $options = addslashes(serialize($this->_optionText));
                 $values = addslashes(serialize($this->_optionValues));
                 $saveArray = array('label' => $label, 'optionSet' => $options, 'valueSet' => $values);
                 $db = new PHPWS_DB('mod_phatform_options');
                 $db->addValue($saveArray);
                 $id = $db->insert();
                 if ($id) {
                     $this->setOptionSet($id);
                     $returnText = sprintf(dgettext('phatform', 'The option set %s was successfully saved.'), '<b><i>' . $label . '</i></b>') . '<br />';
                 } else {
                     return PHPWS_Error::get(PHATFORM_OPTION_WONT_SAVE, 'phatform', 'PHAT_Element::saveOptions()', array($label));
                 }
             }
             if (PHPWS_Error::isError($this->commit())) {
                 return PHPWS_Error::get(PHATFORM_ELEMENT_FAIL, 'phatform', 'PHAT_Element::saveOptions()', array($properName));
             } else {
                 $returnText .= sprintf(dgettext('phatform', 'The %s was saved successfully.'), '<b><i>' . $properName . '</i></b>');
                 return $returnText;
             }
         } else {
             if ($atLeastOne) {
                 return PHPWS_Error::get(PHATFORM_VALUES_NOT_SET, 'phatform', 'PHAT_Element::saveOptions()');
             } else {
                 return PHPWS_Error::get(PHATFORM_VAL_OPT_NOT_SET, 'phatform', 'PHAT_Element::saveOptions()');
             }
         }
     } else {
         return PHPWS_Error::get(PHATFORM_ELEMENT_FAIL, 'phatform', 'PHAT_Element::saveOptions()', array($properName));
     }
 }
Example #18
0
 public static function registerMyPage($mod_title)
 {
     $filename = sprintf('%smod/%s/inc/my_page.php', PHPWS_SOURCE_DIR, $mod_title);
     if (!is_file($filename)) {
         return FALSE;
     }
     $db = new PHPWS_DB('users_my_page_mods');
     $db->addValue('mod_title', $mod_title);
     return $db->insert();
 }
Example #19
0
 function _saveFormData()
 {
     $error = NULL;
     /* Setup start and end values for the elements loop */
     $start = $this->_position;
     if ($this->_position + $this->_pageLimit > sizeof($this->_elements)) {
         $end = $this->_position + (sizeof($this->_elements) - $this->_position);
     } else {
         $end = $this->_position + $this->_pageLimit;
     }
     /* Loop through elements and setup query array for database interaction */
     for ($i = $start; $i < $end; $i++) {
         $elementInfo = explode(':', $this->_elements[$i]);
         $this->element = new $elementInfo[0]($elementInfo[1]);
         if ($this->element->isRequired() && (!isset($_REQUEST['PHAT_' . $this->element->getLabel()]) || $_REQUEST['PHAT_' . $this->element->getLabel()] == NULL)) {
             $error = PHPWS_Error::get(PHATFORM_REQUIRED_MISSING, 'phatform', 'PHAT_Form::_saveFormData');
         }
         if ($this->_editData) {
             $this->_userData[$this->element->getLabel()] = $_REQUEST['PHAT_' . $this->element->getLabel()];
         }
         if (isset($_REQUEST['PHAT_' . $this->element->getLabel()])) {
             if (is_string($_REQUEST['PHAT_' . $this->element->getLabel()]) && strlen($_REQUEST['PHAT_' . $this->element->getLabel()]) > PHAT_MAX_CHARS_TEXT_ENTRY) {
                 $error = PHPWS_Error::get(PHATFORM_TEXT_MAXSIZE_PASSED, 'phatform', 'PHAT_Form::_saveFormData', array($this->element->getLabel()));
             }
             $queryData[$this->element->getLabel()] = $_REQUEST['PHAT_' . $this->element->getLabel()];
         }
     }
     /* If no errors occured, move the user to the next page in this form */
     if (!PHPWS_Error::isError($error)) {
         if ($this->currentPage() != $this->numPages()) {
             $this->_position += $this->_pageLimit;
         } else {
             $this->_position = -1;
         }
     }
     if (!$this->_anonymous) {
         $queryData['user'] = Current_User::getUsername();
     } else {
         $queryData['user'] = '******';
     }
     $queryData['position'] = $this->_position;
     $queryData['updated'] = time();
     /* Check to see if this user has started entering data for this form yet */
     $db = new PHPWS_DB('mod_phatform_form_' . $this->getId());
     $db->addValue($queryData);
     if (isset($this->_dataId)) {
         $db->addWhere('id', $this->_dataId);
         $db->update();
     } else {
         $result = $db->insert();
         if (PHPWS_Error::isError($result)) {
             PHPWS_Error::log($result);
         } else {
             $this->_dataId = $result;
         }
     }
     return $error;
 }
 public function updateSequenceTable()
 {
     $this->addColumn('id', 'max');
     $max_id = $this->select('one');
     if (PHPWS_Error::isError($max_id)) {
         return $max_id;
     }
     if ($max_id > 0) {
         $seq_table = $this->getTable(false) . '_seq';
         if (!$this->isTable($seq_table)) {
             $table = $this->addPrefix($this->getTable(false));
             $GLOBALS['PHPWS_DB']['connection']->nextId($table);
         }
         $seq = new PHPWS_DB($seq_table);
         $result = $seq->select('one');
         if (PHPWS_Error::logIfError($result)) {
             return false;
         }
         $seq->addValue('id', $max_id);
         if (!$result) {
             return $seq->insert(false);
         } else {
             return $seq->update();
         }
     }
     return true;
 }
 public static function postMeta()
 {
     $values['page_title'] = strip_tags($_POST['page_title']);
     $values['meta_keywords'] = strip_tags($_POST['meta_keywords']);
     $values['meta_description'] = strip_tags($_POST['meta_description']);
     if (isset($_POST['index'])) {
         $index = 1;
     } else {
         $index = 0;
     }
     if (isset($_POST['follow'])) {
         $follow = 1;
     } else {
         $follow = 0;
     }
     PHPWS_Settings::set('layout', 'use_key_summaries', (int) isset($_POST['use_key_summaries']));
     PHPWS_Settings::save('layout');
     $values['meta_robots'] = $index . $follow;
     if (isset($_POST['key_id'])) {
         $key_id = (int) $_POST['key_id'];
     }
     if (isset($key_id)) {
         $values['key_id'] = $key_id;
         $db = new PHPWS_DB('layout_metatags');
         $db->addWhere('key_id', $key_id);
         $db->delete();
         if (isset($_POST['reset'])) {
             return true;
         }
         $db->reset();
         $db->addValue($values);
         return $db->insert();
     } else {
         $db = new PHPWS_DB('layout_config');
         $db->addValue($values);
         return $db->update();
     }
 }
Example #22
0
 public function saveDependencies()
 {
     if (!$this->_dependency) {
         return true;
     }
     $db = new PHPWS_DB('dependencies');
     $db->addWhere('source_mod', $this->title);
     $db->delete();
     $db->reset();
     $dep_list = $this->getDependencies();
     if (empty($dep_list)) {
         return null;
     }
     foreach ($dep_list['MODULE'] as $stats) {
         $db->addValue('source_mod', $this->title);
         $db->addValue('depended_on', $stats['TITLE']);
         $db->addValue('version', $stats['VERSION']);
         $result = $db->insert();
         if (PHPWS_Error::isError($result)) {
             return $result;
         }
     }
 }
Example #23
0
function createLocalAuthScript()
{
    /*
        if (PHPWS_Settings::get('users', 'local_script')) {
       return true;
        }
    * 
    */
    $db = new PHPWS_DB('users_auth_scripts');
    $db->addValue('display_name', dgettext('users', 'Local'));
    $db->addValue('filename', 'local.php');
    $authorize_id = $db->insert();
    if (PHPWS_Error::logIfError($authorize_id)) {
        return false;
    }
    PHPWS_Settings::set('users', 'default_authorization', $authorize_id);
    PHPWS_Settings::set('users', 'local_script', $authorize_id);
    PHPWS_Settings::save('users');
    return true;
}
Example #24
0
 public function emailPasswordReset($user_id, $email)
 {
     $db = new PHPWS_DB('users_pw_reset');
     // clear old reset rows
     $db->addWhere('timeout', time(), '<');
     PHPWS_Error::logIfError($db->delete());
     $db->reset();
     // check to see if they have already submitted a request
     $db->addWhere('user_id', (int) $user_id);
     $db->addColumn('user_id');
     $reset_present = $db->select('one');
     if (PHPWS_Error::logIfError($reset_present)) {
         return false;
     } elseif ($reset_present) {
         return true;
     }
     $db->reset();
     $page_title = $_SESSION['Layout_Settings']->getPageTitle(true);
     $url = PHPWS_Core::getHomeHttp();
     $hash = md5(time() . $email);
     $message[] = dgettext('users', 'Did you forget your password at our site?');
     $message[] = dgettext('users', 'If so, you may click the link below to reset it.');
     $message[] = '';
     $message[] = sprintf('%sindex.php?module=users&action=user&command=rp&auth=%s', $url, $hash);
     $message[] = '';
     $message[] = dgettext('users', 'If you did not wish to reset your password, you may ignore this message.');
     $message[] = dgettext('users', 'You have one hour to respond.');
     $body = implode("\n", $message);
     PHPWS_Core::initCoreClass('Mail.php');
     $mail = new PHPWS_Mail();
     $mail->addSendTo($email);
     $mail->setSubject(dgettext('users', 'Forgot your password?'));
     $site_contact = PHPWS_User::getUserSetting('site_contact');
     $mail->setFrom(sprintf('%s<%s>', $page_title, $site_contact));
     $mail->setMessageBody($body);
     if ($mail->send()) {
         $db->addValue('user_id', $user_id);
         $db->addValue('authhash', $hash);
         // 1 hour limit = 3600
         $db->addValue('timeout', time() + 3600);
         if (PHPWS_Error::logIfError($db->insert())) {
             return false;
         } else {
             return true;
         }
     } else {
         return false;
     }
 }
Example #25
0
 public function save()
 {
     $db = new PHPWS_DB('users_groups');
     $result = $db->saveObject($this);
     $members = $this->getMembers();
     if (isset($members)) {
         $this->dropAllMembers();
         $db = new PHPWS_DB('users_members');
         foreach ($members as $member) {
             $db->addValue('group_id', $this->getId());
             $db->addValue('member_id', $member);
             PHPWS_Error::logIfError($db->insert());
             $db->resetValues();
         }
     }
 }
Example #26
0
 public function create_core()
 {
     $db = new PHPWS_DB();
     $loaddb = \PHPWS_DB::loadDB($this->getDSN(), $this->dbprefix);
     if (PHPWS_Error::isError($loaddb)) {
         return $loaddb;
     }
     $result = $db->importFile(PHPWS_SOURCE_DIR . 'core/boost/install.sql');
     if ($result == TRUE) {
         $db->setTable('core_version');
         include PHPWS_SOURCE_DIR . 'core/boost/boost.php';
         $db->addValue('version', $version);
         $result = $db->insert();
         if (PHPWS_Error::isError($result)) {
             PHPWS_Error::log($result);
             return $result;
         }
         Branch::loadHubDB();
         return true;
     } else {
         Branch::loadHubDB();
         return $result;
     }
 }
Example #27
0
 public function setRegistered($module, $registered)
 {
     $db = new PHPWS_DB('registered');
     $db->addValue('registered_to', $registered);
     $db->addValue('module', $module);
     $result = $db->insert();
     if (PHPWS_Error::logIfError($result)) {
         return $result;
     } else {
         return (bool) $result;
     }
 }
Example #28
0
 public function saveLocalAuthorization()
 {
     if (empty($this->username) || empty($this->_password)) {
         return false;
     }
     $db = new PHPWS_DB('user_authorization');
     if (!empty($this->_prev_username)) {
         $db->addWhere('username', $this->_prev_username);
     } else {
         $db->addWhere('username', $this->username);
     }
     $result = $db->delete();
     $db->resetWhere();
     $db->addValue('username', $this->username);
     $db->addValue('password', $this->_password);
     return $db->insert();
 }
Example #29
0
 public function createCore()
 {
     require_once 'File.php';
     $this->content[] = dgettext('core', 'Importing core database file.');
     $db = new PHPWS_DB();
     $result = $db->importFile('core/boost/install.sql');
     if (PHPWS_Error::isError($result)) {
         PHPWS_Error::log($result);
         $this->content[] = dgettext('core', 'Some errors occurred while creating the core database tables.');
         $this->content[] = dgettext('core', 'Please check your error log file.');
         return false;
     }
     if ($result == true) {
         $db = new PHPWS_DB('core_version');
         include PHPWS_SOURCE_DIR . 'core/boost/boost.php';
         $db->addValue('version', $version);
         $result = $db->insert();
         if (PHPWS_Error::isError($result)) {
             PHPWS_Error::log($result);
             $this->content[] = dgettext('core', 'Some errors occurred while creating the core database tables.');
             $this->content[] = dgettext('core', 'Please check your error log file.');
             return false;
         } else {
             $this->content[] = dgettext('core', 'Core installation successful.');
             return true;
         }
     }
 }
Example #30
0
 public function addReason($reason)
 {
     $db = new PHPWS_DB('checkin_reasons');
     $db->addValue('summary', $reason);
     return !PHPWS_Error::logIfError($db->insert());
 }