Example #1
0
 /**
  * 用户授权检查
  * 
  * @access protected
  * @param string accessToken 用户授权令牌
  * @return void
  */
 protected function checkAccessToken()
 {
     $this->params = $this->require_params(array('accessToken'));
     if ($this->params['accessToken'] == 'vPoGp4lHm6') {
         $_tokenInfo['userId'] = 306;
     } else {
         $_tokenInfo = $this->model->getTokenInfo($this->params['accessToken']);
     }
     #填写全局信息
     $GLOBALS['userId'] = $_tokenInfo['userId'];
     unset($_tokenInfo);
 }
Example #2
0
 /**
  * (non-PHPdoc)
  * @see base_model::__destruct()
  */
 public function __destruct()
 {
     parent::__destruct();
     unset($this->tagModel);
     unset($this->emailObject);
     unset($this->emailConfig);
     unset($this->groupModel);
 }
Example #3
0
 public function createForShare($data)
 {
     $bytes = openssl_random_pseudo_bytes(100);
     $hex = bin2hex($bytes);
     $update = array('email' => $data->email, 'uuid' => $hex, 'activated' => 'No');
     $result = parent::create($update);
     return $result;
 }
 public function create($data)
 {
     $bytes = openssl_random_pseudo_bytes(100);
     $hex = bin2hex($bytes);
     $query = array();
     $data->uuid = $hex;
     $data->activated = 'No';
     if (isset($data->username)) {
         $query['username'] = $data->username;
     }
     if (isset($data->email)) {
         $query['email'] = $data->email;
     }
     // check if email and username setup
     if (!empty($query)) {
         $artist_exists = $this->find($query);
         if (isset($artist_exists[0])) {
             //				var_dump($artist_exists[0]);
             return null;
         }
     }
     // check if artist name used
     if (isset($data->artist_name)) {
         $artist_exists = $this->find(array('artist_name' => $data->artist_name));
         if (isset($artist_exists[0])) {
             return null;
         }
     }
     $result = parent::create($data);
     $this->load->library('email');
     $message = $this->load->view('emails/ArtistActivation', array('data' => $result), TRUE);
     $this->email->initialize(array('mailtype' => 'html'));
     $this->email->from('*****@*****.**');
     $this->email->to($result->email);
     $this->email->subject("Beatcrumb activation!");
     $this->email->message($message);
     $this->email->send();
     // 		echo($this->db->last_query());
     return $result->id;
 }
Example #5
0
 public function __construct()
 {
     parent::__construct();
     $this->load->database();
     $this->table = 'peasant';
 }
 /**
  * Devuelve el rol asociado al usuario que inició la sesión.
  * @param base_model $obj_model Instancia de un modelo.
  * @param int $user_id Identificador de usuario.
  * @return int Devuelve el role o profile asociado a un usuario.
  *
  **/
 function getRole(&$obj_model, $user_id)
 {
     $ret_sql = $obj_model->Select('user', 'id_profile', 'user_id = ' . $user_id);
     if ($obj_model->hasError()) {
         $ret_val = null;
     } else {
         $ret_val = $ret_sql[0]['user.id_profile'];
     }
     return $ret_val;
 }
 /**
  * Obtiene toda la información de un usuario
  * @param base_model $obj_model Instancia de un modelo
  * @param string $str_user Identificador de usuario (nickname).
  * @return array Toda la información: user_id, nombre, email, nick, trato, idioma,...
  */
 function getInfo(&$obj_model, $str_user)
 {
     if ($str_user == '') {
         $ret_val = array('user_id' => '', 'name' => '', 'surname' => '', 'username' => 'guest', 'password' => '', 'email' => '', 'statut' => '', 'treatment' => '', 'language' => '', 'theme' => '', 'profile' => 'guest', 'isadmin' => false);
     } else {
         $ret_sql = $obj_model->Select('user', 'user_id, nom, prenom, username, password, email, statut, idtreatment, language, theme, profile', "username = {$str_user}");
         if ($obj_model->hasError()) {
             $ret_val = null;
         } else {
             //No incluimos información de la "tabla" o modelo de datos
             $ret_val = array('user_id' => $ret_sql[0]['user_id'], 'name' => $ret_sql[0]['nom'], 'surname' => $ret_sql[0]['prenom'], 'username' => $ret_sql[0]['username'], 'password' => $ret_sql[0]['password'], 'email' => $ret_sql[0]['email'], 'statut' => $ret_sql[0]['statut'], 'treatment' => $ret_sql[0]['idtreatment'], 'language' => $ret_sql[0]['language'], 'theme' => $ret_sql[0]['theme'], 'profile' => $ret_sql[0]['profile']);
         }
     }
     return $ret_val;
 }
Example #8
0
 public function __construct()
 {
     parent::__construct();
     $this->load->database();
     $this->table = 'business';
 }
Example #9
0
 public function __construct()
 {
     $this->tableName = 'users';
     $this->keyField = 'id';
     parent::__construct();
 }
Example #10
0
 public function __construct()
 {
     parent::__construct();
     $this->load->database();
     $this->table = 'lawyer';
 }
Example #11
0
$m = $b->maxid('+1');
xn_assert('b->maxid(\'+1\')', $m == 1);
$r = $b->set(1, array('subject' => 'this is subject 111 .', 'message' => 'this is message 111'));
xn_assert('b->set(1)', $r);
$m = $b->maxid('+1');
xn_assert('b->maxid(\'+1\')', $m == 2);
$r = $b->set(2, array('subject' => 'this is subject 222 .', 'message' => 'this is message 222'));
xn_assert('b->set(2)', $r);
$r = $b->count('+2');
xn_assert('b->count("+2")', $r == 2);
$arr = $b->get(2);
xn_assert('b->get("+2")', count($arr) == 2);
$list = $b->index_fetch($cond = array(), $orderby = array('uid' => -1), 0, $pagesize = 30);
print_r($list);
// ---------------------> 测试主键包含多列字段的情况, 实例 primary key(fid, user)
$b = new base_model();
$b->db->query(" DROP TABLE IF EXISTS `xn_mblog`");
$b->db->query("\n\t CREATE TABLE `xn_mblog` (                                \n           `fid` int(11) unsigned NOT NULL default '0',       \n           `blogid` int(11) unsigned NOT NULL default '0',       \n           `uid` int(11) unsigned NOT NULL default '0',       \n           `dateline` int(11) unsigned NOT NULL default '0',     \n           `subject` char(80) NOT NULL default '',               \n           `message` longtext NOT NULL,                          \n           `username` char(16) NOT NULL default '',              \n           `isprivate` tinyint(4) NOT NULL default '0',          \n           PRIMARY KEY  (`fid`, `blogid`),                              \n           KEY `uidblogid` (`uid`,`blogid`)                \n         ) ENGINE=MyISAM AUTO_INCREMENT=24 DEFAULT CHARSET=utf8  \n");
$b->table = 'mblog';
$b->primarykey = array('fid', 'blogid');
$b->cacheconf['enable'] = FALSE;
$n = $b->count(0);
xn_assert('b->count(0)', $n == 0);
$m = $b->maxid(0);
xn_assert('b->maxid(0)', $m == 0);
$m = $b->maxid('+1');
xn_assert('b->maxid(\'+1\')', $m == 1);
$r = $b->set(1, 1, array('subject' => 'this is subject 111 .', 'message' => 'this is message 111'));
xn_assert('b->set(1)', $r);
$m = $b->maxid('+1');
xn_assert('b->maxid(\'+1\')', $m == 2);
 /**
  * Obtiene toda la informaciÛn de un curso
  * @param base_model $obj_model Instancia de un modelo
  * @param string $course_id Identificador de curso.
  * @return array Toda la informaciÛn: nombre, email, idioma,...
  */
 function getInfo(&$obj_model, $course_id)
 {
     //Obtiene información del curso
     $ret_sql = $obj_model->SelectMultiTable('course, user, person', 'course.course_name, course.course_description, course.course_language, person.person_name, person.person_surname, user.email', 'course_id = ' . $course_id . ' AND course.user_id = user.user_id AND user.person_id = person.person_id');
     if ($obj_model->hasError()) {
         $ret_val = null;
     } else {
         $arr_path = miguel_CourseInfo::_getPath($obj_model, $course_id);
         $ret_val = array('course_id' => $course_id, 'name' => $ret_sql[0]['course.course_name'], 'description' => $ret_sql[0]['course.course_description'], 'user_responsable' => $ret_sql[0]['person.person_name'] . ' ' . $ret_sql[0]['person.person_surname'], 'email' => $ret_sql[0]['user.email'], 'language' => $ret_sql[0]['course.course_language'], 'path' => $arr_path);
     }
     return $ret_val;
 }
Example #13
0
 /**
  * (non-PHPdoc)
  * @see base_model::__destruct()
  */
 public function __destruct()
 {
     parent::__destruct();
     //unset($this->userModel);
 }
Example #14
0
 public function __construct()
 {
     parent::__construct();
     //$this->set_table('test');
 }
 public function __construct()
 {
     parent::__construct();
     $this->tableName = 'contacts';
     $this->keyField = 'id';
 }