예제 #1
0
 protected function Form_Create()
 {
     parent::Form_Create();
     if (QApplication::GetUserId() == NarroUser::ANONYMOUS_USER_ID) {
         $strPassHash = QApplication::QueryString('h');
         $strUsername = QApplication::QueryString('u');
         if ($strPassHash && $strUsername) {
             $objUser = NarroUser::LoadByUsernameAndPassword($strUsername, $strPassHash);
             if ($objUser instanceof NarroUser) {
                 QApplication::$User = $objUser;
             } else {
                 QApplication::Redirect('login.php');
             }
         } else {
             QApplication::Redirect('login.php');
         }
     }
     $this->lblMessage = new QLabel($this);
     $this->lblMessage->HtmlEntities = false;
     $this->txtPassword = new QTextBox($this);
     $this->txtPassword->TextMode = QTextMode::Password;
     $this->btnChangePassword = new QButton($this);
     $this->btnChangePassword->PrimaryButton = true;
     $this->btnChangePassword->Text = t('Change password');
     $this->btnChangePassword->AddAction(new QClickEvent(), new QServerAction('btnChangePassword_Click'));
 }
예제 #2
0
파일: account.php 프로젝트: Jobava/narro
 protected function Form_Create()
 {
     parent::Form_Create();
     if (QApplication::GetUserId() == NarroUser::ANONYMOUS_USER_ID) {
         QApplication::Redirect(NarroLink::ProjectList());
         exit;
     }
     if (QApplication::GetUserId() != QApplication::QueryString('u') && QApplication::HasPermissionForThisLang('Can manage users', null)) {
         $this->objUser = NarroUser::Load(QApplication::QueryString('u'));
     }
     if (!$this->objUser instanceof NarroUser) {
         $this->objUser = QApplication::$User;
     }
     $this->pnlBreadcrumb->setElements(NarroLink::ProjectList(t('Projects')), NarroLink::UserList('', t('Users')), $this->objUser->RealName);
     $this->pnlTab = new QTabs($this);
     new QPanel($this->pnlTab);
     $arrHeaders[] = NarroLink::UserProfile($this->objUser->UserId, t('Profile'));
     if (QApplication::GetUserId() == $this->objUser->UserId || QApplication::HasPermissionForThisLang('Can manage users', null)) {
         new QPanel($this->pnlTab);
         $arrHeaders[] = NarroLink::UserPreferences($this->objUser->UserId, t('Preferences'));
     }
     new QPanel($this->pnlTab);
     $arrHeaders[] = NarroLink::UserRole($this->objUser->UserId, t('Roles'));
     if (QApplication::GetUserId() == $this->objUser->UserId || QApplication::HasPermissionForThisLang('Can manage users', null)) {
         $this->pnlUser = new NarroUserEditPanel($this->objUser, $this->pnlTab);
         $arrHeaders[] = NarroLink::UserEdit($this->objUser->UserId, t('Edit'));
         $this->pnlTab->Selected = count($arrHeaders) - 1;
     }
     $this->pnlTab->Headers = $arrHeaders;
 }
예제 #3
0
 protected function Enable()
 {
     if ($this->blnEnable) {
         NarroUser::RegisterPreference($this->strName, 'option', sprintf(t('Enables the %s plugin'), $this->strName), $this->blnEnable ? 'Yes' : 'No', array('Yes', 'No'));
         $this->blnEnable = $this->blnEnable && QApplication::$User->GetPreferenceValueByName($this->strName) == 'Yes';
     }
 }
예제 #4
0
 public static function InitializeTranslationEngine()
 {
     require_once __NARRO_INCLUDES__ . '/gettext_reader.class.php';
     require_once __NARRO_INCLUDES__ . '/StreamReader.class.php';
     if (QApplication::$User->UserId == NarroUser::ANONYMOUS_USER_ID) {
         QApplication::$LanguageCode = QApplication::$TargetLanguage->LanguageCode;
     } else {
         QApplication::$LanguageCode = QApplication::$User->GetPreferenceValueByName('Application language');
     }
     define('__LOCALE_DIRECTORY__', __DOCROOT__ . __SUBDIRECTORY__ . '/locale/' . QApplication::$LanguageCode);
     QI18n::Initialize('NarroPoParser');
 }
예제 #5
0
 public function __construct()
 {
     parent::__construct();
     $this->blnEnable = false;
     $this->strName = t('Cedill/Comma issue solver');
     if ($this->blnEnable) {
         NarroUser::RegisterPreference('Cedilla or comma', 'option', 'Select whether you want to see s and t with comma or cedilla undernieth', 'cedilla', array('cedilla', 'comma'));
     }
     /**
      * Preference value: t('cedilla');
      * Preference value: t('comma');
      */
 }
예제 #6
0
 public function btnRegister_Click($strFormId, $strControlId, $strParameter)
 {
     if (!trim($this->txtUsername->Text) || !trim($this->txtPassword->Text)) {
         $this->lblMessage->ForeColor = 'red';
         $this->lblMessage->Text = t("It's just three fields, don't leave one empty please.");
         return false;
     }
     try {
         $objUser = NarroUser::RegisterUser($this->txtUsername->Text, $this->txtEmail->Text, $this->txtPassword->Text, $this->txtRealname->Text);
     } catch (Exception $objEx) {
         $this->lblMessage->ForeColor = 'red';
         $this->lblMessage->Text = t("Seems like the username or email is already in use.") . $objEx->getMessage();
         return false;
     }
     if (!$objUser instanceof NarroUser) {
         QApplication::Redirect(sprintf('login.php?l=%s', QApplication::$TargetLanguage->LanguageCode));
     }
     QApplication::$Session->User = $objUser;
     QApplication::Redirect(NarroLink::UserPreferences($objUser->UserId));
 }
 public function btnRecoverPassword_Click($strFormId, $strControlId, $strParameter)
 {
     if ($this->txtEmail->Text) {
         $objUser = NarroUser::QuerySingle(QQ::Equal(QQN::NarroUser()->Email, $this->txtEmail->Text));
     } elseif ($this->txtUsername->Text) {
         $objUser = NarroUser::QuerySingle(QQ::Equal(QQN::NarroUser()->Username, $this->txtUsername->Text));
     } else {
         $this->lblMessage->ForeColor = 'red';
         $this->lblMessage->Text = t('Please enter a username or email to continue.');
         return false;
     }
     if ($objUser instanceof NarroUser) {
         if ($objUser->UserId == NarroUser::ANONYMOUS_USER_ID) {
             $this->lblMessage->ForeColor = 'red';
             $this->lblMessage->Text = t('Hey, the anonymous user doesn\'t have a password. What are you trying to do?');
             return false;
         }
         $objMessage = new QEmailMessage();
         $objMessage->From = sprintf('%s <%s>', __FROM_EMAIL_NAME__, __FROM_EMAIL_ADDRESS__);
         $objMessage->To = sprintf('%s <%s>', $objUser->Username, $objUser->Email);
         $objMessage->Subject = sprintf('Password recovery for "%s" on "%s"', $objUser->Username, $_SERVER['HTTP_HOST']);
         $objMessage->Body = sprintf('Somebody, probably you, requested a password recovery for "%s" on "%s". To change your password, please follow this link: %s', $objUser->Username, $_SERVER['HTTP_HOST'], (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on' ? 'https://' : 'http://') . $_SERVER['HTTP_HOST'] . __VIRTUAL_DIRECTORY__ . __SUBDIRECTORY__ . sprintf('/change_password.php?l=%s&u=%s&h=%s', QApplication::$TargetLanguage->LanguageCode, $objUser->Username, $objUser->Password));
         try {
             QEmailServer::Send($objMessage);
             $this->lblMessage->ForeColor = 'green';
             $this->lblMessage->Text = t('You should have a new email message with instructions. Check your spam/bulk directory too.');
         } catch (Exception $objEx) {
             $this->lblMessage->ForeColor = 'red';
             $this->lblMessage->Text = t('Failed to send email. This may be a server issue. Please try again later.');
             return false;
         }
     } else {
         $this->lblMessage->ForeColor = 'red';
         $this->lblMessage->Text = t('Bad username or/and email');
     }
 }
예제 #8
0
 public static function GetSoapObjectFromObject($objObject, $blnBindRelatedObjects)
 {
     if ($objObject->objText) {
         $objObject->objText = NarroText::GetSoapObjectFromObject($objObject->objText, false);
     } else {
         if (!$blnBindRelatedObjects) {
             $objObject->intTextId = null;
         }
     }
     if ($objObject->objUser) {
         $objObject->objUser = NarroUser::GetSoapObjectFromObject($objObject->objUser, false);
     } else {
         if (!$blnBindRelatedObjects) {
             $objObject->intUserId = null;
         }
     }
     if ($objObject->objLanguage) {
         $objObject->objLanguage = NarroLanguage::GetSoapObjectFromObject($objObject->objLanguage, false);
     } else {
         if (!$blnBindRelatedObjects) {
             $objObject->intLanguageId = null;
         }
     }
     if ($objObject->dttCreated) {
         $objObject->dttCreated = $objObject->dttCreated->qFormat(QDateTime::FormatSoap);
     }
     if ($objObject->dttModified) {
         $objObject->dttModified = $objObject->dttModified->qFormat(QDateTime::FormatSoap);
     }
     return $objObject;
 }
예제 #9
0
 public static function GetSoapArrayFromArray($objArray)
 {
     if (!$objArray) {
         return null;
     }
     $objArrayToReturn = array();
     foreach ($objArray as $objObject) {
         array_push($objArrayToReturn, NarroUser::GetSoapObjectFromObject($objObject, true));
     }
     return unserialize(serialize($objArrayToReturn));
 }
예제 #10
0
 public static function GetSoapObjectFromObject($objObject, $blnBindRelatedObjects)
 {
     if ($objObject->objUser) {
         $objObject->objUser = NarroUser::GetSoapObjectFromObject($objObject->objUser, false);
     } else {
         if (!$blnBindRelatedObjects) {
             $objObject->intUserId = null;
         }
     }
     if ($objObject->objRole) {
         $objObject->objRole = NarroRole::GetSoapObjectFromObject($objObject->objRole, false);
     } else {
         if (!$blnBindRelatedObjects) {
             $objObject->intRoleId = null;
         }
     }
     if ($objObject->objProject) {
         $objObject->objProject = NarroProject::GetSoapObjectFromObject($objObject->objProject, false);
     } else {
         if (!$blnBindRelatedObjects) {
             $objObject->intProjectId = null;
         }
     }
     if ($objObject->objLanguage) {
         $objObject->objLanguage = NarroLanguage::GetSoapObjectFromObject($objObject->objLanguage, false);
     } else {
         if (!$blnBindRelatedObjects) {
             $objObject->intLanguageId = null;
         }
     }
     return $objObject;
 }
예제 #11
0
 public static function GetSoapObjectFromObject($objObject, $blnBindRelatedObjects)
 {
     if ($objObject->objSuggestion) {
         $objObject->objSuggestion = NarroSuggestion::GetSoapObjectFromObject($objObject->objSuggestion, false);
     } else {
         if (!$blnBindRelatedObjects) {
             $objObject->intSuggestionId = null;
         }
     }
     if ($objObject->objContext) {
         $objObject->objContext = NarroContext::GetSoapObjectFromObject($objObject->objContext, false);
     } else {
         if (!$blnBindRelatedObjects) {
             $objObject->intContextId = null;
         }
     }
     if ($objObject->objUser) {
         $objObject->objUser = NarroUser::GetSoapObjectFromObject($objObject->objUser, false);
     } else {
         if (!$blnBindRelatedObjects) {
             $objObject->intUserId = null;
         }
     }
     if ($objObject->dttCreated) {
         $objObject->dttCreated = $objObject->dttCreated->qFormat(QDateTime::FormatSoap);
     }
     if ($objObject->dttModified) {
         $objObject->dttModified = $objObject->dttModified->qFormat(QDateTime::FormatSoap);
     }
     return $objObject;
 }
예제 #12
0
 public function dtgUser_Bind()
 {
     if ($this->txtSearch->Text != '') {
         $objSearchCondition = QQ::OrCondition(QQ::Like(QQN::NarroUser()->RealName, sprintf('%%%s%%', $this->txtSearch->Text)), QQ::Like(QQN::NarroUser()->Username, sprintf('%%%s%%', $this->txtSearch->Text)), QQ::Like(QQN::NarroUser()->Email, sprintf('%%%s%%', $this->txtSearch->Text)));
     } else {
         $objSearchCondition = QQ::All();
     }
     // Because we want to enable pagination AND sorting, we need to setup the $objClauses array to send to LoadAll()
     // Remember!  We need to first set the TotalItemCount, which will affect the calcuation of LimitClause below
     $this->dtgUser->TotalItemCount = NarroUser::QueryCount($objSearchCondition);
     // Setup the $objClauses Array
     $objClauses = array();
     // If a column is selected to be sorted, and if that column has a OrderByClause set on it, then let's add
     // the OrderByClause to the $objClauses array
     if ($objClause = $this->dtgUser->OrderByClause) {
         array_push($objClauses, $objClause);
     }
     // Add the LimitClause information, as well
     if ($objClause = $this->dtgUser->LimitClause) {
         array_push($objClauses, $objClause);
     }
     // Set the DataSource to be the array of all NarroUser objects, given the clauses above
     $this->dtgUser->DataSource = NarroUser::QueryArray($objSearchCondition, $objClauses);
     QApplication::ExecuteJavaScript('highlight_datagrid();');
 }
 /**
  * Refresh this MetaControl with Data from the local NarroSuggestionVote object.
  * @param boolean $blnReload reload NarroSuggestionVote from the database
  * @return void
  */
 public function Refresh($blnReload = false)
 {
     if ($blnReload) {
         $this->objNarroSuggestionVote->Reload();
     }
     if ($this->lstSuggestion) {
         $this->lstSuggestion->RemoveAllItems();
         if (!$this->blnEditMode) {
             $this->lstSuggestion->AddItem(QApplication::Translate('- Select One -'), null);
         }
         $objSuggestionArray = NarroSuggestion::LoadAll();
         if ($objSuggestionArray) {
             foreach ($objSuggestionArray as $objSuggestion) {
                 $objListItem = new QListItem($objSuggestion->__toString(), $objSuggestion->SuggestionId);
                 if ($this->objNarroSuggestionVote->Suggestion && $this->objNarroSuggestionVote->Suggestion->SuggestionId == $objSuggestion->SuggestionId) {
                     $objListItem->Selected = true;
                 }
                 $this->lstSuggestion->AddItem($objListItem);
             }
         }
     }
     if ($this->lblSuggestionId) {
         $this->lblSuggestionId->Text = $this->objNarroSuggestionVote->Suggestion ? $this->objNarroSuggestionVote->Suggestion->__toString() : null;
     }
     if ($this->lstContext) {
         $this->lstContext->RemoveAllItems();
         if (!$this->blnEditMode) {
             $this->lstContext->AddItem(QApplication::Translate('- Select One -'), null);
         }
         $objContextArray = NarroContext::LoadAll();
         if ($objContextArray) {
             foreach ($objContextArray as $objContext) {
                 $objListItem = new QListItem($objContext->__toString(), $objContext->ContextId);
                 if ($this->objNarroSuggestionVote->Context && $this->objNarroSuggestionVote->Context->ContextId == $objContext->ContextId) {
                     $objListItem->Selected = true;
                 }
                 $this->lstContext->AddItem($objListItem);
             }
         }
     }
     if ($this->lblContextId) {
         $this->lblContextId->Text = $this->objNarroSuggestionVote->Context ? $this->objNarroSuggestionVote->Context->__toString() : null;
     }
     if ($this->lstUser) {
         $this->lstUser->RemoveAllItems();
         if (!$this->blnEditMode) {
             $this->lstUser->AddItem(QApplication::Translate('- Select One -'), null);
         }
         $objUserArray = NarroUser::LoadAll();
         if ($objUserArray) {
             foreach ($objUserArray as $objUser) {
                 $objListItem = new QListItem($objUser->__toString(), $objUser->UserId);
                 if ($this->objNarroSuggestionVote->User && $this->objNarroSuggestionVote->User->UserId == $objUser->UserId) {
                     $objListItem->Selected = true;
                 }
                 $this->lstUser->AddItem($objListItem);
             }
         }
     }
     if ($this->lblUserId) {
         $this->lblUserId->Text = $this->objNarroSuggestionVote->User ? $this->objNarroSuggestionVote->User->__toString() : null;
     }
     if ($this->txtVoteValue) {
         $this->txtVoteValue->Text = $this->objNarroSuggestionVote->VoteValue;
     }
     if ($this->lblVoteValue) {
         $this->lblVoteValue->Text = $this->objNarroSuggestionVote->VoteValue;
     }
     if ($this->calCreated) {
         $this->calCreated->DateTime = $this->objNarroSuggestionVote->Created;
     }
     if ($this->lblCreated) {
         $this->lblCreated->Text = sprintf($this->objNarroSuggestionVote->Created) ? $this->objNarroSuggestionVote->Created->qFormat($this->strCreatedDateTimeFormat) : null;
     }
     if ($this->calModified) {
         $this->calModified->DateTime = $this->objNarroSuggestionVote->Modified;
     }
     if ($this->lblModified) {
         $this->lblModified->Text = sprintf($this->objNarroSuggestionVote->Modified) ? $this->objNarroSuggestionVote->Modified->qFormat($this->strModifiedDateTimeFormat) : null;
     }
 }
예제 #14
0
 public static function RegisterUser($strUsername, $strEmail, $strPassword, $strRealName)
 {
     $objMaxUser = NarroUser::LoadAll(QQ::Clause(QQ::LimitInfo(1, 0), QQ::OrderBy(QQN::NarroUser()->UserId, false)));
     $objUser = new NarroUser();
     $objUser->UserId = $objMaxUser[0]->UserId + 1;
     $objUser->Username = $strUsername;
     if ($strRealName) {
         $objUser->RealName = $strRealName;
     }
     $objUser->Email = $strEmail;
     require_once __NARRO_INCLUDES__ . '/PasswordHash.class.php';
     $objHasher = new PasswordHash(8, FALSE);
     $objUser->Password = $objHasher->HashPassword($strPassword);
     try {
         $objUser->Save();
     } catch (Exception $objEx) {
         throw $objEx;
     }
     /**
      * set up default roles
      */
     $objUserRole = new NarroUserRole();
     if ($objUser->UserId == 1) {
         $objUserRole->RoleId = 5;
     } else {
         $objUserRole->RoleId = 2;
     }
     $objUserRole->UserId = $objUser->UserId;
     $objUserRole->Save();
     return NarroUser::LoadByUsernameAndPassword($strUsername, md5($strPassword));
 }
 /**
  * Refresh this MetaControl with Data from the local NarroUserRole object.
  * @param boolean $blnReload reload NarroUserRole from the database
  * @return void
  */
 public function Refresh($blnReload = false)
 {
     if ($blnReload) {
         $this->objNarroUserRole->Reload();
     }
     if ($this->lblUserRoleId) {
         if ($this->blnEditMode) {
             $this->lblUserRoleId->Text = $this->objNarroUserRole->UserRoleId;
         }
     }
     if ($this->lstUser) {
         $this->lstUser->RemoveAllItems();
         if (!$this->blnEditMode) {
             $this->lstUser->AddItem(QApplication::Translate('- Select One -'), null);
         }
         $objUserArray = NarroUser::LoadAll();
         if ($objUserArray) {
             foreach ($objUserArray as $objUser) {
                 $objListItem = new QListItem($objUser->__toString(), $objUser->UserId);
                 if ($this->objNarroUserRole->User && $this->objNarroUserRole->User->UserId == $objUser->UserId) {
                     $objListItem->Selected = true;
                 }
                 $this->lstUser->AddItem($objListItem);
             }
         }
     }
     if ($this->lblUserId) {
         $this->lblUserId->Text = $this->objNarroUserRole->User ? $this->objNarroUserRole->User->__toString() : null;
     }
     if ($this->lstRole) {
         $this->lstRole->RemoveAllItems();
         if (!$this->blnEditMode) {
             $this->lstRole->AddItem(QApplication::Translate('- Select One -'), null);
         }
         $objRoleArray = NarroRole::LoadAll();
         if ($objRoleArray) {
             foreach ($objRoleArray as $objRole) {
                 $objListItem = new QListItem($objRole->__toString(), $objRole->RoleId);
                 if ($this->objNarroUserRole->Role && $this->objNarroUserRole->Role->RoleId == $objRole->RoleId) {
                     $objListItem->Selected = true;
                 }
                 $this->lstRole->AddItem($objListItem);
             }
         }
     }
     if ($this->lblRoleId) {
         $this->lblRoleId->Text = $this->objNarroUserRole->Role ? $this->objNarroUserRole->Role->__toString() : null;
     }
     if ($this->lstProject) {
         $this->lstProject->RemoveAllItems();
         $this->lstProject->AddItem(QApplication::Translate('- Select One -'), null);
         $objProjectArray = NarroProject::LoadAll();
         if ($objProjectArray) {
             foreach ($objProjectArray as $objProject) {
                 $objListItem = new QListItem($objProject->__toString(), $objProject->ProjectId);
                 if ($this->objNarroUserRole->Project && $this->objNarroUserRole->Project->ProjectId == $objProject->ProjectId) {
                     $objListItem->Selected = true;
                 }
                 $this->lstProject->AddItem($objListItem);
             }
         }
     }
     if ($this->lblProjectId) {
         $this->lblProjectId->Text = $this->objNarroUserRole->Project ? $this->objNarroUserRole->Project->__toString() : null;
     }
     if ($this->lstLanguage) {
         $this->lstLanguage->RemoveAllItems();
         $this->lstLanguage->AddItem(QApplication::Translate('- Select One -'), null);
         $objLanguageArray = NarroLanguage::LoadAll();
         if ($objLanguageArray) {
             foreach ($objLanguageArray as $objLanguage) {
                 $objListItem = new QListItem($objLanguage->__toString(), $objLanguage->LanguageId);
                 if ($this->objNarroUserRole->Language && $this->objNarroUserRole->Language->LanguageId == $objLanguage->LanguageId) {
                     $objListItem->Selected = true;
                 }
                 $this->lstLanguage->AddItem($objListItem);
             }
         }
     }
     if ($this->lblLanguageId) {
         $this->lblLanguageId->Text = $this->objNarroUserRole->Language ? $this->objNarroUserRole->Language->__toString() : null;
     }
 }
예제 #16
0
 public function __set($strName, $mixValue)
 {
     switch ($strName) {
         case "TranslationPath":
             if (file_exists($mixValue)) {
                 $this->strTranslationPath = $mixValue;
             } else {
                 if (!file_exists(dirname($mixValue))) {
                     throw new Exception(sprintf('Cannot create "%s" because the parent directory "%s" does not exist', $mixValue, dirname($mixValue)));
                 }
                 if (!is_writable(dirname($mixValue))) {
                     throw new Exception(sprintf('Cannot create "%s" because the parent directory "%s" is not writable', $mixValue, dirname($mixValue)));
                 }
                 chmod(dirname($mixValue), 0777);
                 if (mkdir($mixValue, 0777, true)) {
                     $this->strTranslationPath = $mixValue;
                 } else {
                     throw new Exception(sprintf(t('TranslationPath "%s" does not exist.'), $mixValue));
                 }
                 NarroUtils::RecursiveChmod($mixValue);
             }
             break;
         case "TemplatePath":
             if (file_exists($mixValue)) {
                 $this->strTemplatePath = $mixValue;
             } else {
                 if (!file_exists(dirname($mixValue))) {
                     throw new Exception(sprintf('Cannot create "%s" because the parent directory "%s" does not exist', $mixValue, dirname($mixValue)));
                 }
                 if (!is_writable(dirname($mixValue))) {
                     throw new Exception(sprintf('Cannot create "%s" because the parent directory "%s" is not writable', $mixValue, dirname($mixValue)));
                 }
                 chmod(dirname($mixValue), 0777);
                 if (mkdir($mixValue, 0777, true)) {
                     $this->strTranslationPath = $mixValue;
                 } else {
                     throw new Exception(sprintf(t('TranslationPath "%s" does not exist.'), $mixValue));
                 }
                 NarroUtils::RecursiveChmod($mixValue);
             }
             break;
         case "User":
             if ($mixValue instanceof NarroUser) {
                 $this->objUser = $mixValue;
             } else {
                 throw new Exception(t('User should be set with an instance of NarroUser'));
             }
             break;
         case "Project":
             if ($mixValue instanceof NarroProject) {
                 $this->objProject = $mixValue;
             } else {
                 throw new Exception(t('Project should be set with an instance of NarroProject'));
             }
             break;
         case "TargetLanguage":
             if ($mixValue instanceof NarroLanguage) {
                 $this->objTargetLanguage = $mixValue;
             } else {
                 throw new Exception(t('TargetLanguage should be set with an instance of NarroLanguage'));
             }
             break;
         case "SourceLanguage":
             if ($mixValue instanceof NarroLanguage) {
                 $this->objSourceLanguage = $mixValue;
             } else {
                 throw new Exception(t('SourceLanguage should be set with an instance of NarroLanguage'));
             }
             break;
         case "Approve":
             try {
                 $this->blnApprove = QType::Cast($mixValue, QType::Boolean);
                 break;
             } catch (QInvalidCastException $objExc) {
                 $objExc->IncrementOffset();
                 throw $objExc;
             }
         case "SkipUntranslated":
             try {
                 $this->blnSkipUntranslated = QType::Cast($mixValue, QType::Boolean);
                 break;
             } catch (QInvalidCastException $objExc) {
                 $objExc->IncrementOffset();
                 throw $objExc;
             }
         case "ApproveAlreadyApproved":
             try {
                 $this->blnApproveAlreadyApproved = QType::Cast($mixValue, QType::Boolean);
                 break;
             } catch (QInvalidCastException $objExc) {
                 $objExc->IncrementOffset();
                 throw $objExc;
             }
         case "CheckEqual":
             try {
                 $this->blnCheckEqual = QType::Cast($mixValue, QType::Boolean);
                 break;
             } catch (QInvalidCastException $objExc) {
                 $objExc->IncrementOffset();
                 throw $objExc;
             }
         case "ImportUnchangedFiles":
             try {
                 $this->blnImportUnchangedFiles = QType::Cast($mixValue, QType::Boolean);
                 break;
             } catch (QInvalidCastException $objExc) {
                 $objExc->IncrementOffset();
                 throw $objExc;
             }
         case "ImportSuggestions":
             try {
                 $this->blnImportSuggestions = QType::Cast($mixValue, QType::Boolean);
                 break;
             } catch (QInvalidCastException $objExc) {
                 $objExc->IncrementOffset();
                 throw $objExc;
             }
         case "CopyUnhandledFiles":
             try {
                 $this->blnCopyUnhandledFiles = QType::Cast($mixValue, QType::Boolean);
                 break;
             } catch (QInvalidCastException $objExc) {
                 $objExc->IncrementOffset();
                 throw $objExc;
             }
         case "OnlySuggestions":
             try {
                 $this->blnOnlySuggestions = QType::Cast($mixValue, QType::Boolean);
                 break;
             } catch (QInvalidCastException $objExc) {
                 $objExc->IncrementOffset();
                 throw $objExc;
             }
         case "ExportedSuggestion":
             try {
                 $this->intExportedSuggestion = QType::Cast($mixValue, QType::Integer);
                 break;
             } catch (QInvalidCastException $objExc) {
                 $objExc->IncrementOffset();
                 throw $objExc;
             }
         case "ExportAuthorList":
             try {
                 if (is_array($mixValue)) {
                     $this->arrExportAuthorList = QType::Cast($mixValue, QType::ArrayType);
                 } else {
                     $arrAuthor = explode(',', $mixValue);
                     foreach ($arrAuthor as $intIdx => $strAuthor) {
                         $arrAuthor[$intIdx] = trim($strAuthor);
                     }
                     foreach (NarroUser::QueryArray(QQ::In(QQN::NarroUser()->RealName, $arrAuthor)) as $objUser) {
                         $this->arrExportAuthorList[] = $objUser->UserId;
                     }
                 }
                 break;
             } catch (QInvalidCastException $objExc) {
                 $objExc->IncrementOffset();
                 throw $objExc;
             }
         default:
             return false;
     }
 }
 /**
  * Refresh this MetaControl with Data from the local NarroTextComment object.
  * @param boolean $blnReload reload NarroTextComment from the database
  * @return void
  */
 public function Refresh($blnReload = false)
 {
     if ($blnReload) {
         $this->objNarroTextComment->Reload();
     }
     if ($this->lblTextCommentId) {
         if ($this->blnEditMode) {
             $this->lblTextCommentId->Text = $this->objNarroTextComment->TextCommentId;
         }
     }
     if ($this->lstText) {
         $this->lstText->RemoveAllItems();
         if (!$this->blnEditMode) {
             $this->lstText->AddItem(QApplication::Translate('- Select One -'), null);
         }
         $objTextArray = NarroText::LoadAll();
         if ($objTextArray) {
             foreach ($objTextArray as $objText) {
                 $objListItem = new QListItem($objText->__toString(), $objText->TextId);
                 if ($this->objNarroTextComment->Text && $this->objNarroTextComment->Text->TextId == $objText->TextId) {
                     $objListItem->Selected = true;
                 }
                 $this->lstText->AddItem($objListItem);
             }
         }
     }
     if ($this->lblTextId) {
         $this->lblTextId->Text = $this->objNarroTextComment->Text ? $this->objNarroTextComment->Text->__toString() : null;
     }
     if ($this->lstUser) {
         $this->lstUser->RemoveAllItems();
         if (!$this->blnEditMode) {
             $this->lstUser->AddItem(QApplication::Translate('- Select One -'), null);
         }
         $objUserArray = NarroUser::LoadAll();
         if ($objUserArray) {
             foreach ($objUserArray as $objUser) {
                 $objListItem = new QListItem($objUser->__toString(), $objUser->UserId);
                 if ($this->objNarroTextComment->User && $this->objNarroTextComment->User->UserId == $objUser->UserId) {
                     $objListItem->Selected = true;
                 }
                 $this->lstUser->AddItem($objListItem);
             }
         }
     }
     if ($this->lblUserId) {
         $this->lblUserId->Text = $this->objNarroTextComment->User ? $this->objNarroTextComment->User->__toString() : null;
     }
     if ($this->lstLanguage) {
         $this->lstLanguage->RemoveAllItems();
         if (!$this->blnEditMode) {
             $this->lstLanguage->AddItem(QApplication::Translate('- Select One -'), null);
         }
         $objLanguageArray = NarroLanguage::LoadAll();
         if ($objLanguageArray) {
             foreach ($objLanguageArray as $objLanguage) {
                 $objListItem = new QListItem($objLanguage->__toString(), $objLanguage->LanguageId);
                 if ($this->objNarroTextComment->Language && $this->objNarroTextComment->Language->LanguageId == $objLanguage->LanguageId) {
                     $objListItem->Selected = true;
                 }
                 $this->lstLanguage->AddItem($objListItem);
             }
         }
     }
     if ($this->lblLanguageId) {
         $this->lblLanguageId->Text = $this->objNarroTextComment->Language ? $this->objNarroTextComment->Language->__toString() : null;
     }
     if ($this->calCreated) {
         $this->calCreated->DateTime = $this->objNarroTextComment->Created;
     }
     if ($this->lblCreated) {
         $this->lblCreated->Text = sprintf($this->objNarroTextComment->Created) ? $this->objNarroTextComment->Created->qFormat($this->strCreatedDateTimeFormat) : null;
     }
     if ($this->calModified) {
         $this->calModified->DateTime = $this->objNarroTextComment->Modified;
     }
     if ($this->lblModified) {
         $this->lblModified->Text = sprintf($this->objNarroTextComment->Modified) ? $this->objNarroTextComment->Modified->qFormat($this->strModifiedDateTimeFormat) : null;
     }
     if ($this->txtCommentText) {
         $this->txtCommentText->Text = $this->objNarroTextComment->CommentText;
     }
     if ($this->lblCommentText) {
         $this->lblCommentText->Text = $this->objNarroTextComment->CommentText;
     }
     if ($this->txtCommentTextMd5) {
         $this->txtCommentTextMd5->Text = $this->objNarroTextComment->CommentTextMd5;
     }
     if ($this->lblCommentTextMd5) {
         $this->lblCommentTextMd5->Text = $this->objNarroTextComment->CommentTextMd5;
     }
 }
예제 #18
0
 /**
  * Default / simple DataBinder for this Meta DataGrid.  This can easily be overridden
  * by calling SetDataBinder() on this DataGrid with another DataBinder of your choice.
  *
  * If a paginator is set on this DataBinder, it will use it.  If not, then no pagination will be used.
  * It will also perform any sorting (if applicable).
  */
 public function MetaDataBinder()
 {
     $objConditions = $this->Conditions;
     if (null !== $this->conAdditionalConditions) {
         $objConditions = QQ::AndCondition($this->conAdditionalConditions, $objConditions);
     }
     // Setup the $objClauses Array
     $objClauses = array();
     if (null !== $this->clsAdditionalClauses) {
         $objClauses = $this->clsAdditionalClauses;
     }
     // Remember!  We need to first set the TotalItemCount, which will affect the calcuation of LimitClause below
     if ($this->Paginator) {
         $this->TotalItemCount = NarroUser::QueryCount($objConditions);
     }
     // If a column is selected to be sorted, and if that column has a OrderByClause set on it, then let's add
     // the OrderByClause to the $objClauses array
     if ($objClause = $this->OrderByClause) {
         array_push($objClauses, $objClause);
     }
     // Add the LimitClause information, as well
     if ($objClause = $this->LimitClause) {
         array_push($objClauses, $objClause);
     }
     // Set the DataSource to be a Query result from NarroUser, given the clauses above
     $this->DataSource = NarroUser::QueryArray($objConditions, $objClauses);
 }
예제 #19
0
 public static function GetSoapObjectFromObject($objObject, $blnBindRelatedObjects)
 {
     if ($objObject->objLanguage) {
         $objObject->objLanguage = NarroLanguage::GetSoapObjectFromObject($objObject->objLanguage, false);
     } else {
         if (!$blnBindRelatedObjects) {
             $objObject->intLanguageId = null;
         }
     }
     if ($objObject->objProject) {
         $objObject->objProject = NarroProject::GetSoapObjectFromObject($objObject->objProject, false);
     } else {
         if (!$blnBindRelatedObjects) {
             $objObject->intProjectId = null;
         }
     }
     if ($objObject->objUser) {
         $objObject->objUser = NarroUser::GetSoapObjectFromObject($objObject->objUser, false);
     } else {
         if (!$blnBindRelatedObjects) {
             $objObject->intUserId = null;
         }
     }
     if ($objObject->dttDate) {
         $objObject->dttDate = $objObject->dttDate->qFormat(QDateTime::FormatSoap);
     }
     return $objObject;
 }
 * http://code.google.com/p/narro/
 *
 * This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public
 * License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any
 * later version.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the
 * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
 * more details.
 *
 * You should have received a copy of the GNU General Public License along with this program; if not, write to the
 * Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
 */
require_once dirname(__FILE__) . '/configuration/prepend.inc.php';
if (QApplication::HasPermission('Administrator')) {
    foreach (NarroUser::LoadAll() as $objUser) {
        $arrUserPermissions = array();
        foreach (NarroUserPermission::LoadArrayByUserId($objUser->UserId) as $objUserPermission) {
            $objUserRole = new NarroUserRole();
            switch ($objUserPermission->PermissionId) {
                case 1:
                case 2:
                case 4:
                    $objUserRole->RoleId = 2;
                    break;
                case 3:
                    $objUserRole->RoleId = 3;
                    break;
                case 5:
                case 6:
                case 8:
예제 #21
0
 public function btnBrowserIdLogin_Click($strFormId, $strControlId, $strAssertion)
 {
     // open connection
     $ch = curl_init();
     // set the url, number of POST vars, POST data
     curl_setopt($ch, CURLOPT_URL, 'https://browserid.org/verify');
     curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
     curl_setopt($ch, CURLOPT_POST, 2);
     curl_setopt($ch, CURLOPT_POSTFIELDS, sprintf('assertion=%s&audience=%s', $strAssertion, __HTTP_URL__));
     // execute post
     $result = json_decode(curl_exec($ch));
     // close connection
     curl_close($ch);
     if ($result && property_exists($result, 'status') && $result->status == 'okay') {
         $objUser = NarroUser::LoadByUsername($result->email);
         if (!$objUser instanceof NarroUser) {
             try {
                 $objUser = NarroUser::RegisterUser($result->email, $result->email, '', $result->email);
             } catch (Exception $objEx) {
                 $this->lblMessage->ForeColor = 'red';
                 $this->lblMessage->Text = sprintf(t('Failed to create an associated user for the email address "%s": %s'), $result->email, $objEx->getMessage());
                 return false;
             }
             $objUser->Reload();
             QApplication::$Session->User = $objUser;
             QApplication::Redirect(NarroLink::UserPreferences($objUser->UserId));
             exit;
         } elseif ($objUser->Password != $objHasher->HashPassword('')) {
             $this->lblMessage->ForeColor = 'red';
             $this->lblMessage->Text = t('This user has a password set, please login with that instead');
             return false;
         }
         QApplication::$Session->RegenerateId();
         QApplication::$Session->User = $objUser;
         QApplication::$User = $objUser;
         if ($this->txtPreviousUrl) {
             $strUrl = preg_replace('/([\\?\\&]l\\=)[a-z0-9\\-\\_]+/', '\\1' . QApplication::$User->GetPreferenceValueByName('Language'), $this->txtPreviousUrl);
             if ($strUrl) {
                 QApplication::Redirect($strUrl);
             } else {
                 QApplication::Redirect($this->txtPreviousUrl);
             }
         } else {
             QApplication::Redirect(NarroLink::ProjectList(null, null, QApplication::$User->GetPreferenceValueByName('Language')));
         }
         exit;
     } else {
         $this->lblMessage->Text = t('BrowserID login failed');
         $this->lblMessage->ForeColor = 'red';
     }
 }
 /**
  * Refresh this MetaControl with Data from the local NarroSuggestion object.
  * @param boolean $blnReload reload NarroSuggestion from the database
  * @return void
  */
 public function Refresh($blnReload = false)
 {
     if ($blnReload) {
         $this->objNarroSuggestion->Reload();
     }
     if ($this->lblSuggestionId) {
         if ($this->blnEditMode) {
             $this->lblSuggestionId->Text = $this->objNarroSuggestion->SuggestionId;
         }
     }
     if ($this->lstUser) {
         $this->lstUser->RemoveAllItems();
         $this->lstUser->AddItem(QApplication::Translate('- Select One -'), null);
         $objUserArray = NarroUser::LoadAll();
         if ($objUserArray) {
             foreach ($objUserArray as $objUser) {
                 $objListItem = new QListItem($objUser->__toString(), $objUser->UserId);
                 if ($this->objNarroSuggestion->User && $this->objNarroSuggestion->User->UserId == $objUser->UserId) {
                     $objListItem->Selected = true;
                 }
                 $this->lstUser->AddItem($objListItem);
             }
         }
     }
     if ($this->lblUserId) {
         $this->lblUserId->Text = $this->objNarroSuggestion->User ? $this->objNarroSuggestion->User->__toString() : null;
     }
     if ($this->lstText) {
         $this->lstText->RemoveAllItems();
         if (!$this->blnEditMode) {
             $this->lstText->AddItem(QApplication::Translate('- Select One -'), null);
         }
         $objTextArray = NarroText::LoadAll();
         if ($objTextArray) {
             foreach ($objTextArray as $objText) {
                 $objListItem = new QListItem($objText->__toString(), $objText->TextId);
                 if ($this->objNarroSuggestion->Text && $this->objNarroSuggestion->Text->TextId == $objText->TextId) {
                     $objListItem->Selected = true;
                 }
                 $this->lstText->AddItem($objListItem);
             }
         }
     }
     if ($this->lblTextId) {
         $this->lblTextId->Text = $this->objNarroSuggestion->Text ? $this->objNarroSuggestion->Text->__toString() : null;
     }
     if ($this->lstLanguage) {
         $this->lstLanguage->RemoveAllItems();
         if (!$this->blnEditMode) {
             $this->lstLanguage->AddItem(QApplication::Translate('- Select One -'), null);
         }
         $objLanguageArray = NarroLanguage::LoadAll();
         if ($objLanguageArray) {
             foreach ($objLanguageArray as $objLanguage) {
                 $objListItem = new QListItem($objLanguage->__toString(), $objLanguage->LanguageId);
                 if ($this->objNarroSuggestion->Language && $this->objNarroSuggestion->Language->LanguageId == $objLanguage->LanguageId) {
                     $objListItem->Selected = true;
                 }
                 $this->lstLanguage->AddItem($objListItem);
             }
         }
     }
     if ($this->lblLanguageId) {
         $this->lblLanguageId->Text = $this->objNarroSuggestion->Language ? $this->objNarroSuggestion->Language->__toString() : null;
     }
     if ($this->txtSuggestionValue) {
         $this->txtSuggestionValue->Text = $this->objNarroSuggestion->SuggestionValue;
     }
     if ($this->lblSuggestionValue) {
         $this->lblSuggestionValue->Text = $this->objNarroSuggestion->SuggestionValue;
     }
     if ($this->txtSuggestionValueMd5) {
         $this->txtSuggestionValueMd5->Text = $this->objNarroSuggestion->SuggestionValueMd5;
     }
     if ($this->lblSuggestionValueMd5) {
         $this->lblSuggestionValueMd5->Text = $this->objNarroSuggestion->SuggestionValueMd5;
     }
     if ($this->txtSuggestionCharCount) {
         $this->txtSuggestionCharCount->Text = $this->objNarroSuggestion->SuggestionCharCount;
     }
     if ($this->lblSuggestionCharCount) {
         $this->lblSuggestionCharCount->Text = $this->objNarroSuggestion->SuggestionCharCount;
     }
     if ($this->txtSuggestionWordCount) {
         $this->txtSuggestionWordCount->Text = $this->objNarroSuggestion->SuggestionWordCount;
     }
     if ($this->lblSuggestionWordCount) {
         $this->lblSuggestionWordCount->Text = $this->objNarroSuggestion->SuggestionWordCount;
     }
     if ($this->chkHasComments) {
         $this->chkHasComments->Checked = $this->objNarroSuggestion->HasComments;
     }
     if ($this->lblHasComments) {
         $this->lblHasComments->Text = $this->objNarroSuggestion->HasComments ? QApplication::Translate('Yes') : QApplication::Translate('No');
     }
     if ($this->chkIsImported) {
         $this->chkIsImported->Checked = $this->objNarroSuggestion->IsImported;
     }
     if ($this->lblIsImported) {
         $this->lblIsImported->Text = $this->objNarroSuggestion->IsImported ? QApplication::Translate('Yes') : QApplication::Translate('No');
     }
     if ($this->calCreated) {
         $this->calCreated->DateTime = $this->objNarroSuggestion->Created;
     }
     if ($this->lblCreated) {
         $this->lblCreated->Text = sprintf($this->objNarroSuggestion->Created) ? $this->objNarroSuggestion->Created->qFormat($this->strCreatedDateTimeFormat) : null;
     }
     if ($this->calModified) {
         $this->calModified->DateTime = $this->objNarroSuggestion->Modified;
     }
     if ($this->lblModified) {
         $this->lblModified->Text = sprintf($this->objNarroSuggestion->Modified) ? $this->objNarroSuggestion->Modified->qFormat($this->strModifiedDateTimeFormat) : null;
     }
 }
예제 #23
0
    ///////////////////////
    // Setup Error Handling
    ///////////////////////
    if (array_key_exists('SERVER_PROTOCOL', $_SERVER)) {
        set_error_handler('QcodoHandleError', error_reporting());
        set_exception_handler('QcodoHandleException');
    }
    spl_autoload_register(array('QApplication', 'Autoload'));
    QApplication::Initialize();
    QApplication::InitializeDatabaseConnections();
    QApplication::$EncodingType = 'UTF-8';
    NarroUser::GetDatabase()->NonQuery("SET NAMES 'utf8'");
    NarroUser::RegisterPreference('Items per page', 'number', t('How many items are displayed per page'), 10);
    NarroUser::RegisterPreference('Font size', 'option', t('The application font size'), 'medium', array('x-small', 'small', 'medium', 'large', 'x-large'));
    NarroUser::RegisterPreference('Language', 'option', t('The language you are translating to'), QApplication::QueryString('l'), array(QApplication::QueryString('l')));
    NarroUser::RegisterPreference('Application language', 'option', t('The language you want to see Narro in'), isset(QApplication::$TargetLanguage) ? QApplication::$TargetLanguage->LanguageCode : NarroLanguage::SOURCE_LANGUAGE_CODE, array(isset(QApplication::$TargetLanguage) ? QApplication::$TargetLanguage->LanguageCode : NarroLanguage::SOURCE_LANGUAGE_CODE));
    NarroUser::RegisterPreference('Special characters', 'text', t('Characters that are not on your keyboard, separated by spaces'), '$€');
    NarroUser::RegisterPreference('Automatically save translations', 'option', t('Save translations when moving to the next text to translate'), 'No', array('Yes', 'No'));
    NarroUser::RegisterPreference('Launch imports and exports in background', 'option', t('Launch imports and exports in background'), 'Yes', array('Yes', 'No'));
    NarroUser::RegisterPreference('Load more texts while scrolling', 'option', t('Whether to load more content if you reach the bottom of the page'), 'No', array('Yes', 'No'));
    if (!isset($argv)) {
        QApplication::SessionOverride();
        QApplication::InitializeSession();
    }
    QApplication::InitializeUser();
    QApplication::InitializeLanguage();
    NarroProject::RegisterPreference('Export translators and reviewers in the file header as a comment', false, 0, 'option', '', 'No', array('Yes', 'No'));
    QApplication::InitializeLogging();
    QApplication::InitializeTranslationEngine();
    QApplication::$PluginHandler = new NarroPluginHandler(dirname(__FILE__) . '/../includes/narro/plugins');
}
예제 #24
0
 /**
  * Static Helper Method to Create using PK arguments
  * You must pass in the PK arguments on an object to load, or leave it blank to create a new one.
  * If you want to load via QueryString or PathInfo, use the CreateFromQueryString or CreateFromPathInfo
  * static helper methods.  Finally, specify a CreateType to define whether or not we are only allowed to
  * edit, or if we are also allowed to create a new one, etc.
  *
  * @param mixed $objParentObject QForm or QPanel which will be using this NarroUserMetaControl
  * @param integer $intUserId primary key value
  * @param QMetaControlCreateType $intCreateType rules governing NarroUser object creation - defaults to CreateOrEdit
  * @return NarroUserMetaControl
  */
 public static function Create($objParentObject, $intUserId = null, $intCreateType = QMetaControlCreateType::CreateOrEdit)
 {
     // Attempt to Load from PK Arguments
     if (strlen($intUserId)) {
         $objNarroUser = NarroUser::Load($intUserId);
         // NarroUser was found -- return it!
         if ($objNarroUser) {
             return new NarroUserMetaControl($objParentObject, $objNarroUser);
         } else {
             if ($intCreateType != QMetaControlCreateType::CreateOnRecordNotFound) {
                 throw new QCallerException('Could not find a NarroUser object with PK arguments: ' . $intUserId);
             }
         }
         // If EditOnly is specified, throw an exception
     } else {
         if ($intCreateType == QMetaControlCreateType::EditOnly) {
             throw new QCallerException('No PK arguments specified');
         }
     }
     // If we are here, then we need to create a new record
     return new NarroUserMetaControl($objParentObject, new NarroUser());
 }
예제 #25
0
파일: narro-cli.php 프로젝트: Jobava/narro
 }
 if (array_search('--template-lang', $argv) !== false) {
     $strSourceLanguage = $argv[array_search('--template-lang', $argv) + 1];
 } else {
     $strSourceLanguage = NarroLanguage::SOURCE_LANGUAGE_CODE;
 }
 if (array_search('--translation-lang', $argv) !== false) {
     $strTargetLanguage = $argv[array_search('--translation-lang', $argv) + 1];
 }
 if (array_search('--user', $argv) !== false) {
     $intUserId = $argv[array_search('--user', $argv) + 1];
 }
 $objUser = NarroUser::LoadByUserId($intUserId);
 if (!$objUser instanceof NarroUser) {
     NarroLogger::LogInfo(sprintf('User id=%s does not exist in the database, will try to use the anonymous user.', $intUserId));
     $objUser = NarroUser::LoadAnonymousUser();
     if (!$objUser instanceof NarroUser) {
         NarroLogger::LogInfo(sprintf('The anonymous user id=%s does not exist in the database.', $intUserId));
         return false;
     }
 }
 QApplication::$User = $objUser;
 $objProject = NarroProject::Load($intProjectId);
 if (!$objProject instanceof NarroProject) {
     NarroLogger::LogInfo(sprintf('Project with id=%s does not exist in the database.', $intProjectId));
     return false;
 }
 $objLanguage = NarroLanguage::LoadByLanguageCode($strTargetLanguage);
 if (!$objLanguage instanceof NarroLanguage) {
     NarroLogger::LogInfo(sprintf('Language %s does not exist in the database.', $strTargetLanguage));
     return false;
 /**
  * Refresh this MetaControl with Data from the local NarroContextInfo object.
  * @param boolean $blnReload reload NarroContextInfo from the database
  * @return void
  */
 public function Refresh($blnReload = false)
 {
     if ($blnReload) {
         $this->objNarroContextInfo->Reload();
     }
     if ($this->lblContextInfoId) {
         if ($this->blnEditMode) {
             $this->lblContextInfoId->Text = $this->objNarroContextInfo->ContextInfoId;
         }
     }
     if ($this->lstContext) {
         $this->lstContext->RemoveAllItems();
         if (!$this->blnEditMode) {
             $this->lstContext->AddItem(QApplication::Translate('- Select One -'), null);
         }
         $objContextArray = NarroContext::LoadAll();
         if ($objContextArray) {
             foreach ($objContextArray as $objContext) {
                 $objListItem = new QListItem($objContext->__toString(), $objContext->ContextId);
                 if ($this->objNarroContextInfo->Context && $this->objNarroContextInfo->Context->ContextId == $objContext->ContextId) {
                     $objListItem->Selected = true;
                 }
                 $this->lstContext->AddItem($objListItem);
             }
         }
     }
     if ($this->lblContextId) {
         $this->lblContextId->Text = $this->objNarroContextInfo->Context ? $this->objNarroContextInfo->Context->__toString() : null;
     }
     if ($this->lstLanguage) {
         $this->lstLanguage->RemoveAllItems();
         if (!$this->blnEditMode) {
             $this->lstLanguage->AddItem(QApplication::Translate('- Select One -'), null);
         }
         $objLanguageArray = NarroLanguage::LoadAll();
         if ($objLanguageArray) {
             foreach ($objLanguageArray as $objLanguage) {
                 $objListItem = new QListItem($objLanguage->__toString(), $objLanguage->LanguageId);
                 if ($this->objNarroContextInfo->Language && $this->objNarroContextInfo->Language->LanguageId == $objLanguage->LanguageId) {
                     $objListItem->Selected = true;
                 }
                 $this->lstLanguage->AddItem($objListItem);
             }
         }
     }
     if ($this->lblLanguageId) {
         $this->lblLanguageId->Text = $this->objNarroContextInfo->Language ? $this->objNarroContextInfo->Language->__toString() : null;
     }
     if ($this->lstValidatorUser) {
         $this->lstValidatorUser->RemoveAllItems();
         $this->lstValidatorUser->AddItem(QApplication::Translate('- Select One -'), null);
         $objValidatorUserArray = NarroUser::LoadAll();
         if ($objValidatorUserArray) {
             foreach ($objValidatorUserArray as $objValidatorUser) {
                 $objListItem = new QListItem($objValidatorUser->__toString(), $objValidatorUser->UserId);
                 if ($this->objNarroContextInfo->ValidatorUser && $this->objNarroContextInfo->ValidatorUser->UserId == $objValidatorUser->UserId) {
                     $objListItem->Selected = true;
                 }
                 $this->lstValidatorUser->AddItem($objListItem);
             }
         }
     }
     if ($this->lblValidatorUserId) {
         $this->lblValidatorUserId->Text = $this->objNarroContextInfo->ValidatorUser ? $this->objNarroContextInfo->ValidatorUser->__toString() : null;
     }
     if ($this->lstValidSuggestion) {
         $this->lstValidSuggestion->RemoveAllItems();
         $this->lstValidSuggestion->AddItem(QApplication::Translate('- Select One -'), null);
         $objValidSuggestionArray = NarroSuggestion::LoadAll();
         if ($objValidSuggestionArray) {
             foreach ($objValidSuggestionArray as $objValidSuggestion) {
                 $objListItem = new QListItem($objValidSuggestion->__toString(), $objValidSuggestion->SuggestionId);
                 if ($this->objNarroContextInfo->ValidSuggestion && $this->objNarroContextInfo->ValidSuggestion->SuggestionId == $objValidSuggestion->SuggestionId) {
                     $objListItem->Selected = true;
                 }
                 $this->lstValidSuggestion->AddItem($objListItem);
             }
         }
     }
     if ($this->lblValidSuggestionId) {
         $this->lblValidSuggestionId->Text = $this->objNarroContextInfo->ValidSuggestion ? $this->objNarroContextInfo->ValidSuggestion->__toString() : null;
     }
     if ($this->chkHasSuggestions) {
         $this->chkHasSuggestions->Checked = $this->objNarroContextInfo->HasSuggestions;
     }
     if ($this->lblHasSuggestions) {
         $this->lblHasSuggestions->Text = $this->objNarroContextInfo->HasSuggestions ? QApplication::Translate('Yes') : QApplication::Translate('No');
     }
     if ($this->txtSuggestionAccessKey) {
         $this->txtSuggestionAccessKey->Text = $this->objNarroContextInfo->SuggestionAccessKey;
     }
     if ($this->lblSuggestionAccessKey) {
         $this->lblSuggestionAccessKey->Text = $this->objNarroContextInfo->SuggestionAccessKey;
     }
     if ($this->txtSuggestionCommandKey) {
         $this->txtSuggestionCommandKey->Text = $this->objNarroContextInfo->SuggestionCommandKey;
     }
     if ($this->lblSuggestionCommandKey) {
         $this->lblSuggestionCommandKey->Text = $this->objNarroContextInfo->SuggestionCommandKey;
     }
     if ($this->calCreated) {
         $this->calCreated->DateTime = $this->objNarroContextInfo->Created;
     }
     if ($this->lblCreated) {
         $this->lblCreated->Text = sprintf($this->objNarroContextInfo->Created) ? $this->objNarroContextInfo->Created->qFormat($this->strCreatedDateTimeFormat) : null;
     }
     if ($this->calModified) {
         $this->calModified->DateTime = $this->objNarroContextInfo->Modified;
     }
     if ($this->lblModified) {
         $this->lblModified->Text = sprintf($this->objNarroContextInfo->Modified) ? $this->objNarroContextInfo->Modified->qFormat($this->strModifiedDateTimeFormat) : null;
     }
 }
예제 #27
0
 /**
  * Refresh this MetaControl with Data from the local NarroLog object.
  * @param boolean $blnReload reload NarroLog from the database
  * @return void
  */
 public function Refresh($blnReload = false)
 {
     if ($blnReload) {
         $this->objNarroLog->Reload();
     }
     if ($this->lblLogId) {
         if ($this->blnEditMode) {
             $this->lblLogId->Text = $this->objNarroLog->LogId;
         }
     }
     if ($this->lstLanguage) {
         $this->lstLanguage->RemoveAllItems();
         $this->lstLanguage->AddItem(QApplication::Translate('- Select One -'), null);
         $objLanguageArray = NarroLanguage::LoadAll();
         if ($objLanguageArray) {
             foreach ($objLanguageArray as $objLanguage) {
                 $objListItem = new QListItem($objLanguage->__toString(), $objLanguage->LanguageId);
                 if ($this->objNarroLog->Language && $this->objNarroLog->Language->LanguageId == $objLanguage->LanguageId) {
                     $objListItem->Selected = true;
                 }
                 $this->lstLanguage->AddItem($objListItem);
             }
         }
     }
     if ($this->lblLanguageId) {
         $this->lblLanguageId->Text = $this->objNarroLog->Language ? $this->objNarroLog->Language->__toString() : null;
     }
     if ($this->lstProject) {
         $this->lstProject->RemoveAllItems();
         $this->lstProject->AddItem(QApplication::Translate('- Select One -'), null);
         $objProjectArray = NarroProject::LoadAll();
         if ($objProjectArray) {
             foreach ($objProjectArray as $objProject) {
                 $objListItem = new QListItem($objProject->__toString(), $objProject->ProjectId);
                 if ($this->objNarroLog->Project && $this->objNarroLog->Project->ProjectId == $objProject->ProjectId) {
                     $objListItem->Selected = true;
                 }
                 $this->lstProject->AddItem($objListItem);
             }
         }
     }
     if ($this->lblProjectId) {
         $this->lblProjectId->Text = $this->objNarroLog->Project ? $this->objNarroLog->Project->__toString() : null;
     }
     if ($this->lstUser) {
         $this->lstUser->RemoveAllItems();
         $this->lstUser->AddItem(QApplication::Translate('- Select One -'), null);
         $objUserArray = NarroUser::LoadAll();
         if ($objUserArray) {
             foreach ($objUserArray as $objUser) {
                 $objListItem = new QListItem($objUser->__toString(), $objUser->UserId);
                 if ($this->objNarroLog->User && $this->objNarroLog->User->UserId == $objUser->UserId) {
                     $objListItem->Selected = true;
                 }
                 $this->lstUser->AddItem($objListItem);
             }
         }
     }
     if ($this->lblUserId) {
         $this->lblUserId->Text = $this->objNarroLog->User ? $this->objNarroLog->User->__toString() : null;
     }
     if ($this->txtMessage) {
         $this->txtMessage->Text = $this->objNarroLog->Message;
     }
     if ($this->lblMessage) {
         $this->lblMessage->Text = $this->objNarroLog->Message;
     }
     if ($this->txtPriority) {
         $this->txtPriority->Text = $this->objNarroLog->Priority;
     }
     if ($this->lblPriority) {
         $this->lblPriority->Text = $this->objNarroLog->Priority;
     }
     if ($this->calDate) {
         $this->calDate->DateTime = $this->objNarroLog->Date;
     }
     if ($this->lblDate) {
         $this->lblDate->Text = sprintf($this->objNarroLog->Date) ? $this->objNarroLog->Date->qFormat($this->strDateDateTimeFormat) : null;
     }
 }
예제 #28
0
 /**
  * This Form_Validate event handler allows you to specify any custom Form Validation rules.
  * It will also Blink() on all invalid controls, as well as Focus() on the top-most invalid control.
  */
 protected function Form_Validate()
 {
     // By default, we report the result of validation from the parent
     $blnToReturn = parent::Form_Validate();
     // Custom Validation Rules
     // TODO: Be sure to set $blnToReturn to false if any custom validation fails!
     // Check for records that may violate Unique Clauses
     if (($objNarroUser = NarroUser::LoadByUsername($this->txtUsername->Text)) && $objNarroUser->UserId != $this->mctNarroUser->NarroUser->UserId) {
         $blnToReturn = false;
         $this->txtUsername->Warning = QApplication::Translate("Already in Use");
     }
     if (($objNarroUser = NarroUser::LoadByEmail($this->txtEmail->Text)) && $objNarroUser->UserId != $this->mctNarroUser->NarroUser->UserId) {
         $blnToReturn = false;
         $this->txtEmail->Warning = QApplication::Translate("Already in Use");
     }
     if (($objNarroUser = NarroUser::LoadByRealName($this->txtRealName->Text)) && $objNarroUser->UserId != $this->mctNarroUser->NarroUser->UserId) {
         $blnToReturn = false;
         $this->txtRealName->Warning = QApplication::Translate("Already in Use");
     }
     $blnFocused = false;
     foreach ($this->GetErrorControls() as $objControl) {
         // Set Focus to the top-most invalid control
         if (!$blnFocused) {
             $objControl->Focus();
             $blnFocused = true;
         }
         // Blink on ALL invalid controls
         $objControl->Blink();
     }
     return $blnToReturn;
 }