示例#1
0
 public static function loadSiteProfile($name)
 {
     global $config;
     $settings = SiteProfile::getSettings($name);
     $config = array_replace_recursive($config, $settings);
 }
示例#2
0
 public function getProfile()
 {
     if (class_exists('SiteProfile')) {
         return SiteProfile::findByUId($this->getId());
     }
     return null;
 }
示例#3
0
<?php

//-- SiteProfile:Clear cache
if ($command == "cc") {
    if ($arg1 == "all" || $arg1 == "siteuser_profile") {
        echo " - Drop table 'site_profile' ";
        echo SiteProfile::dropTable() ? "success\n" : "fail\n";
    }
}
//-- SiteProfile:Import DB
if ($command == "import" && $arg1 == "db" && (is_null($arg2) || $arg2 == "site_profile")) {
    //- create tables if not exits
    echo " - Create table 'site_profile' ";
    echo SiteProfile::createTableIfNotExist() ? "success\n" : "fail\n";
}
示例#4
0
    static function renderCreateFormFrontend(MySiteUser $user = null, $action = '')
    {
        // set default action value
        if ($action != '') {
            $action = uri($action);
        }
        // get vars from form submission
        $username = isset($_POST['username']) ? strip_tags($_POST['username']) : (isset($user) ? $user->getUsername() : '');
        $email = isset($_POST['email']) ? strip_tags($_POST['email']) : (isset($user) ? $user->getEmail() : '');
        $password = '';
        $password_confirm = '';
        if ($user && $user->getId() == MySiteUser::getCurrentUser()->getId()) {
            // when updating self profile, we don't include 'active'
            $active_field = '';
        } else {
            $active = isset($_POST['active']) ? strip_tags($_POST['active']) : (isset($user) ? $user->getActive() . "" : false);
            $active_field = '
  <div class="form-group" id="form-field-active">
    <label class="col-sm-2 control-label" for="active">' . i18n(array('en' => 'Active', 'zh' => '是否在职')) . '</label>
    <div class="col-sm-10">
      <select class="form-control" name="active" id="active">
        <option value="1" ' . ($active && $active == "1" ? 'selected=selected' : '') . '>在职</option>
        <option value="0" ' . ($active && $active == "0" ? 'selected=selected' : '') . '>离职</option>
      </select>
    </div>
  </div>
  <div class="hr-line-dashed"></div>';
        }
        $mandatory_label = ' <span style="color: rgb(185,2,0); font-weight: bold;">*</span>';
        $roles_form_markup = '<div id="form-field-roles"><label class="col-sm-2 control-label">Roles</label><div class="col-sm-10"><ul class="checkbox">';
        foreach (SiteRole::findAll() as $role) {
            $roles_form_markup .= '<li><label><input type="checkbox" name="roles[' . $role->getid() . ']" value=1 ' . (isset($_POST['roles']) ? isset($_POST['roles'][$role->getId()]) ? 'checked="checked"' : '' : ($user && $user->hasRole($role->getName()) ? 'checked="checked"' : '')) . ' />' . $role->getName() . '</label></li>';
        }
        $roles_form_markup .= '</ul></div></div>';
        $rtn = '
<form class="form-horizontal" action="' . $action . '" method="POST" enctype="multipart/form-data">
  <div class="form-group" id="form-field-email" >
    <label class="col-sm-2 control-label" for="email">' . i18n(array('en' => 'Email', 'zh' => '电子邮箱')) . $mandatory_label . '</label>
    <div class="col-sm-10">
      <input type="email" class="form-control" id="email" name="email" value="' . $email . '" required />
    </div>
  </div>
  <div class="hr-line-dashed"></div>
  <div class="form-group" id="form-field-password">
    <label class="col-sm-2 control-label" for="password">' . i18n(array('en' => 'Password', 'zh' => '密码')) . $mandatory_label . ' </label>
    <div class="col-sm-10">
      <input type="password" class="form-control" id="password" name="password" value="' . $password . '" required />
      <span class="help-block m-b-none"><small>(' . i18n(array('en' => 'at least 6 letters', 'zh' => '至少6位')) . ')</small></span>
    </div>
  </div>
  <div class="form-group" id="form-field-password_confirm">
    <label class="col-sm-2 control-label" for="password_confirm">' . i18n(array('en' => 'Password again', 'zh' => '再次确认密码')) . $mandatory_label . '</label>
    <div class="col-sm-10">
      <input type="password" class="form-control" id="password_confirm" name="password_confirm" value="' . $password_confirm . '" required />
    </div>
  </div>
  <div class="hr-line-dashed"></div>
  ' . (class_exists('SiteProfile') ? SiteProfile::renderUpdateForm($user) : '') . '
  <div class="hr-line-dashed"></div>
' . $active_field . '
  <input type="hidden" value=1 name="noemailnotification" />
  ' . (is_backend() ? $roles_form_markup : '') . '
  <div class="form-group" id="form-field-notice">
    <div class="col-sm-10 col-sm-push-2">
      <small><i>
    ' . $mandatory_label . i18n(array('en' => ' indicates mandatory fields', 'zh' => ' 标记为必填项')) . '
      </i></small>
    </div>
  </div>
  <div class="col-sm-10 col-sm-push-2">
    <button type="submit" name="submit" class="btn btn-primary">' . (is_null($user) ? i18n(array('en' => 'Add new user', 'zh' => '添加新用户')) : i18n(array('en' => 'Update user', 'zh' => '更新用户'))) . '</button>
  </div>
  
</form>
';
        return $rtn;
    }
示例#5
0
<?php

$profile = $user->getProfile();
if (is_null($profile)) {
    $profile = new SiteProfile();
    $profile->setUserId($user->getId());
}
$profile->setNickname($nickname);
if ($avatar && $avatar['error'] == UPLOAD_ERR_OK) {
    load_library_wide_image();
    $image = WideImage::load($avatar['tmp_name']);
    $image = $image->resize($settings['profile']['avatar_width'], $settings['profile']['avatar_height']);
    $white = $image->allocateColor(255, 255, 255);
    $image = $image->resizeCanvas($settings['profile']['avatar_width'], $settings['profile']['avatar_height'], 'center', 'center', $white);
    $image->saveToFile(AVATAR_DIR . '/' . $user->getUsername() . '.jpg', 80);
    $profile->setThumbnail($user->getUsername() . '.jpg');
    @unlink($avatar['tmp_name']);
}
$profile->save();