Ejemplo n.º 1
2
 public function init()
 {
     require_once _base_ . '/lib/lib.json.php';
     $this->db = DbConn::getInstance();
     $this->model = new ProfileLms();
     $this->json = new Services_JSON();
     $this->aclManager = Docebo::user()->getAClManager();
     $this->max_dim_avatar = 150;
 }
 public function init()
 {
     parent::init();
     require_once _base_ . '/lib/lib.json.php';
     $this->db = DbConn::getInstance();
     $this->model = new GroupmanagementAdm();
     $this->json = new Services_JSON();
     $this->permissions = array('view' => checkPerm('view', true, 'groupmanagement'), 'add' => checkPerm('add', true, 'groupmanagement'), 'mod' => checkPerm('mod', true, 'groupmanagement'), 'del' => checkPerm('del', true, 'groupmanagement'), 'associate_user' => checkPerm('associate_user', true, 'groupmanagement'));
 }
Ejemplo n.º 3
1
 function id($verify = FALSE)
 {
     $id = get_cookie('admin_id');
     if (!$id) {
         return FALSE;
     }
     // If no verification is necessary, we're good to go
     if (!$verify) {
         return $id;
     }
     $token = get_cookie('admin_token');
     if (!$token) {
         return FALSE;
     }
     $db = new DbConn();
     $result = $db->query('select * from admins where id = ?', $id);
     $admin = $result->next();
     if (!$admin) {
         return FALSE;
     }
     if ($admin->token != $token) {
         return FALSE;
     }
     return $id;
 }
Ejemplo n.º 4
1
 public static function checkLogin($userName, $password)
 {
     $sql = "select * from manager where userName='******' and password='******'";
     $conn = new DbConn();
     $result = $conn->executeQuery($sql);
     $conn->close();
     return $result[0];
 }
Ejemplo n.º 5
1
 public static function addReviews($articleId, $userName, $body, $face)
 {
     $sql = "insert into reviews(articleId,userName,body,face)values({$articleId},'{$userName}','{$body}','{$face}')";
     $conn = new DbConn();
     $row = $conn->executeUpdate($sql);
     $conn->close();
     return $row;
 }
Ejemplo n.º 6
1
 public static function getNewsTypes()
 {
     $sql = "select * from newsTypes";
     $conn = new DbConn();
     $result = $conn->executeQuery($sql);
     $conn->freeResult();
     $conn->close();
     return $result;
 }
Ejemplo n.º 7
1
function delete_note($noteid)
{
    $db = new DbConn();
    $result = $db->fetch('select userid from notes where id = ?');
    if ($result) {
        $db->exec('delete from notes where id = ?', $noteid);
        log_event(LOG_NOTE_DELETED, $result->userid, $noteid);
    }
}
Ejemplo n.º 8
1
 public function DbConn()
 {
     $connStr = 'mysql:host=localhost;dbname=esplm';
     $dbConn = new PDO($connStr, 'root', '');
     $dbConn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
     self::$dbConn = $dbConn;
 }
Ejemplo n.º 9
1
 public function getBbsInfo()
 {
     $sql = "select * from bbsinfo";
     $conn = DbConn::getInstance();
     $bbsInfo = $conn->query($sql);
     return $bbsInfo;
 }
Ejemplo n.º 10
1
 public static function getConnection()
 {
     if (self::$dbh === null) {
         self::$dbh = new \PDO('mysql:host=' . $_SERVER['DB_HOST'] . ';dbname=' . $_SERVER['DB_DEFAULT'] . ';charset=utf8', $_SERVER['DB_USER'], $_SERVER['DB_PASSWORD']);
     }
     return self::$dbh;
 }
Ejemplo n.º 11
1
 public function findAll($conditions, $params)
 {
     $db = DbConn::getInstance();
     $query = $db->query("SELECT c.idCourse, c.course_type, c.idCategory, c.code, c.name, c.description, c.difficult, c.status AS course_status, c.course_edition, " . "\tc.max_num_subscribe, c.create_date, " . "\tc.direct_play, c.img_othermaterial, c.course_demo, c.use_logo_in_courselist, c.img_course, c.lang_code, " . "\tc.course_vote, " . "\tc.date_begin, c.date_end, c.valid_time, c.show_result, c.userStatusOp, c.auto_unsubscribe, c.unsubscribe_date_limit, " . "\tcu.status AS user_status, cu.level, cu.date_inscr, cu.date_first_access, cu.date_complete, cu.waiting" . " FROM %lms_course AS c " . " JOIN %lms_courseuser AS cu ON (c.idCourse = cu.idCourse) " . " WHERE " . $this->compileWhere($conditions, $params) . ($_SESSION['id_common_label'] > 0 ? " AND c.idCourse IN (SELECT id_course FROM %lms_label_course WHERE id_common_label = '" . $_SESSION['id_common_label'] . "')" : "") . " ORDER BY " . $this->_resolveOrder(array('cu', 'c')));
     $result = array();
     $courses = array();
     while ($data = $db->fetch_assoc($query)) {
         $data['enrolled'] = 0;
         $data['numof_waiting'] = 0;
         $data['first_lo_type'] = FALSE;
         $courses[] = $data['idCourse'];
         $result[$data['idCourse']] = $data;
     }
     if (!empty($courses)) {
         // find subscriptions
         $re_enrolled = $db->query("SELECT c.idCourse, COUNT(*) as numof_associated, SUM(waiting) as numof_waiting" . " FROM %lms_course AS c " . " JOIN %lms_courseuser AS cu ON (c.idCourse = cu.idCourse) " . " WHERE c.idCourse IN (" . implode(',', $courses) . ") " . " GROUP BY c.idCourse");
         while ($data = $db->fetch_assoc($re_enrolled)) {
             $result[$data['idCourse']]['enrolled'] = $data['numof_associated'] - $data['numof_waiting'];
             $result[$data['idCourse']]['numof_waiting'] = $data['numof_waiting'];
         }
         // find first LO type
         $re_firstlo = $db->query("SELECT o.idOrg, o.idCourse, o.objectType FROM %lms_organization AS o " . " WHERE o.objectType != '' AND o.idCourse IN (" . implode(',', $courses) . ") " . " GROUP BY o.idCourse ORDER BY o.path");
         while ($data = $db->fetch_assoc($re_firstlo)) {
             $result[$data['idCourse']]['first_lo_type'] = $data['objectType'];
         }
     }
     return $result;
 }
Ejemplo n.º 12
0
 function index()
 {
     $this->load->helper('mail');
     $db = new DbConn();
     $mails = $db->query('select * from mails_scheduled where due <= NOW()');
     while ($mail = $mails->next()) {
         $user_id = $mail->userid;
         $mail_id = $mail->mailid;
         $template = get_mail_template($mail_id, false);
         if (!$template) {
             continue;
         }
         send_user_mail($template, $user_id);
         $db->exec('delete from mails_scheduled where id = ?', $mail->id);
     }
 }
Ejemplo n.º 13
0
 /**
  * @param int 		$id_course the id of the course to be deleted
  *
  * @return bool 	true if success false otherwise
  */
 function deleteAllCourseAdvices($id_course)
 {
     //validate input
     if ((int) $id_course <= 0) {
         return false;
     }
     $db = DbConn::getInstance();
     $db->start_transaction();
     //get all existing advices for the course
     $arr_id_advice = array();
     $query = "SELECT idAdvice FROM %lms_advice WHERE idCourse = " . (int) $id_course;
     $res = $db->query($query);
     while (list($id_advice) = $db->fetch_row($res)) {
         $arr_id_advice[] = $id_advice;
     }
     //delete all adviceusers
     if (!empty($arr_id_advice)) {
         $query = "DELETE FROM %lms_adviceuser WHERE idAdvice IN (" . implode(",", $arr_id_advice) . ")";
         $res = $db->query($query);
         if (!res) {
             $db->rollback();
             return false;
         }
     }
     //delete course advices
     $query = "DELETE FROM %lms_advice WHERE idCourse = '" . (int) $id_course . "'";
     $res = $db->query($query);
     if (!$res) {
         $db->rollback();
         return false;
     }
     $db->commit();
     return true;
 }
Ejemplo n.º 14
0
 public static function getNewsTypes()
 {
     $sql = "select * from newsTypes";
     $conn = DbConn::getInstance();
     $newsTypes = $conn->query($sql);
     return $newsTypes;
 }
Ejemplo n.º 15
0
 public static function checkLogin($userName, $password)
 {
     $sql = "select * from manager where userName='******' and password='******'";
     $conn = DbConn::getInstance();
     $userInfo = $conn->queryOne($sql);
     return $userInfo;
 }
Ejemplo n.º 16
0
 public static function getNewsTypes()
 {
     $sql = "select * from newsTypes";
     $conn = DbConn::getInstance();
     $result = $conn->queryAll($sql);
     return $result;
 }
Ejemplo n.º 17
0
 public function __construct()
 {
     require_once _lms_ . '/lib/lib.date.php';
     require_once _lms_ . '/lib/lib.course.php';
     $this->id_user = Docebo::user()->getIdst();
     $this->db = DbConn::getInstance();
 }
Ejemplo n.º 18
0
 /**
  * This function return the current instance for the class, if it's the first
  * time that is called it will instance the class
  * @return DbConn
  */
 public static function &getInstance()
 {
     if (self::$instance == NULL) {
         $db_type = Get::cfg('db_type', function_exists('mysqli_connect') ? 'mysqli' : 'mysql');
         switch ($db_type) {
             case "mysql":
                 require_once _base_ . '/db/drivers/docebodb.mysql.php';
                 self::$instance = new Mysql_DbConn();
                 self::$instance->debug = Get::cfg('do_debug');
                 $conn = self::$instance->connect(Get::cfg('db_host'), Get::cfg('db_user'), Get::cfg('db_pass'), Get::cfg('db_name'));
                 if ($conn) {
                     self::$connected = true;
                 }
                 break;
             case "mysqli":
                 require_once _base_ . '/db/drivers/docebodb.mysqli.php';
                 self::$instance = new Mysqli_DbConn();
                 self::$instance->debug = Get::cfg('do_debug');
                 $conn = self::$instance->connect(Get::cfg('db_host'), Get::cfg('db_user'), Get::cfg('db_pass'), Get::cfg('db_name'));
                 if ($conn) {
                     self::$connected = true;
                 }
                 break;
         }
     }
     return self::$instance;
 }
Ejemplo n.º 19
0
 public static function addReviews($articleId, $face, $content, $userName)
 {
     $sql = "insert into reviews(articleId,face,body,userName)values({$articleId},'{$face}','{$content}','{$userName}')";
     $conn = DbConn::getInstance();
     $row = $conn->exec($sql);
     return $row;
 }
Ejemplo n.º 20
0
 public static function getHotNews()
 {
     $sql = "select * from newsArticles a inner join newsTypes b on a.typeId=b.typeId order by hints desc limit 0,6";
     $conn = DbConn::getInstance();
     $hotNews = $conn->query($sql);
     return $hotNews;
 }
Ejemplo n.º 21
0
 public function insert()
 {
     $pdo = DbConn::getConn();
     $pdo->exec("SET NAMES 'utf8';");
     $q = "INSERT INTO flowers(cat_id,name,description,image) VALUES (:cat_id,:name,:desc,:img)";
     $stmt = $pdo->prepare($q);
     $stmt->execute(array(":cat_id" => $this->cat_id, ":name" => $this->name, ":desc" => $this->description, ":img" => $this->image));
 }
 public function init()
 {
     parent::init();
     require_once _base_ . '/lib/lib.json.php';
     $this->db = DbConn::getInstance();
     $this->model = new PrivacypolicyAdm();
     $this->json = new Services_JSON();
     $this->permissions = array('view' => checkPerm('view', true, 'privacypolicy'), 'add' => checkPerm('mod', true, 'privacypolicy'), 'mod' => checkPerm('mod', true, 'privacypolicy'), 'del' => checkPerm('del', true, 'privacypolicy'));
 }
Ejemplo n.º 23
0
 function connectToDb()
 {
     require_once _base_ . '/config.php';
     require_once _base_ . '/db/lib.docebodb.php';
     //		$db = mysql_connect($cfg['db_host'], $cfg['db_user'], $cfg['db_pass']);
     //		mysql_select_db($cfg['db_name']);
     $db =& DbConn::getInstance();
     return $db;
 }
Ejemplo n.º 24
0
 /**
  * 完成抽奖动作,返回抽奖结果
  * @return array 抽奖结果
  */
 public function loterry()
 {
     $tmpArr = array();
     $db = new DbConn();
     foreach ($this->prizeArr as $k => $v) {
         $tmpArr[$v['id']] = $v['v'];
     }
     do {
         $prizeId = $this->getPrizeId($tmpArr);
         // 奖项id
         $nums = $db->countByPid($prizeId);
         // 查询已获取当前奖项的人数
     } while ($nums >= $this->prizeArr[$prizeId - 1]['num']);
     //$prizeId = $this->getPrizeId($tmpArr); // 奖项id
     //$angle = $this->getRotation($this->prizeArr[$prizeId-1]); // 旋转角度
     // 插入数据库,记录用户中奖情况
     $db->add($this->uid, $prizeId, $this->prizeArr[$prizeId - 1]['prize'], time());
     return array('prize' => $prizeId);
 }
Ejemplo n.º 25
0
 function Report_Aggregate()
 {
     $this->db = DbConn::getInstance();
     $this->lang =& DoceboLanguage::createInstance('report', 'framework');
     $this->_set_columns_category(_RA_CATEGORY_COURSES, Lang::t('_RU_CAT_COURSES', 'report'), 'get_courses_filter', 'show_report_courses', '_get_courses_query');
     $this->_set_columns_category(_RA_CATEGORY_COURSECATS, Lang::t('_RA_CAT_COURSECATS', 'report'), 'get_coursecategories_filter', 'show_report_coursecategories', '_get_coursecategories_query');
     $this->_set_columns_category(_RA_CATEGORY_TIME, Lang::t('_RA_CAT_TIME', 'report'), 'get_time_filter', 'show_report_time', '_get_time_query');
     $this->_set_columns_category(_RA_CATEGORY_COMMUNICATIONS, Lang::t('_RU_CAT_COMMUNICATIONS', 'report'), 'get_communications_filter', 'show_report_communications', '_get_communications_query');
     $this->_set_columns_category(_RA_CATEGORY_GAMES, Lang::t('_RU_CAT_GAMES', 'report'), 'get_games_filter', 'show_report_games', '_get_games_query');
 }
Ejemplo n.º 26
0
 /**
  * function learning_Object()
  * class constructor
  **/
 function Learning_Object($id = NULL, $environment = false)
 {
     $this->id = $id;
     $this->environment = $environment ? $environment : 'course_lo';
     $this->idAuthor = '';
     $this->title = '';
     $this->db = DbConn::getInstance();
     $this->aclManager = Docebo::user()->getAclManager();
     $this->table = '';
 }
Ejemplo n.º 27
0
 public function init()
 {
     require_once _base_ . '/lib/lib.json.php';
     $this->db = DbConn::getInstance();
     $this->model = new MessageLms();
     $this->json = new Services_JSON();
     $this->aclManager = Docebo::user()->getAClManager();
     $this->can_send = true;
     //checkPerm('send_all', true) || checkPerm('send_upper', true);
 }
Ejemplo n.º 28
0
/**
 * Return the ID of a custom menu searcing by a given menu name
 * @param string $name
 * @return integer 
 */
function getCustomMenuIdByName($name)
{
    $res = false;
    $query = "\r\n\t\tSELECT idCustom \r\n\t\tFROM %lms_menucustom\r\n\t\tWHERE title='" . $name . "' LIMIT 0,1";
    $re_custom = DbConn::getInstance()->query($query);
    if ($re_custom && DbConn::getInstance()->num_rows($re_custom)) {
        list($res) = DbConn::getInstance()->fetch_row($re_custom);
    }
    return $res;
}
Ejemplo n.º 29
0
 public function __construct($id_course = 0, $id_date = 0)
 {
     require_once _lms_ . '/lib/lib.date.php';
     require_once _lms_ . '/lib/lib.course.php';
     $this->id_course = $id_course;
     $this->id_date = $id_date;
     $this->db = DbConn::getInstance();
     $this->classroom_man = new DateManager();
     $this->course_man = new Man_Course();
     $this->acl_man =& Docebo::user()->getAclManager();
 }
Ejemplo n.º 30
0
 public static function getConn()
 {
     try {
         if (!self::$conn) {
             self::$conn = new PDO('mysql:dbname=' . self::DB_NAME . ';host=' . self::DB_HOST . ';', self::DB_USER, self::DB_PASS);
         }
     } catch (PDOException $e) {
         echo "An error occured: " . $e->getMessage();
     }
     return self::$conn;
 }