function setApplets_User($arrIDs_DAU, $user)
 {
     global $arrConf;
     $dsn = "sqlite3:///{$arrConf['elastix_dbdir']}/dashboard.db";
     $pDB = new paloDB($dsn);
     if (is_array($arrIDs_DAU) & count($arrIDs_DAU) > 0) {
         $pDB2 = new paloDB($arrConf['elastix_dsn']['elastix']);
         $pACL = new paloACL($pDB2);
         if ($pACL->isUserSuperAdmin($user)) {
             $typeUser = "******";
         } else {
             $typeUser = "******";
         }
         $pDB->beginTransaction();
         // Parte 1: Elimino todas las actuales
         $query1 = " delete from activated_applet_by_user \n                        where username=? and id_dabu in (select id from default_applet_by_user where username=?)";
         $result1 = $pDB->genQuery($query1, array($user, $typeUser));
         if ($result1 == FALSE) {
             $this->errMsg = $pDB->errMsg;
             $pDB->rollBack();
             return false;
         }
         // Parte 2: Inserto todas las checked
         foreach ($arrIDs_DAU as $key => $value) {
             $query2 = "insert into activated_applet_by_user (id_dabu, order_no, username) values (?,?,?)";
             $result2 = $pDB->genQuery($query2, array($value, $key + 1, $user));
             if ($result2 == FALSE) {
                 $this->errMsg = $pDB->errMsg;
                 $pDB->rollBack();
                 return false;
             }
         }
         $pDB->commit();
     }
     return true;
 }
Esempio n. 2
0
function saveNeoToggleTabByUser($menu, $action_status)
{
    include_once "libs/paloSantoACL.class.php";
    $arrResult['status'] = FALSE;
    $arrResult['msg'] = _tr("Please your session id does not exist. Refresh the browser and try again.");
    if ($menu != "") {
        $user = isset($_SESSION['elastix_user']) ? $_SESSION['elastix_user'] : "";
        global $arrConf;
        $pdbACL = new paloDB("sqlite3:///{$arrConf['elastix_dbdir']}/acl.db");
        $pACL = new paloACL($pdbACL);
        $uid = $pACL->getIdUser($user);
        if ($uid !== FALSE) {
            $exist = false;
            $togglesTabs = "SELECT * FROM acl_user_shortcut WHERE id_user = ? AND type = 'NeoToggleTab'";
            $arr_result1 = $pdbACL->getFirstRowQuery($togglesTabs, TRUE, array($uid));
            if ($arr_result1 !== FALSE && count($arr_result1) > 0) {
                $exist = true;
            }
            if ($exist) {
                $pdbACL->beginTransaction();
                $query = "UPDATE acl_user_shortcut SET description = ? WHERE id_user = ? AND type = ?";
                $r = $pdbACL->genQuery($query, array($action_status, $uid, "NeoToggleTab"));
                if (!$r) {
                    $pdbACL->rollBack();
                    $arrResult['status'] = FALSE;
                    $arrResult['msg'] = _tr("Request cannot be completed. Please try again or contact with your elastix administrator and notify the next error: ") . $pdbACL->errMsg;
                    return $arrResult;
                } else {
                    $pdbACL->commit();
                    $arrResult['status'] = TRUE;
                    $arrResult['msg'] = _tr("Request has been sent.");
                    return $arrResult;
                }
            } else {
                $pdbACL->beginTransaction();
                $query = "INSERT INTO acl_user_shortcut(id_user, id_resource, type, description) VALUES(?, ?, ?, ?)";
                $r = $pdbACL->genQuery($query, array($uid, $uid, "NeoToggleTab", $action_status));
                if (!$r) {
                    $pdbACL->rollBack();
                    $arrResult['status'] = FALSE;
                    $arrResult['msg'] = _tr("Request cannot be completed. Please try again or contact with your elastix administrator and notify the next error: ") . $pdbACL->errMsg;
                    return $arrResult;
                } else {
                    $pdbACL->commit();
                    $arrResult['status'] = TRUE;
                    $arrResult['msg'] = _tr("Request has been sent.");
                    return $arrResult;
                }
            }
        }
    }
    return $arrResult;
}