Esempio n. 1
0
 function edit_privilege_one($table, $id)
 {
     if ($_SESSION['user_type'] == 1) {
         return "1";
     }
     $ob1 = new connect();
     if ($table == "users") {
         $sql = mysqli_query($ob1->dbcon(), "SELECT * FROM `{$table}` WHERE  `user_id` = '{$id}'");
     } else {
         $sql = mysqli_query($ob1->dbcon(), "SELECT * FROM `{$table}` WHERE  `id` = '{$id}'");
     }
     if ($row = mysqli_fetch_array($sql)) {
         if ($table != "accounts") {
             //check if this assigned to this user
             if ($row['assignedto'] == $_SESSION['user_id']) {
                 return "1";
             }
         }
         if ($_SESSION['_' . $row['group']][$table] == 2 || $_SESSION['_' . $row['group']][$table] == 3 || $_SESSION['_' . $row['group']][$table] == 6 || $_SESSION['_' . $row['group']][$table] == 7) {
             return "1";
         } else {
             return "0";
         }
     }
 }
Esempio n. 2
0
 function user_privilage($pri)
 {
     // to check peivilages using privilage id
     $ob1 = new connect();
     $sql = "SELECT * FROM user_group WHERE id='{$pri}' ";
     return mysqli_query($ob1->dbcon(), $sql);
 }
Esempio n. 3
0
 function user_can_delete_groups($table)
 {
     $loguser = $_SESSION['user_id'];
     $ob1 = new connect();
     // $sql=" SELECT * FROM `user_group` WHERE `user_id` = '$loguser' AND ($table > '2' OR $table > '3' OR $table > '6' OR $table > '7' )";
     if ($_SESSION['user_type'] == '1') {
         $sql = "SELECT * FROM groups WHERE deleted = '0' ";
     } else {
         $sql = "SELECT user_group.*,groups.group_name FROM user_group\n                           LEFT OUTER JOIN groups ON user_group.group_id = groups.group_id\n                           WHERE user_group.user_id = '{$loguser}' AND (user_group.{$table} ='1' OR user_group.{$table} = '3' OR user_group.{$table} = '5' OR user_group.{$table} = '7' )";
     }
     // echo $sql;
     return mysqli_query($ob1->dbcon(), $sql);
 }
Esempio n. 4
0
 function countrows1($tablename, $field, $value)
 {
     $ob1 = new connect();
     $ids = join(',', $_SESSION['user_groups']);
     $sql = mysqli_query($ob1->dbcon(), "SELECT COUNT(id) AS `count` FROM `{$tablename}` WHERE `deleted` = '0' AND `{$field}`='{$value}' AND `group` IN ({$ids})");
     //  this use for users
     if ($_SESSION['user_type'] == '1') {
         $sql = mysqli_query($ob1->dbcon(), "SELECT COUNT(id) AS `count` FROM `{$tablename}` WHERE `deleted` = '0' AND `{$field}`='{$value}' ");
         // this use for admin
     }
     $row = mysqli_fetch_assoc($sql);
     return $row['count'];
 }
Esempio n. 5
0
 function viewdatalimit_contact($limit, $offset, $contact)
 {
     $ob1 = new connect();
     $ids = join(',', $_SESSION['user_groups']);
     // user groups
     $sql = "SELECT call_log.* , users.user_name AS owner, modi.user_name AS modified, assi.user_name AS assigned, contacts.contact_firstname, groups.group_name, accounts.account_name\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tFROM call_log INNER JOIN users ON\n\t\t                                                          call_log.call_owner=users.user_id\n\t\t                                                INNER JOIN contacts ON\n\t\t                                                \t\t  call_log.contact_id=contacts.id\n\t\t                                                LEFT OUTER JOIN users AS modi ON\n\t\t                                                \t\t  call_log.call_modified_by=modi.user_id\n\t\t                                                LEFT OUTER JOIN users AS assi ON\n\t\t                                                \t\t  call_log.assignedto=assi.user_id\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tINNER JOIN groups ON\n\t\t\t\t\t\t\t\t                                  call_log.group_id=groups.group_id\n\t\t\t\t\t\t\t\t                        LEFT OUTER JOIN accounts ON\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t  contacts.contact_account = accounts.id\n\t\t                                                \t\t             WHERE call_log.deleted = '0' AND call_log.cli = '{$contact}' ";
     if ($_SESSION['user_type'] != 1) {
         $sql .= "AND call_log.group IN ({$ids}) ";
     }
     // if($_SESSION['user_type']!='1'){     // view call log filter with group
     //   	$sql.=" AND groups.group_id='$_SESSION[user_group]' ";
     // }
     $sql .= "ORDER BY `id` DESC LIMIT {$limit} OFFSET {$offset}";
     //set lime and offset
     // echo $sql;
     return mysqli_query($ob1->dbcon(), $sql);
 }