fetchByComponentUserId() public static method

Получение настроек для компонента, и пользователя.
public static fetchByComponentUserId ( Component $component, integer $user_id ) : static
$component skeeks\cms\base\Component компонент с настройками
$user_id integer id пользователя
return static
Ejemplo n.º 1
0
 /**
  * @inheritdoc
  */
 public function getDataCellValue($model, $key, $index)
 {
     $settings = null;
     if ($this->component === null) {
         return $this->_result(Cms::BOOL_N);
     }
     if ($model instanceof CmsSite) {
         $settings = \skeeks\cms\models\CmsComponentSettings::fetchByComponentSiteCode($this->component, $model->code);
     }
     if ($model instanceof User) {
         $settings = \skeeks\cms\models\CmsComponentSettings::fetchByComponentUserId($this->component, $model->id);
     }
     if ($settings) {
         return $this->_result(Cms::BOOL_Y);
     }
     return $this->_result(Cms::BOOL_N);
 }
Ejemplo n.º 2
0
 /**
  * Настройки для пользователя
  * @param (int) $site_code
  * @return array
  */
 public function fetchDefaultSettingsByUserId($user_id)
 {
     $settings = CmsComponentSettings::fetchByComponentUserId($this, (int) $user_id);
     if (!$settings) {
         return [];
     }
     return (array) $settings->value;
 }
Ejemplo n.º 3
0
Archivo: user.php Proyecto: Liv1020/cms
<?php 
echo $this->render('_header', ['component' => $component]);
?>


    <h2><?php 
echo \Yii::t('app', 'User settings');
?>
: <?php 
echo $user->getDisplayName();
?>
</h2>
    <div class="sx-box sx-mb-10 sx-p-10">
        <?php 
if ($settings = \skeeks\cms\models\CmsComponentSettings::fetchByComponentUserId($component, $user->id)) {
    ?>
            <button type="submit" class="btn btn-danger btn-xs" onclick="sx.ComponentSettings.Remove.removeByUser('<?php 
    echo $user->id;
    ?>
'); return false;">
                <i class="glyphicon glyphicon-remove"></i> <?php 
    echo \Yii::t('app', 'Reset settings for this user');
    ?>
            </button>
            <small><?php 
    echo \Yii::t('app', 'The settings for this component are stored in the database. This option will erase them from the database, but the component, restore the default values. As they have in the code the developer.');
    ?>
</small>
        <?php 
} else {