protected function generateSignatureWithoutParameters()
 {
     if (!($app_key = $this->app->getConfigVar(self::SIGN_CONFIG_VAR))) {
         $app_key = GcrEschoolTable::generateRandomString(15);
         $this->app->setConfigVar(self::SIGN_CONFIG_VAR, $app_key);
     }
     $plain_text_string = $app_key . self::SIGNED_REQUEST_SALT;
     return md5($plain_text_string);
 }
 public function setObject()
 {
     $arr = explode('_', $this->id);
     $this->object = GcrEschoolTable::getEschool($arr[0]);
     $this->mdl_course = $this->object->selectFromMdlTable('course', 'id', $arr[1], true);
     $course = new GcrMdlCourse($this->mdl_course, $this->object);
     if ($course->isRepresented()) {
         $this->mdl_course = $course->getCourseCollection()->getRepresentativeCourse()->getObject();
     }
 }
 public function getGradeLetter()
 {
     $grade = false;
     $grade_letters = $this->course->getGradeLetters();
     if ($this->grade_data) {
         $grade = $this->grade_data->finalgrade;
     }
     if ($grade && $grade != '') {
         return GcrEschoolTable::getLetterGrade($grade, $grade_letters);
     }
     return false;
 }
 public function startProcess()
 {
     define('INTERNAL', true);
     foreach ($this->apps as $institution) {
         $short_name = $institution->getShortName();
         if (GcrEschoolTable::isShortNameValid($short_name)) {
             error_log("\n" . date('d/m/Y H:i:s', time()) . ": App=" . $short_name . ": Starting LDAP sync", 3, gcr::rootDir . 'debug/error.log');
             print "\n" . date('d/m/Y H:i:s', time()) . ": Starting LDAP sync for {$short_name}";
             $command = "/usr/bin/php " . gcr::maharaDir . "auth/ldap/cli/sync_users.php now {$short_name}";
             system($command);
         }
     }
     $this->process->delete();
 }
 public function getEschools($refresh = false)
 {
     if (!$this->eschools || $refresh) {
         $mhr_gcr_institution_catalogs = $this->getMhrGcrInstitutionCatalogs();
         if ($mhr_gcr_institution_catalogs) {
             foreach ($mhr_gcr_institution_catalogs as $mhr_gcr_institution_catalog) {
                 $eschool = GcrEschoolTable::getEschool($mhr_gcr_institution_catalog->eschool_id, true);
                 if ($eschool) {
                     $this->eschools[] = $eschool;
                 }
             }
         }
     }
     return $this->eschools;
 }
function potentialcatalogs_submit(Pieform $form, $values)
{
    global $CFG;
    foreach ($values['potentialcatalogs'] as $eschool_short_name) {
        if ($eschool_short_name != '0') {
            $eschool = GcrEschoolTable::getEschool($eschool_short_name);
            if ($eschool->getOrganizationId() != $CFG->current_app->getId()) {
                if ($eschool->getIsPublic() || $CFG->current_app->hasPrivilege('GCUser')) {
                    $CFG->current_app->createMnetConnection($eschool);
                    $eschool->setMnetConnection($CFG->current_app);
                }
            }
        }
    }
    redirect("/artefact/courses/catalogs.php");
}
 public function getJs()
 {
     global $CFG;
     foreach ($CFG->current_app->getMnetEschools() as $eschool) {
         if (GcrEschoolTable::authorizeEschoolAccess($eschool)) {
             $this->js .= 'category_array["' . $eschool->getShortName() . '"] = [];';
             $categories = $eschool->getCourseCategories(false);
             foreach ($categories as $category) {
                 if ($category->getObject()->visible == 1 || GcrEschoolTable::authorizeHiddenCategoryAccess($eschool)) {
                     $mdl_course_category = $category->getObject();
                     $this->js .= 'category_array["' . $eschool->getShortName() . '"]["' . $mdl_course_category->id . '"] = "' . $mdl_course_category->name . '";';
                 }
             }
         }
     }
     return $this->js;
 }
 public function startProcess()
 {
     define('INTERNAL', true);
     require gcr::maharaDir . 'lib/version.php';
     foreach ($this->apps as $institution) {
         $short_name = $institution->getShortName();
         $upgrade_needed = $config->version > $institution->getConfigVar('version');
         $siteclosed = $institution->getConfigVar('siteclosed');
         if (!$upgrade_needed && (!$siteclosed || empty($siteclosed))) {
             if (GcrEschoolTable::isShortNameValid($short_name)) {
                 error_log("\n" . date('d/m/Y H:i:s', time()) . ": App=" . $short_name . ": Starting Cron Script", 3, gcr::rootDir . 'debug/error.log');
                 print "\n" . date('d/m/Y H:i:s', time()) . ": Starting cron for {$short_name}";
                 $command = "/usr/bin/php " . gcr::maharaDir . "lib/cron.php now {$short_name}";
                 system($command);
             }
         } else {
             print "\n" . date('d/m/Y H:i:s', time()) . ": Delaying cron for {$short_name}, upgrade pending";
         }
     }
     $this->process->delete();
 }
 public function startProcess()
 {
     foreach ($this->apps as $eschool) {
         $output = '';
         $ts = time();
         $short_name = $eschool->getShortName();
         if (GcrEschoolTable::isShortNameValid($short_name)) {
             $command = "/usr/bin/php " . gcr::moodleDir . "admin/cli/upgrade.php --eschool {$short_name} --non-interactive";
             system($command, $output);
             // If everything worked, this second execution should return int(0),
             // which signifies that everything is already up to date.
             system($command, $output);
             if ($output === 0) {
                 $text = ': Moodle updates for ' . $short_name . ' completed in ' . (time() - $ts) . ' seconds.';
             } else {
                 $text = ': Moodle updates FAILED for ' . $short_name . ' after ' . (time() - $ts) . ' seconds.';
             }
             $eschool->deleteCacheDirectories();
             error_log("\n" . date('d/m/Y H:i:s', time()) . $text, 3, gcr::rootDir . 'debug/error.log');
         }
     }
     $this->process->delete();
 }
 public function logout()
 {
     global $USER;
     if (isset($_COOKIE['gc_eschools'])) {
         $short_names = explode(';', $_COOKIE['gc_eschools']);
         foreach ($short_names as $short_name) {
             if ($short_name == '') {
                 continue;
             }
             if ($eschool = Doctrine::getTable('GcrEschool')->findOneByShortName($short_name)) {
                 if ($mdl_user = $this->getUserOnEschool($eschool)) {
                     $sql = 'select id, timecreated from ' . $eschool->getShortName() . '.mdl_sessions where userid = ? order by timecreated DESC';
                     $mdl_session = $eschool->gcQuery($sql, array($mdl_user->getObject()->id), true);
                     if ($mdl_session) {
                         $eschool->updateMdlTable('sessions', array('sid' => time() . 'logout' . GcrEschoolTable::generateRandomString(15)), array('id' => $mdl_session->id));
                     }
                 }
             }
         }
         setcookie('gc_eschools', '', time() - 65536, ini_get('session.cookie_path'), ini_get('session.cookie_domain'), ini_get('session.cookie_secure'), ini_get('session.cookie_httponly'));
     }
     $USER->logout();
 }
 public function startProcess()
 {
     define('MOODLE_INTERNAL', true);
     require gcr::moodleDir . "version.php";
     foreach ($this->apps as $eschool) {
         $short_name = $eschool->getShortName();
         $eschool_version = $eschool->getConfigVar('version');
         $upgrade_running = $eschool->getConfigVar('upgraderunning');
         if (empty($eschool_version)) {
             error_log('Version data missing from ' . $short_name, 3, gcr::rootDir . 'debug/error.log');
         }
         if (!$upgrade_running && $version <= $eschool_version) {
             if (GcrEschoolTable::isShortNameValid($short_name)) {
                 error_log("\n" . date('d/m/Y H:i:s', time()) . ": App=" . $short_name . ": Starting Cron Script", 3, gcr::rootDir . 'debug/error.log');
                 print "\n" . date('d/m/Y H:i:s', time()) . ": Starting cron for {$short_name}";
                 $command = "/usr/bin/php " . gcr::moodleDir . "admin/cli/cron.php --eschool {$short_name}";
                 system($command);
             }
         } else {
             print "\n" . date('d/m/Y H:i:s', time()) . ": Delaying cron for {$short_name}, upgrade pending";
         }
     }
     $this->process->delete();
 }
 public static function refreshUrl($mdl_mediaelementjs)
 {
     $url = $mdl_mediaelementjs->externalurl;
     if (strpos($url, 'institution/getUserStorageFile?')) {
         $file_param = self::FILE_GET_PARAMETER . '=';
         $str_start = strpos($url, $file_param);
         if ($str_start) {
             $short_name = GcrEschoolTable::parseShortNameFromUrl($url);
             $app = GcrInstitutionTable::getApp($short_name);
             $institution = $app->getInstitution();
             $short_name = $institution->getShortName();
             $str_start += strlen($file_param);
             $str_end = strpos($url, '&', $str_start);
             $filename = substr($url, $str_start, $str_end - $str_start);
             $filename = urldecode($filename);
             $str_start = strpos($url, '&app=');
             if ($str_start) {
                 $str_start += strlen('&app=');
                 $str_end = strpos($url, '&', $str_start);
                 $short_name_user_app = substr($url, $str_start, $str_end - $str_start);
                 $user_app = GcrInstitutionTable::getApp($short_name_user_app);
                 if ($user_app) {
                     $short_name = $short_name_user_app;
                 }
             }
             $params = array(self::FILE_GET_PARAMETER => $filename, 'course_id' => $mdl_mediaelementjs->course, 'app' => $short_name);
             $mdl_mediaelementjs->externalurl = GcrStorageAccessS3::generateStaticUrl($filename, $params, $app);
         }
     }
     return $mdl_mediaelementjs;
 }
 public function executeAutoUpdates(sfWebRequest $request)
 {
     global $CFG;
     $this->checkAuthorization();
     $this->forward404Unless($request->isMethod(sfRequest::POST));
     $form = $request->getPostParameters();
     if ($form['eschool'] == '1') {
         $eschools = Doctrine::getTable('GcrEschool')->findAll();
     } else {
         if ($eschool = GcrEschoolTable::getEschool($form['eschool'])) {
             $eschools = array($eschool);
         }
     }
     $count = GcrBackgroundProcessTypeMoodleUpdates::createProcess($eschools);
     $_SESSION['adminEschoolActionMessage'] = 'Moodle Updates started, ' . $count . ' processes were created. (check debug/error.log for updates)';
     $this->redirect($CFG->current_app->getUrl() . '/admin/eschool');
 }
 public static function generateToken()
 {
     return GcrEschoolTable::generateRandomString() . GcrEschoolTable::generateRandomString();
 }
 protected function validateEschoolShortName($shortName)
 {
     global $CFG;
     $shortNameValid = true;
     if (!GcrEschoolTable::isShortNameValid($shortName)) {
         $this->formErrors['short_nameSize'] = 'eClassroom URL must be 2-32 alphanumeric characters (1st character must be a letter).';
         $shortNameValid = false;
     }
     if (GcrEschoolTable::isShortNameUsed($shortName)) {
         $app = GcrInstitutionTable::getApp($shortName);
         if (!$CFG->current_app->hasPrivilege('GCUser') || $app->isMahara()) {
             $this->formErrors['short_nameUsed'] = 'eClassroom URL is already in use.';
             $shortNameValid = false;
         }
     }
     if (GcrEschoolTable::isShortNameReserved($shortName)) {
         $this->formErrors['short_nameReserved'] = 'eClassroom URL is a reserved word.';
         $shortNameValid = false;
     }
     return $shortNameValid;
 }
print GcrEschoolTable::getHome()->getUrl() . '/homeadmin/createCommission';
?>
" method="POST">
    <fieldset>
        <label for="institution">Platform: </label>
        <select id="institution" name="institution" style="width:95%">
        <?php 
foreach (GcrInstitutionTable::getInstitutions() as $institution) {
    print "<option value={$institution->getShortName()}>{$institution->getFullName()} ({$institution->getShortName()})</option>";
}
?>
        </select>
        <label for="institution">Catalog: </label>
        <select id="eschool" name="eschool" style="width:95%">
        <?php 
foreach (GcrEschoolTable::getEschools() as $eschool) {
    print "<option value={$eschool->getShortName()}>{$eschool->getFullName()} ({$eschool->getShortName()})</option>";
}
?>
        </select>
        <label for="commission_rate">Commission Rate %: </label>
        <input type="text" name="commission_rate" id="commission_rate" value="" />       
    </fieldset>
    </form>
</div>
<form id="deleteCommissionForm" name="deleteCommissionForm" value="-1" action="<?php 
print GcrEschoolTable::getHome()->getUrl();
?>
/homeadmin/deleteCommission" method="POST">
    <input id="del_commission_id" name="del_commission_id" type="hidden" />
</form>  
 public function setMdlCacheSettings()
 {
     $dataroot = gcr::moodledataDir;
     $home = GcrEschoolTable::getHome();
     $home_short_name = $home->getShortName();
     $home_config_file = $dataroot . $home_short_name . '/muc/config.php';
     $home_site_indentifier = md5((string) $home->getConfigVar('siteidentifier'));
     $site_identifier = md5((string) $this->getConfigVar('siteidentifier'));
     $memcached_prefix = $this->id;
     $config_file = $dataroot . $this->short_name . '/muc/config.php';
     exec('cp ' . $home_config_file . ' ' . $config_file);
     exec("sed 's/{$home_short_name}/{$memcached_prefix}/g' {$config_file} > {$config_file}_tmp");
     exec("sed 's/{$home_site_indentifier}/{$site_identifier}/g' {$config_file}_tmp > {$config_file}");
     exec('rm ' . $config_file . '_tmp');
     $this->deleteCacheDirectories();
 }
if ($app->isMoodle()) {
    $institution = $app->getInstitution();
} else {
    $institution = $app;
}
$current_user_obj = $current_user->getObject();
$mhr_user_obj = $institution->getMhrUserByUsername($current_user_obj->username);
// if the user's account doesn't exist on the institution (check for email address)
if (!$mhr_user_obj) {
    $admin = 0;
    if ($role_manager->hasPrivilege('GCUser')) {
        // we only give site admin privilege to those on home who are
        // institution admins, while everyone gets the eschool admin role
        $admin = 1;
    }
    $temp_password = GcrEschoolTable::generateRandomString(12);
    $new_user_credentials = $institution->buildUserCredentials($current_user_obj->username, $temp_password);
    $params = array('id' => gcr::autoNumber, 'password' => $new_user_credentials->password, 'salt' => $new_user_credentials->salt, 'active' => 1, 'admin' => $admin, 'firstname' => $current_user_obj->firstname, 'lastname' => $current_user_obj->lastname, 'email' => $current_user_obj->email, 'quota' => 52428800, 'passwordchange' => 1, 'username' => $current_user_obj->username);
    $mhr_user = $institution->createUser($params);
    if ($mhr_user) {
        $mhr_user_obj = $mhr_user->getObject();
        $url = $institution->setupAutoLogin($current_user_obj->username, $temp_password, 60);
    }
} else {
    $mhr_user = new GcrMhrUser($mhr_user_obj, $institution);
}
// Add user to home mhr_institution as an admin
if ($current_user_obj->email == $mhr_user_obj->email) {
    $user_app = $mhr_user->getApp();
    $mhr_usr_institution = $mhr_user->getMhrUsrInstitutionRecords($user_app->getMhrInstitution());
    if (!$mhr_usr_institution) {
print number_format($item1->getAmount(), 2);
?>
 fee)<br />
        <input type="radio" name="purchase_item" id="credits2" value="<?php 
print $item2->getShortName();
?>
" />
                2 Credit Course ($<?php 
print number_format($item2->getAmount(), 2);
?>
 fee)<br />
        <input type="radio" name="purchase_item" id="credits3" value="<?php 
print $item3->getShortName();
?>
" />
                3 Credit Course ($<?php 
print number_format($item3->getAmount(), 2);
?>
 fee)<br /><br />
        <input type="hidden" name="token" id="token" value="<?php 
print GcrEschoolTable::generateRandomString();
?>
" />
        NOTE: Selecting the wrong number of credits could result in a delay of the issuing of your transcript.<br/><br/>
        Contact <?php 
print mail_to("*****@*****.**", "*****@*****.**", array('encode' => 'true', 'class' => 'email_link'));
?>
        with any questions.<br/><br/>
        <input type="submit" class="button" value="Continue" />
    </form>
</div>
Example #20
0
 public function executeMembershipPurchase(sfWebRequest $request)
 {
     global $CFG;
     $this->authorizePurchaseOnInstitution();
     $form = $request->getPostParameters();
     if (!$request->isMethod(sfRequest::POST)) {
         $this->redirect($CFG->current_app->getUrl());
     }
     $form = $request->getPostParameters();
     if ($form['bill_cycle'] && $CFG->current_app->isMembershipAllowed($form['bill_cycle'])) {
         $this->form = new GcrPurchaseForm();
         $this->form->setDefaults(array('purchase_type' => 'membership', 'purchase_type_id' => $CFG->current_app->getShortName(), 'purchase_type_eschool_id' => $CFG->current_app->getShortName(), 'bill_cycle' => $form['bill_cycle'], 'purchase_token' => GcrEschoolTable::generateRandomString()));
         // set up object which hold info about the purchase item to display on form
         $this->purchaseObject = new StdClass();
         $this->hydratePurchaseObject($this->purchaseObject, 'membership', $CFG->current_app->getShortName(), $CFG->current_app->getShortName(), $form['bill_cycle']);
         $this->getResponse()->setTitle('eClassroom Purchase');
     } else {
         $this->redirect($CFG->current_app->getUrl());
     }
 }
 public function executeCreatePaymentInfo(sfWebRequest $request)
 {
     global $CFG;
     $CFG->current_app->requireLogin();
     $this->current_user = $CFG->current_app->getCurrentUser();
     $role_manager = $this->current_user->getRoleManager();
     $form = $request->getPostParameters();
     if ($form['id'] != '') {
         if (!$role_manager->hasPrivilege('GCUser')) {
             $CFG->current_app->gcError('Non-privileged attempted access to edit ' . $form['user_eschool_id'] . ' createPaymentInfo with user ID ' . $form['user_id'], 'gcpageaccessdenied');
         }
         if (!($credentials = Doctrine::getTable('GcrPayoffCredentials')->find($form['id']))) {
             $CFG->current_app->gcError('Credentials with ID ' . $form['id'] . ' does not exist.', 'gcdatabaseerror');
         }
         $this->payoff_credentials_form = new GcrPayoffCredentialsForm($credentials);
     } else {
         $this->payoff_credentials_form = new GcrPayoffCredentialsForm();
     }
     $institution = GcrInstitutionTable::getInstitution($form['user_eschool_id']);
     if (!($user = $institution->getUserById($form['user_id']))) {
         $CFG->current_app->gcError('Local User with ID ' . $form['user_id'] . ' on eschool ' . $institution->getShortName() . ' does not exist', 'gcdatabaseerror');
     }
     $account_manager = $user->getAccountManager();
     // If this isn't a gc admin, we need to check that they aren't trying to change someone else's credentials
     if (!$role_manager->hasPrivilege('GCUser')) {
         if (!$this->current_user->isSameUser($user)) {
             $CFG->current_app->gcError('Non-privileged attempted access to ' . $form['user_eschool_id'] . ' createPaymentInfo with user ID ' . $form['user_id'], 'gcpageaccessdenied');
         }
         if ($account_manager->usesChainedPayments()) {
             $CFG->current_app->gcError('User cannot change payoff credentials with chained payments enabled.', 'gcchainedpaymentcredentials');
         }
         $form['verify_status'] = 'unverified';
     } else {
         $form['verify_status'] = 'verified';
     }
     $form['verify_hash'] = GcrEschoolTable::generateRandomString();
     $this->payoff_credentials_form->bind($form);
     if ($this->payoff_credentials_form->isValid()) {
         $old_credentials = $account_manager->getPayoffCredentials();
         $payoff_credentials = $this->payoff_credentials_form->save();
         if ($old_credentials && $form['id'] == '') {
             $old_credentials->setVerifyStatus('expired');
             $old_credentials->save();
         }
         if ($form['verify_status'] == 'unverified') {
             $subject = 'Verification of Global Classroom Payment Information';
             $params = array('institution' => $institution, 'credentials' => $payoff_credentials);
             $email = new GcrUserEmailer('verify_payoff_credentials', $user, $subject, $params);
             $email->sendHtmlEmail();
         }
         $this->redirect($CFG->current_app->getUrl() . '/account/newPaymentInfo?id=' . $payoff_credentials->getId());
     }
     $this->setTemplate('paymentInfo');
 }
 protected function getCourseCell($ts, $enrolment)
 {
     $content = '';
     $course = $enrolment->getCourse();
     if ($course) {
         $mdl_course = $course->getObject();
         $content = "{$mdl_course->fullname} ({$mdl_course->shortname})";
         if (strlen($content) > 50) {
             $content = $mdl_course->fullname;
         }
         if (GcrEschoolTable::authorizeCourseAccess($course)) {
             global $CFG;
             $content = '<a href="' . $course->getUrl() . '?transfer=' . $CFG->current_app->getShortName() . '">' . $content . '</a>';
         }
     }
     return new GcrTableCell(array(), $content);
 }
Example #23
0
 public static function initialize()
 {
     $url = explode('.', $_SERVER['HTTP_HOST']);
     if ($url[0] . '.' . $url[1] != self::rootDomainName) {
         // Repair problem where fast CGI is sending *.globalclassroom.us as
         // the $_SERVER['SERVER_NAME']
         $_SERVER['SERVER_NAME'] = str_replace('*', $url[0], $_SERVER['SERVER_NAME']);
         // redirect all http:// to https://
         if (empty($_SERVER['HTTPS']) || $_SERVER['HTTPS'] === 'off' || $_SERVER['SERVER_PORT'] != 443) {
             header('Location: https://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
             die;
         }
         if ((defined('GC_SYMFONY_LOADED') && GC_SYMFONY_LOADED) == false) {
             self::loadSymfony();
             define('GC_SYMFONY_LOADED', true);
         }
         global $CFG;
         if ($institution = Doctrine::getTable('GcrInstitution')->findOneByShortName($url[0])) {
             if (isset($CFG)) {
                 GcrInstitutionTable::constructCurrentInstitution($institution);
             } else {
                 define('INTERNAL', 1);
                 define('PUBLIC', 1);
                 global $USER, $db, $THEME, $SESSION;
                 require '/var/www/globalclassroom4/web/portal/init.php';
             }
         } else {
             if ($eschool = Doctrine::getTable('GcrEschool')->findOneByShortName($url[0])) {
                 if (isset($CFG)) {
                     GcrEschoolTable::constructCurrentEschool($eschool);
                 } else {
                     require_once '/var/www/globalclassroom4/web/stratus/config.php';
                 }
             } else {
                 // redirect to front page if the short_name doesn't exist
                 header('Location: https://' . self::frontPageDomain . '/notfound');
                 die;
             }
         }
         return true;
     }
     return false;
 }
 public function executeTranscript(sfWebRequest $request)
 {
     global $CFG;
     $this->authorizeHistory();
     $form = $request->getPostParameters();
     $enrolments = array();
     foreach ($form as $key => $value) {
         $key_data = explode('&', $key);
         $eschool = GcrEschoolTable::getEschool($key_data[0]);
         $mdl_user_enrolment = $eschool->selectFromMdlTable('user_enrolments', 'id', $key_data[1], true);
         $enrolment = new GcrMdlUserEnrolment($mdl_user_enrolment, $eschool);
         if ($this->is_user) {
             $mhr_user = $enrolment->getUser();
             if ($this->user->getObject()->id == $mhr_user->getObject()->id) {
                 $enrolments[] = $enrolment;
             }
         } else {
             $enrolments[] = $enrolment;
         }
     }
     $this->course_history_table = new GcrCourseHistoryTable($enrolments, $this->user, 0, false, $this->gc_admin, $this->owner, false);
     $this->course_history_table->printTableAsPdf();
     die;
 }
    print GcrPurchaseTable::gc_format_money($amount);
    ?>
</td>
                <?php 
    if ($payoff->isPending()) {
        ?>
                    <td>
                        <form action="<?php 
        print GcrEschoolTable::getHome()->getUrl() . '/homeadmin/approvePayoff?id=' . $payoff->getId();
        ?>
" method="POST">
                            <button type="submit" class="approvePayoffButton form_button button">Approve</button>
                        </form>
                    </td>
                <?php 
    } else {
        print '<td> </td>';
    }
    ?>
                <td>
                    <input type="button" class="form_button button" value="Delete" onclick="return confirmClick('Are you sure you want to delete this transaction?', '<?php 
    print GcrEschoolTable::getHome()->getUrl() . '/homeadmin/deletePayoff?id=' . $payoff->getId();
    ?>
')" />
                </td>
            </tr>
        <?php 
}
?>
    </tbody>
</table>
 public function executeDoManualClassroom(sfWebRequest $request)
 {
     $this->authorizeUser();
     global $CFG;
     $form = $request->getPostParameters();
     if ($form['id'] != '') {
         // Edit of existing purchase
         $purchase = $this->getManualPurchase($form['id'], 'classroom');
         $institution = $this->eschool->getInstitution();
         if (!($mhr_user = $institution->selectFromMhrTable('usr', 'id', $form['purchase_user_field'], true))) {
             $CFG->current_app->gcError('Invalid user ID ' . $form['purchase_user_field'], 'gcdatabaseerror');
         }
         $manual_purchase_form = new GcrPurchaseClassroomManualForm($purchase, array('eschool' => $institution));
         $form['user_id'] = $mhr_user->id;
         $form['amount'] = $form['amount_field'];
         $form['gc_fee'] = $this->eschool->getGcFeeClassroom();
         $form['bill_cycle'] = GcrPurchaseTable::convertDatetoTimestamp($form['bill_cycle']);
         $form['trans_time'] = GcrPurchaseTable::convertDatetoTimestamp($form['trans_time']);
         $manual_purchase_form->bind($form);
         if ($manual_purchase_form->isValid()) {
             $purchase = $manual_purchase_form->save();
             $purchase->updateRelatedAccounting();
             $this->redirect($CFG->current_app->getUrl() . '/account/view?eschool=' . $institution->getShortName());
         }
     } else {
         // New purchase
         if ($short_name = $form['purchase_type_eschool_field']) {
             $this->eschool = GcrEschoolTable::getEschool($short_name);
         } else {
             $CFG->current_app->gcError('eSchool Parameter Missing', 'gcdatabaseerror');
         }
         $institution = $this->eschool->getInstitution();
         $manual_purchase_form = new GcrPurchaseClassroomManualForm(array(), array('eschool' => $institution));
         $form['purchase_type'] = 'classroom_manual';
         $form['purchase_type_description'] = 'Manual eClassroom Transaction';
         $form['purchase_type_quantity'] = 1;
         $form['purchase_type_id'] = $this->eschool->getShortName();
         $form['user_id'] = $form['purchase_user_field'];
         $form['purchase_type_eschool_id'] = $form['purchase_type_eschool_field'];
         $form['user_institution_id'] = $institution->getShortName();
         $form['amount'] = $form['amount_field'];
         $form['gc_fee'] = $this->eschool->getGcFeeClassroom();
         $form['owner_fee'] = 0;
         $form['seller_id'] = 0;
         $form['bill_cycle'] = GcrPurchaseTable::convertDatetoTimestamp($form['bill_cycle']);
         $form['trans_time'] = GcrPurchaseTable::convertDatetoTimestamp($form['trans_time']);
         $manual_purchase_form->bind($form);
         if ($manual_purchase_form->isValid()) {
             if (!($mhr_user = $institution->selectFromMhrTable('usr', 'id', $form['purchase_user_field'], true))) {
                 $CFG->current_app->gcError('Invalid user ID ' . $form['purchase_user_field'], 'gcdatabaseerror');
             }
             $mhr_user = new GcrMhrUser($mhr_user, $institution);
             $purchase = $manual_purchase_form->save();
             $purchase->assignSeller();
             if (!$mhr_user->hasEclassroom($this->eschool)) {
                 $institution->createEclassroom($mhr_user, $this->eschool);
             }
             $purchase->updateRelatedAccounting();
             $this->redirect($CFG->current_app->getUrl() . '/account/view?eschool=' . $institution->getShortName());
         }
     }
     $this->classroom_form = $manual_purchase_form;
     $this->setTemplate('manualClassroom');
 }
							</tr>
						</thead>
						<tbody>
						<?php 
            foreach ($ctlg_courses_list as $course_list) {
                $mdl_course = $course_list->getObject();
                $course_list_item = new GcrCourseListItem($course_list);
                $eschool = $course_list->getApp();
                $id = 'gcr_course_' . $eschool->getShortName() . '_' . $mdl_course->id;
                $img_src = $course_list_item->getCourseIconUrl();
                $mdl_user = $course_list_item->getInstructor();
                $summary = $course_list_item->getSummary();
                $enrol_count = $course_list_item->getActiveUserCount();
                $shortsummary = GcrInstitutionTable::formatStringSize($summary, 250, 21);
                if ($mdl_user) {
                    $teacher_text = GcrEschoolTable::getInstructorProfileHtml($mdl_user);
                } else {
                    $teacher_text = 'None';
                }
                $fullname = GcrInstitutionTable::formatStringSize($mdl_course->fullname, 60, 30);
                $cost = $course_list->getCost();
                $cost_text = '';
                //if ($cost) {
                //$cost_text = 'Price: ' . GcrPurchaseTable::gc_format_money($cost);
                $cost_text = GcrPurchaseTable::gc_format_money($cost);
                //}
                $enrollment_status = false;
                $current_user = $CFG->current_app->getCurrentUser();
                if ($current_user->getRoleManager()->hasPrivilege('Student')) {
                    $mdl_roles = $course_list->getRoleAssignments($current_user);
                    $enrollment_status = $mdl_roles && count($mdl_roles > 0);
<?php

require_once dirname(__FILE__) . '/../config/ProjectConfiguration.class.php';
$configuration = ProjectConfiguration::getApplicationConfiguration('frontend', 'prod', false);
sfContext::createInstance($configuration);
$databaseManager = new sfDatabaseManager($configuration);
$databaseManager->loadConfiguration();
if (!($conn = Doctrine_Manager::getInstance()->getCurrentConnection())) {
    echo "Could not connect to Database.";
    die;
}
foreach (GcrInstitutionTable::getInstitutions() as $institution) {
    $password_salt = $institution->getPasswordSalt();
    if ($password_salt == '') {
        $salt = GcrEschoolTable::generateRandomString();
        $institution->setPasswordSalt($salt);
        $institution->save();
        print "\n" . $institution->getShortName() . ': salt created';
    }
}
 protected function validateShortName($shortName, $testForValidNewName = true)
 {
     $shortNameValid = true;
     if (!GcrEschoolTable::isShortNameValid($shortName)) {
         $this->formErrors['short_nameSize'] = 'eSchool URL must be 3-32 alphanumeric characters (1st character must be a letter).';
         $shortNameValid = false;
     }
     if ($testForValidNewName && GcrEschoolTable::isShortNameUsed($shortName)) {
         $this->formErrors['short_nameUsed'] = 'eSchool URL is already in use.';
         $shortNameValid = false;
     }
     if ($testForValidNewName && GcrEschoolTable::isShortNameReserved($shortName)) {
         $this->formErrors['short_nameReserved'] = 'eSchool URL is a reserved word.';
         $shortNameValid = false;
     }
     return $shortNameValid;
 }
 public function checkForReplaceMnet()
 {
     if (isset($_GET['replace_mnet'])) {
         $home = GcrEschoolTable::getHome();
         if (!($var = $home->getConfigVar('gc_replace_mnet_token' . $_GET['replace_mnet']))) {
             global $CFG;
             $CFG->current_app->gcError('No Token Stored in gchome.config table for mnet replacement', 'gcpageaccessdenied');
         } else {
             if ($var != $_GET['replace_mnet']) {
                 global $CFG;
                 GcrEschoolTable::getHome()->deleteFromMdlTable('config', 'name', 'gc_replace_mnet_token' . $_GET['replace_mnet']);
                 $CFG->current_app->gcError('Mnet replacement token ' . $_GET['replace_mnet'] . ' does not match record ' . $var, 'gcpageaccessdenied');
             }
         }
         $this->replaceMnetKeys();
         print '<div id="mnet_replacement"></div>';
         die;
     }
 }