本文整理汇总了PHP中Preference::setUserId方法的典型用法代码示例。如果您正苦于以下问题:PHP Preference::setUserId方法的具体用法?PHP Preference::setUserId怎么用?PHP Preference::setUserId使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Preference
的用法示例。
在下文中一共展示了Preference::setUserId方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: executeSavePreferences
public function executeSavePreferences()
{
sfLoader::loadHelpers('I18N');
$criteria = new Criteria();
$criteria->add(PreferencePeer::USER_ID, $this->getUser()->getId());
$preferences = PreferencePeer::doSelect($criteria);
foreach ($preferences as $preference) {
$preference->delete();
}
$this->msg = __('Preferences saved.');
if (($preference = $this->getUser()->getPreference('box_user')) != sfConfig::get('app_preference_box_user')) {
$this->msg .= "\napp_preference_box_user : " . ($preference == 'none' ? __('do not display') : __('display'));
$p = new Preference();
$p->setUserId($this->getUser()->getId());
$p->setName('box_user');
$p->setValue($preference);
$p->save();
}
if (($preference = $this->getUser()->getPreference('box_snippets')) != sfConfig::get('app_preference_box_snippets')) {
$this->msg .= "\napp_preference_box_snippets : " . ($preference == 'none' ? __('do not display') : __('display'));
$p = new Preference();
$p->setUserId($this->getUser()->getId());
$p->setName('box_snippets');
$p->setValue($preference);
$p->save();
}
if (($preference = $this->getUser()->getPreference('box_language_cloud')) != sfConfig::get('app_preference_box_language_cloud')) {
$this->msg .= "\napp_preference_box_language_cloud : " . ($preference == 'none' ? __('do not display') : __('display'));
$p = new Preference();
$p->setUserId($this->getUser()->getId());
$p->setName('box_language_cloud');
$p->setValue($preference);
$p->save();
}
if (($preference = $this->getUser()->getPreference('box_tag_cloud')) != sfConfig::get('app_preference_box_tag_cloud')) {
$this->msg .= "\napp_preference_box_tag_cloud : " . ($preference == 'none' ? __('do not display') : __('display'));
$p = new Preference();
$p->setUserId($this->getUser()->getId());
$p->setName('box_tag_cloud');
$p->setValue($preference);
$p->save();
}
if (($preference = $this->getUser()->getPreference('box_snippets_size')) != sfConfig::get('app_preference_box_snippets_size')) {
$this->msg .= "\napp_preference_box_snippets_size : " . $preference;
$p = new Preference();
$p->setUserId($this->getUser()->getId());
$p->setName('box_snippets_size');
$p->setValue($preference);
$p->save();
}
if (($preference = $this->getUser()->getPreference('search_size')) != sfConfig::get('app_preference_search_size')) {
$this->msg .= "\napp_preference_search_size : " . $preference;
$p = new Preference();
$p->setUserId($this->getUser()->getId());
$p->setName('box_search_size');
$p->setValue($preference);
$p->save();
}
if (($preference = $this->getUser()->getPreference('box_order')) != sfConfig::get('app_preference_box_order')) {
$order_str = "";
foreach ($preference as $order_no) {
$order_str .= "{$order_no}, ";
}
$order_str = substr($order_str, 0, strlen($order_str) - 2);
$p = new Preference();
$p->setUserId($this->getUser()->getId());
$p->setName('box_order');
$p->setValue($order_str);
$p->save();
$this->msg .= "\napp_preference_box_order : " . $order_str;
}
}