Exemplo n.º 1
0
 public function UpdateField($fieldName, $newValue, &$pkVal = NULL, $fieldType = NULL)
 {
     // if pk is null, update the pk to random string
     if ($pkVal === null) {
         parent::UpdateField('cms_id', 'newpage_' . rand(), $pkVal);
     }
     // if field is pk and newvalue is empty, return
     if ($fieldName == 'cms_id' && !$newValue) {
         return;
     }
     parent::UpdateField($fieldName, $newValue, $pkVal, $fieldType);
 }
Exemplo n.º 2
0
 public function UpdateField($fieldName, $newValue, &$pkVal = NULL, $fieldType = NULL)
 {
     if ($fieldName == 'username') {
         $newValue = trim($newValue);
         // does this email already exist?
         $r = database::query('SELECT * FROM `' . $this->tablename . '` WHERE `username` = ?', array($newValue));
         if ($r->fetch()) {
             uNotices::AddNotice('This email is already registered to an account.', NOTICE_TYPE_ERROR);
             return FALSE;
         }
         if (preg_match('/^[A-Z0-9._%+-]+@[A-Z0-9.-]+\\.[A-Z]{2,4}$/i', $newValue)) {
             // email address has been updated - set email_confirm and email_confirm_code
             if ($pkVal === NULL) {
                 parent::UpdateField('username', $newValue, $pkVal);
             }
             parent::UpdateField('email_confirm', $newValue, $pkVal);
         } else {
             parent::UpdateField('username', $newValue, $pkVal);
         }
         return TRUE;
     }
     if ($pkVal === NULL) {
         parent::UpdateField('username', 'unverified_' . uCrypt::GetRandom(75), $pkVal);
     }
     if ($fieldName == 'email_confirm_code' && $newValue === true) {
         // get old username
         $r = database::query('SELECT username, email_confirm FROM `' . $this->tablename . '` WHERE user_id = ?', array($pkVal));
         if ($r && ($row = $r->fetch()) && $row['email_confirm']) {
             $old = $row['username'];
             $new = $row['email_confirm'];
             // set username to email_confirm
             parent::UpdateField('username', 'email_confirm', $pkVal, ftRAW);
             // clear email_confirm + code
             parent::UpdateField('email_confirm', '', $pkVal);
             parent::UpdateField('email_confirm_code', '', $pkVal);
             if ($old != $new) {
                 uEvents::TriggerEvent('UsernameChanged', NULL, array($old, $new));
             }
         }
         return;
     }
     parent::UpdateField($fieldName, $newValue, $pkVal, $fieldType);
 }
Exemplo n.º 3
0
 public static function initChecksums()
 {
     if (!self::$tableChecksum) {
         $file = uCache::retrieve('__table_checksum', false);
         if ($file) {
             self::$tableChecksum = parse_ini_string(file_get_contents($file));
         }
     }
 }
Exemplo n.º 4
0
$allmodules = utopia::GetModulesOf('iUtopiaModule');
foreach ($allmodules as $row) {
    // must run second due to requiring GLOB_MOD to be setup fully
    timer_start('Init: ' . $row['module_name']);
    $row['module_name']::Initialise();
    timer_end('Init: ' . $row['module_name']);
}
timer_end('Static Initialise');
uConfig::DefineConfig();
uConfig::ValidateConfig();
uEvents::TriggerEvent('ConfigDefined');
timer_start('Before Init');
uEvents::TriggerEvent('BeforeInit');
timer_end('Before Init');
timer_start('Table Initialise');
uTableDef::TableExists(null);
// cache table exists
$allmodules = utopia::GetModulesOf('uTableDef');
foreach ($allmodules as $row) {
    // must run second due to requiring GLOB_MOD to be setup fully
    timer_start('Init: ' . $row['module_name']);
    $obj = utopia::GetInstance($row['module_name']);
    $obj->AssertTable();
    // setup Parents
    timer_end('Init: ' . $row['module_name']);
}
timer_end('Table Initialise');
define('INIT_COMPLETE', TRUE);
timer_start('After Init');
uEvents::TriggerEvent('InitComplete');
uEvents::TriggerEvent('AfterInit');