コード例 #1
0
ファイル: elastixutils.lib.php プロジェクト: hardikk/HNH
/**
 * Funcion que se encarga de guardar o editar una nota de tipo sticky note.
 *
 * @return array con la informacion como mensaje y estado de resultado
 * @param string $menu nombre del menu al cual se le va a agregar la nota
 * @param string $description contenido de la nota que se desea agregar o editar
 *
 * @author Eduardo Cueva
 * @author ecueva@palosanto.com
 */
function saveStickyNote($menu, $description, $popup)
{
    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);
        $id_resource = $pACL->getResourceId($menu);
        $uid = $pACL->getIdUser($user);
        $date_edit = date("Y-m-d h:i:s");
        if ($uid !== FALSE) {
            $exist = false;
            $query = "SELECT * FROM sticky_note WHERE id_user = ? AND id_resource = ?";
            $arr_result1 = $pdbACL->getFirstRowQuery($query, TRUE, array($uid, $id_resource));
            if ($arr_result1 !== FALSE && count($arr_result1) > 0) {
                $exist = true;
            }
            if ($exist) {
                $pdbACL->beginTransaction();
                $query = "UPDATE sticky_note SET description = ?, date_edit = ?, auto_popup = ? WHERE id_user = ? AND id_resource = ?";
                $r = $pdbACL->genQuery($query, array($description, $date_edit, $popup, $uid, $id_resource));
                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'] = "";
                    return $arrResult;
                }
            } else {
                $pdbACL->beginTransaction();
                $query = "INSERT INTO sticky_note(id_user, id_resource, date_edit, description, auto_popup) VALUES(?, ?, ?, ?, ?)";
                $r = $pdbACL->genQuery($query, array($uid, $id_resource, $date_edit, $description, $popup));
                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'] = "";
                    return $arrResult;
                }
            }
        }
    }
    return $arrResult;
}
コード例 #2
0
ファイル: misc.lib.php プロジェクト: hardikk/HNH
/**
 * Funcion que se encarga obtener un sticky note.
 *
 * @return array con la informacion como mensaje y estado de resultado
 * @param string $menu nombre del menu al cual se le va a agregar la nota
 *
 * @author Eduardo Cueva
 * @author ecueva@palosanto.com
 */
function getStickyNote($pdbACL, $uid, $menu)
{
    require_once 'libs/paloSantoACL.class.php';
    $arrResult = array('status' => FALSE, 'msg' => 'no_data', 'data' => _tr("Click here to leave a note."));
    $pACL = new paloACL($pdbACL);
    $tupla = $pdbACL->getFirstRowQuery('SELECT * FROM sticky_note WHERE id_user = ? AND id_resource = ?', TRUE, array($uid, $pACL->getResourceId($menu)));
    if (is_array($tupla) && count($tupla) > 0) {
        $arrResult = array('status' => TRUE, 'msg' => '', 'data' => $tupla['description'], 'popup' => $tupla['auto_popup']);
    }
    return $arrResult;
}