Ejemplo n.º 1
0
 public function secure()
 {
     if ($user = user::load()) {
         return true;
     }
     return false;
 }
Ejemplo n.º 2
0
 static function reconcileAllPaymentUids()
 {
     $txn = new paypal_transaction();
     $extraWhere = "bp_biobounce_uid ='0'";
     while ($txn->loadNext($extraWhere)) {
         $found = false;
         $email = $txn->get_variable('bp_paypal_email');
         $paypalid = $txn->get_variable('bp_paypal_payer_id');
         $txnFind = new paypal_transaction();
         $extraWhere2 = "bp_biobounce_uid<>'0' AND bp_paypal_payer_id='" . $paypalid . "'";
         if ($txnFind->load($extraWhere2)) {
             $bioId = $txnFind->get_variable('bp_biobounce_uid');
             $found = true;
             //echo "\n\nFOUND THE USER ID BASED ON PREVIOUSLY BEING SET:PAYPALID=" . $paypalid;
         } else {
             $usr = new user();
             $usr->set_variable('users_email', $email);
             if ($usr->load()) {
                 $bioId = $usr->get_variable('users_id');
                 $found = true;
                 //echo "\nFOUND THE USER ID BASED ON SAME EMAIL ADDRESS:ADDRESS=" . $email;
             }
         }
         if ($found) {
             $txnId = $txn->get_variable('bp_id');
             //echo "\nUPDATING TRANSACTION NUMBER=" . $txnId . " to use UID=" . $bioId;
             $txn->set_variable('bp_biobounce_uid', $bioId);
             $txn->update();
         }
     }
 }
Ejemplo n.º 3
0
 /**
  * Creates a new user model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $model = new user();
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         return $this->redirect(['view', 'id' => $model->id]);
     } else {
         return $this->render('create', ['model' => $model]);
     }
 }
Ejemplo n.º 4
0
 /**
  * Returns human readable context identifier.
  *
  * @param boolean $withprefix whether to prefix the name of the context with User
  * @param boolean $short does not apply to user context
  * @return string the human readable context name.
  */
 public function get_context_name($withprefix = true, $short = false)
 {
     global $DB;
     $name = '';
     if ($user = new \user($this->_instanceid)) {
         $user->load();
         if ($withprefix) {
             $name = get_string('user', 'local_elisprogram') . ': ';
         }
         $name .= $user->moodle_fullname();
     }
     return $name;
 }
Ejemplo n.º 5
0
 public static function updateReferral($newUserId, $referralCode)
 {
     $referredByUser = new user();
     $referredByUser->set_variable('users_referralid', $referralCode);
     echo "CHECKING REFERRAL";
     if ($referredByUser->load()) {
         $rbUid = $referredByUser->get_variable("users_id");
         $referral = new referral();
         $referral->set_variable("referral_referred_by_userid", $rbUid);
         $referral->set_variable("referral_referred_userid", $newUserId);
         $referral->set_variable("referral_date", date('Y-m-d'));
         $referral->set_variable("referral_paid", 0);
         $referral->createNew();
     }
 }
Ejemplo n.º 6
0
 /**
  * Test successful user creation.
  */
 public function test_success()
 {
     global $DB;
     // Create custom field.
     $fieldcat = new field_category();
     $fieldcat->name = 'Test';
     $fieldcat->save();
     $field = new field();
     $field->categoryid = $fieldcat->id;
     $field->shortname = 'testfield';
     $field->name = 'Test Field';
     $field->datatype = 'text';
     $field->save();
     $fieldctx = new field_contextlevel();
     $fieldctx->fieldid = $field->id;
     $fieldctx->contextlevel = CONTEXT_ELIS_USER;
     $fieldctx->save();
     $user = array('idnumber' => 'testuser', 'username' => 'testuser', 'firstname' => 'testuser', 'lastname' => 'testuser', 'email' => '*****@*****.**', 'country' => 'CA', 'field_testfield' => 'Test Field');
     $tempuser = new user();
     $tempuser->reset_custom_field_list();
     $this->give_permissions(array('local/elisprogram:user_create'));
     $response = local_datahub_elis_user_create::user_create($user);
     $this->assertNotEmpty($response);
     $this->assertInternalType('array', $response);
     $this->assertArrayHasKey('messagecode', $response);
     $this->assertArrayHasKey('message', $response);
     $this->assertArrayHasKey('record', $response);
     $this->assertEquals(get_string('ws_user_create_success_code', 'local_datahub'), $response['messagecode']);
     $this->assertEquals(get_string('ws_user_create_success_msg', 'local_datahub'), $response['message']);
     $this->assertInternalType('array', $response['record']);
     $this->assertArrayHasKey('id', $response['record']);
     // Get user.
     $createduser = new user($response['record']['id']);
     $createduser->load();
     $createduser = $createduser->to_array();
     foreach ($user as $param => $val) {
         $this->assertArrayHasKey($param, $createduser);
         $this->assertEquals($val, $createduser[$param]);
     }
 }
Ejemplo n.º 7
0
 public function getUserByFbId($fb_id)
 {
     $user = new user();
     $user->load("fb_id = ?", array($fb_id));
     return $user;
 }
Ejemplo n.º 8
0
 static function stillHasDefaultAccount()
 {
     $file = c::get('root.site') . '/' . c::get('panel.folder') . '/accounts/admin.php';
     if (file_exists($file)) {
         return true;
     }
     $dir = c::get('root.site') . '/' . c::get('panel.folder') . '/accounts';
     $files = dir::read($dir);
     $default = array('username' => 'admin', 'password' => 'adminpassword', 'language' => 'en');
     foreach ($files as $file) {
         $username = f::name($file);
         $user = user::load($username);
         $diff = array_diff($user, $default);
         if (empty($diff)) {
             return true;
         }
     }
     return false;
 }
 /**
  * Validate that the "menu of choices" custom field type works correctly
  * when options are separated by a carriage return and a line feed
  */
 public function testmenuofchoicesignorescarriagereturns()
 {
     global $CFG, $DB;
     require_once $CFG->dirroot . '/local/elisprogram/lib/setup.php';
     require_once elis::lib('data/customfield.class.php');
     require_once elispm::file('accesslib.php');
     require_once elispm::lib('data/user.class.php');
     // Setup.
     $field = new field(array('shortname' => 'testcustomfieldshortname', 'name' => 'testcustomfieldname', 'datatype' => 'char'));
     $category = new field_category(array('name' => 'testcategoryname'));
     field::ensure_field_exists_for_context_level($field, CONTEXT_ELIS_USER, $category);
     $ownerparams = array('control' => 'menu', 'options' => "option1\r\noption2");
     field_owner::ensure_field_owner_exists($field, 'manual', $ownerparams);
     // Run the create action.
     $record = new stdClass();
     $record->action = 'create';
     $record->email = '*****@*****.**';
     $record->username = '******';
     $record->idnumber = 'testuserid';
     $record->firstname = 'testuserfirstname';
     $record->lastname = 'testuserlastname';
     $record->country = 'CA';
     $record->testcustomfieldshortname = 'option1';
     $user = new user();
     $user->reset_custom_field_list();
     $importplugin = rlip_dataplugin_factory::factory('dhimport_version1elis');
     $importplugin->fslogger = new silent_fslogger(null);
     $importplugin->process_record('user', (object) $record, 'bogus');
     // Validation.
     $user = new user(1);
     $user->load();
     $this->assertEquals('option1', $user->field_testcustomfieldshortname);
 }
Ejemplo n.º 10
0
 /**
  * Function to handle class not completed events.
  *
  * @param   student  $student  The class enrolment / student object who is "not completed"
  * @uses    $CFG
  * @uses    $DB
  * @return  boolean            TRUE is successful, otherwise FALSE
  */
 public static function class_notcompleted_handler($student)
 {
     global $CFG, $DB;
     require_once elispm::lib('notifications.php');
     /// Does the user receive a notification?
     $sendtouser = elis::$config->local_elisprogram->notify_classnotcompleted_user;
     $sendtorole = elis::$config->local_elisprogram->notify_classnotcompleted_role;
     $sendtosupervisor = elis::$config->local_elisprogram->notify_classnotcompleted_supervisor;
     /// If nobody receives a notification, we're done.
     if (!$sendtouser && !$sendtorole && !$sendtosupervisor) {
         return true;
     }
     if (!empty($student->moodlecourseid)) {
         if (!($context = context_course::instance($student->moodlecourseid))) {
             if (in_cron()) {
                 mtrace(get_string('invalidcontext'));
             } else {
                 debugging(get_string('invalidcontext'));
             }
             return true;
         }
     } else {
         $context = context_system::instance();
     }
     $message = new notification();
     /// Set up the text of the message
     $text = empty(elis::$config->local_elisprogram->notify_classnotcompleted_message) ? get_string('notifyclassnotcompletedmessagedef', self::LANG_FILE) : elis::$config->local_elisprogram->notify_classnotcompleted_message;
     $search = array('%%userenrolname%%', '%%classname%%', '%%coursename%%');
     $user = new user($student->userid);
     if (!$user) {
         if (in_cron()) {
             mtrace(get_string('nouser', 'local_elisprogram'));
         } else {
             debugging(get_string('nouser', 'local_elisprogram'));
         }
         return true;
     }
     $user->load();
     // Get course info
     $pmcourse = $DB->get_record(course::TABLE, array('id' => $student->courseid));
     $pmclass = $DB->get_record(pmclass::TABLE, array('id' => $student->classid));
     $replace = array($user->moodle_fullname(), $pmclass->idnumber, $pmcourse->name);
     $text = str_replace($search, $replace, $text);
     $eventlog = new Object();
     $eventlog->event = 'class_notcompleted';
     $eventlog->instance = $student->classid;
     $eventlog->fromuserid = $user->id;
     if ($sendtouser) {
         $message->send_notification($text, $user, null, $eventlog);
     }
     $users = array();
     if ($sendtorole) {
         /// Get all users with the notify_classnotcomplete capability.
         if ($roleusers = get_users_by_capability($context, 'local/elisprogram:notify_classnotcomplete')) {
             $users = $users + $roleusers;
         }
     }
     if ($sendtosupervisor) {
         /// Get parent-context users.
         if ($supervisors = pm_get_users_by_capability('user', $user->id, 'local/elisprogram:notify_classnotcomplete')) {
             $users = $users + $supervisors;
         }
     }
     // Send notifications to any users who need to receive them.
     foreach ($users as $touser) {
         $message->send_notification($text, $touser, $user, $eventlog);
     }
     return true;
 }
Ejemplo n.º 11
0
require_once elispm::lib('deprecatedlib.php');
// cm_get_crlmuserid()
require_once elispm::lib('data/user.class.php');
require_once elispm::lib('data/course.class.php');
require_once elispm::lib('data/certificatesettings.class.php');
require_once elispm::lib('data/certificateissued.class.php');
require_once elispm::lib('data/student.class.php');
require_once elispm::lib('data/instructor.class.php');
$ciid = required_param('id', PARAM_INT);
// Issued certificate id
$csid = required_param('csid', PARAM_INT);
// certificate setting id
global $USER;
$cmuserid = cm_get_crlmuserid($USER->id);
$student = new user($cmuserid);
$student->load();
if (empty($student->id)) {
    return get_string('studentnotfound', 'local_elisprogram');
}
// Retrieve the certificate settings record
$certsettingrec = new certificatesettings($csid);
$certsettingrec->load();
// Check if the record exists or if the certificate is disabled
if (empty($certsettingrec->id) and !empty($certsettingrec->disable)) {
    // Passing hard coded error code to disallow administrators from changing them to
    // custom strings
    echo get_string('errorfindingcertsetting', 'local_elisprogram', 'Error 11');
}
// Retrieve the certificate issued record
$certissuedrec = new certificateissued($ciid);
$certissuedrec->load();
Ejemplo n.º 12
0
 function currentUser()
 {
     global $lang;
     $language = _DEFAULT_LANGUAGE_;
     if (isset($_SESSION['USER_DATA']) && isset($_SESSION['USER_DATA']['ID'])) {
         parent::user($_SESSION['USER_DATA']['ID']);
         parent::load();
         if (isset($this->details['language'])) {
             $language = $this->details['language'];
         }
     }
     // Load strings...
     if ($language != $lang->id) {
         $this->lang = new language($language, _DEFAULT_SITE_, true);
     } else {
         $this->lang =& $lang;
     }
 }
Ejemplo n.º 13
0
        }
    }
    if (isset($error['top']) && $error['top'] != "" && $filled == TRUE) {
        $error['top'] = '<div class="notification red">' . $error['top'] . '</div>';
    }
    //page
    $pagecontent .= "<h3>My account:</h3>\n\t<p><b>Verification:</b> ";
    if ($sessus->verified == TRUE) {
        $pagecontent .= "Verified.</p>";
    } else {
        $pagecontent .= "Not verified. Contact website staff for verification.</p>";
    }
    $pagecontent .= "<p><b>Account state:</b> ";
    if ($sessus->banned == TRUE) {
        $bannedby = new user($sql, "id", $sessus->banned);
        if ($bannedby->load()) {
            $bannedby = $bannedby->username;
            $pagecontent .= "Banned for " . $sessus->bannedreason . "(at " . $sessus->bannedtime . " by " . $bannedby . ")</p>";
        }
    } else {
        $pagecontent .= "Good.</p>";
    }
    $pagecontent .= '<h4>Change Password</h4>

	<form action="user.php" method="post">
			' . $error['top'] . $message . '
			<table>
				<tr>
					<td>Current password</td>
					<td><input type="password" name="current" placeholder="Current Password" size="35"></td>
					<td>' . $error['current'] . '</td>
    function render_video() {
	return "<p>Showing recent video in sidebar widget.</p>";
    }

    private function _render_template($template) {
	$tpl = new Template(CURRENT_THEME_FSPATH."/widget_$template.tpl");
	return $tpl->fetch();
    }

}
    
// --- controller (part 2)

// find user and badge
$user = new user();
$user->load((int)$login_uid);
try {
    $badge = new Badge($user, $badge_tag);
} catch (PAException $e) {
    switch ($e->code) {
    case CONTENT_HAS_BEEN_DELETED:
    case ROW_DOES_NOT_EXIST:
	header("Location: " . PA::$url . "/badge_create.php");
	exit;
    default:
	throw $e;
    }
}

function badge_disp($content) {
    if ($content instanceof Badge_Redirect) {
Ejemplo n.º 15
0
                $filled['password'] = TRUE;
            }
        }
        $isfilled = TRUE;
    } else {
        $error['top'] .= "<p>Both passwords must be identical.</p>";
        $error['password2'] = "Both passwords must be identical.";
    }
    if ($isfilled == TRUE && $filled['username'] == TRUE && $filled['email'] == TRUE && $filled['password'] == TRUE) {
        $user = new user($sql, "username", $_POST['username']);
        $user->email = $_POST['email'];
        $user->membersince = currentTime();
        $user->logLogin();
        if ($user->changePW($_POST['password'])) {
            if ($user->save()) {
                $user->load();
                $_SESSION['userid'] = $user->id;
                $pagecontent .= '
					<div class="notification green">
						<p>Your account has been created.</p>
					</div>';
            } else {
                $pagecontent .= '
					<div class="notification red">
						<p>Failed to save user.</p>
					</div>';
            }
        } else {
            $pagecontent .= '
				<div class="notification red">
					<p>Failed to save user.</p>
function perform_user_removal()
{
    // User accounts are not actually deleted from the database.  They are flagged as INACTIVE because the user ID is referenced
    // by other tables that need to maintain a historical record of actions performed by that user (e.g. rappels.confirmed_by).
    if (!isset($_POST['user_id'])) {
        throw new Exception('You must specify a user account to remove!');
    }
    if (!user::exists($_POST['user_id'])) {
        throw new Exception('The requested user account does not exist!');
    }
    $user = new user();
    $user->load($_POST['user_id']);
    $user->set('inactive', 1);
    $user->save();
    return 1;
}
Ejemplo n.º 17
0
function process()
{
    global $DB;
    global $website;
    global $events;
    global $theme;
    set_time_limit(0);
    setlocale(LC_ALL, $_SESSION['navigate_install_locale']);
    $lang = navigate_install_load_language();
    switch ($_REQUEST['process']) {
        case 'verify_zip':
            sleep(1);
            if (!file_exists('package.zip')) {
                die(json_encode($lang['missing_package']));
            } else {
                $zip = new ZipArchive();
                if ($zip->open('package.zip') !== TRUE) {
                    die(json_encode($lang['invalid_package']));
                } else {
                    $zip->close();
                    die(json_encode(true));
                }
            }
            break;
        case 'extract_zip':
            $npath = getcwd() . NAVIGATE_FOLDER;
            $npath = str_replace('\\', '/', $npath);
            if (!file_exists($npath)) {
                mkdir($npath);
            }
            if (file_exists($npath)) {
                $zip = new ZipArchive();
                if ($zip->open('package.zip') === TRUE) {
                    $zip->extractTo($npath);
                    $zip->close();
                    copy($npath . '/crossdomain.xml', dirname($npath) . '/crossdomain.xml');
                    die(json_encode(true));
                } else {
                    die(json_encode($lang['extraction_failed']));
                }
            }
            die(json_encode($lang['folder_not_exists']));
            break;
        case 'chmod':
            sleep(1);
            // chmod the directories recursively
            $npath = getcwd() . NAVIGATE_FOLDER;
            if (!navigate_install_chmodr($npath, 0755)) {
                die(json_encode($lang['chmod_failed']));
            } else {
                die(json_encode(true));
            }
            break;
        case 'verify_database':
            if ($_REQUEST['PDO_DRIVER'] == 'mysql' || $_REQUEST['PDO_DRIVER'] == 'mysql-socket') {
                try {
                    $dsn = "mysql:host=" . $_REQUEST['PDO_HOSTNAME'] . ";port=" . $_REQUEST['PDO_PORT'] . ';charset=utf8';
                    if ($_REQUEST['PDO_DRIVER'] == "mysql-socket") {
                        $dsn = "mysql:unix_socket=" . $_REQUEST['PDO_SOCKET'] . ";charset=utf8";
                    }
                    $db_test = @new PDO($dsn, $_REQUEST['PDO_USERNAME'], $_REQUEST['PDO_PASSWORD']);
                    if (!$db_test) {
                        echo json_encode(array('error' => $lang['database_connect_error']));
                    } else {
                        $create_database_privilege = false;
                        $drop_database_privilege = false;
                        $stm = $db_test->query('SHOW DATABASES;');
                        $rs = $stm->fetchAll(PDO::FETCH_COLUMN, 'Database');
                        $rs = array_diff($rs, array('mysql', 'information_schema'));
                        $stm = $db_test->query('SHOW PRIVILEGES;');
                        $privileges = $stm->fetchAll(PDO::FETCH_ASSOC);
                        for ($p = 0; $p < count($privileges); $p++) {
                            if ($privileges[$p]['Privilege'] == 'Create') {
                                if (strpos($privileges[$p]['Context'], 'Databases') !== false) {
                                    $create_database_privilege = true;
                                }
                            }
                            if ($privileges[$p]['Privilege'] == 'Drop') {
                                if (strpos($privileges[$p]['Context'], 'Databases') !== false) {
                                    $drop_database_privilege = true;
                                }
                            }
                        }
                        if ($create_database_privilege && $drop_database_privilege) {
                            // check if we are really allowed to create databases
                            $dbname = 'navigate_test_' . time();
                            $create_result = $db_test->exec('CREATE DATABASE ' . $dbname);
                            if ($create_result) {
                                $db_test->exec('DROP DATABASE ' . $dbname);
                            }
                            if (!$create_result) {
                                $create_database_privilege = false;
                            }
                        }
                        $db_test = NULL;
                        echo json_encode(array('databases' => array_values($rs), 'create_database_privilege' => $create_database_privilege));
                    }
                } catch (Exception $e) {
                    echo json_encode(array('error' => $e->getMessage()));
                }
            } else {
                echo json_encode(array('error' => $lang['database_driver_error']));
            }
            exit;
            break;
        case 'database_create':
            $DB = new database();
            if (!$DB->connect()) {
                // try to create the database automatically
                if (PDO_DRIVER == 'mysql') {
                    if (PDO_DATABASE != '') {
                        if (PDO_HOSTNAME != "") {
                            $dsn = "mysql:host=" . PDO_HOSTNAME . ";port=" . PDO_PORT . ";charset=utf8";
                        } else {
                            $dsn = "mysql:unix_socket=" . PDO_SOCKET . ";charset=utf8";
                        }
                        $db_test = new PDO($dsn, PDO_USERNAME, PDO_PASSWORD);
                        $db_test->exec('CREATE DATABASE IF NOT EXISTS `' . PDO_DATABASE . '` DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci;');
                        $db_test = NULL;
                    }
                    if (!$DB->connect()) {
                        echo json_encode(array('error' => $DB->get_last_error()));
                    } else {
                        echo json_encode(array('ok' => $lang['database_created']));
                    }
                }
            } else {
                echo json_encode(array('ok' => $lang['database_exists']));
            }
            exit;
            break;
        case 'database_import':
            $DB = new database();
            if (!$DB->connect()) {
                die(json_encode(array('error' => $DB->get_last_error())));
            }
            try {
                $sql = file_get_contents('navigate.sql');
                $sql = str_replace("{#!NAVIGATE_FOLDER!#}", NAVIGATE_PARENT . NAVIGATE_FOLDER, $sql);
                $sql = explode("\n\n", $sql);
                // can't do it in one step => SQLSTATE[HY000]: General error: 2014
                foreach ($sql as $sqlline) {
                    $sqlline = trim($sqlline);
                    if (empty($sqlline)) {
                        continue;
                    }
                    if (!@$DB->execute($sqlline)) {
                        $error = $DB->get_last_error();
                    }
                    if (!empty($error)) {
                        break;
                    }
                }
            } catch (Exception $e) {
                $error = $e->getMessage();
            }
            if (!empty($error) && false) {
                echo json_encode(array('error' => $error));
            } else {
                echo json_encode(array('ok' => $lang['done']));
            }
            exit;
            break;
        case 'create_account':
            // create admin
            try {
                $DB = new database();
                if (!$DB->connect()) {
                    die(json_encode(array('error' => $DB->get_last_error())));
                }
                $user = new user();
                $user->id = 0;
                $user->username = $_SESSION['NAVIGATE-SETUP']['ADMIN_USERNAME'];
                $user->set_password($_SESSION['NAVIGATE-SETUP']['ADMIN_PASSWORD']);
                $user->email = $_SESSION['NAVIGATE-SETUP']['ADMIN_EMAIL'];
                $user->profile = 1;
                $user->skin = 'cupertino';
                $user->language = $_SESSION['navigate_install_lang'];
                $user->blocked = 0;
                $user->timezone = 'UTC';
                $user->date_format = 'Y-m-d H:i';
                $user->decimal_separator = ',';
                $user->thousands_separator = '';
                $user->attempts = 0;
                $user->cookie_hash = '';
                $user->activation_key = '';
                $ok = $user->insert();
                if (!$ok) {
                    throw new Exception($lang['error']);
                }
                // create default website details
                $website = new website();
                $website->create_default();
                $_SESSION['NAVIGATE-SETUP']['WEBSITE_DEFAULT'] = $website->id;
                echo json_encode(array('ok' => $lang['done']));
            } catch (Exception $e) {
                echo json_encode(array('error' => $e->getMessage()));
            }
            exit;
            break;
        case 'install_default_theme':
            try {
                $DB = new database();
                if (!$DB->connect()) {
                    die(json_encode(array('error' => $DB->get_last_error())));
                }
                if (@$_SESSION['NAVIGATE-SETUP']['DEFAULT_THEME'] == 'theme_kit') {
                    $website = new website();
                    $website->load($_SESSION['NAVIGATE-SETUP']['WEBSITE_DEFAULT']);
                    $website->theme = 'theme_kit';
                    $website->languages = array('en' => array('language' => 'en', 'variant' => '', 'code' => 'en', 'system_locale' => 'en_US.utf8'), 'es' => array('language' => 'es', 'variant' => '', 'code' => 'es', 'system_locale' => 'es_ES.utf8'));
                    $website->languages_published = array('en', 'es');
                    $website->save();
                    // default objects (first user, no events bound...)
                    $user = new user();
                    $user->load(1);
                    $events = new events();
                    $zip = new ZipArchive();
                    $zip_open_status = $zip->open(NAVIGATE_PATH . '/themes/theme_kit.zip');
                    if ($zip_open_status === TRUE) {
                        $zip->extractTo(NAVIGATE_PATH . '/themes/theme_kit');
                        $zip->close();
                        $theme = new theme();
                        $theme->load('theme_kit');
                        $theme->import_sample($website);
                    }
                    echo json_encode(array('ok' => $lang['done']));
                } else {
                    // user does not want to install the default theme
                    echo json_encode(array('ok' => $lang['not_selected']));
                }
            } catch (Exception $e) {
                echo json_encode(array('error' => $e->getMessage()));
            }
            exit;
            break;
        case 'apache_htaccess':
            try {
                $nvweb = dirname($_SERVER['REQUEST_URI']) . NAVIGATE_FOLDER . '/web/nvweb.php';
                $nvweb = str_replace('//', '/', $nvweb);
                $data = array();
                $data[] = 'Options +FollowSymLinks';
                $data[] = 'Options -Indexes';
                $data[] = 'RewriteEngine On';
                $data[] = 'RewriteBase /';
                $data[] = 'RewriteCond %{REQUEST_FILENAME} !-f';
                $data[] = 'RewriteCond %{REQUEST_FILENAME} !-d';
                $data[] = 'RewriteRule ^(.+) ' . $nvweb . '?route=$1 [QSA]';
                $data[] = 'RewriteRule ^$ ' . $nvweb . '?route=nv.empty [L,QSA]';
                $ok = @file_put_contents(dirname(NAVIGATE_PATH) . '/.htaccess', implode("\n", $data));
                if (!$ok) {
                    throw new Exception($lang['unexpected_error']);
                }
                echo json_encode('true');
            } catch (Exception $e) {
                echo json_encode(array('error' => $e->getMessage()));
            }
            exit;
            break;
    }
}
Ejemplo n.º 18
0
 /**
  * Return the HTML to edit a specific instructor.
  * This could be extended to allow for application specific editing, for example
  * a Moodle interface to its formslib.
  *
  * @param int $classid The class ID.
  * @param string $sort Field to sort on.
  * @param string $dir Direction of sort.
  * @param int $page The page to start at.
  * @param int $perpage Number of records per page.
  * @param string $namesearch Search string for item name.
  * @param string $alpha Start initial of item name filter.
  * @return string The form HTML, without the form.
  */
 public function edit_form_html($classid, $sort = 'name', $dir = 'ASC', $page = 0, $perpage = 30, $namesearch = '', $alpha = '')
 {
     global $CFG, $OUTPUT, $SESSION, $PAGE;
     $action = optional_param('action', '', PARAM_ALPHA);
     $this->classid = $classid;
     $output = '';
     ob_start();
     if (empty($this->id)) {
         $columns = array('assign' => array('header' => get_string('assign', self::LANG_FILE), 'display_function' => 'htmltab_display_function', 'sortable' => false), 'idnumber' => array('header' => get_string('class_idnumber', self::LANG_FILE), 'display_function' => 'htmltab_display_function'), 'name' => array('header' => get_string('tag_name', self::LANG_FILE), 'display_function' => 'htmltab_display_function'), 'assigntime' => array('header' => get_string('assigntime', self::LANG_FILE), 'display_function' => 'htmltab_display_function', 'sortable' => false), 'completetime' => array('header' => get_string('completion_time', self::LANG_FILE), 'display_function' => 'htmltab_display_function', 'sortable' => false));
     } else {
         $columns = array('idnumber' => array('header' => get_string('class_idnumber', self::LANG_FILE), 'display_function' => 'htmltab_display_function'), 'name' => array('header' => get_string('tag_name', self::LANG_FILE), 'display_function' => 'htmltab_display_function'), 'assigntime' => array('header' => get_string('assigntime', self::LANG_FILE), 'display_function' => 'htmltab_display_function', 'sortable' => false), 'completetime' => array('header' => get_string('completion_time', self::LANG_FILE), 'display_function' => 'htmltab_display_function', 'sortable' => false));
     }
     if ($dir !== 'DESC') {
         $dir = 'ASC';
     }
     if (isset($columns[$sort])) {
         $columns[$sort]['sortable'] = $dir;
     } else {
         $sort = 'name';
         $columns[$sort]['sortable'] = $dir;
     }
     $newarr = array();
     $users = array();
     if (empty($this->id)) {
         $users = $this->get_users_avail($sort, $dir, $page * $perpage, $perpage, $namesearch, $alpha);
         $usercount = $this->count_users_avail($namesearch, $alpha);
         pmalphabox(new moodle_url('/local/elisprogram/index.php', array('s' => 'ins', 'section' => 'curr', 'action' => 'add', 'id' => $classid, 'sort' => $sort, 'dir' => $dir, 'perpage' => $perpage)), 'alpha', get_string('tag_name', self::LANG_FILE) . ':');
         $pagingbar = new paging_bar($usercount, $page, $perpage, "index.php?s=ins&amp;section=curr&amp;id={$classid}&amp;action=add&amp;" . "sort={$sort}&amp;dir={$dir}&amp;perpage={$perpage}&amp;alpha={$alpha}&amp;" . "search=" . urlencode($namesearch));
         // TBD: .'&amp;'
         echo $OUTPUT->render($pagingbar);
         flush();
     } else {
         //error_log("instructor.class.php::edit_form_html(); userid = {$this->userid}");
         $user = new stdClass();
         $user->name = '?';
         if ($tmpuser = new user($this->userid)) {
             $tmpuser->load();
             $user = $tmpuser->to_object();
             $user->name = $tmpuser->moodle_fullname();
         }
         $users[] = $user;
         $usercount = 0;
         // TBD: 1 ???
     }
     $has_users = is_array($users) && !empty($users) || $users instanceof Iterator && $users->valid() === true ? true : false;
     if (empty($this->id) && $has_users === false) {
         $table = NULL;
     } else {
         $insobj = new instructor();
         //$table->width = "100%";
         foreach ($users as $user) {
             $tabobj = new stdClass();
             $assigntime = $this->assigntime;
             $completetime = $this->completetime;
             $selection = json_decode(retrieve_session_selection($user->id, 'add'));
             if ($selection) {
                 $assigntime = pm_timestamp(0, 0, 0, $selection->enrolment_date->month, $selection->enrolment_date->day, $selection->enrolment_date->year);
                 $completetime = pm_timestamp(0, 0, 0, $selection->completion_date->month, $selection->completion_date->day, $selection->completion_date->year);
             }
             /* **** debug code
                  ob_start();
                  var_dump($user);
                  $tmp = ob_get_contents();
                  ob_end_clean();
                  error_log("instructor.class.php::edit_form_html() user = $tmp");
                **** */
             foreach ($columns as $column => $cdesc) {
                 switch ($column) {
                     case 'assign':
                         $tabobj->{$column} = '<input type="checkbox" id="checkbox' . $user->id . '" onClick="select_item(' . $user->id . ')" name="users[' . $user->id . '][assign]" value="1" ' . ($selection ? 'checked="checked"' : '') . '/>' . '<input type="hidden" name="users[' . $user->id . '][idnumber]" ' . 'value="' . $user->idnumber . '" />';
                         break;
                     case 'name':
                     case 'idnumber':
                     case 'description':
                         $tabobj->{$column} = $user->{$column};
                         break;
                     case 'assigntime':
                         $tabobj->{$column} = cm_print_date_selector('users[' . $user->id . '][startday]', 'users[' . $user->id . '][startmonth]', 'users[' . $user->id . '][startyear]', $assigntime, true);
                         break;
                     case 'completetime':
                         $tabobj->{$column} = cm_print_date_selector('users[' . $user->id . '][endday]', 'users[' . $user->id . '][endmonth]', 'users[' . $user->id . '][endyear]', $completetime, true);
                         break;
                     default:
                         $tabobj->{$column} = '';
                         break;
                 }
             }
             $newarr[] = $tabobj;
             //$table->data[] = $newarr;
         }
         $table = new display_table($newarr, $columns, get_pm_url(), 'sort', 'dir', array('id' => 'selectiontbl'));
     }
     unset($users);
     print_checkbox_selection($classid, 'ins', 'add');
     if (empty($this->id)) {
         pmsearchbox(null, 'search', 'get', get_string('show_all_users', self::LANG_FILE));
         echo '<form method="post" action="index.php?s=ins&amp;section=curr&amp;id=' . $classid . '" >' . "\n";
         echo '<input type="hidden" name="action" value="savenew" />' . "\n";
     } else {
         echo '<form method="post" action="index.php?s=ins&amp;section=curr&amp;id=' . $classid . '" >' . "\n";
         echo '<input type="hidden" name="action" value="update" />' . "\n";
         echo '<input type="hidden" name="association_id" value="' . $this->id . '" />' . "\n";
         echo '<input type="hidden" name="id" value="' . $this->classid . '" />' . "\n";
         echo '<input type="hidden" name="userid" value="' . $this->userid . '" />' . "\n";
     }
     if (!empty($table) && !empty($newarr)) {
         if ($action == 'add') {
             $PAGE->requires->js('/local/elisprogram/js/classform.js');
             echo '<input type="button" onclick="checkbox_select(true,\'[assign]\')" value="' . get_string('selectall') . '" /> ';
             echo '<input type="button" onclick="checkbox_select(false,\'[assign]\')" value="' . get_string('deselectall') . '" /> ';
         }
         echo $table->get_html();
         $pagingbar = new paging_bar($usercount, $page, $perpage, "index.php?s=ins&amp;section=curr&amp;id={$classid}&amp;action=add&amp;" . "sort={$sort}&amp;dir={$dir}&amp;perpage={$perpage}&amp;alpha={$alpha}&amp;" . "search=" . urlencode($namesearch));
         // TBD: .'&amp;'
         echo $OUTPUT->render($pagingbar);
     }
     if (empty($this->id)) {
         if ($has_users === false) {
             pmshowmatches($alpha, $namesearch);
         }
         echo '<br /><input type="submit" value="' . get_string('assign_selected', self::LANG_FILE) . '">' . "\n";
     } else {
         echo '<br /><input type="submit" value="' . get_string('update_assignment', self::LANG_FILE) . '">' . "\n";
     }
     echo '</form>' . "\n";
     $output = ob_get_contents();
     ob_end_clean();
     return $output;
 }
Ejemplo n.º 19
0
 /**
  * Function to handle curriculum not completed events.
  *
  */
 public static function curriculum_notcompleted_handler($curstudent)
 {
     global $CFG, $DB;
     require_once elispm::lib('notifications.php');
     /// Does the user receive a notification?
     $sendtouser = elis::$config->local_elisprogram->notify_curriculumnotcompleted_user;
     $sendtorole = elis::$config->local_elisprogram->notify_curriculumnotcompleted_role;
     $sendtosupervisor = elis::$config->local_elisprogram->notify_curriculumnotcompleted_supervisor;
     /// If nobody receives a notification, we're done.
     if (!$sendtouser && !$sendtorole && !$sendtosupervisor) {
         return true;
     }
     $context = context_system::instance();
     // Send notifications
     $message = new notification();
     /// Set up the text of the message
     $text = empty(elis::$config->local_elisprogram->notify_curriculumnotcompleted_message) ? get_string('notifycurriculumnotcompletedmessagedef', 'local_elisprogram') : elis::$config->local_elisprogram->notify_curriculumnotcompleted_message;
     $user = new user($curstudent->userid);
     if (!$user) {
         return true;
     }
     $user->load();
     // Get course info
     $program = $DB->get_record(curriculum::TABLE, array('id' => $curstudent->curriculumid));
     $search = array('%%userenrolname%%', '%%programname%%');
     $replace = array($user->moodle_fullname(), $program->name);
     $text = str_replace($search, $replace, $text);
     $eventlog = new Object();
     $eventlog->event = 'curriculum_notcompleted';
     $eventlog->instance = $curstudent->id;
     /// Store the assignment id.
     $eventlog->fromuserid = $user->id;
     if ($sendtouser) {
         $message->send_notification($text, $user, null, $eventlog);
     }
     $users = array();
     if ($sendtorole) {
         /// Get all users with the notify_curriculumnotcomplete capability.
         if ($roleusers = get_users_by_capability($context, 'local/elisprogram:notify_programnotcomplete')) {
             $users = $users + $roleusers;
         }
     }
     if ($sendtosupervisor) {
         /// Get parent-context users.
         if ($supervisors = pm_get_users_by_capability('user', $user->id, 'local/elisprogram:notify_programnotcomplete')) {
             $users = $users + $supervisors;
         }
     }
     foreach ($users as $u) {
         $message->send_notification($text, $u, $user, $eventlog);
     }
     return true;
 }
Ejemplo n.º 20
0
         if ($pwdAccepted) {
             $_SESSION['userid'] = $user->get_variable('users_id');
             header('Location: ' . $relocationString);
         }
     }
 } else {
     if (isset($_POST['signup'])) {
         $userNameValid = false;
         $emailValid = false;
         $previousEmailAddress = $_POST['email'];
         $previousSignupName = $_POST['signup'];
         if (filter_var($previousEmailAddress, FILTER_VALIDATE_EMAIL)) {
             // check if email or user name is currently used.
             $user = new user();
             $user->set_variable('users_username', $_POST['signup']);
             if (!$user->load()) {
                 // user name is ok
                 $userNameValid = true;
             }
             $user->reset_query();
             $user->set_variable('users_email', $_POST['email']);
             if (!$user->load()) {
                 //email is ok
                 $emailValid = true;
             } else {
                 $emailInvalidString = "Email address already in use.";
             }
             if ($emailValid && $userNameValid) {
                 $randPassword = user::randomPassword();
                 $user->reset_query();
                 $user->set_variable('users_email', $_POST['email']);
Ejemplo n.º 21
0
<?php

//Include the PS_Pagination class
require_once 'php/db_interface/autoload.php';
session_start();
if (!isset($_SESSION['userid'])) {
    header('Location: /');
}
$username = "******";
$user = new user();
$uid = $_SESSION['userid'];
$user->set_variable('users_id', $uid);
$userCreationDate;
if ($user->load()) {
    $username = $user->get_variable('users_username');
    $userCreationDate = $user->get_variable('users_creationdate');
}
$admin = new admins();
$admin->set_variable('admin_user_id', $uid);
$isAdmin = false;
$showToAdminClass = '';
if ($admin->load()) {
    $isAdmin = true;
    $showToAdminClass = '';
}
if (isset($_GET['lo'])) {
    session_destroy();
    header('Location: /');
}
$showClass = "";
$trialTimeClass = "none";
Ejemplo n.º 22
0
global $user;
global $config;
global $layout;
global $website;
// create database connection
$DB = new database();
if (!$DB->connect()) {
    die(APP_NAME . ' # ERROR<br /> ' . $DB->get_last_error());
}
// session checking
if (empty($_SESSION['APP_USER#' . APP_UNIQUE])) {
    $DB->disconnect();
    die('{"jsonrpc" : "2.0", "error" : {"code": 100, "message": "No user logged in."}, "id" : "id"}');
} else {
    $user = new user();
    $user->load($_SESSION['APP_USER#' . APP_UNIQUE]);
}
// load the working website
$website = new Website();
if (!empty($_SESSION['website_active'])) {
    $website->load($_SESSION['website_active']);
} else {
    $website->load();
}
// load the first available
// force loading user permissions before desconnecting from the database
$foo = $user->permission("foo");
session_write_close();
$DB->disconnect();
function navigate_upload_remove_temporary($targetDir, $maxFileAge = 86400)
{
Ejemplo n.º 23
0
function nvweb_content($vars = array())
{
    global $website;
    global $DB;
    global $current;
    global $template;
    global $structure;
    $out = '';
    switch (@$vars['mode']) {
        case 'title':
            if ($current['type'] == 'structure') {
                $rs = nvweb_content_items($current['object']->id, true, 1);
                $texts = webdictionary::load_element_strings('item', $rs[0]->id);
                $out = $texts[$current['lang']]['title'];
            } else {
                $texts = webdictionary::load_element_strings($current['type'], $current['object']->id);
                $out = $texts[$current['lang']]['title'];
            }
            if (!empty($vars['function'])) {
                eval('$out = ' . $vars['function'] . '("' . $out . '");');
            }
            break;
        case 'date':
        case 'date_post':
            $ts = $current['object']->date_to_display;
            // if no date, return nothing
            if (!empty($ts)) {
                $out = nvweb_content_date_format(@$vars['format'], $ts);
            }
            break;
        case 'date_created':
            $ts = $current['object']->date_created;
            $out = $vars['format'];
            $out = nvweb_content_date_format($out, $ts);
            break;
        case 'comments':
            // display published comments number for the current item
            $out = nvweb_content_comments_count();
            break;
        case 'views':
            $out = $current['object']->views;
            break;
        case 'summary':
            $length = 300;
            $allowed_tags = array();
            if (!empty($vars['length'])) {
                $length = intval($vars['length']);
            }
            $texts = webdictionary::load_element_strings('item', $current['object']->id);
            $text = $texts[$current['lang']]['main'];
            if (!empty($vars['allowed_tags'])) {
                $allowed_tags = explode(',', $vars['allowed_tags']);
            }
            $out = core_string_cut($text, 300, '&hellip;', $allowed_tags);
            break;
        case 'author':
            if (!empty($current['object']->author)) {
                $nu = new user();
                $nu->load($current['object']->author);
                $out = $nu->username;
                unset($nu);
            }
            if (empty($out)) {
                $out = $website->name;
            }
            break;
        case 'structure':
            // force loading structure data
            nvweb_menu();
            $structure_id = 0;
            if ($current['type'] == 'item') {
                $structure_id = $current['object']->category;
            } else {
                if ($current['type'] == 'structure') {
                    $structure_id = $current['object']->id;
                }
            }
            switch ($vars['return']) {
                case 'path':
                    $out = $structure['routes'][$structure_id];
                    break;
                case 'title':
                    $out = $structure['dictionary'][$structure_id];
                    break;
                case 'action':
                    $out = nvweb_menu_action($structure_id);
                    break;
                default:
            }
            break;
        case 'tags':
            $tags = array();
            $search_url = nvweb_source_url('theme', 'search');
            if (!empty($search_url)) {
                $search_url .= '?q=';
            } else {
                $search_url = NVWEB_ABSOLUTE . '/nvtags?q=';
            }
            $ids = array();
            if (empty($vars['separator'])) {
                $vars['separator'] = ' ';
            }
            $class = 'item-tag';
            if (!empty($vars['class'])) {
                $class = $vars['class'];
            }
            if (!empty($vars['id'])) {
                $itm = new item();
                $itm->load($vars['id']);
                $enabled = nvweb_object_enabled($itm);
                if ($enabled) {
                    $texts = webdictionary::load_element_strings('item', $itm->id);
                    $itags = explode(',', $texts[$current['lang']]['tags']);
                    if (!empty($itags)) {
                        for ($i = 0; $i < count($itags); $i++) {
                            if (empty($itags[$i])) {
                                continue;
                            }
                            $tags[$i] = '<a class="' . $class . '" href="' . $search_url . $itags[$i] . '">' . $itags[$i] . '</a>';
                        }
                    }
                }
            } else {
                if ($current['type'] == 'item') {
                    // check publishing is enabled
                    $enabled = nvweb_object_enabled($current['object']);
                    if ($enabled) {
                        $texts = webdictionary::load_element_strings('item', $current['object']->id);
                        $itags = explode(',', $texts[$current['lang']]['tags']);
                        if (!empty($itags)) {
                            for ($i = 0; $i < count($itags); $i++) {
                                if (empty($itags[$i])) {
                                    continue;
                                }
                                $tags[$i] = '<a class="' . $class . '" href="' . $search_url . $itags[$i] . '">' . $itags[$i] . '</a>';
                            }
                        }
                    }
                } else {
                    if ($current['type'] == 'structure') {
                        $rs = nvweb_content_items($current['object']->id);
                        foreach ($rs as $category_item) {
                            $enabled = nvweb_object_enabled($category_item);
                            if ($enabled) {
                                $texts = webdictionary::load_element_strings('item', $current['object']->id);
                                $itags = explode(',', $texts[$current['lang']]['tags']);
                                if (!empty($itags)) {
                                    for ($i = 0; $i < count($itags); $i++) {
                                        $tags[$i] = '<a class="' . $class . '" href="' . $search_url . $itags[$i] . '">' . $itags[$i] . '</a>';
                                    }
                                }
                            }
                        }
                    }
                }
            }
            $out = implode($vars['separator'], $tags);
            break;
        case 'section':
        case 'body':
        default:
            if (empty($vars['section'])) {
                $vars['section'] = 'main';
            }
            $section = "section-" . $vars['section'];
            if ($current['type'] == 'item') {
                // check publishing is enabled
                $enabled = nvweb_object_enabled($current['object']);
                $texts = NULL;
                // retrieve last saved text (is a preview request from navigate)
                if ($_REQUEST['preview'] == 'true' && $current['navigate_session'] == 1) {
                    $texts = webdictionary_history::load_element_strings('item', $current['object']->id, 'latest');
                } else {
                    if ($enabled) {
                        $texts = webdictionary::load_element_strings('item', $current['object']->id);
                    }
                }
                // have we found any content?
                if (!empty($texts)) {
                    foreach ($template->sections as $tsection) {
                        if ($tsection['id'] == $vars['section'] || $tsection['code'] == $vars['section']) {
                            switch ($tsection['editor']) {
                                case 'raw':
                                    $out = nl2br($texts[$current['lang']][$section]);
                                    break;
                                case 'html':
                                case 'tinymce':
                                default:
                                    $out = $texts[$current['lang']][$section];
                                    break;
                            }
                            break;
                        }
                    }
                }
            } else {
                if ($current['type'] == 'structure') {
                    $rs = nvweb_content_items($current['object']->id);
                    foreach ($rs as $category_item) {
                        $enabled = nvweb_object_enabled($category_item);
                        if (!$enabled) {
                            continue;
                        } else {
                            $texts = webdictionary::load_element_strings('item', $category_item->id);
                            foreach ($template->sections as $tsection) {
                                if ($tsection['id'] == $vars['section'] || $tsection['code'] == $vars['section']) {
                                    switch ($tsection['editor']) {
                                        case 'raw':
                                            $texts[$current['lang']][$section] = nl2br($texts[$current['lang']][$section]);
                                            break;
                                        case 'html':
                                        case 'tinymce':
                                        default:
                                            // we don't need to change a thing
                                            // $texts[$current['lang']][$section] = $texts[$current['lang']][$section];
                                            break;
                                    }
                                    break;
                                }
                            }
                            $out .= '<div id="navigate-content-' . $category_item->id . '-' . $section . '">' . $texts[$current['lang']][$section] . '</div>';
                        }
                    }
                }
            }
            break;
    }
    return $out;
}
Ejemplo n.º 24
0
 public static function getUserExpirationDateTEST($uid)
 {
     $paymentDates = payment_info::getPaymentDates($uid);
     $paymentDate = date('0-0-00');
     $expiration = array();
     if (!empty($paymentDates)) {
         $paymentDate = $paymentDates['next']->format("Y-m-d");
     }
     $trialDate = date('0-0-00');
     $manualExpDate = date('0-0-00');
     $user = new user();
     $user->set_variable('users_id', $uid);
     if ($user->load()) {
         $created = new DateTime($user->get_variable('users_creationdate'));
         $created->add(new DateInterval('P' . user::TRIAL_PERIOD . 'D'));
         $trialDate = $created->format('F j, Y');
         $manualExpDate = $user->get_variable('users_manualexpdate');
     }
     if (!empty($paymentDates)) {
         $datetime = strtotime($paymentDate);
         $expiration['date'] = date("F j, Y", $datetime);
         $expiration['type'] = user::EXP_TYPE_PAID;
     }
     return $expiration;
 }
 /**
  * Validate that mappings are applied during the user enrolment (role assignment) delete action
  */
 public function test_mapping_applied_during_user_enrolment_delete()
 {
     global $CFG, $DB;
     require_once $CFG->dirroot . '/local/elisprogram/accesslib.php';
     $this->init_mapping();
     $userid = $this->create_test_user();
     $user = new user($userid);
     $user->load();
     $muser = $user->get_moodleuser();
     $roleid = create_role('testrolename', 'testroleshortname', 'testroledescription');
     $instance = context_user::instance($muser->id);
     role_assign($roleid, $muser->id, $instance->id);
     // Run the user enrolment delete actions.
     $record = new stdClass();
     $record->customaction = 'delete';
     $record->customcontext = 'user_testuseridnumber';
     $record->customuser_username = '******';
     $record->customuser_email = '*****@*****.**';
     $record->customuser_idnumber = 'testuseridnumber';
     $record->customrole = 'testroleshortname';
     $this->run_enrolment_import((array) $record);
     // Validation.
     $this->assertEquals(0, $DB->count_records('role_assignments'));
 }
Ejemplo n.º 26
0
						</li>
						<li>
							<label>&nbsp;</label>
							<input type="submit" value="Add User" />
						</li>
					</ul>
				</form>
				
				<?php 
                include "footer.php";
                break;
            case 'user_edited':
                include_once "includes/class.user.php";
                $u = new user();
                $u->username = $_POST['name'];
                $u->load(true);
                $u->unencrypted_password = $_POST['password'];
                $u->role = $_POST['role'];
                echo "<pre>";
                print_r($_POST);
                print_r($u);
                echo "</pre>";
                if ($u->save()) {
                    include "header.php";
                    ?>
					
					<h1>User Updated</h1>
					<p>The user has been updated successfully.</p>
					<p><a href="<?php 
                    echo RAPID_DIR;
                    ?>
Ejemplo n.º 27
0
						<script>$(document).ready(function() 
						    { 
						        $("#userlist").tablesorter(); 
						    } 
						); 
						</script>';
                    }
                } else {
                    $pagecontent .= '<div class="notification red"><p>Failed to load users.</p></div>';
                }
            }
        } elseif ($_GET['action'] == "bans" && $sessus->adminusers == TRUE) {
            if (isset($_GET['edit']) && intval($_GET['edit']) != 0) {
                $pagecontent .= "<h3>Edit user ban</h3>";
                $ban = new user($sql, "id", intval($_GET['edit']));
                if ($ban->load()) {
                    $changed = FALSE;
                    $redmsg = "";
                    $greenmsg = "";
                    if (isset($_POST['save'])) {
                        if (isset($_POST['isbanned'])) {
                            $changed = TRUE;
                            $ban->banned = TRUE;
                        } else {
                            $changed = TRUE;
                            $ban->banned = FALSE;
                        }
                        if (isset($_POST['banreason'])) {
                            $changed = TRUE;
                            if (strlen($_POST['banreason']) >= 3 && strlen($_POST['banreason']) <= 150) {
                                $ban->bannedreason = $_POST['banreason'];
Ejemplo n.º 28
0
 /**
  * Performs updating of user identifiers.
  * @throws moodle_exception If there was an error in passed parameters.
  * @throws data_object_exception If there was an error editing the entity.
  * @param array $data The incoming data parameter.
  * @return array An array of parameters, if successful.
  */
 public static function user_update_identifiers(array $data)
 {
     global $USER, $DB;
     if (static::require_elis_dependencies() !== true) {
         throw new moodle_exception('ws_function_requires_elis', 'local_datahub');
     }
     // Parameter validation.
     $params = self::validate_parameters(self::user_update_identifiers_parameters(), array('data' => $data));
     // Context validation.
     $context = context_user::instance($USER->id);
     self::validate_context($context);
     // Initialize version1elis importplugin for utility functions.
     $importplugin = rlip_dataplugin_factory::factory('dhimport_version1elis');
     $userparams = array();
     $data = (object) $data;
     $userid = $importplugin->get_userid_from_record($data, '', $userparams);
     if ($userid == false) {
         $a = new stdClass();
         if (empty($userparams)) {
             $a->userparams = '{empty}';
         } else {
             $a->userparams = '';
             foreach ($userparams as $userfield => $uservalue) {
                 $subfield = strpos($userfield, '_');
                 $userfield = substr($userfield, $subfield === false ? 0 : $subfield + 1);
                 if (!empty($a->userparams)) {
                     $a->userparams .= ', ';
                 }
                 $a->userparams .= "{$userfield}: '{$uservalue}'";
             }
         }
         throw new data_object_exception('ws_user_update_identifiers_fail_invalid_user', 'local_datahub', '', $a);
     }
     // Capability checking.
     require_capability('local/elisprogram:user_edit', \local_elisprogram\context\user::instance($userid));
     $user = new user($userid);
     $user->load();
     if (isset($data->username)) {
         $user->username = $data->username;
     }
     if (isset($data->idnumber)) {
         $user->idnumber = $data->idnumber;
     }
     if (isset($data->email)) {
         $user->email = $data->email;
     }
     $user->save();
     // Respond.
     $userrec = (array) $DB->get_record(user::TABLE, array('id' => $user->id));
     $userobj = $user->to_array();
     // Convert multi-valued custom field arrays to comma-separated listing.
     $fields = self::get_user_custom_fields();
     foreach ($fields as $field) {
         // Generate name using custom field prefix.
         $fullfieldname = data_object_with_custom_fields::CUSTOM_FIELD_PREFIX . $field->shortname;
         if ($field->multivalued && isset($userobj[$fullfieldname]) && is_array($userobj[$fullfieldname])) {
             $userobj[$fullfieldname] = implode(',', $userobj[$fullfieldname]);
         }
     }
     return array('messagecode' => get_string('ws_user_update_identifiers_success_code', 'local_datahub'), 'message' => get_string('ws_user_update_identifiers_success_msg', 'local_datahub'), 'record' => array_merge($userrec, $userobj));
 }
Ejemplo n.º 29
0
 private function set_base_variables()
 {
     // Initialize
     global $config;
     // Define base template variables
     $this->assign('site_uri', SITE_URI);
     $this->assign('site_path', SITE_PATH);
     $this->assign('theme_uri', SITE_URI . '/themes/' . $this->theme);
     $this->assign('theme_dir', SITE_PATH . '/themes/' . $this->theme);
     $this->assign('route', $this->route);
     $this->assign('page_title', $this->page_title);
     $this->assign('current_year', date('Y'));
     $this->assign('exchange_rate', fmoney($config['exchange_rate']));
     $this->assign('config', $config);
     // User message
     $user_message = '';
     $msg_types = array('success', 'info', 'error');
     foreach ($msg_types as $type) {
         if (!isset($this->user_messages[$type])) {
             continue;
         }
         $css_type = $type == 'error' ? 'danger' : $type;
         // Get icon
         if ($type == 'info') {
             $icon = 'info';
         } elseif ($type == 'error') {
             $icon = 'ban';
         } else {
             $icon = 'check';
         }
         // Create HTML
         $user_message .= '<div class="callout callout-' . $css_type . ' text-center"><p><i class="icon fa fa-' . $icon . '"></i> ';
         foreach ($this->user_messages[$type] as $msg) {
             if ($msg == '') {
                 continue;
             }
             $user_message .= "{$msg}<br />";
         }
         $user_message .= "</p></div>";
     }
     $this->assign('user_message', $user_message);
     // Check login
     //if (!defined('LOGIN')) {
     //	define('LOGIN', false);
     //	$GLOBALS['userid'] = 0;
     //}
     // Alerts, if admin panel
     if ($this->theme == 'admin' && $GLOBALS['userid'] > 0) {
         // Update alerts
         DB::query("UPDATE alerts SET is_new = 2 WHERE is_new = 1 AND userid = %d", $GLOBALS['userid']);
         // Get total alerts
         $total_alerts = DB::queryFirstField("SELECT count(*) FROM alerts WHERE is_new = 2 AND userid = %d", $GLOBALS['userid']);
         if ($total_alerts == '') {
             $total_alerts = 0;
         }
         // Get alerts
         $alerts = array();
         $rows = DB::query("SELECT count(*) AS total, sum(amount) AS amount, type FROM alerts WHERE is_new = 2 AND userid = %d GROUP BY type ORDER BY type", $GLOBALS['userid']);
         foreach ($rows as $row) {
             // Get icon
             if ($row['type'] == 'new_user') {
                 $icon = 'fa-users text-light-blue';
                 $name = '<b>' . $row['total'] . '</b> new users registered';
             } elseif ($row['type'] == 'new_deposit') {
                 $icon = 'fa-btc text-green';
                 $name = '<b>' . $row['total'] . '</b> new deposits, total <b>' . fmoney_coin($row['amount']) . ' BTC</b>';
             } elseif ($row['type'] == 'product_purchase') {
                 $icon = 'fa-shield text-red';
                 $name = '<b>' . $tow['total'] . '<b> product orders, total <b>' . fmoney_coin($row['amount']) . ' BTC</b>';
             } elseif ($row['type'] == 'invoice_paid') {
                 $icon = 'fa-file-pdf-o text-orange';
                 $name = '<b>' . $tow['total'] . '<b> invoices paid, total <b>' . fmoney_coin($row['amount']) . ' BTC</b>';
             } else {
                 continue;
             }
             // Add to alerts
             $vars = array('icon' => $icon, 'name' => $name);
             array_push($alerts, $vars);
         }
         // Template variables
         $this->assign('total_alerts', $total_alerts);
         $this->assign('alerts', $alerts);
     }
     // Set variables
     $this->assign('is_login', $GLOBALS['userid'] > 0 ? true : false);
     $this->assign('userid', $GLOBALS['userid']);
     // User variables, if needed
     if ($GLOBALS['userid'] > 0) {
         $user = new user($GLOBALS['userid']);
         $profile = $user->load();
         $this->assign('user', $profile);
         $this->assign('username', $profile['username']);
         $this->assign('full_name', $profile['full_name']);
         $this->assign('email', $profile['email']);
     }
 }
Ejemplo n.º 30
0
 }
 if (intval(date("Y", strtotime($user['users_lastlogindate'])) < 2013)) {
     $lastlogin = "******";
 }
 if (intval(date("Y", strtotime($user['users_manualexpdate'])) < 2013)) {
     $manualdate = "-";
 }
 $ipAddr = $user['users_ipaddress'];
 $tableDup = "";
 $otherUserId = intval($user['users_dupid']);
 $otherUserHtml = "";
 if ($otherUserId > 0) {
     $tableDup = "dupId";
     $otherUserInfo = new user();
     $otherUserInfo->set_variable('users_id', $otherUserId);
     $otherUserInfo->load();
     $otherUserHtml = '(<a href="indiv.php?uid=' . $otherUserId . '">' . $otherUserInfo->get_variable('users_username') . '</a>)';
 }
 $expirationdate = $user['expdate'];
 $now = new DateTime(date("Y-m-d"));
 $expiresin = intval($now->diff($expirationdate)->format("%r%a"));
 $emailAddress = $user['users_email'];
 $emailList[] = $emailAddress;
 //		echo '<input type="hidden" name="'.$counter.'" value="'.$id.'"/>' . "\n";
 echo '<tr class="table_row ' . $tablestate . ' ">' . "\n";
 echo '<td class="left">' . $counter . '</td>' . "\n";
 echo '<td><a href="indiv.php?uid=' . $id . '">' . $user['users_username'] . '</a>' . $otherUserHtml . '</td>' . "\n";
 echo '<td>' . $user['users_email'] . '</td>' . "\n";
 echo '<td>' . $creationdate . '</td>' . "\n";
 echo '<td>' . $lastlogin . '</td>' . "\n";
 echo '<td>' . $expiresin . '</td>' . "\n";