Exemple #1
0
 public function execute()
 {
     $page = $this->context->get('page');
     $page = max(intval($page), 1);
     $page_size = $this->configHandle->get('page_size');
     if (empty($page_size)) {
         $page_size = 25;
     }
     $param['limit'] = $page_size;
     $param['offset'] = ($page - 1) * $page_size;
     $param['op'] = $this->context->get('op');
     $param['gid'] = $this->context->post('gid');
     $param['q'] = $this->context->post('q');
     $param['field'] = $this->context->post('field');
     // userid
     $uid = $this->data['uid'];
     $addressBookService = new AddressBookService();
     // 取当前用户通讯录的所有分组
     $this->data['groups'] = $addressBookService->getAllGroups($uid);
     $this->data['data'] = $addressBookService->getAddressBookListByUserId($uid, $param);
     $count = $this->data['data']['count'];
     // 分页  :page 会自动被替换掉
     $base_url = LtObjectUtil::singleton('LtUrl')->generate('Default', 'Index', array('page' => ':page'));
     $pagination = new LtPagination();
     $pagination->init();
     $this->data['pages'] = $pagination->pager($page, $count, $base_url);
     // 页面标题
     $this->data['title'] = 'addressbook';
     // 入口文件url路径
     $this->data['baseurl'] = $this->configHandle->get('baseurl');
 }
 public function execute()
 {
     $password = md5($this->context->post('password'));
     $username = trim($this->context->post('username'));
     if ($username && $password) {
         $addressbookService = new AddressBookService();
         $uid = $addressbookService->getUserIdByName($username);
         if ($uid) {
             $data = $addressbookService->getUserById($uid);
         } else {
             $data = array();
         }
         if ($data && $data['password'] == $password) {
             $authCode = $data['uid'] . "\t" . $data['password'];
             $this->message = "登陆成功";
         } else {
             $this->message = "帐号密码错误";
             $authCode = '';
         }
         /**
          * 保存时间86400秒(一天)
          */
         C("LtCookie")->setCookie('auth', $authCode, time() + 86400);
         $this->data['forward'] = C('LtUrl')->generate('Default', 'Index');
     } else {
         $this->message = "请输入帐号和密码登陆";
         $this->data['forward'] = C('LtUrl')->generate('User', 'Login');
     }
     $this->data['baseurl'] = LtObjectUtil::singleton('LtConfig')->get('baseurl');
     $this->data['title'] = '用户登陆';
     $this->responseType = 'tpl';
     $this->layout = 'result';
 }
Exemple #3
0
 public function execute()
 {
     $addressbook = new AddressBookService();
     $this->data['groups'] = $addressbook->getAllGroups($this->uid);
     $this->data['title'] = 'addressbook';
     $this->data['baseurl'] = LtObjectUtil::singleton('LtConfig')->get('baseurl');
 }
Exemple #4
0
 public function execute()
 {
     $gid = $this->context->get('gid');
     $addressbook = new AddressBookService();
     $this->data['group'] = $addressbook->getGroupsById($this->uid, $gid);
     $this->data['title'] = 'addressbook';
     $this->data['baseurl'] = LtObjectUtil::singleton('LtConfig')->get('baseurl');
 }
Exemple #5
0
 public function execute()
 {
     $mobile = $this->context->get('mobile');
     $addressbookService = new AddressBookService();
     if ($addressbookService->isMobileExists($mobile)) {
         $this->message = "手机号已经注册";
     } else {
         $this->message = "可以使用";
     }
     $this->responseType = 'json';
     // 返回json类型
 }
Exemple #6
0
 public function execute()
 {
     $data = $this->context->post('data');
     $data['uid'] = $this->uid;
     $addressbook = new AddressBookService();
     $addressbook->addAddressBook($data);
     $this->code = 200;
     $this->data['forward'] = C('LtUrl')->generate('Default', 'Index');
     $this->data['title'] = 'addressbook';
     $this->data['baseurl'] = LtObjectUtil::singleton('LtConfig')->get('baseurl');
     $this->layout = 'result';
 }
 public function execute()
 {
     $id = $this->context->get('id');
     $addressbook = new AddressBookService();
     $addressbook->delAddressBook($id);
     $this->code = 200;
     $this->message = '删除成功';
     $this->data['title'] = 'addressbook';
     $this->data['forward'] = C('LtUrl')->generate('Default', 'Index');
     $this->data['baseurl'] = LtObjectUtil::singleton('LtConfig')->get('baseurl');
     $this->layout = 'result';
 }
 public function execute()
 {
     $gid = $this->context->get('gid');
     $addressbook = new AddressBookService();
     $addressbook->deleteGroup($this->uid, $gid);
     $this->code = 200;
     $this->message = '删除成功';
     $this->data['title'] = 'addressbook';
     $this->data['forward'] = C('LtUrl')->generate('Groups', 'Index');
     $this->data['baseurl'] = LtObjectUtil::singleton('LtConfig')->get('baseurl');
     $this->responseType = 'tpl';
     $this->layout = 'result';
 }
Exemple #9
0
 public function execute()
 {
     $data = $this->context->post('data');
     $addressbook = new AddressBookService();
     $addressbook->updateGroup($this->uid, $data);
     $this->code = 200;
     $this->data['forward'] = C('LtUrl')->generate('Groups', 'Index');
     $this->data['title'] = 'addressbook';
     $this->data['baseurl'] = LtObjectUtil::singleton('LtConfig')->get('baseurl');
     $this->responseType = 'tpl';
     $this->layout = 'result';
     // 使用不同的页面布局
 }
 /**
  * (non-PHPdoc)
  * @see LtAction::beforeExecute()
  */
 public function beforeExecute()
 {
     $this->context->admin_id = 0;
     $authCode = C('LtCookie')->getCookie('auth');
     if ($authCode) {
         list($uid, $password) = explode("\t", $authCode);
         $addressbookService = new AddressBookService();
         $data = $addressbookService->getUserById($uid);
         if ($data && $data['password'] == $password) {
             $this->data['username'] = $data['username'];
             $this->data['uid'] = $data['uid'];
             $this->uid = $data['uid'];
         } else {
             $this->data['username'] = '';
             $this->data['uid'] = 0;
             C('LtCookie')->delCookie('auth');
         }
     }
     if (!$this->data['uid']) {
         header("Location: " . C('LtUrl')->generate('User', 'Login'));
     }
 }
 public function index()
 {
     $this->set('addresses', AddressBookService::findAll());
     $this->renderView('index');
 }
 public static function loadColumnFamilies()
 {
     self::$cfAddress = new CassandraCF('AddressBook', 'Addresses');
 }
<?php

session_start();
require 'functions.php';
require 'models.php';
require 'services.php';
require 'controllers.php';
// Configure cassandra nodes
AddressBookService::addNode('localhost', 9160);
AddressBookService::connect();