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();');
 }
 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;
     }
 }
Exemple #3
0
 /**
  * Load all NarroUsers
  * @param QQClause[] $objOptionalClauses additional optional QQClause objects for this query
  * @return NarroUser[]
  */
 public static function LoadAll($objOptionalClauses = null)
 {
     if (func_num_args() > 1) {
         throw new QCallerException("LoadAll must be called with an array of optional clauses as a single argument");
     }
     // Call NarroUser::QueryArray to perform the LoadAll query
     try {
         return NarroUser::QueryArray(QQ::All(), $objOptionalClauses);
     } catch (QCallerException $objExc) {
         $objExc->IncrementOffset();
         throw $objExc;
     }
 }
 /**
  * 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);
 }