Esempio n. 1
0
 public static function send($toEmail, $subject, $template, $data = [], $options = [])
 {
     if (!filter_var($toEmail, FILTER_VALIDATE_EMAIL) || !$subject || !$template) {
         return false;
     }
     $data['subject'] = trim($subject);
     $message = Yii::$app->mailer->compose($template, $data)->setTo($toEmail)->setSubject($data['subject']);
     if (filter_var(Preferences::get('sEmail', 'username'), FILTER_VALIDATE_EMAIL)) {
         $message->setFrom(Preferences::get('sEmail', 'username'));
     }
     if (!empty($options['replyTo']) && filter_var($options['replyTo'], FILTER_VALIDATE_EMAIL)) {
         $message->setReplyTo($options['replyTo']);
     }
     return $message->send();
 }
Esempio n. 2
0
 /**
  * (返回更新的记录数) userPowerUpdate :
  * @param $currentUID   integer 当前登录的用户ID
  * @param $setUID       integer 需要设置单位权限的用户ID
  * @param $permission   integer 单位权限级别
  * @param $unitcode     string  单位编码
  * @param int $type             更新类型
  * @return 返回更新的记录数
  * @throws \yii\db\Exception
  */
 private function userPowerUpdate($currentUID, $setUID, $permission, $unitcode, $type = self::UPDATE_SELF)
 {
     /** @var $result 返回更新的记录数*/
     $result = 0;
     /** @var $adminRole string 在Preferences中配置,classmark:sSystem */
     $adminRole = Preferences::get('sSystem', 'adminRole');
     //超级管理员
     /** @var $role \yii\rbac\Role[] 当前用户角色数组*/
     $role = Yii::$app->authManager->getRolesByUser(Yii::$app->user->identity->id);
     /** @var $is_admin boolean 是否为超级管理员*/
     $is_admin = array_key_exists($adminRole, $role);
     $unitlist = $unitcode;
     switch ($type) {
         case self::UPDATE_CHILDLIST:
             $unitlist = Unit::getChildList($unitcode);
             break;
         case self::UPDATE_PARENTLIST:
             $unitlist = Unit::getParentList($unitcode);
             break;
     }
     $SQL = "REPLACE INTO `map_unit`(`user_id`, `unitcode`, `user_power`) " . " SELECT {$setUID}, cur_mu.unitcode, CASE WHEN cur_mu.user_power >= :user_power THEN :user_power ELSE cur_mu.user_power END FROM " . " (SELECT unitcode, user_power FROM `map_unit` WHERE `user_id` = :currentUID AND FIND_IN_SET(unitcode,:unitlist)) cur_mu " . " LEFT JOIN (SELECT unitcode, user_power FROM `map_unit` WHERE `user_id` = :setUID ) set_mu ON (cur_mu.unitcode = set_mu.unitcode) " . " WHERE (set_mu.user_power <= cur_mu.user_power and set_mu.user_power <> :user_power or set_mu.user_power IS NULL)";
     //超级管理员
     if ($is_admin) {
         $SQL = "REPLACE INTO `map_unit`(`user_id`, `unitcode`, `user_power`) " . " SELECT {$setUID}, u.unitcode, {$permission} FROM " . " (SELECT unitcode FROM `unit` WHERE FIND_IN_SET(unitcode,:unitlist)) u " . " LEFT JOIN (SELECT unitcode, user_power FROM `map_unit` WHERE `user_id` = :setUID ) set_mu ON (u.unitcode = set_mu.unitcode) " . " WHERE :currentUID > 0 and (set_mu.user_power <> :user_power or set_mu.user_power IS NULL)";
     }
     $result = Yii::$app->db->createCommand($SQL)->bindValues([':currentUID' => $currentUID, ':user_power' => $permission, ':unitlist' => $unitlist, ':setUID' => $setUID])->execute();
     if ($permission == MapUnit::USER_POWER_DENY) {
         //清除禁止访问的
         MapUnit::deleteAll(['user_power' => MapUnit::USER_POWER_DENY]);
     }
     return $result;
 }
Esempio n. 3
0
 /**
  * Lists all Unit models.
  * @return mixed
  */
 public function actionIndex()
 {
     return $this->render('index', ['iSearchColNum' => Preferences::get('tSearch', 'colnum')]);
 }
Esempio n. 4
0
 /**
  * (返回更新的记录数) userPowerUpdate :
  * @param $currentUID   integer 当前登录的用户ID
  * @param $setUID       integer 需要设置单位权限的用户ID
  * @param $permission   integer 字段权限级别
  * @param $id           string  格式:gdjs.pbc_tnam.pbc_cnam
  * @return 返回更新的记录数
  * @throws \yii\db\Exception
  */
 private function userPowerUpdate($currentUID, $setUID, $permission, $id)
 {
     /** @var $result 返回更新的记录数*/
     $result = 0;
     /** @var array $pbc_data [ 0 => 'gdjs', 1 => pbc_tnam, 2 => pbc_cnam ] */
     $pbc_data = explode('.', $id);
     //校验格式,格式不对,返回 0
     if ($pbc_data[0] != 'gdjs' || count($pbc_data) != 3) {
         return $result;
     }
     /** @var string $pbc_tnam 表名 */
     $pbc_tnam = $pbc_data[1];
     /** @var string $pbc_cnam 字段名 */
     $pbc_cnam = $pbc_data[2];
     /** @var $adminRole string 在Preferences中配置,classmark:sSystem */
     $adminRole = Preferences::get('sSystem', 'adminRole');
     //超级管理员
     /** @var $role \yii\rbac\Role[] 当前用户角色数组*/
     $role = Yii::$app->authManager->getRolesByUser(Yii::$app->user->identity->id);
     /** @var $is_admin boolean 是否为超级管理员*/
     $is_admin = array_key_exists($adminRole, $role);
     $SQL = "REPLACE INTO `map_field`(`user_id`, `pbc_tnam`, `pbc_cnam`, `user_power`) " . " SELECT :setUID, :pbc_tnam, :pbc_cnam, :user_power FROM `map_field` " . " WHERE (SELECT COUNT(1) FROM `map_field` WHERE " . " `user_id`=:currentUID AND `pbc_tnam`=:pbc_tnam AND `pbc_cnam`=:pbc_cnam) <= 0 LIMIT 1";
     //超级管理员
     if ($is_admin) {
         $SQL = "REPLACE INTO `map_field`(`user_id`, `pbc_tnam`, `pbc_cnam`, `user_power`) " . " SELECT :setUID, :pbc_tnam, :pbc_cnam, :user_power FROM `map_field` " . " WHERE :currentUID > 0 LIMIT 1";
     }
     $result = Yii::$app->db->createCommand($SQL)->bindValues([':currentUID' => $currentUID, ':setUID' => $setUID, ':pbc_tnam' => $pbc_tnam, ':pbc_cnam' => $pbc_cnam, ':user_power' => $permission])->execute();
     if ($permission == MapField::USER_POWER_ALLOW) {
         //清除完全访问的
         MapField::deleteAll(['user_power' => MapField::USER_POWER_ALLOW]);
     }
     return $result;
 }
Esempio n. 5
0
 * ----------------------------------------------
 * @date: 16-7-1 下午4:16
 * @author: LocoRoco<*****@*****.**>
 * @version:v2016
 * @since:Yii2
 * ----------------------------------------------
 * 程序文件简介:
 * ==============================================
 */
/**
 * @var \mdm\admin\models\User $user 当前用户
 * @var string $avatar 用户头像地址
 */
$user_avatar = \common\populac\models\Preferences::get('sSystem', 'backendUrl') . '/uploads/user/default/user2-160x160.jpg';
if ($avatar) {
    $user_avatar = \common\populac\models\Preferences::get('sSystem', 'backendUrl') . '/uploads/user/avatar/' . $avatar;
}
$this->title = '修改用户头像';
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="box box-primary">
    <div class="box-body">
        <div class="row">
            <div class="col-md-3">
                <?php 
echo $this->render('@common/views/user/settings/_menu');
?>
            </div>
            <div class="col-md-9">
                <div class="panel panel-info">
                    <div class="panel-heading">
Esempio n. 6
0
 public function notifyUser()
 {
     $settings = Yii::$app->getModule('populac')->activeModules['guestbook']->settings;
     return Mail::send($this->email, $settings['subjectNotifyUser'], $settings['templateNotifyUser'], ['post' => $this, 'link' => str_replace(Preferences::get('sSystem', 'backendUrl'), '', Url::to([$settings['frontendGuestbookRoute']], true))]);
 }
Esempio n. 7
0
        if (!$model->new_value) {
            return '';
        }
        $new = explode(',', str_replace(['[', ']', '"'], ['', '', ''], $model->new_value));
        $field = explode(',', str_replace(['[', ']', '"'], ['', '', ''], $model->field));
        $rawModel = new $model->model();
        $table = $rawModel->tableName();
        $display = [];
        foreach ($new as $i => $line) {
            if (in_array($field[$i], ['created_at', 'updated_at', 'created_by', 'updated_by'])) {
                continue;
            }
            $classmark = '';
            $value = '';
            $classmark = \common\populac\models\ColTable::getClassmark($table, $field[$i]);
            $value = \common\populac\models\Preferences::get($classmark, $line);
            $line = $value ? $value : $line;
            $line = '<span class="bg-info text-success">' . $line . '</span>';
            $display[] = $line;
        }
        return '<h4>' . implode('<br>', $display) . '</h4>';
    }, 'contentOptions' => ['width' => '20%'], 'format' => 'raw'];
}
if (empty($columns) || in_array('diff', $columns)) {
    $_columns[] = ['label' => Yii::t('audit', 'Diff'), 'value' => function ($model) {
        /** @var AuditTrail $model */
        return $model->getDiffHtml();
    }, 'format' => 'raw'];
}
if (empty($columns) || in_array('created', $columns)) {
    $_columns[] = ['attribute' => 'created', 'contentOptions' => ['class' => 'text-center', 'style' => ['vertical-align' => 'middle']]];