コード例 #1
0
ファイル: install.php プロジェクト: jlbooker/homestead
function hms_install(&$content)
{
    PHPWS_Core::initModClass('users', 'Users.php');
    $DB = new PHPWS_DB('users');
    $DB->addWhere('username', 'hms_admin');
    $result = $DB->select('one');
    if ($result == null) {
        $user = new PHPWS_User();
        $user->setUsername('hms_admin');
        $user->setPassword('in the white room, with black curtains');
        $user->save();
    }
    $DB = new PHPWS_DB('users');
    $DB->addWhere('username', 'hms_student');
    $result = $DB->select('one');
    if ($result == null) {
        $user = new PHPWS_User();
        $user->setUsername('hms_student');
        $user->setPassword('shes my everything, shes my pride and joy');
        $user->save();
    }
    $directory = PHPWS_HOME_DIR . 'files/hms_reports/';
    if (!is_dir($directory)) {
        mkdir($directory);
    }
    return true;
}
コード例 #2
0
ファイル: Report.php プロジェクト: HaldunA/phpwebsite
 public function view()
 {
     $tpl['DATE_SENT'] = $this->getDate();
     $tpl['MESSAGE'] = nl2br($this->message);
     $tpl['REASON'] = $this->getReason();
     $reporter = new \PHPWS_User($this->reporter_id);
     $offender = new \PHPWS_User($this->offender_id);
     $tpl['REPORTER'] = $reporter->getUsername();
     $tpl['OFFENDER'] = $offender->getUsername();
     $vars['QUESTION'] = "Ignoring this report will permanently delete it. Be sure you have dealt with those involved before removing it.\nAre you sure you want to ignore this report?";
     $vars['ADDRESS'] = \PHPWS_Text::linkAddress('properties', array('aop' => 'ignore_report', 'id' => $this->id), true);
     $vars['LINK'] = 'Ignore';
     $tpl['IGNORE'] = javascript('confirm', $vars);
     if (!$this->block) {
         $vars['QUESTION'] = "Ignoring this report will permanently delete it. Be sure you have dealt with those involved before removing it.\nAre you sure you want to ignore this report?";
         $vars['ADDRESS'] = \PHPWS_Text::linkAddress('properties', array('aop' => 'ignore_report', 'id' => $this->id), true);
         $vars['LINK'] = 'Ignore';
         $links[] = javascript('confirm', $vars);
         $vars['QUESTION'] = "Blocking a report will prevent the offender from logging in. Are you sure you want to do this?";
         $vars['ADDRESS'] = \PHPWS_Text::linkAddress('properties', array('aop' => 'block_report', 'id' => $this->id), true);
         $vars['LINK'] = 'Block';
         $links[] = javascript('confirm', $vars);
     } else {
         $vars['QUESTION'] = 'Removing this block will allow ' . $offender->getUsername() . ' access to roommates again. Are you sure you want to do this?';
         $vars['ADDRESS'] = \PHPWS_Text::linkAddress('properties', array('aop' => 'ignore_report', 'id' => $this->id), true);
         $vars['LINK'] = 'Remove Block';
         $links[] = javascript('confirm', $vars);
     }
     $links[] = '<a style="cursor : pointer" id="close-view">Close</a>';
     if ($this->block) {
         $tpl['BLOCK_REASON'] = $this->block_reason;
     }
     $tpl['LINKS'] = implode(' | ', $links);
     return \PHPWS_Template::process($tpl, 'properties', 'report_view.tpl');
 }
コード例 #3
0
 /**
  * NB: All of the params are optional for compatibility with db->getObjects() .. Database is done wrong. Don't have time to fix it.
  * @param Internship $i
  * @param PHPWS_User $phpwsUser
  * @param int $timestamp
  * @param WorkflowState $fromState
  * @param WorkflowState $toState
  */
 public function __construct(Internship $i = null, PHPWS_User $phpwsUser = null, $timestamp = null, WorkflowState $fromState = null, WorkflowState $toState = null, $note = null)
 {
     if (!is_null($i)) {
         $this->id = 0;
         $this->internship_id = $i->getId();
         $this->username = $phpwsUser->getUsername();
         $this->timestamp = $timestamp;
         $this->from_state = $fromState->getName();
         $this->to_state = $toState->getName();
         $this->note = $note;
     }
 }
コード例 #4
0
 /**
  * NB: All of the params are optional for compatibility with db->getObjects() .. Database is done wrong. Don't have time to fix it.
  * @param Internship $i
  * @param PHPWS_User $phpwsUser
  * @param int $timestamp
  * @param WorkflowState $fromState
  * @param WorkflowState $toState
  */
 public function __construct(Internship $i = null, \PHPWS_User $phpwsUser = null, $timestamp = null, WorkflowState $fromState = null, WorkflowState $toState = null, $note = null)
 {
     if (!is_null($i)) {
         $this->id = 0;
         $this->internship_id = $i->getId();
         $this->username = $phpwsUser->getUsername();
         $this->timestamp = $timestamp;
         // Strip namespace from start of from and to states, all four backspaces are required to escaping backslash
         $this->from_state = preg_replace("/Intern\\\\WorkflowState\\\\/", '', $fromState->getName());
         $this->to_state = preg_replace("/Intern\\\\WorkflowState\\\\/", '', $toState->getName());
         $this->note = $note;
     }
 }
コード例 #5
0
ファイル: parse.php プロジェクト: HaldunA/phpwebsite
/**
 * @author Matthew McNaney
 * @version $Id$
 */
function new_account($item)
{
    if (!PHPWS_User::getUserSetting('new_user_method') > 0) {
        $msg = dgettext('users', 'New user signup is currently disabled.');
        return $msg;
    }
    $signup_vars = array('action' => 'user', 'command' => 'signup_user');
    if (!empty($item[1])) {
        $link = strip_tags($item[1]);
    } else {
        $link = USER_SIGNUP_QUESTION;
    }
    return PHPWS_Text::moduleLink($link, 'users', $signup_vars);
}
コード例 #6
0
ファイル: Users.php プロジェクト: HaldunA/phpwebsite
 public function __construct($id = 0, $username = null)
 {
     if ($id) {
         $this->setId($id);
     } else {
         if ($username) {
             $this->setUsername($username);
         } else {
             $this->authorize = PHPWS_User::getUserSetting('default_authorization');
             $this->loadScript();
             return;
         }
     }
     $result = $this->init();
     PHPWS_Error::logIfError($result);
     if ($result) {
         $this->loadScript();
     }
 }
コード例 #7
0
ファイル: WikiManager.php プロジェクト: Jopperi/wiki
 /**
  * Sends email to Wiki Admin if option enabled
  *
  * @author Greg Meiste <*****@*****.**>
  */
 function sendEmail()
 {
     if (PHPWS_Settings::get('wiki', 'monitor_edits')) {
         $pagetitle = WikiManager::formatTitle(strip_tags($_REQUEST['page']));
         $message = PHPWS_Settings::get('wiki', 'email_text');
         $message = str_replace('[page]', $pagetitle, $message);
         $message = str_replace('[url]', PHPWS_Core::getHomeHttp() . (MOD_REWRITE_ENABLED ? 'wiki/' : 'index.php?module=wiki&page=') . $_REQUEST['page'], $message);
         PHPWS_Core::initCoreClass('Mail.php');
         $mail = new PHPWS_Mail();
         $mail->addSendTo(PHPWS_Settings::get('wiki', 'admin_email'));
         $mail->setSubject(sprintf(dgettext('wiki', '%s updated!'), $pagetitle));
         $mail->setFrom(PHPWS_User::getUserSetting('site_contact'));
         $mail->setMessageBody($message);
         $mail->send();
     }
 }
コード例 #8
0
ファイル: my_page.php プロジェクト: HaldunA/phpwebsite
 public static function userForm(PHPWS_User $user, $message = NULL)
 {
     require_once PHPWS_SOURCE_DIR . 'core/class/Time.php';
     javascript('jquery');
     $form = new PHPWS_Form();
     $form->addHidden('module', 'users');
     $form->addHidden('action', 'user');
     $form->addHidden('command', 'my_page');
     $form->addHidden('subcommand', 'postUser');
     if (Current_User::allow('users') || $user->display_name == $user->username) {
         $form->addText('display_name', $user->display_name);
         $form->setClass('display_name', 'form-control');
         $form->setLabel('display_name', dgettext('users', 'Display Name'));
     } else {
         $form->addTplTag('DISPLAY_NAME_LABEL', dgettext('users', 'Display Name'));
         $tpl['DISPLAY_NAME'] = javascript('slider', array('link' => $user->display_name, 'id' => 'name-info', 'message' => dgettext('users', 'Once you change your display name, you may not change it again until reset by the site administrator.')));
     }
     if ($user->canChangePassword()) {
         $form->addPassword('password1');
         $form->setAutoComplete('password1');
         $form->setClass('password1', 'form-control');
         $form->addPassword('password2');
         $form->setAutoComplete('password2');
         $form->setClass('password2', 'form-control');
         $form->setTitle('password2', dgettext('users', 'Password confirm'));
         $form->setLabel('password1', dgettext('users', 'Password'));
     } else {
         $tpl['PASSWORD1_LABEL'] = dgettext('users', 'Password');
         $tpl['PASSWORD1'] = javascript('slider', array('link' => dgettext('users', 'Why can\'t I change my password?'), 'id' => 'pw-info', 'message' => dgettext('users', 'Your account is authorized external to this site. You will need to update it at the source.')));
     }
     $form->addText('email', $user->getEmail());
     $form->setSize('email', 40);
     $form->setLabel('email', dgettext('users', 'Email Address'));
     $form->setClass('email', 'form-control');
     if (isset($tpl)) {
         $form->mergeTemplate($tpl);
     }
     $tz_list = PHPWS_Time::getTZList();
     $timezones['server'] = dgettext('users', '-- Use server\'s time zone --');
     foreach ($tz_list as $tz) {
         if (!empty($tz['codes'])) {
             $timezones[$tz['id']] = sprintf('%s : %s', $tz['id'], $tz['codes'][0]);
         } elseif (!empty($tz['city'])) {
             $timezones[$tz['id']] = sprintf('%s : %s', $tz['id'], $tz['city'][0]);
         } else {
             $timezones[$tz['id']] = $tz['id'];
         }
     }
     if (isset($_REQUEST['timezone'])) {
         $user_tz = $_REQUEST['timezone'];
     } else {
         $user_tz = PHPWS_Cookie::read('user_tz');
     }
     $form->addSelect('timezone', $timezones);
     $form->setLabel('timezone', dgettext('users', 'Time Zone'));
     $form->setMatch('timezone', $user_tz);
     $form->setClass('timezone', 'form-control');
     if (isset($_REQUEST['dst']) && $_REQUEST['timezone'] != 'server') {
         $dst = $_REQUEST['dst'];
     } else {
         $dst = PHPWS_Cookie::read('user_dst');
     }
     $form->addCheckbox('dst', 1);
     $form->setMatch('dst', $dst);
     $form->setLabel('dst', dgettext('users', 'Use Daylight Savings Time'));
     if (isset($_POST['cp'])) {
         $cp = (int) $_POST['cp'];
     } else {
         $cp = (int) PHPWS_Cookie::read('user_cp');
     }
     if (Current_User::allowRememberMe()) {
         // User must authorize locally
         if ($_SESSION['User']->authorize == 1) {
             $form->addCheckbox('remember_me', 1);
             if (PHPWS_Cookie::read('remember_me')) {
                 $form->setMatch('remember_me', 1);
             }
             $form->setLabel('remember_me', dgettext('users', 'Remember me'));
         }
     }
     $form->addHidden('userId', $user->getId());
     $form->addSubmit('submit', dgettext('users', 'Update my information'));
     $form->setClass('submit', 'btn btn-primary');
     if (!DISABLE_TRANSLATION && !FORCE_DEFAULT_LANGUAGE) {
         $language_file = PHPWS_Core::getConfigFile('users', 'languages.php');
         if ($language_file) {
             include $language_file;
             $form->addSelect('language', $languages);
             $form->setClass('language', 'form-control');
             $form->setLabel('language', dgettext('users', 'Language preference'));
             if (isset($_COOKIE['phpws_default_language'])) {
                 $language = preg_replace('/\\W/', '', $_COOKIE['phpws_default_language']);
                 $form->setMatch('language', $language);
             }
         }
     }
     $template = $form->getTemplate();
     if (isset($message)) {
         foreach ($message as $tag => $error) {
             $template[$tag] = $error;
         }
     }
     $template['ACCT_INFO'] = dgettext('users', 'Account Information');
     $template['LOCAL_INFO'] = dgettext('users', 'Localization');
     $template['PREF'] = dgettext('users', 'Preferences');
     return PHPWS_Template::process($template, 'users', 'my_page/user_setting.tpl');
 }
コード例 #9
0
ファイル: HMS_Floor.php プロジェクト: jlbooker/homestead
 /**
  * Copies this floor object to a new term, then calls copy on all
  * 'this' floor's rooms
  *
  * Setting $assignments to 'true' causes the copy public function to copy
  * the assignments as well as the hall structure.
  *
  * @return bool False if unsuccessful.
  */
 public function copy($to_term, $hall_id, $assignments = false, $roles = false)
 {
     if (!$this->id) {
         return false;
     }
     //echo "in hms_floor, copying this floor id: $this->id <br>";
     // Create a clone of the current floor object
     // Set id to 0, set term, and save
     $new_floor = clone $this;
     $new_floor->reset();
     $new_floor->term = $to_term;
     $new_floor->residence_hall_id = $hall_id;
     $new_floor->f_movein_time_id = null;
     $new_floor->t_movein_time_id = null;
     $new_floor->rt_movein_time_id = null;
     try {
         $new_floor->save();
     } catch (Exception $e) {
         throw $e;
     }
     // Copy any roles related to this floor.
     if ($roles) {
         PHPWS_Core::initModClass("hms", "HMS_Permission.php");
         PHPWS_Core::initModClass("hms", "HMS_Role.php");
         // Get memberships by object instance.
         $membs = HMS_Permission::getUserRolesForInstance($this);
         // Add each user to new floor
         foreach ($membs as $m) {
             // Lookup the username
             $user = new PHPWS_User($m['user_id']);
             // Load role and add user to new instance
             $role = new HMS_Role();
             $role->id = $m['role'];
             $role->load();
             $role->addUser($user->getUsername(), get_class($new_floor), $new_floor->id);
         }
     }
     // Load all the rooms for this floor
     if (empty($this->_rooms)) {
         try {
             $this->loadRooms();
         } catch (Exception $e) {
             throw $e;
         }
     }
     /**
      * Rooms exist. Start making copies.
      * Further copying is needed at the room level.
      */
     if (!empty($this->_rooms)) {
         foreach ($this->_rooms as $room) {
             try {
                 $room->copy($to_term, $new_floor->id, null, $assignments);
             } catch (Exception $e) {
                 throw $e;
             }
         }
     }
 }
コード例 #10
0
 /**
  * Signup form for new users
  */
 public static function signup_form($user, $message = NULL)
 {
     $form = new PHPWS_Form();
     $form->addHidden('module', 'users');
     $form->addHidden('action', 'user');
     $form->addHidden('command', 'submit_new_user');
     $form->addText('username', $user->getUsername());
     $form->setLabel('username', dgettext('users', 'Username'));
     $new_user_method = PHPWS_User::getUserSetting('new_user_method');
     $form->addPassword('password1', $user->getPassword());
     $form->allowValue('password1');
     $form->setLabel('password1', dgettext('users', 'Password'));
     $form->addPassword('password2', $user->getPassword());
     $form->allowValue('password2');
     $form->setLabel('password2', dgettext('users', 'Confirm'));
     $form->addText('email', $user->getEmail());
     $form->setLabel('email', dgettext('users', 'Email Address'));
     $form->setSize('email', 40);
     if (PHPWS_User::getUserSetting('graphic_confirm')) {
         $result = User_Form::confirmGraphic();
         if (PHPWS_Error::isError($result)) {
             PHPWS_Error::log($result);
         } else {
             $form->addTplTag('GRAPHIC', $result);
         }
     }
     $form->addSubmit('submit', dgettext('users', 'Sign up'));
     $template = $form->getTemplate();
     if (isset($message)) {
         foreach ($message as $tag => $error) {
             $template[$tag] = $error;
         }
     }
     $result = PHPWS_Template::process($template, 'users', 'forms/signup_form.tpl');
     return $result;
 }
コード例 #11
0
ファイル: settings.php プロジェクト: Jopperi/wiki
<?php

/**
 * Wiki for phpWebSite
 *
 * See docs/CREDITS for copyright information
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 *
 * @package Wiki
 * @author Greg Meiste <*****@*****.**>
 */
$settings = array('show_on_home' => 1, 'allow_anon_view' => 1, 'allow_page_edit' => 0, 'allow_image_upload' => 0, 'allow_bbcode' => 0, 'ext_chars_support' => 0, 'add_to_title' => 1, 'format_title' => 0, 'show_modified_info' => 1, 'diff_type' => 'two_col', 'monitor_edits' => 0, 'admin_email' => PHPWS_User::getUserSetting('site_contact'), 'email_text' => '[page] has been updated.  Go to [url] to view it.', 'default_page' => 'FrontPage', 'ext_page_target' => '_blank', 'immutable_page' => 1, 'raw_text' => 0, 'print_view' => 1, 'what_links_here' => 1, 'recent_changes' => 1, 'random_page' => 1, 'discussion' => 1, 'discussion_anon' => 0);
コード例 #12
0
ファイル: Admin.php プロジェクト: par-orillonsoft/phpwebsite
 public function blockReport($report_id)
 {
     \PHPWS_Core::initModClass('properties', 'Message.php');
     \PHPWS_Core::initModClass('properties', 'Report.php');
     $report = new Report($report_id);
     $message = new Message($report->message_id);
     $user = new \PHPWS_User($message->from_user_id);
     $this->title = 'Block user:'******'module', 'properties');
     $form->addHidden('aop', 'block_post');
     $form->addHidden('report_id', $report->id);
     $form->addHidden('message_id', $message->id);
     $form->addTextarea('block_reason');
     $form->addSubmit('Block user');
     $tpl = $form->getTemplate();
     $this->content = \PHPWS_Template::process($tpl, 'properties', 'block.tpl');
 }
コード例 #13
0
 public function copy($to_term, $assignments = FALSE, $roles = FALSE)
 {
     if (!$this->id) {
         return false;
     }
     // echo "In hms_residence_hall, copying this hall: $this->id <br>";
     // Create clone of current room object
     // Set id to 0, set term, and save
     $new_hall = clone $this;
     $new_hall->reset();
     $new_hall->id = 0;
     $new_hall->term = $to_term;
     try {
         $new_hall->save();
     } catch (Exception $e) {
         // rethrow it to the top level
         throw $e;
     }
     // Copy any roles related to this residence hall.
     if ($roles) {
         PHPWS_Core::initModClass("hms", "HMS_Permission.php");
         PHPWS_Core::initModClass("hms", "HMS_Role.php");
         // Get memberships by object instance.
         $membs = HMS_Permission::getUserRolesForInstance($this);
         // test($membs,1);
         // Add each user to new hall
         foreach ($membs as $m) {
             // Lookup the username
             $user = new PHPWS_User($m['user_id']);
             // Load role and add user to new instance
             $role = new HMS_Role();
             $role->id = $m['role'];
             $role->load();
             $role->addUser($user->getUsername(), get_class($new_hall), $new_hall->id);
         }
     }
     // Save successful, create new floors
     // Load all floors for this hall
     if (empty($this->_floors)) {
         try {
             $this->loadFloors();
         } catch (Exception $e) {
             throw $e;
         }
     }
     // Floors exist, start making copies
     if (!empty($this->_floors)) {
         foreach ($this->_floors as $floor) {
             try {
                 $floor->copy($to_term, $new_hall->id, $assignments, $roles);
             } catch (Exception $e) {
                 throw $e;
             }
         }
     }
 }
コード例 #14
0
ファイル: Action.php プロジェクト: HaldunA/phpwebsite
 public static function notifyUser($user, $password)
 {
     PHPWS_Core::initCoreClass('Mail.php');
     $page_title = Layout::getPageTitle(true);
     $body[] = sprintf(dgettext('users', '%s created an user account for you.'), $page_title);
     $body[] = dgettext('users', 'You may log-in using the following information:');
     $body[] = sprintf(dgettext('users', 'Site address: %s'), PHPWS_Core::getHomeHttp());
     $body[] = sprintf(dgettext('users', 'Username: %s'), $user->username);
     $body[] = sprintf(dgettext('users', 'Password: %s'), $password);
     $body[] = dgettext('users', 'Please change your password immediately after logging in.');
     $mail = new PHPWS_Mail();
     $mail->addSendTo($user->email);
     $mail->setSubject(sprintf(dgettext('users', '%s account created'), $page_title));
     $mail->setFrom(PHPWS_User::getUserSetting('site_contact'));
     $mail->setReplyTo(PHPWS_User::getUserSetting('site_contact'));
     $mail->setMessageBody(implode("\n\n", $body));
     $result = $mail->send();
     return $result;
 }
コード例 #15
0
ファイル: Permission.php プロジェクト: HaldunA/phpwebsite
 /**
  * Although called via Current_User, this functions gives
  * a group with edit permissions the right to edit this item.
  */
 public static function giveItemPermission($user_id, Key $key)
 {
     $user = new PHPWS_User($user_id);
     $groups = $user->getGroups();
     if (empty($groups) || !is_array($groups)) {
         return;
     }
     if (empty($key->_edit_groups)) {
         $key->_edit_groups = array();
     }
     PHPWS_Core::initModClass('users', 'Group.php');
     foreach ($groups as $group_id) {
         $group_obj = new PHPWS_Group($group_id, false);
         if (!in_array($group_id, $key->_edit_groups) && $group_obj->allow($key->module, $key->edit_permission)) {
             $key->_edit_groups[] = $group_id;
         }
     }
     return $key->savePermissions();
 }
コード例 #16
0
ファイル: Current_User.php プロジェクト: HaldunA/phpwebsite
 /**
  * sends a user to the 403 error page and logs a message (if specified)
  * to the security log
  * @param string  message  Message sent to log
  * @param boolean login    If true, then allow change to login
  */
 public static function disallow($message = null, $login = true)
 {
     if ($login && Current_User::requireLogin()) {
         return;
     } else {
         PHPWS_User::disallow($message);
     }
 }