Example #1
0
 private static function Log($strMessage, $intPriority, $intProjectId = null, $intLanguageId = null, $intUserId = null)
 {
     if (SERVER_INSTANCE != 'dev' && $intPriority == NarroLog::PRIORITY_DEBUG) {
         return true;
     }
     $objLogEntry = new NarroLog();
     $objLogEntry->Date = QDateTime::Now();
     $objLogEntry->Priority = $intPriority;
     $objLogEntry->Message = $strMessage;
     $objLogEntry->ProjectId = is_null($intProjectId) ? is_null(self::$intProjectId) ? null : self::$intProjectId : $intProjectId;
     $objLogEntry->LanguageId = is_null($intLanguageId) ? is_null(self::$intLanguageId) ? null : self::$intLanguageId : $intLanguageId;
     $objLogEntry->UserId = is_null($intUserId) ? is_null(self::$intUserId) ? null : self::$intUserId : $intUserId;
     try {
         $objLogEntry->Save();
     } catch (Exception $objEx) {
         error_log($objEx->getMessage() . $objEx->getTraceAsString());
     }
     if (QFirebug::getEnabled()) {
         switch ($intPriority) {
             case NarroLog::PRIORITY_INFO:
                 QFirebug::info($objLogEntry->Message . ' / ' . $objLogEntry->UserId . ' / ' . $objLogEntry->ProjectId . ' / ' . $objLogEntry->LanguageId);
                 break;
             case NarroLog::PRIORITY_WARN:
                 QFirebug::warn($objLogEntry->Message . ' / ' . $objLogEntry->UserId . ' / ' . $objLogEntry->ProjectId . ' / ' . $objLogEntry->LanguageId);
                 break;
             case NarroLog::PRIORITY_ERROR:
                 QFirebug::error($objLogEntry->Message . ' / ' . $objLogEntry->UserId . ' / ' . $objLogEntry->ProjectId . ' / ' . $objLogEntry->LanguageId);
                 break;
             default:
                 QFirebug::log($objLogEntry->Message . ' / ' . $objLogEntry->UserId . ' / ' . $objLogEntry->ProjectId . ' / ' . $objLogEntry->LanguageId);
         }
     }
 }
 public function GetControlHtml()
 {
     $strLogContents = '';
     foreach (NarroLog::QueryArray(QQ::AndCondition(QQ::Equal(QQN::NarroLog()->ProjectId, $this->intProjectId), QQ::Equal(QQN::NarroLog()->LanguageId, $this->intLanguageId), QQ::GreaterThan(QQN::NarroLog()->Date, $this->dttStart))) as $objLogEntry) {
         switch ($objLogEntry->Priority) {
             case NarroLog::PRIORITY_INFO:
                 $strLogContents .= '<div class="info"';
                 break;
             case NarroLog::PRIORITY_WARN:
                 $strLogContents .= '<div class="warning"';
                 break;
             case NarroLog::PRIORITY_ERROR:
                 $strLogContents .= '<div class="error"';
                 break;
             default:
                 $strLogContents .= '<div';
         }
         $strLogContents .= sprintf('title="%s">%s</div>', $objLogEntry->Date, nl2br(NarroString::HtmlEntities($objLogEntry->Message)));
     }
     $this->strText = sprintf('<div class="ui-accordion ui-widget ui-helper-reset ui-accordion-icons">
             <h3 class="ui-accordion-header ui-helper-reset ui-state-default ui-state-active ui-corner-top">
             <span class="ui-icon ui-icon-triangle-1-s"></span>
             <a>%s</a>
             </h3>
             <div class="ui-accordion-content ui-helper-reset ui-widget-content ui-corner-bottom ui-accordion-content-active" style="max-height:300px;overflow:auto">
             %s
             </div>
             </div>', t('Operation log'), $strLogContents);
     return parent::GetControlHtml();
 }
 /**
  * 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 NarroLogMetaControl
  * @param integer $intLogId primary key value
  * @param QMetaControlCreateType $intCreateType rules governing NarroLog object creation - defaults to CreateOrEdit
  * @return NarroLogMetaControl
  */
 public static function Create($objParentObject, $intLogId = null, $intCreateType = QMetaControlCreateType::CreateOrEdit)
 {
     // Attempt to Load from PK Arguments
     if (strlen($intLogId)) {
         $objNarroLog = NarroLog::Load($intLogId);
         // NarroLog was found -- return it!
         if ($objNarroLog) {
             return new NarroLogMetaControl($objParentObject, $objNarroLog);
         } else {
             if ($intCreateType != QMetaControlCreateType::CreateOnRecordNotFound) {
                 throw new QCallerException('Could not find a NarroLog object with PK arguments: ' . $intLogId);
             }
         }
         // 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 NarroLogMetaControl($objParentObject, new NarroLog());
 }
Example #4
0
File: log.php Project: Jobava/narro
 public function btnClearLog_Click($strFormId, $strControlId, $strParameter)
 {
     if (QApplication::HasPermissionForThisLang('Administrator')) {
         if (QApplication::HasPermission('Administrator')) {
             NarroLog::GetDatabase()->NonQuery(sprintf('DELETE FROM narro_log'));
         } else {
             NarroLog::GetDatabase()->NonQuery(sprintf('DELETE FROM narro_log WHERE language_id=%d', QApplication::GetLanguageId()));
         }
         $this->dtgLog->btnFilterReset_Click($strFormId, $strControlId, $strParameter);
         $this->dtgLog->Refresh();
     }
 }
Example #5
0
 public static function GetSoapArrayFromArray($objArray)
 {
     if (!$objArray) {
         return null;
     }
     $objArrayToReturn = array();
     foreach ($objArray as $objObject) {
         array_push($objArrayToReturn, NarroLog::GetSoapObjectFromObject($objObject, true));
     }
     return unserialize(serialize($objArrayToReturn));
 }
Example #6
0
 /**
  * Counts all associated NarroLogsAsUser
  * @return int
  */
 public function CountNarroLogsAsUser()
 {
     if (is_null($this->intUserId)) {
         return 0;
     }
     return NarroLog::CountByUserId($this->intUserId);
 }
Example #7
0
 * 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 (!isset($argv)) {
    exit;
}
QFirebug::setEnabled(false);
if (array_search('--help', $argv) !== false) {
    echo sprintf("php %s [options]\n" . "--user                       user id that will be used for the added translations\n" . "--project                    project id instead of importing all projects\n" . "--language                   language code instead of importing all languages\n" . "--disable-plugins            disable plugins during import/export\n" . "--do-not-clear-logs          doesn't clear the logs before starting\n" . "                             suggestions, optional, defaults to anonymous\n" . "--do-not-check-equal         don't check if the translation is equal to the original\n" . "                             text and don't import it\n" . "--skip-untranslated          skip likes that don't have translated texts\n" . "--approve                    approve the imported suggestions\n" . "--approve-already-approved   overwrite translations approved in Narro\n" . "--import-unchanged-files     import files marked unchanged after the last import\n" . "--only-suggestions           import only suggestions, don't add files, texts\n" . "                             or contexts\n" . "--no-suggestions             do not import suggestions\n", basename(__FILE__), NarroLanguage::SOURCE_LANGUAGE_CODE);
    exit;
}
$intProjCnt = NarroProject::CountByActive(1);
$intLangCnt = NarroLanguage::CountAllActive();
if (!in_array('--do-not-clear-logs', $argv)) {
    NarroLog::Truncate();
}
$intStartTime = time();
foreach (NarroProject::LoadArrayByActive(1) as $intProjIdx => $objProject) {
    if (in_array('--project', $argv) && $objProject->ProjectId != $argv[array_search('--project', $argv) + 1]) {
        continue;
    }
    foreach (NarroLanguage::LoadAllActive() as $intLangIdx => $objLanguage) {
        if (in_array('--language', $argv) && $objLanguage->LanguageCode != $argv[array_search('--language', $argv) + 1]) {
            continue;
        }
        if (in_array('--progress', $argv)) {
            $strProjectProgress = '';
            for ($i = 1; $i < 11; $i++) {
                if ($intProjIdx * 10 / $intProjCnt <= $i) {
                    $strProjectProgress .= '-';
Example #8
0
 /**
  * Counts all associated NarroLogsAsLanguage
  * @return int
  */
 public function CountNarroLogsAsLanguage()
 {
     if (is_null($this->intLanguageId)) {
         return 0;
     }
     return NarroLog::CountByLanguageId($this->intLanguageId);
 }
 /**
  * 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 = NarroLog::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 NarroLog, given the clauses above
     $this->DataSource = NarroLog::QueryArray($objConditions, $objClauses);
 }
Example #10
0
 /**
  * Counts all associated NarroLogsAsProject
  * @return int
  */
 public function CountNarroLogsAsProject()
 {
     if (is_null($this->intProjectId)) {
         return 0;
     }
     return NarroLog::CountByProjectId($this->intProjectId);
 }