本文整理汇总了PHP中Application_Model_User::setDefaultPermissions方法的典型用法代码示例。如果您正苦于以下问题:PHP Application_Model_User::setDefaultPermissions方法的具体用法?PHP Application_Model_User::setDefaultPermissions怎么用?PHP Application_Model_User::setDefaultPermissions使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Application_Model_User
的用法示例。
在下文中一共展示了Application_Model_User::setDefaultPermissions方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: doFacebookLogin
public function doFacebookLogin()
{
$view = new Zend_view();
$view->addHelperPath('Base/View/Helper/', 'Base_View_Helper');
$facebook = $view->facebook();
$session = $facebook->getSession();
if ($session) {
try {
$Auth = new Base_Auth_Auth();
$uid = $facebook->getUser();
$user = new Application_Model_User();
$where = "facebook_id='{$uid}'";
$user = $user->fetchRow($where);
if (false === $user) {
//create new user
$me = $facebook->api('/me');
$password = md5($Auth->passwordGenerator());
$user = new Application_Model_User();
if ($me['email'] != "") {
$where = "email='{$me['email']}'";
$user = $user->fetchRow($where);
if (false === $user) {
//insertex
$user = new Application_Model_User();
$user->setEmail($me['email']);
$user->setUsername($me['id']);
$user->setPassword($password);
$user->setfirstName($me['first_name']);
$user->setLastName($me['last_name']);
$user->setSex($me['gender']);
$user->setGapperOrFriend('gapper');
$user->setFacebookId($me['id']);
$user->setStatus('active');
$user->setDob('0000-00-00');
$user->setUserLevelId(1);
} else {
//update
$user->setFacebookId($me['id']);
}
} else {
$user = new Application_Model_User();
$user->setEmail($me['email']);
$user->setUsername($me['id']);
$user->setPassword($password);
$user->setfirstName($me['first_name']);
$user->setLastName($me['last_name']);
$user->setSex($me['gender']);
$user->setGapperOrFriend('gapper');
$user->setFacebookId($me['id']);
$user->setStatus('active');
$user->setDob('0000-00-00');
$user->setUserLevelId(1);
}
$user_id = $user->save();
if ($user_id > 0) {
$user->setDefaultPermissions($user_id);
if ($params['email'] != "") {
//send registration mail
}
}
}
//--do login --
$params['email'] = $user->getEmail();
//$params['username']=$user->getUsername();
$params['password'] = $user->getPassword();
$params['md5'] = "false";
$Auth->doLogout();
$loginStatus = true;
if ($params['email'] != "") {
$loginStatus = $Auth->doLogin($params, 'email');
} else {
$params['email'] = $user->getUsername();
$loginStatus = $Auth->doLogin($params, 'username');
}
if ($user->getEmail() == "" || is_null($user->getEmail())) {
//echo "<a href='/gapper/update-your-email' >Click here</a>";
//$this->_helper->redirector('update-your-email','gapper');
$result['email'] = "no";
return $result;
}
if ($loginStatus) {
$result['email'] = "ok";
return $result;
//echo "<a href='/gapper/where-i-am' >Click here</a>";
//$this->_helper->redirector('where-i-am','gapper');
} else {
if ($user->getStatus() == "inactive") {
exit("Please activate your account. <br><a href='#' onclick='window.close();'>Close</a>");
} else {
if ($user->getStatus() == "deleted") {
exit("Your account status is deleted. Please contact administrator.");
} else {
exit("error while login");
}
}
}
} catch (FacebookApiException $e) {
error_log($e);
}
}
//.........这里部分代码省略.........
示例2: connectYourAccountAction
public function connectYourAccountAction()
{
//get referer sender user Id from session
$usersNs = new Zend_Session_Namespace("app");
$sender_id = $usersNs->sender_id;
//echo "sssss=".$sender_id;
$facebook = $this->view->facebook();
$session = $facebook->getSession();
//echo "<pre>";
//print_r($session);
if (!$session) {
$this->_helper->redirector("register", "index", "default");
}
$uid = $facebook->getUser();
$me = $facebook->api('/me');
//echo "<pre>";
//print_r($me);
//exit;
$params['email'] = $me['email'];
$arrBday = explode("/", $me['birthday']);
$params['year'] = $arrBday[2];
$params['month'] = $arrBday[0];
$params['day'] = $arrBday[1];
$params['firstName'] = $me['first_name'];
$params['lastName'] = $me['last_name'];
if (isset($me['gender']) && $me['gender'] != "") {
$params['sex'] = $me['gender'];
}
$form = new Application_Form_Register();
$form->populate($params);
$elements = $form->getElements();
$form->clearDecorators();
foreach ($elements as $element) {
$element->removeDecorator('label');
}
$this->view->fbmsg = $this->_getParam("fbmsg");
$this->view->form = $form;
$this->view->successMsg = "";
$this->view->sender = $this->_getParam('sender');
if ($this->getRequest()->isPost()) {
$params = $this->getRequest()->getPost();
$params['firstName'] = $me['first_name'];
$params['lastName'] = $me['last_name'];
if (isset($me['gender']) && $me['gender'] != "") {
$params['sex'] = $me['gender'];
}
if ($form->isValid($params)) {
$params['facebookId'] = $uid;
$params['dob'] = $params['year'] . "-" . $params['month'] . "-" . $params['day'];
$params['status'] = 'inactive';
$params['userLevelId'] = 1;
$password = $params['password'];
$params['password'] = md5($params['password']);
$params['status'] = "active";
/*----find gapper id ---*/
$gapper_id = 0;
if ($params['gapperOrFriend'] == "friend") {
$gapperM = new Application_Model_User();
$gapper = $gapperM->getDataByUsername($params['usernameOfGapper']);
if (false !== $gapper) {
$gapper_id = $gapper->getId();
}
}
$params['gapperId'] = $gapper_id;
/*----------------------*/
$user = new Application_Model_User($params);
$user_id = $user->save();
if ($user_id > 0) {
//If user has checked Newsletter, then insert in subscribe table
if ($params['newsletter'] == "yes") {
$user->newsletterSubscribe($user_id);
}
/*---- default permission settings ----*/
$user->setDefaultPermissions($user_id);
$user->setDefaultJournal($user_id);
/*-------------------------------------------*/
/*---------add a friend -------------*/
//$sender_id = base64_decode($this->_getParam('sender'));
//$senderM=new Application_Model_Friend();
//$senderM->addAsFriend($sender_id,$user_id);
$sender_id = $usersNs->sender_id;
if ($sender_id > 0) {
$senderM = new Application_Model_Friend();
$senderM->addAsFriend($sender_id, $user_id);
$senderM->addAsFriend($user_id, $sender_id);
}
/*-------------------------------------*/
$params['activate_link'] = Zend_Registry::get('siteurl') . "/index/activate/id/" . base64_encode($user_id);
$params['password'] = $password;
$usersNs->registration_id = $user_id;
//$mail=new Base_Mail();
//$mail->sendRegistrationMail($params);
$usersNs = new Zend_Session_Namespace("app");
$usersNs->facebookId = $uid;
$this->_helper->redirector('invite', 'index', "default");
}
}
}
}
示例3: addAction
public function addAction()
{
$request = $this->getRequest();
$form = new Admin_Form_User();
$options = $request->getPost();
if ($request->isPost()) {
/*---- email validation ----*/
$form->getElement('email')->addValidators(array(array('Db_NoRecordExists', false, array('table' => 'user', 'field' => 'email', 'messages' => 'Email already exists, Please choose another email address.'))));
/*-------------------------*/
if ($form->isValid($options)) {
$model = new Application_Model_User();
$options['dob'] = $options['year'] . "-" . $options['month'] . "-" . $options['day'];
$options['status'] = 'active';
$options['password'] = md5($options['password']);
$options['preferredLanguage'] = 'English';
//$options['userLevelId'] =$options['userLevelId'];
//$model->setOptions($options);
// $id=$model->save();
/*--------- Upload image START -------------------------*/
$upload = new Zend_File_Transfer_Adapter_Http();
if ($upload->isValid('image')) {
$upload->setDestination("media/picture/profile/");
try {
$upload->receive('image');
} catch (Zend_File_Transfer_Exception $e) {
$msg = $e->getMessage();
}
$upload->setOptions(array('useByteString' => false));
$file_name = $upload->getFileName('image');
$cardImageTypeArr = explode(".", $file_name);
$ext = strtolower($cardImageTypeArr[count($cardImageTypeArr) - 1]);
$target_file_name = "profile_" . $id . ".{$ext}";
$targetPath = 'media/picture/profile/' . $target_file_name;
$filterFileRename = new Zend_Filter_File_Rename(array('target' => $targetPath, 'overwrite' => true));
$filterFileRename->filter($file_name);
$options['image'] = $target_file_name;
/*--- Generate Thumbnail ---*/
$thumb = Base_Image_PhpThumbFactory::create($targetPath);
$thumb->resize(100, 100);
$thumb->save($targetPath = 'media/picture/profile/thumb_' . $target_file_name);
$model->setOptions($options);
$model->setId($id);
$id = $model->save();
}
/*--------- Upload image END -------------------------*/
//$options['dob'] = $options['year']."-".$options['month']."-".$options['day'];
//$model->setOptions($options);
//$model->save();
$user = new Application_Model_User($options);
$user_id = $user->save();
if ($user_id > 0) {
/*---- default permission settings ----*/
$user->setDefaultPermissions($user_id);
$user->setDefaultJournal($user_id);
}
$this->view->msg = "'User has been inserted successfully!";
$form->reset();
} else {
$form->reset();
$form->populate($options);
}
}
$this->view->form = $form;
}