コード例 #1
0
ファイル: users.php プロジェクト: OptimalInternet/uCore
 public function UpdateField($fieldAlias, $newValue, &$pkVal = NULL)
 {
     $cUser = $this->LookupRecord(array('user_id' => uUserLogin::IsLoggedIn()));
     if ($fieldAlias == 'username') {
         $newValue = trim($newValue);
         if ($newValue === $cUser['username']) {
             return;
         }
         if (!preg_match('/^[A-Z0-9._%+-]+@[A-Z0-9.-]+\\.[A-Z]{2,4}$/i', $newValue)) {
             uNotices::AddNotice('You must enter a valid email address.', NOTICE_TYPE_ERROR);
             return;
         }
         if (uUsersList::TestCredentials($cUser['username'], $_POST[$this->CreateSqlField('current_password_email', $pkVal)]) === false) {
             uNotices::AddNotice('The password you entered does not match our records.', NOTICE_TYPE_ERROR);
             return;
         }
         uNotices::AddNotice('You must validate your new email address before you are able to log in with it.');
     }
     if ($fieldAlias == 'password') {
         if (!$newValue) {
             return;
         }
         if ($newValue !== $_POST[$this->CreateSqlField('confirm_password', $pkVal)]) {
             uNotices::AddNotice('Password confirmation did not match, please try again.', NOTICE_TYPE_WARNING);
             return;
         }
         if (uUsersList::TestCredentials($cUser['username'], $_POST[$this->CreateSqlField('current_password', $pkVal)]) === false) {
             uNotices::AddNotice('The password you entered does not match our records.', NOTICE_TYPE_ERROR);
             return;
         }
         uNotices::AddNotice('Your password has been updated.');
     }
     return parent::UpdateField($fieldAlias, $newValue, $pkVal);
 }
コード例 #2
0
ファイル: news.php プロジェクト: OptimalInternet/uCore
 public function UpdateField($fieldAlias, $newValue, &$pkVal = NULL)
 {
     if ($fieldAlias == 'tags') {
         $newValue = explode(',', $newValue);
         foreach ($newValue as $k => $v) {
             $newValue[$k] = trim($v);
         }
     }
     parent::UpdateField($fieldAlias, $newValue, $pkVal);
 }
コード例 #3
0
ファイル: cms.php プロジェクト: OptimalInternet/uCore
 public function UpdateField($fieldAlias, $newValue, &$pkVal = NULL)
 {
     if ($fieldAlias == 'cms_id' && !$newValue) {
         return;
     }
     if ($pkVal == NULL && $fieldAlias == 'title') {
         $this->UpdateField('cms_id', UrlReadable($newValue), $pkVal);
     }
     if ($fieldAlias == 'revert') {
         $rec = $this->LookupRecord($pkVal);
         $this->UpdateField('content', $rec['content_published'], $pkVal);
         $this->UpdateFieldRaw('content_published_time', '`content_time`', $pkVal);
         AjaxEcho('window.location.reload();');
         return;
     }
     if ($fieldAlias == 'publish') {
         $rec = $this->LookupRecord($pkVal);
         $this->UpdateField('content_published', $rec['content'], $pkVal);
         return;
     }
     if ($fieldAlias == 'unpublish') {
         $this->UpdateField('is_published', 0, $pkVal);
         $this->UpdateField('content_published_time', null, $pkVal);
         return;
     }
     if ($fieldAlias == 'cms_id') {
         $newValue = UrlReadable($newValue);
         // also update children's "parent" to this value
         if ($pkVal !== NULL) {
             $dataset = $this->GetDataset(array('parent' => $pkVal), true);
             while ($child = $dataset->fetch()) {
                 $this->UpdateField('parent', $newValue, $child['cms_id']);
             }
         }
     }
     if (substr($fieldAlias, 0, 8) == 'content:') {
         $rec = $this->LookupRecord($pkVal);
         $contentarr = utopia::jsonTryDecode($rec['content']);
         if (!is_array($contentarr)) {
             $contentarr = array('' => $contentarr);
         }
         $id = substr($fieldAlias, 8);
         if (!$id) {
             $id = '';
         }
         $contentarr[$id] = (string) $newValue;
         $fieldAlias = 'content';
         $newValue = $contentarr;
         $this->SetFieldType('content_time', ftRAW);
         $this->UpdateField('content_time', 'NOW()', $pkVal);
     }
     if ($fieldAlias == 'content_published') {
         $this->SetFieldType('content_published_time', ftRAW);
         $this->UpdateFieldRaw('content_published_time', '`content_time`', $pkVal);
         $this->UpdateField('is_published', 1, $pkVal);
     }
     $oPk = $pkVal;
     $ret = parent::UpdateField($fieldAlias, $newValue, $pkVal);
     if ($pkVal !== $oPk) {
         $o = utopia::GetInstance('uCMS_View');
         $url = $o->GetURL(array('cms_id' => $pkVal, 'edit' => 1));
         AjaxEcho("window.location.replace('{$url}');");
     }
     // update cms list to reflect published status
     uCMS_List::RefreshList();
     return $ret;
 }
コード例 #4
0
ファイル: widget.php プロジェクト: OptimalInternet/uCore
 public function UpdateField($fieldAlias, $newValue, &$pkVal = NULL)
 {
     $rec = $this->LookupRecord($pkVal);
     $this->InitInstance($rec['block_type']);
     $ret = parent::UpdateField($fieldAlias, $newValue, $pkVal);
     if ($fieldAlias == 'block_type') {
         AjaxEcho("window.location.reload(false);");
     }
     return $ret;
 }
コード例 #5
0
ファイル: detail.php プロジェクト: OptimalInternet/uCore
 public function UpdateField($fieldAlias, $newValue, &$pkVal = NULL)
 {
     if ($fieldAlias == 'role' && isset($_SESSION['current_user']) && $pkVal == $_SESSION['current_user']) {
         uNotices::AddNotice('You cannot edit your own role', NOTICE_TYPE_ERROR);
         return;
     }
     if ($fieldAlias == '_validate_user') {
         return $this->UpdateField('email_confirm_code', true, $pkVal);
     }
     if ($fieldAlias == '_validate_send') {
         uVerifyEmail::VerifyAccount($pkVal);
         return;
     }
     parent::UpdateField($fieldAlias, $newValue, $pkVal);
 }