Example #1
0
 public function setUp()
 {
     SugarTestHelper::setUp('beanList');
     SugarTestHelper::setUp('beanFiles');
     SugarTestHelper::setUp('current_user', array(true, 1));
     SugarTestHelper::setUp('mod_strings', array($this->name));
     $this->user = $GLOBALS['current_user'];
     $this->user->setPreference('datef', 'm/d/Y');
     $this->user->setPreference('timef', 'h:ia');
     $this->user->setPreference('timezone', 'UTC');
 }
Example #2
0
 public function testFormatFieldInSugarFieldRelate()
 {
     global $current_user;
     $current_user = new User();
     $current_user->retrieve('1');
     $current_user->setPreference('default_locale_name_format', 'l f s');
     $sugar_field_relate = new SugarFieldRelate('Relate');
     $new_field = $sugar_field_relate->formatField('Max Liang', array('name' => 'contact_name'));
     $this->assertEquals(trim($new_field), trim('Liang Max'), "Assert that name format is correct");
     $current_user->setPreference('default_locale_name_format', 'f l s');
     $sugar_field_relate = new SugarFieldRelate('Relate');
     $new_field = $sugar_field_relate->formatField('Max Liang', array('name' => 'contact_name'));
     $this->assertEquals(trim($new_field), trim('Max Liang'), "Assert that name format is correct");
 }
 protected function createUser($userData)
 {
     $user = new User();
     $user->user_name = $userData['email'];
     $user->email = $userData['email'];
     $user->email1 = $userData['email'];
     $user->first_name = $userData['first_name'];
     $user->last_name = $userData['last_name'];
     $user->status = 'Active';
     $user->is_admin = 0;
     $user->external_auth_only = 1;
     $user->system_generated_password = 0;
     $user->authenticate_id = $userData['remote_id'];
     $user->receive_notifications = 0;
     if (!empty($userData['photo'])) {
         $picid = create_guid();
         if (copy($userData['photo'], "upload://{$picid}")) {
             $user->picture = $picid;
         }
     }
     $user->id = 'rmt-' . md5($userData['remote_id']);
     $user->new_with_id = true;
     $user->save();
     $user->setPreference('ut', 1);
     $user->savePreferencesToDB();
     return $user->id;
 }
Example #4
0
 protected function setUp()
 {
     parent::setUp();
     SugarTestHelper::init();
     SugarTestHelper::setUp('current_user');
     $this->currentUser = $GLOBALS['current_user'];
     $this->currentUser->setPreference('default_number_grouping_seperator', '.');
     $this->currentUser->setPreference('default_decimal_seperator', ',');
     $sugarChartObject = new SugarChart();
     $sugarChartObject->group_by = array('sales_stage', 'user_name');
     $sugarChartObject->data_set = $this->getDataSet();
     $sugarChartObject->base_url = array('module' => 'Opportunities', 'action' => 'index', 'query' => 'true', 'searchFormTab' => 'advanced_search');
     $sugarChartObject->url_params = array();
     $sugarChartObject->is_currency = true;
     // we have 5 users
     $sugarChartObject->super_set = array('will', 'max', 'sarah', 'sally', 'chris');
     $this->sugarChartObject = $sugarChartObject;
 }
Example #5
0
 /**
  *  Create a user in the seed data.
  */
 function _create_seed_user($id, $last_name, $first_name, $user_name, $title, $is_admin, $reports_to, $reports_to_name, $email)
 {
     $u = new User();
     $u->id = $id;
     $u->new_with_id = true;
     $u->last_name = $last_name;
     $u->first_name = $first_name;
     $u->user_name = $user_name;
     $u->title = $title;
     $u->status = 'Active';
     $u->employee_status = 'Active';
     $u->is_admin = $is_admin;
     $u->is_group = 0;
     //$u->user_password = $u->encrypt_password($user_name);
     $u->user_hash = User::getPasswordHash($user_name);
     $u->reports_to_id = $reports_to;
     $u->reports_to_name = $reports_to_name;
     //$u->email1 = $email;
     $u->emailAddress->addAddress($email, true);
     $u->emailAddress->addAddress("reply." . $email, false, true);
     $u->emailAddress->addAddress("alias." . $email);
     // bug 15371 tyoung set a user preference so that Users/DetailView.php can find something without repeatedly querying the db in vain
     $u->setPreference('max_tabs', '7');
     $u->savePreferencesToDB();
     $u->picture = $this->_copy_user_image($id);
     $u->save();
     if ($id == "seed_jim_id") {
         // add to Sales Administrator Role
         $acl_roles = new ACLRole();
         $arrRoles = $acl_roles->getAllRoles(true);
         foreach ($arrRoles as $role) {
             if ($role['name'] == "Sales Administrator") {
                 $u->load_relationship('aclroles');
                 $u->aclroles->add($role['id']);
                 // re-save user manually. otherwise the relation to role set will not be saved
                 // because One2MBeanRelationship::add() doesn't call SugarRelationship::addToResaveList()
                 // in workflow and during installation
                 $u->save();
                 break;
             }
         }
     }
 }
Example #6
0
    private static function upgradeUserPreferences()
    {
        $users = User::getActiveUsers();
        foreach ($users as $user_id => $user_name) {
            $user = new User();
            $user->retrieve($user_id);

            $preferencePopupReminderTime = $user->getPreference('reminder_time');
            $preferenceEmailReminderTime = $user->getPreference('email_reminder_time');

            $preferencePopupReminderChecked = $preferencePopupReminderTime > -1;
            $preferenceEmailReminderChecked = $preferenceEmailReminderTime > -1;
            $user->setPreference('reminder_checked', $preferencePopupReminderChecked);
            $user->setPreference('email_reminder_checked', $preferenceEmailReminderChecked);

        }
    }
Example #7
0
 /**
  * Toggle the preference.
  * Should not be called directly unless you know what you do
  *
  * @param User   $current_user The user
  * @param string $id           the id of the toggler
  */
 public static function togglePreference(User $current_user, $id)
 {
     $current_user->setPreference('toggle_' . $id, 1 - (int) $current_user->getPreference('toggle_' . $id));
 }
Example #8
0
    installLog('DBG: save currency');
    $currency->save();
}
installLog('Save user settings..');
//      <------------------------------------------------
//          from UsersController->action_saveuserwizard()
//          ---------------------------------------------------------->
// set all of these default parameters since the Users save action will undo the defaults otherwise
// load admin
$current_user = new User();
$current_user->retrieve(1);
$current_user->is_admin = '1';
$sugar_config = get_sugar_config_defaults();
// set local settings -  if neccessary you can set here more fields as named in User module / EditView form...
if (isset($_REQUEST['timezone']) && $_REQUEST['timezone']) {
    $current_user->setPreference('timezone', $_REQUEST['timezone']);
}
//$_POST[''] = $_REQUEST['default_locale_name_format'];
$_POST['dateformat'] = $_REQUEST['default_date_format'];
//$_POST[''] = $_REQUEST['default_time_format'];
//$_POST[''] = $_REQUEST['default_language'];
//$_POST[''] = $_REQUEST['default_currency_name'];
//$_POST[''] = $_REQUEST['default_currency_symbol'];
//$_POST[''] = $_REQUEST['default_currency_iso4217'];
//$_POST[''] = $_REQUEST['setup_site_session_path'];
//$_POST[''] = $_REQUEST['setup_site_log_dir'];
//$_POST[''] = $_REQUEST['setup_site_guid'];
//$_POST[''] = $_REQUEST['default_email_charset'];
//$_POST[''] = $_REQUEST['default_export_charset'];
//$_POST[''] = $_REQUEST['export_delimiter'];
$_POST['record'] = $current_user->id;
Example #9
0
 $focus->portal_only = 0;
 if (isset($_POST['sugar_user_name'])) {
     $focus->user_name = $_POST['sugar_user_name'];
 }
 if (isset($_POST['is_admin']) && ($_POST['is_admin'] == 'on' || $_POST['is_admin'] == '1')) {
     $focus->is_admin = 1;
 } elseif (empty($_POST['is_admin'])) {
     $focus->is_admin = 0;
 }
 //if(empty($_POST['portal_only']) || !empty($_POST['is_admin'])) $focus->portal_only = 0;
 //if(empty($_POST['is_group'])    || !empty($_POST['is_admin'])) $focus->is_group = 0;
 if (empty($_POST['receive_notifications'])) {
     $focus->receive_notifications = 0;
 }
 if (isset($_POST['mailmerge_on']) && !empty($_POST['mailmerge_on'])) {
     $focus->setPreference('mailmerge_on', 'on', 0, 'global', $focus);
 } else {
     $focus->setPreference('mailmerge_on', 'off', 0, 'global', $focus);
 }
 if (isset($_POST['user_max_tabs'])) {
     $focus->setPreference('max_tabs', $_POST['user_max_tabs'], 0, 'global', $focus);
 }
 if (isset($_POST['user_max_subtabs'])) {
     $focus->setPreference('max_subtabs', $_POST['user_max_subtabs'], 0, 'global', $focus);
 }
 if (isset($_POST['user_swap_last_viewed'])) {
     $focus->setPreference('swap_last_viewed', $_POST['user_swap_last_viewed'], 0, 'global', $focus);
 } else {
     $focus->setPreference('swap_last_viewed', '', 0, 'global', $focus);
 }
 if (isset($_POST['user_swap_shortcuts'])) {
Example #10
0
/**
 * Creates a new Group User
 * @param string $name Name of Group User
 * @return string GUID of new Group User
 */
function createGroupUser($name)
{
    $group = new User();
    $group->user_name = $name;
    $group->last_name = $name;
    $group->is_group = 1;
    $group->deleted = 0;
    $group->status = 'Active';
    // cn: bug 6711
    $group->setPreference('timezone', TimeDate::userTimezone());
    $group->save();
    return $group->id;
}
Example #11
0
function update_iframe_dashlets()
{
    require_once sugar_cached('dashlets/dashlets.php');
    $db = DBManagerFactory::getInstance();
    $query = "SELECT id, contents, assigned_user_id FROM user_preferences WHERE deleted = 0 AND category = 'Home'";
    $result = $db->query($query, true, "Unable to update new default dashlets! ");
    while ($row = $db->fetchByAssoc($result)) {
        $content = unserialize(base64_decode($row['contents']));
        $assigned_user_id = $row['assigned_user_id'];
        $record_id = $row['id'];
        $current_user = new User();
        $current_user->retrieve($row['assigned_user_id']);
        if (!empty($content['dashlets']) && !empty($content['pages'])) {
            $originalDashlets = $content['dashlets'];
            foreach ($originalDashlets as $key => $ds) {
                if (!empty($ds['options']['url']) && stristr($ds['options']['url'], 'http://www.sugarcrm.com/crm/product/gopro')) {
                    unset($originalDashlets[$key]);
                }
            }
            $current_user->setPreference('dashlets', $originalDashlets, 0, 'Home');
        }
    }
}
Example #12
0
 $focus->portal_only = 0;
 if (isset($_POST['sugar_user_name'])) {
     $focus->user_name = $_POST['sugar_user_name'];
 }
 if (isset($_POST['is_admin']) && ($_POST['is_admin'] == 'on' || $_POST['is_admin'] == '1')) {
     $focus->is_admin = 1;
 } elseif (empty($_POST['is_admin'])) {
     $focus->is_admin = 0;
 }
 //if(empty($_POST['portal_only']) || !empty($_POST['is_admin'])) $focus->portal_only = 0;
 //if(empty($_POST['is_group'])    || !empty($_POST['is_admin'])) $focus->is_group = 0;
 if (empty($_POST['receive_notifications'])) {
     $focus->receive_notifications = 0;
 }
 if (isset($_POST['mailmerge_on']) && !empty($_POST['mailmerge_on'])) {
     $focus->setPreference('mailmerge_on', 'on', 0, 'global');
 } else {
     $focus->setPreference('mailmerge_on', 'off', 0, 'global');
 }
 if (isset($_POST['user_max_tabs'])) {
     $current_theme_max_tabs = SugarThemeRegistry::current()->maxTabs;
     if (empty($current_theme_max_tabs) || $_POST['user_max_tabs'] <= SugarThemeRegistry::current()->maxTabs) {
         $focus->setPreference('max_tabs', $_POST['user_max_tabs'], 0, 'global');
     }
 }
 if (isset($_POST['user_swap_last_viewed'])) {
     $focus->setPreference('swap_last_viewed', $_POST['user_swap_last_viewed'], 0, 'global');
 } else {
     $focus->setPreference('swap_last_viewed', '', 0, 'global');
 }
 if (isset($_POST['user_swap_shortcuts'])) {
Example #13
0
 public function testDeprecatedUserPreferenceInterface()
 {
     User::setPreference('deprecated_pref', 'dog', 0, 'global', $this->_user);
     $this->assertEquals('dog', User::getPreference('deprecated_pref', 'global', $this->_user));
 }
Example #14
0
 protected function tearDown()
 {
     $this->currentUser->setPreference(self::DEFAULT_EXPORT_CHARSET_PREF_NAME, $this->defaultExportCharset);
     SugarTestHelper::tearDown();
     SugarTestOpportunityUtilities::removeAllCreatedOpportunities();
 }
Example #15
0
////    CREATE MAILBOX QUEUE
////////////////////////////////////////////////////////////////////////////////
if (isset($_REQUEST['group_id']) && $_REQUEST['group_id'] == 'new') {
    if ($uid = $focus->groupUserDupeCheck()) {
        $focus->group_id = $uid;
    } else {
        require_once 'modules/Users/User.php';
        $group = new User();
        $group->user_name = $focus->name;
        $group->last_name = $focus->name;
        $group->is_group = 1;
        $group->deleted = 0;
        $group->status = 'Active';
        // cn: bug 6711
        $timezone = lookupTimezone();
        $group->setPreference('timezone', $timezone);
        $group->save();
        $focus->group_id = $group->id;
    }
} elseif (!empty($_REQUEST['group_id']) && $_REQUEST['group_id'] != 'new') {
    $focus->group_id = $_REQUEST['group_id'];
}
////////////////////////////////////////////////////////////////////////////////
////    SEND US TO SAVE DESTINATION
////////////////////////////////////////////////////////////////////////////////
//_ppd($focus);
$focus->save();
$_REQUEST['return_id'] = $focus->id;
$edit = '';
if (isset($_REQUEST['return_module']) && $_REQUEST['return_module'] != "") {
    $return_module = $_REQUEST['return_module'];
        }
    } else {
        if ($action == "change") {
            if (user::checkValidPwd($_POST['passwd'])) {
                $user->changePasswd($_POST['passwd']);
                $json['errno'] = 0;
                $json['msg'] = "成功更改了 " . $_GET['uname'] . " 的密码。";
            }
            // Will raise exception if password invalid
        } else {
            if ($action == "delete") {
                $user->unRegister();
                $json['errno'] = 0;
                $json['msg'] = "成功删除了该用户。";
            } else {
                if ($action == "model") {
                    if (isset($_POST['model']) && $_POST['model'] == 'slim' || $_POST['model'] == 'default') {
                        $user->setPreference($_POST['model']);
                        $json['errno'] = 0;
                        $json['msg'] = "成功地将用户 " . $_GET['uname'] . " 的优先皮肤模型更改为 " . $_POST['model'] . " 。";
                    } else {
                        Utils::raise(1, '非法参数。');
                    }
                } else {
                    Utils::raise(1, '非法参数。');
                }
            }
        }
    }
}
echo json_encode($json);
Example #17
0
function update_iframe_dashlets()
{
    require_once 'cache/dashlets/dashlets.php';
    $db =& PearDatabase::getInstance();
    $query = "SELECT id, contents, assigned_user_id FROM user_preferences WHERE deleted = 0 AND category = 'Home'";
    $result = $db->query($query, true, "Unable to update new default dashlets! ");
    while ($row = $db->fetchByAssoc($result)) {
        $content = unserialize(base64_decode($row['contents']));
        $assigned_user_id = $row['assigned_user_id'];
        $record_id = $row['id'];
        $current_user = new User();
        $current_user->retrieve($row['assigned_user_id']);
        if (!empty($content['dashlets']) && !empty($content['pages'])) {
            $originalDashlets = $content['dashlets'];
            foreach ($originalDashlets as $key => $ds) {
                if (!empty($ds['options']['title']) && $ds['options']['title'] == translate('LBL_DASHLET_DISCOVER_SUGAR_PRO', 'iFrames')) {
                    unset($originalDashlets[$key]);
                }
            }
            $current_user->setPreference('dashlets', $originalDashlets, 0, 'Home');
        }
    }
}
Example #18
0
 public function testSetAndGetAndResetPreference()
 {
     //unset and reconnect Db to resolve mysqli fetch exeception
     global $db;
     unset($db->database);
     $db->checkConnection();
     $user = new User();
     $user->retrieve(1);
     //test setPreference method
     $user->setPreference('userPrivGuid', 'someGuid', 0, 'global', $user);
     //test getPreference method
     $result = $user->getPreference('userPrivGuid', 'global', $user);
     $this->assertTrue(isset($result));
     $this->assertEquals('someGuid', $result);
     //test resetPreferences method and verify that created preference is no longer available
     $user->resetPreferences();
     $result = $user->getPreference('userPrivGuid', 'global', $user);
     $this->assertFalse(isset($result));
 }
Example #19
0
 /**
  * Method removes module from global search configurations
  *
  * return bool
  */
 public function uninstall_global_search()
 {
     if (empty($this->installdefs['beans'])) {
         return true;
     }
     if (is_file('custom/modules/unified_search_modules_display.php') == false) {
         return true;
     }
     $user = new User();
     $users = get_user_array();
     $unified_search_modules_display = array();
     require 'custom/modules/unified_search_modules_display.php';
     foreach ($this->installdefs['beans'] as $beanDefs) {
         if (array_key_exists($beanDefs['module'], $unified_search_modules_display) == false) {
             continue;
         }
         unset($unified_search_modules_display[$beanDefs['module']]);
         foreach ($users as $userId => $userName) {
             if (empty($userId)) {
                 continue;
             }
             $user->retrieve($userId);
             $prefs = $user->getPreference('globalSearch', 'search');
             if (array_key_exists($beanDefs['module'], $prefs) == false) {
                 continue;
             }
             unset($prefs[$beanDefs['module']]);
             $user->setPreference('globalSearch', $prefs, 0, 'search');
             $user->savePreferencesToDB();
         }
     }
     if (write_array_to_file("unified_search_modules_display", $unified_search_modules_display, 'custom/modules/unified_search_modules_display.php') == false) {
         global $app_strings;
         $msg = string_format($app_strings['ERR_FILE_WRITE'], array('custom/modules/unified_search_modules_display.php'));
         $GLOBALS['log']->error($msg);
         throw new Exception($msg);
         return false;
     }
     return true;
 }
Example #20
0
 /**
  * Display a report. Choose the report among
  *  - the requested 'select_report'
  *  - the last viewed report (stored in preferences)
  *  - the default report of this tracker
  *
  * If the user request a 'link-artifact-id' then display also manual and recent 
  * panels to ease the selection of artifacts to link
  *
  * @param Tracker_IDisplayTrackerLayout  $layout          Displays the page header and footer
  * @param Codendi_Request                $request         The request
  * @param User                           $current_user    The user who made the request
  *
  * @return void
  */
 public function displayAReport(Tracker_IDisplayTrackerLayout $layout, $request, $current_user)
 {
     $report = null;
     //Does the user wants to change its report?
     if ($request->get('select_report') && $request->isPost()) {
         //Is the report id valid
         if ($report = $this->getReportFactory()->getReportById($request->get('select_report'), $current_user->getid())) {
             $current_user->setPreference('tracker_' . $this->id . '_last_report', $report->id);
         }
     }
     //If no valid report found. Search the last viewed report for the user
     if (!$report) {
         if ($report_id = $current_user->getPreference('tracker_' . $this->id . '_last_report')) {
             $report = $this->getReportFactory()->getReportById($report_id, $current_user->getid());
         }
     }
     //If no valid report found. Take the default one
     if (!$report) {
         $report = $this->getReportFactory()->getDefaultReportsByTrackerId($this->id);
     }
     $link_artifact_id = (int) $request->get('link-artifact-id');
     if ($link_artifact_id && !$request->get('report-only')) {
         $linked_artifact = Tracker_ArtifactFactory::instance()->getArtifactById($link_artifact_id);
         if (!$linked_artifact) {
             $err = "Linked artifact not found or doesn't exist";
             if (!$request->isAjax()) {
                 $GLOBALS['Response']->addFeedback('error', $err);
                 $GLOBALS['Response']->redirect('/');
             }
             die($err);
         }
         if (!$request->isAjax()) {
             //screwed up
             $GLOBALS['Response']->addFeedback('error', 'Something is wrong with your request');
             $GLOBALS['Response']->redirect(TRACKER_BASE_URL . '/?aid=' . $linked_artifact->getId());
         }
         echo $linked_artifact->fetchTitle($GLOBALS['Language']->getText('plugin_tracker_artifactlink', 'title_prefix'));
         echo '<input type="hidden" id="link-artifact-id" value="' . (int) $link_artifact_id . '" />';
         echo '<table id="tracker-link-artifact-different-ways" cellpadding="0" cellspacing="0" border="0"><tbody><tr>';
         //the fast ways
         echo '<td id="tracker-link-artifact-fast-ways">';
         //Manual
         echo '<div id="tracker-link-artifact-manual-way">';
         echo '<div class="boxtitle">';
         echo $GLOBALS['HTML']->getImage('ic/lightning-white.png', array('style' => 'vertical-align:middle')) . '&nbsp;';
         echo $GLOBALS['Language']->getText('plugin_tracker_artifactlink', 'manual_panel_title');
         echo '</div>';
         echo '<div class="tracker-link-artifact-manual-way-content">';
         echo $GLOBALS['Language']->getText('plugin_tracker_artifactlink', 'manual_panel_desc');
         echo '<p><label for="link-artifact-manual-field">';
         echo $GLOBALS['Language']->getText('plugin_tracker_artifactlink', 'manual_panel_label');
         echo '</label><br />';
         echo '<input type="text" name="link-artifact[manual]" value="" id="link-artifact-manual-field" />';
         echo '</p>';
         echo '</div>';
         echo '</div>';
         //History
         echo '<div id="tracker-link-artifact-recentitems-way">';
         echo '<div class="boxtitle">';
         echo $GLOBALS['HTML']->getImage('ic/star-white.png', array('style' => 'vertical-align:middle')) . '&nbsp;';
         echo $GLOBALS['Language']->getText('plugin_tracker_artifactlink', 'recent_panel_title');
         echo '</div>';
         echo '<div class="tracker-link-artifact-recentitems-way-content">';
         if ($recent_items = $current_user->getRecentElements()) {
             echo $GLOBALS['Language']->getText('plugin_tracker_artifactlink', 'recent_panel_desc');
             echo '<ul>';
             foreach ($recent_items as $item) {
                 if ($item['id'] != $link_artifact_id) {
                     echo '<li>';
                     echo '<input type="checkbox" 
                                  name="link-artifact[recent][]" 
                                  value="' . (int) $item['id'] . '" /> ';
                     echo $item['link'];
                     echo '</li>';
                 }
             }
             echo '</ul>';
         }
         echo '</div>';
         echo '</div>';
         //end of fast ways
         echo '</td>';
         //And the slow way (aka need to search)
         if ($report) {
             echo '<td><div id="tracker-link-artifact-slow-way">';
             echo '<div class="boxtitle">';
             echo $GLOBALS['HTML']->getImage('ic/magnifier-white.png', array('style' => 'vertical-align:middle')) . '&nbsp;';
             echo $GLOBALS['Language']->getText('plugin_tracker_artifactlink', 'search_panel_title');
             echo '</div>';
             echo '<div id="tracker-link-artifact-slow-way-content">';
         }
     }
     if ($report) {
         $report->process($layout, $request, $current_user);
     } elseif (!$link_artifact_id) {
         $this->displayHeader($layout, $this->name, array());
         echo $GLOBALS['Language']->getText('plugin_tracker', 'no_reports_available');
         $this->displayFooter($layout);
     }
     if ($link_artifact_id && !$request->get('report-only')) {
         if ($report) {
             echo '</div></div></td>';
             //end of slow
         }
         echo '</tr></tbody></table>';
         //end of ways
         echo '<div class="tracker-link-artifact-controls">';
         echo '<a href="#cancel" onclick="myLightWindow.deactivate(); return false;">&laquo;&nbsp;' . $GLOBALS['Language']->getText('global', 'btn_cancel') . '</a>';
         echo ' ';
         echo '<button name="link-artifact-submit">' . $GLOBALS['Language']->getText('global', 'btn_submit') . '</button>';
         echo '</div>';
     }
 }
 /**
  * Get the users default IE account id
  *
  * @param User $user
  */
 function setUsersDefaultOutboundServerId($user, $oe_id)
 {
     $user->setPreference($this->keyForUsersDefaultIEAccount, $oe_id, '', 'Emails');
 }
Example #22
0
 if (isset($_POST['is_admin']) && ($_POST['is_admin'] == 'on' || $_POST['is_admin'] == '1')) {
     $focus->is_admin = 1;
 } elseif (empty($_POST['is_admin'])) {
     $focus->is_admin = 0;
 }
 if (empty($_POST['portal_only']) || !empty($_POST['is_admin'])) {
     $focus->portal_only = 0;
 }
 if (empty($_POST['is_group']) || !empty($_POST['is_admin'])) {
     $focus->is_group = 0;
 }
 if (empty($_POST['receive_notifications'])) {
     $focus->receive_notifications = 0;
 }
 if (isset($_POST['gridline'])) {
     $focus->setPreference('gridline', 'on', 0, 'global', $focus);
 } else {
     $focus->setPreference('gridline', 'off', 0, 'global', $focus);
 }
 if (isset($_POST['mailmerge_on']) && !empty($_POST['mailmerge_on'])) {
     $focus->setPreference('mailmerge_on', 'on', 0, 'global', $focus);
 } else {
     $focus->setPreference('mailmerge_on', 'off', 0, 'global', $focus);
 }
 if (isset($_POST['user_max_tabs'])) {
     $focus->setPreference('max_tabs', $_POST['user_max_tabs'], 0, 'global', $focus);
 }
 if (isset($_POST['user_max_subtabs'])) {
     $focus->setPreference('max_subtabs', $_POST['user_max_subtabs'], 0, 'global', $focus);
 }
 if (isset($_POST['user_swap_last_viewed'])) {
 /**
  *  Create a user in the seed data.
  */
 function _create_seed_user($id, $last_name, $first_name, $user_name, $title, $is_admin, $reports_to, $reports_to_name, $email)
 {
     $u = new User();
     $u->id = $id;
     $u->new_with_id = true;
     $u->last_name = $last_name;
     $u->first_name = $first_name;
     $u->user_name = $user_name;
     $u->title = $title;
     $u->status = 'Active';
     $u->employee_status = 'Active';
     $u->is_admin = $is_admin;
     //$u->user_password = $u->encrypt_password($user_name);
     $u->user_hash = strtolower(md5($user_name));
     $u->reports_to_id = $reports_to;
     $u->reports_to_name = $reports_to_name;
     //$u->email1 = $email;
     $u->emailAddress->addAddress($email, true);
     $u->emailAddress->addAddress("reply." . $email, false, true);
     $u->emailAddress->addAddress("alias." . $email);
     // bug 15371 tyoung set a user preference so that Users/DetailView.php can find something without repeatedly querying the db in vain
     $u->setPreference('max_tabs', '12');
     UserPreference::savePreferencesToDB($u, true);
     $u->save();
 }
Example #24
0
                    $json['cape']['msg'] = "披风上传成功!";
                } else {
                    $json['cape']['errno'] = 1;
                    $json['cape']['msg'] = "出现了奇怪的错误。。请联系作者 :(";
                }
            }
        }
    } else {
        $json['errno'] = 1;
        $json['msg'] = "无效的 token,请先登录。";
    }
} else {
    if ($action == "model") {
        if (Utils::getValue('token', $_SESSION) == $user->getToken()) {
            $new_model = $user->getPreference() == "default" ? "slim" : "default";
            $user->setPreference($new_model);
            $json['errno'] = 0;
            $json['msg'] = "优先模型已经更改为 " . $user->getPreference() . "。";
        } else {
            $json['errno'] = 1;
            $json['msg'] = "无效的 token,请先登录。";
        }
    }
}
function checkFile()
{
    global $json;
    if (!(Utils::getValue('skin_file', $_FILES) || Utils::getValue('cape_file', $_FILES))) {
        $json['errno'] = 1;
        $json['msg'] = "什么文件都没有诶?";
        return false;